From 1e31b4f929c564f426c6b51ab954eae8cc1e547d Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 20:19:43 -0400 Subject: [PATCH 001/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] [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/801] 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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] 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/801] 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/801] [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/801] [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/801] [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/801] 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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] 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/801] [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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] [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/801] [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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] 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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] 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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] [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/801] 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/801] 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/801] [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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] - 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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/801] 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 f5ab5fab2bc462cd47bbc3e4ab766aab2798d558 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 19 Aug 2022 11:24:58 -0500 Subject: [PATCH 570/801] Fix not swapping buffers because out of cmd buffer space Reserve space for end of list and swap buffer commands. These are absolutely required and cannot be dropped. Dropping swap buffer command causes screen to not update and possible crash from drawsurf buffer overflow if not enough cmd buffer space for many continous frames. Fix reserved size for swap buffer command being too small on x86_64 Replace 4 with sizeof( int ) in R_GetCommandBufferReserved https://github.com/ioquake/ioq3/commit/8531162bd9761ce49016b3738ddf394b28f8e462 https://github.com/ioquake/ioq3/commit/81e2b6c0cf1bf8f7cea18035d24edb1ff8ae36ff https://github.com/ioquake/ioq3/commit/41f83ac8b0a5e6e9b1a80be9ec6f8c143944201f Also make sure all renderer commands do not function when the renderer is not loaded (tr.registered) Simplify the setColor(NULL) command Fix incorrect null pointer check on an array Remove unused variables in SP tr_cmds Doubled the size of renderer command buffers to match other engines. Fixes and replaces/supersedes #1109 --- code/rd-vanilla/tr_cmds.cpp | 66 ++++++++++++++++++++++------------ code/rd-vanilla/tr_local.h | 3 +- code/rd-vanilla/tr_shader.cpp | 2 +- codemp/rd-dedicated/tr_local.h | 1 - codemp/rd-vanilla/tr_cmds.cpp | 51 ++++++++++++++++++-------- codemp/rd-vanilla/tr_local.h | 3 +- 6 files changed, 83 insertions(+), 43 deletions(-) diff --git a/code/rd-vanilla/tr_cmds.cpp b/code/rd-vanilla/tr_cmds.cpp index 7d17c20d4d..04ad9bdb4e 100644 --- a/code/rd-vanilla/tr_cmds.cpp +++ b/code/rd-vanilla/tr_cmds.cpp @@ -89,9 +89,6 @@ void R_PerformanceCounters( void ) { R_IssueRenderCommands ==================== */ -int c_blockedOnRender; -int c_blockedOnMain; - void R_IssueRenderCommands( qboolean runPerformanceCounters ) { renderCommandList_t *cmdList; @@ -134,23 +131,21 @@ void R_IssuePendingRenderCommands( void ) { /* ============ -R_GetCommandBuffer +R_GetCommandBufferReserved 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 *)); - - assert(cmdList); + 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 ) { - Com_Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes ); + 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 return NULL; @@ -161,6 +156,17 @@ void *R_GetCommandBuffer( int bytes ) { return cmdList->cmds + cmdList->used - bytes; } +/* +============ +R_GetCommandBuffer + +make sure there is enough command space +============ +*/ +static void *R_GetCommandBuffer( int bytes ) { + return R_GetCommandBufferReserved( bytes, PAD( sizeof( swapBuffersCommand_t ), sizeof(void *) ) ); +} + /* ============= @@ -203,18 +209,14 @@ void RE_SetColor( const float *rgba ) { return; } cmd->commandId = RC_SET_COLOR; - if ( rgba ) { - cmd->color[0] = rgba[0]; - cmd->color[1] = rgba[1]; - cmd->color[2] = rgba[2]; - cmd->color[3] = rgba[3]; - return; + if ( !rgba ) { + rgba = colorWhite; } + cmd->color[0] = rgba[0]; + cmd->color[1] = rgba[1]; + cmd->color[2] = rgba[2]; + cmd->color[3] = rgba[3]; - cmd->color[0] = 1; - cmd->color[1] = 1; - cmd->color[2] = 1; - cmd->color[3] = 1; } @@ -227,6 +229,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; + } cmd = (stretchPicCommand_t *) R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; @@ -252,6 +257,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; @@ -278,6 +286,10 @@ 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; @@ -314,6 +326,10 @@ void RE_RenderWorldEffects(void) { setModeCommand_t *cmd; + if (!tr.registered) { + return; + } + cmd = (setModeCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; @@ -330,6 +346,10 @@ void RE_Scissor ( float x, float y, float w, float h) { scissorCommand_t *cmd; + if (!tr.registered) { + return; + } + cmd = (scissorCommand_t *) R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; @@ -350,7 +370,7 @@ for each RE_EndFrame ==================== */ void RE_BeginFrame( stereoFrame_t stereoFrame ) { - drawBufferCommand_t *cmd; + drawBufferCommand_t *cmd = NULL; if ( !tr.registered ) { return; @@ -472,7 +492,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; } diff --git a/code/rd-vanilla/tr_local.h b/code/rd-vanilla/tr_local.h index 27cb88fe7d..c9e745aacd 100644 --- a/code/rd-vanilla/tr_local.h +++ b/code/rd-vanilla/tr_local.h @@ -1694,7 +1694,7 @@ RENDERER BACK END COMMAND QUEUE ============================================================= */ -#define MAX_RENDER_COMMANDS 0x40000 +#define MAX_RENDER_COMMANDS 0x80000 typedef struct { byte cmds[MAX_RENDER_COMMANDS]; @@ -1800,7 +1800,6 @@ typedef struct { extern backEndData_t *backEndData; -void *R_GetCommandBuffer( int bytes ); void RB_ExecuteRenderCommands( const void *data ); void R_IssuePendingRenderCommands( void ); diff --git a/code/rd-vanilla/tr_shader.cpp b/code/rd-vanilla/tr_shader.cpp index 12f12feda1..c50a17e42e 100644 --- a/code/rd-vanilla/tr_shader.cpp +++ b/code/rd-vanilla/tr_shader.cpp @@ -3372,7 +3372,7 @@ static inline const int *R_FindLightmap( const int *lightmapIndex ) return lightmapIndex; // bail if no world dir - if( tr.worldDir == NULL || !*tr.worldDir ) + if( tr.worldDir[0] == '\0' ) { return lightmapsVertex; } diff --git a/codemp/rd-dedicated/tr_local.h b/codemp/rd-dedicated/tr_local.h index 2207419839..8a721e1dd4 100644 --- a/codemp/rd-dedicated/tr_local.h +++ b/codemp/rd-dedicated/tr_local.h @@ -1809,7 +1809,6 @@ extern int max_polyverts; extern backEndData_t *backEndData; -void *R_GetCommandBuffer( int bytes ); void RB_ExecuteRenderCommands( const void *data ); void R_IssuePendingRenderCommands( void ); diff --git a/codemp/rd-vanilla/tr_cmds.cpp b/codemp/rd-vanilla/tr_cmds.cpp index 203f782ec3..59433b3aa2 100644 --- a/codemp/rd-vanilla/tr_cmds.cpp +++ b/codemp/rd-vanilla/tr_cmds.cpp @@ -90,7 +90,7 @@ void R_IssueRenderCommands( qboolean runPerformanceCounters ) { renderCommandList_t *cmdList; cmdList = &backEndData->commands; - assert(cmdList); + // add an end-of-list command byteAlias_t *ba = (byteAlias_t *)&cmdList->cmds[cmdList->used]; ba->ui = RC_END_OF_LIST; @@ -128,23 +128,21 @@ void R_IssuePendingRenderCommands( void ) { /* ============ -R_GetCommandBuffer +R_GetCommandBufferReserved 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 *)); - - assert(cmdList); + 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 ) { - Com_Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes ); + 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 return NULL; @@ -155,6 +153,17 @@ void *R_GetCommandBuffer( int bytes ) { return cmdList->cmds + cmdList->used - bytes; } +/* +============ +R_GetCommandBuffer + +make sure there is enough command space +============ +*/ +static void *R_GetCommandBuffer( int bytes ) { + return R_GetCommandBufferReserved( bytes, PAD( sizeof( swapBuffersCommand_t ), sizeof(void *) ) ); +} + /* ============= @@ -198,15 +207,13 @@ void RE_SetColor( const float *rgba ) { } 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]; + } @@ -219,6 +226,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; + } cmd = (stretchPicCommand_t *) R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; @@ -244,6 +254,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; @@ -270,6 +283,10 @@ 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; @@ -291,6 +308,9 @@ void RE_RenderWorldEffects(void) { drawBufferCommand_t *cmd; + if (!tr.registered) { + return; + } cmd = (drawBufferCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; @@ -302,6 +322,9 @@ void RE_RenderAutoMap(void) { drawBufferCommand_t *cmd; + if (!tr.registered) { + return; + } cmd = (drawBufferCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { @@ -319,7 +342,7 @@ for each RE_EndFrame ==================== */ void RE_BeginFrame( stereoFrame_t stereoFrame ) { - drawBufferCommand_t *cmd; + drawBufferCommand_t *cmd = NULL; if ( !tr.registered ) { return; @@ -442,7 +465,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; } diff --git a/codemp/rd-vanilla/tr_local.h b/codemp/rd-vanilla/tr_local.h index 3714069d62..7cbfbe6c19 100644 --- a/codemp/rd-vanilla/tr_local.h +++ b/codemp/rd-vanilla/tr_local.h @@ -1730,7 +1730,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]; @@ -1833,7 +1833,6 @@ extern int max_polyverts; extern backEndData_t *backEndData; -void *R_GetCommandBuffer( int bytes ); void RB_ExecuteRenderCommands( const void *data ); void R_IssuePendingRenderCommands( void ); From 9671dd7224e0a04b5be611a2c831ed43d1ebd687 Mon Sep 17 00:00:00 2001 From: Tobias Heider Date: Sat, 7 May 2022 00:21:40 +0200 Subject: [PATCH 571/801] Fix typo that causes comparison to always evaluate to false. --- code/game/g_active.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/g_active.cpp b/code/game/g_active.cpp index f79a8c2b72..9805ce95b4 100644 --- a/code/game/g_active.cpp +++ b/code/game/g_active.cpp @@ -2905,7 +2905,7 @@ qboolean G_CheckClampUcmd( gentity_t *ent, usercmd_t *ucmd ) } } if ( ent->client->ps.legsAnimTimer <= 1150 - && ent->client->ps.legsAnimTimer > 10500 ) + && ent->client->ps.legsAnimTimer > 1050 ) { TIMER_Set( ent, "grappleDamageDebounce", 150 ); if ( ent->s.number < MAX_CLIENTS ) From fdf206ed429e7ad8a51a1b2ca49385f2ae37d672 Mon Sep 17 00:00:00 2001 From: Razish Date: Tue, 15 Jun 2021 23:21:26 +1000 Subject: [PATCH 572/801] [Shared] fix s_initSound 0 crash --- code/client/snd_ambient.cpp | 183 ++++++++++++++++----------------- code/client/snd_dma.cpp | 74 +++++++------- code/client/snd_local.h | 20 ++-- codemp/client/snd_ambient.cpp | 184 ++++++++++++++++++---------------- codemp/client/snd_dma.cpp | 80 +++++++-------- codemp/client/snd_local.h | 23 ++--- 6 files changed, 280 insertions(+), 284 deletions(-) diff --git a/code/client/snd_ambient.cpp b/code/client/snd_ambient.cpp index 66143fbe75..6e2c612d3d 100644 --- a/code/client/snd_ambient.cpp +++ b/code/client/snd_ambient.cpp @@ -788,10 +788,8 @@ AS_AddPrecacheEntry ------------------------- */ -void AS_AddPrecacheEntry( const char *name ) -{ - if (!pMap) //s_initsound 0 probably - { +void AS_AddPrecacheEntry( const char *name ) { + if ( !pMap ) { // s_initsound 0 probably return; } if (!Q_stricmp(name,"#clear")) @@ -816,10 +814,10 @@ Called on the client side to load and precache all the ambient sound sets void AS_ParseSets( void ) { - cvar_t *cv = Cvar_Get ("s_initsound", "1", 0); - if ( !cv->integer ) { + if ( !s_initsound->integer ) { return; } + AS_Init(); //Parse all the sets @@ -913,47 +911,47 @@ Fades volumes up or down depending on the action being taken on them. ------------------------- */ -static void AS_UpdateSetVolumes( void ) -{ - ambientSet_t *old, *current; - float scale; - int deltaTime; +static void AS_UpdateSetVolumes( void ) { + if ( !aSets ) { + return; + } //Get the sets and validate them - current = aSets->GetSet( currentSet ); - - if ( current == NULL ) + ambientSet_t *current = aSets->GetSet( currentSet ); + if ( !current ) { return; + } - if ( current->masterVolume < MAX_SET_VOLUME ) - { + float scale; + int deltaTime; + if ( current->masterVolume < MAX_SET_VOLUME ) { deltaTime = cls.realtime - current->fadeTime; scale = ((float)(deltaTime)/(float)(crossDelay)); current->masterVolume = (int)((scale) * (float)MAX_SET_VOLUME); } - if ( current->masterVolume > MAX_SET_VOLUME ) + if ( current->masterVolume > MAX_SET_VOLUME ) { current->masterVolume = MAX_SET_VOLUME; + } //Only update the old set if it's still valid - if ( oldSet == -1 ) + if ( oldSet == -1 ) { return; + } - old = aSets->GetSet( oldSet ); - - if ( old == NULL ) + ambientSet_t *old = aSets->GetSet( oldSet ); + if ( !old ) { return; + } //Update the volumes - if ( old->masterVolume > 0 ) - { + if ( old->masterVolume > 0 ) { deltaTime = cls.realtime - old->fadeTime; scale = ((float)(deltaTime)/(float)(crossDelay)); old->masterVolume = MAX_SET_VOLUME - (int)((scale) * (float)MAX_SET_VOLUME); } - if ( old->masterVolume <= 0 ) - { + if ( old->masterVolume <= 0 ) { old->masterVolume = 0; oldSet = -1; } @@ -967,26 +965,25 @@ Does internal maintenance to keep track of changing sets. ------------------------- */ -static void AS_UpdateCurrentSet( int id ) -{ - ambientSet_t *old, *current; +static void AS_UpdateCurrentSet( int id ) { + if ( !aSets ) { + return; + } //Check for a change - if ( id != currentSet ) - { + if ( id != currentSet ) { //This is new, so start the fading oldSet = currentSet; currentSet = id; - old = aSets->GetSet( oldSet ); - current = aSets->GetSet( currentSet ); + ambientSet_t *current = aSets->GetSet( currentSet ); // Ste, I just put this null check in for now, not sure if there's a more graceful way to exit this function - dmv - if( !current ) - { + if ( !current ) { return; } - if ( old ) - { + + ambientSet_t *old = aSets->GetSet( oldSet ); + if ( old ) { old->masterVolume = MAX_SET_VOLUME; old->fadeTime = cls.realtime; } @@ -1010,42 +1007,42 @@ Alters lastTime to reflect the time updates. ------------------------- */ -static void AS_PlayLocalSet( vec3_t listener_origin, vec3_t origin, ambientSet_t *set, int entID, int *lastTime ) -{ - unsigned char volume; - vec3_t dir; - float volScale, dist, distScale; - int time = cl.serverTime; - +static void AS_PlayLocalSet( vec3_t listener_origin, vec3_t origin, const ambientSet_t *set, int entID, int *lastTime ) { //Make sure it's valid - if ( set == NULL ) + if ( !set ) { return; + } + vec3_t dir; VectorSubtract( origin, listener_origin, dir ); - dist = VectorLength( dir ); + float dist = VectorLength( dir ); //Determine the volume based on distance (NOTE: This sits on top of what SpatializeOrigin does) - distScale = ( dist < ( set->radius * 0.5f ) ) ? 1 : ( set->radius - dist ) / ( set->radius * 0.5f ); - volume = ( distScale > 1.0f || distScale < 0.0f ) ? 0 : (unsigned char) ( set->masterVolume * distScale ); + float distScale = ( dist < ( set->radius * 0.5f ) ) ? 1 : ( set->radius - dist ) / ( set->radius * 0.5f ); + unsigned char volume = ( distScale > 1.0f || distScale < 0.0f ) ? 0 : (unsigned char) ( set->masterVolume * distScale ); //Add the looping sound - if ( set->loopedWave ) + if ( set->loopedWave ) { S_AddAmbientLoopingSound( origin, volume, set->loopedWave ); + } //Check the time to start another one-shot subwave - if ( ( time - *lastTime ) < ( ( Q_irand( set->time_start, set->time_end ) ) * 1000 ) ) + int time = cl.serverTime; + if ( ( time - *lastTime ) < ( ( Q_irand( set->time_start, set->time_end ) ) * 1000 ) ) { return; + } //Update the time *lastTime = time; //Scale the volume ranges for the subwaves based on the overall master volume - volScale = (float) volume / (float) MAX_SET_VOLUME; + float volScale = (float) volume / (float) MAX_SET_VOLUME; volume = (unsigned char) Q_irand( (int)(volScale*set->volRange_start), (int)(volScale*set->volRange_end) ); //Add the random subwave - if ( set->numSubWaves ) + if ( set->numSubWaves ) { S_StartAmbientSound( origin, entID, volume, set->subWaves[Q_irand( 0, set->numSubWaves-1)] ); + } } /* @@ -1057,38 +1054,39 @@ Alters lastTime to reflect the time updates. ------------------------- */ -static void AS_PlayAmbientSet( vec3_t origin, ambientSet_t *set, int *lastTime ) -{ - unsigned char volume; - float volScale; - int time = cls.realtime; - +static void AS_PlayAmbientSet( vec3_t origin, const ambientSet_t *set, int *lastTime ) { //Make sure it's valid - if ( set == NULL ) + if ( !set ) { return; + } //Add the looping sound - if ( set->loopedWave ) + if ( set->loopedWave ) { S_AddAmbientLoopingSound( origin, (unsigned char) set->masterVolume, set->loopedWave ); + } //Check the time to start another one-shot subwave - if ( ( time - *lastTime ) < ( ( Q_irand( set->time_start, set->time_end ) ) * 1000 ) ) + int time = cls.realtime; + if ( ( time - *lastTime ) < ( ( Q_irand( set->time_start, set->time_end ) ) * 1000 ) ) { return; + } //Update the time *lastTime = time; //Scale the volume ranges for the subwaves based on the overall master volume - volScale = (float) set->masterVolume / (float) MAX_SET_VOLUME; - volume = Q_irand( (int)(volScale*set->volRange_start), (int)(volScale*set->volRange_end) ); + float volScale = (float) set->masterVolume / (float) MAX_SET_VOLUME; + unsigned char volume = Q_irand( (int)(volScale*set->volRange_start), (int)(volScale*set->volRange_end) ); //Allow for softer noises than the masterVolume, but not louder - if ( volume > set->masterVolume ) + if ( volume > set->masterVolume ) { volume = set->masterVolume; + } //Add the random subwave - if ( set->numSubWaves ) + if ( set->numSubWaves ) { S_StartAmbientSound( origin, 0, volume, set->subWaves[Q_irand( 0, set->numSubWaves-1)] ); + } } /* @@ -1099,29 +1097,28 @@ Does maintenance and plays the ambient sets (two if crossfading) ------------------------- */ -void S_UpdateAmbientSet ( const char *name, vec3_t origin ) -{ - ambientSet_t *current, *old; - if (aSets == NULL) - { +void S_UpdateAmbientSet( const char *name, vec3_t origin ) { + if ( !aSets ) { return; } - ambientSet_t *set = aSets->GetSet( name ); - if ( set == NULL ) + const ambientSet_t *set = aSets->GetSet( name ); + if ( !set ) { return; + } //Update the current and old set for crossfading AS_UpdateCurrentSet( set->id ); - current = aSets->GetSet( currentSet ); - old = aSets->GetSet( oldSet ); - - if ( current ) + const ambientSet_t *current = aSets->GetSet( currentSet ); + if ( current ) { AS_PlayAmbientSet( origin, set, ¤tSetTime ); + } - if ( old ) + const ambientSet_t *old = aSets->GetSet( oldSet ); + if ( old ) { AS_PlayAmbientSet( origin, old, &oldSetTime ); + } } /* @@ -1130,20 +1127,18 @@ S_AddLocalSet ------------------------- */ -int S_AddLocalSet( const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time ) -{ - ambientSet_t *set; - int currentTime = 0; - - set = aSets->GetSet( name ); - - if ( set == NULL ) +int S_AddLocalSet( const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time ) { + if ( !aSets ) { return cl.serverTime; + } - currentTime = time; + const ambientSet_t *set = aSets->GetSet( name ); + if ( !set ) { + return cl.serverTime; + } + int currentTime = time; AS_PlayLocalSet( listener_origin, origin, set, entID, ¤tTime ); - return currentTime; } @@ -1153,18 +1148,16 @@ AS_GetBModelSound ------------------------- */ -sfxHandle_t AS_GetBModelSound( const char *name, int stage ) -{ - ambientSet_t *set; - - set = aSets->GetSet( name ); - - if ( set == NULL ) +sfxHandle_t AS_GetBModelSound( const char *name, int stage ) { + if ( !aSets ) { return -1; + } //Stage must be within a valid range - if ( ( stage > ( set->numSubWaves - 1 ) ) || ( stage < 0 ) ) + const ambientSet_t *set = aSets->GetSet( name ); + if ( !set || stage < 0 || stage > (set->numSubWaves - 1) ) { return -1; + } - return set->subWaves[ stage ]; + return set->subWaves[stage]; } diff --git a/code/client/snd_dma.cpp b/code/client/snd_dma.cpp index 5e9a5e36f9..3cf06daff7 100644 --- a/code/client/snd_dma.cpp +++ b/code/client/snd_dma.cpp @@ -173,23 +173,24 @@ int s_numSfx; #define LOOP_HASH 128 static sfx_t *sfxHash[LOOP_HASH]; -cvar_t *s_volume; -cvar_t *s_volumeVoice; -cvar_t *s_testsound; -cvar_t *s_khz; -cvar_t *s_allowDynamicMusic; -cvar_t *s_show; -cvar_t *s_mixahead; -cvar_t *s_mixPreStep; -cvar_t *s_musicVolume; -cvar_t *s_separation; -cvar_t *s_lip_threshold_1; -cvar_t *s_lip_threshold_2; -cvar_t *s_lip_threshold_3; -cvar_t *s_lip_threshold_4; -cvar_t *s_language; // note that this is distinct from "g_language" -cvar_t *s_dynamix; -cvar_t *s_debugdynamic; +cvar_t *s_allowDynamicMusic; +cvar_t *s_debugdynamic; +cvar_t *s_dynamix; +cvar_t *s_initsound; +cvar_t *s_khz; +cvar_t *s_language; // note that this is distinct from "g_language" +cvar_t *s_lip_threshold_1; +cvar_t *s_lip_threshold_2; +cvar_t *s_lip_threshold_3; +cvar_t *s_lip_threshold_4; +cvar_t *s_mixahead; +cvar_t *s_mixPreStep; +cvar_t *s_musicVolume; +cvar_t *s_separation; +cvar_t *s_show; +cvar_t *s_testsound; +cvar_t *s_volume; +cvar_t *s_volumeVoice; typedef struct { @@ -443,34 +444,31 @@ S_Init ================ */ void S_Init( void ) { - cvar_t *cv; qboolean r; Com_Printf("\n------- sound initialization -------\n"); - s_volume = Cvar_Get ("s_volume", "0.5", CVAR_ARCHIVE); - s_volumeVoice= Cvar_Get ("s_volumeVoice", "1.0", CVAR_ARCHIVE); - s_musicVolume = Cvar_Get ("s_musicvolume", "0.25", CVAR_ARCHIVE); - s_separation = Cvar_Get ("s_separation", "0.5", CVAR_ARCHIVE); - s_khz = Cvar_Get ("s_khz", "44", CVAR_ARCHIVE|CVAR_LATCH); - s_allowDynamicMusic = Cvar_Get ("s_allowDynamicMusic", "1", CVAR_ARCHIVE_ND); - s_mixahead = Cvar_Get ("s_mixahead", "0.2", CVAR_ARCHIVE); - - s_mixPreStep = Cvar_Get ("s_mixPreStep", "0.05", CVAR_ARCHIVE); - s_show = Cvar_Get ("s_show", "0", CVAR_CHEAT); - s_testsound = Cvar_Get ("s_testsound", "0", CVAR_CHEAT); - s_debugdynamic = Cvar_Get("s_debugdynamic","0", 0); - s_lip_threshold_1 = Cvar_Get("s_threshold1" , "0.3",0); - s_lip_threshold_2 = Cvar_Get("s_threshold2" , "4",0); - s_lip_threshold_3 = Cvar_Get("s_threshold3" , "6",0); - s_lip_threshold_4 = Cvar_Get("s_threshold4" , "8",0); - - s_language = Cvar_Get("s_language","english",CVAR_ARCHIVE | CVAR_NORESTART); + s_allowDynamicMusic = Cvar_Get( "s_allowDynamicMusic", "1", CVAR_ARCHIVE_ND ); + s_debugdynamic = Cvar_Get( "s_debugdynamic", "0", 0 ); + s_initsound = Cvar_Get( "s_initsound", "1", CVAR_ARCHIVE | CVAR_LATCH ); + s_khz = Cvar_Get( "s_khz", "44", CVAR_ARCHIVE | CVAR_LATCH ); + s_language = Cvar_Get( "s_language", "english", CVAR_ARCHIVE | CVAR_NORESTART ); + s_lip_threshold_1 = Cvar_Get( "s_threshold1", "0.3", 0 ); + s_lip_threshold_2 = Cvar_Get( "s_threshold2", "4", 0 ); + s_lip_threshold_3 = Cvar_Get( "s_threshold3", "6", 0 ); + s_lip_threshold_4 = Cvar_Get( "s_threshold4", "8", 0 ); + s_mixahead = Cvar_Get( "s_mixahead", "0.2", CVAR_ARCHIVE ); + s_mixPreStep = Cvar_Get( "s_mixPreStep", "0.05", CVAR_ARCHIVE ); + s_musicVolume = Cvar_Get( "s_musicvolume", "0.25", CVAR_ARCHIVE ); + s_separation = Cvar_Get( "s_separation", "0.5", CVAR_ARCHIVE ); + s_show = Cvar_Get( "s_show", "0", CVAR_CHEAT ); + s_testsound = Cvar_Get( "s_testsound", "0", CVAR_CHEAT ); + s_volume = Cvar_Get( "s_volume", "0.5", CVAR_ARCHIVE ); + s_volumeVoice = Cvar_Get( "s_volumeVoice", "1.0", CVAR_ARCHIVE ); MP3_InitCvars(); - cv = Cvar_Get ("s_initsound", "1", 0); - if ( !cv->integer ) { + if ( !s_initsound->integer ) { s_soundStarted = 0; // needed in case you set s_initsound to 0 midgame then snd_restart (div0 err otherwise later) Com_Printf ("not initializing.\n"); Com_Printf("------------------------------------\n"); diff --git a/code/client/snd_local.h b/code/client/snd_local.h index cdc66e0127..6a4dcff258 100644 --- a/code/client/snd_local.h +++ b/code/client/snd_local.h @@ -198,16 +198,16 @@ extern dma_t dma; extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES]; portable_samplepair_t *S_GetRawSamplePointer(); // TA added this, but it just returns the s_rawsamples[] array above. Oh well... -extern cvar_t *s_volume; -extern cvar_t *s_volumeVoice; -extern cvar_t *s_nosound; -extern cvar_t *s_khz; -extern cvar_t *s_allowDynamicMusic; -extern cvar_t *s_show; -extern cvar_t *s_mixahead; - -extern cvar_t *s_testsound; -extern cvar_t *s_separation; +extern cvar_t *s_allowDynamicMusic; +extern cvar_t *s_initsound; +extern cvar_t *s_khz; +extern cvar_t *s_mixahead; +extern cvar_t *s_nosound; +extern cvar_t *s_separation; +extern cvar_t *s_show; +extern cvar_t *s_testsound; +extern cvar_t *s_volume; +extern cvar_t *s_volumeVoice; wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength); diff --git a/codemp/client/snd_ambient.cpp b/codemp/client/snd_ambient.cpp index 58096d9404..0b187088c9 100644 --- a/codemp/client/snd_ambient.cpp +++ b/codemp/client/snd_ambient.cpp @@ -780,9 +780,15 @@ AS_AddPrecacheEntry void AS_AddPrecacheEntry( const char *name ) { + if (!pMap) //s_initsound 0 probably + { + return; + } if (!Q_stricmp(name,"#clear")) { pMap->clear(); + currentSet = -1; + oldSet = -1; } else { @@ -800,6 +806,10 @@ Called on the client side to load and precache all the ambient sound sets void AS_ParseSets( void ) { + if ( !s_initsound->integer ) { + return; + } + AS_Init(); //Parse all the sets @@ -874,6 +884,7 @@ void AS_FreePartial(void) delete pMap; pMap = new namePrecache_m; + pMap->clear(); } } @@ -893,47 +904,47 @@ Fades volumes up or down depending on the action being taken on them. ------------------------- */ -static void AS_UpdateSetVolumes( void ) -{ - ambientSet_t *old, *current; - float scale; - int deltaTime; +static void AS_UpdateSetVolumes( void ){ + if ( !aSets ) { + return; + } //Get the sets and validate them - current = aSets->GetSet( currentSet ); - - if ( current == NULL ) + ambientSet_t *current = aSets->GetSet( currentSet ); + if ( !current ) { return; + } - if ( current->masterVolume < MAX_SET_VOLUME ) - { + float scale; + int deltaTime; + if ( current->masterVolume < MAX_SET_VOLUME ) { deltaTime = cls.realtime - current->fadeTime; scale = ((float)(deltaTime)/(float)(crossDelay)); current->masterVolume = (int)((scale) * (float)MAX_SET_VOLUME); } - if ( current->masterVolume > MAX_SET_VOLUME ) + if ( current->masterVolume > MAX_SET_VOLUME ) { current->masterVolume = MAX_SET_VOLUME; + } //Only update the old set if it's still valid - if ( oldSet == -1 ) + if ( oldSet == -1 ) { return; + } - old = aSets->GetSet( oldSet ); - - if ( old == NULL ) + ambientSet_t *old = aSets->GetSet( oldSet ); + if ( !old ) { return; + } //Update the volumes - if ( old->masterVolume > 0 ) - { + if ( old->masterVolume > 0 ) { deltaTime = cls.realtime - old->fadeTime; scale = ((float)(deltaTime)/(float)(crossDelay)); old->masterVolume = MAX_SET_VOLUME - (int)((scale) * (float)MAX_SET_VOLUME); } - if ( old->masterVolume <= 0 ) - { + if ( old->masterVolume <= 0 ) { old->masterVolume = 0; oldSet = -1; } @@ -947,26 +958,25 @@ Does internal maintenance to keep track of changing sets. ------------------------- */ -static void AS_UpdateCurrentSet( int id ) -{ - ambientSet_t *old, *current; +static void AS_UpdateCurrentSet( int id ) { + if ( !aSets ) { + return; + } //Check for a change - if ( id != currentSet ) - { + if ( id != currentSet ) { //This is new, so start the fading oldSet = currentSet; currentSet = id; - old = aSets->GetSet( oldSet ); - current = aSets->GetSet( currentSet ); + ambientSet_t *current = aSets->GetSet( currentSet ); // Ste, I just put this null check in for now, not sure if there's a more graceful way to exit this function - dmv - if( !current ) - { + if ( !current ) { return; } - if ( old ) - { + + ambientSet_t *old = aSets->GetSet( oldSet ); + if ( old ) { old->masterVolume = MAX_SET_VOLUME; old->fadeTime = cls.realtime; } @@ -990,42 +1000,42 @@ Alters lastTime to reflect the time updates. ------------------------- */ -static void AS_PlayLocalSet( vec3_t listener_origin, vec3_t origin, ambientSet_t *set, int entID, int *lastTime ) -{ - unsigned char volume; - vec3_t dir; - float volScale, dist, distScale; - int time = cl.serverTime; - +static void AS_PlayLocalSet( vec3_t listener_origin, vec3_t origin, const ambientSet_t *set, int entID, int *lastTime ) { //Make sure it's valid - if ( set == NULL ) + if ( !set ) { return; + } + vec3_t dir; VectorSubtract( origin, listener_origin, dir ); - dist = VectorLength( dir ); + float dist = VectorLength( dir ); //Determine the volume based on distance (NOTE: This sits on top of what SpatializeOrigin does) - distScale = ( dist < ( set->radius * 0.5f ) ) ? 1 : ( set->radius - dist ) / ( set->radius * 0.5f ); - volume = ( distScale > 1.0f || distScale < 0.0f ) ? 0 : (unsigned char) ( set->masterVolume * distScale ); + float distScale = ( dist < ( set->radius * 0.5f ) ) ? 1 : ( set->radius - dist ) / ( set->radius * 0.5f ); + unsigned char volume = ( distScale > 1.0f || distScale < 0.0f ) ? 0 : (unsigned char) ( set->masterVolume * distScale ); //Add the looping sound - if ( set->loopedWave ) + if ( set->loopedWave ) { S_AddAmbientLoopingSound( origin, volume, set->loopedWave ); + } //Check the time to start another one-shot subwave - if ( ( time - *lastTime ) < ( ( Q_irand( set->time_start, set->time_end ) ) * 1000 ) ) + int time = cl.serverTime; + if ( ( time - *lastTime ) < ( ( Q_irand( set->time_start, set->time_end ) ) * 1000 ) ) { return; + } //Update the time *lastTime = time; //Scale the volume ranges for the subwaves based on the overall master volume - volScale = (float) volume / (float) MAX_SET_VOLUME; + float volScale = (float) volume / (float) MAX_SET_VOLUME; volume = (unsigned char) Q_irand( (int)(volScale*set->volRange_start), (int)(volScale*set->volRange_end) ); //Add the random subwave - if ( set->numSubWaves ) + if ( set->numSubWaves ) { S_StartAmbientSound( origin, entID, volume, set->subWaves[Q_irand( 0, set->numSubWaves-1)] ); + } } /* @@ -1037,38 +1047,39 @@ Alters lastTime to reflect the time updates. ------------------------- */ -static void AS_PlayAmbientSet( vec3_t origin, ambientSet_t *set, int *lastTime ) -{ - unsigned char volume; - float volScale; - int time = cls.realtime; - +static void AS_PlayAmbientSet( vec3_t origin, const ambientSet_t *set, int *lastTime ) { //Make sure it's valid - if ( set == NULL ) + if ( !set ) { return; + } //Add the looping sound - if ( set->loopedWave ) + if ( set->loopedWave ) { S_AddAmbientLoopingSound( origin, (unsigned char) set->masterVolume, set->loopedWave ); + } //Check the time to start another one-shot subwave - if ( ( time - *lastTime ) < ( ( Q_irand( set->time_start, set->time_end ) ) * 1000 ) ) + int time = cls.realtime; + if ( ( time - *lastTime ) < ( ( Q_irand( set->time_start, set->time_end ) ) * 1000 ) ) { return; + } //Update the time *lastTime = time; //Scale the volume ranges for the subwaves based on the overall master volume - volScale = (float) set->masterVolume / (float) MAX_SET_VOLUME; - volume = Q_irand( (int)(volScale*set->volRange_start), (int)(volScale*set->volRange_end) ); + float volScale = (float) set->masterVolume / (float) MAX_SET_VOLUME; + unsigned char volume = Q_irand( (int)(volScale*set->volRange_start), (int)(volScale*set->volRange_end) ); //Allow for softer noises than the masterVolume, but not louder - if ( volume > set->masterVolume ) + if ( volume > set->masterVolume ) { volume = set->masterVolume; + } //Add the random subwave - if ( set->numSubWaves ) + if ( set->numSubWaves ) { S_StartAmbientSound( origin, 0, volume, set->subWaves[Q_irand( 0, set->numSubWaves-1)] ); + } } /* @@ -1079,25 +1090,28 @@ Does maintenance and plays the ambient sets (two if crossfading) ------------------------- */ -void S_UpdateAmbientSet ( const char *name, vec3_t origin ) -{ - ambientSet_t *current, *old; - ambientSet_t *set = aSets->GetSet( name ); +void S_UpdateAmbientSet( const char *name, vec3_t origin ) { + if ( !aSets ) { + return; + } - if ( set == NULL ) + const ambientSet_t *set = aSets->GetSet( name ); + if ( !set ) { return; + } //Update the current and old set for crossfading AS_UpdateCurrentSet( set->id ); - current = aSets->GetSet( currentSet ); - old = aSets->GetSet( oldSet ); - - if ( current ) + const ambientSet_t *current = aSets->GetSet( currentSet ); + if ( current ) { AS_PlayAmbientSet( origin, set, ¤tSetTime ); + } - if ( old ) + const ambientSet_t *old = aSets->GetSet( oldSet ); + if ( old ) { AS_PlayAmbientSet( origin, old, &oldSetTime ); + } } /* @@ -1106,20 +1120,18 @@ S_AddLocalSet ------------------------- */ -int S_AddLocalSet( const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time ) -{ - ambientSet_t *set; - int currentTime = 0; - - set = aSets->GetSet( name ); - - if ( set == NULL ) +int S_AddLocalSet( const char *name, vec3_t listener_origin, vec3_t origin, int entID, int time ) { + if ( !aSets ) { return cl.serverTime; + } - currentTime = time; + const ambientSet_t *set = aSets->GetSet( name ); + if ( !set ) { + return cl.serverTime; + } + int currentTime = time; AS_PlayLocalSet( listener_origin, origin, set, entID, ¤tTime ); - return currentTime; } @@ -1129,18 +1141,16 @@ AS_GetBModelSound ------------------------- */ -sfxHandle_t AS_GetBModelSound( const char *name, int stage ) -{ - ambientSet_t *set; - - set = aSets->GetSet( name ); - - if ( set == NULL ) +sfxHandle_t AS_GetBModelSound( const char *name, int stage ) { + if ( !aSets ) { return -1; + } //Stage must be within a valid range - if ( ( stage > ( set->numSubWaves - 1 ) ) || ( stage < 0 ) ) + const ambientSet_t *set = aSets->GetSet( name ); + if ( !set || stage < 0 || stage > (set->numSubWaves - 1) ) { return -1; + } - return set->subWaves[ stage ]; + return set->subWaves[stage]; } diff --git a/codemp/client/snd_dma.cpp b/codemp/client/snd_dma.cpp index 23e1b39f09..c02a220cf2 100644 --- a/codemp/client/snd_dma.cpp +++ b/codemp/client/snd_dma.cpp @@ -173,25 +173,25 @@ int s_numSfx; #define LOOP_HASH 128 static sfx_t *sfxHash[LOOP_HASH]; -cvar_t *s_volume; -cvar_t *s_volumeVoice; -cvar_t *s_testsound; -cvar_t *s_khz; -cvar_t *s_allowDynamicMusic; -cvar_t *s_show; -cvar_t *s_mixahead; -cvar_t *s_mixPreStep; -cvar_t *s_musicVolume; -cvar_t *s_separation; -cvar_t *s_lip_threshold_1; -cvar_t *s_lip_threshold_2; -cvar_t *s_lip_threshold_3; -cvar_t *s_lip_threshold_4; -cvar_t *s_language; // note that this is distinct from "g_language" -cvar_t *s_dynamix; -cvar_t *s_debugdynamic; - -cvar_t *s_doppler; +cvar_t *s_allowDynamicMusic; +cvar_t *s_debugdynamic; +cvar_t *s_doppler; +cvar_t *s_dynamix; +cvar_t *s_initsound; +cvar_t *s_khz; +cvar_t *s_language; // note that this is distinct from "g_language" +cvar_t *s_lip_threshold_1; +cvar_t *s_lip_threshold_2; +cvar_t *s_lip_threshold_3; +cvar_t *s_lip_threshold_4; +cvar_t *s_mixahead; +cvar_t *s_mixPreStep; +cvar_t *s_musicVolume; +cvar_t *s_separation; +cvar_t *s_show; +cvar_t *s_testsound; +cvar_t *s_volume; +cvar_t *s_volumeVoice; typedef struct { @@ -443,36 +443,32 @@ S_Init ================ */ void S_Init( void ) { - cvar_t *cv; qboolean r; Com_Printf("\n------- sound initialization -------\n"); - s_volume = Cvar_Get ("s_volume", "0.5", CVAR_ARCHIVE, "Volume" ); - s_volumeVoice= Cvar_Get ("s_volumeVoice", "1.0", CVAR_ARCHIVE, "Volume for voice channels" ); - s_musicVolume = Cvar_Get ("s_musicvolume", "0.25", CVAR_ARCHIVE, "Music Volume" ); - s_separation = Cvar_Get ("s_separation", "0.5", CVAR_ARCHIVE); - s_khz = Cvar_Get ("s_khz", "44", CVAR_ARCHIVE|CVAR_LATCH); - s_allowDynamicMusic = Cvar_Get ("s_allowDynamicMusic", "1", CVAR_ARCHIVE_ND); - s_mixahead = Cvar_Get ("s_mixahead", "0.2", CVAR_ARCHIVE); - - s_mixPreStep = Cvar_Get ("s_mixPreStep", "0.05", CVAR_ARCHIVE); - s_show = Cvar_Get ("s_show", "0", CVAR_CHEAT); - s_testsound = Cvar_Get ("s_testsound", "0", CVAR_CHEAT); - s_debugdynamic = Cvar_Get("s_debugdynamic","0", CVAR_CHEAT); - s_lip_threshold_1 = Cvar_Get("s_threshold1" , "0.5",0); - s_lip_threshold_2 = Cvar_Get("s_threshold2" , "4.0",0); - s_lip_threshold_3 = Cvar_Get("s_threshold3" , "7.0",0); - s_lip_threshold_4 = Cvar_Get("s_threshold4" , "8.0",0); - - s_language = Cvar_Get("s_language","english",CVAR_ARCHIVE | CVAR_NORESTART, "Sound language" ); - - s_doppler = Cvar_Get("s_doppler", "1", CVAR_ARCHIVE_ND); + s_allowDynamicMusic = Cvar_Get( "s_allowDynamicMusic", "1", CVAR_ARCHIVE_ND ); + s_debugdynamic = Cvar_Get( "s_debugdynamic", "0", CVAR_CHEAT ); + s_doppler = Cvar_Get( "s_doppler", "1", CVAR_ARCHIVE_ND ); + s_initsound = Cvar_Get( "s_initsound", "1", CVAR_ARCHIVE ); + s_khz = Cvar_Get( "s_khz", "44", CVAR_ARCHIVE | CVAR_LATCH ); + s_language = Cvar_Get( "s_language", "english", CVAR_ARCHIVE | CVAR_NORESTART, "Sound language" ); + s_lip_threshold_1 = Cvar_Get( "s_threshold1", "0.5", 0 ); + s_lip_threshold_2 = Cvar_Get( "s_threshold2", "4.0", 0 ); + s_lip_threshold_3 = Cvar_Get( "s_threshold3", "7.0", 0 ); + s_lip_threshold_4 = Cvar_Get( "s_threshold4", "8.0", 0 ); + s_mixahead = Cvar_Get( "s_mixahead", "0.2", CVAR_ARCHIVE ); + s_mixPreStep = Cvar_Get( "s_mixPreStep", "0.05", CVAR_ARCHIVE ); + s_musicVolume = Cvar_Get( "s_musicvolume", "0.25", CVAR_ARCHIVE, "Music Volume" ); + s_separation = Cvar_Get( "s_separation", "0.5", CVAR_ARCHIVE ); + s_show = Cvar_Get( "s_show", "0", CVAR_CHEAT ); + s_testsound = Cvar_Get( "s_testsound", "0", CVAR_CHEAT ); + s_volume = Cvar_Get( "s_volume", "0.5", CVAR_ARCHIVE, "Volume" ); + s_volumeVoice = Cvar_Get( "s_volumeVoice", "1.0", CVAR_ARCHIVE, "Volume for voice channels" ); MP3_InitCvars(); - cv = Cvar_Get ("s_initsound", "1", 0); - if ( !cv->integer ) { + if ( !s_initsound->integer ) { s_soundStarted = 0; // needed in case you set s_initsound to 0 midgame then snd_restart (div0 err otherwise later) Com_Printf ("not initializing.\n"); Com_Printf("------------------------------------\n"); diff --git a/codemp/client/snd_local.h b/codemp/client/snd_local.h index 14935ba003..8e70bbc5b7 100644 --- a/codemp/client/snd_local.h +++ b/codemp/client/snd_local.h @@ -194,18 +194,17 @@ extern dma_t dma; extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES]; portable_samplepair_t *S_GetRawSamplePointer(); // TA added this, but it just returns the s_rawsamples[] array above. Oh well... -extern cvar_t *s_volume; -extern cvar_t *s_volumeVoice; -extern cvar_t *s_nosound; -extern cvar_t *s_khz; -extern cvar_t *s_allowDynamicMusic; -extern cvar_t *s_show; -extern cvar_t *s_mixahead; - -extern cvar_t *s_testsound; -extern cvar_t *s_separation; - -extern cvar_t *s_doppler; +extern cvar_t *s_allowDynamicMusic; +extern cvar_t *s_doppler; +extern cvar_t *s_initsound; +extern cvar_t *s_khz; +extern cvar_t *s_mixahead; +extern cvar_t *s_nosound; +extern cvar_t *s_separation; +extern cvar_t *s_show; +extern cvar_t *s_testsound; +extern cvar_t *s_volume; +extern cvar_t *s_volumeVoice; wavinfo_t GetWavinfo (const char *name, byte *wav, int wavlength); From 034057e7209db097a9fb21357b11fa73f452df65 Mon Sep 17 00:00:00 2001 From: Razish Date: Fri, 2 Sep 2022 23:48:32 +1000 Subject: [PATCH 573/801] hotfix for fdf206e - i broke the MSVC build :( --- code/client/snd_dma.cpp | 2 +- codemp/client/snd_dma.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/client/snd_dma.cpp b/code/client/snd_dma.cpp index 3cf06daff7..bb539e4cd6 100644 --- a/code/client/snd_dma.cpp +++ b/code/client/snd_dma.cpp @@ -485,7 +485,7 @@ void S_Init( void ) { Cmd_AddCommand("s_dynamic", S_SetDynamicMusic_f); #ifdef USE_OPENAL - cv = Cvar_Get("s_UseOpenAL" , "0",CVAR_ARCHIVE|CVAR_LATCH); + cvar_t *cv = Cvar_Get("s_UseOpenAL" , "0",CVAR_ARCHIVE|CVAR_LATCH); s_UseOpenAL = !!(cv->integer); if (s_UseOpenAL) diff --git a/codemp/client/snd_dma.cpp b/codemp/client/snd_dma.cpp index c02a220cf2..736203492a 100644 --- a/codemp/client/snd_dma.cpp +++ b/codemp/client/snd_dma.cpp @@ -485,7 +485,7 @@ void S_Init( void ) { Cmd_AddCommand("s_dynamic", S_SetDynamicMusic_f, "Change dynamic music state" ); #ifdef USE_OPENAL - cv = Cvar_Get("s_UseOpenAL" , "0",CVAR_ARCHIVE|CVAR_LATCH); + cvar_t *cv = Cvar_Get("s_UseOpenAL" , "0",CVAR_ARCHIVE|CVAR_LATCH); s_UseOpenAL = !!(cv->integer); if (s_UseOpenAL) From 5902a2e6ec9aca8184069525804fdf4aeb54805d Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 14 Sep 2022 15:26:33 +0200 Subject: [PATCH 574/801] 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 575/801] 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 576/801] 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 577/801] 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 578/801] 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 579/801] 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 580/801] 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 581/801] 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 582/801] 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 583/801] 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 584/801] 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 585/801] 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 586/801] 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 587/801] 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 c2095bb4e321d82b7e4f3bd7b44707a4ab644ba3 Mon Sep 17 00:00:00 2001 From: razor Date: Fri, 14 Oct 2022 09:38:47 +1100 Subject: [PATCH 588/801] Fix same-frame mutual kills (#1127) Found and fixed by Bucky, regression introduced by a fix suggested by Master HeX https://lucasforumsarchive.com/thread/140104/page/3\#post-117 --- codemp/game/g_combat.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/codemp/game/g_combat.c b/codemp/game/g_combat.c index ccccc690f0..3540974377 100644 --- a/codemp/game/g_combat.c +++ b/codemp/game/g_combat.c @@ -2235,18 +2235,6 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int G_BreakArm(self, 0); //unbreak anything we have broken self->client->ps.saberEntityNum = self->client->saberStoredIndex; //in case we died while our saber was knocked away. - if (self->client->ps.weapon == WP_SABER && self->client->saberKnockedTime) - { - gentity_t *saberEnt = &g_entities[self->client->ps.saberEntityNum]; - //trap->Print("DEBUG: Running saber cleanup for %s\n", self->client->pers.netname); - self->client->saberKnockedTime = 0; - saberReactivate(saberEnt, self); - saberEnt->r.contents = CONTENTS_LIGHTSABER; - saberEnt->think = saberBackToOwner; - saberEnt->nextthink = level.time; - G_RunObject(saberEnt); - } - self->client->bodyGrabIndex = ENTITYNUM_NONE; self->client->bodyGrabTime = 0; From 6802ebe8b9f46919f176c39631caffd7a95f1e3f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 14 Oct 2022 23:01:03 +0200 Subject: [PATCH 589/801] 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 590/801] 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 2a27be7cac748aab16faa5fa54595833861b51ad Mon Sep 17 00:00:00 2001 From: taysta Date: Sun, 16 Oct 2022 03:02:08 +0800 Subject: [PATCH 591/801] Workflow overhaul - Update environment & action runners - Add automatic latest releasing as well as manual releases - Add portable & non-portable, release, debug builds --- .github/workflows/build.yml | 382 +++++++++++++++++++++++++++++------- 1 file changed, 307 insertions(+), 75 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb9fccf68a..a0d58c70bd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,105 +1,337 @@ -name: Build +name: build on: workflow_dispatch: push: - branches: master + paths-ignore: + - '**.md' + - '*.txt' + - '.gitignore' + - 'docs/*' pull_request: - branches: master + paths-ignore: + - '**.md' + - '*.txt' + - '.gitignore' + - 'docs/*' + release: + types: [published] + +env: + newline: \\n jobs: - vs2019: - name: Build VS 2019, ${{ matrix.build_type }}, ${{ matrix.arch }} - runs-on: windows-2019 + msvc: + name: Windows ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable }}) + runs-on: windows-2022 strategy: matrix: - build_type: [Debug, RelWithDebInfo] - arch: [Win32, x64] + 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@v2 + - 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: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.2 + - 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: Create Build Environment - run: cmake -E make_directory ${{runner.workspace}}/build + - name: Build + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --build . --config ${{ matrix.build_type }} - - name: Configure CMake - shell: bash - working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -A ${{ matrix.arch }} + - name: Install + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --install . --config ${{ matrix.build_type }} - - name: Build - working-directory: ${{runner.workspace}}/build - shell: bash - run: cmake --build . --config ${{ matrix.build_type }} + - uses: actions/upload-artifact@v3 + with: + name: windows-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{ runner.workspace }}/build/bin + if-no-files-found: error - vs2017_xp: - name: Build VS 2017, Windows XP - runs-on: windows-2016 + 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@v2 + - uses: actions/checkout@v3 - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.2 + - 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: Create Build Environment + run: cmake -E make_directory ${{ runner.workspace }}/build - - name: Configure CMake - shell: bash - working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -A Win32 -T v141_xp + - 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 RelWithDebInfo + - name: Build + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --build . --config ${{ matrix.build_type }} + + - name: Install + working-directory: ${{ runner.workspace }}/build + shell: bash + run: | + cmake --install . --config ${{ matrix.build_type }} + - uses: actions/upload-artifact@v3 + with: + name: 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: [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=CMakeModules/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 + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --install . + + - name: Create binary archive + 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 + with: + name: 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: Build macOS AppleClang - runs-on: macos-10.15 + 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: [Portable, Non-Portable] steps: - - uses: actions/checkout@v2 - - - 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: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=RelWithDebInfo - - - name: Build - working-directory: ${{runner.workspace}}/build - shell: bash - run: cmake --build . - - linux: - name: Build Linux, ${{ matrix.build_type }} - runs-on: ubuntu-20.04 + - 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 + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --install . + + - name: Create binary archive + 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 + with: + name: 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 == 'push' && github.ref == 'refs/heads/master' + 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 ./windows-x86-Release/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + mv ./linux-x86-Release-Non-Portable/* OpenJK-linux-x86.tar.gz + mv ./linux-x86_64-Release-Non-Portable/* OpenJK-linux-x86_64.tar.gz + mv ./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: - build_type: [Debug, RelWithDebInfo] + include: + - artifact_dir: windows-x86-Release-Portable/JediAcademy + artifact_name: OpenJK-windows-x86.zip + zip: true + + - artifact_dir: linux-x86-Release-Non-Portable + artifact_name: OpenJK-linux-x86.tar.gz + zip: false + + - artifact_dir: linux-x86_64-Release-Non-Portable + artifact_name: OpenJK-linux-x86_64.tar.gz + zip: false + + - artifact_dir: macos-x86_64-Release-Non-Portable + artifact_name: OpenJK-macos-x86_64.tar.gz + zip: false steps: - - uses: actions/checkout@v2 - - - name: Create Build Environment - run: | - sudo apt-get update - sudo apt-get install libjpeg-dev libpng-dev zlib1g-dev libsdl2-dev - cmake -E make_directory ${{runner.workspace}}/build - - name: Configure CMake - shell: bash - working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - - - name: Build - working-directory: ${{runner.workspace}}/build - shell: bash - run: cmake --build . + - 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 9c099fb0730706c1ba58fad502a2cba0737b50d2 Mon Sep 17 00:00:00 2001 From: taysta Date: Sun, 16 Oct 2022 03:10:46 +0800 Subject: [PATCH 592/801] Fix ubuntu x86 toolchain path --- .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 a0d58c70bd..9b41c8ae98 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -174,7 +174,7 @@ jobs: fi if [ ${{ matrix.arch }} == "x86" ]; then - cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} $OPTIONS -DCMAKE_TOOLCHAIN_FILE=CMakeModules/Toolchains/linux-i686.cmake + 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 From 068fa2254bfbb54b69e1887367cb35e8e8712681 Mon Sep 17 00:00:00 2001 From: tayst Date: Sun, 16 Oct 2022 03:27:34 +0800 Subject: [PATCH 593/801] Only run automatically on master branch --- .github/workflows/build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b41c8ae98..9ad8bee1f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,12 +3,14 @@ name: build on: workflow_dispatch: push: + branches: [master] paths-ignore: - '**.md' - '*.txt' - '.gitignore' - 'docs/*' pull_request: + branches: [master] paths-ignore: - '**.md' - '*.txt' @@ -17,9 +19,6 @@ on: release: types: [published] -env: - newline: \\n - jobs: msvc: name: Windows ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable }}) From 0d13b36658ee0b30906cf7f5e26648fa0812933b Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 18 Oct 2022 17:59:29 +0200 Subject: [PATCH 594/801] 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 595/801] 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 596/801] 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 2854f96b88ac6778eda4294e2d4b869de88be3ac Mon Sep 17 00:00:00 2001 From: tayst Date: Thu, 20 Oct 2022 21:29:42 +0800 Subject: [PATCH 597/801] Change build/upload/release options With the following commit, the set-up will be as follows: Build: - Windows/WinXP 32/64 Portable/Non-Portable Release/Debug - Linux 32/64 Non-Portable Release/Debug - MacOS 64 Non-Portable Release/Debug Release: - Windows/WinXP 32 Non-Portable Release - Linux 32/64 Non-Portable Release - MacOS 64 Non-Portable Release Optional (Artifacts uploaded but not included in release): - Windows/WinXP 64 Portable/Non-Portable Release - Windows/WinXP 32 Portable Release --- .github/workflows/build.yml | 39 ++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ad8bee1f3..ffe503e824 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,13 +60,15 @@ jobs: 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: windows-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + name: OpenJK-windows-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} path: ${{ runner.workspace }}/build/bin if-no-files-found: error @@ -124,13 +126,16 @@ jobs: 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: windowsxp-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + name: OpenJK-windowsxp-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} path: ${{ runner.workspace }}/build/bin if-no-files-found: error @@ -142,7 +147,7 @@ jobs: matrix: arch: [x86, x86_64] build_type: [Debug, Release] - portable: [Portable, Non-Portable] + portable: [Non-Portable] steps: - uses: actions/checkout@v3 @@ -184,11 +189,13 @@ jobs: 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: | @@ -200,8 +207,9 @@ jobs: 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: linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + 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 @@ -213,7 +221,7 @@ jobs: matrix: arch: [x86_64] build_type: [Debug, Release] - portable: [Portable, Non-Portable] + portable: [Non-Portable] steps: - uses: actions/checkout@v3 @@ -240,11 +248,13 @@ jobs: 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: | @@ -252,8 +262,9 @@ jobs: 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: macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + 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 @@ -271,10 +282,10 @@ jobs: - name: Create binary archives run: | - 7z a -r OpenJK-windows-x86.zip ./windows-x86-Release/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' - mv ./linux-x86-Release-Non-Portable/* OpenJK-linux-x86.tar.gz - mv ./linux-x86_64-Release-Non-Portable/* OpenJK-linux-x86_64.tar.gz - mv ./macos-x86_64-Release-Non-Portable/* OpenJK-macos-x86_64.tar.gz + 7z a -r OpenJK-windows-x86.zip ./OpenJK-windows-x86-Release/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + mv ./OpenJK-linux-x86-Release-Non-Portable/* OpenJK-linux-x86.tar.gz + 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 @@ -295,19 +306,19 @@ jobs: strategy: matrix: include: - - artifact_dir: windows-x86-Release-Portable/JediAcademy + - artifact_dir: OpenJK-windows-x86-Release-Portable/JediAcademy artifact_name: OpenJK-windows-x86.zip zip: true - - artifact_dir: linux-x86-Release-Non-Portable + - artifact_dir: OpenJK-linux-x86-Release-Non-Portable artifact_name: OpenJK-linux-x86.tar.gz zip: false - - artifact_dir: linux-x86_64-Release-Non-Portable + - artifact_dir: OpenJK-linux-x86_64-Release-Non-Portable artifact_name: OpenJK-linux-x86_64.tar.gz zip: false - - artifact_dir: macos-x86_64-Release-Non-Portable + - artifact_dir: OpenJK-macos-x86_64-Release-Non-Portable artifact_name: OpenJK-macos-x86_64.tar.gz zip: false From 2547427920255782a9498485a0d89d87ea671fed Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 20 Oct 2022 20:21:47 +0200 Subject: [PATCH 598/801] 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 599/801] 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 600/801] 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 601/801] 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 602/801] 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 603/801] 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 604/801] 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 605/801] 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 606/801] 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 607/801] 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 608/801] 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 609/801] 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 610/801] 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 611/801] [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 612/801] 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 613/801] 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 614/801] 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 615/801] 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 616/801] 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 617/801] 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 618/801] 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 619/801] 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 620/801] 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 621/801] 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 622/801] 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 623/801] 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 624/801] 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 625/801] 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 626/801] 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 627/801] 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 52abfbf271e86012f11a09518bf92d6f0def59b6 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 5 Mar 2023 08:33:01 -0600 Subject: [PATCH 628/801] Add more build folders to .gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 3853e47221..a8a1494a1f 100644 --- a/.gitignore +++ b/.gitignore @@ -187,3 +187,9 @@ pip-log.txt ## CLion ############# .idea + +############# +## CMake Builds +############# +[Bb]uild*/ +cmake-build-* \ No newline at end of file From a055ad6ddd4cfee86959435e0d3e4a1b0271e461 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 5 Mar 2023 08:50:53 -0600 Subject: [PATCH 629/801] Fix bug in SP where game could hang on maps with too many spawn points Fixes #1137 Replaces and Closes #1138 --- code/game/g_client.cpp | 2 +- codeJK2/game/g_client.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/g_client.cpp b/code/game/g_client.cpp index de478f5982..053a8f10d9 100644 --- a/code/game/g_client.cpp +++ b/code/game/g_client.cpp @@ -238,7 +238,7 @@ gentity_t *SelectRandomDeathmatchSpawnPoint( team_t team ) { count = 0; spot = NULL; - while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) { + while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL && count < MAX_SPAWN_POINTS) { /*if ( team == TEAM_RED && ( spot->spawnflags & 2 ) ) { continue; } diff --git a/codeJK2/game/g_client.cpp b/codeJK2/game/g_client.cpp index 0535279a7a..36e99e2bc8 100644 --- a/codeJK2/game/g_client.cpp +++ b/codeJK2/game/g_client.cpp @@ -218,7 +218,7 @@ gentity_t *SelectRandomDeathmatchSpawnPoint( team_t team ) { count = 0; spot = NULL; - while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) { + while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL && count < MAX_SPAWN_POINTS) { /*if ( team == TEAM_RED && ( spot->spawnflags & 2 ) ) { continue; } From 0f74fd44a6067df0c35c10031e8229a74955b1ab Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 5 Mar 2023 08:53:37 -0600 Subject: [PATCH 630/801] Fix JK2SP compile related to debug symbol being accessed Fixes #1113, #1097 --- codeJK2/game/bg_pmove.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codeJK2/game/bg_pmove.cpp b/codeJK2/game/bg_pmove.cpp index 0fb672ea5b..964cfcece2 100644 --- a/codeJK2/game/bg_pmove.cpp +++ b/codeJK2/game/bg_pmove.cpp @@ -6499,9 +6499,9 @@ qboolean PM_SaberLocked( void ) qboolean ret = #endif // _DEBUG gi.G2API_GetBoneAnimIndex( &gent->ghoul2[gent->playerModel], gent->lowerLumbarBone, (cg.time?cg.time:level.time), ¤tFrame, &junk, &junk, &junk, &junk2, NULL ); - +#ifdef _DEBUG assert(ret); // this would be pretty bad, the below code seems to assume the call succeeds. -gil - +#endif strength = G_SaberLockStrength( gent ); if ( pm->ps->torsoAnim == BOTH_CCWCIRCLELOCK || pm->ps->torsoAnim == BOTH_BF2LOCK ) From 1a5503c0e0cca907b0e1bdd9b5b9cb2d27cfa90e Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 5 Mar 2023 08:54:39 -0600 Subject: [PATCH 631/801] Add VS 2022 x86 project file build script --- CreateVisualStudio2019Projects.bat | 2 +- CreateVisualStudio2022Projects.bat | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 CreateVisualStudio2022Projects.bat diff --git a/CreateVisualStudio2019Projects.bat b/CreateVisualStudio2019Projects.bat index 257d42d069..14b253ddb5 100644 --- a/CreateVisualStudio2019Projects.bat +++ b/CreateVisualStudio2019Projects.bat @@ -1,4 +1,4 @@ -@REM Create OpenJK projects for Visual Studio 2017 using CMake +@REM Create OpenJK projects for Visual Studio 2019 using CMake @echo off for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X) if not defined FOUND ( diff --git a/CreateVisualStudio2022Projects.bat b/CreateVisualStudio2022Projects.bat new file mode 100644 index 0000000000..d71a888c79 --- /dev/null +++ b/CreateVisualStudio2022Projects.bat @@ -0,0 +1,18 @@ +@REM Create OpenJK projects for Visual Studio 2022 using CMake +@echo off +for %%X in (cmake.exe) do (set FOUND=%%~$PATH:X) +if not defined FOUND ( + echo CMake was not found on your system. Please make sure you have installed CMake + echo from http://www.cmake.org/ and cmake.exe is installed to your system's PATH + echo environment variable. + echo. + pause + exit /b 1 +) else ( + echo Found CMake! +) +if not exist build\nul (mkdir build) +pushd build +cmake -G "Visual Studio 17 2022" -A Win32 -D CMAKE_INSTALL_PREFIX=../install .. +popd +pause \ No newline at end of file From 7482b27a8f048ea17818721e349602a18365d034 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 5 Mar 2023 09:00:42 -0600 Subject: [PATCH 632/801] Fix minizip using old C style function declaration Deprecated and will be removed completely in near future updates to C standard. --- lib/minizip/ioapi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/minizip/ioapi.c b/lib/minizip/ioapi.c index 7f5c191b2a..c2b536f8fc 100644 --- a/lib/minizip/ioapi.c +++ b/lib/minizip/ioapi.c @@ -221,8 +221,7 @@ static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) return ret; } -void fill_fopen_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; +void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen_file = fopen_file_func; pzlib_filefunc_def->zread_file = fread_file_func; From b9ba3e72b1fbdbfaad4e90b95533e9413f263e07 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 5 Mar 2023 19:13:23 -0600 Subject: [PATCH 633/801] Fix create test build with wrong path on Windows --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ffe503e824..7da53c61ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -282,7 +282,7 @@ jobs: - name: Create binary archives run: | - 7z a -r OpenJK-windows-x86.zip ./OpenJK-windows-x86-Release/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + 7z a -r OpenJK-windows-x86.zip ./OpenJK-windows-x86-Release-Non-Portable/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' mv ./OpenJK-linux-x86-Release-Non-Portable/* OpenJK-linux-x86.tar.gz 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 @@ -306,7 +306,7 @@ jobs: strategy: matrix: include: - - artifact_dir: OpenJK-windows-x86-Release-Portable/JediAcademy + - artifact_dir: OpenJK-windows-x86-Release-Non-Portable/JediAcademy artifact_name: OpenJK-windows-x86.zip zip: true From ab77102b7246d116343566875b705cb06dc5924a Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 5 Mar 2023 19:44:40 -0600 Subject: [PATCH 634/801] Implement better workaround for force power menu when using setForceAll No longer assumes cheats active implies can skip to weapon selection. --- code/ui/ui_main.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/code/ui/ui_main.cpp b/code/ui/ui_main.cpp index 1b448b4fc8..b6d4fed156 100644 --- a/code/ui/ui_main.cpp +++ b/code/ui/ui_main.cpp @@ -4643,6 +4643,34 @@ static void UI_SetPowerTitleText ( qboolean showAllocated ) } } +#ifndef JK2_MODE +static int UI_CountForcePowers( void ) { + const client_t *cl = &svs.clients[0]; + + if ( cl && cl->gentity ) { + const playerState_t *ps = cl->gentity->client; + return ps->forcePowerLevel[FP_HEAL] + + ps->forcePowerLevel[FP_TELEPATHY] + + ps->forcePowerLevel[FP_PROTECT] + + ps->forcePowerLevel[FP_ABSORB] + + ps->forcePowerLevel[FP_GRIP] + + ps->forcePowerLevel[FP_LIGHTNING] + + ps->forcePowerLevel[FP_RAGE] + + ps->forcePowerLevel[FP_DRAIN]; + } + else { + return uiInfo.forcePowerLevel[FP_HEAL] + + uiInfo.forcePowerLevel[FP_TELEPATHY] + + uiInfo.forcePowerLevel[FP_PROTECT] + + uiInfo.forcePowerLevel[FP_ABSORB] + + uiInfo.forcePowerLevel[FP_GRIP] + + uiInfo.forcePowerLevel[FP_LIGHTNING] + + uiInfo.forcePowerLevel[FP_RAGE] + + uiInfo.forcePowerLevel[FP_DRAIN]; + } +} +#endif + //. Find weapons button and make active/inactive (Used by Force Power Allocation screen) static void UI_ForcePowerWeaponsButton(qboolean activeFlag) { @@ -4654,9 +4682,13 @@ static void UI_ForcePowerWeaponsButton(qboolean activeFlag) return; } - // Cheats are on so lets always let us pass - if(trap_Cvar_VariableValue("helpUsObi") != 0) - activeFlag = qtrue; +#ifndef JK2_MODE + if (!activeFlag) { + // total light and dark powers are at maximum level 3 ( 3 levels * ( 4ls + 4ds ) = 24 ) + if ( UI_CountForcePowers() >= 24 ) + activeFlag = qtrue; + } +#endif // Find weaponsbutton itemDef_t *item; From 4d090e2c42efa6ef02a831d9414698dfd01f8e93 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Wed, 8 Mar 2023 18:46:03 -0600 Subject: [PATCH 635/801] Code warning fixes --- code/cgame/cg_camera.cpp | 4 ++-- code/cgame/cg_main.cpp | 2 +- code/cgame/cg_predict.cpp | 2 +- code/cgame/cg_view.cpp | 4 ++-- code/client/snd_mem.cpp | 6 +++--- code/game/NPC.cpp | 3 --- code/game/g_active.cpp | 2 +- code/game/g_combat.cpp | 2 +- code/game/g_inventory.cpp | 14 +++++++------- code/game/g_items.cpp | 2 +- code/game/g_local.h | 4 ++-- code/game/g_missile.cpp | 2 +- code/game/g_navigator.cpp | 2 +- codeJK2/cgame/cg_camera.cpp | 4 ++-- codeJK2/cgame/cg_main.cpp | 2 +- codeJK2/cgame/cg_predict.cpp | 2 +- codeJK2/cgame/cg_view.cpp | 4 ++-- codeJK2/game/g_active.cpp | 2 +- codeJK2/game/g_combat.cpp | 2 +- codeJK2/game/g_inventory.cpp | 14 +++++++------- codeJK2/game/g_items.cpp | 2 +- codeJK2/game/g_local.h | 4 ++-- codeJK2/game/g_missile.cpp | 2 +- codemp/client/snd_mem.cpp | 6 +++--- codemp/game/ai_main.c | 4 ++-- codemp/game/g_client.c | 4 ++-- codemp/game/g_team.c | 2 +- 27 files changed, 50 insertions(+), 53 deletions(-) diff --git a/code/cgame/cg_camera.cpp b/code/cgame/cg_camera.cpp index 72752164b8..878a17dd3e 100644 --- a/code/cgame/cg_camera.cpp +++ b/code/cgame/cg_camera.cpp @@ -95,7 +95,7 @@ void CGCam_Enable( void ) client_camera.next_roff_time = 0; - if ( &g_entities[0] && g_entities[0].client ) + if ( g_entities[0].inuse && g_entities[0].client ) { //Player zero not allowed to do anything VectorClear( g_entities[0].client->ps.velocity ); @@ -148,7 +148,7 @@ void CGCam_Disable( void ) client_camera.info_state |= CAMERA_BAR_FADING; - if ( &g_entities[0] && g_entities[0].client ) + if ( g_entities[0].inuse && g_entities[0].client ) { g_entities[0].contents = CONTENTS_BODY;//MASK_PLAYERSOLID; } diff --git a/code/cgame/cg_main.cpp b/code/cgame/cg_main.cpp index 1b9c16153e..9823ec8419 100644 --- a/code/cgame/cg_main.cpp +++ b/code/cgame/cg_main.cpp @@ -1613,7 +1613,7 @@ Ghoul2 Insert End for (i=0 ; i < ENTITYNUM_WORLD ; i++) { - if(&g_entities[i]) + if(g_entities[i].inuse) { if(g_entities[i].client) { diff --git a/code/cgame/cg_predict.cpp b/code/cgame/cg_predict.cpp index e0c57f7519..f0a55359ad 100644 --- a/code/cgame/cg_predict.cpp +++ b/code/cgame/cg_predict.cpp @@ -291,7 +291,7 @@ qboolean CG_CheckModifyUCmd( usercmd_t *cmd, vec3_t viewangles ) */ } - if ( &g_entities[0] && g_entities[0].client ) + if ( g_entities[0].inuse && g_entities[0].client ) { if ( !PM_AdjustAnglesToGripper( &g_entities[0], cmd ) ) { diff --git a/code/cgame/cg_view.cpp b/code/cgame/cg_view.cpp index 3523e64355..01cb293e07 100644 --- a/code/cgame/cg_view.cpp +++ b/code/cgame/cg_view.cpp @@ -1179,7 +1179,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { // add view height if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD ) { - if ( &g_entities[cg.snap->ps.viewEntity] && + if ( g_entities[cg.snap->ps.viewEntity].inuse && g_entities[cg.snap->ps.viewEntity].client && g_entities[cg.snap->ps.viewEntity].client->ps.viewheight ) { @@ -1359,7 +1359,7 @@ static qboolean CG_CalcFov( void ) { && (!cg.renderingThirdPerson || g_entities[cg.snap->ps.viewEntity].e_DieFunc == dieF_camera_die) ) { // if in entity camera view, use a special FOV - if ( &g_entities[cg.snap->ps.viewEntity] && + if ( g_entities[cg.snap->ps.viewEntity].inuse && g_entities[cg.snap->ps.viewEntity].NPC ) {//FIXME: looks bad when take over a jedi... but never really do that, do we? fov_x = g_entities[cg.snap->ps.viewEntity].NPC->stats.hfov; diff --git a/code/client/snd_mem.cpp b/code/client/snd_mem.cpp index f2a003edab..fb7ea05b2b 100644 --- a/code/client/snd_mem.cpp +++ b/code/client/snd_mem.cpp @@ -258,10 +258,10 @@ void ResampleSfx (sfx_t *sfx, int iInRate, int iInWidth, byte *pData) void S_LoadSound_Finalize(wavinfo_t *info, sfx_t *sfx, byte *data) { - float stepscale = (float)info->rate / dma.speed; - int len = (int)(info->samples / stepscale); + //float stepscale = (float)info->rate / dma.speed; + //int len = (int)(info->samples / stepscale); - len *= info->width; + //len *= info->width; sfx->eSoundCompressionMethod = ct_16; sfx->iSoundLengthInSamples = info->samples; diff --git a/code/game/NPC.cpp b/code/game/NPC.cpp index 328d9a2dbe..d1c794e0e0 100644 --- a/code/game/NPC.cpp +++ b/code/game/NPC.cpp @@ -438,9 +438,6 @@ void pitch_roll_for_slope( gentity_t *forwhom, vec3_t pass_slope, vec3_t storeAn if ( trace.fraction >= 1.0 ) return; - if( !( &trace.plane ) ) - return; - if ( VectorCompare( vec3_origin, trace.plane.normal ) ) return; diff --git a/code/game/g_active.cpp b/code/game/g_active.cpp index 9805ce95b4..e8b19398bc 100644 --- a/code/game/g_active.cpp +++ b/code/game/g_active.cpp @@ -218,7 +218,7 @@ qboolean G_ClearViewEntity( gentity_t *ent ) if ( ent->client->ps.viewEntity > 0 && ent->client->ps.viewEntity < ENTITYNUM_NONE ) { - if ( &g_entities[ent->client->ps.viewEntity] ) + if ( g_entities[ent->client->ps.viewEntity].inuse ) { g_entities[ent->client->ps.viewEntity].svFlags &= ~SVF_BROADCAST; if ( g_entities[ent->client->ps.viewEntity].NPC ) diff --git a/code/game/g_combat.cpp b/code/game/g_combat.cpp index 6378aee1cd..32fee2e01d 100644 --- a/code/game/g_combat.cpp +++ b/code/game/g_combat.cpp @@ -4035,7 +4035,7 @@ extern void RunEmplacedWeapon( gentity_t *ent, usercmd_t **ucmd ); {//FIXME: just HazTeam members in formation on away missions? //or more controlled- via deathscripts? // Don't count player - if (( &g_entities[0] != NULL && g_entities[0].client ) && (self->s.number != 0)) + if (( g_entities[0].inuse && g_entities[0].client ) && (self->s.number != 0)) {//add to the number of teammates lost g_entities[0].client->ps.persistant[PERS_TEAMMATES_KILLED]++; } diff --git a/code/game/g_inventory.cpp b/code/game/g_inventory.cpp index 71720b0c64..8cb3eb539a 100644 --- a/code/game/g_inventory.cpp +++ b/code/game/g_inventory.cpp @@ -85,7 +85,7 @@ qboolean INV_SecurityKeyGive( gentity_t *target, const char *keyname ) return qfalse; } - for ( int i = 0; i <= 4; i++ ) + for ( int i = 0; i < MAX_SECURITY_KEYS; i++ ) { if ( target->client->ps.security_key_message[i][0] == '\0' ) {//fill in the first empty slot we find with this key @@ -98,16 +98,16 @@ qboolean INV_SecurityKeyGive( gentity_t *target, const char *keyname ) return qfalse; } -void INV_SecurityKeyTake( gentity_t *target, char *keyname ) +void INV_SecurityKeyTake( gentity_t *target, const char *keyname ) { if ( !target || !keyname || !target->client ) { return; } - for ( int i = 0; i <= 4; i++ ) + for ( int i = 0; i < MAX_SECURITY_KEYS; i++ ) { - if ( target->client->ps.security_key_message[i] ) + if ( target->client->ps.security_key_message[i][0] != '\0' ) { if ( !Q_stricmp( keyname, target->client->ps.security_key_message[i] ) ) { @@ -126,16 +126,16 @@ void INV_SecurityKeyTake( gentity_t *target, char *keyname ) } } -qboolean INV_SecurityKeyCheck( gentity_t *target, char *keyname ) +qboolean INV_SecurityKeyCheck( gentity_t *target, const char *keyname ) { if ( !target || !keyname || !target->client ) { return (qfalse); } - for ( int i = 0; i <= 4; i++ ) + for ( int i = 0; i < MAX_SECURITY_KEYS; i++ ) { - if ( target->client->ps.inventory[INV_SECURITY_KEY] && target->client->ps.security_key_message[i] ) + if ( target->client->ps.inventory[INV_SECURITY_KEY] && target->client->ps.security_key_message[i][0] != '\0' ) { if ( !Q_stricmp( keyname, target->client->ps.security_key_message[i] ) ) { diff --git a/code/game/g_items.cpp b/code/game/g_items.cpp index 96ecfb166f..96d6099c0f 100644 --- a/code/game/g_items.cpp +++ b/code/game/g_items.cpp @@ -1198,7 +1198,7 @@ void FinishSpawningItem( gentity_t *ent ) { gi.trace( &tr, ent->s.origin, ent->mins, ent->maxs, dest, ent->s.number, MASK_SOLID|CONTENTS_PLAYERCLIP, (EG2_Collision)0, 0 ); if ( tr.startsolid ) { - if ( &g_entities[tr.entityNum] != NULL ) + if ( g_entities[tr.entityNum].inuse ) { gi.Printf (S_COLOR_RED"FinishSpawningItem: removing %s startsolid at %s (in a %s)\n", ent->classname, vtos(ent->s.origin), g_entities[tr.entityNum].classname ); } diff --git a/code/game/g_local.h b/code/game/g_local.h index 73acc265e4..8f5d03a6af 100644 --- a/code/game/g_local.h +++ b/code/game/g_local.h @@ -617,8 +617,8 @@ extern qboolean INV_GoodieKeyGive( gentity_t *target ); extern qboolean INV_GoodieKeyTake( gentity_t *target ); extern int INV_GoodieKeyCheck( gentity_t *target ); extern qboolean INV_SecurityKeyGive( gentity_t *target, const char *keyname ); -extern void INV_SecurityKeyTake( gentity_t *target, char *keyname ); -extern qboolean INV_SecurityKeyCheck( gentity_t *target, char *keyname ); +extern void INV_SecurityKeyTake( gentity_t *target, const char *keyname ); +extern qboolean INV_SecurityKeyCheck( gentity_t *target, const char *keyname ); // // g_team.c diff --git a/code/game/g_missile.cpp b/code/game/g_missile.cpp index 020744f455..e5f955b566 100644 --- a/code/game/g_missile.cpp +++ b/code/game/g_missile.cpp @@ -1174,7 +1174,7 @@ void G_RollMissile( gentity_t *ent ) // // modify velocity so it parallels all of the clip planes // - if ( &g_entities[trace.entityNum] != NULL && g_entities[trace.entityNum].client ) + if ( g_entities[trace.entityNum].inuse && g_entities[trace.entityNum].client ) {//hit a person, bounce off much less bounceAmt = OVERCLIP; } diff --git a/code/game/g_navigator.cpp b/code/game/g_navigator.cpp index c1a56b43bb..21ca67b5a7 100644 --- a/code/game/g_navigator.cpp +++ b/code/game/g_navigator.cpp @@ -5490,7 +5490,7 @@ bool STEER::Reached(gentity_t* actor, NAV::TNodeHandle target, float targetRadiu //////////////////////////////////////////////////////////////////////////////////// bool STEER::Reached(gentity_t* actor, const vec3_t& target, float targetRadius, bool flying) { - if (!actor || !target) + if (!actor || VectorCompare(target, vec3_origin) ) { return false; } diff --git a/codeJK2/cgame/cg_camera.cpp b/codeJK2/cgame/cg_camera.cpp index 459fe4a722..5abb11956a 100644 --- a/codeJK2/cgame/cg_camera.cpp +++ b/codeJK2/cgame/cg_camera.cpp @@ -95,7 +95,7 @@ void CGCam_Enable( void ) client_camera.next_roff_time = 0; - if ( &g_entities[0] && g_entities[0].client ) + if ( g_entities[0].inuse && g_entities[0].client ) { //Player zero not allowed to do anything VectorClear( g_entities[0].client->ps.velocity ); @@ -148,7 +148,7 @@ void CGCam_Disable( void ) client_camera.info_state |= CAMERA_BAR_FADING; - if ( &g_entities[0] && g_entities[0].client ) + if ( g_entities[0].inuse && g_entities[0].client ) { g_entities[0].contents = CONTENTS_BODY;//MASK_PLAYERSOLID; } diff --git a/codeJK2/cgame/cg_main.cpp b/codeJK2/cgame/cg_main.cpp index a49ebf7321..2fb49dd93a 100644 --- a/codeJK2/cgame/cg_main.cpp +++ b/codeJK2/cgame/cg_main.cpp @@ -1436,7 +1436,7 @@ Ghoul2 Insert End for (i=0 ; i < ENTITYNUM_WORLD ; i++) { - if(&g_entities[i]) + if(g_entities[i].inuse) { if(g_entities[i].client) { diff --git a/codeJK2/cgame/cg_predict.cpp b/codeJK2/cgame/cg_predict.cpp index a849076229..6c92ef4d85 100644 --- a/codeJK2/cgame/cg_predict.cpp +++ b/codeJK2/cgame/cg_predict.cpp @@ -250,7 +250,7 @@ qboolean CG_CheckModifyUCmd( usercmd_t *cmd, vec3_t viewangles ) } } - if ( &g_entities[0] && g_entities[0].client ) + if ( g_entities[0].inuse && g_entities[0].client ) { if ( !PM_AdjustAnglesToGripper( &g_entities[0], cmd ) ) { diff --git a/codeJK2/cgame/cg_view.cpp b/codeJK2/cgame/cg_view.cpp index 2abf8931ae..e3dcdd650d 100644 --- a/codeJK2/cgame/cg_view.cpp +++ b/codeJK2/cgame/cg_view.cpp @@ -1111,7 +1111,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { // add view height if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD ) { - if ( &g_entities[cg.snap->ps.viewEntity] && + if ( g_entities[cg.snap->ps.viewEntity].inuse && g_entities[cg.snap->ps.viewEntity].client && g_entities[cg.snap->ps.viewEntity].client->ps.viewheight ) { @@ -1350,7 +1350,7 @@ static qboolean CG_CalcFov( void ) { && (!cg.renderingThirdPerson || g_entities[cg.snap->ps.viewEntity].e_DieFunc == dieF_camera_die) ) { // if in entity camera view, use a special FOV - if ( &g_entities[cg.snap->ps.viewEntity] && + if ( g_entities[cg.snap->ps.viewEntity].inuse && g_entities[cg.snap->ps.viewEntity].NPC ) {//FIXME: looks bad when take over a jedi... but never really do that, do we? fov_x = g_entities[cg.snap->ps.viewEntity].NPC->stats.hfov; diff --git a/codeJK2/game/g_active.cpp b/codeJK2/game/g_active.cpp index b11c447668..d204f64116 100644 --- a/codeJK2/game/g_active.cpp +++ b/codeJK2/game/g_active.cpp @@ -170,7 +170,7 @@ qboolean G_ClearViewEntity( gentity_t *ent ) if ( ent->client->ps.viewEntity > 0 && ent->client->ps.viewEntity < ENTITYNUM_NONE ) { - if ( &g_entities[ent->client->ps.viewEntity] ) + if ( g_entities[ent->client->ps.viewEntity].inuse ) { g_entities[ent->client->ps.viewEntity].svFlags &= ~SVF_BROADCAST; if ( g_entities[ent->client->ps.viewEntity].NPC ) diff --git a/codeJK2/game/g_combat.cpp b/codeJK2/game/g_combat.cpp index 7b208daf78..3a35dbf4d9 100644 --- a/codeJK2/game/g_combat.cpp +++ b/codeJK2/game/g_combat.cpp @@ -3561,7 +3561,7 @@ extern void RunEmplacedWeapon( gentity_t *ent, usercmd_t **ucmd ); {//FIXME: just HazTeam members in formation on away missions? //or more controlled- via deathscripts? // Don't count player - if (( &g_entities[0] != NULL && g_entities[0].client ) && (self->s.number != 0)) + if (( g_entities[0].inuse && g_entities[0].client ) && (self->s.number != 0)) {//add to the number of teammates lost g_entities[0].client->ps.persistant[PERS_TEAMMATES_KILLED]++; } diff --git a/codeJK2/game/g_inventory.cpp b/codeJK2/game/g_inventory.cpp index cec16fc16c..46afc0cfb2 100644 --- a/codeJK2/game/g_inventory.cpp +++ b/codeJK2/game/g_inventory.cpp @@ -88,7 +88,7 @@ qboolean INV_SecurityKeyGive( gentity_t *target, const char *keyname ) return qfalse; } - for ( int i = 0; i <= 4; i++ ) + for ( int i = 0; i < MAX_SECURITY_KEYS; i++ ) { if ( target->client->ps.security_key_message[i][0] == '\0' ) {//fill in the first empty slot we find with this key @@ -102,16 +102,16 @@ qboolean INV_SecurityKeyGive( gentity_t *target, const char *keyname ) return qfalse; } -void INV_SecurityKeyTake( gentity_t *target, char *keyname ) +void INV_SecurityKeyTake( gentity_t *target, const char *keyname ) { if ( !target || !keyname || !target->client ) { return; } - for ( int i = 0; i <= 4; i++ ) + for ( int i = 0; i < MAX_SECURITY_KEYS; i++ ) { - if ( target->client->ps.security_key_message[i] ) + if ( target->client->ps.security_key_message[i][0] != '\0' ) { if ( !Q_stricmp( keyname, target->client->ps.security_key_message[i] ) ) { @@ -130,16 +130,16 @@ void INV_SecurityKeyTake( gentity_t *target, char *keyname ) } } -qboolean INV_SecurityKeyCheck( gentity_t *target, char *keyname ) +qboolean INV_SecurityKeyCheck( gentity_t *target, const char *keyname ) { if ( !target || !keyname || !target->client ) { return (qfalse); } - for ( int i = 0; i <= 4; i++ ) + for ( int i = 0; i < MAX_SECURITY_KEYS; i++ ) { - if ( target->client->ps.inventory[INV_SECURITY_KEY] && target->client->ps.security_key_message[i] ) + if ( target->client->ps.inventory[INV_SECURITY_KEY] && target->client->ps.security_key_message[i][0] != '\0' ) { if ( !Q_stricmp( keyname, target->client->ps.security_key_message[i] ) ) { diff --git a/codeJK2/game/g_items.cpp b/codeJK2/game/g_items.cpp index 07877b3cab..165e03e36e 100644 --- a/codeJK2/game/g_items.cpp +++ b/codeJK2/game/g_items.cpp @@ -882,7 +882,7 @@ void FinishSpawningItem( gentity_t *ent ) { gi.trace( &tr, ent->s.origin, ent->mins, ent->maxs, dest, ent->s.number, MASK_SOLID|CONTENTS_PLAYERCLIP, G2_NOCOLLIDE, 0 ); if ( tr.startsolid ) { - if ( &g_entities[tr.entityNum] != NULL ) + if ( g_entities[tr.entityNum].inuse ) { gi.Printf (S_COLOR_RED"FinishSpawningItem: removing %s startsolid at %s (in a %s)\n", ent->classname, vtos(ent->s.origin), g_entities[tr.entityNum].classname ); } diff --git a/codeJK2/game/g_local.h b/codeJK2/game/g_local.h index fbc630cc24..e4c4c11741 100644 --- a/codeJK2/game/g_local.h +++ b/codeJK2/game/g_local.h @@ -555,8 +555,8 @@ extern qboolean INV_GoodieKeyGive( gentity_t *target ); extern qboolean INV_GoodieKeyTake( gentity_t *target ); extern int INV_GoodieKeyCheck( gentity_t *target ); extern qboolean INV_SecurityKeyGive( gentity_t *target, const char *keyname ); -extern void INV_SecurityKeyTake( gentity_t *target, char *keyname ); -extern qboolean INV_SecurityKeyCheck( gentity_t *target, char *keyname ); +extern void INV_SecurityKeyTake( gentity_t *target, const char *keyname ); +extern qboolean INV_SecurityKeyCheck( gentity_t *target, const char *keyname ); // // g_team.c diff --git a/codeJK2/game/g_missile.cpp b/codeJK2/game/g_missile.cpp index 875f4ad7d5..b340f302aa 100644 --- a/codeJK2/game/g_missile.cpp +++ b/codeJK2/game/g_missile.cpp @@ -1055,7 +1055,7 @@ void G_RollMissile( gentity_t *ent ) // // modify velocity so it parallels all of the clip planes // - if ( &g_entities[trace.entityNum] != NULL && g_entities[trace.entityNum].client ) + if ( g_entities[trace.entityNum].inuse && g_entities[trace.entityNum].client ) {//hit a person, bounce off much less bounceAmt = OVERCLIP; } diff --git a/codemp/client/snd_mem.cpp b/codemp/client/snd_mem.cpp index ba07a3356d..16bcd57daa 100644 --- a/codemp/client/snd_mem.cpp +++ b/codemp/client/snd_mem.cpp @@ -258,10 +258,10 @@ void ResampleSfx (sfx_t *sfx, int iInRate, int iInWidth, byte *pData) void S_LoadSound_Finalize(wavinfo_t *info, sfx_t *sfx, byte *data) { - float stepscale = (float)info->rate / dma.speed; - int len = (int)(info->samples / stepscale); + //float stepscale = (float)info->rate / dma.speed; + //int len = (int)(info->samples / stepscale); - len *= info->width; + //len *= info->width; sfx->eSoundCompressionMethod = ct_16; sfx->iSoundLengthInSamples = info->samples; diff --git a/codemp/game/ai_main.c b/codemp/game/ai_main.c index 8e6a96e586..3908e2c119 100644 --- a/codemp/game/ai_main.c +++ b/codemp/game/ai_main.c @@ -3119,7 +3119,7 @@ int Siege_TargetClosestObjective(bot_state_t *bs, int flag) maxs[2] = 1; if ( bs->wpDestination && (bs->wpDestination->flags & flag) && bs->wpDestination->associated_entity != ENTITYNUM_NONE && - &g_entities[bs->wpDestination->associated_entity] && g_entities[bs->wpDestination->associated_entity].use ) + g_entities[bs->wpDestination->associated_entity].inuse && g_entities[bs->wpDestination->associated_entity].use ) { goto hasPoint; } @@ -3127,7 +3127,7 @@ int Siege_TargetClosestObjective(bot_state_t *bs, int flag) while (i < gWPNum) { if ( gWPArray[i] && gWPArray[i]->inuse && (gWPArray[i]->flags & flag) && gWPArray[i]->associated_entity != ENTITYNUM_NONE && - &g_entities[gWPArray[i]->associated_entity] && g_entities[gWPArray[i]->associated_entity].use ) + g_entities[gWPArray[i]->associated_entity].inuse && g_entities[gWPArray[i]->associated_entity].use ) { VectorSubtract(gWPArray[i]->origin, bs->origin, a); testdistance = VectorLength(a); diff --git a/codemp/game/g_client.c b/codemp/game/g_client.c index 757290dc74..a46845ddb5 100644 --- a/codemp/game/g_client.c +++ b/codemp/game/g_client.c @@ -698,7 +698,7 @@ gentity_t *SelectRandomFurthestSpawnPoint ( vec3_t avoidPoint, vec3_t origin, ve && team != TEAM_FREE && team != TEAM_SPECTATOR ) { - char *classname = NULL; + const char *classname = NULL; if ( team == TEAM_RED ) { classname = "info_player_start_red"; @@ -808,7 +808,7 @@ gentity_t *SelectDuelSpawnPoint( int team, vec3_t avoidPoint, vec3_t origin, vec float list_dist[MAX_SPAWN_POINTS]; gentity_t *list_spot[MAX_SPAWN_POINTS]; int numSpots, rnd, i, j; - char *spotName; + const char *spotName; if (team == DUELTEAM_LONE) { diff --git a/codemp/game/g_team.c b/codemp/game/g_team.c index 80032eaef0..f43fc1636f 100644 --- a/codemp/game/g_team.c +++ b/codemp/game/g_team.c @@ -1034,7 +1034,7 @@ gentity_t *SelectRandomTeamSpawnPoint( int teamstate, team_t team, int siegeClas int count; int selection; gentity_t *spots[MAX_TEAM_SPAWN_POINTS]; - char *classname; + const char *classname; qboolean mustBeEnabled = qfalse; if (level.gametype == GT_SIEGE) From 9d4cac81db0495becedf4c368f34b9b9e35f75d5 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Wed, 8 Mar 2023 18:46:51 -0600 Subject: [PATCH 636/801] Better overflow checking in scores command --- codemp/game/g_cmds.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/codemp/game/g_cmds.c b/codemp/game/g_cmds.c index a8125ab990..e5c7e24d29 100644 --- a/codemp/game/g_cmds.c +++ b/codemp/game/g_cmds.c @@ -43,25 +43,29 @@ DeathmatchScoreboardMessage ================== */ void DeathmatchScoreboardMessage( gentity_t *ent ) { - char entry[1024]; - char string[1400]; - int stringlength; + char entry[256]; + char string[MAX_STRING_CHARS-1]; + int stringlength, prefix; int i, j; gclient_t *cl; int numSorted, scoreFlags, accuracy, perfect; // send the latest information on all clients - string[0] = 0; + string[0] = '\0'; stringlength = 0; scoreFlags = 0; numSorted = level.numConnectedClients; + // This is dumb that we are capping to 20 clients but support 32 in server if (numSorted > MAX_CLIENT_SCORE_SEND) { numSorted = MAX_CLIENT_SCORE_SEND; } + // estimate prefix length to avoid oversize of final string + prefix = Com_sprintf( entry, sizeof(entry), "scores %i %i %i", level.teamScores[TEAM_RED], level.teamScores[TEAM_BLUE], level.numConnectedClients ); + for (i=0 ; i < numSorted ; i++) { int ping; @@ -81,7 +85,7 @@ void DeathmatchScoreboardMessage( gentity_t *ent ) { } perfect = ( cl->ps.persistant[PERS_RANK] == 0 && cl->ps.persistant[PERS_KILLED] == 0 ) ? 1 : 0; - Com_sprintf (entry, sizeof(entry), + j = Com_sprintf (entry, sizeof(entry), " %i %i %i %i %i %i %i %i %i %i %i %i %i %i", level.sortedClients[i], cl->ps.persistant[PERS_SCORE], ping, (level.time - cl->pers.enterTime)/60000, scoreFlags, g_entities[level.sortedClients[i]].s.powerups, accuracy, @@ -92,17 +96,15 @@ void DeathmatchScoreboardMessage( gentity_t *ent ) { cl->ps.persistant[PERS_ASSIST_COUNT], perfect, cl->ps.persistant[PERS_CAPTURES]); - j = strlen(entry); - if (stringlength + j > 1022) + + if (stringlength + j + prefix >= sizeof(string)) break; - strcpy (string + stringlength, entry); + + strcpy( string + stringlength, entry ); stringlength += j; } - //still want to know the total # of clients - i = level.numConnectedClients; - - trap->SendServerCommand( ent-g_entities, va("scores %i %i %i%s", i, + trap->SendServerCommand( ent-g_entities, va("scores %i %i %i%s", level.numConnectedClients, level.teamScores[TEAM_RED], level.teamScores[TEAM_BLUE], string ) ); } From 04cd89f0e09ef5a6027e0ed3bd736d685b55586f Mon Sep 17 00:00:00 2001 From: Ensiform Date: Wed, 8 Mar 2023 19:42:21 -0600 Subject: [PATCH 637/801] MP3 stereo fixes This code seems to be in JKA but not JK2 thus allowing stereo MP3s by removing it. --- code/mp3code/towave.c | 7 ------- codemp/mp3code/towave.c | 6 ------ 2 files changed, 13 deletions(-) diff --git a/code/mp3code/towave.c b/code/mp3code/towave.c index 344d3548d0..ff83a00229 100644 --- a/code/mp3code/towave.c +++ b/code/mp3code/towave.c @@ -273,13 +273,6 @@ char *C_MP3_IsValid(void *pvData, int iDataLen, int bStereoDesired) // although the decoder can convert stereo to mono (apparently), we want to know about stereo files // because they're a waste of source space... (all FX are mono, and moved via panning) // - if (head.mode != 3 && !bStereoDesired && iDataLen > 98000) //3 seems to mean mono - {// we'll allow it for small files even if stereo - if ( iDataLen != 1050024 ) //fixme, make cinematic_1 play as music instead - { - return "MP3ERR: Sound file is stereo!"; - } - } if (audio.decode_init(&head, iFrameBytes, reduction_code, iRealDataStart, bStereoDesired?convert_code_stereo:convert_code_mono, freq_limit)) { if (bStereoDesired) diff --git a/codemp/mp3code/towave.c b/codemp/mp3code/towave.c index eadf5d4431..98d09c0037 100644 --- a/codemp/mp3code/towave.c +++ b/codemp/mp3code/towave.c @@ -271,12 +271,6 @@ char *C_MP3_IsValid(void *pvData, int iDataLen, int bStereoDesired) // although the decoder can convert stereo to mono (apparently), we want to know about stereo files // because they're a waste of source space... (all FX are mono, and moved via panning) // - if (head.mode != 3 && !bStereoDesired) //3 seems to mean mono - { - if (iDataLen > 98000) { // we'll allow it for small files even if stereo - return "MP3ERR: Sound file is stereo!"; - } - } if (audio.decode_init(&head, iFrameBytes, reduction_code, iRealDataStart, bStereoDesired?convert_code_stereo:convert_code_mono, freq_limit)) { if (bStereoDesired) From f35116c8b8708ea985c1c58e52e91bceccfa738e Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 9 Mar 2023 09:22:44 -0600 Subject: [PATCH 638/801] Add win64 builds --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7da53c61ab..a1d035730d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -283,6 +283,7 @@ 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-Release-Non-Portable/* OpenJK-linux-x86.tar.gz 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 @@ -310,6 +311,10 @@ jobs: artifact_name: OpenJK-windows-x86.zip zip: true + - artifact_dir: OpenJK-windows-x86_64-Release-Non-Portable/JediAcademy + artifact_name: OpenJK-windows-x86_64.zip + zip: true + - artifact_dir: OpenJK-linux-x86-Release-Non-Portable artifact_name: OpenJK-linux-x86.tar.gz zip: false From 96d9b3c9172184251ff7a765ee892caab7a73bee Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sat, 11 Mar 2023 02:45:27 +0100 Subject: [PATCH 639/801] 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 640/801] 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 641/801] 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 642/801] 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 643/801] 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 644/801] 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 645/801] 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 646/801] [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 647/801] [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 648/801] 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 649/801] 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 650/801] 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 651/801] 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 652/801] 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 653/801] 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 654/801] 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 655/801] 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 656/801] 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 657/801] 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 658/801] 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 659/801] 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 660/801] 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 661/801] 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 662/801] 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 663/801] 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 664/801] 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 665/801] 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 666/801] 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 667/801] 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 668/801] 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 669/801] 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 670/801] 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 671/801] 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 672/801] 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 673/801] 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 674/801] 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 675/801] 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 d3e8c8d71e58a2c55f13d36de042c4e913ca36ab Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 9 Apr 2023 10:25:48 -0500 Subject: [PATCH 676/801] Possibly fixed JK2's asian languages Korean, Taiwanese, and Japanese are only 3 supported by JK2. Other non-western languages not supported in JK2 compared to JKA. --- code/rd-common/tr_font.cpp | 101 ++++++++++++++++++++++++++++++++----- 1 file changed, 89 insertions(+), 12 deletions(-) diff --git a/code/rd-common/tr_font.cpp b/code/rd-common/tr_font.cpp index 0c1cf81661..671b38128b 100644 --- a/code/rd-common/tr_font.cpp +++ b/code/rd-common/tr_font.cpp @@ -30,6 +30,10 @@ along with this program; if not, see . #include "../qcommon/stringed_ingame.h" +#ifdef JK2_MODE +#include "../qcommon/strippublic.h" +#endif + ///////////////////////////////////////////////////////////////////////////////////////////////////////// // // This file is shared in the single and multiplayer codebases, so be CAREFUL WHAT YOU ADD/CHANGE!!!!! @@ -39,27 +43,40 @@ along with this program; if not, see . typedef enum { eWestern, // ( I only care about asian languages in here at the moment ) +#ifndef JK2_MODE eRussian, // .. but now I need to care about this, since it uses a different TP ePolish, // ditto +#endif eKorean, eTaiwanese, // 15x15 glyphs tucked against BR of 16x16 space eJapanese, // 15x15 glyphs tucked against TL of 16x16 space +#ifndef JK2_MODE eChinese, // 15x15 glyphs tucked against TL of 16x16 space eThai, // 16x16 cells with glyphs against left edge, special file (tha_widths.dat) for variable widths +#endif } Language_e; // this is to cut down on all the stupid string compares I've been doing, and convert asian stuff to switch-case // -Language_e GetLanguageEnum() +static Language_e GetLanguageEnum() { -#ifndef JK2_MODE - static int iSE_Language_ModificationCount = -1234; // any old silly value that won't match the cvar mod count -#endif static Language_e eLanguage = eWestern; +#ifdef JK2_MODE + if ( !sp_language ) + return eLanguage; + else if ( sp_language->integer == SP_LANGUAGE_KOREAN ) + eLanguage = eKorean; + else if ( sp_language->integer == SP_LANGUAGE_JAPANESE ) + eLanguage = eJapanese; + else if ( sp_language->integer == SP_LANGUAGE_TAIWANESE ) + eLanguage = eTaiwanese; + + return eLanguage; +#else + static int iSE_Language_ModificationCount = -1234; // any old silly value that won't match the cvar mod count // only re-strcmp() when language string has changed from what we knew it as... // -#ifndef JK2_MODE if (iSE_Language_ModificationCount != se_language->modificationCount ) { iSE_Language_ModificationCount = se_language->modificationCount; @@ -73,11 +90,11 @@ Language_e GetLanguageEnum() else if ( Language_IsThai() ) eLanguage = eThai; else eLanguage = eWestern; } -#endif - return eLanguage; +#endif } +#ifndef JK2_MODE struct SBCSOverrideLanguages_t { const char *m_psName; @@ -191,6 +208,7 @@ struct ThaiCodes_t return m_strInitFailureReason.c_str(); } }; +#endif #define GLYPH_MAX_KOREAN_SHADERS 3 @@ -216,9 +234,15 @@ class CFontInfo int m_iAsianGlyphsAcross; // needed to dynamically calculate S,T coords int m_iAsianPagesLoaded; bool m_bAsianLastPageHalfHeight; +#ifdef JK2_MODE + int m_iAsianLanguageLoaded; // doesn't matter what this is, so long as it's comparable as being changed +#else int m_iLanguageModificationCount; // doesn't matter what this is, so long as it's comparable as being changed +#endif +#ifndef JK2_MODE ThaiCodes_t *m_pThaiData; +#endif public: char m_sFontName[MAX_QPATH]; // eg "fonts/lcd" // needed for korean font-hint if we need >1 hangul set @@ -228,10 +252,12 @@ class CFontInfo int mDescender; bool mbRoundCalcs; // trying to make this !@#$%^ thing work with scaling +#ifndef JK2_MODE int m_iThisFont; // handle to itself int m_iAltSBCSFont; // -1 == NULL // alternative single-byte font for languages like russian/polish etc that need to override high characters ? int m_iOriginalFontWhenSBCSOverriden; float m_fAltSBCSFontScaleFactor; // -1, else amount to adjust returned values by to make them fit the master western font they're substituting for +#endif bool m_bIsFakeAlienLanguage; // ... if true, don't process as MBCS or override as SBCS etc CFontInfo(const char *fontName); @@ -250,7 +276,11 @@ class CFontInfo const int GetLetterHorizAdvance(const unsigned int uiLetter); const int GetShader(void) const { return(mShader); } +#ifdef JK2_MODE + void FlagNoAsianGlyphs(void) { m_hAsianShaders[0] = 0; m_iAsianLanguageLoaded = -1; } // used during constructor +#else void FlagNoAsianGlyphs(void) { m_hAsianShaders[0] = 0; m_iLanguageModificationCount = -1; } // used during constructor +#endif bool AsianGlyphsAvailable(void) const { return !!(m_hAsianShaders[0]); } void UpdateAsianIfNeeded( bool bForceReEval = false); @@ -503,6 +533,7 @@ static int Japanese_InitFields(int &iGlyphTPs, const char *&psLang) return 64; // m_iAsianGlyphsAcross } +#ifndef JK2_MODE // ======================== some Chinese stuff ============================== #define GB_HIBYTE_START 0xA1 // range is... @@ -527,7 +558,6 @@ static inline qboolean Chinese_ValidGBCode( unsigned int uiCode) return Chinese_ValidGBCode( uiCode >> 8, uiCode & 0xFF ); } -#ifndef JK2_MODE // only call this when Chinese_ValidGBCode() has already returned true... // static qboolean Chinese_IsTrailingPunctuation( unsigned int uiCode ) @@ -543,7 +573,6 @@ static qboolean Chinese_IsTrailingPunctuation( unsigned int uiCode ) return qfalse; } -#endif // takes a GB double-byte code and collapses down to a 0..n glyph index... // Assumes rows are 96 wide (glyph slots), not 94 wide (actual glyphs), so I can ignore boundary markers @@ -595,7 +624,6 @@ static int Thai_IsAccentChar( unsigned int uiCode ) } */ -#ifndef JK2_MODE // returns a valid Thai code (or 0), based on taking 1,2 or 3 bytes from the supplied byte stream // Fills in with 1,2 or 3 static int Thai_ValidTISCode( const byte *psString, int &iThaiBytes ) @@ -638,7 +666,6 @@ static int Thai_ValidTISCode( const byte *psString, int &iThaiBytes ) return 0; } -#endif // special case, thai can only break on certain letters, and since the rules are complicated then // we tell the translators to put an underscore ('_') between each word even though in Thai they're @@ -674,6 +701,7 @@ static int Thai_InitFields(int &iGlyphTPs, const char *&psLang) g_iNonScaledCharRange = INT_MAX; // in other words, don't scale any thai chars down return 32; // m_iAsianGlyphsAcross } +#endif // ============================================================================ @@ -914,8 +942,10 @@ qboolean Language_IsAsian(void) case eKorean: case eTaiwanese: case eJapanese: +#ifndef JK2_MODE case eChinese: case eThai: // this is asian, but the query is normally used for scaling +#endif return qtrue; default: break; @@ -931,8 +961,10 @@ qboolean Language_UsesSpaces(void) { case eTaiwanese: case eJapanese: +#ifndef JK2_MODE case eChinese: case eThai: +#endif return qfalse; default: break; @@ -960,11 +992,13 @@ CFontInfo::CFontInfo(const char *_fontName) // clear some general things... // +#ifndef JK2_MODE m_pThaiData = NULL; m_iAltSBCSFont = -1; m_iThisFont = -1; m_iOriginalFontWhenSBCSOverriden = -1; m_fAltSBCSFontScaleFactor = -1; +#endif m_bIsFakeAlienLanguage = !strcmp(_fontName,"aurabesh"); // dont try and make SBCS or asian overrides for this len = ri.FS_ReadFile(fontName, NULL); @@ -1041,6 +1075,7 @@ CFontInfo::CFontInfo(const char *_fontName) // SBCS override languages... // fileHandle_t f; +#ifndef JK2_MODE for (int i=0; g_SBCSOverrideLanguages[i].m_psName ;i++) { char sTemp[MAX_QPATH]; @@ -1053,16 +1088,23 @@ CFontInfo::CFontInfo(const char *_fontName) ri.FS_FOpenFileRead( sTemp, &f, qfalse ); if (f) ri.FS_FCloseFile( f ); } +#endif // asian MBCS override languages... // +#ifdef JK2_MODE + for (int iLang=0; iLang<3; iLang++) +#else for (int iLang=0; iLang<5; iLang++) +#endif + { switch (iLang) { case 0: m_iAsianGlyphsAcross = Korean_InitFields (iGlyphTPs, psLang); break; case 1: m_iAsianGlyphsAcross = Taiwanese_InitFields (iGlyphTPs, psLang); break; case 2: m_iAsianGlyphsAcross = Japanese_InitFields (iGlyphTPs, psLang); break; +#ifndef JK2_MODE case 3: m_iAsianGlyphsAcross = Chinese_InitFields (iGlyphTPs, psLang); break; case 4: m_iAsianGlyphsAcross = Thai_InitFields (iGlyphTPs, psLang); { @@ -1079,6 +1121,7 @@ CFontInfo::CFontInfo(const char *_fontName) } } break; +#endif } for (int i=0; imodificationCount || !AsianGlyphsAvailable() || bForceReEval) { m_iLanguageModificationCount = se_language->modificationCount; +#endif int iGlyphTPs = 0; const char *psLang = NULL; @@ -1120,6 +1174,7 @@ void CFontInfo::UpdateAsianIfNeeded( bool bForceReEval /* = false */ ) case eKorean: m_iAsianGlyphsAcross = Korean_InitFields(iGlyphTPs, psLang); break; case eTaiwanese: m_iAsianGlyphsAcross = Taiwanese_InitFields(iGlyphTPs, psLang); break; case eJapanese: m_iAsianGlyphsAcross = Japanese_InitFields(iGlyphTPs, psLang); break; +#ifndef JK2_MODE case eChinese: m_iAsianGlyphsAcross = Chinese_InitFields(iGlyphTPs, psLang); break; case eThai: { @@ -1142,6 +1197,7 @@ void CFontInfo::UpdateAsianIfNeeded( bool bForceReEval /* = false */ ) } } break; +#endif default: break; } @@ -1189,7 +1245,10 @@ void CFontInfo::UpdateAsianIfNeeded( bool bForceReEval /* = false */ ) case eTaiwanese: case eJapanese: - case eChinese: m_AsianGlyph.horizAdvance = iCappedHeight + 3; // need to force some spacing for these +#ifndef JK2_MODE + case eChinese: +#endif + m_AsianGlyph.horizAdvance = iCappedHeight + 3; // need to force some spacing for these // case eThai: // this is done dynamically elsewhere, since Thai glyphs are variable width } m_AsianGlyph.horizOffset = 0; // "" @@ -1282,7 +1341,9 @@ const glyphInfo_t *CFontInfo::GetLetter(const unsigned int uiLetter, int *piShad break; case eJapanese: +#ifndef JK2_MODE case eChinese: +#endif { m_AsianGlyph.s = (float)(((1024 / m_iAsianGlyphsAcross) * ( iColumn )) ) / 1024.0f; m_AsianGlyph.t = (float)(((1024 / iAsianGlyphsDown ) * ( iRow )) ) / 1024.0f; @@ -1291,6 +1352,7 @@ const glyphInfo_t *CFontInfo::GetLetter(const unsigned int uiLetter, int *piShad } break; +#ifndef JK2_MODE case eThai: { int iGlyphXpos = (1024 / m_iAsianGlyphsAcross) * ( iColumn ); @@ -1318,6 +1380,7 @@ const glyphInfo_t *CFontInfo::GetLetter(const unsigned int uiLetter, int *piShad m_AsianGlyph.horizAdvance = iGlyphWidth + 1; } break; +#endif } *piShader = m_hAsianShaders[ iTexturePageIndex ]; } @@ -1334,6 +1397,7 @@ const glyphInfo_t *CFontInfo::GetLetter(const unsigned int uiLetter, int *piShad // // SBCS language substitution?... // +#ifndef JK2_MODE if ( m_fAltSBCSFontScaleFactor != -1 ) { // sod it, use the asian glyph, that's fine... @@ -1353,6 +1417,7 @@ const glyphInfo_t *CFontInfo::GetLetter(const unsigned int uiLetter, int *piShad pGlyph = &m_AsianGlyph; } +#endif return pGlyph; } @@ -1368,8 +1433,10 @@ const int CFontInfo::GetCollapsedAsianCode(ulong uiLetter) const case eKorean: iCollapsedAsianCode = Korean_CollapseKSC5601HangulCode( uiLetter ); break; case eTaiwanese: iCollapsedAsianCode = Taiwanese_CollapseBig5Code( uiLetter ); break; case eJapanese: iCollapsedAsianCode = Japanese_CollapseShiftJISCode( uiLetter ); break; +#ifndef JK2_MODE case eChinese: iCollapsedAsianCode = Chinese_CollapseGBCode( uiLetter ); break; case eThai: iCollapsedAsianCode = Thai_CollapseTISCode( uiLetter ); break; +#endif default: assert(0); /* unhandled asian language */ break; } } @@ -1391,6 +1458,7 @@ const int CFontInfo::GetLetterHorizAdvance(unsigned int uiLetter) // ensure any GetFont calls that need SBCS overriding (such as when playing in Russian) have the appropriate stuff done... // +#ifndef JK2_MODE static CFontInfo *GetFont_SBCSOverride(CFontInfo *pFont, Language_e eLanguageSBCS, const char *psLanguageNameSBCS ) { if ( !pFont->m_bIsFakeAlienLanguage ) @@ -1436,6 +1504,7 @@ static CFontInfo *GetFont_SBCSOverride(CFontInfo *pFont, Language_e eLanguageSBC return NULL; } +#endif @@ -1443,6 +1512,7 @@ CFontInfo *GetFont(int index) { CFontInfo *pFont = GetFont_Actual( index ); +#ifndef JK2_MODE if (pFont) { // any SBCS overrides? (this has to be pretty quick, and is (sort of))... @@ -1456,6 +1526,7 @@ CFontInfo *GetFont(int index) } } } +#endif return pFont; } @@ -1590,7 +1661,9 @@ int RE_Font_StrLenChars(const char *psText) break; // colour code (note next-char skip) case 10: break; // linefeed case 13: break; // return +#ifndef JK2_MODE case '_': iCharCount += (GetLanguageEnum() == eThai && (((unsigned char *)psText)[0] >= TIS_GLYPHS_START))?0:1; break; // special word-break hack +#endif default: iCharCount++; break; } } @@ -1974,7 +2047,9 @@ int RE_RegisterFont(const char *psName) { int iFontIndex = g_iCurrentFontIndex - 1; g_mapFontIndexes[psName] = iFontIndex; +#ifndef JK2_MODE pFont->m_iThisFont = iFontIndex; +#endif return iFontIndex; } else @@ -2025,7 +2100,9 @@ void R_ShutdownFonts(void) g_vFontArray.clear(); g_iCurrentFontIndex = 1; // entry 0 is reserved for "missing/invalid" +#ifndef JK2_MODE g_ThaiCodes.Clear(); +#endif } // this is only really for debugging while tinkering with fonts, but harmless to leave in... From 6f5c5788ab9306e75c7f1377ed7f2fc2a556e5c4 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 9 Apr 2023 10:31:45 -0500 Subject: [PATCH 677/801] Fixed some errors pointed out by sanitizers and clang --- code/cgame/cg_main.cpp | 2 +- code/client/snd_mem.cpp | 2 +- code/qcommon/cm_polylib.cpp | 8 ++++---- code/qcommon/z_memman_pc.cpp | 10 +++++----- code/rd-vanilla/tr_bsp.cpp | 4 ++-- code/rd-vanilla/tr_model.cpp | 2 +- codeJK2/cgame/cg_main.cpp | 2 +- codemp/client/snd_mem.cpp | 2 +- codemp/qcommon/RoffSystem.cpp | 14 +++++++------- codemp/qcommon/z_memman_pc.cpp | 4 ++-- codemp/rd-vanilla/tr_bsp.cpp | 2 +- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/code/cgame/cg_main.cpp b/code/cgame/cg_main.cpp index 9823ec8419..86bf1a0c78 100644 --- a/code/cgame/cg_main.cpp +++ b/code/cgame/cg_main.cpp @@ -101,7 +101,7 @@ This is the only way control passes into the cgame module. This must be the very first function compiled into the .q3vm file ================ */ -extern "C" Q_EXPORT intptr_t QDECL vmMain( intptr_t command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7 ) { +extern "C" Q_EXPORT intptr_t QDECL vmMain( int command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7 ) { centity_t *cent; switch ( command ) { diff --git a/code/client/snd_mem.cpp b/code/client/snd_mem.cpp index fb7ea05b2b..97b4f4b4d1 100644 --- a/code/client/snd_mem.cpp +++ b/code/client/snd_mem.cpp @@ -236,7 +236,7 @@ void ResampleSfx (sfx_t *sfx, int iInRate, int iInWidth, byte *pData) if (iInWidth == 2) { iSample = LittleShort ( ((short *)pData)[iSrcSample] ); } else { - iSample = (int)( (unsigned char)(pData[iSrcSample]) - 128) << 8; + iSample = (unsigned int)( (unsigned char)(pData[iSrcSample]) - 128) << 8; } sfx->pSoundData[i] = (short)iSample; diff --git a/code/qcommon/cm_polylib.cpp b/code/qcommon/cm_polylib.cpp index bfdca8fe0c..95d4b6a1ca 100644 --- a/code/qcommon/cm_polylib.cpp +++ b/code/qcommon/cm_polylib.cpp @@ -188,12 +188,12 @@ ChopWindingInPlace void ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t epsilon) { winding_t *in; - vec_t dists[MAX_POINTS_ON_WINDING+4]; - int sides[MAX_POINTS_ON_WINDING+4]; + float dists[MAX_POINTS_ON_WINDING+4] = { 0 }; + int sides[MAX_POINTS_ON_WINDING+4] = { 0 }; int counts[3]; - static vec_t dot; // VC 4.2 optimizer bug if not static + static float dot; // VC 4.2 optimizer bug if not static int i, j; - vec_t *p1, *p2; + float *p1, *p2; vec3_t mid; winding_t *f; int maxpts; diff --git a/code/qcommon/z_memman_pc.cpp b/code/qcommon/z_memman_pc.cpp index b2cab8b793..d0051ed635 100644 --- a/code/qcommon/z_memman_pc.cpp +++ b/code/qcommon/z_memman_pc.cpp @@ -993,15 +993,15 @@ Touch all known used data to make sure it is paged in void Com_TouchMemory( void ) { //int start, end; int i, j; - int sum; - int totalTouched; + unsigned int sum; + //int totalTouched; Z_Validate(); //start = Sys_Milliseconds(); sum = 0; - totalTouched=0; + //totalTouched=0; zoneHeader_t *pMemory = TheZone.Header.pNext; while (pMemory) @@ -1009,9 +1009,9 @@ void Com_TouchMemory( void ) { byte *pMem = (byte *) &pMemory[1]; j = pMemory->iSize >> 2; for (i=0; iiSize; + //totalTouched+=pMemory->iSize; pMemory = pMemory->pNext; } diff --git a/code/rd-vanilla/tr_bsp.cpp b/code/rd-vanilla/tr_bsp.cpp index 5ea038d541..afbbb175f6 100644 --- a/code/rd-vanilla/tr_bsp.cpp +++ b/code/rd-vanilla/tr_bsp.cpp @@ -395,7 +395,7 @@ static void ParseFace( dsurface_t *ds, mapVert_t *verts, msurface_t *surf, int * numIndexes = LittleLong( ds->numIndexes ); // create the srfSurfaceFace_t - sfaceSize = ( intptr_t ) &((srfSurfaceFace_t *)0)->points[numPoints]; + sfaceSize = sizeof( *cv ) - sizeof( cv->points ) + sizeof( cv->points[0] ) * numPoints; ofsIndexes = sfaceSize; sfaceSize += sizeof( int ) * numIndexes; @@ -684,7 +684,7 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump, wor { case MST_PLANAR: - int sfaceSize = ( intptr_t ) &((srfSurfaceFace_t *)0)->points[LittleLong(in->numVerts)]; + int sfaceSize = sizeof( srfSurfaceFace_t ) - sizeof( float[1][VERTEXSIZE] ) + sizeof( float[VERTEXSIZE] ) * LittleLong(in->numVerts); sfaceSize += sizeof( int ) * LittleLong(in->numIndexes); iFaceDataSizeRequired += sfaceSize; diff --git a/code/rd-vanilla/tr_model.cpp b/code/rd-vanilla/tr_model.cpp index 9b2d74fdaa..a6d5bc7b34 100644 --- a/code/rd-vanilla/tr_model.cpp +++ b/code/rd-vanilla/tr_model.cpp @@ -768,7 +768,7 @@ qhandle_t RE_RegisterModel( const char *name ) qhandle_t q = RE_RegisterModel_Actual( name ); - if (Q_stricmp(&name[strlen(name)-4],".gla")){ + if (!COM_CompareExtension(name, ".gla")) { gbInsideRegisterModel = qfalse; // GLA files recursively call this, so don't turn off half way. A reference count would be nice, but if any ERR_DROP ever occurs within the load then the refcount will be knackered from then on } diff --git a/codeJK2/cgame/cg_main.cpp b/codeJK2/cgame/cg_main.cpp index 2fb49dd93a..9be003e9a9 100644 --- a/codeJK2/cgame/cg_main.cpp +++ b/codeJK2/cgame/cg_main.cpp @@ -103,7 +103,7 @@ This is the only way control passes into the cgame module. This must be the very first function compiled into the .q3vm file ================ */ -extern "C" Q_EXPORT intptr_t vmMain( intptr_t command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7 ) { +extern "C" Q_EXPORT intptr_t vmMain( int command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7 ) { centity_t *cent; switch ( command ) { diff --git a/codemp/client/snd_mem.cpp b/codemp/client/snd_mem.cpp index 16bcd57daa..8270fc91d6 100644 --- a/codemp/client/snd_mem.cpp +++ b/codemp/client/snd_mem.cpp @@ -236,7 +236,7 @@ void ResampleSfx (sfx_t *sfx, int iInRate, int iInWidth, byte *pData) if (iInWidth == 2) { iSample = LittleShort ( ((short *)pData)[iSrcSample] ); } else { - iSample = (int)( (unsigned char)(pData[iSrcSample]) - 128) << 8; + iSample = (unsigned int)( (unsigned char)(pData[iSrcSample]) - 128) << 8; } sfx->pSoundData[i] = (short)iSample; diff --git a/codemp/qcommon/RoffSystem.cpp b/codemp/qcommon/RoffSystem.cpp index a61e0e3334..bcb14caa4a 100644 --- a/codemp/qcommon/RoffSystem.cpp +++ b/codemp/qcommon/RoffSystem.cpp @@ -869,19 +869,19 @@ qboolean CROFFSystem::ApplyROFF( SROFFEntity *roff_ent, CROFFSystem::CROFF *roff return qtrue; } +#ifndef DEDICATED + vec3_t originTemp, angleTemp; if (roff_ent->mIsClient) { -#ifndef DEDICATED - vec3_t originTemp, angleTemp; originTrajectory = CGVM_GetOriginTrajectory( roff_ent->mEntID ); angleTrajectory = CGVM_GetAngleTrajectory( roff_ent->mEntID ); CGVM_GetOrigin( roff_ent->mEntID, originTemp ); origin = originTemp; CGVM_GetAngles( roff_ent->mEntID, angleTemp ); angle = angleTemp; -#endif } else +#endif { // Find the entity to apply the roff to ent = SV_GentityNum( roff_ent->mEntID ); @@ -982,7 +982,7 @@ void CROFFSystem::ProcessNote(SROFFEntity *roff_ent, char *note) { temp[size++] = note[pos++]; } - temp[size] = 0; + temp[size] = '\0'; if (size) { @@ -1016,19 +1016,19 @@ qboolean CROFFSystem::ClearLerp( SROFFEntity *roff_ent ) trajectory_t *originTrajectory = NULL, *angleTrajectory = NULL; float *origin = NULL, *angle = NULL; +#ifndef DEDICATED + vec3_t originTemp, angleTemp; if (roff_ent->mIsClient) { -#ifndef DEDICATED - vec3_t originTemp, angleTemp; originTrajectory = CGVM_GetOriginTrajectory( roff_ent->mEntID ); angleTrajectory = CGVM_GetAngleTrajectory( roff_ent->mEntID ); CGVM_GetOrigin( roff_ent->mEntID, originTemp ); origin = originTemp; CGVM_GetAngles( roff_ent->mEntID, angleTemp ); angle = angleTemp; -#endif } else +#endif { // Find the entity to apply the roff to ent = SV_GentityNum( roff_ent->mEntID ); diff --git a/codemp/qcommon/z_memman_pc.cpp b/codemp/qcommon/z_memman_pc.cpp index 25f92d4fa7..dff480cf0b 100644 --- a/codemp/qcommon/z_memman_pc.cpp +++ b/codemp/qcommon/z_memman_pc.cpp @@ -666,7 +666,7 @@ Touch all known used data to make sure it is paged in void Com_TouchMemory( void ) { // int start, end; int i, j; - int sum; + unsigned int sum; // start = Sys_Milliseconds(); Z_Validate(); @@ -679,7 +679,7 @@ void Com_TouchMemory( void ) { byte *pMem = (byte *) &pMemory[1]; j = pMemory->iSize >> 2; for (i=0; ipNext; diff --git a/codemp/rd-vanilla/tr_bsp.cpp b/codemp/rd-vanilla/tr_bsp.cpp index a7f42c0cf1..7ce2e82eec 100644 --- a/codemp/rd-vanilla/tr_bsp.cpp +++ b/codemp/rd-vanilla/tr_bsp.cpp @@ -383,7 +383,7 @@ static void ParseFace( dsurface_t *ds, mapVert_t *verts, msurface_t *surf, int * numIndexes = LittleLong( ds->numIndexes ); // create the srfSurfaceFace_t - sfaceSize = ( size_t ) &((srfSurfaceFace_t *)0)->points[numPoints]; + sfaceSize = sizeof( *cv ) - sizeof( cv->points ) + sizeof( cv->points[0] ) * numPoints; ofsIndexes = sfaceSize; sfaceSize += sizeof( int ) * numIndexes; From c55d81a2e04e3a910a67c8c5ed9e401143f25cac Mon Sep 17 00:00:00 2001 From: Ensiform Date: Tue, 28 Feb 2023 21:19:53 -0600 Subject: [PATCH 678/801] SP: Attempt to fix GetString() calls with cvars in ICARUS Cvar_VariableStringBuffer() does not like unallocated buffers with strlen(). Uses a local variable and cache the result in a map<> that is then cleared upon shutdown. --- code/game/Q3_Interface.cpp | 17 ++++++++++------- code/game/Q3_Interface.h | 2 ++ codeJK2/game/Q3_Interface.cpp | 19 ++++++++++--------- codeJK2/game/Q3_Registers.h | 3 +++ codeJK2/game/g_ICARUS.cpp | 6 ++++++ codeJK2/game/g_icarus.h | 1 + codeJK2/game/g_local.h | 1 + 7 files changed, 33 insertions(+), 16 deletions(-) diff --git a/code/game/Q3_Interface.cpp b/code/game/Q3_Interface.cpp index 310dd28882..2504ffb927 100644 --- a/code/game/Q3_Interface.cpp +++ b/code/game/Q3_Interface.cpp @@ -7473,6 +7473,7 @@ CQuake3GameInterface::CQuake3GameInterface() : IGameInterface() { m_ScriptList.clear(); m_EntityList.clear(); + m_cvars.clear(); m_numVariables = 0; @@ -7509,6 +7510,7 @@ CQuake3GameInterface::~CQuake3GameInterface() m_ScriptList.clear(); m_EntityList.clear(); + m_cvars.clear(); } // Initialize an Entity by ID. @@ -8230,8 +8232,7 @@ void CQuake3GameInterface::Set( int taskID, int entID, const char *type_name, co vec3_t vector_data; // eezstreet: Add support for cvars getting modified thru ICARUS script - if(!Q_stricmpn(type_name, "cvar_", 5) && - strlen(type_name) > 5) + if(strlen(type_name) > 5 && !Q_stricmpn(type_name, "cvar_", 5)) { gi.cvar_set(type_name+5, data); return; @@ -9867,8 +9868,7 @@ int CQuake3GameInterface::GetFloat( int entID, const char *name, float *value ) return false; } - if( !Q_stricmpn(name, "cvar_", 5) && - strlen(name) > 5 ) + if( strlen(name) > 5 &&!Q_stricmpn(name, "cvar_", 5) ) { *value = (float)gi.Cvar_VariableIntegerValue(name+5); return true; @@ -10568,10 +10568,13 @@ int CQuake3GameInterface::GetString( int entID, const char *name, char **value return false; } - if( !Q_stricmpn(name, "cvar_", 5) && - strlen(name) > 5 ) + if( strlen(name) > 5 && Q_stricmpn(name, "cvar_", 5) ) { - gi.Cvar_VariableStringBuffer(name+5, *value, strlen(*value)); + char cvarbuf[MAX_STRING_CHARS]; + + gi.Cvar_VariableStringBuffer(name+5, cvarbuf, sizeof(cvarbuf)); + m_cvars[name+5] = cvarbuf; + *value = &m_cvars[name+5][0]; return true; } diff --git a/code/game/Q3_Interface.h b/code/game/Q3_Interface.h index a37c3a3002..dbb7fdc610 100644 --- a/code/game/Q3_Interface.h +++ b/code/game/Q3_Interface.h @@ -577,6 +577,8 @@ class CQuake3GameInterface : public IGameInterface varString_m m_varVectors; int m_numVariables; + varString_m m_cvars; + int m_entFilter; // Register variables functions. diff --git a/codeJK2/game/Q3_Interface.cpp b/codeJK2/game/Q3_Interface.cpp index 7987da9b23..e1d3dd4d46 100644 --- a/codeJK2/game/Q3_Interface.cpp +++ b/codeJK2/game/Q3_Interface.cpp @@ -6533,11 +6533,10 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da int int_data, toSet; vec3_t vector_data; - // eezstreet: In response to issue #75 (Cvars being affected by set command) - if( !Q_stricmpn(type_name, "cvar_", 5) && - strlen(type_name) > 5 ) + // eezstreet: Add support for cvars getting modified thru ICARUS script + if(strlen(type_name) > 5 && !Q_stricmpn(type_name, "cvar_", 5)) { - cgi_Cvar_Set(type_name+5, data); + gi.cvar_set(type_name+5, data); return; } @@ -7904,8 +7903,7 @@ static int Q3_GetFloat( int entID, int type, const char *name, float *value ) return false; } - if( !Q_stricmpn(name, "cvar_", 5) && - strlen(name) > 5 ) + if( strlen(name) > 5 &&!Q_stricmpn(name, "cvar_", 5) ) { *value = (float)gi.Cvar_VariableIntegerValue(name+5); return true; @@ -8599,10 +8597,13 @@ static int Q3_GetString( int entID, int type, const char *name, char **value ) return false; } - if( !Q_stricmpn(name, "cvar_", 5) && - strlen(name) > 5 ) + if( strlen(name) > 5 && Q_stricmpn(name, "cvar_", 5) ) { - gi.Cvar_VariableStringBuffer(name+5, *value, strlen(*value)); + char cvarbuf[MAX_STRING_CHARS]; + + gi.Cvar_VariableStringBuffer(name+5, cvarbuf, sizeof(cvarbuf)); + ICARUS_CvarList[name+5] = cvarbuf; + *value = &ICARUS_CvarList[name+5][0]; return true; } diff --git a/codeJK2/game/Q3_Registers.h b/codeJK2/game/Q3_Registers.h index f321bf3934..0eee1fb8e4 100644 --- a/codeJK2/game/Q3_Registers.h +++ b/codeJK2/game/Q3_Registers.h @@ -25,6 +25,9 @@ along with this program; if not, see . #define MAX_VARIABLES 32 +#include +#include + typedef std::map < std::string, std::string > varString_m; typedef std::map < std::string, float > varFloat_m; diff --git a/codeJK2/game/g_ICARUS.cpp b/codeJK2/game/g_ICARUS.cpp index e89ff765d0..c5fb26dac8 100644 --- a/codeJK2/game/g_ICARUS.cpp +++ b/codeJK2/game/g_ICARUS.cpp @@ -34,6 +34,8 @@ ICARUS_Instance *iICARUS; bufferlist_t ICARUS_BufferList; entlist_t ICARUS_EntList; +cvarlist_t ICARUS_CvarList; + extern uint32_t Com_BlockChecksum (const void *buffer, int length); extern void Q3_DebugPrint( int level, const char *format, ... ); @@ -136,6 +138,8 @@ void ICARUS_Init( void ) Com_Error( ERR_DROP, "Unable to initialize ICARUS instance\n" ); return; } + + ICARUS_CvarList.clear(); } /* @@ -172,6 +176,8 @@ void ICARUS_Shutdown( void ) //Clear the name map ICARUS_EntList.clear(); + ICARUS_CvarList.clear(); + //Free this instance if ( iICARUS ) { diff --git a/codeJK2/game/g_icarus.h b/codeJK2/game/g_icarus.h index 89c6a53d9d..70176170c4 100644 --- a/codeJK2/game/g_icarus.h +++ b/codeJK2/game/g_icarus.h @@ -35,6 +35,7 @@ extern bool ICARUS_RegisterScript( const char *name, bool bCalledDuringInterroga extern ICARUS_Instance *iICARUS; extern bufferlist_t ICARUS_BufferList; extern entlist_t ICARUS_EntList; +extern cvarlist_t ICARUS_CvarList; // // g_ICARUS.cpp diff --git a/codeJK2/game/g_local.h b/codeJK2/game/g_local.h index e4c4c11741..70566bdd86 100644 --- a/codeJK2/game/g_local.h +++ b/codeJK2/game/g_local.h @@ -636,6 +636,7 @@ typedef struct pscript_s typedef std::map < std::string, int, std::less > entlist_t; typedef std::map < std::string, pscript_t*, std::less > bufferlist_t; +typedef std::map < std::string, std::string > cvarlist_t; extern char *G_NewString( const char *string ); From f3fbe80b6cf00fdd68d51ce9e6a2ac06484bff48 Mon Sep 17 00:00:00 2001 From: Willi Schinmeyer Date: Wed, 29 Mar 2023 20:54:06 +0200 Subject: [PATCH 679/801] SP: Fix use-after-free on repeat GetString() calls with cvars in ICARUS We can't use an std::string, as pointers to its content become invalidated when the content is modified. Using a 1KB buffer instead lets us avoid re-allocations at the cost of wasting some space, but that should be okay. --- code/game/Q3_Interface.cpp | 13 ++++++++----- code/game/Q3_Interface.h | 5 ++++- codeJK2/game/Q3_Interface.cpp | 13 ++++++++----- codeJK2/game/Q3_Registers.h | 1 + codeJK2/game/g_local.h | 2 +- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/code/game/Q3_Interface.cpp b/code/game/Q3_Interface.cpp index 2504ffb927..494351f6be 100644 --- a/code/game/Q3_Interface.cpp +++ b/code/game/Q3_Interface.cpp @@ -10570,11 +10570,14 @@ int CQuake3GameInterface::GetString( int entID, const char *name, char **value if( strlen(name) > 5 && Q_stricmpn(name, "cvar_", 5) ) { - char cvarbuf[MAX_STRING_CHARS]; - - gi.Cvar_VariableStringBuffer(name+5, cvarbuf, sizeof(cvarbuf)); - m_cvars[name+5] = cvarbuf; - *value = &m_cvars[name+5][0]; + const char* cvar_name = name + 5; + // by allocating and then re-using the same sufficiently large buffer, + // we ensure that pointers to it never become invalid, + // so we can support expressions using the same cvar twice, + // e.g. if(get(cvar_x) == get(cvar_x)) + std::array& buf = m_cvars[cvar_name]; + gi.Cvar_VariableStringBuffer(cvar_name, buf.data(), buf.size()); + *value = buf.data(); return true; } diff --git a/code/game/Q3_Interface.h b/code/game/Q3_Interface.h index dbb7fdc610..1290c842d1 100644 --- a/code/game/Q3_Interface.h +++ b/code/game/Q3_Interface.h @@ -23,6 +23,7 @@ along with this program; if not, see . #ifndef __Q3_INTERFACE__ #define __Q3_INTERFACE__ +#include #include "../icarus/IcarusInterface.h" #include "bg_public.h" #include "g_shared.h" @@ -558,6 +559,8 @@ typedef std::map < std::string, pscript_t* > scriptlist_t; // STL map type definitions for the variable containers. typedef std::map < std::string, std::string > varString_m; typedef std::map < std::string, float > varFloat_m; +// For cases where we need to re-use a buffer without invalidating it +typedef std::map < std::string, std::array< char, MAX_STRING_CHARS > > varStringBuf_m; // The Quake 3 Game Interface Class for Quake3 and Icarus to use. @@ -577,7 +580,7 @@ class CQuake3GameInterface : public IGameInterface varString_m m_varVectors; int m_numVariables; - varString_m m_cvars; + varStringBuf_m m_cvars; int m_entFilter; diff --git a/codeJK2/game/Q3_Interface.cpp b/codeJK2/game/Q3_Interface.cpp index e1d3dd4d46..f89646dccb 100644 --- a/codeJK2/game/Q3_Interface.cpp +++ b/codeJK2/game/Q3_Interface.cpp @@ -8599,11 +8599,14 @@ static int Q3_GetString( int entID, int type, const char *name, char **value ) if( strlen(name) > 5 && Q_stricmpn(name, "cvar_", 5) ) { - char cvarbuf[MAX_STRING_CHARS]; - - gi.Cvar_VariableStringBuffer(name+5, cvarbuf, sizeof(cvarbuf)); - ICARUS_CvarList[name+5] = cvarbuf; - *value = &ICARUS_CvarList[name+5][0]; + const char* cvar_name = name + 5; + // by allocating and then re-using the same sufficiently large buffer, + // we ensure that pointers to it never become invalid, + // so we can support expressions using the same cvar twice, + // e.g. if(get(cvar_x) == get(cvar_x)) + std::array& buf = m_cvars[cvar_name]; + gi.Cvar_VariableStringBuffer(cvar_name, buf.data(), buf.size()); + *value = buf.data(); return true; } diff --git a/codeJK2/game/Q3_Registers.h b/codeJK2/game/Q3_Registers.h index 0eee1fb8e4..3d65bbb307 100644 --- a/codeJK2/game/Q3_Registers.h +++ b/codeJK2/game/Q3_Registers.h @@ -27,6 +27,7 @@ along with this program; if not, see . #include #include +#include typedef std::map < std::string, std::string > varString_m; typedef std::map < std::string, float > varFloat_m; diff --git a/codeJK2/game/g_local.h b/codeJK2/game/g_local.h index 70566bdd86..0c2bf4fdf7 100644 --- a/codeJK2/game/g_local.h +++ b/codeJK2/game/g_local.h @@ -636,7 +636,7 @@ typedef struct pscript_s typedef std::map < std::string, int, std::less > entlist_t; typedef std::map < std::string, pscript_t*, std::less > bufferlist_t; -typedef std::map < std::string, std::string > cvarlist_t; +typedef std::map < std::string, std::array > cvarlist_t; extern char *G_NewString( const char *string ); 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 680/801] 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 681/801] 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 682/801] 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 683/801] 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 97cbf1e74c2f6b7f6ed30badef766c6c8e3cc01a Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 19 Apr 2023 02:27:14 +0200 Subject: [PATCH 684/801] Also aspect correct the fov in skybox portals (#1142) Was missing and created a visual break when using cg_fovAspectAdjust 1. Just copied the correction code from CG_CalcFov. --- 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 6b516e6410320d482229199cf0764c5ad5da2ca2 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 20 Apr 2023 20:38:15 -0500 Subject: [PATCH 685/801] Use correct variable for cvarlist in jk2 code Fixes #1143 --- codeJK2/game/Q3_Interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codeJK2/game/Q3_Interface.cpp b/codeJK2/game/Q3_Interface.cpp index f89646dccb..fff63489d3 100644 --- a/codeJK2/game/Q3_Interface.cpp +++ b/codeJK2/game/Q3_Interface.cpp @@ -8604,7 +8604,7 @@ static int Q3_GetString( int entID, int type, const char *name, char **value ) // we ensure that pointers to it never become invalid, // so we can support expressions using the same cvar twice, // e.g. if(get(cvar_x) == get(cvar_x)) - std::array& buf = m_cvars[cvar_name]; + std::array& buf = ICARUS_CvarList[cvar_name]; gi.Cvar_VariableStringBuffer(cvar_name, buf.data(), buf.size()); *value = buf.data(); return true; From 5d3620cb9f399a9dc6f8b2530ce2ffbf21d0a4d3 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 20 Apr 2023 20:59:07 -0500 Subject: [PATCH 686/801] Fix warning in font code with jk2 compilation --- code/rd-common/tr_font.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/rd-common/tr_font.cpp b/code/rd-common/tr_font.cpp index 671b38128b..de2382448e 100644 --- a/code/rd-common/tr_font.cpp +++ b/code/rd-common/tr_font.cpp @@ -1311,7 +1311,9 @@ const glyphInfo_t *CFontInfo::GetLetter(const unsigned int uiLetter, int *piShad iTexturePageIndex = 0; } +#ifndef JK2_MODE int iOriginalCollapsedAsianCode = iCollapsedAsianCode; // need to back this up (if Thai) for later +#endif iCollapsedAsianCode -= iTexturePageIndex * (m_iAsianGlyphsAcross * m_iAsianGlyphsAcross); const int iColumn = iCollapsedAsianCode % m_iAsianGlyphsAcross; From cb26c2e563ec3b256c5203200519f6bd39f0a91b Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 20 Apr 2023 20:59:37 -0500 Subject: [PATCH 687/801] Fix #1143 for real this time --- codeJK2/game/Q3_Interface.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codeJK2/game/Q3_Interface.h b/codeJK2/game/Q3_Interface.h index 64a0343713..ecff2f7bdb 100644 --- a/codeJK2/game/Q3_Interface.h +++ b/codeJK2/game/Q3_Interface.h @@ -23,6 +23,8 @@ along with this program; if not, see . #ifndef __Q3_INTERFACE__ #define __Q3_INTERFACE__ +#include + //NOTENOTE: The enums and tables in this file will obviously bitch if they are included multiple times, don't do that typedef enum //# setType_e From f1448bc2c04d13f259a88dd2a22d6b3c6fa68772 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 20 Apr 2023 21:25:26 -0500 Subject: [PATCH 688/801] Disable g2 trace assert in SP to be like MP This assert is unnecessary, and crashes even on jk2 SP maps. --- code/rd-vanilla/G2_misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/rd-vanilla/G2_misc.cpp b/code/rd-vanilla/G2_misc.cpp index 9a6162fabf..bc5ca630a6 100644 --- a/code/rd-vanilla/G2_misc.cpp +++ b/code/rd-vanilla/G2_misc.cpp @@ -1240,7 +1240,7 @@ static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_ } if (i == MAX_G2_COLLISIONS) { - assert(i!=MAX_G2_COLLISIONS); // run out of collision record space - will probalbly never happen + //assert(i!=MAX_G2_COLLISIONS); // run out of collision record space - will probalbly never happen TS.hitOne = true; //force stop recursion return true; // return true to avoid wasting further time, but no hit will result without a record } From 4edea1a45303300897dd1197eabca9891a596922 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 22 Apr 2023 16:59:30 -0500 Subject: [PATCH 689/801] Fix unintended boolean change for stricmp with getstring commits Fixes #1144 --- code/game/Q3_Interface.cpp | 4 ++-- codeJK2/game/Q3_Interface.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/game/Q3_Interface.cpp b/code/game/Q3_Interface.cpp index 494351f6be..eb344d2b0a 100644 --- a/code/game/Q3_Interface.cpp +++ b/code/game/Q3_Interface.cpp @@ -9868,7 +9868,7 @@ int CQuake3GameInterface::GetFloat( int entID, const char *name, float *value ) return false; } - if( strlen(name) > 5 &&!Q_stricmpn(name, "cvar_", 5) ) + if( strlen(name) > 5 && !Q_stricmpn(name, "cvar_", 5) ) { *value = (float)gi.Cvar_VariableIntegerValue(name+5); return true; @@ -10568,7 +10568,7 @@ int CQuake3GameInterface::GetString( int entID, const char *name, char **value return false; } - if( strlen(name) > 5 && Q_stricmpn(name, "cvar_", 5) ) + if( strlen(name) > 5 && !Q_stricmpn(name, "cvar_", 5) ) { const char* cvar_name = name + 5; // by allocating and then re-using the same sufficiently large buffer, diff --git a/codeJK2/game/Q3_Interface.cpp b/codeJK2/game/Q3_Interface.cpp index fff63489d3..4be6d5216f 100644 --- a/codeJK2/game/Q3_Interface.cpp +++ b/codeJK2/game/Q3_Interface.cpp @@ -7903,7 +7903,7 @@ static int Q3_GetFloat( int entID, int type, const char *name, float *value ) return false; } - if( strlen(name) > 5 &&!Q_stricmpn(name, "cvar_", 5) ) + if( strlen(name) > 5 && !Q_stricmpn(name, "cvar_", 5) ) { *value = (float)gi.Cvar_VariableIntegerValue(name+5); return true; @@ -8597,7 +8597,7 @@ static int Q3_GetString( int entID, int type, const char *name, char **value ) return false; } - if( strlen(name) > 5 && Q_stricmpn(name, "cvar_", 5) ) + if( strlen(name) > 5 && !Q_stricmpn(name, "cvar_", 5) ) { const char* cvar_name = name + 5; // by allocating and then re-using the same sufficiently large buffer, 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 690/801] 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 691/801] 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 692/801] 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 693/801] 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 90e8005b0cef3ce3405ad3f0011a204ca78e4c37 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 30 Apr 2023 19:06:34 -0500 Subject: [PATCH 694/801] Remove vm protection from cl_renderer cvar So it can be put in menus to change in menus. --- code/client/cl_main.cpp | 2 +- codemp/client/cl_main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index e8f3d3f2a1..b74008c31b 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -1086,7 +1086,7 @@ void CL_InitRef( void ) { GetRefAPI_t GetRefAPI; Com_Printf( "----- Initializing Renderer ----\n" ); - cl_renderer = Cvar_Get( "cl_renderer", DEFAULT_RENDER_LIBRARY, CVAR_ARCHIVE|CVAR_LATCH|CVAR_PROTECTED ); + cl_renderer = Cvar_Get( "cl_renderer", DEFAULT_RENDER_LIBRARY, CVAR_ARCHIVE|CVAR_LATCH ); Com_sprintf( dllName, sizeof( dllName ), "%s_" ARCH_STRING DLL_EXT, cl_renderer->string ); diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index e540fd210c..b5b07c6fa9 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -2370,7 +2370,7 @@ void CL_InitRef( void ) { Com_Printf( "----- Initializing Renderer ----\n" ); - cl_renderer = Cvar_Get( "cl_renderer", DEFAULT_RENDER_LIBRARY, CVAR_ARCHIVE|CVAR_LATCH|CVAR_PROTECTED, "Which renderer library to use" ); + cl_renderer = Cvar_Get( "cl_renderer", DEFAULT_RENDER_LIBRARY, CVAR_ARCHIVE|CVAR_LATCH, "Which renderer library to use" ); Com_sprintf( dllName, sizeof( dllName ), "%s_" ARCH_STRING DLL_EXT, cl_renderer->string ); 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 695/801] 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 696/801] 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 697/801] 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 698/801] 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 699/801] 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 700/801] 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 701/801] 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 702/801] 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 703/801] 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 704/801] 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 705/801] 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 706/801] 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 707/801] 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 708/801] 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 709/801] 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 710/801] 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 711/801] 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 712/801] 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 995d0dd461ce41755cb54dc78059cd42aeef0445 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 20 May 2023 15:18:25 -0500 Subject: [PATCH 713/801] Fix rocket lock wedges on JK2 SP JK2 shader has a different hash --- code/rd-vanilla/tr_shader.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/code/rd-vanilla/tr_shader.cpp b/code/rd-vanilla/tr_shader.cpp index c50a17e42e..1fd3d40296 100644 --- a/code/rd-vanilla/tr_shader.cpp +++ b/code/rd-vanilla/tr_shader.cpp @@ -39,12 +39,18 @@ 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. +// retail JK2/JKA shader for gfx/2d/wedge. +#ifdef JK2_MODE +#define RETAIL_ROCKET_WEDGE_SHADER_HASH (1193966) +#else #define RETAIL_ROCKET_WEDGE_SHADER_HASH (1217042) +#endif +#ifndef JK2_MODE // Hash value (generated using the generateHashValueForText function) for the original // retail JKA shader for gfx/menus/radar/arrow_w. #define RETAIL_ARROW_W_SHADER_HASH (1650186) +#endif #define FILE_HASH_SIZE 1024 @@ -2449,7 +2455,7 @@ Ghoul2 Insert End shader.explicitlyDefined = true; - // The basejka rocket lock wedge shader uses the incorrect blending mode. + // The basejk2/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. @@ -2465,6 +2471,7 @@ Ghoul2 Insert End stages[0].stateBits |= GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; } +#ifndef JK2_MODE // The basejka radar arrow contains an incorrect rgbGen of identity // It only worked because the original code didn't check shaders at all, // thus setcolor worked fine but with fixing RB_RotatePic it no longer @@ -2479,6 +2486,7 @@ Ghoul2 Insert End stages[0].rgbGen = CGEN_VERTEX; stages[0].alphaGen = AGEN_VERTEX; } +#endif COM_EndParseSession(); return qtrue; 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 714/801] 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 715/801] 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 716/801] 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 717/801] 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 718/801] 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 719/801] 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 720/801] 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 721/801] 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 722/801] 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 723/801] 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 724/801] 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 725/801] 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 726/801] 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 727/801] 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 728/801] 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 729/801] 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 730/801] 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 731/801] 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 732/801] 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 733/801] 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 734/801] 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 735/801] 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 736/801] 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 737/801] 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 738/801] 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 802c9b1b05d478861db9d1f9af4188527ee735ed Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Wed, 13 Sep 2023 21:11:23 +0000 Subject: [PATCH 739/801] Fixed bug with hexadecimal read number in botlib (#1161) --- codemp/botlib/l_script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/botlib/l_script.cpp b/codemp/botlib/l_script.cpp index 8be425b0c8..ab49c8c62b 100644 --- a/codemp/botlib/l_script.cpp +++ b/codemp/botlib/l_script.cpp @@ -652,7 +652,7 @@ int PS_ReadNumber(script_t *script, token_t *token) //hexadecimal while((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'A')) + (c >= 'A' && c <= 'F')) { token->string[len++] = *script->script_p++; if (len >= MAX_TOKEN) From f90488d43a99e0a4bf63b8058b78a16b6ea54ce0 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sat, 16 Sep 2023 22:45:37 +0200 Subject: [PATCH 740/801] Multiplayer RoffSystem Fixes (#1165) * [MP] Fix ROFF system using incorrect time value. The ROFF system previously used engine time instead of module time when setting the time values for trajectories of shared entities. This caused issues when the server module time has been reset on map change, because the game module would misinterpret the trajectories. * [MP] Fix roff not working on 64 bit builds. Change type of mVersion in TROFFHeader and TROFF2Header from long to int. --- codemp/qcommon/RoffSystem.cpp | 18 +++++++++--------- codemp/qcommon/RoffSystem.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/codemp/qcommon/RoffSystem.cpp b/codemp/qcommon/RoffSystem.cpp index bcb14caa4a..753eb75c84 100644 --- a/codemp/qcommon/RoffSystem.cpp +++ b/codemp/qcommon/RoffSystem.cpp @@ -647,7 +647,7 @@ qboolean CROFFSystem::Play( int entID, int id, qboolean doTranslation, qboolean roffing_ent->mEntID = entID; roffing_ent->mROFFID = id; - roffing_ent->mNextROFFTime = svs.time; + roffing_ent->mNextROFFTime = sv.time; roffing_ent->mROFFFrame = 0; roffing_ent->mKill = qfalse; roffing_ent->mSignal = qtrue; // TODO: hook up the real signal code @@ -864,7 +864,7 @@ qboolean CROFFSystem::ApplyROFF( SROFFEntity *roff_ent, CROFFSystem::CROFF *roff float *origin = NULL, *angle = NULL; - if ( svs.time < roff_ent->mNextROFFTime ) + if ( sv.time < roff_ent->mNextROFFTime ) { // Not time to roff yet return qtrue; } @@ -900,8 +900,8 @@ qboolean CROFFSystem::ApplyROFF( SROFFEntity *roff_ent, CROFFSystem::CROFF *roff if ( roff_ent->mROFFFrame >= roff->mROFFEntries ) { // we are done roffing, so stop moving and flag this ent to be removed - SetLerp( originTrajectory, TR_STATIONARY, origin, NULL, svs.time, roff->mLerp ); - SetLerp( angleTrajectory, TR_STATIONARY, angle, NULL, svs.time, roff->mLerp ); + SetLerp( originTrajectory, TR_STATIONARY, origin, NULL, sv.time, roff->mLerp ); + SetLerp( angleTrajectory, TR_STATIONARY, angle, NULL, sv.time, roff->mLerp ); if (!roff_ent->mIsClient) { ent->r.mIsRoffing = qfalse; @@ -922,11 +922,11 @@ qboolean CROFFSystem::ApplyROFF( SROFFEntity *roff_ent, CROFFSystem::CROFF *roff } // Set up our origin interpolation - SetLerp( originTrajectory, TR_LINEAR, origin, result, svs.time, roff->mLerp ); + SetLerp( originTrajectory, TR_LINEAR, origin, result, sv.time, roff->mLerp ); // Set up our angle interpolation SetLerp( angleTrajectory, TR_LINEAR, angle, - roff->mMoveRotateList[roff_ent->mROFFFrame].mRotateOffset, svs.time, roff->mLerp ); + roff->mMoveRotateList[roff_ent->mROFFFrame].mRotateOffset, sv.time, roff->mLerp ); if (roff->mMoveRotateList[roff_ent->mROFFFrame].mStartNote >= 0) { @@ -940,7 +940,7 @@ qboolean CROFFSystem::ApplyROFF( SROFFEntity *roff_ent, CROFFSystem::CROFF *roff // Advance ROFF frames and lock to a 10hz cycle roff_ent->mROFFFrame++; - roff_ent->mNextROFFTime = svs.time + roff->mFrameTime; + roff_ent->mNextROFFTime = sv.time + roff->mFrameTime; //rww - npcs need to know when they're getting roff'd if ( !roff_ent->mIsClient ) @@ -1044,8 +1044,8 @@ qboolean CROFFSystem::ClearLerp( SROFFEntity *roff_ent ) angle = ent->r.currentAngles; } - SetLerp( originTrajectory, TR_STATIONARY, origin, NULL, svs.time, ROFF_SAMPLE_RATE ); - SetLerp( angleTrajectory, TR_STATIONARY, angle, NULL, svs.time, ROFF_SAMPLE_RATE ); + SetLerp( originTrajectory, TR_STATIONARY, origin, NULL, sv.time, ROFF_SAMPLE_RATE ); + SetLerp( angleTrajectory, TR_STATIONARY, angle, NULL, sv.time, ROFF_SAMPLE_RATE ); return qtrue; } diff --git a/codemp/qcommon/RoffSystem.h b/codemp/qcommon/RoffSystem.h index 23c1dd26a1..7f2aa0ac6f 100644 --- a/codemp/qcommon/RoffSystem.h +++ b/codemp/qcommon/RoffSystem.h @@ -64,7 +64,7 @@ class CROFFSystem //------------------------------- { char mHeader[4]; // should match roff_string defined above - long mVersion; // version num, supported version defined above + int mVersion; // version num, supported version defined above float mCount; // I think this is a float because of a limitation of the roff exporter } TROFFHeader; @@ -81,7 +81,7 @@ class CROFFSystem //------------------------------- { char mHeader[4]; // should match roff_string defined above - long mVersion; // version num, supported version defined above + int mVersion; // version num, supported version defined above int mCount; // I think this is a float because of a limitation of the roff exporter int mFrameRate; // Frame rate the roff should be played at int mNumNotes; // number of notes (null terminated strings) after the roff data From 4834a1a33b6803069194feb41e1b6bfd3e5d56f4 Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Sat, 16 Sep 2023 20:46:14 +0000 Subject: [PATCH 741/801] Fixed bug in Clear() function SIntRange, mMax is never cleared. (#1162) Signed-off-by: German Semenov --- code/rd-vanilla/tr_WorldEffects.cpp | 2 +- codemp/rd-vanilla/tr_WorldEffects.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/rd-vanilla/tr_WorldEffects.cpp b/code/rd-vanilla/tr_WorldEffects.cpp index 6b63507704..3cd4fa5e9a 100644 --- a/code/rd-vanilla/tr_WorldEffects.cpp +++ b/code/rd-vanilla/tr_WorldEffects.cpp @@ -257,7 +257,7 @@ struct SIntRange inline void Clear() { mMin = 0; - mMin = 0; + mMax = 0; } inline void Pick(int& V) { diff --git a/codemp/rd-vanilla/tr_WorldEffects.cpp b/codemp/rd-vanilla/tr_WorldEffects.cpp index 67acd6ca7f..286c973f64 100644 --- a/codemp/rd-vanilla/tr_WorldEffects.cpp +++ b/codemp/rd-vanilla/tr_WorldEffects.cpp @@ -229,7 +229,7 @@ struct SIntRange inline void Clear() { mMin = 0; - mMin = 0; + mMax = 0; } inline void Pick(int& V) { From 41ff78fe33624e8ea8bf87a2d09e08ce34c494de Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sun, 5 Dec 2021 03:21:37 +0100 Subject: [PATCH 742/801] [Shared] Add support for arm64 (Apple M1). --- CMakeLists.txt | 6 ++++-- code/client/cl_cgame.cpp | 6 +++++- code/client/vmachine.cpp | 5 ++--- code/client/vmachine.h | 5 ++++- shared/qcommon/q_platform.h | 3 +++ 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bde16bb813..76b334c70a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,9 @@ if(WIN32) endif() else() set(X86 OFF) - if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") + if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$") + set(Architecture "arm64") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") set(Architecture "arm") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") set(X86 ON) @@ -388,4 +390,4 @@ endif() if(BuildTests) enable_testing() add_subdirectory("tests") -endif() \ No newline at end of file +endif() diff --git a/code/client/cl_cgame.cpp b/code/client/cl_cgame.cpp index 70b6534353..b9d7b6fc11 100644 --- a/code/client/cl_cgame.cpp +++ b/code/client/cl_cgame.cpp @@ -64,7 +64,11 @@ qboolean CL_InitCGameVM( void *gameLibrary ) typedef void DllEntryProc( SyscallProc * ); DllEntryProc *dllEntry = (DllEntryProc *)Sys_LoadFunction( gameLibrary, "dllEntry" ); - cgvm.entryPoint = (intptr_t (*)(int,...))Sys_LoadFunction( gameLibrary, "vmMain" ); + + // NOTE: arm64 mac has a different calling convention for fixed parameters vs. variadic parameters. + // As the cgame entryPoints (vmMain) in jk2 and jka use fixed arg0 to arg7 we can't use "..." around here or we end up with undefined behavior. + // See: https://developer.apple.com/documentation/apple-silicon/addressing-architectural-differences-in-your-macos-code + cgvm.entryPoint = (intptr_t (*)(int,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))Sys_LoadFunction( gameLibrary, "vmMain" ); if ( !cgvm.entryPoint || !dllEntry ) { #ifdef JK2_MODE diff --git a/code/client/vmachine.cpp b/code/client/vmachine.cpp index e18b3aef06..0ee1464468 100644 --- a/code/client/vmachine.cpp +++ b/code/client/vmachine.cpp @@ -34,7 +34,7 @@ VIRTUAL MACHINE */ intptr_t VM_Call( int callnum, ... ) { - intptr_t args[10] = { 0 }; + intptr_t args[8] = { 0 }; va_list ap; if ( cgvm.entryPoint ) { @@ -43,8 +43,7 @@ intptr_t VM_Call( int callnum, ... ) args[i] = va_arg( ap, intptr_t ); va_end(ap); - return cgvm.entryPoint( callnum, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], - args[8], args[9]); + return cgvm.entryPoint( callnum, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); } return -1; } diff --git a/code/client/vmachine.h b/code/client/vmachine.h index 8102d75db5..6d7b0eca47 100644 --- a/code/client/vmachine.h +++ b/code/client/vmachine.h @@ -71,7 +71,10 @@ VIRTUAL MACHINE ============================================================== */ typedef struct vm_s { - intptr_t (*entryPoint)( int callNum, ... ); + // NOTE: arm64 mac has a different calling convention for fixed parameters vs. variadic parameters. + // As the cgame entryPoints (vmMain) in jk2 and jka use fixed arg0 to arg7 we can't use "..." around here or we end up with undefined behavior. + // See: https://developer.apple.com/documentation/apple-silicon/addressing-architectural-differences-in-your-macos-code + intptr_t (*entryPoint)( int callNum, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7 ); } vm_t; extern vm_t cgvm; diff --git a/shared/qcommon/q_platform.h b/shared/qcommon/q_platform.h index 1c450d7d80..b843d0ad51 100644 --- a/shared/qcommon/q_platform.h +++ b/shared/qcommon/q_platform.h @@ -108,6 +108,9 @@ along with this program; if not, see . #define idx64 #define ARCH_STRING "x86_64" #define Q3_LITTLE_ENDIAN + #elif defined(__arm64__) + #define ARCH_STRING "arm64" + #define Q3_LITTLE_ENDIAN #endif #define DLL_EXT ".dylib" From c1b347d39b6c069c73818bcd7fedd0da2be08342 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sat, 16 Sep 2023 14:35:29 +0200 Subject: [PATCH 743/801] [Shared] Workarounds for zlib and libpng to compile on macOS 13.5.2 (Apple M1) using Xcode 14.3.1 (14E300c). The same workarounds were also used to compile on macOS 11.4 (Apple M1) using Xcode 12.5.1 (12E507). --- CMakeLists.txt | 1 + lib/zlib/gzguts.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76b334c70a..10092066ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,6 +114,7 @@ else() set(X86 OFF) if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$") set(Architecture "arm64") + add_definitions(-DPNG_ARM_NEON_OPT=0) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") set(Architecture "arm") elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") diff --git a/lib/zlib/gzguts.h b/lib/zlib/gzguts.h index d87659d031..0f340e9156 100644 --- a/lib/zlib/gzguts.h +++ b/lib/zlib/gzguts.h @@ -3,6 +3,10 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ +#if defined(__APPLE__) +# include +#endif + #ifdef _LARGEFILE64_SOURCE # ifndef _LARGEFILE_SOURCE # define _LARGEFILE_SOURCE 1 From 05a1e5e1dce39e48375672d6531ee91eb20592a0 Mon Sep 17 00:00:00 2001 From: razor Date: Fri, 29 Sep 2023 13:26:08 +1000 Subject: [PATCH 744/801] add CODEOWNERS (#1168) --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..b44290de1a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @JACoders/openjk-maintainers From 4e5fc65ff4b9c7a53821cda83ae11d84b2fd0ccd Mon Sep 17 00:00:00 2001 From: Alexander Sago Date: Thu, 28 Sep 2023 23:27:39 -0400 Subject: [PATCH 745/801] Update gsl-lite (#1154) --- code/cgame/FxScheduler.cpp | 2 +- code/cgame/FxScheduler.h | 104 +- code/cgame/FxSystem.cpp | 6 +- code/cgame/FxSystem.h | 6 +- code/cgame/FxTemplate.cpp | 102 +- code/client/snd_music.cpp | 18 +- code/game/genericparser2.cpp | 30 +- code/game/genericparser2.h | 26 +- code/qcommon/sstring.h | 2 +- codeJK2/cgame/FxScheduler.cpp | 2 +- codeJK2/cgame/FxScheduler.h | 102 +- codeJK2/cgame/FxSystem.cpp | 6 +- codeJK2/cgame/FxSystem.h | 6 +- codeJK2/cgame/FxTemplate.cpp | 100 +- codeJK2/game/genericparser2.cpp | 30 +- codeJK2/game/genericparser2.h | 26 +- lib/gsl-lite/include/gsl/gsl-lite.h | 5829 ++++++++++++++++++++++++--- shared/qcommon/safe/files.h | 2 +- shared/qcommon/safe/gsl.h | 6 +- shared/qcommon/safe/sscanf.h | 30 +- shared/qcommon/safe/string.cpp | 10 +- shared/qcommon/safe/string.h | 10 +- 22 files changed, 5559 insertions(+), 896 deletions(-) diff --git a/code/cgame/FxScheduler.cpp b/code/cgame/FxScheduler.cpp index 5942efd7e2..2b91ef1871 100644 --- a/code/cgame/FxScheduler.cpp +++ b/code/cgame/FxScheduler.cpp @@ -524,7 +524,7 @@ int CFxScheduler::ParseEffect( const char *file, const CGPGroup& base ) for( const auto& primitiveGroup : base.GetSubGroups() ) { - static std::map< gsl::cstring_view, EPrimType, Q::CStringViewILess > primitiveTypes{ + static std::map< gsl::cstring_span, EPrimType, Q::CStringViewILess > primitiveTypes{ { CSTRING_VIEW( "particle" ), Particle }, { CSTRING_VIEW( "line" ), Line }, { CSTRING_VIEW( "tail" ), Tail }, diff --git a/code/cgame/FxScheduler.h b/code/cgame/FxScheduler.h index 7bf78398e7..e2a51441b0 100644 --- a/code/cgame/FxScheduler.h +++ b/code/cgame/FxScheduler.h @@ -278,41 +278,41 @@ class CPrimitiveTemplate private: // Lower level parsing utilities - bool ParseVector( const gsl::cstring_view& val, vec3_t min, vec3_t max ); - bool ParseFloat( const gsl::cstring_view& val, float& min, float& max ); - bool ParseGroupFlags( const gsl::cstring_view& val, int& flags ); + bool ParseVector( const gsl::cstring_span& val, vec3_t min, vec3_t max ); + bool ParseFloat( const gsl::cstring_span& val, float& min, float& max ); + bool ParseGroupFlags( const gsl::cstring_span& val, int& flags ); // Base key processing // Note that these all have their own parse functions in case it becomes important to do certain kinds // of validation specific to that type. - bool ParseMin( const gsl::cstring_view& val ); - bool ParseMax( const gsl::cstring_view& val ); - bool ParseDelay( const gsl::cstring_view& val ); - bool ParseCount( const gsl::cstring_view& val ); - bool ParseLife( const gsl::cstring_view& val ); - bool ParseElasticity( const gsl::cstring_view& val ); - bool ParseFlags( const gsl::cstring_view& val ); - bool ParseSpawnFlags( const gsl::cstring_view& val ); - - bool ParseOrigin1( const gsl::cstring_view& val ); - bool ParseOrigin2( const gsl::cstring_view& val ); - bool ParseRadius( const gsl::cstring_view& val ); - bool ParseHeight( const gsl::cstring_view& val ); - bool ParseWindModifier( const gsl::cstring_view& val ); - bool ParseRotation( const gsl::cstring_view& val ); - bool ParseRotationDelta( const gsl::cstring_view& val ); - bool ParseAngle( const gsl::cstring_view& val ); - bool ParseAngleDelta( const gsl::cstring_view& val ); - bool ParseVelocity( const gsl::cstring_view& val ); - bool ParseAcceleration( const gsl::cstring_view& val ); - bool ParseGravity( const gsl::cstring_view& val ); - bool ParseDensity( const gsl::cstring_view& val ); - bool ParseVariance( const gsl::cstring_view& val ); + bool ParseMin( const gsl::cstring_span& val ); + bool ParseMax( const gsl::cstring_span& val ); + bool ParseDelay( const gsl::cstring_span& val ); + bool ParseCount( const gsl::cstring_span& val ); + bool ParseLife( const gsl::cstring_span& val ); + bool ParseElasticity( const gsl::cstring_span& val ); + bool ParseFlags( const gsl::cstring_span& val ); + bool ParseSpawnFlags( const gsl::cstring_span& val ); + + bool ParseOrigin1( const gsl::cstring_span& val ); + bool ParseOrigin2( const gsl::cstring_span& val ); + bool ParseRadius( const gsl::cstring_span& val ); + bool ParseHeight( const gsl::cstring_span& val ); + bool ParseWindModifier( const gsl::cstring_span& val ); + bool ParseRotation( const gsl::cstring_span& val ); + bool ParseRotationDelta( const gsl::cstring_span& val ); + bool ParseAngle( const gsl::cstring_span& val ); + bool ParseAngleDelta( const gsl::cstring_span& val ); + bool ParseVelocity( const gsl::cstring_span& val ); + bool ParseAcceleration( const gsl::cstring_span& val ); + bool ParseGravity( const gsl::cstring_span& val ); + bool ParseDensity( const gsl::cstring_span& val ); + bool ParseVariance( const gsl::cstring_span& val ); /// Case insensitive map from cstring_view to Value template< typename Value > - using StringViewIMap = std::map< gsl::cstring_view, Value, Q::CStringViewILess >; - using ParseMethod = bool ( CPrimitiveTemplate::* )( const gsl::cstring_view& ); + using StringViewIMap = std::map< gsl::cstring_span, Value, Q::CStringViewILess >; + using ParseMethod = bool ( CPrimitiveTemplate::* )( const gsl::cstring_span& ); // Group type processing bool ParseGroup( const CGPGroup& grp, const StringViewIMap< ParseMethod >& parseMethods, gsl::czstring name ); bool ParseRGB( const CGPGroup& grp ); @@ -331,30 +331,30 @@ class CPrimitiveTemplate bool ParsePlayFxStrings( const CGPProperty& grp ); // Group keys - bool ParseRGBStart( const gsl::cstring_view& val ); - bool ParseRGBEnd( const gsl::cstring_view& val ); - bool ParseRGBParm( const gsl::cstring_view& val ); - bool ParseRGBFlags( const gsl::cstring_view& val ); - - bool ParseAlphaStart( const gsl::cstring_view& val ); - bool ParseAlphaEnd( const gsl::cstring_view& val ); - bool ParseAlphaParm( const gsl::cstring_view& val ); - bool ParseAlphaFlags( const gsl::cstring_view& val ); - - bool ParseSizeStart( const gsl::cstring_view& val ); - bool ParseSizeEnd( const gsl::cstring_view& val ); - bool ParseSizeParm( const gsl::cstring_view& val ); - bool ParseSizeFlags( const gsl::cstring_view& val ); - - bool ParseSize2Start( const gsl::cstring_view& val ); - bool ParseSize2End( const gsl::cstring_view& val ); - bool ParseSize2Parm( const gsl::cstring_view& val ); - bool ParseSize2Flags( const gsl::cstring_view& val ); - - bool ParseLengthStart( const gsl::cstring_view& val ); - bool ParseLengthEnd( const gsl::cstring_view& val ); - bool ParseLengthParm( const gsl::cstring_view& val ); - bool ParseLengthFlags( const gsl::cstring_view& val ); + bool ParseRGBStart( const gsl::cstring_span& val ); + bool ParseRGBEnd( const gsl::cstring_span& val ); + bool ParseRGBParm( const gsl::cstring_span& val ); + bool ParseRGBFlags( const gsl::cstring_span& val ); + + bool ParseAlphaStart( const gsl::cstring_span& val ); + bool ParseAlphaEnd( const gsl::cstring_span& val ); + bool ParseAlphaParm( const gsl::cstring_span& val ); + bool ParseAlphaFlags( const gsl::cstring_span& val ); + + bool ParseSizeStart( const gsl::cstring_span& val ); + bool ParseSizeEnd( const gsl::cstring_span& val ); + bool ParseSizeParm( const gsl::cstring_span& val ); + bool ParseSizeFlags( const gsl::cstring_span& val ); + + bool ParseSize2Start( const gsl::cstring_span& val ); + bool ParseSize2End( const gsl::cstring_span& val ); + bool ParseSize2Parm( const gsl::cstring_span& val ); + bool ParseSize2Flags( const gsl::cstring_span& val ); + + bool ParseLengthStart( const gsl::cstring_span& val ); + bool ParseLengthEnd( const gsl::cstring_span& val ); + bool ParseLengthParm( const gsl::cstring_span& val ); + bool ParseLengthFlags( const gsl::cstring_span& val ); public: diff --git a/code/cgame/FxSystem.cpp b/code/cgame/FxSystem.cpp index 6e47129b4a..0a0112d136 100644 --- a/code/cgame/FxSystem.cpp +++ b/code/cgame/FxSystem.cpp @@ -136,21 +136,21 @@ void SFxHelper::AddFxToScene( refEntity_t *ent ) } //------------------------------------------------------ -int SFxHelper::RegisterShader( const gsl::cstring_view& shader ) +int SFxHelper::RegisterShader( const gsl::cstring_span& shader ) { // TODO: it would be nice to change the ABI here to allow for passing of string views return cgi_R_RegisterShader( std::string( shader.begin(), shader.end() ).c_str() ); } //------------------------------------------------------ -int SFxHelper::RegisterSound( const gsl::cstring_view& sound ) +int SFxHelper::RegisterSound( const gsl::cstring_span& sound ) { // TODO: it would be nice to change the ABI here to allow for passing of string views return cgi_S_RegisterSound( std::string( sound.begin(), sound.end() ).c_str() ); } //------------------------------------------------------ -int SFxHelper::RegisterModel( const gsl::cstring_view& model ) +int SFxHelper::RegisterModel( const gsl::cstring_span& model ) { return cgi_R_RegisterModel( std::string( model.begin(), model.end() ).c_str() ); } diff --git a/code/cgame/FxSystem.h b/code/cgame/FxSystem.h index 3a81749aa1..010e3b5018 100644 --- a/code/cgame/FxSystem.h +++ b/code/cgame/FxSystem.h @@ -58,7 +58,7 @@ struct SFxHelper // Sound void PlaySound( const vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx ); void PlayLocalSound( sfxHandle_t sfx, int channelNum ); - int RegisterSound( const gsl::cstring_view& sound ); + int RegisterSound( const gsl::cstring_span& sound ); //G2 int GetOriginAxisFromBolt(const centity_t ¢, int modelNum, int boltNum, vec3_t /*out*/origin, vec3_t /*out*/*axis); @@ -70,8 +70,8 @@ struct SFxHelper void AddFxToScene( refEntity_t *ent ); void AddLightToScene( vec3_t org, float radius, float red, float green, float blue ); - int RegisterShader( const gsl::cstring_view& shader ); - int RegisterModel( const gsl::cstring_view& model ); + int RegisterShader( const gsl::cstring_span& shader ); + int RegisterModel( const gsl::cstring_span& model ); void AddPolyToScene( int shader, int count, polyVert_t *verts ); diff --git a/code/cgame/FxTemplate.cpp b/code/cgame/FxTemplate.cpp index dc8efc6dbc..78b3503fc2 100644 --- a/code/cgame/FxTemplate.cpp +++ b/code/cgame/FxTemplate.cpp @@ -193,7 +193,7 @@ void CPrimitiveTemplate::operator=(const CPrimitiveTemplate &that) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseFloat( const gsl::cstring_view& val, float& min, float& max ) +bool CPrimitiveTemplate::ParseFloat( const gsl::cstring_span& val, float& min, float& max ) { // attempt to read out the values int v = Q::sscanf( val, min, max ); @@ -224,7 +224,7 @@ bool CPrimitiveTemplate::ParseFloat( const gsl::cstring_view& val, float& min, f // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseVector( const gsl::cstring_view& val, vec3_t min, vec3_t max ) +bool CPrimitiveTemplate::ParseVector( const gsl::cstring_span& val, vec3_t min, vec3_t max ) { // we don't allow passing in a null if ( min == nullptr || max == nullptr ) @@ -256,7 +256,7 @@ namespace detail struct ScanStrings { template< std::size_t count, typename... Args > - static int call( const gsl::cstring_view& val, std::array< gsl::cstring_view, count >& arr, Args&... args ) + static int call( const gsl::cstring_span& val, std::array< gsl::cstring_span, count >& arr, Args&... args ) { return ScanStrings< remaining - 1 >::call( val, arr, arr[ remaining - 1 ], args... ); } @@ -266,7 +266,7 @@ namespace detail struct ScanStrings< 0 > { template< std::size_t count, typename... Args > - static int call( const gsl::cstring_view& val, std::array< gsl::cstring_view, count >& arr, Args&... args ) + static int call( const gsl::cstring_span& val, std::array< gsl::cstring_span, count >& arr, Args&... args ) { return Q::sscanf( val, args... ); } @@ -274,7 +274,7 @@ namespace detail } template< std::size_t count > -static gsl::array_view< gsl::cstring_view > scanStrings( const gsl::cstring_view& val, std::array< gsl::cstring_view, count >& arr ) +static gsl::span< gsl::cstring_span > scanStrings( const gsl::cstring_span& val, std::array< gsl::cstring_span, count >& arr ) { int numParsed = detail::ScanStrings< count >::call( val, arr ); return{ arr.data(), arr.data() + numParsed }; @@ -293,10 +293,10 @@ static gsl::array_view< gsl::cstring_view > scanStrings( const gsl::cstring_view // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseGroupFlags( const gsl::cstring_view& val, int& flags ) +bool CPrimitiveTemplate::ParseGroupFlags( const gsl::cstring_span& val, int& flags ) { // For a sub group, really you probably only have one or two flags set - std::array< gsl::cstring_view, 4 > flag; + std::array< gsl::cstring_span, 4 > flag; const auto availableFlag = scanStrings( val, flag ); @@ -338,7 +338,7 @@ bool CPrimitiveTemplate::ParseGroupFlags( const gsl::cstring_view& val, int& fla // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseMin( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseMin( const gsl::cstring_span& val ) { vec3_t min; @@ -364,7 +364,7 @@ bool CPrimitiveTemplate::ParseMin( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseMax( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseMax( const gsl::cstring_span& val ) { vec3_t max; @@ -390,7 +390,7 @@ bool CPrimitiveTemplate::ParseMax( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseLife( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseLife( const gsl::cstring_span& val ) { float min, max; @@ -413,7 +413,7 @@ bool CPrimitiveTemplate::ParseLife( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseDelay( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseDelay( const gsl::cstring_span& val ) { float min, max; @@ -436,7 +436,7 @@ bool CPrimitiveTemplate::ParseDelay( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseCount( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseCount( const gsl::cstring_span& val ) { float min, max; @@ -459,7 +459,7 @@ bool CPrimitiveTemplate::ParseCount( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseElasticity( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseElasticity( const gsl::cstring_span& val ) { float min, max; @@ -486,7 +486,7 @@ bool CPrimitiveTemplate::ParseElasticity( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseOrigin1( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseOrigin1( const gsl::cstring_span& val ) { vec3_t min, max; @@ -511,7 +511,7 @@ bool CPrimitiveTemplate::ParseOrigin1( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseOrigin2( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseOrigin2( const gsl::cstring_span& val ) { vec3_t min, max; @@ -536,7 +536,7 @@ bool CPrimitiveTemplate::ParseOrigin2( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRadius( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRadius( const gsl::cstring_span& val ) { float min, max; @@ -559,7 +559,7 @@ bool CPrimitiveTemplate::ParseRadius( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseHeight( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseHeight( const gsl::cstring_span& val ) { float min, max; @@ -582,7 +582,7 @@ bool CPrimitiveTemplate::ParseHeight( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseWindModifier( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseWindModifier( const gsl::cstring_span& val ) { float min, max; @@ -605,7 +605,7 @@ bool CPrimitiveTemplate::ParseWindModifier( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRotation( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRotation( const gsl::cstring_span& val ) { float min, max; @@ -628,7 +628,7 @@ bool CPrimitiveTemplate::ParseRotation( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRotationDelta( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRotationDelta( const gsl::cstring_span& val ) { float min, max; @@ -651,7 +651,7 @@ bool CPrimitiveTemplate::ParseRotationDelta( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAngle( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAngle( const gsl::cstring_span& val ) { vec3_t min, max; @@ -676,7 +676,7 @@ bool CPrimitiveTemplate::ParseAngle( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAngleDelta( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAngleDelta( const gsl::cstring_span& val ) { vec3_t min, max; @@ -701,7 +701,7 @@ bool CPrimitiveTemplate::ParseAngleDelta( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseVelocity( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseVelocity( const gsl::cstring_span& val ) { vec3_t min, max; @@ -727,10 +727,10 @@ bool CPrimitiveTemplate::ParseVelocity( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseFlags( const gsl::cstring_span& val ) { // For a primitive, really you probably only have two or less flags set - std::array< gsl::cstring_view, 7 > flag; + std::array< gsl::cstring_span, 7 > flag; const auto availableFlag = scanStrings( val, flag ); @@ -780,9 +780,9 @@ bool CPrimitiveTemplate::ParseFlags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSpawnFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSpawnFlags( const gsl::cstring_span& val ) { - std::array< gsl::cstring_view, 7 > flag; + std::array< gsl::cstring_span, 7 > flag; // For a primitive, really you probably only have two or less flags set const auto availableFlag = scanStrings( val, flag ); @@ -830,7 +830,7 @@ bool CPrimitiveTemplate::ParseSpawnFlags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAcceleration( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAcceleration( const gsl::cstring_span& val ) { vec3_t min, max; @@ -855,7 +855,7 @@ bool CPrimitiveTemplate::ParseAcceleration( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseGravity( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseGravity( const gsl::cstring_span& val ) { float min, max; @@ -880,7 +880,7 @@ bool CPrimitiveTemplate::ParseGravity( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseDensity( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseDensity( const gsl::cstring_span& val ) { float min, max; @@ -906,7 +906,7 @@ bool CPrimitiveTemplate::ParseDensity( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseVariance( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseVariance( const gsl::cstring_span& val ) { float min, max; @@ -929,7 +929,7 @@ bool CPrimitiveTemplate::ParseVariance( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRGBStart( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRGBStart( const gsl::cstring_span& val ) { vec3_t min, max; @@ -954,7 +954,7 @@ bool CPrimitiveTemplate::ParseRGBStart( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRGBEnd( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRGBEnd( const gsl::cstring_span& val ) { vec3_t min, max; @@ -979,7 +979,7 @@ bool CPrimitiveTemplate::ParseRGBEnd( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRGBParm( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRGBParm( const gsl::cstring_span& val ) { float min, max; @@ -1002,7 +1002,7 @@ bool CPrimitiveTemplate::ParseRGBParm( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRGBFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRGBFlags( const gsl::cstring_span& val ) { int flags; @@ -1026,7 +1026,7 @@ bool CPrimitiveTemplate::ParseRGBFlags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAlphaStart( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAlphaStart( const gsl::cstring_span& val ) { float min, max; @@ -1049,7 +1049,7 @@ bool CPrimitiveTemplate::ParseAlphaStart( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAlphaEnd( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAlphaEnd( const gsl::cstring_span& val ) { float min, max; @@ -1072,7 +1072,7 @@ bool CPrimitiveTemplate::ParseAlphaEnd( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAlphaParm( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAlphaParm( const gsl::cstring_span& val ) { float min, max; @@ -1095,7 +1095,7 @@ bool CPrimitiveTemplate::ParseAlphaParm( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAlphaFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAlphaFlags( const gsl::cstring_span& val ) { int flags; @@ -1119,7 +1119,7 @@ bool CPrimitiveTemplate::ParseAlphaFlags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSizeStart( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSizeStart( const gsl::cstring_span& val ) { float min, max; @@ -1142,7 +1142,7 @@ bool CPrimitiveTemplate::ParseSizeStart( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSizeEnd( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSizeEnd( const gsl::cstring_span& val ) { float min, max; @@ -1165,7 +1165,7 @@ bool CPrimitiveTemplate::ParseSizeEnd( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSizeParm( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSizeParm( const gsl::cstring_span& val ) { float min, max; @@ -1188,7 +1188,7 @@ bool CPrimitiveTemplate::ParseSizeParm( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSizeFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSizeFlags( const gsl::cstring_span& val ) { int flags; @@ -1212,7 +1212,7 @@ bool CPrimitiveTemplate::ParseSizeFlags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSize2Start( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSize2Start( const gsl::cstring_span& val ) { float min, max; @@ -1235,7 +1235,7 @@ bool CPrimitiveTemplate::ParseSize2Start( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSize2End( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSize2End( const gsl::cstring_span& val ) { float min, max; @@ -1258,7 +1258,7 @@ bool CPrimitiveTemplate::ParseSize2End( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSize2Parm( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSize2Parm( const gsl::cstring_span& val ) { float min, max; @@ -1281,7 +1281,7 @@ bool CPrimitiveTemplate::ParseSize2Parm( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSize2Flags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSize2Flags( const gsl::cstring_span& val ) { int flags; @@ -1305,7 +1305,7 @@ bool CPrimitiveTemplate::ParseSize2Flags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseLengthStart( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseLengthStart( const gsl::cstring_span& val ) { float min, max; @@ -1328,7 +1328,7 @@ bool CPrimitiveTemplate::ParseLengthStart( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseLengthEnd( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseLengthEnd( const gsl::cstring_span& val ) { float min, max; @@ -1351,7 +1351,7 @@ bool CPrimitiveTemplate::ParseLengthEnd( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseLengthParm( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseLengthParm( const gsl::cstring_span& val ) { float min, max; @@ -1374,7 +1374,7 @@ bool CPrimitiveTemplate::ParseLengthParm( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseLengthFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseLengthFlags( const gsl::cstring_span& val ) { int flags; diff --git a/code/client/snd_music.cpp b/code/client/snd_music.cpp index 8c8eec9332..5bebe9cdee 100644 --- a/code/client/snd_music.cpp +++ b/code/client/snd_music.cpp @@ -204,7 +204,7 @@ const char *Music_BaseStateToString( MusicState_e eMusicState, qboolean bDebugPr return NULL; } -static qboolean Music_ParseMusic( gsl::czstring filename, const CGenericParser2& Parser, MusicData_t* MusicData, const CGPGroup& pgMusicFiles, const gsl::cstring_view& psMusicName, const gsl::cstring_view& psMusicNameKey, MusicState_e eMusicState ) +static qboolean Music_ParseMusic( gsl::czstring filename, const CGenericParser2& Parser, MusicData_t* MusicData, const CGPGroup& pgMusicFiles, const gsl::cstring_span& psMusicName, const gsl::cstring_span& psMusicNameKey, MusicState_e eMusicState ) { bool bReturn = false; MusicFile_t MusicFile; @@ -424,7 +424,7 @@ static qboolean Music_ParseLeveldata( gsl::czstring psLevelName ) // check for new USE keyword... // int steps = 0; - gsl::cstring_view searchName{ &sLevelName[ 0 ], &sLevelName[ strlen( &sLevelName[ 0 ] ) ] }; + gsl::cstring_span searchName{ &sLevelName[ 0 ], &sLevelName[ strlen( &sLevelName[ 0 ] ) ] }; const int sanityLimit = 10; while( !searchName.empty() && steps < sanityLimit ) @@ -469,10 +469,10 @@ static qboolean Music_ParseLeveldata( gsl::czstring psLevelName ) { // these are optional fields, so see which ones we find... // - gsl::cstring_view psName_Explore; - gsl::cstring_view psName_Action; - gsl::cstring_view psName_Boss; - gsl::cstring_view psName_UseBoss; + gsl::cstring_span psName_Explore; + gsl::cstring_span psName_Action; + gsl::cstring_span psName_Boss; + gsl::cstring_span psName_UseBoss; for( auto& prop : pgThisLevelMusic->GetProperties() ) { @@ -532,15 +532,15 @@ static qboolean Music_ParseLeveldata( gsl::czstring psLevelName ) // done this way in case I want to conditionally pass any bools depending on music type... // - if( bReturn && psName_Explore ) + if( bReturn && psName_Explore.length() ) { bReturn = Music_ParseMusic( filename, Parser, MusicData, *pgMusicFiles, psName_Explore, sKEY_EXPLORE, eBGRNDTRACK_EXPLORE ); } - if( bReturn && psName_Action ) + if( bReturn && psName_Action.length() ) { bReturn = Music_ParseMusic( filename, Parser, MusicData, *pgMusicFiles, psName_Action, sKEY_ACTION, eBGRNDTRACK_ACTION ); } - if( bReturn && psName_Boss ) + if( bReturn && psName_Boss.length() ) { bReturn = Music_ParseMusic( filename, Parser, MusicData, *pgMusicFiles, psName_Boss, sKEY_BOSS, eBGRNDTRACK_BOSS ); } diff --git a/code/game/genericparser2.cpp b/code/game/genericparser2.cpp index 4988c7dd2e..ad825ce1a8 100644 --- a/code/game/genericparser2.cpp +++ b/code/game/genericparser2.cpp @@ -33,9 +33,9 @@ along with this program; if not, see . #include -static void skipWhitespace( gsl::cstring_view& text, const bool allowLineBreaks ) +static void skipWhitespace( gsl::cstring_span& text, const bool allowLineBreaks ) { - gsl::cstring_view::iterator whitespaceEnd = text.begin(); + gsl::cstring_span::iterator whitespaceEnd = text.begin(); while( whitespaceEnd != text.end() // No EOF && std::isspace( *whitespaceEnd ) // No End of Whitespace && ( allowLineBreaks || *whitespaceEnd != '\n' ) ) // No unwanted newline @@ -45,7 +45,7 @@ static void skipWhitespace( gsl::cstring_view& text, const bool allowLineBreaks text = { whitespaceEnd, text.end() }; } -static void skipWhitespaceAndComments( gsl::cstring_view& text, const bool allowLineBreaks ) +static void skipWhitespaceAndComments( gsl::cstring_span& text, const bool allowLineBreaks ) { skipWhitespace( text, allowLineBreaks ); // skip single line comment @@ -87,7 +87,7 @@ static void skipWhitespaceAndComments( gsl::cstring_view& text, const bool allow return; } -static gsl::cstring_view removeTrailingWhitespace( const gsl::cstring_view& text ) +static gsl::cstring_span removeTrailingWhitespace( const gsl::cstring_span& text ) { return{ text.begin(), @@ -106,7 +106,7 @@ A token can be: - EOL- or comment-delimited (if readToEOL == true); i.e. reads to end of line or the first // or /* @param text adjusted to start beyond the read token */ -static gsl::cstring_view GetToken( gsl::cstring_view& text, bool allowLineBreaks, bool readToEOL = false ) +static gsl::cstring_span GetToken( gsl::cstring_span& text, bool allowLineBreaks, bool readToEOL = false ) { skipWhitespaceAndComments( text, allowLineBreaks ); // EOF @@ -121,13 +121,13 @@ static gsl::cstring_view GetToken( gsl::cstring_view& text, bool allowLineBreaks auto tokenEnd = std::find( text.begin() + 1, text.end(), '"' ); if( tokenEnd == text.end() ) { - gsl::cstring_view token = { text.begin() + 1, text.end() }; + gsl::cstring_span token = { text.begin() + 1, text.end() }; text = { text.end(), text.end() }; return token; } else { - gsl::cstring_view token = { text.begin() + 1, tokenEnd }; + gsl::cstring_span token = { text.begin() + 1, tokenEnd }; text = { tokenEnd + 1, text.end() }; return token; } @@ -150,7 +150,7 @@ static gsl::cstring_view GetToken( gsl::cstring_view& text, bool allowLineBreaks ) ); } - gsl::cstring_view token{ text.begin(), tokenEnd }; + gsl::cstring_span token{ text.begin(), tokenEnd }; text = { tokenEnd, text.end() }; return removeTrailingWhitespace( token ); } @@ -158,7 +158,7 @@ static gsl::cstring_view GetToken( gsl::cstring_view& text, bool allowLineBreaks { // consume until first whitespace (if allowLineBreaks == false, that may be text.begin(); in that case token is empty.) auto tokenEnd = std::find_if( text.begin(), text.end(), static_cast< int( *)( int ) >( std::isspace ) ); - gsl::cstring_view token{ text.begin(), tokenEnd }; + gsl::cstring_span token{ text.begin(), tokenEnd }; text = { tokenEnd, text.end() }; return token; } @@ -168,7 +168,7 @@ static gsl::cstring_view GetToken( gsl::cstring_view& text, bool allowLineBreaks -CGPProperty::CGPProperty( gsl::cstring_view initKey, gsl::cstring_view initValue ) +CGPProperty::CGPProperty( gsl::cstring_span initKey, gsl::cstring_span initValue ) : mKey( initKey ) { if( !initValue.empty() ) @@ -177,7 +177,7 @@ CGPProperty::CGPProperty( gsl::cstring_view initKey, gsl::cstring_view initValue } } -void CGPProperty::AddValue( gsl::cstring_view newValue ) +void CGPProperty::AddValue( gsl::cstring_span newValue ) { mValues.push_back( newValue ); } @@ -197,16 +197,16 @@ void CGPProperty::AddValue( gsl::cstring_view newValue ) -CGPGroup::CGPGroup( const gsl::cstring_view& initName ) +CGPGroup::CGPGroup( const gsl::cstring_span& initName ) : mName( initName ) { } -bool CGPGroup::Parse( gsl::cstring_view& data, const bool topLevel ) +bool CGPGroup::Parse( gsl::cstring_span& data, const bool topLevel ) { while( true ) { - gsl::cstring_view token = GetToken( data, true ); + gsl::cstring_span token = GetToken( data, true ); if( token.empty() ) { @@ -234,7 +234,7 @@ bool CGPGroup::Parse( gsl::cstring_view& data, const bool topLevel ) return true; } } - gsl::cstring_view lastToken = token; + gsl::cstring_span lastToken = token; // read ahead to see what we are doing token = GetToken( data, true, true ); diff --git a/code/game/genericparser2.h b/code/game/genericparser2.h index 9b2425f3c9..2f05627170 100644 --- a/code/game/genericparser2.h +++ b/code/game/genericparser2.h @@ -44,31 +44,31 @@ namespace GP2 class CGPProperty { public: - using Values = GP2::Vector< gsl::cstring_view >; + using Values = GP2::Vector< gsl::cstring_span >; private: - gsl::cstring_view mKey; + gsl::cstring_span mKey; Values mValues; public: - CGPProperty( gsl::cstring_view initKey, gsl::cstring_view initValue = {} ); + CGPProperty( gsl::cstring_span initKey, gsl::cstring_span initValue = {} ); - const gsl::cstring_view& GetName() const { return mKey; } + const gsl::cstring_span& GetName() const { return mKey; } bool IsList() const NOEXCEPT { return mValues.size() > 1; } - const gsl::cstring_view& GetTopValue() const NOEXCEPT + const gsl::cstring_span& GetTopValue() const NOEXCEPT { - static gsl::cstring_view empty{}; + static gsl::cstring_span empty{}; return mValues.empty() ? empty : mValues.front(); } const Values& GetValues() const NOEXCEPT { return mValues; } - void AddValue( gsl::cstring_view newValue ); + void AddValue( gsl::cstring_span newValue ); }; @@ -81,11 +81,11 @@ class CGPGroup using SubGroups = GP2::Vector< CGPGroup >; private: Properties mProperties; - gsl::cstring_view mName = CSTRING_VIEW( "Top Level" ); + gsl::cstring_span mName = CSTRING_VIEW( "Top Level" ); SubGroups mSubGroups; public: CGPGroup() = default; - CGPGroup( const gsl::cstring_view& initName ); + CGPGroup( const gsl::cstring_span& initName ); // non-copyable; but just for performance reasons, since it would incur a deep copy. CGPGroup( const CGPGroup& ) = delete; CGPGroup& operator=( const CGPGroup& ) = delete; @@ -119,7 +119,7 @@ class CGPGroup { return mSubGroups; } - const CGPGroup* FindSubGroup( const gsl::cstring_view& name ) const NOEXCEPT + const CGPGroup* FindSubGroup( const gsl::cstring_span& name ) const NOEXCEPT { for( auto& sub : GetSubGroups() ) { @@ -130,7 +130,7 @@ class CGPGroup } return nullptr; } - const CGPProperty* FindProperty( const gsl::cstring_view& name ) const NOEXCEPT + const CGPProperty* FindProperty( const gsl::cstring_span& name ) const NOEXCEPT { for( auto& prop : GetProperties() ) { @@ -141,7 +141,7 @@ class CGPGroup } return nullptr; } - const gsl::cstring_view& GetName() const NOEXCEPT + const gsl::cstring_span& GetName() const NOEXCEPT { return mName; } @@ -151,7 +151,7 @@ class CGPGroup mProperties.clear(); mSubGroups.clear(); } - bool Parse( gsl::cstring_view& data, const bool topLevel = true ); + bool Parse( gsl::cstring_span& data, const bool topLevel = true ); }; /** diff --git a/code/qcommon/sstring.h b/code/qcommon/sstring.h index a3ca6695ae..df9aed85af 100644 --- a/code/qcommon/sstring.h +++ b/code/qcommon/sstring.h @@ -61,7 +61,7 @@ class sstring //strcpy(mStorage.data,s); Q_strncpyz(mStorage.data,s,sizeof(mStorage.data)); } - sstring( const gsl::cstring_view& v ) + sstring( const gsl::cstring_span& v ) { if( v.size() + 1 > sizeof( mStorage.data ) ) { diff --git a/codeJK2/cgame/FxScheduler.cpp b/codeJK2/cgame/FxScheduler.cpp index 1aa018eff4..fd4f9cef1c 100644 --- a/codeJK2/cgame/FxScheduler.cpp +++ b/codeJK2/cgame/FxScheduler.cpp @@ -270,7 +270,7 @@ int CFxScheduler::ParseEffect( const char *file, const CGPGroup& base ) for( const auto& primitiveGroup : base.GetSubGroups() ) { - static std::map< gsl::cstring_view, EPrimType, Q::CStringViewILess > primitiveTypes{ + static std::map< gsl::cstring_span, EPrimType, Q::CStringViewILess > primitiveTypes{ { CSTRING_VIEW( "particle" ), Particle }, { CSTRING_VIEW( "line" ), Line }, { CSTRING_VIEW( "tail" ), Tail }, diff --git a/codeJK2/cgame/FxScheduler.h b/codeJK2/cgame/FxScheduler.h index 6d6e0c8e4f..f40fe5fbbc 100644 --- a/codeJK2/cgame/FxScheduler.h +++ b/codeJK2/cgame/FxScheduler.h @@ -276,40 +276,40 @@ class CPrimitiveTemplate private: // Lower level parsing utilities - bool ParseVector( const gsl::cstring_view& val, vec3_t min, vec3_t max ); - bool ParseFloat( const gsl::cstring_view& val, float& min, float& max ); - bool ParseGroupFlags( const gsl::cstring_view& val, int& flags ); + bool ParseVector( const gsl::cstring_span& val, vec3_t min, vec3_t max ); + bool ParseFloat( const gsl::cstring_span& val, float& min, float& max ); + bool ParseGroupFlags( const gsl::cstring_span& val, int& flags ); // Base key processing // Note that these all have their own parse functions in case it becomes important to do certain kinds // of validation specific to that type. - bool ParseMin( const gsl::cstring_view& val ); - bool ParseMax( const gsl::cstring_view& val ); - bool ParseDelay( const gsl::cstring_view& val ); - bool ParseCount( const gsl::cstring_view& val ); - bool ParseLife( const gsl::cstring_view& val ); - bool ParseElasticity( const gsl::cstring_view& val ); - bool ParseFlags( const gsl::cstring_view& val ); - bool ParseSpawnFlags( const gsl::cstring_view& val ); - - bool ParseOrigin1( const gsl::cstring_view& val ); - bool ParseOrigin2( const gsl::cstring_view& val ); - bool ParseRadius( const gsl::cstring_view& val ); - bool ParseHeight( const gsl::cstring_view& val ); - bool ParseRotation( const gsl::cstring_view& val ); - bool ParseRotationDelta( const gsl::cstring_view& val ); - bool ParseAngle( const gsl::cstring_view& val ); - bool ParseAngleDelta( const gsl::cstring_view& val ); - bool ParseVelocity( const gsl::cstring_view& val ); - bool ParseAcceleration( const gsl::cstring_view& val ); - bool ParseGravity( const gsl::cstring_view& val ); - bool ParseDensity( const gsl::cstring_view& val ); - bool ParseVariance( const gsl::cstring_view& val ); + bool ParseMin( const gsl::cstring_span& val ); + bool ParseMax( const gsl::cstring_span& val ); + bool ParseDelay( const gsl::cstring_span& val ); + bool ParseCount( const gsl::cstring_span& val ); + bool ParseLife( const gsl::cstring_span& val ); + bool ParseElasticity( const gsl::cstring_span& val ); + bool ParseFlags( const gsl::cstring_span& val ); + bool ParseSpawnFlags( const gsl::cstring_span& val ); + + bool ParseOrigin1( const gsl::cstring_span& val ); + bool ParseOrigin2( const gsl::cstring_span& val ); + bool ParseRadius( const gsl::cstring_span& val ); + bool ParseHeight( const gsl::cstring_span& val ); + bool ParseRotation( const gsl::cstring_span& val ); + bool ParseRotationDelta( const gsl::cstring_span& val ); + bool ParseAngle( const gsl::cstring_span& val ); + bool ParseAngleDelta( const gsl::cstring_span& val ); + bool ParseVelocity( const gsl::cstring_span& val ); + bool ParseAcceleration( const gsl::cstring_span& val ); + bool ParseGravity( const gsl::cstring_span& val ); + bool ParseDensity( const gsl::cstring_span& val ); + bool ParseVariance( const gsl::cstring_span& val ); /// Case insensitive map from cstring_view to Value template< typename Value > - using StringViewIMap = std::map< gsl::cstring_view, Value, Q::CStringViewILess >; - using ParseMethod = bool ( CPrimitiveTemplate::* )( const gsl::cstring_view& ); + using StringViewIMap = std::map< gsl::cstring_span, Value, Q::CStringViewILess >; + using ParseMethod = bool ( CPrimitiveTemplate::* )( const gsl::cstring_span& ); // Group type processing bool ParseGroup( const CGPGroup& grp, const StringViewIMap< ParseMethod >& parseMethods, gsl::czstring name ); bool ParseRGB( const CGPGroup& grp ); @@ -328,30 +328,30 @@ class CPrimitiveTemplate bool ParsePlayFxStrings( const CGPProperty& grp ); // Group keys - bool ParseRGBStart( const gsl::cstring_view& val ); - bool ParseRGBEnd( const gsl::cstring_view& val ); - bool ParseRGBParm( const gsl::cstring_view& val ); - bool ParseRGBFlags( const gsl::cstring_view& val ); - - bool ParseAlphaStart( const gsl::cstring_view& val ); - bool ParseAlphaEnd( const gsl::cstring_view& val ); - bool ParseAlphaParm( const gsl::cstring_view& val ); - bool ParseAlphaFlags( const gsl::cstring_view& val ); - - bool ParseSizeStart( const gsl::cstring_view& val ); - bool ParseSizeEnd( const gsl::cstring_view& val ); - bool ParseSizeParm( const gsl::cstring_view& val ); - bool ParseSizeFlags( const gsl::cstring_view& val ); - - bool ParseSize2Start( const gsl::cstring_view& val ); - bool ParseSize2End( const gsl::cstring_view& val ); - bool ParseSize2Parm( const gsl::cstring_view& val ); - bool ParseSize2Flags( const gsl::cstring_view& val ); - - bool ParseLengthStart( const gsl::cstring_view& val ); - bool ParseLengthEnd( const gsl::cstring_view& val ); - bool ParseLengthParm( const gsl::cstring_view& val ); - bool ParseLengthFlags( const gsl::cstring_view& val ); + bool ParseRGBStart( const gsl::cstring_span& val ); + bool ParseRGBEnd( const gsl::cstring_span& val ); + bool ParseRGBParm( const gsl::cstring_span& val ); + bool ParseRGBFlags( const gsl::cstring_span& val ); + + bool ParseAlphaStart( const gsl::cstring_span& val ); + bool ParseAlphaEnd( const gsl::cstring_span& val ); + bool ParseAlphaParm( const gsl::cstring_span& val ); + bool ParseAlphaFlags( const gsl::cstring_span& val ); + + bool ParseSizeStart( const gsl::cstring_span& val ); + bool ParseSizeEnd( const gsl::cstring_span& val ); + bool ParseSizeParm( const gsl::cstring_span& val ); + bool ParseSizeFlags( const gsl::cstring_span& val ); + + bool ParseSize2Start( const gsl::cstring_span& val ); + bool ParseSize2End( const gsl::cstring_span& val ); + bool ParseSize2Parm( const gsl::cstring_span& val ); + bool ParseSize2Flags( const gsl::cstring_span& val ); + + bool ParseLengthStart( const gsl::cstring_span& val ); + bool ParseLengthEnd( const gsl::cstring_span& val ); + bool ParseLengthParm( const gsl::cstring_span& val ); + bool ParseLengthFlags( const gsl::cstring_span& val ); public: diff --git a/codeJK2/cgame/FxSystem.cpp b/codeJK2/cgame/FxSystem.cpp index 96b4e56cee..d4a47ffd0f 100644 --- a/codeJK2/cgame/FxSystem.cpp +++ b/codeJK2/cgame/FxSystem.cpp @@ -121,21 +121,21 @@ void SFxHelper::AddFxToScene( refEntity_t *ent ) } //------------------------------------------------------ -int SFxHelper::RegisterShader( const gsl::cstring_view& shader ) +int SFxHelper::RegisterShader( const gsl::cstring_span& shader ) { // TODO: it would be nice to change the ABI here to allow for passing of string views return cgi_R_RegisterShader( std::string( shader.begin(), shader.end() ).c_str() ); } //------------------------------------------------------ -int SFxHelper::RegisterSound( const gsl::cstring_view& sound ) +int SFxHelper::RegisterSound( const gsl::cstring_span& sound ) { // TODO: it would be nice to change the ABI here to allow for passing of string views return cgi_S_RegisterSound( std::string( sound.begin(), sound.end() ).c_str() ); } //------------------------------------------------------ -int SFxHelper::RegisterModel( const gsl::cstring_view& model ) +int SFxHelper::RegisterModel( const gsl::cstring_span& model ) { return cgi_R_RegisterModel( std::string( model.begin(), model.end() ).c_str() ); } diff --git a/codeJK2/cgame/FxSystem.h b/codeJK2/cgame/FxSystem.h index 565e321f51..fb83979ce0 100644 --- a/codeJK2/cgame/FxSystem.h +++ b/codeJK2/cgame/FxSystem.h @@ -59,7 +59,7 @@ struct SFxHelper // Sound void PlaySound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx ); - int RegisterSound( const gsl::cstring_view& sound ); + int RegisterSound( const gsl::cstring_span& sound ); // Physics/collision void Trace( trace_t *tr, vec3_t start, vec3_t min, vec3_t max, vec3_t end, int skipEntNum, int flags ); @@ -67,8 +67,8 @@ struct SFxHelper void AddFxToScene( refEntity_t *ent ); void AddLightToScene( vec3_t org, float radius, float red, float green, float blue ); - int RegisterShader( const gsl::cstring_view& shader ); - int RegisterModel( const gsl::cstring_view& model ); + int RegisterShader( const gsl::cstring_span& shader ); + int RegisterModel( const gsl::cstring_span& model ); void AddPolyToScene( int shader, int count, polyVert_t *verts ); diff --git a/codeJK2/cgame/FxTemplate.cpp b/codeJK2/cgame/FxTemplate.cpp index b95ee11ab8..7e06a808fb 100644 --- a/codeJK2/cgame/FxTemplate.cpp +++ b/codeJK2/cgame/FxTemplate.cpp @@ -189,7 +189,7 @@ void CPrimitiveTemplate::operator=(const CPrimitiveTemplate &that) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseFloat( const gsl::cstring_view& val, float& min, float& max ) +bool CPrimitiveTemplate::ParseFloat( const gsl::cstring_span& val, float& min, float& max ) { // attempt to read out the values int v = Q::sscanf( val, min, max ); @@ -220,7 +220,7 @@ bool CPrimitiveTemplate::ParseFloat( const gsl::cstring_view& val, float& min, f // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseVector( const gsl::cstring_view& val, vec3_t min, vec3_t max ) +bool CPrimitiveTemplate::ParseVector( const gsl::cstring_span& val, vec3_t min, vec3_t max ) { // we don't allow passing in a null if ( min == nullptr || max == nullptr ) @@ -252,7 +252,7 @@ namespace detail struct ScanStrings { template< std::size_t count, typename... Args > - static int call( const gsl::cstring_view& val, std::array< gsl::cstring_view, count >& arr, Args&... args ) + static int call( const gsl::cstring_span& val, std::array< gsl::cstring_span, count >& arr, Args&... args ) { return ScanStrings< remaining - 1 >::call( val, arr, arr[ remaining - 1 ], args... ); } @@ -262,7 +262,7 @@ namespace detail struct ScanStrings< 0 > { template< std::size_t count, typename... Args > - static int call( const gsl::cstring_view& val, std::array< gsl::cstring_view, count >& arr, Args&... args ) + static int call( const gsl::cstring_span& val, std::array< gsl::cstring_span, count >& arr, Args&... args ) { return Q::sscanf( val, args... ); } @@ -270,7 +270,7 @@ namespace detail } template< std::size_t count > -static gsl::array_view< gsl::cstring_view > scanStrings( const gsl::cstring_view& val, std::array< gsl::cstring_view, count >& arr ) +static gsl::span< gsl::cstring_span > scanStrings( const gsl::cstring_span& val, std::array< gsl::cstring_span, count >& arr ) { int numParsed = detail::ScanStrings< count >::call( val, arr ); return{ arr.data(), arr.data() + numParsed }; @@ -289,10 +289,10 @@ static gsl::array_view< gsl::cstring_view > scanStrings( const gsl::cstring_view // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseGroupFlags( const gsl::cstring_view& val, int& flags ) +bool CPrimitiveTemplate::ParseGroupFlags( const gsl::cstring_span& val, int& flags ) { // For a sub group, really you probably only have one or two flags set - std::array< gsl::cstring_view, 4 > flag; + std::array< gsl::cstring_span, 4 > flag; const auto availableFlag = scanStrings( val, flag ); @@ -334,7 +334,7 @@ bool CPrimitiveTemplate::ParseGroupFlags( const gsl::cstring_view& val, int& fla // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseMin( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseMin( const gsl::cstring_span& val ) { vec3_t min; @@ -360,7 +360,7 @@ bool CPrimitiveTemplate::ParseMin( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseMax( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseMax( const gsl::cstring_span& val ) { vec3_t max; @@ -386,7 +386,7 @@ bool CPrimitiveTemplate::ParseMax( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseLife( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseLife( const gsl::cstring_span& val ) { float min, max; @@ -409,7 +409,7 @@ bool CPrimitiveTemplate::ParseLife( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseDelay( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseDelay( const gsl::cstring_span& val ) { float min, max; @@ -432,7 +432,7 @@ bool CPrimitiveTemplate::ParseDelay( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseCount( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseCount( const gsl::cstring_span& val ) { float min, max; @@ -455,7 +455,7 @@ bool CPrimitiveTemplate::ParseCount( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseElasticity( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseElasticity( const gsl::cstring_span& val ) { float min, max; @@ -482,7 +482,7 @@ bool CPrimitiveTemplate::ParseElasticity( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseOrigin1( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseOrigin1( const gsl::cstring_span& val ) { vec3_t min, max; @@ -507,7 +507,7 @@ bool CPrimitiveTemplate::ParseOrigin1( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseOrigin2( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseOrigin2( const gsl::cstring_span& val ) { vec3_t min, max; @@ -532,7 +532,7 @@ bool CPrimitiveTemplate::ParseOrigin2( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRadius( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRadius( const gsl::cstring_span& val ) { float min, max; @@ -555,7 +555,7 @@ bool CPrimitiveTemplate::ParseRadius( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseHeight( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseHeight( const gsl::cstring_span& val ) { float min, max; @@ -578,7 +578,7 @@ bool CPrimitiveTemplate::ParseHeight( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRotation( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRotation( const gsl::cstring_span& val ) { float min, max; @@ -601,7 +601,7 @@ bool CPrimitiveTemplate::ParseRotation( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRotationDelta( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRotationDelta( const gsl::cstring_span& val ) { float min, max; @@ -624,7 +624,7 @@ bool CPrimitiveTemplate::ParseRotationDelta( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAngle( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAngle( const gsl::cstring_span& val ) { vec3_t min, max; @@ -649,7 +649,7 @@ bool CPrimitiveTemplate::ParseAngle( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAngleDelta( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAngleDelta( const gsl::cstring_span& val ) { vec3_t min, max; @@ -674,7 +674,7 @@ bool CPrimitiveTemplate::ParseAngleDelta( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseVelocity( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseVelocity( const gsl::cstring_span& val ) { vec3_t min, max; @@ -700,10 +700,10 @@ bool CPrimitiveTemplate::ParseVelocity( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseFlags( const gsl::cstring_span& val ) { // For a primitive, really you probably only have two or less flags set - std::array< gsl::cstring_view, 7 > flag; + std::array< gsl::cstring_span, 7 > flag; const auto availableFlag = scanStrings( val, flag ); @@ -749,9 +749,9 @@ bool CPrimitiveTemplate::ParseFlags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSpawnFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSpawnFlags( const gsl::cstring_span& val ) { - std::array< gsl::cstring_view, 7 > flag; + std::array< gsl::cstring_span, 7 > flag; // For a primitive, really you probably only have two or less flags set const auto availableFlag = scanStrings( val, flag ); @@ -799,7 +799,7 @@ bool CPrimitiveTemplate::ParseSpawnFlags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAcceleration( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAcceleration( const gsl::cstring_span& val ) { vec3_t min, max; @@ -824,7 +824,7 @@ bool CPrimitiveTemplate::ParseAcceleration( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseGravity( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseGravity( const gsl::cstring_span& val ) { float min, max; @@ -849,7 +849,7 @@ bool CPrimitiveTemplate::ParseGravity( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseDensity( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseDensity( const gsl::cstring_span& val ) { float min, max; @@ -875,7 +875,7 @@ bool CPrimitiveTemplate::ParseDensity( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseVariance( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseVariance( const gsl::cstring_span& val ) { float min, max; @@ -898,7 +898,7 @@ bool CPrimitiveTemplate::ParseVariance( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRGBStart( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRGBStart( const gsl::cstring_span& val ) { vec3_t min, max; @@ -923,7 +923,7 @@ bool CPrimitiveTemplate::ParseRGBStart( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRGBEnd( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRGBEnd( const gsl::cstring_span& val ) { vec3_t min, max; @@ -948,7 +948,7 @@ bool CPrimitiveTemplate::ParseRGBEnd( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRGBParm( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRGBParm( const gsl::cstring_span& val ) { float min, max; @@ -971,7 +971,7 @@ bool CPrimitiveTemplate::ParseRGBParm( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseRGBFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseRGBFlags( const gsl::cstring_span& val ) { int flags; @@ -995,7 +995,7 @@ bool CPrimitiveTemplate::ParseRGBFlags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAlphaStart( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAlphaStart( const gsl::cstring_span& val ) { float min, max; @@ -1018,7 +1018,7 @@ bool CPrimitiveTemplate::ParseAlphaStart( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAlphaEnd( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAlphaEnd( const gsl::cstring_span& val ) { float min, max; @@ -1041,7 +1041,7 @@ bool CPrimitiveTemplate::ParseAlphaEnd( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAlphaParm( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAlphaParm( const gsl::cstring_span& val ) { float min, max; @@ -1064,7 +1064,7 @@ bool CPrimitiveTemplate::ParseAlphaParm( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseAlphaFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseAlphaFlags( const gsl::cstring_span& val ) { int flags; @@ -1088,7 +1088,7 @@ bool CPrimitiveTemplate::ParseAlphaFlags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSizeStart( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSizeStart( const gsl::cstring_span& val ) { float min, max; @@ -1111,7 +1111,7 @@ bool CPrimitiveTemplate::ParseSizeStart( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSizeEnd( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSizeEnd( const gsl::cstring_span& val ) { float min, max; @@ -1134,7 +1134,7 @@ bool CPrimitiveTemplate::ParseSizeEnd( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSizeParm( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSizeParm( const gsl::cstring_span& val ) { float min, max; @@ -1157,7 +1157,7 @@ bool CPrimitiveTemplate::ParseSizeParm( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSizeFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSizeFlags( const gsl::cstring_span& val ) { int flags; @@ -1181,7 +1181,7 @@ bool CPrimitiveTemplate::ParseSizeFlags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSize2Start( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSize2Start( const gsl::cstring_span& val ) { float min, max; @@ -1204,7 +1204,7 @@ bool CPrimitiveTemplate::ParseSize2Start( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSize2End( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSize2End( const gsl::cstring_span& val ) { float min, max; @@ -1227,7 +1227,7 @@ bool CPrimitiveTemplate::ParseSize2End( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSize2Parm( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSize2Parm( const gsl::cstring_span& val ) { float min, max; @@ -1250,7 +1250,7 @@ bool CPrimitiveTemplate::ParseSize2Parm( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseSize2Flags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseSize2Flags( const gsl::cstring_span& val ) { int flags; @@ -1274,7 +1274,7 @@ bool CPrimitiveTemplate::ParseSize2Flags( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseLengthStart( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseLengthStart( const gsl::cstring_span& val ) { float min, max; @@ -1297,7 +1297,7 @@ bool CPrimitiveTemplate::ParseLengthStart( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseLengthEnd( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseLengthEnd( const gsl::cstring_span& val ) { float min, max; @@ -1320,7 +1320,7 @@ bool CPrimitiveTemplate::ParseLengthEnd( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseLengthParm( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseLengthParm( const gsl::cstring_span& val ) { float min, max; @@ -1343,7 +1343,7 @@ bool CPrimitiveTemplate::ParseLengthParm( const gsl::cstring_view& val ) // return: // success of parse operation. //------------------------------------------------------ -bool CPrimitiveTemplate::ParseLengthFlags( const gsl::cstring_view& val ) +bool CPrimitiveTemplate::ParseLengthFlags( const gsl::cstring_span& val ) { int flags; diff --git a/codeJK2/game/genericparser2.cpp b/codeJK2/game/genericparser2.cpp index 196ec7b8f2..f893395ca8 100644 --- a/codeJK2/game/genericparser2.cpp +++ b/codeJK2/game/genericparser2.cpp @@ -33,9 +33,9 @@ along with this program; if not, see . #include -static void skipWhitespace( gsl::cstring_view& text, const bool allowLineBreaks ) +static void skipWhitespace( gsl::cstring_span& text, const bool allowLineBreaks ) { - gsl::cstring_view::iterator whitespaceEnd = text.begin(); + gsl::cstring_span::iterator whitespaceEnd = text.begin(); while ( whitespaceEnd != text.end() // No EOF && std::isspace( *whitespaceEnd ) // No End of Whitespace && (allowLineBreaks || *whitespaceEnd != '\n') ) // No unwanted newline @@ -45,7 +45,7 @@ static void skipWhitespace( gsl::cstring_view& text, const bool allowLineBreaks text = { whitespaceEnd, text.end() }; } -static void skipWhitespaceAndComments( gsl::cstring_view& text, const bool allowLineBreaks ) +static void skipWhitespaceAndComments( gsl::cstring_span& text, const bool allowLineBreaks ) { skipWhitespace( text, allowLineBreaks ); // skip single line comment @@ -87,7 +87,7 @@ static void skipWhitespaceAndComments( gsl::cstring_view& text, const bool allow return; } -static gsl::cstring_view removeTrailingWhitespace( const gsl::cstring_view& text ) +static gsl::cstring_span removeTrailingWhitespace( const gsl::cstring_span& text ) { return{ text.begin(), @@ -106,7 +106,7 @@ A token can be: - EOL- or comment-delimited (if readToEOL == true); i.e. reads to end of line or the first // or /* @param text adjusted to start beyond the read token */ -static gsl::cstring_view GetToken( gsl::cstring_view& text, bool allowLineBreaks, bool readToEOL = false ) +static gsl::cstring_span GetToken( gsl::cstring_span& text, bool allowLineBreaks, bool readToEOL = false ) { skipWhitespaceAndComments( text, allowLineBreaks ); // EOF @@ -121,13 +121,13 @@ static gsl::cstring_view GetToken( gsl::cstring_view& text, bool allowLineBreaks auto tokenEnd = std::find( text.begin() + 1, text.end(), '"' ); if ( tokenEnd == text.end() ) { - gsl::cstring_view token = { text.begin() + 1, text.end() }; + gsl::cstring_span token = { text.begin() + 1, text.end() }; text = { text.end(), text.end() }; return token; } else { - gsl::cstring_view token = { text.begin() + 1, tokenEnd }; + gsl::cstring_span token = { text.begin() + 1, tokenEnd }; text = { tokenEnd + 1, text.end() }; return token; } @@ -150,7 +150,7 @@ static gsl::cstring_view GetToken( gsl::cstring_view& text, bool allowLineBreaks ) ); } - gsl::cstring_view token{ text.begin(), tokenEnd }; + gsl::cstring_span token{ text.begin(), tokenEnd }; text = { tokenEnd, text.end() }; return removeTrailingWhitespace( token ); } @@ -158,7 +158,7 @@ static gsl::cstring_view GetToken( gsl::cstring_view& text, bool allowLineBreaks { // consume until first whitespace (if allowLineBreaks == false, that may be text.begin(); in that case token is empty.) auto tokenEnd = std::find_if( text.begin(), text.end(), static_cast< int( *)(int) >(std::isspace) ); - gsl::cstring_view token{ text.begin(), tokenEnd }; + gsl::cstring_span token{ text.begin(), tokenEnd }; text = { tokenEnd, text.end() }; return token; } @@ -168,7 +168,7 @@ static gsl::cstring_view GetToken( gsl::cstring_view& text, bool allowLineBreaks -CGPProperty::CGPProperty( gsl::cstring_view initKey, gsl::cstring_view initValue ) +CGPProperty::CGPProperty( gsl::cstring_span initKey, gsl::cstring_span initValue ) : mKey( initKey ) { if ( !initValue.empty() ) @@ -177,7 +177,7 @@ CGPProperty::CGPProperty( gsl::cstring_view initKey, gsl::cstring_view initValue } } -void CGPProperty::AddValue( gsl::cstring_view newValue ) +void CGPProperty::AddValue( gsl::cstring_span newValue ) { mValues.push_back( newValue ); } @@ -197,15 +197,15 @@ void CGPProperty::AddValue( gsl::cstring_view newValue ) -CGPGroup::CGPGroup( const gsl::cstring_view& initName ) +CGPGroup::CGPGroup( const gsl::cstring_span& initName ) : mName( initName ) {} -bool CGPGroup::Parse( gsl::cstring_view& data, const bool topLevel ) +bool CGPGroup::Parse( gsl::cstring_span& data, const bool topLevel ) { while ( true ) { - gsl::cstring_view token = GetToken( data, true ); + gsl::cstring_span token = GetToken( data, true ); if ( token.empty() ) { @@ -233,7 +233,7 @@ bool CGPGroup::Parse( gsl::cstring_view& data, const bool topLevel ) return true; } } - gsl::cstring_view lastToken = token; + gsl::cstring_span lastToken = token; // read ahead to see what we are doing token = GetToken( data, true, true ); diff --git a/codeJK2/game/genericparser2.h b/codeJK2/game/genericparser2.h index 815d96ff6b..3084c9f106 100644 --- a/codeJK2/game/genericparser2.h +++ b/codeJK2/game/genericparser2.h @@ -44,17 +44,17 @@ namespace GP2 class CGPProperty { public: - using Values = GP2::Vector< gsl::cstring_view >; + using Values = GP2::Vector< gsl::cstring_span >; private: - gsl::cstring_view mKey; + gsl::cstring_span mKey; Values mValues; public: - CGPProperty( gsl::cstring_view initKey, gsl::cstring_view initValue = {} ); + CGPProperty( gsl::cstring_span initKey, gsl::cstring_span initValue = {} ); - const gsl::cstring_view& GetName() const + const gsl::cstring_span& GetName() const { return mKey; } @@ -62,9 +62,9 @@ class CGPProperty { return mValues.size() > 1; } - const gsl::cstring_view& GetTopValue() const NOEXCEPT + const gsl::cstring_span& GetTopValue() const NOEXCEPT { - static gsl::cstring_view empty{}; + static gsl::cstring_span empty{}; return mValues.empty() ? empty : mValues.front(); } const Values& GetValues() const NOEXCEPT @@ -72,7 +72,7 @@ class CGPProperty return mValues; } // Copies the value into the textPool and adds a pointer to that copy to the end of the list. - void AddValue( gsl::cstring_view newValue ); + void AddValue( gsl::cstring_span newValue ); }; @@ -85,11 +85,11 @@ class CGPGroup using SubGroups = GP2::Vector< CGPGroup >; private: Properties mProperties; - gsl::cstring_view mName = CSTRING_VIEW( "Top Level" ); + gsl::cstring_span mName = CSTRING_VIEW( "Top Level" ); SubGroups mSubGroups; public: CGPGroup() = default; - CGPGroup( const gsl::cstring_view& initName ); + CGPGroup( const gsl::cstring_span& initName ); // non-copyable; but just for performance reasons, since it would incur a deep copy. CGPGroup( const CGPGroup& ) = delete; CGPGroup& operator=( const CGPGroup& ) = delete; @@ -122,7 +122,7 @@ class CGPGroup { return mSubGroups; } - const CGPGroup* FindSubGroup( const gsl::cstring_view& name ) const NOEXCEPT + const CGPGroup* FindSubGroup( const gsl::cstring_span& name ) const NOEXCEPT { for ( auto& sub : GetSubGroups() ) { @@ -133,7 +133,7 @@ class CGPGroup } return nullptr; } - const CGPProperty* FindProperty( const gsl::cstring_view& name ) const NOEXCEPT + const CGPProperty* FindProperty( const gsl::cstring_span& name ) const NOEXCEPT { for ( auto& prop : GetProperties() ) { @@ -144,7 +144,7 @@ class CGPGroup } return nullptr; } - const gsl::cstring_view& GetName() const NOEXCEPT + const gsl::cstring_span& GetName() const NOEXCEPT { return mName; } @@ -154,7 +154,7 @@ class CGPGroup mProperties.clear(); mSubGroups.clear(); } - bool Parse( gsl::cstring_view& data, const bool topLevel = true ); + bool Parse( gsl::cstring_span& data, const bool topLevel = true ); }; /** diff --git a/lib/gsl-lite/include/gsl/gsl-lite.h b/lib/gsl-lite/include/gsl/gsl-lite.h index 0a99083e38..8ae9b57f89 100644 --- a/lib/gsl-lite/include/gsl/gsl-lite.h +++ b/lib/gsl-lite/include/gsl/gsl-lite.h @@ -1,881 +1,5544 @@ // -// gsl-lite is based on GSL: Guidelines Support Library, -// https://github.com/microsoft/gsl -// -// Copyright (c) 2015 Martin Moene -// Copyright (c) 2015 Microsoft Corporation. All rights reserved. -// -// This code is licensed under the MIT License (MIT). -// -// 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. - -#pragma once - -#ifndef GSL_GSL_LITE_H_INCLUDED -#define GSL_GSL_LITE_H_INCLUDED - -#include -#include +// gsl-lite is based on GSL: Guidelines Support Library. +// For more information see https://github.com/gsl-lite/gsl-lite +// +// Copyright (c) 2015-2019 Martin Moene +// Copyright (c) 2019-2023 Moritz Beutel +// Copyright (c) 2015-2018 Microsoft Corporation. All rights reserved. +// +// This code is licensed under the MIT License (MIT). +// +// 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. + +#ifndef GSL_GSL_LITE_HPP_INCLUDED +#define GSL_GSL_LITE_HPP_INCLUDED + +#include // for exception, terminate(), uncaught_exceptions() #include -#include -#include +#include // for addressof(), unique_ptr<>, shared_ptr<> +#include // for basic_ostream<> +#include // for ios_base, streamsize +#include // for logic_error #include -#include -#include +#include // for move(), forward<>(), swap() +#include // for size_t, ptrdiff_t, nullptr_t +#include // for abort() + +#define gsl_lite_MAJOR 0 +#define gsl_lite_MINOR 41 +#define gsl_lite_PATCH 0 + +#define gsl_lite_VERSION gsl_STRINGIFY(gsl_lite_MAJOR) "." gsl_STRINGIFY(gsl_lite_MINOR) "." gsl_STRINGIFY(gsl_lite_PATCH) + +#define gsl_STRINGIFY( x ) gsl_STRINGIFY_( x ) +#define gsl_STRINGIFY_( x ) #x +#define gsl_CONCAT_( a, b ) gsl_CONCAT2_( a, b ) +#define gsl_CONCAT2_( a, b ) a##b +#define gsl_EVALF_( f ) f() + +// configuration argument checking: + +#define gsl_DETAIL_CFG_TOGGLE_VALUE_1 1 +#define gsl_DETAIL_CFG_TOGGLE_VALUE_0 1 +#define gsl_DETAIL_CFG_DEFAULTS_VERSION_VALUE_1 1 +#define gsl_DETAIL_CFG_DEFAULTS_VERSION_VALUE_0 1 +#define gsl_DETAIL_CFG_STD_VALUE_98 1 +#define gsl_DETAIL_CFG_STD_VALUE_3 1 +#define gsl_DETAIL_CFG_STD_VALUE_03 1 +#define gsl_DETAIL_CFG_STD_VALUE_11 1 +#define gsl_DETAIL_CFG_STD_VALUE_14 1 +#define gsl_DETAIL_CFG_STD_VALUE_17 1 +#define gsl_DETAIL_CFG_STD_VALUE_20 1 +#define gsl_DETAIL_CFG_NO_VALUE_ 1 +#define gsl_DETAIL_CFG_NO_VALUE_1 1 // many compilers treat the command-line parameter "-Dfoo" as equivalent to "-Dfoo=1", so we tolerate that +#define gsl_CHECK_CFG_TOGGLE_VALUE_( x ) gsl_CONCAT_( gsl_DETAIL_CFG_TOGGLE_VALUE_, x ) +#define gsl_CHECK_CFG_DEFAULTS_VERSION_VALUE_( x ) gsl_CONCAT_( gsl_DETAIL_CFG_DEFAULTS_VERSION_VALUE_, x ) +#define gsl_CHECK_CFG_STD_VALUE_( x ) gsl_CONCAT_( gsl_DETAIL_CFG_STD_VALUE_, x ) +#define gsl_CHECK_CFG_NO_VALUE_( x ) gsl_CONCAT_( gsl_DETAIL_CFG_NO_VALUE, gsl_CONCAT_( _, x ) ) + +// gsl-lite backward compatibility: + +#if defined( gsl_CONFIG_DEFAULTS_VERSION ) +# if ! gsl_CHECK_CFG_DEFAULTS_VERSION_VALUE_( gsl_CONFIG_DEFAULTS_VERSION ) +# pragma message ("invalid configuration value gsl_CONFIG_DEFAULTS_VERSION=" gsl_STRINGIFY(gsl_CONFIG_DEFAULTS_VERSION) ", must be 0 or 1") +# endif +#else +# define gsl_CONFIG_DEFAULTS_VERSION gsl_lite_MAJOR // default +#endif +# define gsl_CONFIG_DEFAULTS_VERSION_() gsl_CONFIG_DEFAULTS_VERSION + +#if defined( gsl_CONFIG_ALLOWS_SPAN_CONTAINER_CTOR ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_CONFIG_ALLOWS_SPAN_CONTAINER_CTOR ) +# pragma message ("invalid configuration value gsl_CONFIG_ALLOWS_SPAN_CONTAINER_CTOR=" gsl_STRINGIFY(gsl_CONFIG_ALLOWS_SPAN_CONTAINER_CTOR) ", must be 0 or 1") +# endif +# define gsl_CONFIG_ALLOWS_UNCONSTRAINED_SPAN_CONTAINER_CTOR gsl_CONFIG_ALLOWS_SPAN_CONTAINER_CTOR +# pragma message ("gsl_CONFIG_ALLOWS_SPAN_CONTAINER_CTOR is deprecated since gsl-lite 0.7; replace with gsl_CONFIG_ALLOWS_UNCONSTRAINED_SPAN_CONTAINER_CTOR, or consider span(with_container, cont).") +#endif + +#if defined( gsl_CONFIG_CONTRACT_LEVEL_ON ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_LEVEL_ON ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_LEVEL_ON=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_LEVEL_ON) "; macro must be defined without value") +# endif +# pragma message ("gsl_CONFIG_CONTRACT_LEVEL_ON is deprecated since gsl-lite 0.36; replace with gsl_CONFIG_CONTRACT_CHECKING_ON.") +# define gsl_CONFIG_CONTRACT_CHECKING_ON +#endif +#if defined( gsl_CONFIG_CONTRACT_LEVEL_OFF ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_LEVEL_OFF ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_LEVEL_OFF=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_LEVEL_OFF) "; macro must be defined without value") +# endif +# pragma message ("gsl_CONFIG_CONTRACT_LEVEL_OFF is deprecated since gsl-lite 0.36; replace with gsl_CONFIG_CONTRACT_CHECKING_OFF.") +# define gsl_CONFIG_CONTRACT_CHECKING_OFF +#endif +#if defined( gsl_CONFIG_CONTRACT_LEVEL_EXPECTS_ONLY ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_LEVEL_EXPECTS_ONLY ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_LEVEL_EXPECTS_ONLY=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_LEVEL_EXPECTS_ONLY) "; macro must be defined without value") +# endif +# pragma message ("gsl_CONFIG_CONTRACT_LEVEL_EXPECTS_ONLY is deprecated since gsl-lite 0.36; replace with gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF and gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF.") +# define gsl_CONFIG_CONTRACT_CHECKING_ON +# define gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF +# define gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF +#elif defined( gsl_CONFIG_CONTRACT_LEVEL_ENSURES_ONLY ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_LEVEL_ENSURES_ONLY ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_LEVEL_ENSURES_ONLY=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_LEVEL_ENSURES_ONLY) "; macro must be defined without value") +# endif +# pragma message ("gsl_CONFIG_CONTRACT_LEVEL_ENSURES_ONLY is deprecated since gsl-lite 0.36; replace with gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF and gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF.") +# define gsl_CONFIG_CONTRACT_CHECKING_ON +# define gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF +# define gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF +#endif + +// M-GSL compatibility: + +#if defined( GSL_THROW_ON_CONTRACT_VIOLATION ) +# if ! gsl_CHECK_CFG_NO_VALUE_( GSL_THROW_ON_CONTRACT_VIOLATION ) +# pragma message ("invalid configuration value GSL_THROW_ON_CONTRACT_VIOLATION=" gsl_STRINGIFY(GSL_THROW_ON_CONTRACT_VIOLATION) "; macro must be defined without value") +# endif +# define gsl_CONFIG_CONTRACT_VIOLATION_THROWS +#endif + +#if defined( GSL_TERMINATE_ON_CONTRACT_VIOLATION ) +# if ! gsl_CHECK_CFG_NO_VALUE_( GSL_TERMINATE_ON_CONTRACT_VIOLATION ) +# pragma message ("invalid configuration value GSL_TERMINATE_ON_CONTRACT_VIOLATION=" gsl_STRINGIFY(GSL_TERMINATE_ON_CONTRACT_VIOLATION) "; macro must be defined without value") +# endif +# define gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES +#endif + +#if defined( GSL_UNENFORCED_ON_CONTRACT_VIOLATION ) +# if ! gsl_CHECK_CFG_NO_VALUE_( GSL_UNENFORCED_ON_CONTRACT_VIOLATION ) +# pragma message ("invalid configuration value GSL_UNENFORCED_ON_CONTRACT_VIOLATION=" gsl_STRINGIFY(GSL_UNENFORCED_ON_CONTRACT_VIOLATION) "; macro must be defined without value") +# endif +# define gsl_CONFIG_CONTRACT_CHECKING_OFF +#endif + +// Configuration: Features + +#if defined( gsl_FEATURE_WITH_CONTAINER_TO_STD ) +# if ! gsl_CHECK_CFG_STD_VALUE_( gsl_FEATURE_WITH_CONTAINER_TO_STD ) +# pragma message ("invalid configuration value gsl_FEATURE_WITH_CONTAINER_TO_STD=" gsl_STRINGIFY(gsl_FEATURE_WITH_CONTAINER_TO_STD) ", must be 98, 3, 11, 14, 17, or 20") +# endif +#else +# define gsl_FEATURE_WITH_CONTAINER_TO_STD 99 // default +#endif +#define gsl_FEATURE_WITH_CONTAINER_TO_STD_() gsl_FEATURE_WITH_CONTAINER_TO_STD + +#if defined( gsl_FEATURE_MAKE_SPAN_TO_STD ) +# if ! gsl_CHECK_CFG_STD_VALUE_( gsl_FEATURE_MAKE_SPAN_TO_STD ) +# pragma message ("invalid configuration value gsl_FEATURE_MAKE_SPAN_TO_STD=" gsl_STRINGIFY(gsl_FEATURE_MAKE_SPAN_TO_STD) ", must be 98, 3, 11, 14, 17, or 20") +# endif +#else +# define gsl_FEATURE_MAKE_SPAN_TO_STD 99 // default +#endif +#define gsl_FEATURE_MAKE_SPAN_TO_STD_() gsl_FEATURE_MAKE_SPAN_TO_STD + +#if defined( gsl_FEATURE_BYTE_SPAN_TO_STD ) +# if ! gsl_CHECK_CFG_STD_VALUE_( gsl_FEATURE_BYTE_SPAN_TO_STD ) +# pragma message ("invalid configuration value gsl_FEATURE_BYTE_SPAN_TO_STD=" gsl_STRINGIFY(gsl_FEATURE_BYTE_SPAN_TO_STD) ", must be 98, 3, 11, 14, 17, or 20") +# endif +#else +# define gsl_FEATURE_BYTE_SPAN_TO_STD 99 // default +#endif +#define gsl_FEATURE_BYTE_SPAN_TO_STD_() gsl_FEATURE_BYTE_SPAN_TO_STD + +#if defined( gsl_FEATURE_IMPLICIT_MACRO ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_FEATURE_IMPLICIT_MACRO ) +# pragma message ("invalid configuration value gsl_FEATURE_IMPLICIT_MACRO=" gsl_STRINGIFY(gsl_FEATURE_IMPLICIT_MACRO) ", must be 0 or 1") +# endif +#else +# define gsl_FEATURE_IMPLICIT_MACRO 0 // default +#endif +#define gsl_FEATURE_IMPLICIT_MACRO_() gsl_FEATURE_IMPLICIT_MACRO + +#if defined( gsl_FEATURE_OWNER_MACRO ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_FEATURE_OWNER_MACRO ) +# pragma message ("invalid configuration value gsl_FEATURE_OWNER_MACRO=" gsl_STRINGIFY(gsl_FEATURE_OWNER_MACRO) ", must be 0 or 1") +# endif +#else +# define gsl_FEATURE_OWNER_MACRO (gsl_CONFIG_DEFAULTS_VERSION == 0) // default +#endif +#define gsl_FEATURE_OWNER_MACRO_() gsl_FEATURE_OWNER_MACRO + +//#if defined( gsl_FEATURE_STRING_SPAN ) +//# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_FEATURE_STRING_SPAN ) +//# pragma message ("invalid configuration value gsl_FEATURE_STRING_SPAN=" gsl_STRINGIFY(gsl_FEATURE_STRING_SPAN) ", must be 0 or 1") +//# endif +//#else +//# define gsl_FEATURE_STRING_SPAN (gsl_CONFIG_DEFAULTS_VERSION == 0) // default +//#endif +//#define gsl_FEATURE_STRING_SPAN_() gsl_FEATURE_STRING_SPAN + +#if defined( gsl_FEATURE_EXPERIMENTAL_RETURN_GUARD ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_FEATURE_EXPERIMENTAL_RETURN_GUARD ) +# pragma message ("invalid configuration value gsl_FEATURE_EXPERIMENTAL_RETURN_GUARD=" gsl_STRINGIFY(gsl_FEATURE_EXPERIMENTAL_RETURN_GUARD) ", must be 0 or 1") +# endif +#else +# define gsl_FEATURE_EXPERIMENTAL_RETURN_GUARD 0 // default +#endif +# define gsl_FEATURE_EXPERIMENTAL_RETURN_GUARD_() gsl_FEATURE_EXPERIMENTAL_RETURN_GUARD + +#if defined( gsl_FEATURE_GSL_LITE_NAMESPACE ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_FEATURE_GSL_LITE_NAMESPACE ) +# pragma message ("invalid configuration value gsl_FEATURE_GSL_LITE_NAMESPACE=" gsl_STRINGIFY(gsl_FEATURE_GSL_LITE_NAMESPACE) ", must be 0 or 1") +# endif +#else +# define gsl_FEATURE_GSL_LITE_NAMESPACE (gsl_CONFIG_DEFAULTS_VERSION >= 1) // default +#endif +#define gsl_FEATURE_GSL_LITE_NAMESPACE_() gsl_FEATURE_GSL_LITE_NAMESPACE + +// Configuration: Other + +#if defined( gsl_CONFIG_TRANSPARENT_NOT_NULL ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_CONFIG_TRANSPARENT_NOT_NULL ) +# pragma message ("invalid configuration value gsl_CONFIG_TRANSPARENT_NOT_NULL=" gsl_STRINGIFY(gsl_CONFIG_TRANSPARENT_NOT_NULL) ", must be 0 or 1") +# endif +# if gsl_CONFIG_TRANSPARENT_NOT_NULL && defined( gsl_CONFIG_NOT_NULL_GET_BY_CONST_REF ) +# error configuration option gsl_CONFIG_NOT_NULL_GET_BY_CONST_REF is meaningless if gsl_CONFIG_TRANSPARENT_NOT_NULL=1 +# endif +#else +# define gsl_CONFIG_TRANSPARENT_NOT_NULL (gsl_CONFIG_DEFAULTS_VERSION >= 1) // default +#endif +# define gsl_CONFIG_TRANSPARENT_NOT_NULL_() gsl_CONFIG_TRANSPARENT_NOT_NULL + +#if ! defined( gsl_CONFIG_DEPRECATE_TO_LEVEL ) +# if gsl_CONFIG_DEFAULTS_VERSION >= 1 +# define gsl_CONFIG_DEPRECATE_TO_LEVEL 7 +# else +# define gsl_CONFIG_DEPRECATE_TO_LEVEL 0 +# endif +#endif + +#if ! defined( gsl_CONFIG_SPAN_INDEX_TYPE ) +# define gsl_CONFIG_SPAN_INDEX_TYPE std::size_t +#endif +# define gsl_CONFIG_SPAN_INDEX_TYPE_() gsl_CONFIG_SPAN_INDEX_TYPE + +#if ! defined( gsl_CONFIG_INDEX_TYPE ) +# if gsl_CONFIG_DEFAULTS_VERSION >= 1 +// p0122r3 uses std::ptrdiff_t +# define gsl_CONFIG_INDEX_TYPE std::ptrdiff_t +# else +# define gsl_CONFIG_INDEX_TYPE gsl_CONFIG_SPAN_INDEX_TYPE +# endif +#endif +# define gsl_CONFIG_INDEX_TYPE_() gsl_CONFIG_INDEX_TYPE + +#if defined( gsl_CONFIG_NOT_NULL_EXPLICIT_CTOR ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_CONFIG_NOT_NULL_EXPLICIT_CTOR ) +# pragma message ("invalid configuration value gsl_CONFIG_NOT_NULL_EXPLICIT_CTOR=" gsl_STRINGIFY(gsl_CONFIG_NOT_NULL_EXPLICIT_CTOR) ", must be 0 or 1") +# endif +#else +# define gsl_CONFIG_NOT_NULL_EXPLICIT_CTOR (gsl_CONFIG_DEFAULTS_VERSION >= 1) // default +#endif +#define gsl_CONFIG_NOT_NULL_EXPLICIT_CTOR_() gsl_CONFIG_NOT_NULL_EXPLICIT_CTOR + +#if defined( gsl_CONFIG_NOT_NULL_GET_BY_CONST_REF ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_CONFIG_NOT_NULL_GET_BY_CONST_REF ) +# pragma message ("invalid configuration value gsl_CONFIG_NOT_NULL_GET_BY_CONST_REF=" gsl_STRINGIFY(gsl_CONFIG_NOT_NULL_GET_BY_CONST_REF) ", must be 0 or 1") +# endif +#else +# define gsl_CONFIG_NOT_NULL_GET_BY_CONST_REF 0 // default +#endif +#define gsl_CONFIG_NOT_NULL_GET_BY_CONST_REF_() gsl_CONFIG_NOT_NULL_GET_BY_CONST_REF + +#if defined( gsl_CONFIG_CONFIRMS_COMPILATION_ERRORS ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_CONFIG_CONFIRMS_COMPILATION_ERRORS ) +# pragma message ("invalid configuration value gsl_CONFIG_CONFIRMS_COMPILATION_ERRORS=" gsl_STRINGIFY(gsl_CONFIG_CONFIRMS_COMPILATION_ERRORS) ", must be 0 or 1") +# endif +#else +# define gsl_CONFIG_CONFIRMS_COMPILATION_ERRORS 0 // default +#endif +#define gsl_CONFIG_CONFIRMS_COMPILATION_ERRORS_() gsl_CONFIG_CONFIRMS_COMPILATION_ERRORS + +#if defined( gsl_CONFIG_ALLOWS_SPAN_COMPARISON ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_CONFIG_ALLOWS_SPAN_COMPARISON ) +# pragma message ("invalid configuration value gsl_CONFIG_ALLOWS_SPAN_COMPARISON=" gsl_STRINGIFY(gsl_CONFIG_ALLOWS_SPAN_COMPARISON) ", must be 0 or 1") +# endif +#else +# define gsl_CONFIG_ALLOWS_SPAN_COMPARISON (gsl_CONFIG_DEFAULTS_VERSION == 0) // default +#endif +#define gsl_CONFIG_ALLOWS_SPAN_COMPARISON_() gsl_CONFIG_ALLOWS_SPAN_COMPARISON + +#if defined( gsl_CONFIG_ALLOWS_NONSTRICT_SPAN_COMPARISON ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_CONFIG_ALLOWS_NONSTRICT_SPAN_COMPARISON ) +# pragma message ("invalid configuration value gsl_CONFIG_ALLOWS_NONSTRICT_SPAN_COMPARISON=" gsl_STRINGIFY(gsl_CONFIG_ALLOWS_NONSTRICT_SPAN_COMPARISON) ", must be 0 or 1") +# endif +#else +# define gsl_CONFIG_ALLOWS_NONSTRICT_SPAN_COMPARISON 1 // default +#endif +#define gsl_CONFIG_ALLOWS_NONSTRICT_SPAN_COMPARISON_() gsl_CONFIG_ALLOWS_NONSTRICT_SPAN_COMPARISON + +#if defined( gsl_CONFIG_ALLOWS_UNCONSTRAINED_SPAN_CONTAINER_CTOR ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_CONFIG_ALLOWS_UNCONSTRAINED_SPAN_CONTAINER_CTOR ) +# pragma message ("invalid configuration value gsl_CONFIG_ALLOWS_UNCONSTRAINED_SPAN_CONTAINER_CTOR=" gsl_STRINGIFY(gsl_CONFIG_ALLOWS_UNCONSTRAINED_SPAN_CONTAINER_CTOR) ", must be 0 or 1") +# endif +#else +# define gsl_CONFIG_ALLOWS_UNCONSTRAINED_SPAN_CONTAINER_CTOR 0 // default +#endif +#define gsl_CONFIG_ALLOWS_UNCONSTRAINED_SPAN_CONTAINER_CTOR_() gsl_CONFIG_ALLOWS_UNCONSTRAINED_SPAN_CONTAINER_CTOR + +#if defined( gsl_CONFIG_NARROW_THROWS_ON_TRUNCATION ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_CONFIG_NARROW_THROWS_ON_TRUNCATION ) +# pragma message ("invalid configuration value gsl_CONFIG_NARROW_THROWS_ON_TRUNCATION=" gsl_STRINGIFY(gsl_CONFIG_NARROW_THROWS_ON_TRUNCATION) ", must be 0 or 1") +# endif +#else +# define gsl_CONFIG_NARROW_THROWS_ON_TRUNCATION (gsl_CONFIG_DEFAULTS_VERSION >= 1) // default +#endif +#define gsl_CONFIG_NARROW_THROWS_ON_TRUNCATION_() gsl_CONFIG_NARROW_THROWS_ON_TRUNCATION + +#if defined( gsl_CONFIG_VALIDATES_UNENFORCED_CONTRACT_EXPRESSIONS ) +# if ! gsl_CHECK_CFG_TOGGLE_VALUE_( gsl_CONFIG_VALIDATES_UNENFORCED_CONTRACT_EXPRESSIONS ) +# pragma message ("invalid configuration value gsl_CONFIG_VALIDATES_UNENFORCED_CONTRACT_EXPRESSIONS=" gsl_STRINGIFY(gsl_CONFIG_VALIDATES_UNENFORCED_CONTRACT_EXPRESSIONS) ", must be 0 or 1") +# endif +#else +# define gsl_CONFIG_VALIDATES_UNENFORCED_CONTRACT_EXPRESSIONS 1 // default +#endif +#define gsl_CONFIG_VALIDATES_UNENFORCED_CONTRACT_EXPRESSIONS_() gsl_CONFIG_VALIDATES_UNENFORCED_CONTRACT_EXPRESSIONS + +#if defined( gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_CONTRACT_CHECKING_AUDIT ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_CHECKING_AUDIT ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_CHECKING_AUDIT=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_CHECKING_AUDIT) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_CONTRACT_CHECKING_ON ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_CHECKING_ON ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_CHECKING_ON=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_CHECKING_ON) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_CONTRACT_CHECKING_OFF ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_CHECKING_OFF ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_CHECKING_OFF=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_CHECKING_OFF) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT ) +# pragma message ("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON ) +# pragma message ("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF ) +# pragma message ("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_CONTRACT_VIOLATION_THROWS ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_VIOLATION_THROWS ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_VIOLATION_THROWS=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_VIOLATION_THROWS) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_CONTRACT_VIOLATION_TRAPS ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_VIOLATION_TRAPS ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_VIOLATION_TRAPS=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_VIOLATION_TRAPS) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER ) +# pragma message ("invalid configuration value gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER=" gsl_STRINGIFY(gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS ) +# pragma message ("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS ) +# pragma message ("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER ) +# pragma message ("invalid configuration value gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME ) +# pragma message ("invalid configuration value gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME=" gsl_STRINGIFY(gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE ) +# pragma message ("invalid configuration value gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE=" gsl_STRINGIFY(gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME ) +# pragma message ("invalid configuration value gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME) "; macro must be defined without value") +# endif +#endif +#if defined( gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE ) +# if ! gsl_CHECK_CFG_NO_VALUE_( gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE ) +# pragma message ("invalid configuration value gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE=" gsl_STRINGIFY(gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE) "; macro must be defined without value") +# endif +#endif + +#if defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_THROWS ) +# error cannot use gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_THROWS because exceptions are not supported in device code; use gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS or gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS +#endif +#if defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TERMINATES ) +# error gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TERMINATES is not supported; use gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS or gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS +#endif + +#if 1 < defined( gsl_CONFIG_CONTRACT_CHECKING_AUDIT ) + defined( gsl_CONFIG_CONTRACT_CHECKING_ON ) + defined( gsl_CONFIG_CONTRACT_CHECKING_OFF ) +# error only one of gsl_CONFIG_CONTRACT_CHECKING_AUDIT, gsl_CONFIG_CONTRACT_CHECKING_ON, and gsl_CONFIG_CONTRACT_CHECKING_OFF may be defined +#endif +#if 1 < defined( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT ) + defined( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON ) + defined( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF ) +# error only one of gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT, gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON, and gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF may be defined +#endif +#if 1 < defined( gsl_CONFIG_CONTRACT_VIOLATION_THROWS ) + defined( gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES ) + defined( gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS ) + defined( gsl_CONFIG_CONTRACT_VIOLATION_TRAPS ) + defined( gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER ) +# error only one of gsl_CONFIG_CONTRACT_VIOLATION_THROWS, gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES, gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS, gsl_CONFIG_CONTRACT_VIOLATION_TRAPS, and gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER may be defined +#endif +#if 1 < defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS ) + defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS ) + defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER ) +# error only one of gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS, gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS, and gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER may be defined +#endif +#if 1 < defined( gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME ) + defined( gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE ) +# error only one of gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME and gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE may be defined +#endif +#if 1 < defined( gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME ) + defined( gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE ) +# error only one of gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME and gsl_CONFIG_UNENFORCED_DEVICE_CONTRACTS_ELIDE may be defined +#endif + +#if 0 == defined( gsl_CONFIG_CONTRACT_CHECKING_AUDIT ) + defined( gsl_CONFIG_CONTRACT_CHECKING_ON ) + defined( gsl_CONFIG_CONTRACT_CHECKING_OFF ) +// select default +# define gsl_CONFIG_CONTRACT_CHECKING_ON +#endif +#if 0 == defined( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT ) + defined( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON ) + defined( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF ) +// select default +# if defined( gsl_CONFIG_CONTRACT_CHECKING_AUDIT ) +# define gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT +# elif defined( gsl_CONFIG_CONTRACT_CHECKING_OFF ) +# define gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF +# else +# define gsl_CONFIG_DEVICE_CONTRACT_CHECKING_ON +# endif +#endif +#if 0 == defined( gsl_CONFIG_CONTRACT_VIOLATION_THROWS ) + defined( gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES ) + defined( gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS ) + defined( gsl_CONFIG_CONTRACT_VIOLATION_TRAPS ) + defined( gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER ) +// select default +# define gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES +#endif +#if 0 == defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS ) + defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS ) + defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER ) +// select default +# if defined( gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER ) +# define gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER +# elif defined( gsl_CONFIG_CONTRACT_VIOLATION_TRAPS ) +# define gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS +# else +# define gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS +# endif +#endif +#if 0 == defined( gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME ) + defined( gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE ) +// select default +# define gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE +#endif +#if 0 == defined( gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME ) + defined( gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE ) +// select default +# if defined( gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME ) +# define gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME +# else +# define gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE +# endif +#endif + +// C++ language version detection (C++23 is speculative): +// Note: VC14.0/1900 (VS2015) lacks too much from C++14. + +#ifndef gsl_CPLUSPLUS +# if defined(_MSVC_LANG ) && !defined(__clang__) +# define gsl_CPLUSPLUS (_MSC_VER == 1900 ? 201103L : _MSVC_LANG ) +# else +# define gsl_CPLUSPLUS __cplusplus +# endif +#endif + +// C++ standard library version: + +#ifndef gsl_CPLUSPLUS_STDLIB +# define gsl_CPLUSPLUS_STDLIB gsl_CPLUSPLUS +#endif + +#define gsl_CPP98_OR_GREATER ( gsl_CPLUSPLUS >= 199711L ) +#define gsl_CPP11_OR_GREATER ( gsl_CPLUSPLUS >= 201103L ) +#define gsl_CPP14_OR_GREATER ( gsl_CPLUSPLUS >= 201402L ) +#define gsl_CPP17_OR_GREATER ( gsl_CPLUSPLUS >= 201703L ) +#define gsl_CPP20_OR_GREATER ( gsl_CPLUSPLUS >= 202002L ) +#define gsl_CPP23_OR_GREATER ( gsl_CPLUSPLUS > 202002L ) // tentative + +// C++ language version (represent 98 as 3): + +#define gsl_CPLUSPLUS_V ( gsl_CPLUSPLUS / 100 - (gsl_CPLUSPLUS > 200000 ? 2000 : 1994) ) + +// half-open range [lo..hi): +#define gsl_BETWEEN( v, lo, hi ) ( (lo) <= (v) && (v) < (hi) ) + +// Compiler versions: + +// MSVC++ 6.0 _MSC_VER == 1200 gsl_COMPILER_MSVC_VERSION == 60 (Visual Studio 6.0) +// MSVC++ 7.0 _MSC_VER == 1300 gsl_COMPILER_MSVC_VERSION == 70 (Visual Studio .NET 2002) +// MSVC++ 7.1 _MSC_VER == 1310 gsl_COMPILER_MSVC_VERSION == 71 (Visual Studio .NET 2003) +// MSVC++ 8.0 _MSC_VER == 1400 gsl_COMPILER_MSVC_VERSION == 80 (Visual Studio 2005) +// MSVC++ 9.0 _MSC_VER == 1500 gsl_COMPILER_MSVC_VERSION == 90 (Visual Studio 2008) +// MSVC++ 10.0 _MSC_VER == 1600 gsl_COMPILER_MSVC_VERSION == 100 (Visual Studio 2010) +// MSVC++ 11.0 _MSC_VER == 1700 gsl_COMPILER_MSVC_VERSION == 110 (Visual Studio 2012) +// MSVC++ 12.0 _MSC_VER == 1800 gsl_COMPILER_MSVC_VERSION == 120 (Visual Studio 2013) +// MSVC++ 14.0 _MSC_VER == 1900 gsl_COMPILER_MSVC_VERSION == 140 (Visual Studio 2015) +// MSVC++ 14.1 _MSC_VER >= 1910 gsl_COMPILER_MSVC_VERSION == 141 (Visual Studio 2017) +// MSVC++ 14.2 _MSC_VER >= 1920 gsl_COMPILER_MSVC_VERSION == 142 (Visual Studio 2019) +// MSVC++ 14.3 _MSC_VER >= 1930 gsl_COMPILER_MSVC_VERSION == 143 (Visual Studio 2022) + +#if defined( _MSC_VER ) && ! defined( __clang__ ) +# define gsl_COMPILER_MSVC_VER (_MSC_VER ) +# define gsl_COMPILER_MSVC_VERSION (_MSC_VER / 10 - 10 * ( 5 + (_MSC_VER < 1900 ) ) ) +# define gsl_COMPILER_MSVC_VERSION_FULL (_MSC_VER - 100 * ( 5 + (_MSC_VER < 1900 ) ) ) +#else +# define gsl_COMPILER_MSVC_VER 0 +# define gsl_COMPILER_MSVC_VERSION 0 +# define gsl_COMPILER_MSVC_VERSION_FULL 0 +#endif + +#define gsl_COMPILER_VERSION( major, minor, patch ) ( 10 * ( 10 * (major) + (minor) ) + (patch) ) + +// AppleClang 7.0.0 __apple_build_version__ == 7000172 gsl_COMPILER_APPLECLANG_VERSION == 700 (Xcode 7.0, 7.0.1) (LLVM 3.7.0) +// AppleClang 7.0.0 __apple_build_version__ == 7000176 gsl_COMPILER_APPLECLANG_VERSION == 700 (Xcode 7.1) (LLVM 3.7.0) +// AppleClang 7.0.2 __apple_build_version__ == 7000181 gsl_COMPILER_APPLECLANG_VERSION == 702 (Xcode 7.2, 7.2.1) (LLVM 3.7.0) +// AppleClang 7.3.0 __apple_build_version__ == 7030029 gsl_COMPILER_APPLECLANG_VERSION == 730 (Xcode 7.3) (LLVM 3.8.0) +// AppleClang 7.3.0 __apple_build_version__ == 7030031 gsl_COMPILER_APPLECLANG_VERSION == 730 (Xcode 7.3.1) (LLVM 3.8.0) +// AppleClang 8.0.0 __apple_build_version__ == 8000038 gsl_COMPILER_APPLECLANG_VERSION == 800 (Xcode 8.0) (LLVM 3.9.0) +// AppleClang 8.0.0 __apple_build_version__ == 8000042 gsl_COMPILER_APPLECLANG_VERSION == 800 (Xcode 8.1, 8.2, 8.2.1) (LLVM 3.9.0) +// AppleClang 8.1.0 __apple_build_version__ == 8020038 gsl_COMPILER_APPLECLANG_VERSION == 810 (Xcode 8.3) (LLVM 3.9.0) +// AppleClang 8.1.0 __apple_build_version__ == 8020041 gsl_COMPILER_APPLECLANG_VERSION == 810 (Xcode 8.3.1) (LLVM 3.9.0) +// AppleClang 8.1.0 __apple_build_version__ == 8020042 gsl_COMPILER_APPLECLANG_VERSION == 810 (Xcode 8.3.2, 8.3.3) (LLVM 3.9.0) +// AppleClang 9.0.0 __apple_build_version__ == 9000037 gsl_COMPILER_APPLECLANG_VERSION == 900 (Xcode 9.0) (LLVM 4.0.0) +// AppleClang 9.0.0 __apple_build_version__ == 9000038 gsl_COMPILER_APPLECLANG_VERSION == 900 (Xcode 9.1) (LLVM 4.0.0) +// AppleClang 9.0.0 __apple_build_version__ == 9000039 gsl_COMPILER_APPLECLANG_VERSION == 900 (Xcode 9.2) (LLVM 4.0.0) +// AppleClang 9.1.0 __apple_build_version__ == 9020039 gsl_COMPILER_APPLECLANG_VERSION == 910 (Xcode 9.3, 9.3.1) (LLVM 5.0.2) +// AppleClang 9.1.0 __apple_build_version__ == 9020039 gsl_COMPILER_APPLECLANG_VERSION == 910 (Xcode 9.4, 9.4.1) (LLVM 5.0.2) +// AppleClang 10.0.0 __apple_build_version__ == 10001145 gsl_COMPILER_APPLECLANG_VERSION == 1000 (Xcode 10.0, 10.1) (LLVM 6.0.1) +// AppleClang 10.0.1 __apple_build_version__ == 10010046 gsl_COMPILER_APPLECLANG_VERSION == 1001 (Xcode 10.2, 10.2.1, 10.3) (LLVM 7.0.0) +// AppleClang 11.0.0 __apple_build_version__ == 11000033 gsl_COMPILER_APPLECLANG_VERSION == 1100 (Xcode 11.1, 11.2, 11.3, 11.3.1) (LLVM 8.0.0) +// AppleClang 11.0.3 __apple_build_version__ == 11030032 gsl_COMPILER_APPLECLANG_VERSION == 1103 (Xcode 11.4, 11.4.1, 11.5, 11.6) (LLVM 9.0.0) +// AppleClang 12.0.0 __apple_build_version__ == 12000032 gsl_COMPILER_APPLECLANG_VERSION == 1200 (Xcode 12.0–12.4) (LLVM 10.0.0) +// AppleClang 12.0.5 __apple_build_version__ == 12050022 gsl_COMPILER_APPLECLANG_VERSION == 1205 (Xcode 12.5) (LLVM 11.1.0) +// AppleClang 13.0.0 __apple_build_version__ == 13000029 gsl_COMPILER_APPLECLANG_VERSION == 1300 (Xcode 13.0–13.2.1) (LLVM 12.0.0) +// AppleClang 13.1.6 __apple_build_version__ == 13160021 gsl_COMPILER_APPLECLANG_VERSION == 1316 (Xcode 13.3–13.4.1) (LLVM 13.0.0) +// AppleClang 14.0.0 __apple_build_version__ == 14000029 gsl_COMPILER_APPLECLANG_VERSION == 1400 (Xcode 14.0–14.2) (LLVM 14.0.0) +// AppleClang 14.0.3 __apple_build_version__ == 14030022 gsl_COMPILER_APPLECLANG_VERSION == 1403 (Xcode 14.3) (LLVM 15.0.0) + +#if defined( __apple_build_version__ ) +# define gsl_COMPILER_APPLECLANG_VERSION gsl_COMPILER_VERSION( __clang_major__, __clang_minor__, __clang_patchlevel__ ) +# define gsl_COMPILER_CLANG_VERSION 0 +#elif defined( __clang__ ) +# define gsl_COMPILER_APPLECLANG_VERSION 0 +# define gsl_COMPILER_CLANG_VERSION gsl_COMPILER_VERSION( __clang_major__, __clang_minor__, __clang_patchlevel__ ) +#else +# define gsl_COMPILER_APPLECLANG_VERSION 0 +# define gsl_COMPILER_CLANG_VERSION 0 +#endif + +#if defined( __GNUC__ ) && ! defined( __clang__ ) && ! defined( __NVCOMPILER ) +# define gsl_COMPILER_GNUC_VERSION gsl_COMPILER_VERSION( __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ ) +#else +# define gsl_COMPILER_GNUC_VERSION 0 +#endif + +#if defined( __NVCC__ ) +# define gsl_COMPILER_NVCC_VERSION ( __CUDACC_VER_MAJOR__ * 10 + __CUDACC_VER_MINOR__ ) +#else +# define gsl_COMPILER_NVCC_VERSION 0 +#endif + +// NVHPC 21.2 gsl_COMPILER_NVHPC_VERSION == 2120 +#if defined( __NVCOMPILER ) +# define gsl_COMPILER_NVHPC_VERSION gsl_COMPILER_VERSION( __NVCOMPILER_MAJOR__, __NVCOMPILER_MINOR__, __NVCOMPILER_PATCHLEVEL__ ) +#else +# define gsl_COMPILER_NVHPC_VERSION 0 +#endif + +#if defined( __ARMCC_VERSION ) +# define gsl_COMPILER_ARMCC_VERSION ( __ARMCC_VERSION / 10000 ) +# define gsl_COMPILER_ARMCC_VERSION_FULL __ARMCC_VERSION +#else +# define gsl_COMPILER_ARMCC_VERSION 0 +# define gsl_COMPILER_ARMCC_VERSION_FULL 0 +#endif + +// Compiler non-strict aliasing: + +#if defined(__clang__) || defined(__GNUC__) +# define gsl_may_alias __attribute__((__may_alias__)) +#else +# define gsl_may_alias +#endif + +// Presence of gsl, language and library features: + +#define gsl_IN_STD( v ) ( ((v) == 98 ? 3 : (v)) >= gsl_CPLUSPLUS_V ) + +#define gsl_DEPRECATE_TO_LEVEL( level ) ( level <= gsl_CONFIG_DEPRECATE_TO_LEVEL ) +#define gsl_FEATURE_TO_STD( feature ) gsl_IN_STD( gsl_FEATURE( feature##_TO_STD ) ) +#define gsl_FEATURE( feature ) gsl_EVALF_( gsl_FEATURE_##feature##_ ) +#define gsl_CONFIG( feature ) gsl_EVALF_( gsl_CONFIG_##feature##_ ) +#define gsl_HAVE( feature ) gsl_EVALF_( gsl_HAVE_##feature##_ ) + +// Presence of wide character support: + +#if defined(__DJGPP__) || (defined(_LIBCPP_VERSION) && defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)) +# define gsl_HAVE_WCHAR 0 +#else +# define gsl_HAVE_WCHAR 1 +#endif +#define gsl_HAVE_WCHAR_() gsl_HAVE_WCHAR + +// Compiling device code: + +#if defined( __CUDACC__ ) && defined( __CUDA_ARCH__ ) +# define gsl_DEVICE_CODE 1 +#else +# define gsl_DEVICE_CODE 0 +#endif + + +// Presence of language & library features: + +#if gsl_COMPILER_CLANG_VERSION || gsl_COMPILER_APPLECLANG_VERSION +# ifdef __OBJC__ + // There are a bunch of inconsistencies about __EXCEPTIONS and __has_feature(cxx_exceptions) in Clang 3.4/3.5/3.6. + // We're interested in C++ exceptions, which can be checked by __has_feature(cxx_exceptions) in 3.5+. + // In pre-3.5, __has_feature(cxx_exceptions) can be true if ObjC exceptions are enabled, but C++ exceptions are disabled. + // The recommended way to check is `__EXCEPTIONS && __has_feature(cxx_exceptions)`. + // See https://releases.llvm.org/3.6.0/tools/clang/docs/ReleaseNotes.html#the-exceptions-macro + // Note: this is only relevant in Objective-C++, thus the ifdef. +# if __EXCEPTIONS && __has_feature(cxx_exceptions) +# define gsl_HAVE_EXCEPTIONS 1 +# else +# define gsl_HAVE_EXCEPTIONS 0 +# endif // __EXCEPTIONS && __has_feature(cxx_exceptions) +# else + // clang-cl doesn't define __EXCEPTIONS for MSVC compatibility (see https://reviews.llvm.org/D4065). + // Neither does Clang in MS-compatiblity mode. + // Let's hope no one tries to build Objective-C++ code using MS-compatibility mode or clang-cl. +# if __has_feature(cxx_exceptions) +# define gsl_HAVE_EXCEPTIONS 1 +# else +# define gsl_HAVE_EXCEPTIONS 0 +# endif +# endif +#elif defined( __GNUC__ ) +# if __GNUC__ < 5 +# ifdef __EXCEPTIONS +# define gsl_HAVE_EXCEPTIONS 1 +# else +# define gsl_HAVE_EXCEPTIONS 0 +# endif // __EXCEPTIONS +# else +# ifdef __cpp_exceptions +# define gsl_HAVE_EXCEPTIONS 1 +# else +# define gsl_HAVE_EXCEPTIONS 0 +# endif // __cpp_exceptions +# endif // __GNUC__ < 5 +#elif gsl_COMPILER_MSVC_VERSION +# ifdef _CPPUNWIND +# define gsl_HAVE_EXCEPTIONS 1 +# else +# define gsl_HAVE_EXCEPTIONS 0 +# endif // _CPPUNWIND +#else +// For all other compilers, assume exceptions are always enabled. +# define gsl_HAVE_EXCEPTIONS 1 +#endif +#define gsl_HAVE_EXCEPTIONS_() gsl_HAVE_EXCEPTIONS + +#if defined( gsl_CONFIG_CONTRACT_VIOLATION_THROWS ) && ! gsl_HAVE_EXCEPTIONS +# error Cannot use gsl_CONFIG_CONTRACT_VIOLATION_THROWS if exceptions are disabled. +#endif // defined( gsl_CONFIG_CONTRACT_VIOLATION_THROWS ) && !gsl_HAVE( EXCEPTIONS ) + +#ifdef _HAS_CPP0X +# define gsl_HAS_CPP0X _HAS_CPP0X +#else +# define gsl_HAS_CPP0X 0 +#endif + +#define gsl_CPP11_100 (gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1600) +#define gsl_CPP11_110 (gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1700) +#define gsl_CPP11_120 (gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1800) +#define gsl_CPP11_140 (gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1900) + +#define gsl_CPP14_000 (gsl_CPP14_OR_GREATER) +#define gsl_CPP14_120 (gsl_CPP14_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1800) +#define gsl_CPP14_140 (gsl_CPP14_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1900) + +#define gsl_CPP17_000 (gsl_CPP17_OR_GREATER) +#define gsl_CPP17_140 (gsl_CPP17_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1900) + +#define gsl_CPP11_140_CPP0X_90 (gsl_CPP11_140 || (gsl_COMPILER_MSVC_VER >= 1500 && gsl_HAS_CPP0X)) +#define gsl_CPP11_140_CPP0X_100 (gsl_CPP11_140 || (gsl_COMPILER_MSVC_VER >= 1600 && gsl_HAS_CPP0X)) + +// Presence of C++11 language features: + +#define gsl_HAVE_C99_PREPROCESSOR gsl_CPP11_140 +#define gsl_HAVE_AUTO gsl_CPP11_100 +#define gsl_HAVE_RVALUE_REFERENCE gsl_CPP11_100 +#define gsl_HAVE_FUNCTION_REF_QUALIFIER ( gsl_CPP11_140 && ! gsl_BETWEEN( gsl_COMPILER_GNUC_VERSION, 1, 481 ) ) +#define gsl_HAVE_ENUM_CLASS gsl_CPP11_110 +#define gsl_HAVE_ALIAS_TEMPLATE gsl_CPP11_120 +#define gsl_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG gsl_CPP11_120 +#define gsl_HAVE_EXPLICIT gsl_CPP11_120 +#define gsl_HAVE_VARIADIC_TEMPLATE gsl_CPP11_120 +#define gsl_HAVE_IS_DELETE gsl_CPP11_120 +#define gsl_HAVE_CONSTEXPR_11 gsl_CPP11_140 +#define gsl_HAVE_IS_DEFAULT gsl_CPP11_140 +#define gsl_HAVE_NOEXCEPT gsl_CPP11_140 +#define gsl_HAVE_NORETURN ( gsl_CPP11_140 && ! gsl_BETWEEN( gsl_COMPILER_GNUC_VERSION, 1, 480 ) ) +#define gsl_HAVE_EXPRESSION_SFINAE gsl_CPP11_140 +#define gsl_HAVE_OVERRIDE_FINAL gsl_CPP11_110 + +#define gsl_HAVE_C99_PREPROCESSOR_() gsl_HAVE_C99_PREPROCESSOR +#define gsl_HAVE_AUTO_() gsl_HAVE_AUTO +#define gsl_HAVE_RVALUE_REFERENCE_() gsl_HAVE_RVALUE_REFERENCE +#define gsl_HAVE_FUNCTION_REF_QUALIFIER_() gsl_HAVE_FUNCTION_REF_QUALIFIER +#define gsl_HAVE_ENUM_CLASS_() gsl_HAVE_ENUM_CLASS +#define gsl_HAVE_ALIAS_TEMPLATE_() gsl_HAVE_ALIAS_TEMPLATE +#define gsl_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG_() gsl_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG +#define gsl_HAVE_EXPLICIT_() gsl_HAVE_EXPLICIT +#define gsl_HAVE_VARIADIC_TEMPLATE_() gsl_HAVE_VARIADIC_TEMPLATE +#define gsl_HAVE_IS_DELETE_() gsl_HAVE_IS_DELETE +#define gsl_HAVE_CONSTEXPR_11_() gsl_HAVE_CONSTEXPR_11 +#define gsl_HAVE_IS_DEFAULT_() gsl_HAVE_IS_DEFAULT +#define gsl_HAVE_NOEXCEPT_() gsl_HAVE_NOEXCEPT +#define gsl_HAVE_NORETURN_() gsl_HAVE_NORETURN +#define gsl_HAVE_EXPRESSION_SFINAE_() gsl_HAVE_EXPRESSION_SFINAE +#define gsl_HAVE_OVERRIDE_FINAL_() gsl_HAVE_OVERRIDE_FINAL + +// Presence of C++14 language features: + +#define gsl_HAVE_CONSTEXPR_14 ( gsl_CPP14_000 && ! gsl_BETWEEN( gsl_COMPILER_GNUC_VERSION, 1, 600 ) ) +#define gsl_HAVE_DECLTYPE_AUTO gsl_CPP14_140 +#define gsl_HAVE_DEPRECATED ( gsl_CPP14_140 && ! gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 1, 142 ) ) + +#define gsl_HAVE_CONSTEXPR_14_() gsl_HAVE_CONSTEXPR_14 +#define gsl_HAVE_DECLTYPE_AUTO_() gsl_HAVE_DECLTYPE_AUTO +#define gsl_HAVE_DEPRECATED_() gsl_HAVE_DEPRECATED + +// Presence of C++17 language features: +// MSVC: template parameter deduction guides since Visual Studio 2017 v15.7 + +#define gsl_HAVE_ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE gsl_CPP17_000 +#define gsl_HAVE_DEDUCTION_GUIDES ( gsl_CPP17_000 && ! gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION_FULL, 1, 1414 ) ) +#define gsl_HAVE_NODISCARD gsl_CPP17_000 +#define gsl_HAVE_CONSTEXPR_17 gsl_CPP17_OR_GREATER + +#define gsl_HAVE_ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE_() gsl_HAVE_ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE +#define gsl_HAVE_DEDUCTION_GUIDES_() gsl_HAVE_DEDUCTION_GUIDES +#define gsl_HAVE_NODISCARD_() gsl_HAVE_NODISCARD +#define gsl_HAVE_CONSTEXPR_17_() gsl_HAVE_CONSTEXPR_17 + +// Presence of C++20 language features: + +#define gsl_HAVE_CONSTEXPR_20 gsl_CPP20_OR_GREATER + +#define gsl_HAVE_CONSTEXPR_20_() gsl_HAVE_CONSTEXPR_20 + +// Presence of C++23 language features: + +#define gsl_HAVE_CONSTEXPR_23 gsl_CPP23_OR_GREATER + +#define gsl_HAVE_CONSTEXPR_23_() gsl_HAVE_CONSTEXPR_23 + +// Presence of C++ library features: + +#if gsl_BETWEEN( gsl_COMPILER_ARMCC_VERSION, 1, 600 ) +// Some versions of the ARM compiler apparently ship without a C++11 standard library despite having some C++11 support. +# define gsl_STDLIB_CPP98_OR_GREATER gsl_CPP98_OR_GREATER +# define gsl_STDLIB_CPP11_OR_GREATER 0 +# define gsl_STDLIB_CPP14_OR_GREATER 0 +# define gsl_STDLIB_CPP17_OR_GREATER 0 +# define gsl_STDLIB_CPP20_OR_GREATER 0 +# define gsl_STDLIB_CPP23_OR_GREATER 0 +#else +# define gsl_STDLIB_CPP98_OR_GREATER gsl_CPP98_OR_GREATER +# define gsl_STDLIB_CPP11_OR_GREATER gsl_CPP11_OR_GREATER +# define gsl_STDLIB_CPP14_OR_GREATER gsl_CPP14_OR_GREATER +# define gsl_STDLIB_CPP17_OR_GREATER gsl_CPP17_OR_GREATER +# define gsl_STDLIB_CPP20_OR_GREATER gsl_CPP20_OR_GREATER +# define gsl_STDLIB_CPP23_OR_GREATER gsl_CPP23_OR_GREATER +#endif + +#define gsl_STDLIB_CPP11_100 (gsl_STDLIB_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1600) +#define gsl_STDLIB_CPP11_110 (gsl_STDLIB_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1700) +#define gsl_STDLIB_CPP11_120 (gsl_STDLIB_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1800) +#define gsl_STDLIB_CPP11_140 (gsl_STDLIB_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1900) + +#define gsl_STDLIB_CPP14_000 (gsl_STDLIB_CPP14_OR_GREATER) +#define gsl_STDLIB_CPP14_120 (gsl_STDLIB_CPP14_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1800) +#define gsl_STDLIB_CPP14_140 (gsl_STDLIB_CPP14_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1900) + +#define gsl_STDLIB_CPP17_000 (gsl_STDLIB_CPP17_OR_GREATER) +#define gsl_STDLIB_CPP17_140 (gsl_STDLIB_CPP17_OR_GREATER || gsl_COMPILER_MSVC_VER >= 1900) + +#define gsl_STDLIB_CPP11_140_CPP0X_90 (gsl_STDLIB_CPP11_140 || (gsl_COMPILER_MSVC_VER >= 1500 && gsl_HAS_CPP0X)) +#define gsl_STDLIB_CPP11_140_CPP0X_100 (gsl_STDLIB_CPP11_140 || (gsl_COMPILER_MSVC_VER >= 1600 && gsl_HAS_CPP0X)) + +#define gsl_HAVE_ADDRESSOF gsl_STDLIB_CPP17_000 +#define gsl_HAVE_ARRAY gsl_STDLIB_CPP11_110 +#define gsl_HAVE_TYPE_TRAITS gsl_STDLIB_CPP11_110 +#define gsl_HAVE_TR1_TYPE_TRAITS gsl_STDLIB_CPP11_110 +#define gsl_HAVE_CONTAINER_DATA_METHOD gsl_STDLIB_CPP11_140_CPP0X_90 +#define gsl_HAVE_STD_DATA gsl_STDLIB_CPP17_000 +#ifdef __cpp_lib_ssize +# define gsl_HAVE_STD_SSIZE 1 +#else +# define gsl_HAVE_STD_SSIZE ( gsl_COMPILER_GNUC_VERSION >= 1000 && __cplusplus > 201703L ) +#endif +#define gsl_HAVE_HASH gsl_STDLIB_CPP11_120 +#define gsl_HAVE_SIZED_TYPES gsl_STDLIB_CPP11_140 +#define gsl_HAVE_MAKE_SHARED gsl_STDLIB_CPP11_140_CPP0X_100 +#define gsl_HAVE_SHARED_PTR gsl_STDLIB_CPP11_140_CPP0X_100 +#define gsl_HAVE_UNIQUE_PTR gsl_STDLIB_CPP11_140_CPP0X_100 +#define gsl_HAVE_MAKE_UNIQUE gsl_STDLIB_CPP14_120 +#define gsl_HAVE_MOVE_FORWARD gsl_STDLIB_CPP11_100 +#define gsl_HAVE_NULLPTR gsl_STDLIB_CPP11_100 +#define gsl_HAVE_UNCAUGHT_EXCEPTIONS gsl_STDLIB_CPP17_140 +#define gsl_HAVE_ADD_CONST gsl_HAVE_TYPE_TRAITS +#define gsl_HAVE_INITIALIZER_LIST gsl_STDLIB_CPP11_120 +#define gsl_HAVE_INTEGRAL_CONSTANT gsl_HAVE_TYPE_TRAITS +#define gsl_HAVE_REMOVE_CONST gsl_HAVE_TYPE_TRAITS +#define gsl_HAVE_REMOVE_REFERENCE gsl_HAVE_TYPE_TRAITS +#define gsl_HAVE_REMOVE_CVREF gsl_STDLIB_CPP20_OR_GREATER +#define gsl_HAVE_TR1_ADD_CONST gsl_HAVE_TR1_TYPE_TRAITS +#define gsl_HAVE_TR1_INTEGRAL_CONSTANT gsl_HAVE_TR1_TYPE_TRAITS +#define gsl_HAVE_TR1_REMOVE_CONST gsl_HAVE_TR1_TYPE_TRAITS +#define gsl_HAVE_TR1_REMOVE_REFERENCE gsl_HAVE_TR1_TYPE_TRAITS + +#define gsl_HAVE_ADDRESSOF_() gsl_HAVE_ADDRESSOF +#define gsl_HAVE_ARRAY_() gsl_HAVE_ARRAY +#define gsl_HAVE_TYPE_TRAITS_() gsl_HAVE_TYPE_TRAITS +#define gsl_HAVE_TR1_TYPE_TRAITS_() gsl_HAVE_TR1_TYPE_TRAITS +#define gsl_HAVE_CONTAINER_DATA_METHOD_() gsl_HAVE_CONTAINER_DATA_METHOD +#define gsl_HAVE_HASH_() gsl_HAVE_HASH +#define gsl_HAVE_STD_DATA_() gsl_HAVE_STD_DATA +#define gsl_HAVE_STD_SSIZE_() gsl_HAVE_STD_SSIZE +#define gsl_HAVE_SIZED_TYPES_() gsl_HAVE_SIZED_TYPES +#define gsl_HAVE_MAKE_SHARED_() gsl_HAVE_MAKE_SHARED +#define gsl_HAVE_MOVE_FORWARD_() gsl_HAVE_MOVE_FORWARD +#define gsl_HAVE_NULLPTR_() gsl_HAVE_NULLPTR // It's a language feature but needs library support, so we list it as a library feature. +#define gsl_HAVE_SHARED_PTR_() gsl_HAVE_SHARED_PTR +#define gsl_HAVE_UNIQUE_PTR_() gsl_HAVE_UNIQUE_PTR +#define gsl_HAVE_MAKE_UNIQUE_() gsl_HAVE_MAKE_UNIQUE +#define gsl_HAVE_UNCAUGHT_EXCEPTIONS_() gsl_HAVE_UNCAUGHT_EXCEPTIONS +#define gsl_HAVE_ADD_CONST_() gsl_HAVE_ADD_CONST +#define gsl_HAVE_INITIALIZER_LIST_() gsl_HAVE_INITIALIZER_LIST // It's a language feature but needs library support, so we list it as a library feature. +#define gsl_HAVE_INTEGRAL_CONSTANT_() gsl_HAVE_INTEGRAL_CONSTANT +#define gsl_HAVE_REMOVE_CONST_() gsl_HAVE_REMOVE_CONST +#define gsl_HAVE_REMOVE_REFERENCE_() gsl_HAVE_REMOVE_REFERENCE +#define gsl_HAVE_REMOVE_CVREF_() gsl_HAVE_REMOVE_CVREF +#define gsl_HAVE_TR1_ADD_CONST_() gsl_HAVE_TR1_ADD_CONST +#define gsl_HAVE_TR1_INTEGRAL_CONSTANT_() gsl_HAVE_TR1_INTEGRAL_CONSTANT +#define gsl_HAVE_TR1_REMOVE_CONST_() gsl_HAVE_TR1_REMOVE_CONST +#define gsl_HAVE_TR1_REMOVE_REFERENCE_() gsl_HAVE_TR1_REMOVE_REFERENCE + +// C++ feature usage: + +#if gsl_HAVE( ADDRESSOF ) +# define gsl_ADDRESSOF(x) std::addressof(x) +#else +# define gsl_ADDRESSOF(x) (&x) +#endif -#define gsl_lite_VERSION "0.0.0" +#if gsl_HAVE( CONSTEXPR_11 ) +# define gsl_constexpr constexpr +#else +# define gsl_constexpr /*constexpr*/ +#endif + +#if gsl_HAVE( CONSTEXPR_14 ) +# define gsl_constexpr14 constexpr +#else +# define gsl_constexpr14 /*constexpr*/ +#endif + +#if gsl_HAVE( CONSTEXPR_17 ) +# define gsl_constexpr17 constexpr +#else +# define gsl_constexpr17 /*constexpr*/ +#endif -// Configuration: +#if gsl_HAVE( CONSTEXPR_20 ) +# define gsl_constexpr20 constexpr +#else +# define gsl_constexpr20 /*constexpr*/ +#endif + +#if gsl_HAVE( CONSTEXPR_23 ) +# define gsl_constexpr23 constexpr +#else +# define gsl_constexpr23 /*constexpr*/ +#endif + +#if gsl_HAVE( EXPLICIT ) +# define gsl_explicit explicit +#else +# define gsl_explicit /*explicit*/ +#endif -#ifndef gsl_FEATURE_HAVE_IMPLICIT_MACRO -# define gsl_FEATURE_HAVE_IMPLICIT_MACRO 1 +#if gsl_FEATURE( IMPLICIT_MACRO ) +# define implicit /*implicit*/ #endif -#ifndef gsl_FEATURE_HAVE_OWNER_MACRO -# define gsl_FEATURE_HAVE_OWNER_MACRO 1 -#endif +#if gsl_HAVE( IS_DELETE ) +# define gsl_is_delete = delete +#else +# define gsl_is_delete +#endif + +#if gsl_HAVE( IS_DELETE ) +# define gsl_is_delete_access public +#else +# define gsl_is_delete_access private +#endif + +#if gsl_HAVE( NOEXCEPT ) +# define gsl_noexcept noexcept +# define gsl_noexcept_if( expr ) noexcept( expr ) +#else +# define gsl_noexcept throw() +# define gsl_noexcept_if( expr ) /*noexcept( expr )*/ +#endif +#if defined( gsl_TESTING_ ) +# define gsl_noexcept_not_testing +#else +# define gsl_noexcept_not_testing gsl_noexcept +#endif + +#if gsl_HAVE( NULLPTR ) +# define gsl_nullptr nullptr +#else +# define gsl_nullptr NULL +#endif + +#if gsl_HAVE( NODISCARD ) +# define gsl_NODISCARD [[nodiscard]] +#else +# define gsl_NODISCARD +#endif + +#if gsl_HAVE( NORETURN ) +# define gsl_NORETURN [[noreturn]] +#elif defined(_MSC_VER) +# define gsl_NORETURN __declspec(noreturn) +#elif defined( __GNUC__ ) || gsl_COMPILER_ARMCC_VERSION +# define gsl_NORETURN __attribute__((noreturn)) +#else +# define gsl_NORETURN +#endif + +#if gsl_HAVE( DEPRECATED ) && ! defined( gsl_TESTING_ ) +# define gsl_DEPRECATED [[deprecated]] +# define gsl_DEPRECATED_MSG( msg ) [[deprecated( msg )]] +#else +# define gsl_DEPRECATED +# define gsl_DEPRECATED_MSG( msg ) +#endif + +#if gsl_HAVE( C99_PREPROCESSOR ) +# if gsl_CPP20_OR_GREATER +# define gsl_CONSTRAINT(...) __VA_ARGS__ +# else +# define gsl_CONSTRAINT(...) typename +# endif +#endif + +#if gsl_HAVE( TYPE_TRAITS ) +# define gsl_STATIC_ASSERT_( cond, msg ) static_assert( cond, msg ) +#else +# define gsl_STATIC_ASSERT_( cond, msg ) ( ( void )sizeof( char[1 - 2*!!( cond ) ] ) ) +#endif + +#if _MSC_VER >= 1900 // Visual Studio 2015 and newer, or Clang emulating a corresponding MSVC +# define gsl_EMPTY_BASES_ __declspec(empty_bases) +#else +# define gsl_EMPTY_BASES_ +#endif + +#if gsl_HAVE( TYPE_TRAITS ) + +#define gsl_DEFINE_ENUM_BITMASK_OPERATORS_( ENUM ) \ + gsl_NODISCARD gsl_api inline gsl_constexpr ENUM \ + operator~( ENUM val ) gsl_noexcept \ + { \ + typedef typename ::gsl::std11::underlying_type::type U; \ + return ENUM( ~U( val ) ); \ + } \ + gsl_NODISCARD gsl_api inline gsl_constexpr ENUM \ + operator|( ENUM lhs, ENUM rhs ) gsl_noexcept \ + { \ + typedef typename ::gsl::std11::underlying_type::type U; \ + return ENUM( U( lhs ) | U( rhs ) ); \ + } \ + gsl_NODISCARD gsl_api inline gsl_constexpr ENUM \ + operator&( ENUM lhs, ENUM rhs ) gsl_noexcept \ + { \ + typedef typename ::gsl::std11::underlying_type::type U; \ + return ENUM( U( lhs ) & U( rhs ) ); \ + } \ + gsl_NODISCARD gsl_api inline gsl_constexpr ENUM \ + operator^( ENUM lhs, ENUM rhs ) gsl_noexcept \ + { \ + typedef typename ::gsl::std11::underlying_type::type U; \ + return ENUM( U( lhs ) ^ U( rhs ) ); \ + } \ + gsl_api inline gsl_constexpr14 ENUM & \ + operator|=( ENUM & lhs, ENUM rhs ) gsl_noexcept \ + { \ + return lhs = lhs | rhs; \ + } \ + gsl_api inline gsl_constexpr14 ENUM & \ + operator&=( ENUM & lhs, ENUM rhs ) gsl_noexcept \ + { \ + return lhs = lhs & rhs; \ + } \ + gsl_api inline gsl_constexpr14 ENUM & \ + operator^=( ENUM & lhs, ENUM rhs ) gsl_noexcept \ + { \ + return lhs = lhs ^ rhs; \ + } + +#define gsl_DEFINE_ENUM_RELATIONAL_OPERATORS_( ENUM ) \ + gsl_NODISCARD gsl_api inline gsl_constexpr bool \ + operator<( ENUM lhs, ENUM rhs ) gsl_noexcept \ + { \ + typedef typename ::gsl::std11::underlying_type::type U; \ + return U( lhs ) < U( rhs ); \ + } \ + gsl_NODISCARD gsl_api inline gsl_constexpr bool \ + operator>( ENUM lhs, ENUM rhs ) gsl_noexcept \ + { \ + typedef typename ::gsl::std11::underlying_type::type U; \ + return U( lhs ) > U( rhs ); \ + } \ + gsl_NODISCARD gsl_api inline gsl_constexpr bool \ + operator<=( ENUM lhs, ENUM rhs ) gsl_noexcept \ + { \ + typedef typename ::gsl::std11::underlying_type::type U; \ + return U( lhs ) <= U( rhs ); \ + } \ + gsl_NODISCARD gsl_api inline gsl_constexpr bool \ + operator>=( ENUM lhs, ENUM rhs ) gsl_noexcept \ + { \ + typedef typename ::gsl::std11::underlying_type::type U; \ + return U( lhs ) >= U( rhs ); \ + } + + // + // Defines bitmask operators `|`, `&`, `^`, `~`, `|=`, `&=`, and `^=` for the given enum type. + // + // enum class Vegetables { tomato = 0b001, onion = 0b010, eggplant = 0b100 }; + // gsl_DEFINE_ENUM_BITMASK_OPERATORS( Vegetables ) + // +#define gsl_DEFINE_ENUM_BITMASK_OPERATORS( ENUM ) gsl_DEFINE_ENUM_BITMASK_OPERATORS_( ENUM ) + + // + // Defines relational operators `<`, `>`, `<=`, `>=` for the given enum type. + // + // enum class OperatorPrecedence { additive = 0, multiplicative = 1, power = 2 }; + // gsl_DEFINE_ENUM_RELATIONAL_OPERATORS( OperatorPrecedence ) + // +#define gsl_DEFINE_ENUM_RELATIONAL_OPERATORS( ENUM ) gsl_DEFINE_ENUM_RELATIONAL_OPERATORS_( ENUM ) + +#endif // gsl_HAVE( TYPE_TRAITS ) + +#define gsl_DIMENSION_OF( a ) ( sizeof(a) / sizeof(0[a]) ) + + +// Method enabling (C++98, VC120 (VS2013) cannot use __VA_ARGS__) + +#if gsl_HAVE( EXPRESSION_SFINAE ) +# define gsl_TRAILING_RETURN_TYPE_(T) auto +# define gsl_RETURN_DECLTYPE_(EXPR) -> decltype( EXPR ) +#else +# define gsl_TRAILING_RETURN_TYPE_(T) T +# define gsl_RETURN_DECLTYPE_(EXPR) +#endif + +// NOTE: When using SFINAE in gsl-lite, please note that overloads of function templates must always use SFINAE with non-type default arguments +// as explained in https://en.cppreference.com/w/cpp/types/enable_if#Notes. `gsl_ENABLE_IF_()` implements graceful fallback to default +// type arguments (for compilers that don't support non-type default arguments); please verify that this is appropriate in the given +// situation, and add additional checks if necessary. +// +// Also, please note that `gsl_ENABLE_IF_()` doesn't enforce the constraint at all if no compiler/library support is available (i.e. pre-C++11). + +#if gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) +# if !gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 1, 140 ) // VS 2013 seems to have trouble with SFINAE for default non-type arguments +# define gsl_ENABLE_IF_(VA) , typename std::enable_if< ( VA ), int >::type = 0 +# else +# define gsl_ENABLE_IF_(VA) , typename = typename std::enable_if< ( VA ), ::gsl::detail::enabler >::type +# endif +#else +# define gsl_ENABLE_IF_(VA) +#endif + + +// Other features: + +#define gsl_HAVE_CONSTRAINED_SPAN_CONTAINER_CTOR ( gsl_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG && gsl_HAVE_CONTAINER_DATA_METHOD ) +#define gsl_HAVE_CONSTRAINED_SPAN_CONTAINER_CTOR_() gsl_HAVE_CONSTRAINED_SPAN_CONTAINER_CTOR + +#define gsl_HAVE_UNCONSTRAINED_SPAN_CONTAINER_CTOR ( gsl_CONFIG_ALLOWS_UNCONSTRAINED_SPAN_CONTAINER_CTOR && gsl_COMPILER_NVCC_VERSION == 0 ) +#define gsl_HAVE_UNCONSTRAINED_SPAN_CONTAINER_CTOR_() gsl_HAVE_UNCONSTRAINED_SPAN_CONTAINER_CTOR + +// GSL API (e.g. for CUDA platform): + +// Guidelines for using `gsl_api`: +// +// NVCC imposes the restriction that a function annotated `__host__ __device__` cannot call host-only or device-only functions. +// This makes `gsl_api` inappropriate for generic functions that call unknown code, e.g. the template constructors of `span<>` +// or functions like `finally()` which accept an arbitrary function object. +// It is often preferable to annotate functions only with `gsl_constexpr` or `gsl_constexpr14`. The "extended constexpr" mode +// of NVCC (currently an experimental feature) will implicitly consider constexpr functions `__host__ __device__` functions +// but tolerates calls to host-only or device-only functions. + +#ifndef gsl_api +# ifdef __CUDACC__ +# define gsl_api __host__ __device__ +# else +# define gsl_api /*gsl_api*/ +# endif +#endif + +// Additional includes: + +#if ! gsl_CPP11_OR_GREATER +# include // for swap() before C++11 +#endif // ! gsl_CPP11_OR_GREATER + +#if gsl_HAVE( ARRAY ) +# include // indirectly includes reverse_iterator<> +#endif + +#if ! gsl_HAVE( ARRAY ) +# include // for reverse_iterator<> +#endif + +#if ! gsl_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR ) || ! gsl_HAVE( AUTO ) +# include +#endif + +#if gsl_HAVE( INITIALIZER_LIST ) +# include +#endif + +#if defined( gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS ) || gsl_DEVICE_CODE +# include +#endif + +#if defined( gsl_CONFIG_CONTRACT_VIOLATION_TRAPS ) && gsl_COMPILER_MSVC_VERSION >= 110 // __fastfail() supported by VS 2012 and later +# include +#endif + +#if gsl_HAVE( ENUM_CLASS ) && ( gsl_COMPILER_ARMCC_VERSION || gsl_COMPILER_NVHPC_VERSION ) && !defined( _WIN32 ) +# include +#endif + +#if gsl_HAVE( TYPE_TRAITS ) +# include // for enable_if<>, + // add_const<>, add_pointer<>, common_type<>, make_signed<>, remove_cv<>, remove_const<>, remove_volatile<>, remove_reference<>, remove_cvref<>, remove_pointer<>, underlying_type<>, + // is_assignable<>, is_constructible<>, is_const<>, is_convertible<>, is_integral<>, is_pointer<>, is_signed<>, + // integral_constant<>, declval() +#elif gsl_HAVE( TR1_TYPE_TRAITS ) +# include // for add_const<>, remove_cv<>, remove_const<>, remove_volatile<>, remove_reference<>, integral_constant<> +#endif + +#if gsl_FEATURE( EXPERIMENTAL_RETURN_GUARD ) + +// Declare __cxa_get_globals() or equivalent in namespace gsl::detail for uncaught_exceptions(): + +# if ! gsl_HAVE( UNCAUGHT_EXCEPTIONS ) +# if defined( _MSC_VER ) // MS-STL with either MSVC or clang-cl +namespace gsl { namespace detail { extern "C" char * __cdecl _getptd(); } } +# elif gsl_COMPILER_CLANG_VERSION || gsl_COMPILER_GNUC_VERSION || gsl_COMPILER_APPLECLANG_VERSION || gsl_COMPILER_NVHPC_VERSION +# if defined( __GLIBCXX__ ) || defined( __GLIBCPP__ ) // libstdc++: prototype from cxxabi.h +# include +# elif ! defined( BOOST_CORE_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED_ ) // libc++: prototype from Boost? +# if defined( __FreeBSD__ ) || defined( __OpenBSD__ ) +namespace __cxxabiv1 { struct __cxa_eh_globals; extern "C" __cxa_eh_globals * __cxa_get_globals(); } +# else +namespace __cxxabiv1 { struct __cxa_eh_globals; extern "C" __cxa_eh_globals * __cxa_get_globals() gsl_noexcept; } +# endif +# endif + namespace gsl { namespace detail { using ::__cxxabiv1::__cxa_get_globals; } } +# endif +# endif // ! gsl_HAVE( UNCAUGHT_EXCEPTIONS ) +#endif // gsl_FEATURE( EXPERIMENTAL_RETURN_GUARD ) + + +// Warning suppression macros: + +#if gsl_COMPILER_MSVC_VERSION >= 140 && ! gsl_COMPILER_NVCC_VERSION +# define gsl_SUPPRESS_MSGSL_WARNING(expr) [[gsl::suppress(expr)]] +# define gsl_SUPPRESS_MSVC_WARNING(code, descr) __pragma(warning(suppress: code) ) +# define gsl_DISABLE_MSVC_WARNINGS(codes) __pragma(warning(push)) __pragma(warning(disable: codes)) +# define gsl_RESTORE_MSVC_WARNINGS() __pragma(warning(pop )) +#else +// TODO: define for Clang +# define gsl_SUPPRESS_MSGSL_WARNING(expr) +# define gsl_SUPPRESS_MSVC_WARNING(code, descr) +# define gsl_DISABLE_MSVC_WARNINGS(codes) +# define gsl_RESTORE_MSVC_WARNINGS() +#endif + +// Warning suppressions: + +#if gsl_COMPILER_CLANG_VERSION || gsl_COMPILER_APPLECLANG_VERSION +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wweak-vtables" // because of `fail_fast` and `narrowing_error` +#endif // gsl_COMPILER_CLANG_VERSION || gsl_COMPILER_APPLECLANG_VERSION + +#if gsl_COMPILER_GNUC_VERSION +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wuseless-cast" // we use `static_cast<>()` in several places where it is possibly redundant depending on the configuration of the library +#endif // gsl_COMPILER_GNUC_VERSION + +// Suppress the following MSVC GSL warnings: +// - C26432: gsl::c.21 : if you define or delete any default operation in the type '...', define or delete them all +// - C26410: gsl::r.32 : the parameter 'ptr' is a reference to const unique pointer, use const T* or const T& instead +// - C26415: gsl::r.30 : smart pointer parameter 'ptr' is used only to access contained pointer. Use T* or T& instead +// - C26418: gsl::r.36 : shared pointer parameter 'ptr' is not copied or moved. Use T* or T& instead +// - C26472: gsl::t.1 : don't use a static_cast for arithmetic conversions; +// use brace initialization, gsl::narrow_cast or gsl::narrow +// - C26439: gsl::f.6 : special function 'function' can be declared 'noexcept' +// - C26440: gsl::f.6 : function 'function' can be declared 'noexcept' +// - C26455: gsl::f.6 : default constructor may not throw. Declare it 'noexcept' +// - C26473: gsl::t.1 : don't cast between pointer types where the source type and the target type are the same +// - C26481: gsl::b.1 : don't use pointer arithmetic. Use span instead +// - C26482: gsl::b.2 : only index into arrays using constant expressions +// - C26446: gdl::b.4 : prefer to use gsl::at() instead of unchecked subscript operator +// - C26490: gsl::t.1 : don't use reinterpret_cast +// - C26487: gsl::l.4 : don't return a pointer '('s result)' that may be invalid +// - C26434: gsl::c.128 : function 'symbol_1' hides a non-virtual function 'symbol_2' (false positive for compiler-generated functions such as constructors) +// - C26456: gsl::c.128 : operator 'symbol_1' hides a non-virtual operator 'symbol_2' (false positive for compiler-generated operators) +// - C26457: es.48 : (void) should not be used to ignore return values, use 'std::ignore =' instead + +gsl_DISABLE_MSVC_WARNINGS( 26432 26410 26415 26418 26472 26439 26440 26455 26473 26481 26482 26446 26490 26487 26434 26456 26457 ) +#if gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 110, 140 ) // VS 2012 and 2013 +# pragma warning(disable: 4127) // conditional expression is constant +#endif // gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 110, 140 ) +#if gsl_COMPILER_MSVC_VERSION == 140 // VS 2015 +# pragma warning(disable: 4577) // 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc +#endif // gsl_COMPILER_MSVC_VERSION == 140 + +namespace gsl { + +// forward declare span<>: + +template< class T > +class span; + +// C++98 emulation: + +namespace detail { + +// We implement `equal()` and `lexicographical_compare()` here to avoid having to pull in the header. +template< class InputIt1, class InputIt2 > +bool equal( InputIt1 first1, InputIt1 last1, InputIt2 first2 ) +{ + // Implementation borrowed from https://en.cppreference.com/w/cpp/algorithm/equal. + for ( ; first1 != last1; ++first1, ++first2 ) + { + if ( ! (*first1 == *first2 ) ) return false; + } + return true; +} +template< class InputIt1, class InputIt2 > +bool lexicographical_compare( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2 ) +{ + // Implementation borrowed from https://en.cppreference.com/w/cpp/algorithm/lexicographical_compare. + for ( ; first1 != last1 && first2 != last2; ++first1, static_cast< void >( ++first2 ) ) + { + if ( *first1 < *first2 ) return true; + if ( *first2 < *first1 ) return false; + } + return first1 == last1 && first2 != last2; +} + +} // namespace detail + +// C++11 emulation: + +namespace std11 { + +#if gsl_HAVE( ADD_CONST ) + +using std::add_const; + +#elif gsl_HAVE( TR1_ADD_CONST ) + +using std::tr1::add_const; + +#else + +template< class T > struct add_const { typedef const T type; }; + +#endif // gsl_HAVE( ADD_CONST ) + +#if gsl_HAVE( REMOVE_CONST ) + +using std::remove_cv; +using std::remove_const; +using std::remove_volatile; + +#elif gsl_HAVE( TR1_REMOVE_CONST ) + +using std::tr1::remove_cv; +using std::tr1::remove_const; +using std::tr1::remove_volatile; + +#else + +template< class T > struct remove_const { typedef T type; }; +template< class T > struct remove_const { typedef T type; }; + +template< class T > struct remove_volatile { typedef T type; }; +template< class T > struct remove_volatile { typedef T type; }; + +template< class T > +struct remove_cv +{ + typedef typename remove_volatile::type>::type type; +}; + +#endif // gsl_HAVE( REMOVE_CONST ) + +#if gsl_HAVE( REMOVE_REFERENCE ) + +using std::remove_reference; + +#elif gsl_HAVE( TR1_REMOVE_REFERENCE ) + +using std::tr1::remove_reference; + +#else + +template< class T > struct remove_reference { typedef T type; }; +template< class T > struct remove_reference { typedef T type; }; +# if gsl_HAVE( RVALUE_REFERENCE ) +template< class T > struct remove_reference { typedef T type; }; +# endif + +#endif // gsl_HAVE( REMOVE_REFERENCE ) + + +#if gsl_HAVE( INTEGRAL_CONSTANT ) + +using std::integral_constant; +using std::true_type; +using std::false_type; + +#elif gsl_HAVE( TR1_INTEGRAL_CONSTANT ) + +using std::tr1::integral_constant; +using std::tr1::true_type; +using std::tr1::false_type; + +#else + +template< class T, T v > struct integral_constant { enum { value = v }; }; +typedef integral_constant< bool, true > true_type; +typedef integral_constant< bool, false > false_type; + +#endif + +#if gsl_HAVE( TYPE_TRAITS ) + +using std::underlying_type; + +#elif gsl_HAVE( TR1_TYPE_TRAITS ) + +using std::tr1::underlying_type; + +#else + +// We could try to define `underlying_type<>` for pre-C++11 here, but let's not until someone actually needs it. + +#endif + +} // namespace std11 + +// C++14 emulation: + +namespace std14 { + +#if gsl_HAVE( UNIQUE_PTR ) +# if gsl_HAVE( MAKE_UNIQUE ) + +using std::make_unique; + +# elif gsl_HAVE( VARIADIC_TEMPLATE ) + +template< class T, class... Args > +gsl_NODISCARD std::unique_ptr +make_unique( Args &&... args ) +{ +# if gsl_HAVE( TYPE_TRAITS ) + static_assert( !std::is_array::value, "make_unique() is not part of C++14" ); +# endif + return std::unique_ptr( new T( std::forward( args )... ) ); +} + +# endif // gsl_HAVE( MAKE_UNIQUE ), gsl_HAVE( VARIADIC_TEMPLATE ) +#endif // gsl_HAVE( UNIQUE_PTR ) + +} // namespace std14 + +namespace detail { + +#if gsl_HAVE( VARIADIC_TEMPLATE ) + +template < bool V0, class T0, class... Ts > struct conjunction_ { using type = T0; }; +template < class T0, class T1, class... Ts > struct conjunction_ : conjunction_ { }; +template < bool V0, class T0, class... Ts > struct disjunction_ { using type = T0; }; +template < class T0, class T1, class... Ts > struct disjunction_ : disjunction_ { }; + +#endif + +template struct dependent_false : std11::integral_constant { }; + +} // namespace detail + +// C++17 emulation: + +namespace std17 { + +template< bool v > struct bool_constant : std11::integral_constant{}; + +#if gsl_CPP11_120 + +template < class... Ts > struct conjunction; +template < > struct conjunction< > : std11::true_type { }; +template < class T0, class... Ts > struct conjunction : detail::conjunction_::type { }; +template < class... Ts > struct disjunction; +template < > struct disjunction< > : std11::false_type { }; +template < class T0, class... Ts > struct disjunction : detail::disjunction_::type { }; +template < class T > struct negation : std11::integral_constant { }; + +# if gsl_CPP14_OR_GREATER + +template < class... Ts > constexpr bool conjunction_v = conjunction::value; +template < class... Ts > constexpr bool disjunction_v = disjunction::value; +template < class T > constexpr bool negation_v = negation::value; + +# endif // gsl_CPP14_OR_GREATER + +template< class... Ts > +struct make_void { typedef void type; }; + +template< class... Ts > +using void_t = typename make_void< Ts... >::type; + +#endif // gsl_CPP11_120 + +#if gsl_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR ) + +template< class T, size_t N > +gsl_NODISCARD gsl_api inline gsl_constexpr auto +size( T const(&)[N] ) gsl_noexcept -> size_t +{ + return N; +} + +template< class C > +gsl_NODISCARD inline gsl_constexpr auto +size( C const & cont ) -> decltype( cont.size() ) +{ + return cont.size(); +} + +template< class T, size_t N > +gsl_NODISCARD gsl_api inline gsl_constexpr auto +data( T(&arr)[N] ) gsl_noexcept -> T* +{ + return &arr[0]; +} + +template< class C > +gsl_NODISCARD inline gsl_constexpr auto +data( C & cont ) -> decltype( cont.data() ) +{ + return cont.data(); +} + +template< class C > +gsl_NODISCARD inline gsl_constexpr auto +data( C const & cont ) -> decltype( cont.data() ) +{ + return cont.data(); +} + +template< class E > +gsl_NODISCARD inline gsl_constexpr auto +data( std::initializer_list il ) gsl_noexcept -> E const * +{ + return il.begin(); +} + +#endif // gsl_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR ) + +} // namespace std17 + +// C++20 emulation: + +namespace std20 { + +#if gsl_CPP11_100 + +struct identity +{ + template < class T > + gsl_constexpr T && operator ()( T && arg ) const gsl_noexcept + { + return std::forward( arg ); + } +}; + +# if gsl_HAVE( ENUM_CLASS ) +enum class endian +{ +# if defined( _WIN32 ) + little = 0, + big = 1, + native = little +# elif gsl_COMPILER_GNUC_VERSION || gsl_COMPILER_CLANG_VERSION || gsl_COMPILER_APPLECLANG_VERSION + little = __ORDER_LITTLE_ENDIAN__, + big = __ORDER_BIG_ENDIAN__, + native = __BYTE_ORDER__ +# elif gsl_COMPILER_ARMCC_VERSION || gsl_COMPILER_NVHPC_VERSION + // from header file + little = __LITTLE_ENDIAN, + big = __BIG_ENDIAN, + native = __BYTE_ORDER +# else +// Do not define any endianness constants for unknown compilers. +# endif +}; +# endif // gsl_HAVE( ENUM_CLASS ) + +#endif // gsl_CPP11_100 + +template< class T > +struct type_identity +{ + typedef T type; +}; +#if gsl_HAVE( ALIAS_TEMPLATE ) +template< class T > +using type_identity_t = typename type_identity::type; +#endif // gsl_HAVE( ALIAS_TEMPLATE ) + +#if gsl_HAVE( STD_SSIZE ) + +using std::ssize; + +#elif gsl_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR ) + +template < class C > +gsl_NODISCARD gsl_constexpr auto +ssize( C const & c ) + -> typename std::common_type::type>::type +{ + using R = typename std::common_type::type>::type; + return static_cast( c.size() ); +} + +template +gsl_NODISCARD gsl_constexpr auto +ssize( T const(&)[N] ) gsl_noexcept -> std::ptrdiff_t +{ + return std::ptrdiff_t( N ); +} + +#endif // gsl_HAVE( STD_SSIZE ) + +#if gsl_HAVE( REMOVE_CVREF ) + +using std::remove_cvref; + +#else + +template< class T > struct remove_cvref { typedef typename std11::remove_cv< typename std11::remove_reference< T >::type >::type type; }; + +#endif // gsl_HAVE( REMOVE_CVREF ) + +} // namespace std20 + +// C++23 emulation: + +namespace std23 { + +} // namespace std23 + +namespace detail { + +/// for gsl_ENABLE_IF_() + +/*enum*/ class enabler{}; + +#if gsl_HAVE( TYPE_TRAITS ) + +template< class Q > +struct is_span_oracle : std::false_type{}; + +template< class T> +struct is_span_oracle< span > : std::true_type{}; + +template< class Q > +struct is_span : is_span_oracle< typename std::remove_cv::type >{}; + +template< class Q > +struct is_std_array_oracle : std::false_type{}; + +# if gsl_HAVE( ARRAY ) + +template< class T, std::size_t Extent > +struct is_std_array_oracle< std::array > : std::true_type{}; + +# endif + +template< class Q > +struct is_std_array : is_std_array_oracle< typename std::remove_cv::type >{}; + +template< class Q > +struct is_array : std::false_type{}; + +template< class T > +struct is_array : std::true_type{}; + +template< class T, std::size_t N > +struct is_array : std::true_type{}; + +# if gsl_CPP11_140 && ! gsl_BETWEEN( gsl_COMPILER_GNUC_VERSION, 1, 500 ) + +template< class, class = void > +struct has_size_and_data : std::false_type{}; + +template< class C > +struct has_size_and_data +< + C, std17::void_t< + decltype( std17::size(std::declval()) ), + decltype( std17::data(std::declval()) ) > +> : std::true_type{}; + +template< class, class, class = void > +struct is_compatible_element : std::false_type {}; + +template< class C, class E > +struct is_compatible_element +< + C, E, std17::void_t< + decltype( std17::data(std::declval()) ), + typename std::remove_pointer() ) )>::type(*)[] > +> : std::is_convertible< typename std::remove_pointer() ) )>::type(*)[], E(*)[] >{}; + +template< class C > +struct is_container : std17::bool_constant +< + ! is_span< C >::value + && ! is_array< C >::value + && ! is_std_array< C >::value + && has_size_and_data< C >::value +>{}; + +template< class C, class E > +struct is_compatible_container : std17::bool_constant +< + is_container::value + && is_compatible_element::value +>{}; + +# else // ^^^ gsl_CPP11_140 && ! gsl_BETWEEN( gsl_COMPILER_GNUC_VERSION, 1, 500 ) ^^^ / vvv ! gsl_CPP11_140 || gsl_BETWEEN( gsl_COMPILER_GNUC_VERSION, 1, 500 ) vvv + +template< + class C, class E + , typename = typename std::enable_if< + ! is_span< C >::value + && ! is_array< C >::value + && ! is_std_array< C >::value + && ( std::is_convertible< typename std::remove_pointer() ) )>::type(*)[], E(*)[] >::value) + // && has_size_and_data< C >::value + , enabler>::type + , class = decltype( std17::size(std::declval()) ) + , class = decltype( std17::data(std::declval()) ) +> +# if gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 1, 140 ) +// VS2013 has insufficient support for expression SFINAE; we cannot make `is_compatible_container<>` a proper type trait here +struct is_compatible_container : std::true_type { }; +# else +struct is_compatible_container_r { is_compatible_container_r(int); }; +template< class C, class E > +std::true_type is_compatible_container_f( is_compatible_container_r ); +template< class C, class E > +std::false_type is_compatible_container_f( ... ); + +template< class C, class E > +struct is_compatible_container : decltype( is_compatible_container_f< C, E >( 0 ) ) { }; +# endif // gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 1, 140 ) + +# endif // gsl_CPP11_140 && ! gsl_BETWEEN( gsl_COMPILER_GNUC_VERSION, 1, 500 ) + +#endif // gsl_HAVE( TYPE_TRAITS ) + +} // namespace detail + +// +// GSL.util: utilities +// + +// Integer type for indices (e.g. in a loop). +typedef gsl_CONFIG_INDEX_TYPE index; + +// Integer type for dimensions. +typedef gsl_CONFIG_INDEX_TYPE dim; + +// Integer type for array strides. +typedef gsl_CONFIG_INDEX_TYPE stride; + +// Integer type for pointer, iterator, or index differences. +typedef gsl_CONFIG_INDEX_TYPE diff; + +// +// GSL.owner: ownership pointers +// +#if gsl_HAVE( SHARED_PTR ) + using std::unique_ptr; + using std::shared_ptr; +#endif + +#if gsl_HAVE( ALIAS_TEMPLATE ) + template< class T +#if gsl_HAVE( TYPE_TRAITS ) + , typename = typename std::enable_if< std::is_pointer::value >::type +#endif + > + using owner = T; +#elif gsl_CONFIG( DEFAULTS_VERSION ) == 0 + // TODO vNext: remove + template< class T > struct owner { typedef T type; }; +#endif + +#define gsl_HAVE_OWNER_TEMPLATE gsl_HAVE_ALIAS_TEMPLATE +#define gsl_HAVE_OWNER_TEMPLATE_() gsl_HAVE_OWNER_TEMPLATE + +// TODO vNext: remove +#if gsl_FEATURE( OWNER_MACRO ) +# if gsl_HAVE( OWNER_TEMPLATE ) +# define Owner(t) ::gsl::owner +# else +# define Owner(t) ::gsl::owner::type +# endif +#endif + +// +// GSL.assert: assertions +// + +#if gsl_HAVE( TYPE_TRAITS ) && gsl_CONFIG( VALIDATES_UNENFORCED_CONTRACT_EXPRESSIONS ) +# define gsl_ELIDE_( x ) static_assert( ::std::is_constructible::value, "argument of contract check must be convertible to bool" ) +#else +# define gsl_ELIDE_( x ) +#endif +#define gsl_NO_OP_() ( static_cast( 0 ) ) + +#if gsl_COMPILER_NVHPC_VERSION +// Suppress "controlling expression is constant" warning when using `gsl_Expects()`, `gsl_Ensures()`, `gsl_Assert()`, etc. +# define gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ _Pragma("diag_suppress 236") +# define gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ _Pragma("diag_default 236") +#else +# define gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ +# define gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ +#endif + +#if gsl_DEVICE_CODE +# if defined( gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME ) +# if gsl_COMPILER_NVCC_VERSION >= 113 +# define gsl_ASSUME_( x ) ( __builtin_assume( !!( x ) ) ) +# define gsl_ASSUME_UNREACHABLE_() __builtin_unreachable() +# else // unknown device compiler +# error gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ASSUME: gsl-lite does not know how to generate UB optimization hints in device code for this compiler; use gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE instead +# endif +# define gsl_CONTRACT_UNENFORCED_( x ) gsl_ASSUME_( x ) +# else // defined( gsl_CONFIG_DEVICE_UNENFORCED_CONTRACTS_ELIDE ) [default] +# define gsl_CONTRACT_UNENFORCED_( x ) gsl_ELIDE_( x ) +# endif +#else // host code +# if defined( gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME ) +# if gsl_COMPILER_MSVC_VERSION >= 140 +# define gsl_ASSUME_( x ) __assume( x ) +# define gsl_ASSUME_UNREACHABLE_() __assume( 0 ) +# elif gsl_COMPILER_GNUC_VERSION +# define gsl_ASSUME_( x ) ( ( x ) ? static_cast(0) : __builtin_unreachable() ) +# define gsl_ASSUME_UNREACHABLE_() __builtin_unreachable() +# elif defined(__has_builtin) +# if __has_builtin(__builtin_unreachable) +# define gsl_ASSUME_( x ) ( ( x ) ? static_cast(0) : __builtin_unreachable() ) +# define gsl_ASSUME_UNREACHABLE_() __builtin_unreachable() +# else +# error gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME: gsl-lite does not know how to generate UB optimization hints for this compiler; use gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE instead +# endif +# else +# error gsl_CONFIG_UNENFORCED_CONTRACTS_ASSUME: gsl-lite does not know how to generate UB optimization hints for this compiler; use gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE instead +# endif +# define gsl_CONTRACT_UNENFORCED_( x ) gsl_ASSUME_( x ) +# else // defined( gsl_CONFIG_UNENFORCED_CONTRACTS_ELIDE ) [default] +# define gsl_CONTRACT_UNENFORCED_( x ) gsl_ELIDE_( x ) +# endif +#endif // gsl_DEVICE_CODE + +#if gsl_DEVICE_CODE +# if gsl_COMPILER_NVCC_VERSION +# define gsl_TRAP_() __trap() +# elif defined(__has_builtin) +# if __has_builtin(__builtin_trap) +# define gsl_TRAP_() __builtin_trap() +# else +# error gsl-lite does not know how to generate a trap instruction for this device compiler +# endif +# else +# error gsl-lite does not know how to generate a trap instruction for this device compiler +# endif +# if defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_TRAPS ) +# define gsl_CONTRACT_CHECK_( str, x ) ( gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ( x ) ? static_cast(0) : gsl_TRAP_() gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ) +# define gsl_FAILFAST_() ( gsl_TRAP_() ) +# elif defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_CALLS_HANDLER ) +# define gsl_CONTRACT_CHECK_( str, x ) ( gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ( x ) ? static_cast(0) : ::gsl::fail_fast_assert_handler( #x, str, __FILE__, __LINE__ ) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ) +# define gsl_FAILFAST_() ( ::gsl::fail_fast_assert_handler( "", "GSL: failure", __FILE__, __LINE__ ), gsl_TRAP_() ) /* do not let the custom assertion handler continue execution */ +# else // defined( gsl_CONFIG_DEVICE_CONTRACT_VIOLATION_ASSERTS ) [default] +# if ! defined( NDEBUG ) +# define gsl_CONTRACT_CHECK_( str, x ) assert( str && ( x ) ) +# else +# define gsl_CONTRACT_CHECK_( str, x ) ( ( x ) ? static_cast(0) : gsl_TRAP_() ) +# endif +# define gsl_FAILFAST_() ( gsl_TRAP_() ) +# endif +#else // host code +# if defined( gsl_CONFIG_CONTRACT_VIOLATION_TRAPS ) +# if gsl_COMPILER_MSVC_VERSION >= 110 // __fastfail() supported by VS 2012 and later +# define gsl_TRAP_() __fastfail( 0 ) /* legacy failure code for buffer-overrun errors, cf. winnt.h, "Fast fail failure codes" */ +# elif gsl_COMPILER_GNUC_VERSION +# define gsl_TRAP_() __builtin_trap() +# elif defined(__has_builtin) +# if __has_builtin(__builtin_trap) +# define gsl_TRAP_() __builtin_trap() +# else +# error gsl_CONFIG_CONTRACT_VIOLATION_TRAPS: gsl-lite does not know how to generate a trap instruction for this compiler; use gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES instead +# endif +# else +# error gsl_CONFIG_CONTRACT_VIOLATION_TRAPS: gsl-lite does not know how to generate a trap instruction for this compiler; use gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES instead +# endif +# define gsl_CONTRACT_CHECK_( str, x ) ( gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ( x ) ? static_cast(0) : gsl_TRAP_() gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ) +# if gsl_COMPILER_MSVC_VERSION +# define gsl_FAILFAST_() ( gsl_TRAP_(), ::gsl::detail::fail_fast_terminate() ) +# else +# define gsl_FAILFAST_() ( gsl_TRAP_() ) +# endif +# elif defined( gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER ) +# define gsl_CONTRACT_CHECK_( str, x ) ( gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ( x ) ? static_cast(0) : ::gsl::fail_fast_assert_handler( #x, str, __FILE__, __LINE__ ) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ) +# define gsl_FAILFAST_() ( ::gsl::fail_fast_assert_handler( "", "GSL: failure", __FILE__, __LINE__ ), ::gsl::detail::fail_fast_terminate() ) /* do not let the custom assertion handler continue execution */ +# elif defined( gsl_CONFIG_CONTRACT_VIOLATION_ASSERTS ) +# if ! defined( NDEBUG ) +# define gsl_CONTRACT_CHECK_( str, x ) ( gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ assert( str && ( x ) ) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ) +# define gsl_FAILFAST_() ( gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ assert( ! "GSL: failure" ) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_, ::gsl::detail::fail_fast_abort() ) +# else +# define gsl_CONTRACT_CHECK_( str, x ) ( gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ( x ) ? static_cast(0) : ::gsl::detail::fail_fast_abort() gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ) +# define gsl_FAILFAST_() ( ::gsl::detail::fail_fast_abort() ) +# endif +# elif defined( gsl_CONFIG_CONTRACT_VIOLATION_THROWS ) +# define gsl_CONTRACT_CHECK_( str, x ) ( gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ( ( x ) ? static_cast(0) : ::gsl::detail::fail_fast_throw( str ": '" #x "' at " __FILE__ ":" gsl_STRINGIFY(__LINE__) ) ) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ) +# define gsl_FAILFAST_() ( ::gsl::detail::fail_fast_throw( "GSL: failure at " __FILE__ ":" gsl_STRINGIFY(__LINE__) ) ) +# else // defined( gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES ) [default] +# define gsl_CONTRACT_CHECK_( str, x ) ( gsl_SUPPRESS_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ( ( x ) ? static_cast(0) : ::gsl::detail::fail_fast_terminate() ) gsl_RESTORE_NVHPC_CONTROLLING_EXPRESSION_IS_CONSTANT_ ) +# define gsl_FAILFAST_() ( ::gsl::detail::fail_fast_terminate() ) +# endif +#endif // gsl_DEVICE_CODE + +#if ( !gsl_DEVICE_CODE && defined( gsl_CONFIG_CONTRACT_CHECKING_OFF ) ) || ( gsl_DEVICE_CODE && defined( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_OFF ) ) +# define gsl_CHECK_CONTRACTS_ 0 +# define gsl_CHECK_DEBUG_CONTRACTS_ 0 +# define gsl_CHECK_AUDIT_CONTRACTS_ 0 +#elif ( !gsl_DEVICE_CODE && defined( gsl_CONFIG_CONTRACT_CHECKING_AUDIT ) ) || ( gsl_DEVICE_CODE && defined( gsl_CONFIG_DEVICE_CONTRACT_CHECKING_AUDIT ) ) +# define gsl_CHECK_CONTRACTS_ 1 +# define gsl_CHECK_DEBUG_CONTRACTS_ 1 +# define gsl_CHECK_AUDIT_CONTRACTS_ 1 +#else // gsl_CONFIG_[DEVICE_]CONTRACT_CHECKING_ON [default] +# define gsl_CHECK_CONTRACTS_ 1 +# if !defined( NDEBUG ) +# define gsl_CHECK_DEBUG_CONTRACTS_ 1 +# else // defined( NDEBUG ) +# define gsl_CHECK_DEBUG_CONTRACTS_ 0 +# endif +# define gsl_CHECK_AUDIT_CONTRACTS_ 0 +#endif + +#if gsl_CHECK_CONTRACTS_ && !defined( gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF ) +# define gsl_Expects( x ) gsl_CONTRACT_CHECK_( "GSL: Precondition failure", x ) +#else +# define gsl_Expects( x ) gsl_CONTRACT_UNENFORCED_( x ) +#endif +#define Expects( x ) gsl_Expects( x ) +#if gsl_CHECK_DEBUG_CONTRACTS_ && !defined( gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF ) +# define gsl_ExpectsDebug( x ) gsl_CONTRACT_CHECK_( "GSL: Precondition failure (debug)", x ) +#else +# define gsl_ExpectsDebug( x ) gsl_ELIDE_( x ) +#endif +#if gsl_CHECK_AUDIT_CONTRACTS_ && !defined( gsl_CONFIG_CONTRACT_CHECKING_EXPECTS_OFF ) +# define gsl_ExpectsAudit( x ) gsl_CONTRACT_CHECK_( "GSL: Precondition failure (audit)", x ) +#else +# define gsl_ExpectsAudit( x ) gsl_ELIDE_( x ) +#endif + +#if gsl_CHECK_CONTRACTS_ && !defined( gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF ) +# define gsl_Ensures( x ) gsl_CONTRACT_CHECK_( "GSL: Postcondition failure", x ) +#else +# define gsl_Ensures( x ) gsl_CONTRACT_UNENFORCED_( x ) +#endif +#define Ensures( x ) gsl_Ensures( x ) +#if gsl_CHECK_DEBUG_CONTRACTS_ && !defined( gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF ) +# define gsl_EnsuresDebug( x ) gsl_CONTRACT_CHECK_( "GSL: Postcondition failure (debug)", x ) +#else +# define gsl_EnsuresDebug( x ) gsl_ELIDE_( x ) +#endif +#if gsl_CHECK_AUDIT_CONTRACTS_ && !defined( gsl_CONFIG_CONTRACT_CHECKING_ENSURES_OFF ) +# define gsl_EnsuresAudit( x ) gsl_CONTRACT_CHECK_( "GSL: Postcondition failure (audit)", x ) +#else +# define gsl_EnsuresAudit( x ) gsl_ELIDE_( x ) +#endif + +#if gsl_CHECK_CONTRACTS_ && !defined( gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF ) +# define gsl_Assert( x ) gsl_CONTRACT_CHECK_( "GSL: Assertion failure", x ) +#else +# define gsl_Assert( x ) gsl_CONTRACT_UNENFORCED_( x ) +#endif +#if gsl_CHECK_DEBUG_CONTRACTS_ && !defined( gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF ) +# define gsl_AssertDebug( x ) gsl_CONTRACT_CHECK_( "GSL: Assertion failure (debug)", x ) +#else +# define gsl_AssertDebug( x ) gsl_ELIDE_( x ) +#endif +#if gsl_CHECK_AUDIT_CONTRACTS_ && !defined( gsl_CONFIG_CONTRACT_CHECKING_ASSERT_OFF ) +# define gsl_AssertAudit( x ) gsl_CONTRACT_CHECK_( "GSL: Assertion failure (audit)", x ) +#else +# define gsl_AssertAudit( x ) gsl_ELIDE_( x ) +#endif + +#define gsl_FailFast() gsl_FAILFAST_() + +#undef gsl_CHECK_CONTRACTS_ +#undef gsl_CHECK_DEBUG_CONTRACTS_ +#undef gsl_CHECK_AUDIT_CONTRACTS_ + + +struct fail_fast : public std::logic_error +{ + explicit fail_fast( char const * message ) + : std::logic_error( message ) {} +}; + +namespace detail { + + +#if gsl_HAVE( EXCEPTIONS ) +gsl_NORETURN inline void fail_fast_throw( char const * message ) +{ + throw fail_fast( message ); +} +#endif // gsl_HAVE( EXCEPTIONS ) +gsl_NORETURN inline void fail_fast_terminate() gsl_noexcept +{ + std::terminate(); +} +gsl_NORETURN inline void fail_fast_abort() gsl_noexcept +{ + std::abort(); +} + +} // namespace detail + +// Should be defined by user +gsl_api void fail_fast_assert_handler( char const * const expression, char const * const message, char const * const file, int line ); + +#if defined( gsl_CONFIG_CONTRACT_VIOLATION_THROWS ) + +# if gsl_HAVE( EXCEPTIONS ) +gsl_DEPRECATED_MSG("don't call gsl::fail_fast_assert() directly; use contract checking macros instead") +gsl_constexpr14 inline +void fail_fast_assert( bool cond, char const * const message ) +{ + if ( !cond ) + throw fail_fast( message ); +} +# endif // gsl_HAVE( EXCEPTIONS ) + +#elif defined( gsl_CONFIG_CONTRACT_VIOLATION_CALLS_HANDLER ) + +gsl_DEPRECATED_MSG("don't call gsl::fail_fast_assert() directly; use contract checking macros instead") +gsl_api gsl_constexpr14 inline +void fail_fast_assert( bool cond, char const * const expression, char const * const message, char const * const file, int line ) +{ + if ( !cond ) + ::gsl::fail_fast_assert_handler( expression, message, file, line ); +} + +#else // defined( gsl_CONFIG_CONTRACT_VIOLATION_TERMINATES ) [default] + +gsl_DEPRECATED_MSG("don't call gsl::fail_fast_assert() directly; use contract checking macros instead") +gsl_constexpr14 inline +void fail_fast_assert( bool cond ) gsl_noexcept +{ + if ( !cond ) + std::terminate(); +} + +#endif + + +// +// GSL.util: utilities +// + +#if gsl_FEATURE( EXPERIMENTAL_RETURN_GUARD ) + +// Add uncaught_exceptions for pre-2017 MSVC, GCC and Clang +// Return unsigned char to save stack space, uncaught_exceptions can only increase by 1 in a scope + +namespace std11 { + +# if gsl_HAVE( UNCAUGHT_EXCEPTIONS ) + +inline unsigned char uncaught_exceptions() gsl_noexcept +{ + return static_cast( std::uncaught_exceptions() ); +} + +# else // ! gsl_HAVE( UNCAUGHT_EXCEPTIONS ) +# if defined( _MSC_VER ) // MS-STL with either MSVC or clang-cl + +inline unsigned char uncaught_exceptions() gsl_noexcept +{ + return static_cast( *reinterpret_cast( detail::_getptd() + (sizeof(void *) == 8 ? 0x100 : 0x90 ) ) ); +} + +# elif gsl_COMPILER_CLANG_VERSION || gsl_COMPILER_GNUC_VERSION || gsl_COMPILER_APPLECLANG_VERSION || gsl_COMPILER_NVHPC_VERSION + +inline unsigned char uncaught_exceptions() gsl_noexcept +{ + return static_cast( ( *reinterpret_cast( reinterpret_cast(detail::__cxa_get_globals()) + sizeof(void *) ) ) ); +} + +# endif +# endif + +} // namespace std11 + +#endif // gsl_FEATURE( EXPERIMENTAL_RETURN_GUARD ) + +#if gsl_STDLIB_CPP11_110 + +gsl_DISABLE_MSVC_WARNINGS( 4702 ) // unreachable code + +template< class F > +class final_action +{ +public: + explicit final_action( F action ) gsl_noexcept + : action_( std::move( action ) ) +#if gsl_CONFIG_DEFAULTS_VERSION < 1 || ! gsl_CPP17_OR_GREATER + , invoke_( true ) +#endif + { + } + + // We only provide the move constructor for legacy defaults, or if we cannot rely on C++17 guaranteed copy elision. +#if gsl_CONFIG_DEFAULTS_VERSION < 1 || ! gsl_CPP17_OR_GREATER + final_action( final_action && other ) gsl_noexcept + : action_( std::move( other.action_ ) ) + , invoke_( other.invoke_ ) + { + other.invoke_ = false; + } +#endif // gsl_CONFIG_DEFAULTS_VERSION < 1 || ! gsl_CPP17_OR_GREATER + + gsl_SUPPRESS_MSGSL_WARNING(f.6) +#if gsl_CONFIG_DEFAULTS_VERSION < 1 // we avoid the unnecessary virtual calls if modern defaults are selected + virtual +#endif + ~final_action() gsl_noexcept + { +#if gsl_CONFIG_DEFAULTS_VERSION < 1 || ! gsl_CPP17_OR_GREATER + if ( invoke_ ) +#endif + { + action_(); + } + } + +gsl_is_delete_access: + final_action( final_action const & ) gsl_is_delete; + final_action & operator=( final_action const & ) gsl_is_delete; + final_action & operator=( final_action && ) gsl_is_delete; + +#if gsl_CONFIG_DEFAULTS_VERSION < 1 +protected: + void dismiss() gsl_noexcept + { + invoke_ = false; + } +#endif // gsl_CONFIG_DEFAULTS_VERSION < 1 + +private: + F action_; +#if gsl_CONFIG_DEFAULTS_VERSION < 1 || ! gsl_CPP17_OR_GREATER + bool invoke_; +#endif +}; + +template< class F > +gsl_NODISCARD inline final_action::type> +finally( F && action ) gsl_noexcept +{ + return final_action::type>( std::forward( action ) ); +} + +# if gsl_FEATURE( EXPERIMENTAL_RETURN_GUARD ) + +#if gsl_CONFIG_DEFAULTS_VERSION >= 1 +template< class F > +class final_action_return +{ +public: + explicit final_action_return( F action ) gsl_noexcept + : action_( std::move( action ) ) + , exception_count_( std11::uncaught_exceptions() ) +#if ! gsl_CPP17_OR_GREATER + , invoke_( true ) +#endif + { + } + + // We only provide the move constructor if we cannot rely on C++17 guaranteed copy elision. +#if ! gsl_CPP17_OR_GREATER + final_action_return( final_action_return && other ) gsl_noexcept + : action_( std::move( other.action_ ) ) + , exception_count_( other.exception_count_ ) + , invoke_( other.invoke_ ) + { + other.invoke_ = false; + } +#endif // ! gsl_CPP17_OR_GREATER + + gsl_SUPPRESS_MSGSL_WARNING(f.6) + ~final_action_return() gsl_noexcept + { +#if ! gsl_CPP17_OR_GREATER + if ( invoke_ ) +#endif + { + if ( std11::uncaught_exceptions() == exception_count_ ) + { + action_(); + } + } + } + +gsl_is_delete_access: + final_action_return( final_action_return const & ) gsl_is_delete; + final_action_return & operator=( final_action_return const & ) gsl_is_delete; + final_action_return & operator=( final_action_return && ) gsl_is_delete; + +private: + F action_; + unsigned char exception_count_; +#if ! gsl_CPP17_OR_GREATER + bool invoke_; +#endif +}; +template< class F > +class final_action_error +{ +public: + explicit final_action_error( F action ) gsl_noexcept + : action_( std::move( action ) ) + , exception_count_( std11::uncaught_exceptions() ) +#if ! gsl_CPP17_OR_GREATER + , invoke_( true ) +#endif + { + } + + // We only provide the move constructor if we cannot rely on C++17 guaranteed copy elision. +#if ! gsl_CPP17_OR_GREATER + final_action_error( final_action_error && other ) gsl_noexcept + : action_( std::move( other.action_ ) ) + , exception_count_( other.exception_count_ ) + , invoke_( other.invoke_ ) + { + other.invoke_ = false; + } +#endif // ! gsl_CPP17_OR_GREATER + + gsl_SUPPRESS_MSGSL_WARNING(f.6) + ~final_action_error() gsl_noexcept + { +#if ! gsl_CPP17_OR_GREATER + if ( invoke_ ) +#endif + { + if ( std11::uncaught_exceptions() != exception_count_ ) + { + action_(); + } + } + } + +gsl_is_delete_access: + final_action_error( final_action_error const & ) gsl_is_delete; + final_action_error & operator=( final_action_error const & ) gsl_is_delete; + final_action_error & operator=( final_action_error && ) gsl_is_delete; + +private: + F action_; + unsigned char exception_count_; +#if ! gsl_CPP17_OR_GREATER + bool invoke_; +#endif +}; +#else // gsl_CONFIG_DEFAULTS_VERSION < 1 +template< class F > +class final_action_return : public final_action +{ +public: + explicit final_action_return( F && action ) gsl_noexcept + : final_action( std::move( action ) ) + , exception_count( std11::uncaught_exceptions() ) + {} + + final_action_return( final_action_return && other ) gsl_noexcept + : final_action( std::move( other ) ) + , exception_count( std11::uncaught_exceptions() ) + {} + + ~final_action_return() override + { + if ( std11::uncaught_exceptions() != exception_count ) + this->dismiss(); + } + +gsl_is_delete_access: + final_action_return( final_action_return const & ) gsl_is_delete; + final_action_return & operator=( final_action_return const & ) gsl_is_delete; + +private: + unsigned char exception_count; +}; + +template< class F > +class final_action_error : public final_action +{ +public: + explicit final_action_error( F && action ) gsl_noexcept + : final_action( std::move( action ) ) + , exception_count( std11::uncaught_exceptions() ) + {} + + final_action_error( final_action_error && other ) gsl_noexcept + : final_action( std::move( other ) ) + , exception_count( std11::uncaught_exceptions() ) + {} + + ~final_action_error() override + { + if ( std11::uncaught_exceptions() == exception_count ) + this->dismiss(); + } + +gsl_is_delete_access: + final_action_error( final_action_error const & ) gsl_is_delete; + final_action_error & operator=( final_action_error const & ) gsl_is_delete; + +private: + unsigned char exception_count; +}; +#endif // gsl_CONFIG_DEFAULTS_VERSION >= 1 + +template< class F > +gsl_NODISCARD inline final_action_return::type> +on_return( F && action ) gsl_noexcept +{ + return final_action_return::type>( std::forward( action ) ); +} + +template< class F > +gsl_NODISCARD inline final_action_error::type> +on_error( F && action ) gsl_noexcept +{ + return final_action_error::type>( std::forward( action ) ); +} + +# endif // gsl_FEATURE( EXPERIMENTAL_RETURN_GUARD ) + +gsl_RESTORE_MSVC_WARNINGS() + +#else // ! gsl_STDLIB_CPP11_110 + +# if gsl_DEPRECATE_TO_LEVEL( 8 ) +gsl_DEPRECATED_MSG("final_action for pre-C++11 compilers is deprecated") +# endif // gsl_DEPRECATE_TO_LEVEL( 8 ) +class final_action +{ +public: + typedef void (*Action)(); + + final_action( Action action ) + : action_( action ) + , invoke_( true ) + {} + + final_action( final_action const & other ) + : action_( other.action_ ) + , invoke_( other.invoke_ ) + { + other.invoke_ = false; + } + + virtual ~final_action() + { + if ( invoke_ ) + action_(); + } + +protected: + void dismiss() + { + invoke_ = false; + } + +private: + final_action & operator=( final_action const & ); + +private: + Action action_; + mutable bool invoke_; +}; + +template< class F > +# if gsl_DEPRECATE_TO_LEVEL( 8 ) +gsl_DEPRECATED_MSG("finally() for pre-C++11 compilers is deprecated") +# endif // gsl_DEPRECATE_TO_LEVEL( 8 ) +inline final_action finally( F const & f ) +{ + return final_action( f ); +} + +# if gsl_FEATURE( EXPERIMENTAL_RETURN_GUARD ) + +# if gsl_DEPRECATE_TO_LEVEL( 8 ) +gsl_DEPRECATED_MSG("final_action_return for pre-C++11 compilers is deprecated") +# endif // gsl_DEPRECATE_TO_LEVEL( 8 ) +class final_action_return : public final_action +{ +public: + explicit final_action_return( Action action ) + : final_action( action ) + , exception_count( std11::uncaught_exceptions() ) + {} + + ~final_action_return() + { + if ( std11::uncaught_exceptions() != exception_count ) + this->dismiss(); + } + +private: + final_action_return & operator=( final_action_return const & ); + +private: + unsigned char exception_count; +}; + +template< class F > +# if gsl_DEPRECATE_TO_LEVEL( 8 ) +gsl_DEPRECATED_MSG("on_return() for pre-C++11 compilers is deprecated") +# endif // gsl_DEPRECATE_TO_LEVEL( 8 ) +inline final_action_return on_return( F const & action ) +{ + return final_action_return( action ); +} + +# if gsl_DEPRECATE_TO_LEVEL( 8 ) +gsl_DEPRECATED_MSG("final_action_error for pre-C++11 compilers is deprecated") +# endif // gsl_DEPRECATE_TO_LEVEL( 8 ) +class final_action_error : public final_action +{ +public: + explicit final_action_error( Action action ) + : final_action( action ) + , exception_count( std11::uncaught_exceptions() ) + {} + + ~final_action_error() + { + if ( std11::uncaught_exceptions() == exception_count ) + this->dismiss(); + } + +private: + final_action_error & operator=( final_action_error const & ); + +private: + unsigned char exception_count; +}; + +template< class F > +# if gsl_DEPRECATE_TO_LEVEL( 8 ) +gsl_DEPRECATED_MSG("on_error() for pre-C++11 compilers is deprecated") +# endif // gsl_DEPRECATE_TO_LEVEL( 8 ) +inline final_action_error on_error( F const & action ) +{ + return final_action_error( action ); +} + +# endif // gsl_FEATURE( EXPERIMENTAL_RETURN_GUARD ) + +#endif // gsl_STDLIB_CPP11_110 + +#if gsl_STDLIB_CPP11_120 + +template< class T, class U > +gsl_NODISCARD gsl_api inline gsl_constexpr T +narrow_cast( U && u ) gsl_noexcept +{ + return static_cast( std::forward( u ) ); +} + +#else // ! gsl_STDLIB_CPP11_120 + +template< class T, class U > +gsl_api inline T +narrow_cast( U u ) gsl_noexcept +{ + return static_cast( u ); +} + +#endif // gsl_STDLIB_CPP11_120 + +struct narrowing_error : public std::exception +{ + char const * what() const gsl_noexcept +#if gsl_HAVE( OVERRIDE_FINAL ) + override +#endif + { + return "narrowing_error"; + } +}; + +#if gsl_HAVE( TYPE_TRAITS ) + +namespace detail { + + template< class T, class U > + struct is_same_signedness : public std::integral_constant::value == std::is_signed::value> {}; + +# if gsl_COMPILER_NVCC_VERSION || gsl_COMPILER_NVHPC_VERSION + // We do this to circumvent NVCC warnings about pointless unsigned comparisons with 0. + template< class T > + gsl_constexpr gsl_api bool is_negative( T value, std::true_type /*isSigned*/ ) gsl_noexcept + { + return value < T(); + } + template< class T > + gsl_constexpr gsl_api bool is_negative( T /*value*/, std::false_type /*isUnsigned*/ ) gsl_noexcept + { + return false; + } + template< class T, class U > + gsl_constexpr gsl_api bool have_same_sign( T, U, std::true_type /*isSameSignedness*/ ) gsl_noexcept + { + return true; + } + template< class T, class U > + gsl_constexpr gsl_api bool have_same_sign( T t, U u, std::false_type /*isSameSignedness*/ ) gsl_noexcept + { + return detail::is_negative( t, std::is_signed() ) == detail::is_negative( u, std::is_signed() ); + } +# endif // gsl_COMPILER_NVCC_VERSION || gsl_COMPILER_NVHPC_VERSION + +} // namespace detail + +#endif + +template< class T, class U > +gsl_NODISCARD gsl_constexpr14 +#if !gsl_CONFIG( NARROW_THROWS_ON_TRUNCATION ) && !defined( gsl_CONFIG_CONTRACT_VIOLATION_THROWS ) +gsl_api +#endif +inline T +narrow( U u ) +{ +#if gsl_CONFIG( NARROW_THROWS_ON_TRUNCATION ) && ! gsl_HAVE( EXCEPTIONS ) + gsl_STATIC_ASSERT_( detail::dependent_false< T >::value, + "According to the GSL specification, narrow<>() throws an exception of type narrowing_error on truncation. Therefore " + "it cannot be used if exceptions are disabled. Consider using narrow_failfast<>() instead which raises a precondition " + "violation if the given value cannot be represented in the target type." ); +#endif + + T t = static_cast( u ); + + if ( static_cast( t ) != u ) + { +#if gsl_HAVE( EXCEPTIONS ) && ( gsl_CONFIG( NARROW_THROWS_ON_TRUNCATION ) || defined( gsl_CONFIG_CONTRACT_VIOLATION_THROWS ) ) + throw narrowing_error(); +#else + std::terminate(); +#endif + } + +#if gsl_HAVE( TYPE_TRAITS ) +# if gsl_COMPILER_NVCC_VERSION || gsl_COMPILER_NVHPC_VERSION + if ( ! detail::have_same_sign( t, u, detail::is_same_signedness() ) ) +# else + gsl_SUPPRESS_MSVC_WARNING( 4127, "conditional expression is constant" ) + if ( ! detail::is_same_signedness::value && ( t < T() ) != ( u < U() ) ) +# endif +#else + // Don't assume T() works: + gsl_SUPPRESS_MSVC_WARNING( 4127, "conditional expression is constant" ) +# if gsl_COMPILER_NVHPC_VERSION + // Suppress: pointless comparison of unsigned integer with zero. +# pragma diag_suppress 186 +# endif + if ( ( t < 0 ) != ( u < 0 ) ) +# if gsl_COMPILER_NVHPC_VERSION + // Restore: pointless comparison of unsigned integer with zero. +# pragma diag_default 186 +# endif + +#endif + { +#if gsl_HAVE( EXCEPTIONS ) && ( gsl_CONFIG( NARROW_THROWS_ON_TRUNCATION ) || defined( gsl_CONFIG_CONTRACT_VIOLATION_THROWS ) ) + throw narrowing_error(); +#else + std::terminate(); +#endif + } + + return t; +} + +template< class T, class U > +gsl_NODISCARD gsl_api gsl_constexpr14 inline T +narrow_failfast( U u ) +{ + T t = static_cast( u ); + + gsl_Expects( static_cast( t ) == u ); + +#if gsl_HAVE( TYPE_TRAITS ) +# if gsl_COMPILER_NVCC_VERSION || gsl_COMPILER_NVHPC_VERSION + gsl_Expects( ::gsl::detail::have_same_sign( t, u, ::gsl::detail::is_same_signedness() ) ); +# else + gsl_SUPPRESS_MSVC_WARNING( 4127, "conditional expression is constant" ) + gsl_Expects( ( ::gsl::detail::is_same_signedness::value || ( t < T() ) == ( u < U() ) ) ); +# endif +#else + // Don't assume T() works: + gsl_SUPPRESS_MSVC_WARNING( 4127, "conditional expression is constant" ) +# if gsl_COMPILER_NVHPC_VERSION + // Suppress: pointless comparison of unsigned integer with zero. +# pragma diag_suppress 186 +# endif + gsl_Expects( ( t < 0 ) == ( u < 0 ) ); +# if gsl_COMPILER_NVHPC_VERSION + // Restore: pointless comparison of unsigned integer with zero. +# pragma diag_default 186 +# endif +#endif + + return t; +} + + +// +// at() - Bounds-checked way of accessing static arrays, std::array, std::vector. +// + +template< class T, size_t N > +gsl_NODISCARD gsl_api inline gsl_constexpr14 T & +at( T(&arr)[N], size_t pos ) +{ + gsl_Expects( pos < N ); + return arr[pos]; +} + +template< class Container > +gsl_NODISCARD gsl_api inline gsl_constexpr14 typename Container::value_type & +at( Container & cont, size_t pos ) +{ + gsl_Expects( pos < cont.size() ); + return cont[pos]; +} + +template< class Container > +gsl_NODISCARD gsl_api inline gsl_constexpr14 typename Container::value_type const & +at( Container const & cont, size_t pos ) +{ + gsl_Expects( pos < cont.size() ); + return cont[pos]; +} + +#if gsl_HAVE( INITIALIZER_LIST ) + +template< class T > +gsl_NODISCARD gsl_api inline const gsl_constexpr14 T +at( std::initializer_list cont, size_t pos ) +{ + gsl_Expects( pos < cont.size() ); + return *( cont.begin() + pos ); +} +#endif + +template< class T > +gsl_NODISCARD gsl_api inline gsl_constexpr14 T & +at( span s, size_t pos ) +{ + return s[ pos ]; +} + +// +// GSL.views: views +// + +// +// not_null<> - Wrap any indirection and enforce non-null. +// + +template< class T > +class not_null; + +namespace detail { + +// helper class to figure out the pointed-to type of a pointer +#if gsl_STDLIB_CPP11_OR_GREATER +template< class T, class E = void > +struct element_type_helper +{ + // For types without a member element_type (this could handle typed raw pointers but not `void*`) + typedef typename std::remove_reference< decltype( *std::declval() ) >::type type; +}; + +template< class T > +struct element_type_helper< T, std17::void_t< typename T::element_type > > +{ + // For types with a member element_type + typedef typename T::element_type type; +}; +#else // ! gsl_STDLIB_CPP11_OR_GREATER +// Pre-C++11, we cannot have decltype, so we cannot handle types without a member element_type +template< class T, class E = void > +struct element_type_helper +{ + typedef typename T::element_type type; +}; +#endif // gsl_STDLIB_CPP11_OR_GREATER + +template< class T > +struct element_type_helper< T* > +{ + typedef T type; +}; + +template< class T > +struct is_not_null_or_bool_oracle : std11::false_type { }; +template< class T > +struct is_not_null_or_bool_oracle< not_null > : std11::true_type { }; +template<> +struct is_not_null_or_bool_oracle< bool > : std11::true_type { }; + + +template< class T, bool IsCopyable > +struct not_null_data; +#if gsl_HAVE( MOVE_FORWARD ) +template< class T > +struct not_null_data< T, false > +{ + T ptr_; + + gsl_api gsl_constexpr14 not_null_data( T && _ptr ) gsl_noexcept + : ptr_( std::move( _ptr ) ) + { + } + + gsl_api gsl_constexpr14 not_null_data( not_null_data && other ) + gsl_noexcept_not_testing // we want to be nothrow-movable despite the assertion + : ptr_( std::move( other.ptr_ ) ) + { + gsl_Assert( ptr_ != gsl_nullptr ); + } + gsl_api gsl_constexpr14 not_null_data & operator=( not_null_data && other ) + gsl_noexcept_not_testing // we want to be nothrow-movable despite the assertion + { + gsl_Assert( other.ptr_ != gsl_nullptr || &other == this ); + ptr_ = std::move( other.ptr_ ); + return *this; + } + +gsl_is_delete_access: + not_null_data( not_null_data const & ) gsl_is_delete; + not_null_data & operator=( not_null_data const & ) gsl_is_delete; +}; +#endif // gsl_HAVE( MOVE_FORWARD ) +template< class T > +struct not_null_data< T, true > +{ + T ptr_; + + gsl_api gsl_constexpr14 not_null_data( T const & _ptr ) gsl_noexcept + : ptr_( _ptr ) + { + } + +#if gsl_HAVE( MOVE_FORWARD ) + gsl_api gsl_constexpr14 not_null_data( T && _ptr ) gsl_noexcept + : ptr_( std::move( _ptr ) ) + { + } + + gsl_api gsl_constexpr14 not_null_data( not_null_data && other ) + gsl_noexcept_not_testing // we want to be nothrow-movable despite the assertion + : ptr_( std::move( other.ptr_ ) ) + { + gsl_Assert( ptr_ != gsl_nullptr ); + } + gsl_api gsl_constexpr14 not_null_data & operator=( not_null_data && other ) + gsl_noexcept_not_testing // we want to be nothrow-movable despite the assertion + { + gsl_Assert( other.ptr_ != gsl_nullptr || &other == this ); + ptr_ = std::move( other.ptr_ ); + return *this; + } +#endif // gsl_HAVE( MOVE_FORWARD ) + + gsl_api gsl_constexpr14 not_null_data( not_null_data const & other ) + : ptr_( other.ptr_ ) + { + gsl_Assert( ptr_ != gsl_nullptr ); + } + gsl_api gsl_constexpr14 not_null_data & operator=( not_null_data const & other ) + { + gsl_Assert( other.ptr_ != gsl_nullptr ); + ptr_ = other.ptr_; + return *this; + } +}; +template< class T > +struct not_null_data< T *, true > +{ + T * ptr_; + + gsl_api gsl_constexpr14 not_null_data( T * _ptr ) gsl_noexcept + : ptr_( _ptr ) + { + } +}; + +template< class T > +struct is_copyable +#if gsl_HAVE( TYPE_TRAITS ) +: std11::integral_constant< bool, std::is_copy_constructible::value && std::is_copy_assignable::value > +#else +: std11::true_type +#endif +{ +}; +#if gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( UNIQUE_PTR ) && gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 1, 140 ) +// Type traits are buggy in VC++ 2013, so we explicitly declare `unique_ptr<>` non-copyable. +template< class T, class Deleter > +struct is_copyable< std::unique_ptr< T, Deleter > > : std11::false_type +{ +}; +#endif + +template< class T > +struct not_null_accessor; + +template< class Derived, class T, bool IsVoidPtr > +struct not_null_deref +{ + typedef typename element_type_helper::type element_type; + + gsl_NODISCARD gsl_api gsl_constexpr14 element_type & + operator*() const + { + return *not_null_accessor::get_checked( static_cast( *this ) ); + } +}; +template< class Derived, class T > +struct not_null_deref< Derived, T, true > +{ +}; + +template< class T > struct is_void : std11::false_type { }; +template< > struct is_void< void > : std11::true_type { }; + +template< class T > struct is_void_ptr : std11::false_type { }; +template< class T > struct is_void_ptr< T* > : is_void< typename std11::remove_cv::type > { }; + +} // namespace detail + +template< class T > +class +gsl_EMPTY_BASES_ // not strictly needed, but will become necessary if we add more base classes +not_null : public detail::not_null_deref< not_null< T >, T, detail::is_void_ptr< T >::value > +{ +private: + detail::not_null_data< T, detail::is_copyable< T >::value > data_; + + // need to access `not_null::data_` + template< class U > + friend struct detail::not_null_accessor; + + typedef detail::not_null_accessor accessor; + +public: + typedef typename detail::element_type_helper::type element_type; + +#if gsl_HAVE( TYPE_TRAITS ) + static_assert( ! std::is_reference::value, "T may not be a reference type" ); + static_assert( ! std::is_const::value && ! std::is_volatile::value, "T may not be cv-qualified" ); + static_assert( std::is_assignable::value, "T cannot be assigned nullptr" ); +#endif + +#if gsl_CONFIG( NOT_NULL_EXPLICIT_CTOR ) +# if gsl_HAVE( MOVE_FORWARD ) + template< class U + // In Clang 3.x, `is_constructible>, unique_ptr>` tries to instantiate the copy constructor of `unique_ptr<>`, triggering an error. + // Note that Apple Clang's `__clang_major__` etc. are different from regular Clang. +# if gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) && ! gsl_BETWEEN( gsl_COMPILER_CLANG_VERSION, 1, 400 ) && ! gsl_BETWEEN( gsl_COMPILER_APPLECLANG_VERSION, 1, 1001 ) + // We *have* to use SFINAE with an NTTP arg here, otherwise the overload is ambiguous. + , typename std::enable_if< ( std::is_constructible::value ), int >::type = 0 +# endif + > + gsl_api gsl_constexpr14 explicit not_null( U other ) + : data_( T( std::move( other ) ) ) + { + gsl_Expects( data_.ptr_ != gsl_nullptr ); + } +# else // a.k.a. ! gsl_HAVE( MOVE_FORWARD ) + template< class U > + gsl_api gsl_constexpr14 explicit not_null( U const& other ) + : data_( T( other ) ) + { + gsl_Expects( data_.ptr_ != gsl_nullptr ); + } +# endif // gsl_HAVE( MOVE_FORWARD ) +#else // a.k.a. !gsl_CONFIG( NOT_NULL_EXPLICIT_CTOR ) +# if gsl_HAVE( MOVE_FORWARD ) + // In Clang 3.x, `is_constructible>, unique_ptr>` tries to instantiate the copy constructor of `unique_ptr<>`, triggering an error. + // Note that Apple Clang's `__clang_major__` etc. are different from regular Clang. +# if gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) && ! gsl_BETWEEN( gsl_COMPILER_CLANG_VERSION, 1, 400 ) && ! gsl_BETWEEN( gsl_COMPILER_APPLECLANG_VERSION, 1, 1001 ) + template< class U + // We *have* to use SFINAE with an NTTP arg here, otherwise the overload is ambiguous. + , typename std::enable_if< ( std::is_constructible::value && !std::is_convertible::value ), int >::type = 0 + > + gsl_api gsl_constexpr14 explicit not_null( U other ) + : data_( T( std::move( other ) ) ) + { + gsl_Expects( data_.ptr_ != gsl_nullptr ); + } + + template< class U + // We *have* to use SFINAE with an NTTP arg here, otherwise the overload is ambiguous. + , typename std::enable_if< ( std::is_convertible::value ), int >::type = 0 + > + gsl_api gsl_constexpr14 not_null( U other ) + : data_( std::move( other ) ) + { + gsl_Expects( data_.ptr_ != gsl_nullptr ); + } +# else // a.k.a. !( gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) && ! gsl_BETWEEN( gsl_COMPILER_CLANG_VERSION, 1, 400 ) && ! gsl_BETWEEN( gsl_COMPILER_APPLECLANG_VERSION, 1, 1001 ) + // If type_traits are not available, then we can't distinguish `is_convertible<>` and `is_constructible<>`, so we unconditionally permit implicit construction. + template< class U > + gsl_api gsl_constexpr14 not_null( U other ) + : data_( T( std::move( other ) ) ) + { + gsl_Expects( data_.ptr_ != gsl_nullptr ); + } +# endif // gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) && ! gsl_BETWEEN( gsl_COMPILER_CLANG_VERSION, 1, 400 ) && ! gsl_BETWEEN( gsl_COMPILER_APPLECLANG_VERSION, 1, 1001 ) +# else // a.k.a. ! gsl_HAVE( MOVE_FORWARD ) + template< class U > + gsl_api gsl_constexpr14 not_null( U const& other ) + : data_( T( other ) ) + { + gsl_Expects( data_.ptr_ != gsl_nullptr ); + } +# endif // gsl_HAVE( MOVE_FORWARD ) +#endif // gsl_CONFIG( NOT_NULL_EXPLICIT_CTOR ) + +#if gsl_HAVE( MOVE_FORWARD ) + // In Clang 3.x, `is_constructible>, unique_ptr>` tries to instantiate the copy constructor of `unique_ptr<>`, triggering an error. + // Note that Apple Clang's `__clang_major__` etc. are different from regular Clang. +# if gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) && ! gsl_BETWEEN( gsl_COMPILER_CLANG_VERSION, 1, 400 ) && ! gsl_BETWEEN( gsl_COMPILER_APPLECLANG_VERSION, 1, 1001 ) + template< class U + // We *have* to use SFINAE with an NTTP arg here, otherwise the overload is ambiguous. + , typename std::enable_if< ( std::is_constructible::value && !std::is_convertible::value ), int >::type = 0 + > + gsl_api gsl_constexpr14 explicit not_null( not_null other ) + : data_( T( detail::not_null_accessor::get_checked( std::move( other ) ) ) ) + { + } + + template< class U + // We *have* to use SFINAE with an NTTP arg here, otherwise the overload is ambiguous. + , typename std::enable_if< ( std::is_convertible::value ), int >::type = 0 + > + gsl_api gsl_constexpr14 not_null( not_null other ) + : data_( T( detail::not_null_accessor::get_checked( std::move( other ) ) ) ) + { + } +# else // a.k.a. ! ( gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) && ! gsl_BETWEEN( gsl_COMPILER_CLANG_VERSION, 1, 400 ) && ! gsl_BETWEEN( gsl_COMPILER_APPLECLANG_VERSION, 1, 1001 ) + // If type_traits are not available, then we can't distinguish `is_convertible<>` and `is_constructible<>`, so we unconditionally permit implicit construction. + template< class U > + gsl_api gsl_constexpr14 not_null( not_null other ) + : data_( T( detail::not_null_accessor::get_checked( std::move( other ) ) ) ) + { + gsl_Expects( data_.ptr_ != gsl_nullptr ); + } + template< class U > + gsl_api gsl_constexpr14 not_null& operator=( not_null other ) + { + data_.ptr_ = detail::not_null_accessor::get_checked( std::move( other ) ); + return *this; + } +# endif // gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) && ! gsl_BETWEEN( gsl_COMPILER_CLANG_VERSION, 1, 400 ) && ! gsl_BETWEEN( gsl_COMPILER_APPLECLANG_VERSION, 1, 1001 ) +#else // a.k.a. ! gsl_HAVE( MOVE_FORWARD ) + template< class U > + gsl_api gsl_constexpr14 not_null( not_null const& other ) + : data_( T( detail::not_null_accessor::get_checked( other ) ) ) + { + } + template< class U > + gsl_api gsl_constexpr14 not_null& operator=( not_null const & other ) + { + data_.ptr_ = detail::not_null_accessor::get_checked( other ); + return *this; + } +#endif // gsl_HAVE( MOVE_FORWARD ) + +#if gsl_CONFIG( TRANSPARENT_NOT_NULL ) + gsl_NODISCARD gsl_api gsl_constexpr14 element_type * + get() const + { + return accessor::get_checked( *this ).get(); + } +#else +# if gsl_CONFIG( NOT_NULL_GET_BY_CONST_REF ) + gsl_NODISCARD gsl_api gsl_constexpr14 T const & + get() const + { + return accessor::get_checked( *this ); + } +# else + gsl_NODISCARD gsl_api gsl_constexpr14 T + get() const + { + return accessor::get_checked( *this ); + } +# endif +#endif + + // We want an implicit conversion operator that can be used to convert from both lvalues (by + // const reference or by copy) and rvalues (by move). So it seems like we could define + // + // template< class U > + // operator U const &() const & { ... } + // template< class U > + // operator U &&() && { ... } + // + // However, having two conversion operators with different return types renders the assignment + // operator of the result type ambiguous: + // + // not_null> p( ... ); + // std::unique_ptr q; + // q = std::move( p ); // ambiguous + // + // To avoid this ambiguity, we have both overloads of the conversion operator return `U` + // rather than `U const &` or `U &&`. This implies that converting an lvalue always induces + // a copy, which can cause unnecessary copies or even fail to compile in some situations: + // + // not_null> sp( ... ); + // std::shared_ptr const & rs = sp; // unnecessary copy + // std::unique_ptr const & ru = p; // error: cannot copy `unique_ptr` + // + // However, these situations are rather unusual, and the following, more frequent situations + // remain unimpaired: + // + // std::shared_ptr vs = sp; // no extra copy + // std::unique_ptr vu = std::move( p ); + +#if gsl_HAVE( MOVE_FORWARD ) && gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) && gsl_HAVE( EXPLICIT ) + // explicit conversion operator + + template< class U + // We *have* to use SFINAE with an NTTP arg here, otherwise the overload is ambiguous. + , typename std::enable_if< ( std::is_constructible::value && !std::is_convertible::value && !detail::is_not_null_or_bool_oracle::value ), int >::type = 0 + > + gsl_NODISCARD gsl_api gsl_constexpr14 explicit + operator U() const +# if gsl_HAVE( FUNCTION_REF_QUALIFIER ) + & +# endif + { + return U( accessor::get_checked( *this ) ); + } +# if gsl_HAVE( FUNCTION_REF_QUALIFIER ) + template< class U + // We *have* to use SFINAE with an NTTP arg here, otherwise the overload is ambiguous. + , typename std::enable_if< ( std::is_constructible::value && !std::is_convertible::value && !detail::is_not_null_or_bool_oracle::value ), int >::type = 0 + > + gsl_NODISCARD gsl_api gsl_constexpr14 explicit + operator U() && + { + return U( accessor::get_checked( std::move( *this ) ) ); + } +# endif + + // implicit conversion operator + template< class U + // We *have* to use SFINAE with an NTTP arg here, otherwise the overload is ambiguous. + , typename std::enable_if< ( std::is_constructible::value && std::is_convertible::value && !detail::is_not_null_or_bool_oracle::value ), int >::type = 0 + > + gsl_NODISCARD gsl_api gsl_constexpr14 + operator U() const +# if gsl_HAVE( FUNCTION_REF_QUALIFIER ) + & +# endif + { + return accessor::get_checked( *this ); + } +# if gsl_HAVE( FUNCTION_REF_QUALIFIER ) + template< class U + // We *have* to use SFINAE with an NTTP arg here, otherwise the overload is ambiguous. + , typename std::enable_if< ( std::is_convertible::value && !detail::is_not_null_or_bool_oracle::value ), int >::type = 0 + > + gsl_NODISCARD gsl_api gsl_constexpr14 + operator U() && + { + return accessor::get_checked( std::move( *this ) ); + } +# endif +#else // a.k.a. #if !( gsl_HAVE( MOVE_FORWARD ) && gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) && gsl_HAVE( EXPLICIT ) ) + template< class U > + gsl_NODISCARD gsl_api gsl_constexpr14 + operator U() const + { + return U( accessor::get_checked( *this ) ); + } +#endif // gsl_HAVE( MOVE_FORWARD ) && gsl_HAVE( TYPE_TRAITS ) && gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) && gsl_HAVE( EXPLICIT ) + + gsl_NODISCARD gsl_api gsl_constexpr14 T const & + operator->() const + { + return accessor::get_checked( *this ); + } + +#if gsl_HAVE( MOVE_FORWARD ) + // Visual C++ 2013 doesn't generate default move constructors, so we declare them explicitly. + gsl_api gsl_constexpr14 not_null( not_null && other ) + gsl_noexcept_not_testing // we want to be nothrow-movable despite the assertion + : data_( std::move( other.data_ ) ) + { + } + gsl_api gsl_constexpr14 not_null & operator=( not_null && other ) + gsl_noexcept_not_testing // we want to be nothrow-movable despite the assertion + { + data_ = std::move( other.data_ ); + return *this; + } +#endif // gsl_HAVE( MOVE_FORWARD ) + +#if gsl_HAVE( IS_DEFAULT ) + gsl_constexpr14 not_null( not_null const & ) = default; + gsl_constexpr14 not_null & operator=( not_null const & ) = default; +#endif + + gsl_api gsl_constexpr20 friend void swap( not_null & lhs, not_null & rhs ) + gsl_noexcept_not_testing // we want to be nothrow-swappable despite the precondition check + { + accessor::check( lhs ); + accessor::check( rhs ); + using std::swap; + swap( lhs.data_.ptr_, rhs.data_.ptr_ ); + } + +gsl_is_delete_access: + not_null() gsl_is_delete; + // prevent compilation when initialized with a nullptr or literal 0: +#if gsl_HAVE( NULLPTR ) + not_null( std::nullptr_t ) gsl_is_delete; + not_null & operator=( std::nullptr_t ) gsl_is_delete; +#else + not_null( int ) gsl_is_delete; + not_null & operator=( int ) gsl_is_delete; +#endif + + // unwanted operators...pointers only point to single objects! + not_null & operator++() gsl_is_delete; + not_null & operator--() gsl_is_delete; + not_null operator++( int ) gsl_is_delete; + not_null operator--( int ) gsl_is_delete; + not_null & operator+ ( size_t ) gsl_is_delete; + not_null & operator+=( size_t ) gsl_is_delete; + not_null & operator- ( size_t ) gsl_is_delete; + not_null & operator-=( size_t ) gsl_is_delete; + not_null & operator+=( std::ptrdiff_t ) gsl_is_delete; + not_null & operator-=( std::ptrdiff_t ) gsl_is_delete; + void operator[]( std::ptrdiff_t ) const gsl_is_delete; +}; +#if gsl_HAVE( DEDUCTION_GUIDES ) +template< class U > +not_null( U ) -> not_null; +template< class U > +not_null( not_null ) -> not_null; +#endif + +#if gsl_HAVE( NULLPTR ) +void make_not_null( std::nullptr_t ) gsl_is_delete; +#endif // gsl_HAVE( NULLPTR ) +#if gsl_HAVE( MOVE_FORWARD ) +template< class U > +gsl_NODISCARD gsl_api gsl_constexpr14 not_null +make_not_null( U u ) +{ + return not_null( std::move( u ) ); +} +template< class U > +gsl_NODISCARD gsl_api gsl_constexpr14 not_null +make_not_null( not_null u ) +{ + return std::move( u ); +} +#else // a.k.a. ! gsl_HAVE( MOVE_FORWARD ) +template< class U > +gsl_NODISCARD gsl_api not_null +make_not_null( U const & u ) +{ + return not_null( u ); +} +template< class U > +gsl_NODISCARD gsl_api not_null +make_not_null( not_null const & u ) +{ + return u; +} +#endif // gsl_HAVE( MOVE_FORWARD ) + +namespace detail { + +template< class T > +struct as_nullable_helper +{ + typedef T type; +}; +template< class T > +struct as_nullable_helper< not_null > +{ +}; + +template< class T > +struct not_null_accessor +{ +#if gsl_HAVE( MOVE_FORWARD ) + static gsl_api T get( not_null&& p ) gsl_noexcept + { + return std::move( p.data_.ptr_ ); + } + static gsl_api T get_checked( not_null&& p ) + { + gsl_Assert( p.data_.ptr_ != gsl_nullptr ); + return std::move( p.data_.ptr_ ); + } +#endif + static gsl_api T const & get( not_null const & p ) gsl_noexcept + { + return p.data_.ptr_; + } + static gsl_api bool is_valid( not_null const & p ) gsl_noexcept + { + return p.data_.ptr_ != gsl_nullptr; + } + static gsl_api void check( not_null const & p ) + { + gsl_Assert( p.data_.ptr_ != gsl_nullptr ); + } + static gsl_api T const & get_checked( not_null const & p ) + { + gsl_Assert( p.data_.ptr_ != gsl_nullptr ); + return p.data_.ptr_; + } +}; +template< class T > +struct not_null_accessor< T * > +{ + static gsl_api T * const & get( not_null< T * > const & p ) gsl_noexcept + { + return p.data_.ptr_; + } + static gsl_api bool is_valid( not_null< T * > const & /*p*/ ) gsl_noexcept + { + return true; + } + static gsl_api void check( not_null< T * > const & /*p*/ ) + { + } + static gsl_api T * const & get_checked( not_null< T * > const & p ) gsl_noexcept + { + return p.data_.ptr_; + } +}; + +namespace no_adl { + +#if gsl_HAVE( MOVE_FORWARD ) +template< class T > +gsl_NODISCARD gsl_api gsl_constexpr auto as_nullable( T && p ) +gsl_noexcept_if( std::is_nothrow_move_constructible::value ) +-> typename detail::as_nullable_helper::type>::type +{ + return std::move( p ); +} +template< class T > +gsl_NODISCARD gsl_api gsl_constexpr14 T as_nullable( not_null && p ) +{ + return detail::not_null_accessor::get_checked( std::move( p ) ); +} +#else // ! gsl_HAVE( MOVE_FORWARD ) +template< class T > +gsl_NODISCARD gsl_api gsl_constexpr T const & as_nullable( T const & p ) gsl_noexcept +{ + return p; +} +#endif // gsl_HAVE( MOVE_FORWARD ) +template< class T > +gsl_NODISCARD gsl_api gsl_constexpr14 T const & +as_nullable( not_null const & p ) +{ + return detail::not_null_accessor::get_checked( p ); +} + +template< class T > +gsl_NODISCARD gsl_api gsl_constexpr bool +is_valid( not_null const & p ) +{ + return detail::not_null_accessor::is_valid( p ); +} + +} // namespace no_adl +} // namespace detail + +using namespace detail::no_adl; + +// not_null with implicit constructor, allowing copy-initialization: + +template< class T > +class not_null_ic : public not_null +{ +public: + template< class U + gsl_ENABLE_IF_(( std::is_constructible::value )) + > + gsl_api gsl_constexpr14 +#if gsl_HAVE( MOVE_FORWARD ) + not_null_ic( U u ) + : not_null( std::move( u ) ) +#else // ! gsl_HAVE( MOVE_FORWARD ) + not_null_ic( U const & u ) + : not_null( u ) +#endif // gsl_HAVE( MOVE_FORWARD ) + {} +}; + +// more not_null unwanted operators + +template< class T, class U > +std::ptrdiff_t operator-( not_null const &, not_null const & ) gsl_is_delete; + +template< class T > +not_null operator-( not_null const &, std::ptrdiff_t ) gsl_is_delete; + +template< class T > +not_null operator+( not_null const &, std::ptrdiff_t ) gsl_is_delete; + +template< class T > +not_null operator+( std::ptrdiff_t, not_null const & ) gsl_is_delete; + +// not_null comparisons + +#if gsl_HAVE( NULLPTR ) && gsl_HAVE( IS_DELETE ) +template< class T > +gsl_constexpr bool +operator==( not_null const &, std::nullptr_t ) = delete; +template< class T > +gsl_constexpr bool +operator==( std::nullptr_t , not_null const & ) = delete; +template< class T > +gsl_constexpr bool +operator!=( not_null const &, std::nullptr_t ) = delete; +template< class T > +gsl_constexpr bool +operator!=( std::nullptr_t , not_null const & ) = delete; +#endif // gsl_HAVE( NULLPTR ) && gsl_HAVE( IS_DELETE ) + +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator==( not_null const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( l.operator->() == r.operator->() ) +{ + return l.operator->() == r.operator->(); +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator==( not_null const & l, U const & r ) +gsl_RETURN_DECLTYPE_(l.operator->() == r ) +{ + return l.operator->() == r; +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator==( T const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( l == r.operator->() ) +{ + return l == r.operator->(); +} + +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator<( not_null const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( l.operator->() < r.operator->() ) +{ + return l.operator->() < r.operator->(); +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator<( not_null const & l, U const & r ) +gsl_RETURN_DECLTYPE_( l.operator->() < r ) +{ + return l.operator->() < r; +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator<( T const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( l < r.operator->() ) +{ + return l < r.operator->(); +} + +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator!=( not_null const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( !( l == r ) ) +{ + return !( l == r ); +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator!=( not_null const & l, U const & r ) +gsl_RETURN_DECLTYPE_( !( l == r ) ) +{ + return !( l == r ); +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator!=( T const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( !( l == r ) ) +{ + return !( l == r ); +} + +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator<=( not_null const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( !( r < l ) ) +{ + return !( r < l ); +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator<=( not_null const & l, U const & r ) +gsl_RETURN_DECLTYPE_( !( r < l ) ) +{ + return !( r < l ); +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator<=( T const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( !( r < l ) ) +{ + return !( r < l ); +} + +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator>( not_null const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( r < l ) +{ + return r < l; +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator>( not_null const & l, U const & r ) +gsl_RETURN_DECLTYPE_( r < l ) +{ + return r < l; +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator>( T const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( r < l ) +{ + return r < l; +} + +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator>=( not_null const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( !( l < r ) ) +{ + return !( l < r ); +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator>=( not_null const & l, U const & r ) +gsl_RETURN_DECLTYPE_( !( l < r ) ) +{ + return !( l < r ); +} +template< class T, class U > +gsl_NODISCARD inline gsl_api gsl_constexpr gsl_TRAILING_RETURN_TYPE_( bool ) +operator>=( T const & l, not_null const & r ) +gsl_RETURN_DECLTYPE_( !( l < r ) ) +{ + return !( l < r ); +} + +// print not_null + +template< class CharType, class Traits, class T > +std::basic_ostream< CharType, Traits > & operator<<( std::basic_ostream< CharType, Traits > & os, not_null const & p ) +{ + return os << p.operator->(); +} + + +#if gsl_HAVE( VARIADIC_TEMPLATE ) +# if gsl_HAVE( UNIQUE_PTR ) +template< class T, class... Args > +gsl_NODISCARD not_null> +make_unique( Args &&... args ) +{ +# if gsl_HAVE( TYPE_TRAITS ) + static_assert( !std::is_array::value, "gsl::make_unique() returns `gsl::not_null>`, which is not " + "defined for array types because the Core Guidelines advise against pointer arithmetic, cf. \"Bounds safety profile\"." ); +# endif + return not_null>( new T( std::forward( args )... ) ); +} +# endif // gsl_HAVE( UNIQUE_PTR ) +# if gsl_HAVE( SHARED_PTR ) +template< class T, class... Args > +gsl_NODISCARD not_null> +make_shared( Args &&... args ) +{ +# if gsl_HAVE( TYPE_TRAITS ) + static_assert( !std::is_array::value, "gsl::make_shared() returns `gsl::not_null>`, which is not " + "defined for array types because the Core Guidelines advise against pointer arithmetic, cf. \"Bounds safety profile\"." ); +# endif + return not_null>( std::make_shared( std::forward( args )... ) ); +} +# endif // gsl_HAVE( SHARED_PTR ) +#endif // gsl_HAVE( VARIADIC_TEMPLATE ) + + +// +// Byte-specific type. +// +#if gsl_HAVE( ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE ) + enum class gsl_may_alias byte : unsigned char {}; +#else + struct gsl_may_alias byte { typedef unsigned char type; type v; }; +#endif + +template< class T > +gsl_NODISCARD gsl_api inline gsl_constexpr byte +to_byte( T v ) gsl_noexcept +{ +#if gsl_HAVE( ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE ) + return static_cast( v ); +#elif gsl_HAVE( CONSTEXPR_11 ) + return { static_cast( v ) }; +#else + byte b = { static_cast( v ) }; return b; +#endif +} + +template< class IntegerType gsl_ENABLE_IF_(( std::is_integral::value )) > +gsl_NODISCARD gsl_api inline gsl_constexpr IntegerType +to_integer( byte b ) gsl_noexcept +{ +#if gsl_HAVE( ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE ) + return static_cast::type>( b ); +#else + return b.v; +#endif +} + +gsl_NODISCARD gsl_api inline gsl_constexpr unsigned char +to_uchar( byte b ) gsl_noexcept +{ + return to_integer( b ); +} + +gsl_NODISCARD gsl_api inline gsl_constexpr unsigned char +to_uchar( int i ) gsl_noexcept +{ + return static_cast( i ); +} + +template< class IntegerType gsl_ENABLE_IF_(( std::is_integral::value )) > +gsl_api inline gsl_constexpr14 byte & +operator<<=( byte & b, IntegerType shift ) gsl_noexcept +{ +#if gsl_HAVE( ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE ) + return b = ::gsl::to_byte( ::gsl::to_uchar( b ) << shift ); +#else + b.v = ::gsl::to_uchar( b.v << shift ); return b; +#endif +} + +template< class IntegerType gsl_ENABLE_IF_(( std::is_integral::value )) > +gsl_NODISCARD gsl_api inline gsl_constexpr byte +operator<<( byte b, IntegerType shift ) gsl_noexcept +{ + return ::gsl::to_byte( ::gsl::to_uchar( b ) << shift ); +} + +template< class IntegerType gsl_ENABLE_IF_(( std::is_integral::value )) > +gsl_NODISCARD gsl_api inline gsl_constexpr14 byte & +operator>>=( byte & b, IntegerType shift ) gsl_noexcept +{ +#if gsl_HAVE( ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE ) + return b = ::gsl::to_byte( ::gsl::to_uchar( b ) >> shift ); +#else + b.v = ::gsl::to_uchar( b.v >> shift ); return b; +#endif +} + +template< class IntegerType gsl_ENABLE_IF_(( std::is_integral::value )) > +gsl_NODISCARD gsl_api inline gsl_constexpr byte +operator>>( byte b, IntegerType shift ) gsl_noexcept +{ + return ::gsl::to_byte( ::gsl::to_uchar( b ) >> shift ); +} + +#if gsl_HAVE( ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE ) +gsl_DEFINE_ENUM_BITMASK_OPERATORS( byte ) +gsl_DEFINE_ENUM_RELATIONAL_OPERATORS( byte ) +#else // a.k.a. !gsl_HAVE( ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE ) +gsl_api inline gsl_constexpr bool operator==( byte l, byte r ) gsl_noexcept +{ + return l.v == r.v; +} + +gsl_api inline gsl_constexpr bool operator!=( byte l, byte r ) gsl_noexcept +{ + return !( l == r ); +} + +gsl_api inline gsl_constexpr bool operator< ( byte l, byte r ) gsl_noexcept +{ + return l.v < r.v; +} + +gsl_api inline gsl_constexpr bool operator<=( byte l, byte r ) gsl_noexcept +{ + return !( r < l ); +} + +gsl_api inline gsl_constexpr bool operator> ( byte l, byte r ) gsl_noexcept +{ + return ( r < l ); +} + +gsl_api inline gsl_constexpr bool operator>=( byte l, byte r ) gsl_noexcept +{ + return !( l < r ); +} + +gsl_api inline gsl_constexpr14 byte & operator|=( byte & l, byte r ) gsl_noexcept +{ + l.v |= r.v; return l; +} + +gsl_api inline gsl_constexpr byte operator|( byte l, byte r ) gsl_noexcept +{ + return ::gsl::to_byte( l.v | r.v ); +} + +gsl_api inline gsl_constexpr14 byte & operator&=( byte & l, byte r ) gsl_noexcept +{ + l.v &= r.v; return l; +} + +gsl_api inline gsl_constexpr byte operator&( byte l, byte r ) gsl_noexcept +{ + return ::gsl::to_byte( l.v & r.v ); +} + +gsl_api inline gsl_constexpr14 byte & operator^=( byte & l, byte r ) gsl_noexcept +{ + l.v ^= r.v; return l; +} + +gsl_api inline gsl_constexpr byte operator^( byte l, byte r ) gsl_noexcept +{ + return ::gsl::to_byte( l.v ^ r.v ); +} + +gsl_api inline gsl_constexpr byte operator~( byte b ) gsl_noexcept +{ + return ::gsl::to_byte( ~b.v ); +} +#endif // gsl_HAVE( ENUM_CLASS_CONSTRUCTION_FROM_UNDERLYING_TYPE ) + +#if gsl_FEATURE_TO_STD( WITH_CONTAINER ) + +// Tag to select span constructor taking a container: + +struct with_container_t { gsl_constexpr with_container_t( ) gsl_noexcept { } }; +const gsl_constexpr with_container_t with_container; // TODO: this can lead to ODR violations because the symbol will be defined in multiple translation units + +#endif + +namespace detail { + +template< class T > +gsl_api gsl_constexpr14 T * endptr( T * data, gsl_CONFIG_SPAN_INDEX_TYPE size ) +{ + // Be sure to run the check before doing pointer arithmetics, which would be UB for `nullptr` and non-0 integers. + gsl_Expects( size == 0 || data != gsl_nullptr ); + return data + size; +} + +} // namespace detail + +// +// span<> - A 1D view of contiguous T's, replace (*,len). +// +template< class T > +class span +{ + template< class U > friend class span; + +public: + typedef gsl_CONFIG_SPAN_INDEX_TYPE index_type; + + typedef T element_type; + typedef typename std11::remove_cv< T >::type value_type; + + typedef T & reference; + typedef T * pointer; + typedef T const * const_pointer; + typedef T const & const_reference; + + typedef pointer iterator; + typedef const_pointer const_iterator; + + typedef std::reverse_iterator< iterator > reverse_iterator; + typedef std::reverse_iterator< const_iterator > const_reverse_iterator; + + typedef gsl_CONFIG_SPAN_INDEX_TYPE size_type; + typedef std::ptrdiff_t difference_type; + + // 26.7.3.2 Constructors, copy, and assignment [span.cons] + + gsl_api gsl_constexpr span() gsl_noexcept + : first_( gsl_nullptr ) + , last_ ( gsl_nullptr ) + { + } + +#if ! gsl_DEPRECATE_TO_LEVEL( 5 ) + +#if gsl_HAVE( NULLPTR ) + gsl_api gsl_constexpr14 span( std::nullptr_t, index_type size_in ) + : first_( nullptr ) + , last_ ( nullptr ) + { + gsl_Expects( size_in == 0 ); + } +#endif + +#if gsl_HAVE( IS_DELETE ) + gsl_DEPRECATED + gsl_api gsl_constexpr span( reference data_in ) + : span( &data_in, 1 ) + {} + + gsl_api gsl_constexpr span( element_type && ) = delete; +#endif + +#endif // deprecate + + gsl_api gsl_constexpr14 span( pointer data_in, index_type size_in ) + : first_( data_in ) + , last_( detail::endptr( data_in, size_in ) ) + { + } + + gsl_api gsl_constexpr14 span( pointer first_in, pointer last_in ) + : first_( first_in ) + , last_ ( last_in ) + { + gsl_Expects( first_in <= last_in ); + } + +#if ! gsl_DEPRECATE_TO_LEVEL( 5 ) + + template< class U > + gsl_api gsl_constexpr14 span( U * data_in, index_type size_in ) + : first_( data_in ) + , last_( detail::endptr( data_in, size_in ) ) + { + } + +#endif // deprecate + +#if ! gsl_DEPRECATE_TO_LEVEL( 5 ) + template< class U, size_t N > + gsl_api gsl_constexpr span( U (&arr)[N] ) gsl_noexcept + : first_( gsl_ADDRESSOF( arr[0] ) ) + , last_ ( gsl_ADDRESSOF( arr[0] ) + N ) + {} +#else + template< size_t N + gsl_ENABLE_IF_(( std::is_convertible::value )) + > + gsl_api gsl_constexpr span( element_type (&arr)[N] ) gsl_noexcept + : first_( gsl_ADDRESSOF( arr[0] ) ) + , last_ ( gsl_ADDRESSOF( arr[0] ) + N ) + {} +#endif // deprecate + +#if gsl_HAVE( ARRAY ) +#if ! gsl_DEPRECATE_TO_LEVEL( 5 ) + + template< class U, size_t N > + gsl_api gsl_constexpr span( std::array< U, N > & arr ) + : first_( arr.data() ) + , last_ ( arr.data() + N ) + {} + + template< class U, size_t N > + gsl_api gsl_constexpr span( std::array< U, N > const & arr ) + : first_( arr.data() ) + , last_ ( arr.data() + N ) + {} + +#else + + template< size_t N + gsl_ENABLE_IF_(( std::is_convertible::value )) + > + gsl_constexpr span( std::array< value_type, N > & arr ) + : first_( arr.data() ) + , last_ ( arr.data() + N ) + {} + + template< size_t N + gsl_ENABLE_IF_(( std::is_convertible::value )) + > + gsl_constexpr span( std::array< value_type, N > const & arr ) + : first_( arr.data() ) + , last_ ( arr.data() + N ) + {} + +#endif // deprecate +#endif // gsl_HAVE( ARRAY ) + +#if gsl_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR ) + template< class Container + gsl_ENABLE_IF_(( detail::is_compatible_container< Container, element_type >::value )) + > + gsl_api gsl_constexpr span( Container & cont ) gsl_noexcept + : first_( std17::data( cont ) ) + , last_ ( std17::data( cont ) + std17::size( cont ) ) + {} + + template< class Container + gsl_ENABLE_IF_(( + std::is_const< element_type >::value + && detail::is_compatible_container< Container, element_type >::value + )) + > + gsl_api gsl_constexpr span( Container const & cont ) gsl_noexcept + : first_( std17::data( cont ) ) + , last_ ( std17::data( cont ) + std17::size( cont ) ) + {} + +#elif gsl_HAVE( UNCONSTRAINED_SPAN_CONTAINER_CTOR ) + + template< class Container > + gsl_constexpr span( Container & cont ) + : first_( cont.size() == 0 ? gsl_nullptr : gsl_ADDRESSOF( cont[0] ) ) + , last_ ( cont.size() == 0 ? gsl_nullptr : gsl_ADDRESSOF( cont[0] ) + cont.size() ) + {} + + template< class Container > + gsl_constexpr span( Container const & cont ) + : first_( cont.size() == 0 ? gsl_nullptr : gsl_ADDRESSOF( cont[0] ) ) + , last_ ( cont.size() == 0 ? gsl_nullptr : gsl_ADDRESSOF( cont[0] ) + cont.size() ) + {} + +#endif + +#if gsl_FEATURE_TO_STD( WITH_CONTAINER ) + + template< class Container > + gsl_constexpr span( with_container_t, Container & cont ) gsl_noexcept + : first_( cont.size() == 0 ? gsl_nullptr : gsl_ADDRESSOF( cont[0] ) ) + , last_ ( cont.size() == 0 ? gsl_nullptr : gsl_ADDRESSOF( cont[0] ) + cont.size() ) + {} + + template< class Container > + gsl_constexpr span( with_container_t, Container const & cont ) gsl_noexcept + : first_( cont.size() == 0 ? gsl_nullptr : gsl_ADDRESSOF( cont[0] ) ) + , last_ ( cont.size() == 0 ? gsl_nullptr : gsl_ADDRESSOF( cont[0] ) + cont.size() ) + {} + +#endif + +#if !gsl_DEPRECATE_TO_LEVEL( 4 ) + // constructor taking shared_ptr deprecated since 0.29.0 + +# if gsl_HAVE( SHARED_PTR ) + gsl_DEPRECATED + gsl_constexpr span( shared_ptr const & ptr ) + : first_( ptr.get() ) + , last_ ( ptr.get() ? ptr.get() + 1 : gsl_nullptr ) + {} +# endif + + // constructors taking unique_ptr deprecated since 0.29.0 + +# if gsl_HAVE( UNIQUE_PTR ) +# if gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) + template< class ArrayElementType = typename std::add_pointer::type > +# else + template< class ArrayElementType > +# endif + gsl_DEPRECATED + gsl_constexpr span( unique_ptr const & ptr, index_type count ) + : first_( ptr.get() ) + , last_ ( ptr.get() + count ) + {} + + gsl_DEPRECATED + gsl_constexpr span( unique_ptr const & ptr ) + : first_( ptr.get() ) + , last_ ( ptr.get() ? ptr.get() + 1 : gsl_nullptr ) + {} +# endif + +#endif // deprecate shared_ptr, unique_ptr + +#if gsl_HAVE( IS_DEFAULT ) && ! gsl_BETWEEN( gsl_COMPILER_GNUC_VERSION, 430, 600) + gsl_constexpr span( span && ) gsl_noexcept = default; + gsl_constexpr span( span const & ) = default; +#else + gsl_api gsl_constexpr span( span const & other ) + : first_( other.begin() ) + , last_ ( other.end() ) + {} +#endif + +#if gsl_HAVE( IS_DEFAULT ) + gsl_constexpr14 span & operator=( span && ) gsl_noexcept = default; + gsl_constexpr14 span & operator=( span const & ) gsl_noexcept = default; +#else + gsl_constexpr14 span & operator=( span other ) gsl_noexcept + { + first_ = other.first_; + last_ = other.last_; + return *this; + } +#endif + + template< class U + gsl_ENABLE_IF_(( std::is_convertible::value )) + > + gsl_api gsl_constexpr span( span const & other ) + : first_( other.begin() ) + , last_ ( other.end() ) + {} + +#if 0 + // Converting from other span ? + template< class U > operator=(); +#endif + + // 26.7.3.3 Subviews [span.sub] + + gsl_NODISCARD gsl_api gsl_constexpr14 span + first( index_type count ) const + { + gsl_Expects( std::size_t( count ) <= std::size_t( this->size() ) ); + return span( this->data(), count ); + } + + gsl_NODISCARD gsl_api gsl_constexpr14 span + last( index_type count ) const + { + gsl_Expects( std::size_t( count ) <= std::size_t( this->size() ) ); + return span( this->data() + this->size() - count, count ); + } + + gsl_NODISCARD gsl_api gsl_constexpr14 span + subspan( index_type offset ) const + { + gsl_Expects( std::size_t( offset ) <= std::size_t( this->size() ) ); + return span( this->data() + offset, this->size() - offset ); + } + + gsl_NODISCARD gsl_api gsl_constexpr14 span + subspan( index_type offset, index_type count ) const + { + gsl_Expects( + std::size_t( offset ) <= std::size_t( this->size() ) && + std::size_t( count ) <= std::size_t( this->size() - offset ) ); + return span( this->data() + offset, count ); + } + + // 26.7.3.4 Observers [span.obs] + + gsl_NODISCARD gsl_api gsl_constexpr index_type + size() const gsl_noexcept + { + return narrow_cast( last_ - first_ ); + } + + gsl_NODISCARD gsl_api gsl_constexpr std::ptrdiff_t + ssize() const gsl_noexcept + { + return narrow_cast( last_ - first_ ); + } + + gsl_NODISCARD gsl_api gsl_constexpr index_type + size_bytes() const gsl_noexcept + { + return size() * narrow_cast( sizeof( element_type ) ); + } + + gsl_NODISCARD gsl_api gsl_constexpr bool + empty() const gsl_noexcept + { + return size() == 0; + } + + // 26.7.3.5 Element access [span.elem] + + gsl_NODISCARD gsl_api gsl_constexpr14 reference + operator[]( index_type pos ) const + { + gsl_Expects( pos < size() ); + return first_[ pos ]; + } + +#if ! gsl_DEPRECATE_TO_LEVEL( 6 ) + gsl_DEPRECATED_MSG("use subscript indexing instead") + gsl_api gsl_constexpr14 reference + operator()( index_type pos ) const + { + return (*this)[ pos ]; + } + + gsl_DEPRECATED_MSG("use subscript indexing instead") + gsl_api gsl_constexpr14 reference + at( index_type pos ) const + { + return (*this)[ pos ]; + } +#endif // deprecate + + gsl_NODISCARD gsl_api gsl_constexpr14 reference + front() const + { + gsl_Expects( first_ != last_ ); + return *first_; + } + + gsl_NODISCARD gsl_api gsl_constexpr14 reference + back() const + { + gsl_Expects( first_ != last_ ); + return *(last_ - 1); + } + + gsl_NODISCARD gsl_api gsl_constexpr pointer + data() const gsl_noexcept + { + return first_; + } + + // 26.7.3.6 Iterator support [span.iterators] + + gsl_NODISCARD gsl_api gsl_constexpr iterator + begin() const gsl_noexcept + { + return iterator( first_ ); + } + + gsl_NODISCARD gsl_api gsl_constexpr iterator + end() const gsl_noexcept + { + return iterator( last_ ); + } + + gsl_NODISCARD gsl_api gsl_constexpr const_iterator + cbegin() const gsl_noexcept + { +#if gsl_CPP11_OR_GREATER + return { begin() }; +#else + return const_iterator( begin() ); +#endif + } + + gsl_NODISCARD gsl_api gsl_constexpr const_iterator + cend() const gsl_noexcept + { +#if gsl_CPP11_OR_GREATER + return { end() }; +#else + return const_iterator( end() ); +#endif + } + + gsl_NODISCARD gsl_constexpr17 reverse_iterator + rbegin() const gsl_noexcept + { + return reverse_iterator( end() ); + } + + gsl_NODISCARD gsl_constexpr17 reverse_iterator + rend() const gsl_noexcept + { + return reverse_iterator( begin() ); + } + + gsl_NODISCARD gsl_constexpr17 const_reverse_iterator + crbegin() const gsl_noexcept + { + return const_reverse_iterator( cend() ); + } -#ifndef gsl_CONFIG_THROWS_FOR_TESTING -# define gsl_CONFIG_THROWS_FOR_TESTING 0 -#endif + gsl_NODISCARD gsl_constexpr17 const_reverse_iterator + crend() const gsl_noexcept + { + return const_reverse_iterator( cbegin() ); + } -#ifndef gsl_CONFIG_CONFIRMS_COMPILATION_ERRORS -# define gsl_CONFIG_CONFIRMS_COMPILATION_ERRORS 0 -#endif + gsl_constexpr14 void swap( span & other ) gsl_noexcept + { + std::swap( first_, other.first_ ); + std::swap( last_ , other.last_ ); + } -// Compiler detection: +#if ! gsl_DEPRECATE_TO_LEVEL( 3 ) + // member length() deprecated since 0.29.0 -#if defined(_MSC_VER) -# define gsl_COMPILER_MSVC_VERSION (_MSC_VER / 100 - 5 - (_MSC_VER < 1900)) -#else -# define gsl_COMPILER_MSVC_VERSION 0 -# define gsl_COMPILER_NON_MSVC 1 -#endif + gsl_DEPRECATED_MSG("use size() instead") + gsl_api gsl_constexpr index_type length() const gsl_noexcept + { + return size(); + } -#if ( __cplusplus >= 201103L ) -# define gsl_CPP11_OR_GREATER 1 -#endif + // member length_bytes() deprecated since 0.29.0 -#if ( __cplusplus >= 201402L ) -# define gsl_CPP14_OR_GREATER 1 + gsl_DEPRECATED_MSG("use size_bytes() instead") + gsl_api gsl_constexpr index_type length_bytes() const gsl_noexcept + { + return size_bytes(); + } #endif -// half-open range [lo..hi): -#define gsl_BETWEEN( v, lo, hi ) ( lo <= v && v < hi ) +#if ! gsl_DEPRECATE_TO_LEVEL( 2 ) + // member as_bytes(), as_writeable_bytes deprecated since 0.17.0 -// Presence of C++ language features: + gsl_DEPRECATED_MSG("use free function gsl::as_bytes() instead") + gsl_api span< const byte > as_bytes() const gsl_noexcept + { + return span< const byte >( reinterpret_cast( data() ), size_bytes() ); // NOLINT + } -#if gsl_CPP11_OR_GREATER -# define gsl_HAVE_ALIAS_TEMPLATE 1 -#endif + gsl_DEPRECATED_MSG("use free function gsl::as_writable_bytes() instead") + gsl_api span< byte > as_writeable_bytes() const gsl_noexcept + { + return span< byte >( reinterpret_cast( data() ), size_bytes() ); // NOLINT + } -#if gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VERSION >= 10 -# define gsl_HAVE_AUTO 1 #endif -#if gsl_CPP11_OR_GREATER -# define gsl_HAVE_CONSTEXPR_11 1 -#endif + template< class U > + gsl_NODISCARD gsl_api span< U > + as_span() const + { + gsl_Expects( ( this->size_bytes() % sizeof(U) ) == 0 ); + return span< U >( reinterpret_cast( this->data() ), this->size_bytes() / sizeof( U ) ); // NOLINT + } -#if gsl_CPP14_OR_GREATER -# define gsl_HAVE_CONSTEXPR_14 1 -#endif +private: + pointer first_; + pointer last_; +}; -#if gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VERSION >= 14 -# define gsl_HAVE_ENUM_CLASS 1 -#endif +// class template argument deduction guides: -#if gsl_CPP11_OR_GREATER -# define gsl_HAVE_IS_DEFAULT_CTOR 1 -#endif +#if gsl_HAVE( DEDUCTION_GUIDES ) // gsl_CPP17_OR_GREATER -#if gsl_CPP11_OR_GREATER -# define gsl_HAVE_EXPLICIT_CONVERSION 1 -#endif +template< class T, size_t N > +span( T (&)[N] ) -> span; -#if gsl_CPP11_OR_GREATER -# define gsl_HAVE_INITIALIZER_LIST 1 -#endif +template< class T, size_t N > +span( std::array & ) -> span; -#if gsl_CPP11_OR_GREATER -# define gsl_HAVE_NOEXCEPT 1 -#endif +template< class T, size_t N > +span( std::array const & ) -> span; -#if gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VERSION >= 10 -# define gsl_HAVE_NULLPTR 1 -#endif +template< class Container > +span( Container& ) -> span; -// Presence of C++ library features: +template< class Container > +span( Container const & ) -> span; -#if gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VERSION >= 11 -# define gsl_HAVE_ARRAY 1 -#endif +#endif // gsl_HAVE( DEDUCTION_GUIDES ) -#if gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VERSION >= 9 -# define gsl_HAVE_CONTAINER_DATA_METHOD 1 -#endif +// 26.7.3.7 Comparison operators [span.comparison] -#if gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VERSION >= 14 -# define gsl_HAVE_SIZED_TYPES 1 -#endif +#if gsl_CONFIG( ALLOWS_SPAN_COMPARISON ) +# if gsl_CONFIG( ALLOWS_NONSTRICT_SPAN_COMPARISON ) -#if gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VERSION >= 10 -# define gsl_HAVE_SHARED_PTR 1 -# define gsl_HAVE_UNIQUE_PTR 1 -#endif +template< class T, class U > +gsl_SUPPRESS_MSGSL_WARNING(stl.1) +gsl_NODISCARD inline gsl_constexpr bool operator==( span const & l, span const & r ) +{ + return l.size() == r.size() + && (l.begin() == r.begin() || detail::equal( l.begin(), l.end(), r.begin() ) ); +} -#if gsl_CPP11_OR_GREATER || gsl_COMPILER_MSVC_VERSION >= 11 -# define gsl_HAVE_TYPE_TRAITS 1 -#endif +template< class T, class U > +gsl_SUPPRESS_MSGSL_WARNING(stl.1) +gsl_NODISCARD inline gsl_constexpr bool operator< ( span const & l, span const & r ) +{ + return detail::lexicographical_compare( l.begin(), l.end(), r.begin(), r.end() ); +} -// For the rest, consider VC12, VC14 as C++11 for GSL Lite: +# else // a.k.a. !gsl_CONFIG( ALLOWS_NONSTRICT_SPAN_COMPARISON ) -#if gsl_COMPILER_MSVC_VERSION >= 12 -# undef gsl_CPP11_OR_GREATER -# define gsl_CPP11_OR_GREATER 1 -#endif +template< class T > +gsl_SUPPRESS_MSGSL_WARNING(stl.1) +gsl_NODISCARD inline gsl_constexpr bool operator==( span const & l, span const & r ) +{ + return l.size() == r.size() + && (l.begin() == r.begin() || detail::equal( l.begin(), l.end(), r.begin() ) ); +} -// C++ feature usage: +template< class T > +gsl_SUPPRESS_MSGSL_WARNING(stl.1) +gsl_NODISCARD inline gsl_constexpr bool operator< ( span const & l, span const & r ) +{ + return detail::lexicographical_compare( l.begin(), l.end(), r.begin(), r.end() ); +} +# endif // gsl_CONFIG( ALLOWS_NONSTRICT_SPAN_COMPARISON ) -#if gsl_HAVE_CONSTEXPR_11 -# define gsl_constexpr constexpr -#else -# define gsl_constexpr /*nothing*/ -#endif +template< class T, class U > +gsl_NODISCARD inline gsl_constexpr bool operator!=( span const & l, span const & r ) +{ + return !( l == r ); +} -#if gsl_HAVE_CONSTEXPR_14 -# define gsl_constexpr14 constexpr -#else -# define gsl_constexpr14 /*nothing*/ -#endif +template< class T, class U > +gsl_NODISCARD inline gsl_constexpr bool operator<=( span const & l, span const & r ) +{ + return !( r < l ); +} -#if gsl_HAVE_EXPLICIT_CONVERSION -# define gsl_explicit explicit -#else -# define gsl_explicit /*nothing*/ -#endif +template< class T, class U > +gsl_NODISCARD inline gsl_constexpr bool operator> ( span const & l, span const & r ) +{ + return ( r < l ); +} -#if gsl_FEATURE_HAVE_IMPLICIT_MACRO -# define implicit -#endif +template< class T, class U > +gsl_NODISCARD inline gsl_constexpr bool operator>=( span const & l, span const & r ) +{ + return !( l < r ); +} +#endif // gsl_CONFIG( ALLOWS_SPAN_COMPARISON ) -#if !gsl_HAVE_NOEXCEPT || gsl_CONFIG_THROWS_FOR_TESTING -# define gsl_noexcept /*nothing*/ -#else -# define gsl_noexcept noexcept -#endif +// span algorithms -#define gsl_DIMENSION_OF( a ) ( sizeof(a) / sizeof(0[a]) ) +template< class T > +gsl_NODISCARD gsl_api inline gsl_constexpr std::size_t +size( span const & spn ) +{ + return static_cast( spn.size() ); +} -#if gsl_HAVE_ARRAY -# include -#endif +template< class T > +gsl_NODISCARD gsl_api inline gsl_constexpr std::ptrdiff_t +ssize( span const & spn ) +{ + return spn.ssize(); +} -#if gsl_HAVE_TYPE_TRAITS -# include -#endif +namespace detail { -namespace gsl { +template< class II, class N, class OI > +gsl_api gsl_constexpr14 inline OI copy_n( II first, N count, OI result ) +{ + if ( count > 0 ) + { + *result++ = *first; + for ( N i = 1; i < count; ++i ) + { + *result++ = *++first; + } + } + return result; +} +} -// -// GSL.owner: ownership pointers -// -#if gsl_HAVE_SHARED_PTR - using std::unique_ptr; - using std::shared_ptr; +template< class T, class U > +gsl_api gsl_constexpr14 inline void copy( span src, span dest ) +{ +#if gsl_CPP14_OR_GREATER // gsl_HAVE( TYPE_TRAITS ) (circumvent Travis clang 3.4) + static_assert( std::is_assignable::value, "Cannot assign elements of source span to elements of destination span" ); #endif + gsl_Expects( dest.size() >= src.size() ); + detail::copy_n( src.data(), src.size(), dest.data() ); +} -#if gsl_HAVE_ALIAS_TEMPLATE - template< class T > using owner = T; -#else - template< class T > struct owner { typedef T type; }; -#endif +// span creator functions (see ctors) -#define gsl_HAVE_OWNER_TEMPLATE gsl_HAVE_ALIAS_TEMPLATE +template< class T > +gsl_NODISCARD gsl_api inline span< const byte > +as_bytes( span spn ) gsl_noexcept +{ + return span< const byte >( reinterpret_cast( spn.data() ), spn.size_bytes() ); // NOLINT +} -#if gsl_FEATURE_HAVE_OWNER_MACRO -# if gsl_HAVE_OWNER_TEMPLATE -# define Owner(t) ::gsl::owner -# else -# define Owner(t) ::gsl::owner::type -# endif -#endif +template< class T> +gsl_NODISCARD gsl_api inline span< byte > +as_writable_bytes( span spn ) gsl_noexcept +{ + return span< byte >( reinterpret_cast( spn.data() ), spn.size_bytes() ); // NOLINT +} -// -// GSL.assert: assertions -// -#define Expects(x) ::gsl::fail_fast_assert((x)) -#define Ensures(x) ::gsl::fail_fast_assert((x)) +#if ! gsl_DEPRECATE_TO_LEVEL( 6 ) +template< class T> +gsl_DEPRECATED_MSG("use as_writable_bytes() (different spelling) instead") +gsl_api inline span< byte > as_writeable_bytes( span spn ) gsl_noexcept +{ + return span< byte >( reinterpret_cast( spn.data() ), spn.size_bytes() ); // NOLINT +} +#endif // deprecate -#if gsl_CONFIG_THROWS_FOR_TESTING +#if gsl_FEATURE_TO_STD( MAKE_SPAN ) -struct fail_fast : public std::runtime_error +template< class T > +gsl_NODISCARD gsl_api inline gsl_constexpr span +make_span( T * ptr, typename span::index_type count ) { - fail_fast() - : std::runtime_error( "GSL assertion" ) {} - - explicit fail_fast( char const * const message ) - : std::runtime_error( message ) {} -}; + return span( ptr, count ); +} -inline void fail_fast_assert( bool cond ) -{ - if ( !cond ) - throw fail_fast(); +template< class T > +gsl_NODISCARD gsl_api inline gsl_constexpr span +make_span( T * first, T * last ) +{ + return span( first, last ); } -inline void fail_fast_assert( bool cond, char const * const message ) -{ - if ( !cond ) - throw fail_fast( message ); +template< class T, size_t N > +gsl_NODISCARD inline gsl_constexpr span +make_span( T (&arr)[N] ) +{ + return span( gsl_ADDRESSOF( arr[0] ), N ); } -#else // gsl_CONFIG_THROWS_FOR_TESTING +#if gsl_HAVE( ARRAY ) -inline void fail_fast_assert( bool cond ) -{ - if ( !cond ) - std::terminate(); +template< class T, size_t N > +gsl_NODISCARD inline gsl_constexpr span +make_span( std::array & arr ) +{ + return span( arr ); } -inline void fail_fast_assert( bool cond, char const * const ) -{ - if ( !cond ) - std::terminate(); +template< class T, size_t N > +gsl_NODISCARD inline gsl_constexpr span +make_span( std::array const & arr ) +{ + return span( arr ); } +#endif -#endif // gsl_CONFIG_THROWS_FOR_TESTING - -// -// GSL.util: utilities -// +#if gsl_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR ) && gsl_HAVE( AUTO ) -#if gsl_CPP11_OR_GREATER +template< class Container, class EP = decltype( std17::data(std::declval())) > +gsl_NODISCARD inline gsl_constexpr auto +make_span( Container & cont ) -> span< typename std::remove_pointer::type > +{ + return span< typename std::remove_pointer::type >( cont ); +} -template< class Fn > -class Final_act +template< class Container, class EP = decltype( std17::data(std::declval())) > +gsl_NODISCARD inline gsl_constexpr auto +make_span( Container const & cont ) -> span< const typename std::remove_pointer::type > { -public: - explicit Final_act( Fn action ) gsl_noexcept - : action_( std::move( action ) ) {} - - ~Final_act() gsl_noexcept { action_(); } + return span< const typename std::remove_pointer::type >( cont ); +} -private: - Fn action_; -}; +#else -template< class Fn > -Final_act finally( Fn const & action ) gsl_noexcept -{ - return Final_act( action ); +template< class T > +inline span +make_span( std::vector & cont ) +{ + return span( with_container, cont ); } -template< class Fn > -Final_act finally( Fn && action ) gsl_noexcept -{ - return Final_act( std::forward( action ) ); +template< class T > +inline span +make_span( std::vector const & cont ) +{ + return span( with_container, cont ); } +#endif -#else // gsl_CPP11_OR_GREATER +#if gsl_FEATURE_TO_STD( WITH_CONTAINER ) -class Final_act +template< class Container > +gsl_NODISCARD inline gsl_constexpr span +make_span( with_container_t, Container & cont ) gsl_noexcept { -public: - typedef void (*Action)(); + return span< typename Container::value_type >( with_container, cont ); +} - Final_act( Action action ) - : action_( action ) {} +template< class Container > +gsl_NODISCARD inline gsl_constexpr span +make_span( with_container_t, Container const & cont ) gsl_noexcept +{ + return span< const typename Container::value_type >( with_container, cont ); +} - ~Final_act() - { - action_(); - } +#endif // gsl_FEATURE_TO_STD( WITH_CONTAINER ) -private: - Action action_; -}; +#if !gsl_DEPRECATE_TO_LEVEL( 4 ) +template< class Ptr > +gsl_DEPRECATED +inline span +make_span( Ptr & ptr ) +{ + return span( ptr ); +} +#endif // !gsl_DEPRECATE_TO_LEVEL( 4 ) -template< class Fn > -Final_act finally( Fn const & f ) +template< class Ptr > +gsl_DEPRECATED +inline span +make_span( Ptr & ptr, typename span::index_type count ) { - return Final_act(( f )); + return span( ptr, count ); } -#endif // gsl_CPP11_OR_GREATER +#endif // gsl_FEATURE_TO_STD( MAKE_SPAN ) -template< class T, class U > -T narrow_cast( U u ) gsl_noexcept -{ - return static_cast( u ); -} +#if gsl_FEATURE_TO_STD( BYTE_SPAN ) -struct narrowing_error : public std::exception {}; +template< class T > +gsl_NODISCARD gsl_api inline gsl_constexpr span +byte_span( T & t ) gsl_noexcept +{ + return span( reinterpret_cast( &t ), sizeof(T) ); +} -template< class T, class U > -T narrow( U u ) -{ - T t = narrow_cast( u ); - - if ( static_cast( t ) != u ) - { - throw narrowing_error(); - } - return t; +template< class T > +gsl_NODISCARD gsl_api inline gsl_constexpr span +byte_span( T const & t ) gsl_noexcept +{ + return span( reinterpret_cast( &t ), sizeof(T) ); } -// -// GSL.views: views -// +#endif // gsl_FEATURE_TO_STD( BYTE_SPAN ) +//#if gsl_FEATURE( STRING_SPAN ) // -// at() - Bounds-checked way of accessing static arrays, std::array, std::vector. +// basic_string_span: // -template< class T, size_t N > -T & at( T(&arr)[N], size_t index ) -{ - Expects( index < N ); - return arr[index]; -} +template< class T > +class basic_string_span; -#if gsl_HAVE_ARRAY +namespace detail { -template< class T, size_t N > -T & at( std::array & arr, size_t index ) -{ - Expects( index < N ); - return arr[index]; -} -#endif +template< class T > +struct is_basic_string_span_oracle : std11::false_type {}; + +template< class T > +struct is_basic_string_span_oracle< basic_string_span > : std11::true_type {}; + +template< class T > +struct is_basic_string_span : is_basic_string_span_oracle< typename std11::remove_cv::type > {}; + +template< class T > +gsl_api inline gsl_constexpr14 std::size_t string_length( T * ptr, std::size_t max ) +{ + if ( ptr == gsl_nullptr || max <= 0 ) + return 0; -template< class Cont > -typename Cont::value_type & at( Cont & cont, size_t index ) -{ - Expects( index < cont.size() ); - return cont[index]; + std::size_t len = 0; + while ( len < max && ptr[len] ) // NOLINT + ++len; + + return len; } +} // namespace detail + // -// not_null<> - Wrap any indirection and enforce non-null. +// basic_string_span<> - A view of contiguous characters, replace (*,len). // -template -class not_null +template< class T > +class basic_string_span { public: - not_null( T t ) : ptr_ ( t ){ Expects( ptr_ != NULL ); } - not_null & operator=( T const & t ) { ptr_ = t ; Expects( ptr_ != NULL ); return *this; } + typedef T element_type; + typedef span span_type; - not_null( not_null const & other ) : ptr_ ( other.ptr_ ) {} - not_null & operator=( not_null const & other ) { ptr_ = other.ptr_; } + typedef typename span_type::size_type size_type; + typedef typename span_type::index_type index_type; + typedef typename span_type::difference_type difference_type; -#if gsl_HAVE_DEFAULT_FUNCTION_TEMPLATE_ARG + typedef typename span_type::pointer pointer ; + typedef typename span_type::reference reference ; - template< typename U, typename Dummy = - typename std::enable_if::value, void>::type > - not_null( not_null const & other ) : ptr_( other.get() ) {} + typedef typename span_type::iterator iterator ; + typedef typename span_type::const_iterator const_iterator ; + typedef typename span_type::reverse_iterator reverse_iterator; + typedef typename span_type::const_reverse_iterator const_reverse_iterator; - template< typename U, typename Dummy = - typename std::enable_if::value, void>::type > - not_null & operator=( not_null const & other ) - { - ptr_ = other.get(); - return *this; - } + // construction: +#if gsl_HAVE( IS_DEFAULT ) + gsl_constexpr basic_string_span() gsl_noexcept = default; #else - - template< typename U > - not_null( not_null const & other ) : ptr_( other.get() ) {} - - template< typename U > - not_null & operator=( not_null const & other ) - { - ptr_ = other.get(); - return *this; - } + gsl_api gsl_constexpr basic_string_span() gsl_noexcept {} #endif -private: - // Prevent compilation when initialized with a nullptr or literal 0: -#if gsl_HAVE_NULLPTR - not_null( std::nullptr_t ); - not_null & operator=( std::nullptr_t ); +#if gsl_HAVE( NULLPTR ) + gsl_api gsl_constexpr basic_string_span( std::nullptr_t ) gsl_noexcept + : span_( nullptr, static_cast( 0 ) ) + {} #endif - not_null( int ); - not_null & operator=( int ); -public: - T get() const - { -#if gsl_HAVE_NULLPTR && gsl_COMPILER_MSVC_VERSION > 0 - // The assume() should help the optimizer: - __assume( ptr_ != nullptr ); -#endif - return ptr_; - } - - operator T() const { return get(); } - T operator->() const { return get(); } +#ifdef __CUDACC_RELAXED_CONSTEXPR__ + gsl_api +#endif // __CUDACC_RELAXED_CONSTEXPR__ +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_constexpr basic_string_span( pointer ptr ) + : span_( remove_z( ptr, (std::numeric_limits::max)() ) ) + {} - bool operator==(T const & rhs) const { return ptr_ == rhs; } - bool operator!=(T const & rhs) const { return !(*this == rhs); } +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_api gsl_constexpr basic_string_span( pointer ptr, index_type count ) + : span_( ptr, count ) + {} -private: - T ptr_; +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_api gsl_constexpr basic_string_span( pointer firstElem, pointer lastElem ) + : span_( firstElem, lastElem ) + {} - not_null & operator++(); - not_null & operator--(); - not_null operator++( int ); - not_null operator--( int ); - not_null & operator+ ( size_t ); - not_null & operator+=( size_t ); - not_null & operator- ( size_t ); - not_null & operator-=( size_t ); -}; + template< std::size_t N > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_constexpr basic_string_span( element_type (&arr)[N] ) + : span_( remove_z( gsl_ADDRESSOF( arr[0] ), N ) ) + {} -// -// Byte-specific type. -// -#if gsl_HAVE_ENUM_CLASS -# include - enum class byte : std::uint8_t {}; -#elif gsl_HAVE_SIZED_TYPES -# include - typedef std::uint8_t byte; -#else - typedef unsigned char byte; -#endif +#if gsl_HAVE( ARRAY ) -// -// array_view<> - A 1D view of contiguous T's, replace (*,len). -// -template< class T > -class array_view -{ - template< class U > friend class array_view; - -public: - typedef size_t size_type; + template< std::size_t N > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_constexpr basic_string_span( std::array< typename std11::remove_const::type, N> & arr ) + : span_( remove_z( arr ) ) + {} - typedef T value_type; - typedef T & reference; - typedef T * pointer; - typedef T const * const_pointer; + template< std::size_t N > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_constexpr basic_string_span( std::array< typename std11::remove_const::type, N> const & arr ) + : span_( remove_z( arr ) ) + {} - typedef pointer iterator; - typedef const_pointer const_iterator; - -#if gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 6, 7 ) - typedef std::reverse_iterator< iterator, T > reverse_iterator; - typedef std::reverse_iterator< const_iterator, const T > const_reverse_iterator; -#else - typedef std::reverse_iterator< iterator > reverse_iterator; - typedef std::reverse_iterator< const_iterator > const_reverse_iterator; #endif - typedef typename std::iterator_traits< iterator >::difference_type difference_type; +#if gsl_HAVE( CONSTRAINED_SPAN_CONTAINER_CTOR ) + + // Exclude: array, [basic_string,] basic_string_span + + template< class Container + gsl_ENABLE_IF_(( + ! detail::is_std_array< Container >::value + && ! detail::is_basic_string_span< Container >::value + && std::is_convertible< typename Container::pointer, pointer >::value + && std::is_convertible< typename Container::pointer, decltype(std::declval().data()) >::value + )) + > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_constexpr basic_string_span( Container & cont ) + : span_( ( cont ) ) + {} - gsl_constexpr14 array_view() - : begin_( NULL ) - , end_ ( NULL ) - { - Expects( size() == 0 ); - } + // Exclude: array, [basic_string,] basic_string_span + + template< class Container + gsl_ENABLE_IF_(( + ! detail::is_std_array< Container >::value + && ! detail::is_basic_string_span< Container >::value + && std::is_convertible< typename Container::pointer, pointer >::value + && std::is_convertible< typename Container::pointer, decltype(std::declval().data()) >::value + )) + > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_constexpr basic_string_span( Container const & cont ) + : span_( ( cont ) ) + {} -#if gsl_HAVE_NULLPTR - gsl_constexpr14 array_view( std::nullptr_t, size_type size ) - : begin_( nullptr ) - , end_ ( nullptr ) - { - Expects( size == 0 ); - } -#endif +#elif gsl_HAVE( UNCONSTRAINED_SPAN_CONTAINER_CTOR ) - gsl_constexpr14 array_view( pointer begin, pointer end ) - : begin_( begin ) - , end_ ( end ) - { - Expects( begin <= end ); - } + template< class Container > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_constexpr basic_string_span( Container & cont ) + : span_( cont ) + {} - gsl_constexpr14 array_view( pointer & data, size_type size ) - : begin_( data ) - , end_ ( data + size ) - { - Expects( size == 0 || ( size > 0 && data != NULL ) ); - } + template< class Container > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_constexpr basic_string_span( Container const & cont ) + : span_( cont ) + {} - template< class U, size_t N > - gsl_constexpr14 array_view( U (&arr)[N] ) - : begin_( arr ) - , end_ ( arr + N ) +#else + + template< class U > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_api gsl_constexpr basic_string_span( span const & rhs ) + : span_( rhs ) {} - template< class U, size_t N > - gsl_constexpr14 array_view( U (&arr)[N], size_type size ) - : begin_( arr ) - , end_ ( arr + size ) - { - Expects( size <= N ); - } +#endif -#if gsl_HAVE_ARRAY - template< class U, size_t N > - gsl_constexpr14 array_view( std::array< U, N > & arr ) - : begin_( arr.data() ) - , end_ ( arr.data() + N ) +#if gsl_FEATURE_TO_STD( WITH_CONTAINER ) + + template< class Container > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_constexpr basic_string_span( with_container_t, Container & cont ) + : span_( with_container, cont ) {} #endif - template< class Cont > - gsl_constexpr14 array_view( Cont & cont ) -#if gsl_HAVE_CONTAINER_DATA_METHOD - : begin_( cont.data() ) - , end_ ( cont.data() + cont.size() ) -#else - : begin_( &cont[0] ) - , end_ ( &cont[0] + cont.size() ) +#if gsl_HAVE( IS_DEFAULT ) +# if gsl_BETWEEN( gsl_COMPILER_GNUC_VERSION, 440, 600 ) + gsl_constexpr basic_string_span( basic_string_span const & ) = default; + + gsl_constexpr basic_string_span( basic_string_span && ) = default; +# else + gsl_constexpr basic_string_span( basic_string_span const & ) gsl_noexcept = default; + + gsl_constexpr basic_string_span( basic_string_span && ) gsl_noexcept = default; +# endif #endif + + template< class U + gsl_ENABLE_IF_(( std::is_convertible::pointer, pointer>::value )) + > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_api gsl_constexpr basic_string_span( basic_string_span const & rhs ) + : span_( reinterpret_cast( rhs.data() ), rhs.length() ) // NOLINT {} -#if gsl_HAVE_IS_DEFAULT_CTOR - gsl_constexpr14 array_view( array_view const & ) = default; -#else - gsl_constexpr14 array_view( array_view const & other ) - : begin_( other.begin() ) - , end_ ( other.end() ) +#if gsl_STDLIB_CPP11_120 + template< class U + gsl_ENABLE_IF_(( std::is_convertible::pointer, pointer>::value )) + > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_api gsl_constexpr basic_string_span( basic_string_span && rhs ) + : span_( reinterpret_cast( rhs.data() ), rhs.length() ) // NOLINT + {} +#endif // gsl_STDLIB_CPP11_120 + + template< class CharTraits, class Allocator > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_constexpr basic_string_span( + std::basic_string< typename std11::remove_const::type, CharTraits, Allocator > & str ) + : span_( gsl_ADDRESSOF( str[0] ), str.length() ) {} -#endif - template< typename U > - gsl_constexpr14 array_view( array_view const & other ) - : begin_( other.begin() ) - , end_ ( other.end() ) + template< class CharTraits, class Allocator > +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_string_span<><> is deprecated; use span<> instead") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_constexpr basic_string_span( + std::basic_string< typename std11::remove_const::type, CharTraits, Allocator > const & str ) + : span_( gsl_ADDRESSOF( str[0] ), str.length() ) {} - array_view & operator=( array_view other ) - { - other.swap( *this ); - return *this; - } + // assignment: -#if 0 - // Converting from other array_view ? - template< typename U > operator=(); +#if gsl_HAVE( IS_DEFAULT ) + gsl_constexpr14 basic_string_span & operator=( basic_string_span const & ) gsl_noexcept = default; + + gsl_constexpr14 basic_string_span & operator=( basic_string_span && ) gsl_noexcept = default; #endif - gsl_constexpr14 iterator begin() const - { - return iterator( begin_ ); - } + // sub span: - gsl_constexpr14 iterator end() const + /*gsl_api*/ // currently disabled due to an apparent NVCC bug + gsl_NODISCARD gsl_constexpr14 basic_string_span + first( index_type count ) const { - return iterator( end_ ); + return span_.first( count ); } - gsl_constexpr14 const_iterator cbegin() const + /*gsl_api*/ // currently disabled due to an apparent NVCC bug + gsl_NODISCARD gsl_constexpr14 basic_string_span + last( index_type count ) const { - return const_iterator( begin() ); + return span_.last( count ); } - gsl_constexpr14 const_iterator cend() const + /*gsl_api*/ // currently disabled due to an apparent NVCC bug + gsl_NODISCARD gsl_constexpr14 basic_string_span + subspan( index_type offset ) const { - return const_iterator( end() ); + return span_.subspan( offset ); } - gsl_constexpr14 reverse_iterator rbegin() const + /*gsl_api*/ // currently disabled due to an apparent NVCC bug + gsl_NODISCARD gsl_constexpr14 basic_string_span + subspan( index_type offset, index_type count ) const { - return reverse_iterator( end() ); + return span_.subspan( offset, count ); } - gsl_constexpr14 reverse_iterator rend() const - { - return reverse_iterator( begin() ); - } + // observers: - gsl_constexpr14 const_reverse_iterator crbegin() const + gsl_NODISCARD gsl_api gsl_constexpr index_type + length() const gsl_noexcept { - return const_reverse_iterator( cend() ); + return span_.size(); } - gsl_constexpr14 const_reverse_iterator crend() const + gsl_NODISCARD gsl_api gsl_constexpr index_type + size() const gsl_noexcept { - return const_reverse_iterator( cbegin() ); + return span_.size(); } - gsl_constexpr14 operator bool () const gsl_noexcept + gsl_NODISCARD gsl_api gsl_constexpr index_type + length_bytes() const gsl_noexcept { - return begin_ != NULL; + return span_.size_bytes(); } - gsl_constexpr14 reference operator[]( size_type index ) + gsl_NODISCARD gsl_api gsl_constexpr index_type + size_bytes() const gsl_noexcept { - return at( index ); + return span_.size_bytes(); } - gsl_constexpr14 bool operator==( array_view const & other ) const gsl_noexcept + gsl_NODISCARD gsl_api gsl_constexpr bool + empty() const gsl_noexcept { - return size() == other.size() - && (begin_ == other.begin_ || std::equal( this->begin(), this->end(), other.begin() ) ); - } - - gsl_constexpr14 bool operator!=( array_view const & other ) const gsl_noexcept - { - return !( *this == other ); - } - - gsl_constexpr14 bool operator< ( array_view const & other ) const gsl_noexcept - { - return std::lexicographical_compare( this->begin(), this->end(), other.begin(), other.end() ); - } - - gsl_constexpr14 bool operator<=( array_view const & other ) const gsl_noexcept - { - return !( other < *this ); + return size() == 0; } - gsl_constexpr14 bool operator> ( array_view const & other ) const gsl_noexcept - { - return ( other < *this ); + gsl_NODISCARD gsl_api gsl_constexpr14 reference + operator[]( index_type idx ) const + { + return span_[idx]; } - gsl_constexpr14 bool operator>=( array_view const & other ) const gsl_noexcept +#if ! gsl_DEPRECATE_TO_LEVEL( 6 ) + gsl_DEPRECATED_MSG("use subscript indexing instead") + gsl_api gsl_constexpr14 reference operator()( index_type idx ) const { - return !( *this < other ); + return span_[idx]; } +#endif // deprecate - gsl_constexpr14 reference at( size_type index ) + gsl_NODISCARD gsl_api gsl_constexpr14 reference + front() const { - Expects( index >= 0 && index < size()); - return begin_[ index ]; + return span_.front(); } - gsl_constexpr14 pointer data() const gsl_noexcept + gsl_NODISCARD gsl_api gsl_constexpr14 reference + back() const { - return begin_; + return span_.back(); } - gsl_constexpr14 bool empty() const gsl_noexcept + gsl_NODISCARD gsl_api gsl_constexpr pointer + data() const gsl_noexcept { - return size() == 0; + return span_.data(); } - gsl_constexpr14 size_type size() const gsl_noexcept + gsl_NODISCARD gsl_api gsl_constexpr iterator + begin() const gsl_noexcept { - return std::distance( begin_, end_ ); + return span_.begin(); } - gsl_constexpr14 size_type length() const gsl_noexcept + gsl_NODISCARD gsl_api gsl_constexpr iterator + end() const gsl_noexcept { - return size(); + return span_.end(); } - gsl_constexpr14 size_type used_length() const gsl_noexcept + gsl_NODISCARD gsl_constexpr17 reverse_iterator + rbegin() const gsl_noexcept { - return length(); + return span_.rbegin(); } - gsl_constexpr14 size_type bytes() const gsl_noexcept + gsl_NODISCARD gsl_constexpr17 reverse_iterator + rend() const gsl_noexcept { - return sizeof( value_type ) * size(); + return span_.rend(); } - gsl_constexpr14 size_type used_bytes() const gsl_noexcept + // const version not in p0123r2: + + gsl_NODISCARD gsl_api gsl_constexpr const_iterator + cbegin() const gsl_noexcept { - return bytes(); + return span_.cbegin(); } - void swap( array_view & other ) gsl_noexcept + gsl_NODISCARD gsl_api gsl_constexpr const_iterator + cend() const gsl_noexcept { - using std::swap; - swap( begin_, other.begin_ ); - swap( end_ , other.end_ ); + return span_.cend(); } - array_view< const byte > as_bytes() const gsl_noexcept + gsl_NODISCARD gsl_constexpr17 const_reverse_iterator + crbegin() const gsl_noexcept { - return array_view< const byte >( reinterpret_cast( data() ), bytes() ); + return span_.crbegin(); } - array_view< byte > as_writeable_bytes() const gsl_noexcept + gsl_NODISCARD gsl_constexpr17 const_reverse_iterator + crend() const gsl_noexcept { - return array_view< byte >( reinterpret_cast( data() ), bytes() ); + return span_.crend(); } - template< typename U > - array_view< U > as_array_view() const gsl_noexcept +private: + gsl_api static gsl_constexpr14 span_type remove_z( pointer sz, std::size_t max ) { - Expects( ( this->bytes() % sizeof(U) ) == 0 ); - return array_view< U >( reinterpret_cast( this->data() ), this->bytes() / sizeof( U ) ); + return span_type( sz, detail::string_length( sz, max ) ); } -private: - // helpers for member as_array_view() - template< typename U > - gsl_constexpr14 array_view( U * & data, size_type size ) - : begin_( data ) - , end_ ( data + size ) +#if gsl_HAVE( ARRAY ) + template< size_t N > + gsl_NODISCARD static gsl_constexpr14 span_type + remove_z( std::array::type, N> & arr ) { - Expects( size == 0 || ( size > 0 && data != NULL ) ); + return remove_z( gsl_ADDRESSOF( arr[0] ), narrow_cast< std::size_t >( N ) ); } - template< typename U > - gsl_constexpr14 array_view( U * const & data, size_type size ) - : begin_( data ) - , end_ ( data + size ) + template< size_t N > + gsl_NODISCARD static gsl_constexpr14 span_type + remove_z( std::array::type, N> const & arr ) { - Expects( size == 0 || ( size > 0 && data != NULL ) ); + return remove_z( gsl_ADDRESSOF( arr[0] ), narrow_cast< std::size_t >( N ) ); } +#endif private: - pointer begin_; - pointer end_; + span_type span_; }; -// array_view creator functions (see ctors) +// basic_string_span comparison functions: + +#if gsl_CONFIG( ALLOWS_NONSTRICT_SPAN_COMPARISON ) -template< typename T > -gsl_constexpr14 array_view as_array_view( T * begin, T * end ) +template< class T, class U > +gsl_SUPPRESS_MSGSL_WARNING(stl.1) +gsl_NODISCARD inline gsl_constexpr14 bool +operator==( basic_string_span const & l, U const & u ) gsl_noexcept { - return array_view( begin, end ); + const basic_string_span< typename std11::add_const::type > r( u ); + + return l.size() == r.size() + && detail::equal( l.begin(), l.end(), r.begin() ); } -template< typename T > -gsl_constexpr14 array_view as_array_view( T * begin, size_t size ) +template< class T, class U > +gsl_SUPPRESS_MSGSL_WARNING(stl.1) +gsl_NODISCARD inline gsl_constexpr14 bool +operator<( basic_string_span const & l, U const & u ) gsl_noexcept { - return array_view( begin, size ); + const basic_string_span< typename std11::add_const::type > r( u ); + + return detail::lexicographical_compare( l.begin(), l.end(), r.begin(), r.end() ); } -template< typename T, size_t N > -gsl_constexpr14 array_view as_array_view( T (&arr)[N] ) -{ - return array_view( arr, N ); +#if gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) + +template< class T, class U + gsl_ENABLE_IF_(( !detail::is_basic_string_span::value )) +> +gsl_SUPPRESS_MSGSL_WARNING(stl.1) +gsl_NODISCARD inline gsl_constexpr14 bool +operator==( U const & u, basic_string_span const & r ) gsl_noexcept +{ + const basic_string_span< typename std11::add_const::type > l( u ); + + return l.size() == r.size() + && detail::equal( l.begin(), l.end(), r.begin() ); } -#if gsl_HAVE_ARRAY -template< typename T, size_t N > -gsl_constexpr14 array_view as_array_view( std::array & arr ) +template< class T, class U + gsl_ENABLE_IF_(( !detail::is_basic_string_span::value )) +> +gsl_SUPPRESS_MSGSL_WARNING(stl.1) +gsl_NODISCARD inline gsl_constexpr14 bool +operator<( U const & u, basic_string_span const & r ) gsl_noexcept { - return array_view( arr ); + const basic_string_span< typename std11::add_const::type > l( u ); + + return detail::lexicographical_compare( l.begin(), l.end(), r.begin(), r.end() ); } #endif -#if gsl_HAVE_AUTO -template< class Cont > -gsl_constexpr14 auto as_array_view( Cont & cont ) -> array_view< typename Cont::value_type > -{ - return array_view< typename Cont::value_type >( cont ); +#else //gsl_CONFIG( ALLOWS_NONSTRICT_SPAN_COMPARISON ) + +template< class T > +gsl_SUPPRESS_MSGSL_WARNING(stl.1) +gsl_NODISCARD inline gsl_constexpr14 bool +operator==( basic_string_span const & l, basic_string_span const & r ) gsl_noexcept +{ + return l.size() == r.size() + && detail::equal( l.begin(), l.end(), r.begin() ); } -#else + template< class T > -array_view as_array_view( std::vector & cont ) -{ - return array_view( cont ); +gsl_SUPPRESS_MSGSL_WARNING(stl.1) +gsl_NODISCARD inline gsl_constexpr14 bool +operator<( basic_string_span const & l, basic_string_span const & r ) gsl_noexcept +{ + return detail::lexicographical_compare( l.begin(), l.end(), r.begin(), r.end() ); +} + +#endif // gsl_CONFIG( ALLOWS_NONSTRICT_SPAN_COMPARISON ) + +template< class T, class U > +gsl_NODISCARD inline gsl_constexpr14 bool +operator!=( basic_string_span const & l, U const & r ) gsl_noexcept +{ + return !( l == r ); +} + +template< class T, class U > +gsl_NODISCARD inline gsl_constexpr14 bool +operator<=( basic_string_span const & l, U const & r ) gsl_noexcept +{ +#if gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) || ! gsl_CONFIG( ALLOWS_NONSTRICT_SPAN_COMPARISON ) + return !( r < l ); +#else + basic_string_span< typename std11::add_const::type > rr( r ); + return !( rr < l ); +#endif } + +template< class T, class U > +gsl_NODISCARD inline gsl_constexpr14 bool +operator>( basic_string_span const & l, U const & r ) gsl_noexcept +{ +#if gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) || ! gsl_CONFIG( ALLOWS_NONSTRICT_SPAN_COMPARISON ) + return ( r < l ); +#else + basic_string_span< typename std11::add_const::type > rr( r ); + return ( rr < l ); #endif +} + +template< class T, class U > +gsl_NODISCARD inline gsl_constexpr14 bool +operator>=( basic_string_span const & l, U const & r ) gsl_noexcept +{ + return !( l < r ); +} + +#if gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) + +template< class T, class U + gsl_ENABLE_IF_(( !detail::is_basic_string_span::value )) +> +gsl_NODISCARD inline gsl_constexpr14 bool +operator!=( U const & l, basic_string_span const & r ) gsl_noexcept +{ + return !( l == r ); +} + +template< class T, class U + gsl_ENABLE_IF_(( !detail::is_basic_string_span::value )) +> +gsl_NODISCARD inline gsl_constexpr14 bool +operator<=( U const & l, basic_string_span const & r ) gsl_noexcept +{ + return !( r < l ); +} + +template< class T, class U + gsl_ENABLE_IF_(( !detail::is_basic_string_span::value )) +> +gsl_NODISCARD inline gsl_constexpr14 bool +operator>( U const & l, basic_string_span const & r ) gsl_noexcept +{ + return ( r < l ); +} + +template< class T, class U + gsl_ENABLE_IF_(( !detail::is_basic_string_span::value )) +> +gsl_NODISCARD inline gsl_constexpr14 bool +operator>=( U const & l, basic_string_span const & r ) gsl_noexcept +{ + return !( l < r ); +} + +#endif // gsl_HAVE( DEFAULT_FUNCTION_TEMPLATE_ARG ) + +// convert basic_string_span to byte span: + +template< class T > +gsl_NODISCARD gsl_api inline span< const byte > +as_bytes( basic_string_span spn ) gsl_noexcept +{ + return span< const byte >( reinterpret_cast( spn.data() ), spn.size_bytes() ); // NOLINT +} +//#endif // gsl_FEATURE( STRING_SPAN ) // // String types: // typedef char * zstring; -typedef wchar_t * zwstring; typedef const char * czstring; + +#if gsl_HAVE( WCHAR ) +typedef wchar_t * wzstring; typedef const wchar_t * cwzstring; +#endif + +//#if gsl_FEATURE( STRING_SPAN ) + +typedef basic_string_span< char > string_span; +typedef basic_string_span< char const > cstring_span; + +#if gsl_HAVE( WCHAR ) +typedef basic_string_span< wchar_t > wstring_span; +typedef basic_string_span< wchar_t const > cwstring_span; +#endif + +// to_string() allow (explicit) conversions from string_span to string + +#if 0 + +template< class T > +inline std::basic_string< typename std::remove_const::type > to_string( basic_string_span spn ) +{ + std::string( spn.data(), spn.length() ); +} + +#else + +gsl_NODISCARD inline std::string +to_string( string_span const & spn ) +{ + return std::string( spn.data(), static_cast( spn.length() ) ); +} + +gsl_NODISCARD inline std::string +to_string( cstring_span const & spn ) +{ + return std::string( spn.data(), static_cast( spn.length() ) ); +} + +#if gsl_HAVE( WCHAR ) + +gsl_NODISCARD inline std::wstring +to_string( wstring_span const & spn ) +{ + return std::wstring( spn.data(), static_cast( spn.length() ) ); +} + +gsl_NODISCARD inline std::wstring +to_string( cwstring_span const & spn ) +{ + return std::wstring( spn.data(), static_cast( spn.length() ) ); +} + +#endif // gsl_HAVE( WCHAR ) +#endif // to_string() + +// +// Stream output for string_span types +// + +namespace detail { + +template< class Stream > +void write_padding( Stream & os, std::streamsize n ) +{ + for ( std::streamsize i = 0; i < n; ++i ) + os.rdbuf()->sputc( os.fill() ); +} + +template< class Stream, class Span > +Stream & write_to_stream( Stream & os, Span const & spn ) +{ + typename Stream::sentry sentry( os ); + + if ( !os ) + return os; + + const std::streamsize length = gsl::narrow_failfast( spn.length() ); + + // Whether, and how, to pad + const bool pad = ( length < os.width() ); + const bool left_pad = pad && ( os.flags() & std::ios_base::adjustfield ) == std::ios_base::right; + + if ( left_pad ) + detail::write_padding( os, os.width() - length ); -typedef array_view< char > string_view; -typedef array_view< wchar_t > wstring_view; -typedef array_view< const char > cstring_view; -typedef array_view< const wchar_t > cwstring_view; + // Write span characters + os.rdbuf()->sputn( spn.begin(), length ); -// to_string() allow (explicit) conversions from string_view to string + if ( pad && !left_pad ) + detail::write_padding( os, os.width() - length ); -inline std::string to_string( string_view const & view ) + // Reset output stream width + os.width(0); + + return os; +} + +} // namespace detail + +template< typename Traits > +std::basic_ostream< char, Traits > & operator<<( std::basic_ostream< char, Traits > & os, string_span const & spn ) { - return std::string( view.data(), view.length() ); + return detail::write_to_stream( os, spn ); } -inline std::string to_string( cstring_view const & view ) +template< typename Traits > +std::basic_ostream< char, Traits > & operator<<( std::basic_ostream< char, Traits > & os, cstring_span const & spn ) { - return std::string( view.data(), view.length() ); + return detail::write_to_stream( os, spn ); } -inline std::wstring to_string( wstring_view const & view ) +#if gsl_HAVE( WCHAR ) + +template< typename Traits > +std::basic_ostream< wchar_t, Traits > & operator<<( std::basic_ostream< wchar_t, Traits > & os, wstring_span const & spn ) { - return std::wstring( view.data(), view.length() ); + return detail::write_to_stream( os, spn ); } -inline std::wstring to_string( cwstring_view const & view ) +template< typename Traits > +std::basic_ostream< wchar_t, Traits > & operator<<( std::basic_ostream< wchar_t, Traits > & os, cwstring_span const & spn ) { - return std::wstring( view.data(), view.length() ); + return detail::write_to_stream( os, spn ); } +#endif // gsl_HAVE( WCHAR ) +//#endif // gsl_FEATURE( STRING_SPAN ) + // -// ensure_sentinel() +// ensure_sentinel() // -// Provides a way to obtain an array_view from a contiguous sequence +// Provides a way to obtain a span from a contiguous sequence // that ends with a (non-inclusive) sentinel value. // // Will fail-fast if sentinel cannot be found before max elements are examined. // namespace detail { -template -static array_view ensure_sentinel( T * seq, SizeType max = std::numeric_limits::max() ) +template< class T, class SizeType, const T Sentinel > +gsl_constexpr14 static span ensure_sentinel( T * seq, SizeType max = (std::numeric_limits::max)() ) { typedef T * pointer; - typedef typename std::iterator_traits::difference_type difference_type; - + + gsl_SUPPRESS_MSVC_WARNING( 26429, "f.23: symbol 'cur' is never tested for nullness, it can be marked as not_null" ) pointer cur = seq; - while ( std::distance( seq, cur ) < static_cast( max ) && *cur != Sentinel ) + while ( static_cast( cur - seq ) < max && *cur != Sentinel ) ++cur; - - Expects( *cur == Sentinel ); - - return array_view( seq, cur - seq ); + + gsl_Expects( *cur == Sentinel ); + + return span( seq, gsl::narrow_cast< typename span::index_type >( cur - seq ) ); } } // namespace detail // -// ensure_z - creates a string_view for a czstring or cwzstring. +// ensure_z - creates a string_span for a czstring or cwzstring. // Will fail fast if a null-terminator cannot be found before // the limit of size_type. // template< class T > -inline array_view ensure_z( T * const & sz, size_t max = std::numeric_limits::max() ) +gsl_NODISCARD inline gsl_constexpr14 span +ensure_z( T * const & sz, size_t max = (std::numeric_limits::max)() ) { return detail::ensure_sentinel( sz, max ); -// return detail::ensure::sentinel( sz, max ); } template< class T, size_t N > -array_view ensure_z( T (&sz)[N] ) -{ - return ensure_z( &sz[0], N ); +gsl_NODISCARD inline gsl_constexpr14 span +ensure_z( T (&sz)[N] ) +{ + return ::gsl::ensure_z( gsl_ADDRESSOF( sz[0] ), N ); } -# if gsl_HAVE_TYPE_TRAITS +# if gsl_HAVE( TYPE_TRAITS ) -template< class Cont > -array_view< typename std::remove_pointer::type > -ensure_z( Cont& cont ) +template< class Container > +gsl_NODISCARD inline gsl_constexpr14 span< typename std::remove_pointer::type > +ensure_z( Container & cont ) { - return ensure_z( cont.data(), cont.length() ); + return ::gsl::ensure_z( cont.data(), cont.length() ); } # endif +//#if gsl_FEATURE( STRING_SPAN ) +// +// basic_zstring_span<> - A view of contiguous null-terminated characters, replace (*,len). +// + +template +class basic_zstring_span +{ +public: + typedef T element_type; + typedef span span_type; + + typedef typename span_type::index_type index_type; + typedef typename span_type::difference_type difference_type; + + typedef element_type * czstring_type; + typedef basic_string_span string_span_type; + +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_zstring_span<> is deprecated") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_api gsl_constexpr14 basic_zstring_span( span_type s ) + : span_( s ) + { + // expects a zero-terminated span + gsl_Expects( s.back() == '\0' ); + } + +#if gsl_HAVE( IS_DEFAULT ) + gsl_constexpr basic_zstring_span( basic_zstring_span const & ) = default; + gsl_constexpr basic_zstring_span( basic_zstring_span && ) = default; + gsl_constexpr14 basic_zstring_span & operator=( basic_zstring_span const & ) = default; + gsl_constexpr14 basic_zstring_span & operator=( basic_zstring_span && ) = default; +#else + gsl_api gsl_constexpr basic_zstring_span( basic_zstring_span const & other) : span_ ( other.span_ ) {} + gsl_api gsl_constexpr basic_zstring_span & operator=( basic_zstring_span const & other ) { span_ = other.span_; return *this; } +#endif + + gsl_NODISCARD gsl_api gsl_constexpr bool + empty() const gsl_noexcept + { + return false; + } + +#if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_zstring_span<> is deprecated") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_NODISCARD gsl_api gsl_constexpr string_span_type + as_string_span() const gsl_noexcept + { + return string_span_type( span_.data(), span_.size() - 1 ); + } + + #if gsl_DEPRECATE_TO_LEVEL( 7 ) + gsl_DEPRECATED_MSG("basic_zstring_span<> is deprecated") +#endif // gsl_DEPRECATE_TO_LEVEL( 7 ) + /*gsl_api*/ // currently disabled due to an apparent NVCC bug + gsl_NODISCARD gsl_constexpr string_span_type + ensure_z() const + { + return ::gsl::ensure_z(span_.data(), span_.size()); + } + + gsl_NODISCARD gsl_api gsl_constexpr czstring_type + assume_z() const gsl_noexcept + { + return span_.data(); + } + +private: + span_type span_; +}; + +// +// zString types: +// + +typedef basic_zstring_span< char > zstring_span; +typedef basic_zstring_span< char const > czstring_span; + +#if gsl_HAVE( WCHAR ) +typedef basic_zstring_span< wchar_t > wzstring_span; +typedef basic_zstring_span< wchar_t const > cwzstring_span; +#endif +//#endif // gsl_FEATURE( STRING_SPAN ) + +} // namespace gsl + +#if gsl_HAVE( HASH ) + +// +// std::hash specializations for GSL types +// + +namespace gsl { + +namespace detail { + +// +// Helper struct for std::hash specializations +// + +template +struct conditionally_enabled_hash +{ + +}; + +// disabled as described in [unord.hash] +template<> +struct conditionally_enabled_hash< false > +{ +gsl_is_delete_access: + conditionally_enabled_hash() gsl_is_delete; + conditionally_enabled_hash( conditionally_enabled_hash const & ) gsl_is_delete; + conditionally_enabled_hash( conditionally_enabled_hash && ) gsl_is_delete; + conditionally_enabled_hash & operator=( conditionally_enabled_hash const & ) gsl_is_delete; + conditionally_enabled_hash & operator=( conditionally_enabled_hash && ) gsl_is_delete; +}; + +} // namespace detail + } // namespace gsl -#endif // GSL_GSL_LITE_H_INCLUDED +namespace std { + +template< class T > +struct hash< ::gsl::not_null< T > > : public ::gsl::detail::conditionally_enabled_hash>::value> +{ +public: + gsl_NODISCARD std::size_t + operator()( ::gsl::not_null const & v ) const + // hash function is not `noexcept` because `as_nullable()` has preconditions + { + return hash()( ::gsl::as_nullable( v ) ); + } +}; +template< class T > +struct hash< ::gsl::not_null< T* > > +{ +public: + gsl_NODISCARD std::size_t + operator()( ::gsl::not_null< T* > const & v ) const gsl_noexcept + { + return hash()( ::gsl::as_nullable( v ) ); + } +}; + +template<> +struct hash< ::gsl::byte > +{ +public: + gsl_NODISCARD std::size_t operator()( ::gsl::byte v ) const gsl_noexcept + { +#if gsl_CONFIG_DEFAULTS_VERSION >= 1 + return std::hash{ }( ::gsl::to_uchar( v ) ); +#else // gsl_CONFIG_DEFAULTS_VERSION < 1 + // Keep the old hashing algorithm if legacy defaults are used. + return ::gsl::to_integer( v ); +#endif // gsl_CONFIG_DEFAULTS_VERSION >= 1 + } +}; + +} // namespace std + +#endif // gsl_HAVE( HASH ) + +#if gsl_FEATURE( GSL_LITE_NAMESPACE ) + +// gsl_lite namespace: + +// gsl-lite currently keeps all symbols in the namespace `gsl`. The `gsl_lite` namespace contains all the symbols in the +// `gsl` namespace, plus some extensions that are not specified in the Core Guidelines. +// +// Going forward, we want to support coexistence of gsl-lite with M-GSL, so we want to encourage using the `gsl_lite` +// namespace when consuming gsl-lite. Typical use in library code would be: +// +// #include // instead of +// +// namespace foo { +// namespace gsl = ::gsl_lite; // convenience alias +// double mean( gsl::span elements ) +// { +// gsl_Expects( ! elements.empty() ); // instead of Expects() +// ... +// } +// } // namespace foo +// +// In a future version, the new header will only define the `gsl_lite` namespace and no +// unprefixed `Expects()` and `Ensures()` macros to avoid collision with M-GSL. To ensure backward compatibility, the +// old header will keep defining the `gsl` namespace and the `Expects()` and `Ensures()` macros. + +namespace gsl_lite { + +namespace std11 = ::gsl::std11; +namespace std14 = ::gsl::std14; +namespace std17 = ::gsl::std17; +namespace std20 = ::gsl::std20; +namespace std23 = ::gsl::std23; + +using namespace std11; +//using namespace std14; // contains only make_unique<>(), which is superseded by `gsl::make_unique<>()` +using namespace std17; +using namespace std20; +using namespace std23; + +using namespace ::gsl::detail::no_adl; + +# if gsl_HAVE( UNIQUE_PTR ) && gsl_HAVE( SHARED_PTR ) +using std::unique_ptr; +using std::shared_ptr; +# if gsl_HAVE( VARIADIC_TEMPLATE ) +using ::gsl::make_unique; +using ::gsl::make_shared; +# endif +# endif + +using ::gsl::index; +using ::gsl::dim; +using ::gsl::stride; +using ::gsl::diff; + +# if gsl_HAVE( ALIAS_TEMPLATE ) +# if gsl_BETWEEN( gsl_COMPILER_MSVC_VERSION, 1, 141 ) // VS 2015 and earlier have trouble with `using` for alias templates + template< class T +# if gsl_HAVE( TYPE_TRAITS ) + , typename = typename std::enable_if< std::is_pointer::value >::type +# endif + > + using owner = T; +# else +using ::gsl::owner; +# endif +# endif + +using ::gsl::fail_fast; + +using ::gsl::finally; +# if gsl_FEATURE( EXPERIMENTAL_RETURN_GUARD ) +using ::gsl::on_return; +using ::gsl::on_error; +# endif // gsl_FEATURE( EXPERIMENTAL_RETURN_GUARD ) + +using ::gsl::narrow_cast; +using ::gsl::narrowing_error; +using ::gsl::narrow; +using ::gsl::narrow_failfast; + +using ::gsl::at; + +using ::gsl::not_null; +using ::gsl::not_null_ic; +using ::gsl::make_not_null; + +using ::gsl::byte; + +using ::gsl::to_byte; +using ::gsl::to_integer; +using ::gsl::to_uchar; +using ::gsl::to_string; + +using ::gsl::with_container_t; +using ::gsl::with_container; + +using ::gsl::span; +using ::gsl::make_span; +using ::gsl::byte_span; +using ::gsl::copy; +using ::gsl::as_bytes; +using ::gsl::as_writable_bytes; +# if ! gsl_DEPRECATE_TO_LEVEL( 6 ) +using ::gsl::as_writeable_bytes; +# endif + +//# if gsl_FEATURE( STRING_SPAN ) +using ::gsl::basic_string_span; +using ::gsl::string_span; +using ::gsl::cstring_span; + +using ::gsl::basic_zstring_span; +using ::gsl::zstring_span; +using ::gsl::czstring_span; +//# endif // gsl_FEATURE( STRING_SPAN ) + +using ::gsl::zstring; +using ::gsl::czstring; + +# if gsl_HAVE( WCHAR ) +using ::gsl::wzstring; +using ::gsl::cwzstring; + +//# if gsl_FEATURE( STRING_SPAN ) +using ::gsl::wzstring_span; +using ::gsl::cwzstring_span; +//# endif // gsl_FEATURE( STRING_SPAN ) +# endif // gsl_HAVE( WCHAR ) + +using ::gsl::ensure_z; + +} // namespace gsl_lite + +#endif // gsl_FEATURE( GSL_LITE_NAMESPACE ) + +gsl_RESTORE_MSVC_WARNINGS() +#if gsl_COMPILER_CLANG_VERSION || gsl_COMPILER_APPLECLANG_VERSION +# pragma clang diagnostic pop +#endif // gsl_COMPILER_CLANG_VERSION || gsl_COMPILER_APPLECLANG_VERSION +#if gsl_COMPILER_GNUC_VERSION +# pragma GCC diagnostic pop +#endif // gsl_COMPILER_GNUC_VERSION + +// #undef internal macros +#undef gsl_STATIC_ASSERT_ +#undef gsl_ENABLE_IF_ +#undef gsl_TRAILING_RETURN_TYPE_ +#undef gsl_RETURN_DECLTYPE_ + +#endif // GSL_GSL_LITE_HPP_INCLUDED // end of file diff --git a/shared/qcommon/safe/files.h b/shared/qcommon/safe/files.h index 7c354a43d8..e82d3964e7 100644 --- a/shared/qcommon/safe/files.h +++ b/shared/qcommon/safe/files.h @@ -44,7 +44,7 @@ namespace FS { return _buffer != nullptr; } - gsl::cstring_view view() const NOEXCEPT + gsl::cstring_span view() const NOEXCEPT { return{ begin(), end() }; } diff --git a/shared/qcommon/safe/gsl.h b/shared/qcommon/safe/gsl.h index 62ee5e494a..3f29f2bd91 100644 --- a/shared/qcommon/safe/gsl.h +++ b/shared/qcommon/safe/gsl.h @@ -10,15 +10,15 @@ // The workaround is using CSTRING_VIEW("literal") instead of "literal"_v (for the time being). # define CSTRING_VIEW(x) vs2013hack_cstring_view_literal(x) template< int length > -inline gsl::cstring_view vs2013hack_cstring_view_literal( const char (&str)[length] ) +inline gsl::cstring_span vs2013hack_cstring_view_literal( const char (&str)[length] ) { static_assert( length > 0, "CSTRING_VIEW expects a string literal argument." ); return{ str, str + length - 1 }; } #else # define CSTRING_VIEW(x) x ## _v -/** gsl::cstring_view from string literal (without null-termination) */ -inline gsl::cstring_view operator"" _v( const char* str, std::size_t length ) +/** gsl::cstring_span from string literal (without null-termination) */ +inline gsl::cstring_span operator"" _v( const char* str, std::size_t length ) { return{ str, str + length }; } diff --git a/shared/qcommon/safe/sscanf.h b/shared/qcommon/safe/sscanf.h index ddeea10db7..e7652fb3d8 100644 --- a/shared/qcommon/safe/sscanf.h +++ b/shared/qcommon/safe/sscanf.h @@ -15,15 +15,15 @@ namespace Q { namespace detail { - inline std::size_t sscanf_impl( const gsl::cstring_view& input, const std::size_t accumulator ) + inline std::size_t sscanf_impl( const gsl::cstring_span& input, const std::size_t accumulator ) { // Scan successful, all format arguments satisfied return accumulator; } - inline gsl::cstring_view::const_iterator skipWhitespace( gsl::cstring_view::const_iterator begin, gsl::cstring_view::const_iterator end ) + inline gsl::cstring_span::const_iterator skipWhitespace( gsl::cstring_span::const_iterator begin, gsl::cstring_span::const_iterator end ) { - return std::find_if_not< gsl::cstring_view::const_iterator, int( *)( int ) >( + return std::find_if_not< gsl::cstring_span::const_iterator, int( *)( int ) >( begin, end, std::isspace ); @@ -32,7 +32,7 @@ namespace Q // Verbatim string // Try to consume the given string; whitespace means consume all available consecutive whitespace. (So format `" "_v` also accepts input `""_v` and vice-versa.) template< typename... Tail > - std::size_t sscanf_impl( const gsl::cstring_view& input, const std::size_t accumulator, const gsl::cstring_view& expected, Tail&&... tail ) + std::size_t sscanf_impl( const gsl::cstring_span& input, const std::size_t accumulator, const gsl::cstring_span& expected, Tail&&... tail ) { auto inputIt = input.begin(); auto expectedIt = expected.begin(); @@ -72,12 +72,12 @@ namespace Q // Whitespace-terminated string template< typename... Tail > - std::size_t sscanf_impl( const gsl::cstring_view& input, const std::size_t accumulator, gsl::cstring_view& string, Tail&&... tail ) + std::size_t sscanf_impl( const gsl::cstring_span& input, const std::size_t accumulator, gsl::cstring_span& string, Tail&&... tail ) { // skip leading whitespace auto begin = skipWhitespace( input.begin(), input.end() ); // string is whitespace-terminated - auto end = std::find_if< gsl::cstring_view::const_iterator, int( *)( int ) >( + auto end = std::find_if< gsl::cstring_span::const_iterator, int( *)( int ) >( begin, input.end(), std::isspace ); @@ -91,13 +91,13 @@ namespace Q } /** - A non-owning stream buffer; for adapting a gsl::cstring_view to std::istream + A non-owning stream buffer; for adapting a gsl::cstring_span to std::istream */ template< typename CharT > class ArrayViewStreambuf : public std::basic_streambuf< CharT > { public: - ArrayViewStreambuf( const gsl::array_view< const CharT >& view ) + ArrayViewStreambuf( const gsl::span< const CharT >& view ) { // it is not written to, but the basic_streambuf interface still wants a non-const CharT. char* data = const_cast< CharT* >( view.data() ); @@ -138,18 +138,18 @@ namespace Q Forward declaration. */ template< bool skipws = true, typename T, typename... Tail > - std::size_t sscanf_impl_stream( const gsl::cstring_view& input, const std::size_t accumulator, T& value, Tail&&... tail ); + std::size_t sscanf_impl_stream( const gsl::cstring_span& input, const std::size_t accumulator, T& value, Tail&&... tail ); // Float template< typename... Tail > - std::size_t sscanf_impl( const gsl::cstring_view& input, const std::size_t accumulator, float& f, Tail&&... tail ) + std::size_t sscanf_impl( const gsl::cstring_span& input, const std::size_t accumulator, float& f, Tail&&... tail ) { return sscanf_impl_stream( input, accumulator, f, std::forward< Tail >( tail )... ); } // Int template< typename... Tail > - std::size_t sscanf_impl( const gsl::cstring_view& input, const std::size_t accumulator, int& i, Tail&&... tail ) + std::size_t sscanf_impl( const gsl::cstring_span& input, const std::size_t accumulator, int& i, Tail&&... tail ) { return sscanf_impl_stream( input, accumulator, i, std::forward< Tail >( tail )... ); } @@ -158,7 +158,7 @@ namespace Q Conversion using std::istream's operator>> */ template< bool skipws, typename T, typename... Tail > - std::size_t sscanf_impl_stream( const gsl::cstring_view& input, const std::size_t accumulator, T& value, Tail&&... tail ) + std::size_t sscanf_impl_stream( const gsl::cstring_span& input, const std::size_t accumulator, T& value, Tail&&... tail ) { ArrayViewStreambuf< char > buf{ input }; std::istream stream( &buf ); @@ -176,7 +176,7 @@ namespace Q assert( stream.eof() ); pos = input.size(); } - gsl::cstring_view::const_iterator end = input.begin() + static_cast< int >( pos ); + gsl::cstring_span::const_iterator end = input.begin() + static_cast< int >( pos ); return sscanf_impl( { end, input.end() }, accumulator + 1, std::forward< Tail >( tail )... ); } else @@ -191,12 +191,12 @@ namespace Q Works very much like std::sscanf; but the input is a string_view instead of a null-terminated string, and the format is implicit in the arguments. - To describe an expected string literal, pass it as a const reference to gsl::cstring_view, e.g. `"foo bar"_v`; just as with sscanf a single whitespace is taken to mean "all available whitespace". + To describe an expected string literal, pass it as a const reference to gsl::cstring_span, e.g. `"foo bar"_v`; just as with sscanf a single whitespace is taken to mean "all available whitespace". Returns the number of successful assignments made. */ template< typename... Format > - std::size_t sscanf( const gsl::cstring_view& input, Format&&... format ) + std::size_t sscanf( const gsl::cstring_span& input, Format&&... format ) { return detail::sscanf_impl( input, 0, std::forward< Format >( format )... ); } diff --git a/shared/qcommon/safe/string.cpp b/shared/qcommon/safe/string.cpp index e94c688c50..f097b731c5 100644 --- a/shared/qcommon/safe/string.cpp +++ b/shared/qcommon/safe/string.cpp @@ -6,7 +6,7 @@ namespace Q { - Ordering stricmp( const gsl::cstring_view& lhs, const gsl::cstring_view& rhs ) NOEXCEPT + Ordering stricmp( const gsl::cstring_span& lhs, const gsl::cstring_span& rhs ) NOEXCEPT { auto lIt = lhs.begin(); auto rIt = rhs.begin(); @@ -39,7 +39,7 @@ namespace Q return Ordering::LT; } - gsl::cstring_view substr( const gsl::cstring_view& lhs, const std::string::size_type pos, const std::string::size_type count ) + gsl::cstring_span substr( const gsl::cstring_span& lhs, const std::string::size_type pos, const std::string::size_type count ) { if( pos > lhs.size() ) { @@ -47,18 +47,18 @@ namespace Q } auto start = lhs.begin() + pos; auto end = count == std::string::npos ? lhs.end() : std::min( start + count, lhs.end() ); - gsl::cstring_view result{ start, end }; + gsl::cstring_span result{ start, end }; return result; } - int svtoi( const gsl::cstring_view& view ) + int svtoi( const gsl::cstring_span& view ) { int result = 0; Q::sscanf( view, result ); return result; } - float svtof( const gsl::cstring_view& view ) + float svtof( const gsl::cstring_span& view ) { float result = 0.f; Q::sscanf( view, result ); diff --git a/shared/qcommon/safe/string.h b/shared/qcommon/safe/string.h index ab368b934a..19c642a9b1 100644 --- a/shared/qcommon/safe/string.h +++ b/shared/qcommon/safe/string.h @@ -16,20 +16,20 @@ namespace Q EQ = 0, GT = 1 }; - Ordering stricmp( const gsl::cstring_view& lhs, const gsl::cstring_view& rhs ) NOEXCEPT; + Ordering stricmp( const gsl::cstring_span& lhs, const gsl::cstring_span& rhs ) NOEXCEPT; /// Case-insensitive less comparator for cstring_view; e.g. for case insensitive std::map struct CStringViewILess { - bool operator()( const gsl::cstring_view& lhs, const gsl::cstring_view& rhs ) const NOEXCEPT + bool operator()( const gsl::cstring_span& lhs, const gsl::cstring_span& rhs ) const NOEXCEPT { return stricmp( lhs, rhs ) == Ordering::LT; } }; - gsl::cstring_view substr( const gsl::cstring_view& lhs, const std::string::size_type pos = 0, const std::string::size_type count = std::string::npos ); + gsl::cstring_span substr( const gsl::cstring_span& lhs, const std::string::size_type pos = 0, const std::string::size_type count = std::string::npos ); - int svtoi( const gsl::cstring_view& view ); - float svtof( const gsl::cstring_view& view ); + int svtoi( const gsl::cstring_span& view ); + float svtof( const gsl::cstring_span& view ); } // operator<< overloads From f3e8614a638f532cc72a266bbfffeb33bdd9a860 Mon Sep 17 00:00:00 2001 From: V-Sarthou Date: Fri, 29 Sep 2023 05:40:17 +0200 Subject: [PATCH 746/801] [SP] Crash when filling SteerUser neighbors (out of bounds vector access) (#1149) We loop over EntityList, which can contain MAX_GENTITIES values, but mNeighbors can only contain STEER::MAX_NEIGHBORS values. --- code/game/g_navigator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/g_navigator.cpp b/code/game/g_navigator.cpp index 21ca67b5a7..5ffaf66fbb 100644 --- a/code/game/g_navigator.cpp +++ b/code/game/g_navigator.cpp @@ -4151,7 +4151,7 @@ void STEER::Activate(gentity_t* actor) gentity_t* neighbor = 0; int numFound = gi.EntitiesInBox(Mins.v, Maxs.v, EntityList, MAX_GENTITIES); - for (int i=0; i Date: Sat, 30 Sep 2023 01:04:09 +1000 Subject: [PATCH 747/801] [MP] seed RNG in modules (#1125) * [MP] seed RNG in modules * [MP] use the same randomSeed for stdlib+vendored PRNG, and seed it a little earlier --- codemp/cgame/cg_main.c | 2 ++ codemp/game/g_main.c | 5 +++-- codemp/ui/ui_main.c | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/codemp/cgame/cg_main.c b/codemp/cgame/cg_main.c index 91d0204ae5..b9c926d787 100644 --- a/codemp/cgame/cg_main.c +++ b/codemp/cgame/cg_main.c @@ -2403,6 +2403,8 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) const char *s; int i = 0; + Rand_Init( trap->Milliseconds() ); + BG_InitAnimsets(); //clear it out trap->RegisterSharedMemory( cg.sharedBuffer.raw ); diff --git a/codemp/game/g_main.c b/codemp/game/g_main.c index 9ec7f32ef5..31715742ad 100644 --- a/codemp/game/g_main.c +++ b/codemp/game/g_main.c @@ -179,6 +179,9 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) { vmCvar_t ckSum; char serverinfo[MAX_INFO_STRING] = {0}; + Rand_Init( randomSeed ); + srand( randomSeed ); + //Init RMG to 0, it will be autoset to 1 if there is terrain on the level. trap->Cvar_Set("RMG", "0"); RMG.integer = 0; @@ -199,8 +202,6 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) { trap->Print ("gamename: %s\n", GAMEVERSION); trap->Print ("gamedate: %s\n", SOURCE_DATE); - srand( randomSeed ); - G_RegisterCvars(); G_ProcessIPBans(); diff --git a/codemp/ui/ui_main.c b/codemp/ui/ui_main.c index 8ca16b705e..45501d9479 100644 --- a/codemp/ui/ui_main.c +++ b/codemp/ui/ui_main.c @@ -9838,6 +9838,8 @@ UI_Init void UI_Init( qboolean inGameLoad ) { const char *menuSet; + Rand_Init( trap->Milliseconds() ); + // Get the list of possible languages uiInfo.languageCount = trap->SE_GetNumLanguages(); // this does a dir scan, so use carefully From 61b6023045f693626eeb1b92ca188da09f12527e Mon Sep 17 00:00:00 2001 From: razor Date: Sat, 30 Sep 2023 15:16:26 +1000 Subject: [PATCH 748/801] fix copypasta bug in SFloatRange::Clear (#1174) ref #1162 --- code/rd-vanilla/tr_WorldEffects.cpp | 2 +- codemp/rd-vanilla/tr_WorldEffects.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/rd-vanilla/tr_WorldEffects.cpp b/code/rd-vanilla/tr_WorldEffects.cpp index 3cd4fa5e9a..6c65c8dad9 100644 --- a/code/rd-vanilla/tr_WorldEffects.cpp +++ b/code/rd-vanilla/tr_WorldEffects.cpp @@ -237,7 +237,7 @@ struct SFloatRange inline void Clear() { mMin = 0; - mMin = 0; + mMax = 0; } inline void Pick(float& V) { diff --git a/codemp/rd-vanilla/tr_WorldEffects.cpp b/codemp/rd-vanilla/tr_WorldEffects.cpp index 286c973f64..636635697b 100644 --- a/codemp/rd-vanilla/tr_WorldEffects.cpp +++ b/codemp/rd-vanilla/tr_WorldEffects.cpp @@ -209,7 +209,7 @@ struct SFloatRange inline void Clear() { mMin = 0; - mMin = 0; + mMax = 0; } inline void Pick(float& V) { From 26b871955051d6c4b12e583557b08153431df38e Mon Sep 17 00:00:00 2001 From: razor Date: Sat, 30 Sep 2023 17:45:32 +1000 Subject: [PATCH 749/801] [MP] fix off-by-one in TruncateGLExtensionsString which affects mods not derived from OJK (#1175) UI_DrawGLInfo has an array of size 128, which was being filled from a GL extensions string of 129 words and displaying garbage in the UI. Ref #472 --- codemp/rd-vanilla/tr_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-vanilla/tr_init.cpp b/codemp/rd-vanilla/tr_init.cpp index 2fb27a4401..847bae6257 100644 --- a/codemp/rd-vanilla/tr_init.cpp +++ b/codemp/rd-vanilla/tr_init.cpp @@ -751,7 +751,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++; 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 750/801] 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 751/801] [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++; From bf403f7e99943d172c980bfa19a820f5cbdceb11 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 3 Oct 2023 10:04:07 +0100 Subject: [PATCH 752/801] Fix/improve buffer overflow in MSG_ReadBits/MSG_WriteBits (#937) Prevent reading past end of message in MSG_ReadBits. If read past end of msg->data buffer (16348 bytes) the engine could SEGFAULT. Make MSG_WriteBits use an exact buffer overflow check instead of possibly failing with a few bytes left. [smcv: Adapt for OpenJK. CVE-2017-11721 has been allocated for the read buffer overflow.] Signed-off-by: Simon McVittie Co-authored-by: Zack Middleton --- codemp/qcommon/huffman.cpp | 27 ++++++++++++++++--------- codemp/qcommon/msg.cpp | 41 +++++++++++++++++++++++++++++++++----- codemp/qcommon/qcommon.h | 6 +++--- 3 files changed, 57 insertions(+), 17 deletions(-) diff --git a/codemp/qcommon/huffman.cpp b/codemp/qcommon/huffman.cpp index a08e5fab3f..9745a99acb 100644 --- a/codemp/qcommon/huffman.cpp +++ b/codemp/qcommon/huffman.cpp @@ -269,9 +269,14 @@ int Huff_Receive (node_t *node, int *ch, byte *fin) { } /* Get a symbol */ -void Huff_offsetReceive (node_t *node, int *ch, byte *fin, int *offset) { +void Huff_offsetReceive (node_t *node, int *ch, byte *fin, int *offset, int maxoffset) { bloc = *offset; while (node && node->symbol == INTERNAL_NODE) { + if (bloc >= maxoffset) { + *ch = 0; + *offset = maxoffset + 1; + return; + } if (get_bit(fin)) { node = node->right; } else { @@ -288,11 +293,15 @@ void Huff_offsetReceive (node_t *node, int *ch, byte *fin, int *offset) { } /* Send the prefix code for this node */ -static void send(node_t *node, node_t *child, byte *fout) { +static void send(node_t *node, node_t *child, byte *fout, int maxoffset) { if (node->parent) { - send(node->parent, node, fout); + send(node->parent, node, fout, maxoffset); } if (child) { + if (bloc >= maxoffset) { + bloc = maxoffset + 1; + return; + } if (node->right == child) { add_bit(1, fout); } else { @@ -302,22 +311,22 @@ static void send(node_t *node, node_t *child, byte *fout) { } /* Send a symbol */ -void Huff_transmit (huff_t *huff, int ch, byte *fout) { +void Huff_transmit (huff_t *huff, int ch, byte *fout, int maxoffset) { int i; if (huff->loc[ch] == NULL) { /* node_t hasn't been transmitted, send a NYT, then the symbol */ - Huff_transmit(huff, NYT, fout); + Huff_transmit(huff, NYT, fout, maxoffset); for (i = 7; i >= 0; i--) { add_bit((char)((ch >> i) & 0x1), fout); } } else { - send(huff->loc[ch], NULL, fout); + send(huff->loc[ch], NULL, fout, maxoffset); } } -void Huff_offsetTransmit (huff_t *huff, int ch, byte *fout, int *offset) { +void Huff_offsetTransmit (huff_t *huff, int ch, byte *fout, int *offset, int maxoffset) { bloc = *offset; - send(huff->loc[ch], NULL, fout); + send(huff->loc[ch], NULL, fout, maxoffset); *offset = bloc; } @@ -404,7 +413,7 @@ void Huff_Compress(msg_t *mbuf, int offset) { for (i=0; imaxsize - msg->cursize < 4 ) { - msg->overflowed = qtrue; + if ( msg->overflowed ) { return; } @@ -175,6 +173,11 @@ void MSG_WriteBits( msg_t *msg, int value, int bits ) { bits = -bits; } if (msg->oob) { + if ( msg->cursize + ( bits >> 3 ) > msg->maxsize ) { + msg->overflowed = qtrue; + return; + } + if (bits==8) { msg->data[msg->cursize] = value; msg->cursize += 1; @@ -197,6 +200,10 @@ void MSG_WriteBits( msg_t *msg, int value, int bits ) { if (bits&7) { int nbits; nbits = bits&7; + if ( msg->bit + nbits > msg->maxsize << 3 ) { + msg->overflowed = qtrue; + return; + } for(i=0;idata, &msg->bit); value = (value>>1); @@ -208,8 +215,13 @@ void MSG_WriteBits( msg_t *msg, int value, int bits ) { #ifdef _NEWHUFFTABLE_ fwrite(&value, 1, 1, fp); #endif // _NEWHUFFTABLE_ - Huff_offsetTransmit (&msgHuff.compressor, (value&0xff), msg->data, &msg->bit); + Huff_offsetTransmit (&msgHuff.compressor, (value&0xff), msg->data, &msg->bit, msg->maxsize << 3); value = (value>>8); + + if ( msg->bit > msg->maxsize << 3 ) { + msg->overflowed = qtrue; + return; + } } } msg->cursize = (msg->bit>>3)+1; @@ -221,6 +233,11 @@ int MSG_ReadBits( msg_t *msg, int bits ) { int get; qboolean sgn; int i, nbits; + + if ( msg->readcount > msg->cursize ) { + return 0; + } + value = 0; if ( bits < 0 ) { @@ -231,6 +248,11 @@ int MSG_ReadBits( msg_t *msg, int bits ) { } if (msg->oob) { + if (msg->readcount + (bits>>3) > msg->cursize) { + msg->readcount = msg->cursize + 1; + return 0; + } + if (bits==8) { value = msg->data[msg->readcount]; msg->readcount += 1; @@ -253,6 +275,10 @@ int MSG_ReadBits( msg_t *msg, int bits ) { nbits = 0; if (bits&7) { nbits = bits&7; + if (msg->bit + nbits > msg->cursize << 3) { + msg->readcount = msg->cursize + 1; + return 0; + } for(i=0;idata, &msg->bit)<data, &msg->bit); + Huff_offsetReceive (msgHuff.decompressor.tree, &get, msg->data, &msg->bit, msg->cursize<<3); #ifdef _NEWHUFFTABLE_ fwrite(&get, 1, 1, fp); #endif // _NEWHUFFTABLE_ value |= (get<<(i+nbits)); + + if (msg->bit > msg->cursize<<3) { + msg->readcount = msg->cursize + 1; + return 0; + } } } msg->readcount = (msg->bit>>3)+1; diff --git a/codemp/qcommon/qcommon.h b/codemp/qcommon/qcommon.h index 1c69b9f3a5..c4dbdacfb9 100644 --- a/codemp/qcommon/qcommon.h +++ b/codemp/qcommon/qcommon.h @@ -1034,9 +1034,9 @@ void Huff_Decompress(msg_t *buf, int offset); void Huff_Init(huffman_t *huff); void Huff_addRef(huff_t* huff, byte ch); int Huff_Receive (node_t *node, int *ch, byte *fin); -void Huff_transmit (huff_t *huff, int ch, byte *fout); -void Huff_offsetReceive (node_t *node, int *ch, byte *fin, int *offset); -void Huff_offsetTransmit (huff_t *huff, int ch, byte *fout, int *offset); +void Huff_transmit (huff_t *huff, int ch, byte *fout, int maxoffset); +void Huff_offsetReceive (node_t *node, int *ch, byte *fin, int *offset, int maxoffset); +void Huff_offsetTransmit (huff_t *huff, int ch, byte *fout, int *offset, int maxoffset); void Huff_putBit( int bit, byte *fout, int *offset); int Huff_getBit( byte *fout, int *offset); From c9d3e97da935bf77188762a1be5835cbee764104 Mon Sep 17 00:00:00 2001 From: Lawrence A <3211473+lawadr@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:43:37 +0100 Subject: [PATCH 753/801] [SP] Fix hanging cutscenes on fast machines (#1153) On machines that can load levels faster than the hardcoded entity spawning delay, the Icarus sequencer could reference non-existing entities and therefore fail to chain events to progress cutscenes. This change increases the number of warmup frames by 1 to push the possible client-server connection time to after all relevant entities have been spawned. --- code/server/sv_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/server/sv_init.cpp b/code/server/sv_init.cpp index 7b78323877..c9dd488088 100644 --- a/code/server/sv_init.cpp +++ b/code/server/sv_init.cpp @@ -311,7 +311,7 @@ void SV_SpawnServer( const char *server, ForceReload_e eForceReload, qboolean bA SV_InitGameProgs(); // run a few frames to allow everything to settle - for ( i = 0 ;i < 3 ; i++ ) { + for ( i = 0 ;i < 4 ; i++ ) { ge->RunFrame( sv.time ); sv.time += 100; re.G2API_SetTime(sv.time,G2T_SV_TIME); From ffadf53bc93595454029d196bd0d2376aebe65e8 Mon Sep 17 00:00:00 2001 From: razor Date: Fri, 6 Oct 2023 22:26:39 +1100 Subject: [PATCH 754/801] [CI] exclude builds that match debug+portable, and all of WinXP's debug and portable builds. (#1169) --- .github/workflows/build.yml | 47 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a1d035730d..c7c069f76e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,17 +5,17 @@ on: push: branches: [master] paths-ignore: - - '**.md' - - '*.txt' - - '.gitignore' - - 'docs/*' + - "**.md" + - "*.txt" + - ".gitignore" + - "docs/*" pull_request: branches: [master] paths-ignore: - - '**.md' - - '*.txt' - - '.gitignore' - - 'docs/*' + - "**.md" + - "*.txt" + - ".gitignore" + - "docs/*" release: types: [published] @@ -28,6 +28,9 @@ jobs: arch: [x86, x86_64] build_type: [Debug, Release] portable: [Portable, Non-Portable] + exclude: + - build_type: Debug + portable: Portable include: - arch: x86 platform: Win32 @@ -60,13 +63,13 @@ jobs: run: cmake --build . --config ${{ matrix.build_type }} - name: Install - if: ${{ matrix.build_type == 'Release' }} + 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' }} + if: ${{ matrix.build_type == 'Release' }} with: name: OpenJK-windows-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} path: ${{ runner.workspace }}/build/bin @@ -78,8 +81,8 @@ jobs: strategy: matrix: arch: [x86, x86_64] - build_type: [Debug, Release] - portable: [Portable, Non-Portable] + build_type: [Release] + portable: [Non-Portable] include: - arch: x86 platform: Win32 @@ -126,14 +129,14 @@ jobs: run: cmake --build . --config ${{ matrix.build_type }} - name: Install - if: ${{ matrix.build_type == 'Release' }} + 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' }} + if: ${{ matrix.build_type == 'Release' }} with: name: OpenJK-windowsxp-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} path: ${{ runner.workspace }}/build/bin @@ -176,7 +179,7 @@ jobs: 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 @@ -189,7 +192,7 @@ jobs: run: cmake --build . - name: Install - if: ${{ matrix.build_type == 'Release' }} + if: ${{ matrix.build_type == 'Release' }} working-directory: ${{ runner.workspace }}/build shell: bash run: cmake --install . @@ -202,12 +205,12 @@ jobs: if [ ${{ matrix.arch }} == "x86" ]; then chmod +x openjk.i386 else - chmod +x openjk.${{ matrix.arch }} + 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' }} + 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 @@ -248,13 +251,13 @@ jobs: run: cmake --build . - name: Install - if: ${{ matrix.build_type == 'Release' }} + if: ${{ matrix.build_type == 'Release' }} working-directory: ${{ runner.workspace }}/build shell: bash run: cmake --install . - name: Create binary archive - if: ${{ matrix.build_type == 'Release' }} + if: ${{ matrix.build_type == 'Release' }} working-directory: ${{ runner.workspace }}/install/JediAcademy shell: bash run: | @@ -262,7 +265,7 @@ jobs: tar -czvf openjk-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz * - uses: actions/upload-artifact@v3 - if: ${{ matrix.build_type == 'Release' }} + 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 From 137f55a6b55c77d2ab5ea71a7a30f6381dcecbcc Mon Sep 17 00:00:00 2001 From: razor Date: Tue, 10 Oct 2023 15:17:47 +1100 Subject: [PATCH 755/801] Add OpenJO build to GitHub actions (#1173) * pipeline: add OpenJO builds, fix up some context usage and normalise cmake options * fix typo on macOS OpenJO archive step * parallelise builds, split OpenJO steps on windows * looks like the python shell is v2 with no f-strings * alternative per-platform methods for obtaining the processor count * enable JK2 in cmake's InstallConfig module so we get runtime libs...and strip them from the official release anyway :') * Add UseInternalLibs cmake option to default all libs to internal * remove unnecessary game path from create-latest step * allow changes to CMake project files to trigger builds --- .github/workflows/build.yml | 181 ++++++++++++++++++++---------- CMakeLists.txt | 12 +- cmake/Modules/InstallConfig.cmake | 14 +-- codeJK2/win32/starwars.ico | Bin 0 -> 615735 bytes 4 files changed, 136 insertions(+), 71 deletions(-) create mode 100644 codeJK2/win32/starwars.ico diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c7c069f76e..e4418953d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,14 +6,12 @@ on: branches: [master] paths-ignore: - "**.md" - - "*.txt" - ".gitignore" - "docs/*" pull_request: branches: [master] paths-ignore: - "**.md" - - "*.txt" - ".gitignore" - "docs/*" release: @@ -44,27 +42,29 @@ jobs: uses: microsoft/setup-msbuild@v1.1 - name: Create Build Environment - run: cmake -E make_directory ${{ runner.workspace }}/build + run: cmake -E make_directory ${{ github.workspace }}/build - name: Configure CMake shell: bash - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build run: | + OPTIONS="-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=bin" if [ "${{ matrix.portable }}" == "Portable" ]; then - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=bin" + OPTIONS+=" -DBuildPortableVersion=ON" else - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=bin" + OPTIONS+=" -DBuildPortableVersion=OFF" fi + OPTIONS+=" -DBuildJK2SPEngine=ON -DBuildJK2SPGame=ON -DBuildJK2SPRdVanilla=ON" cmake $GITHUB_WORKSPACE -A ${{ matrix.platform }} $OPTIONS - name: Build - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build shell: bash - run: cmake --build . --config ${{ matrix.build_type }} + run: cmake --build . --config ${{ matrix.build_type }} -j $NUMBER_OF_PROCESSORS - name: Install if: ${{ matrix.build_type == 'Release' }} - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build shell: bash run: cmake --install . --config ${{ matrix.build_type }} @@ -72,7 +72,14 @@ jobs: if: ${{ matrix.build_type == 'Release' }} with: name: OpenJK-windows-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} - path: ${{ runner.workspace }}/build/bin + path: ${{ github.workspace }}/build/bin/JediAcademy + if-no-files-found: error + + - uses: actions/upload-artifact@v3 + if: ${{ matrix.build_type == 'Release' }} + with: + name: OpenJO-windows-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{ github.workspace }}/build/bin/JediOutcast if-no-files-found: error msvcxp: @@ -110,36 +117,44 @@ jobs: uses: microsoft/setup-msbuild@v1.1 - name: Create Build Environment - run: cmake -E make_directory ${{ runner.workspace }}/build + run: cmake -E make_directory ${{ github.workspace }}/build - name: Configure CMake shell: bash - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build run: | + OPTIONS="-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=bin" if [ "${{ matrix.portable }}" == "Portable" ]; then - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=bin" + OPTIONS+=" -DBuildPortableVersion=ON" else - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=bin" + OPTIONS+=" -DBuildPortableVersion=OFF" fi + OPTIONS+=" -DBuildJK2SPEngine=ON -DBuildJK2SPGame=ON -DBuildJK2SPRdVanilla=ON" cmake $GITHUB_WORKSPACE -T v141_xp -A ${{ matrix.platform }} $OPTIONS - name: Build - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build shell: bash - run: cmake --build . --config ${{ matrix.build_type }} + run: cmake --build . --config ${{ matrix.build_type }} -j $NUMBER_OF_PROCESSORS - name: Install if: ${{ matrix.build_type == 'Release' }} - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build shell: bash - run: | - cmake --install . --config ${{ matrix.build_type }} + 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 + path: ${{ github.workspace }}/build/bin/JediAcademy + if-no-files-found: error + + - uses: actions/upload-artifact@v3 + if: ${{ matrix.build_type == 'Release' }} + with: + name: OpenJO-windowsxp-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{ github.workspace }}/build/bin/JediOutcast if-no-files-found: error ubuntu: @@ -168,52 +183,59 @@ jobs: 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 + cmake -E make_directory ${{ github.workspace }}/build - name: Configure CMake shell: bash - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build run: | + OPTIONS="-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install" if [ "${{ matrix.portable }}" == "Portable" ]; then - OPTIONS="-DUseInternalLibs=ON -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" + OPTIONS+=" -DUseInternalLibs=ON -DBuildPortableVersion=ON" else - OPTIONS="-DUseInternalLibs=OFF -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" + OPTIONS+=" -DUseInternalLibs=OFF -DBuildPortableVersion=OFF" 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 + OPTIONS+=" -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/linux-i686.cmake" fi + OPTIONS+=" -DBuildJK2SPEngine=ON -DBuildJK2SPGame=ON -DBuildJK2SPRdVanilla=ON" + cmake $GITHUB_WORKSPACE $OPTIONS - name: Build - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build shell: bash - run: cmake --build . + run: cmake --build . -j $(nproc) - name: Install if: ${{ matrix.build_type == 'Release' }} - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build shell: bash run: cmake --install . - - name: Create binary archive - if: ${{ matrix.build_type == 'Release'}} - working-directory: ${{ runner.workspace }}/install/JediAcademy + - name: Create OpenJK binary archive + if: ${{ matrix.build_type == 'Release' }} + working-directory: ${{ github.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 * + run: tar -czvf OpenJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz * + + - name: Create OpenJO binary archive + if: ${{ matrix.build_type == 'Release' }} + working-directory: ${{ github.workspace }}/install/JediOutcast + shell: bash + run: tar -czvf OpenJO-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 + path: ${{github.workspace}}/install/JediAcademy/OpenJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz + if-no-files-found: error + + - uses: actions/upload-artifact@v3 + if: ${{ matrix.build_type == 'Release' }} + with: + name: OpenJO-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{github.workspace}}/install/JediOutcast/OpenJO-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz if-no-files-found: error macos: @@ -232,43 +254,60 @@ jobs: - name: Create Build Environment run: | brew install zlib libjpeg libpng sdl2 - cmake -E make_directory ${{ runner.workspace }}/build + cmake -E make_directory ${{ github.workspace }}/build - name: Configure CMake shell: bash - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build run: | + OPTIONS="-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install" if [ "${{ matrix.portable }}" == "Portable" ]; then - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DUseInternalLibs=ON -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" + OPTIONS+=" -DUseInternalLibs=ON -DBuildPortableVersion=ON" else - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DUseInternalLibs=OFF -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" + OPTIONS+=" -DUseInternalLibs=OFF -DBuildPortableVersion=OFF" fi + OPTIONS+=" -DBuildJK2SPEngine=ON -DBuildJK2SPGame=ON -DBuildJK2SPRdVanilla=ON" cmake $GITHUB_WORKSPACE $OPTIONS - name: Build - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build shell: bash - run: cmake --build . + run: cmake --build . -j $(getconf _NPROCESSORS_ONLN) - name: Install if: ${{ matrix.build_type == 'Release' }} - working-directory: ${{ runner.workspace }}/build + working-directory: ${{ github.workspace }}/build shell: bash run: cmake --install . - - name: Create binary archive + - name: Create OpenJK binary archive if: ${{ matrix.build_type == 'Release' }} - working-directory: ${{ runner.workspace }}/install/JediAcademy + working-directory: ${{ github.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 * + tar -czvf openjk-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz * + + - name: Create OpenJO binary archive + if: ${{ matrix.build_type == 'Release' }} + working-directory: ${{ github.workspace }}/install/JediOutcast + shell: bash + run: | + chmod +x openjo_sp.x86_64.app/Contents/MacOS/openjo_sp.x86_64 + tar -czvf openjo_sp-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 + path: ${{ github.workspace }}/install/JediAcademy/openjk-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz + if-no-files-found: error + + - uses: actions/upload-artifact@v3 + if: ${{ matrix.build_type == 'Release' }} + with: + name: OpenJO-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{ github.workspace }}/install/JediOutcast/openjo_sp-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz if-no-files-found: error create-latest: @@ -285,11 +324,17 @@ 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-Release-Non-Portable/* OpenJK-linux-x86.tar.gz - 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-windows-x86.zip ./OpenJK-windows-x86-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + 7z a -r OpenJK-windows-x86_64.zip ./OpenJK-windows-x86_64-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + mv ./OpenJK-linux-x86-Release-Non-Portable/* OpenJK-linux-x86.tar.gz + 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 OpenJO-windows-x86.zip ./OpenJO-windows-x86-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + 7z a -r OpenJO-windows-x86_64.zip ./OpenJO-windows-x86_64-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + mv ./OpenJO-linux-x86-Release-Non-Portable/* OpenJO-linux-x86.tar.gz + mv ./OpenJO-linux-x86_64-Release-Non-Portable/* OpenJO-linux-x86_64.tar.gz + mv ./OpenJO-macos-x86_64-Release-Non-Portable/* OpenJO-macos-x86_64.tar.gz - name: Create latest build uses: marvinpinto/action-automatic-releases@latest @@ -330,6 +375,26 @@ jobs: artifact_name: OpenJK-macos-x86_64.tar.gz zip: false + - artifact_dir: OpenJO-windows-x86-Release-Non-Portable/JediOutcast + artifact_name: OpenJO-windows-x86.zip + zip: true + + - artifact_dir: OpenJO-windows-x86_64-Release-Non-Portable/JediOutcast + artifact_name: OpenJO-windows-x86_64.zip + zip: true + + - artifact_dir: OpenJO-linux-x86-Release-Non-Portable + artifact_name: OpenJO-linux-x86.tar.gz + zip: false + + - artifact_dir: OpenJO-linux-x86_64-Release-Non-Portable + artifact_name: OpenJO-linux-x86_64.tar.gz + zip: false + + - artifact_dir: OpenJO-macos-x86_64-Release-Non-Portable + artifact_name: OpenJO-macos-x86_64.tar.gz + zip: false + steps: - uses: actions/checkout@v3 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index b0aeb6dce8..d32ed22ab8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,17 @@ #============================================================================ # Copyright (C) 2013 - 2018, 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 . #============================================================================ @@ -65,7 +65,7 @@ set(UseInternalPNGDefault OFF) set(UseInternalJPEGDefault OFF) set(UseInternalSDL2Default OFF) -if(WIN32) +if(UseInternalLibs OR WIN32) set(UseInternalOpenALDefault ON) set(UseInternalZlibDefault ON) set(UseInternalPNGDefault ON) @@ -248,7 +248,7 @@ elseif (("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" M # enable somewhat modern C++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - + if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-comment") diff --git a/cmake/Modules/InstallConfig.cmake b/cmake/Modules/InstallConfig.cmake index a25f87f0f5..c8c493b61b 100644 --- a/cmake/Modules/InstallConfig.cmake +++ b/cmake/Modules/InstallConfig.cmake @@ -1,17 +1,17 @@ #============================================================================ # Copyright (C) 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 . #============================================================================ @@ -71,7 +71,7 @@ if(WIN32) set(CPACK_NSIS_PACKAGE_NAME "OpenJK") set(CPACK_NSIS_MUI_ICON "${SharedDir}/icons/icon.ico") set(CPACK_NSIS_MUI_UNIICON "${SharedDir}/icons/icon.ico") - set(CPACK_NSIS_URL_INFO_ABOUT "http://openjk.org") + set(CPACK_NSIS_URL_INFO_ABOUT "https://openjk.org") set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) include(InstallRequiredSystemLibraries) @@ -121,8 +121,8 @@ if(WIN32) endif() # Don't run this for now until we have JK2 SP working - if(FALSE AND BuildJK2SPEngine) - string(REPLACE "/" "\\\\" ICON "${SPDir}/win32/starwars.ico") + if(BuildJK2SPEngine) + string(REPLACE "/" "\\\\" ICON "${JK2SPDir}/win32/starwars.ico") set(CPACK_NSIS_CREATE_ICONS_EXTRA "${CPACK_NSIS_CREATE_ICONS_EXTRA} CreateShortCut '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Jedi Outcast SP.lnk' \\\\ diff --git a/codeJK2/win32/starwars.ico b/codeJK2/win32/starwars.ico new file mode 100644 index 0000000000000000000000000000000000000000..c07f6c314e5384b0c729c481f7f0523bc5e7bfed GIT binary patch literal 615735 zcmeF)1-zBjwmyE2iHV4cfr5dch=5&ylp>&XcO%{1jf8Y}Bi)_S-C&^D?J-W>bI<*M z{@-`a&0>>sJQ(+P<+F}w?Y-A}-!Y###xr7$Io~8n{*)wXk{fPF;{R_=QtQ$rNxCOV zk|a%<@bmO*lO*}p?=ojj_&HUQBtw1n`RBvW=^sgwBwNNLNji2+_<3uRBsD6!fPc~T z9-osWNxyV|ivL_K#U)AJJaqEs8`@r;B;6O6CQ0uTE}JBc|3%-s@PAic_NSYZU3p8g zE3dpfT=plv`dEg$hIFYrxO44iGT-+TA5D_vic6DJE1GTdf)ShM535)1#cQuT=Pmpp zbGkdq7k!~az2fU;4O%nf^|rN(mM@a)>4)#W>}Q~a>yF2@{9*c=Fz>m(Cd8pu$V> z&zs%XJJgvou6MF4lO#`?q<8CTODA+)G_K3U0d4L}dBt^?Cz&y_`@k*@;-m2S-fe5m z8q@2Bq|r4BW`A(q%-5HU?>u8c-r7JH(!cVTSDKxYEET8Aq;?E52*ClJFR5x6mSaE+!#Pj|=WwOi4 zzm)m-d&kCitvsYzfe((qU#C>|J8rl**N1l6Taz{{{>b5j`{wqkJiTLqqel+4u9)q? zI}qW|p9b>>b_$sMswB^(OV+D?fdhMYEg02)!SLqZ3}{_0@8fr*yzWoQuDT@Y6=wUq z<3Hn%wB_2XF7tJCRjFjYE-h+}>D^@C?(GXlw|nFDy8CzU7}2dx=VsL!)F}I0rqrpD zUvk4WmmB68mpS_{eDcO?FHd{Rr4dR0s2fBg2gVZ3L*Vxr#~>P^>QktOw&-C9)Jw02pUmma$- z`JXbUzPfR#$KgMxZ?&nN3LiSKw?T;~GTwFd9XDK(`;j|lj2|+vTeGa`liiy9%JYxH z2$NlN`6FqP_G(%A{dbQxDf`^h_a#kzbJ7RyxVmo9M_qqbpQ@8P7CN|pPt8JE?z=T< z${ViCeAg9~Ubt`L>P17kHF_@Hbt$g9;yi|T#buYIyY0$GWuE=$gZIYwZd5K?${ua% z<$EGk&J5Q#EB(Zw1N&z8tvb0wVe?zNaF(aiUib9<*Eg+MvRsb4dN(P0aNq9sHS;}u z*HxxF5gwzU?;o2prss

Hg%Xe5owQwzygRpUTsd#z zvY8_%b*nI;eUUBeS1g*?`_s=pn=`IY-ptAGyeVns)K~RvP|)??7}+)Z1J_=4lujdM)tTw?8tMQc|s zo;$WzzAQJ~nIf{{dsAN7y5h5k_U&4;aB{&XZccV}+y|e;|AuQWEAsTMZ!Vj8c>m6p z<)6O$mMi^@GPp&~2e0kdsKDVv2WPxiWoqZ5n>MT&+qG)lytk#hgB*Nyog_=-s#9qR*M`N*Xst*RLD9{!IGWvFPqCYlb$-y>{vBS8`;&K5696 zeArh${NVWbzRd(vE_FiclmAbSyKlatNttJl9^OCk^%mLFUt>h!&*Az<4(@k-`m=r0 zn!5Q@7kK*aw0EYs>IxitS+?|7PaWLu!{f&qm3}(SO;?-_9=e3NwMLuZ)IpXNt>f7kTXHp#$`1T>B!Bf9cVbHwg%nh)^y=LA_g) z`{cv->lAzPo?G1XEa1fNuR5W^?8@{f5l?%lP0O3x}|+7{WcYViwM zZbq|LUVdqsn=UVvGws`l_73jaF!P;PTz~aBg%7vD61U!PWwr;BjT_W$_M~AiJaU_8 z;m(_{%AN80H^vQ^@>;EttqZSPu`q9zo9?>#s@sxX^5SEu)-RtoZcx|9@44#cWEbSg z%>M1kuXyslYrD02b>fJA#a?*yp;SrpJeYLG*w?4_esxrvBI{SoFZ@IbI#WFFle4Cb z?$oTt!>O)_{L6Wfi9_U#iMaXtE7IO_S&`h2bZghReUlpXOFlh!^3XT>)tTI-)S4x; znw5L5L(>{v+BVLY^`X=^M*c3Y%!#jap7(&_f^WX=(lj?;k@wjQEo&B9GH23)3B6~J z=&)(c(oPLZ=X)+gs^piZxb_k{z+a!|Qs?;-sjj->(%WvhJX_k!r;X}6y>D&vyJG&d zyboVXKmCaq=lS{t{^{x~FTFqIrBlWX9?|vH*BTaFzHkQL8 zCx2(ZjPevEha{E!?;_+Wu5#MH2$>V$m}oB$!3v-M`Y5?0+o#XhUws+2kH7rrmzXE= zcE933lqJ}>BSq4*w_o$%o!7-*X>Y$aRf?;SIgx%fiQEVXciwc>qxaoVr%IV21N!8D z{MMJBxOL*V(H&YgdOU6N)VEyCaDFv;j2r?PQ(s@|rDxxJ_wC&~w$^+3-o}OQ+q-+G z5VUcvN}2CYcH?yynZyN)NqWjbq*M?pudiyjm`6 zh7@uTAG;{GJO4$@0^KlKFFtZhy`oPAdB)U#WKxsI$aC!N!>y|o%KzA{cc;8M${!|jR_ue_up?dyOSyMfn=6Zn# zEh0RiF0NET5;{y0xf^wTGF|dYx$f#%IU7JWu3Ncv>5Ky#m+s%QYya+Ty_!^PR5s7E z52m>9wrdz5sbmmAs-KTVqHh{qz~uHDlPan(?V|Z}wQtdA`Qmvim(1V0bMt|{JEslo zFzL0%n>Va}>+rs%bEeInK56`@p>?WPd^kdvr^fC#Qn*Q0#?`(i~c;3f-r&ys+;NVWZ5&`)U#9T9a}d|pEB{Ww8^tSbW_D#ceN=W z)1MRa(4PB%GGExKS%ccEmMt9Iw|kKsnedXb6(;|AR0$cvq@gPJCoi5e z!`wHf$bUPvY5r9D8x8i6dv7TE%Cv37-?`-$jYe2>4Uqd=-)@pC|p&1+zc<^yAk$waWWw%FOp9 zqtEH?xHjKoDeD(|I>1@H+t#OTOk8>HzH4*f5-zO z^2k=o<+zg!KH~~LW@bxfP1U`5t$jPUES@{PZi#H!GNhp40<#NLBr|p6b(hnb;?LbN zW8Bd9aqhm|4PLpoe2%;N_UKgbx%;1aAjNYJrocaqN}Rx_Zh}0Yesnx0cFHXGCWBZFs!@rochoI#&%&9LcWzlfWBjo4Ia5D&-whbvtR=GJv%e)X$)Rm(I@Kw0{JnQR z{rJOP&8xGfGTHBBN|VP7sa5b1AiSFI?$+fJ^m$a>EMsE$_E^4Xu^np{f9I`3 z=w;^kVP&7cGh2q6ay)!g!)j-yLgaD#!L>4tX`FTW z%&|ug?(_96o8Bz&_^mX`MMn4QY=8&$Z0p;mj$blfHJlT7KFj|@kH=xoreoE@*?V_v zR-kKE`Z@m5FCR*My*Q_P%ep(aZXlA<$C#EcE0UPRLA5fCs1wN(O=$CMn^w$y`^bTJ z2()`gscfk@7urbw8x_3oouh}gZ(h4##su``f~@#FQ-;lv1JYpg=)si`P1eM>$G$Gmj2Zr9$qIidDg64vSQX)l5ngW*RHIb zJGIyY4h+hhriIgTzQ(e1>!wD9(vedFdmg@~Jkn7IEY?E!z9@^d zv=T&WQzhTVwabaLcKQ67BYMQ~S+#V*s)aK@c<=26Z%nR|CpG&@lk#e8qhe{8RA|Gh zW#nPA^JEklCw-z>{sNu?Z%`pWVxkv<-8pCj?L>fuU%g2rMp=!A8jC} zn-bz)w$rs%{>|%Gy7;zD>xb8UY;;V2Rxe+)bMv}ovnSVo`CdB1PJJ;@y^GY$d-vL< z^L+(?&C6zYBOG-eV!ZUyKbaSnKCF8yq_bnox(zEASAQW5OiVP9&2=PFvMV6QuKP4B zslr2N=rexavunqOHOr?DXg9Ft!!(cpDXx!5#jGfdhgY|Hz|EpF$g z=fUTW8^R;7v!PRPxFRAwt~txSH<K@+`x#lpJz??I2ruD;x5!#@a{ccW`iGC>}E80Krsn`_rCi!@~K z&aHW}q`d!*Yw3?WGFwy3G&t4>pJVS(u&2}C$T6MAzT8okC+>pDruC~`cK7zp5*gl# zobfLPdGchrrG6rL@UwUf;f!sPW9`zp0uLb&c^DTwnJv<2UNoK0?Ap3v*S5{9j~b9R zKFm1&iQjNu_uqc4TJ(Y$6S+TYL(PglkSB9w2yt#dQy%(*4oIDBCD zCm(&#uw)cp$>NjC%AMaVck(y9O_nr=8XLP+5{p3sdw^J(p*#y`PvZf3XNGegOHV9cfGE{XSAo5L z*?e2xT;tWeasdV# zI$&ju7Cn(Rx#1A?{FaqiB$68-5;iGaTGrpW_02_drd7_D>DdQv!NQ~j!DjLEZz;lPIjrHA*VyvCp^7kJ##=X>wI^J?h=evDOPqSQX|9nb%s4^t24zTQZS7NQe8*=+BB}ce$~=hQ^%Drn3FyTrHqu9A3tnB zkf(3ejFCPsTU74(JD<;ZGl*z)^|FO90KZnTSUv$NVSpAq?3s7`$={e@i7*MGZDWhp9KCfPaZsUVLNfgcVB`^zGKZO^qUxM-1Gva~ow2{JeP1 z^ltS_zuu$6vc>b~&YJQ3;}58nu>uNgRpMtO6PL%ENS7|XL~g>^X@$&`BY5P#8;1_) zJ!Smp^=nt|*!t$C)r+@pSjl-w@MlaOH)?2qlSTJJR!IMGJDs_3gGwyGS>LlbP;*A6 z4;h+4VXgTZ)xQUPI+aP^vtkD8v#XaatolM4S{1*a z_O4vESlG<@audGHuP57!MD_$`rj|IPU*U5{gB zYgV)?mEP-($zu=f-X=+IQm2|?8SP>S4Ed~=`b~aG7^@LV8w%^yisV$Z+Pibh)^#f+ z{{w40Ja_6i^_>rozuTxYf()8k3W3B zS;hRaAO)I`FdG6QibBX=SC!(D;~e=0%?G|L7uD3xcTej|FGTY1*tB)+(o^LB;Jr3g zUb3`c0S2|20xGAJrm|`Jezj5XJhVNMJZaQXBrd-r#Z_2Qt)%c%w<+>=suszwfVh6y z+>LWb?_4%*XH-_+vVZs1*IHET+oFoXikd}m2S&jbAYc@~^jv@)O0a@C$@x|~BVm^6 zC>GSMR(4qb*VeCIs!XQZxO@A?w+`*!ux#Gy1=H89jOwB9964YWVadX|OXkn&*t%)? z5(T+7-!*pm(#_Xj8Pz>6zsTu*+*%0__M}%_B0Zxm3Zoh(q=;Z|*`)sLH>Rv#yK4Hx zF}+&UY*jux`Sn|{-=IJ9CXd{=Ym3F~?loR8LG7B3|9aKSEu1@Z`_@fkM~}e#mKd8BN!y`HO#gRo ziOV1C_lr+I?octS<%eR=-tNQIDwbKgXx@q?^SgI!Svc3@G|DKH>f!+gv%UzT$Lc zG{MRx+83TF{reN~nw3AvpHrH~`G4D&Uwl^g<@=Qv~FBy_x4RIm(K6f zB3hh=1EWZ&yG5+@^C!VqT|np#dHSgsq2SoQLFEJc_I&&GmlH-0k8bxs3e0I<)UWY> z`5bpPDs$3*O>F$A^{oZd_^)kWees#msX8ff`aITh&Bv8HA4%D&L5+R8wryCm?DZ}! zianP~1My#pCb2OOiP=rdZd<6>d}ey|uz&P+F(l$tNyJ!jg4-P<;54(rymvQ`yWc3F`g#{L;o5NXbpmm+yuN>3V< zdd7N#zKXBE`m%kEg5)P^r`C^(x2_e-g(PfBj<&< z6zph-Z^5~G=>p^zW^2vavttWSVez|pxoi+KQl!e=5a!=91LHMnPKs`rUl*SI zeQ@7y%a<&mFa~Zxadf|~e24YX1v4krE%=~-ge|Kq|GQIQ!f=kULlvv{XjIl>B$xEr zXPk{eORX)j|7R&Vy1^ka5KIj9lzI3<#C!?tT zQrhuDdw=x7``CchxLU+rMbg>~X1#gOj?ID%WW}bWMNw7v-&0LJ>{ilrK<) zC=c4fz|;>coog2Xz8;QmzW%aX!}4s};osGl#$ zzkU5m{k8g&$bWFp_M?XnSw6JP`jIuVsxcBolIZ<7li zIk2Z^;|f--I2|o|R+ui(ihU08s`Jv)+WGEYHt&t22lu+y`|rKmyl7erlfl>Xp-il8 z-SQa2?Yvemo;kZ$mBjMvZ?Hau|0DU29O4URw8^z-+Q^8+wr-FSXpPlmsq`N_I14g6 z)&pG42Nunm!l8$L8dZx68~|gdJZ6ozYFXmJgZuYsv|?8Jb($2u59iAh@4ESF-bWx| z(i@k5Y18^uVF*j+&6wJ|!J&OS<-hRPPvaHyU)%L(O>LQd_57)NLw9X`Q;w`@j73X1 ztw6h)#u^P?Zn0tYGQztc#%odh0p!4niFAQ1255fAUeMnuV}5Miu`XV+cyQcs{}qv|n_p_F~kmwt1~vZ`rVFcK?QyXLy|~ zA%9=BbiSrf!Y`RU71bAh>UO~o;VFhYiWB0Xb*NSB__4QK#4OC5G+OtVaUpZt=PpEk z0hZV-p%V)>OLg@m!E&yw(O(AGo&O$kIGN6j3z{Pf=LA8M(xXFT(M{l_KWHN z3igYCg8aOy#*|far&vUE9ry^DAWwMQ4qLFW;))RtdG!aAKPn=vUPfu*V|K#c(en?1 zpB6TxzU3-Bq|@ME&lAfZeLgk>ofYd=vd|fT`x2rq`pXg*D;}qD^Kl z2&DJjb}ju0v5i=l{uq@0r`F}OX}lx2i^QIXB!Bi2Y@Z?tqGXcB_3qoS`3f#j@M7vA2Zus<*kJ+FwKrnFO{@2xb z6AoSHXv0_T)g6ToS;6AjQ!$e6E_u^w(a5>vXTK;^{3d)Q|A;!7wS$Zv)aR=&KjV@z z+$B$s(i1aoiJdDHoHQw%R)aOt)t;6i@5VoXMWIX>MOS?x^@5p`qhi$Nb#Ja+ z*|PY9qLByhiUQie8(|90Bfpluc~c|#-(0u4OSuQ64@h|Yn30M|ieTapQ^^}r4~d=` zZ&fmbjs467(S@0w*9DA&|_jb@d|0-Z{dW4({LGvScPf z5te36i7$8_`MF^A{~&+Ef|2mKGwb5I9zJAN=W(5oE5+#R&Nfx@e)h?Sru*~HJ{A2^ z9&o9fp@=g@J=br73JIv(i_ULYvjQMEWN_COOgMC_Q=y1BV*k!1KjRhukpIa3-5b}f z_FX|fwP&jIndT7QOP`kgKe>7Em+oFXYl;?a*}>BJv-FQU!c{=aM<`?|s&^ zA~YS$V)8Ccs>|G|kQk;>kqjbU2{`oPy@^47E;YtKC+k<_7s5sIAJ{{F;D`025H`e4 z7mC1F>M_^ccax%#@~Bj+64Wj7guW$3MVgR!t`p07uJ>RyUmyzkJ9i`8H3hbDcB)%a zx{5_p-<;5+Pc6wWki&;M|LT=WkUzu^LuzH3Gj-h2gL_OO-NTT0Cg5rMD5|>%gv=@5 z*S}NKkB+~`SI(I}$zX+TY=n*_wzYG~eA@5L7b`Xeb`TYO^0r15@*h61#}F3Io?7RX z2W@l--p6N%k&rUnolH|{?UE|d)KXAUh=s+f=ChP#}@06CvPIWr|0#H zX0a_qnccxgyzq-zZlU>L0sgK4)ZUFz$JQKMMy5dUmjzjAo(%yM4xQ)#;gsUo*7W~TWdH434uI=om{WHo8jAZvWz ze)DzvMm4Y;ZDb~9>Sur-#sDI+xdr!ugvqQ8)D$?(rD3V8L={U&laT`$$xo7~x?8oB zlr5}30{`{u8H4;)kX*qD0z`4J&E<{q~!$CX5ld6oWt<>n;oMo+nEr5oB=;4Dz+|E!SIny9qXyL~na6%keupH23MD~NrP#P;@jMcc&1+X^CiWsft)4k; zG9@%XZr6u>#TR|PR>@o(t>TOiARJE9Jc{f7!{T#%AdH84V+l8PM+B%GI_Hfk!k8)J zM^q`6%N_k*i2#`Tw&7p1c<#9TeX2f0e{39@HgPP55tGn5Bh`pZmm1b6w|$Fr{?ooa zyQ(Wv8-AH{4C@!ryD0xmqVka;Feue#_ciG~IG!= zBK(8?sL0`e<%>yUMpSz-jgk?}4dLaSPxkKC{?PtCx=||>E8v$5_P*Pr?pVT`^a~9a zE?|UkFa)z;p%bHW3ZSN?B@5)V*?9AYRg=e!Xi&2v@M$k6Tenn#{Q3v%XAu7!d+X4| z(Zghd5(GH6X!z><+0zg1+cWU>K1MCV0Smik6sSNrcM*jT<1>?nz~KUisj^w5WE3)v z;xE52ZSn-}$#(9Z?V5C{UsehO|4plx3Vzhz#Gm+c^uXR7tLN*{y8gnsZ*1MPVeF_8 zzV3x}Su~2kHb@C+{|vUjfJulx0v6!#S#*h(8U>;t02U(2p#FU|x zuAP~KSEG8h3+2mWTp|#W8~Qca3%Ta6`5E%l3Um}m6+McLIi~R9Th$PZ&K$A#U!QF* z1PZ7IF4Eq~7U+5WWl#}Yo@f=jkgNUrpNWWwUx@9m;NYlJ{DqycB^&>}(au>>GLSG9 z!wIkO8~^>|-yaBER0N`ZA|0bE(yd>0pGb7iU*=!jSbp-&FLVF@b61Vy9Oo->=}*4m zAC72J4s$h0MGPxbs>JE;xK4di zHl6t8mwr^K_AzOx3Gzi>zv0?w3e2XljGl4%S=p67Tv|NHnv=c3*-5hB?45@Uh`c=mb zA24su%pE(nzklp)XZaO-;Tfy0@t39BPd@(G`u>8sGbfH6F=kl*ULBk3Zhh>&Xib(o z;J%pv%R)haFwj}2Adr7pvJt~@wP=UtTivKovd~8#e)z-pf7XAfUFy%@epBI<>~#v< zlkm!akHv8x@K+507SP{$`$(G>O|6NWJLd-Q1x!F(Dw@??^auXu!XG#yc3dHP!QR%d zbxvCBs9mk%fBoa{4hILX7Rn#K|E_wG9Qu~MbYFYfU;=;L6q>fh=O7Zntx2d*(LxgLPRXh^NM*yJ2>3BD&4MIz2aYf{C?lAtvfc`zq9*? zAHJ_sB4?L!4|Xn_@X`*N2>;FBfA?qj>u1xF#{}3BSAx?7qWsGrA<)_2j|x7(Q9}?h zis7xOY6_zKdfw{SsQ4rNqy1kA_%|w@O9xc^)wJ+^C-L988B>iMK2)0}6X3Wx5p0&w z!4h@N{SktmWdpHMBug||x&C~I3Q9idOmiWtRcq06_{P_KM!v_!4 zVXL!?`_NM@UlUNtDMAQzmfQc|{uPxJ8QO^>=jAI!KB9e1#ky5(7ivJSQ2i!jSr$Q|AH|KKc~i99r9MuHQOr+1?v!5mIc4hWqmPCL+v2Fo*w# zZQ)ep6V_JXAS{>j%8!I7ie?%wMV@%uwm4g3I+uN*O}$g`|Ngr;|C~ktcW?XKUw-V` zs-XbYwjj-ccuXHJ3K9j~9&5|wWlmWjh?&Fx!?TbWdHN>Kq40Qs&cgvGNREV^TqKrI z@DX_m9km=gc&B@X3~f)~Z@ZHY(l0*$v_qBL0r@lWmnMimJ2idP7r6kt9W|HQ1cZX* zbmo_TcQ08+v{G|*)PO`1@{lTS3qj!j2W%lR^7uB6e6*x>_2mK*IN*E*2RW}=8ReI; z+7n?@3G$cW_NtVjUH!@-{(-+O{0^n*Q2F^c+UAJA`c!}P!w){NzgYh310L$!s#a-V zGpEj(Id$=ZIm?zT zSTJYCyPmhaCwjb4RD#&Kxl8Lti>8lRIC*HFRyDZ*$FQ&|CSZQ~7u|!xAvZPYoHBD@ zfG1}m<`=>&{4X_xxY`>9qvq)Z-qIw=NQ2oqrweMCw(M6*Cbat805n2!DzaZvz2LG5Ey zA69bde1!ask-}3y-jFJSU1S0i{*ivRZd`l9=%LdmkDESa!iuE}?K%DMgZJ&CiWPs> zQExaa@3gFx*AA5Ut4)df?PLu2JCpPKKY!DvLA9}iUR%C&k%vUtA?PH!DHF$z88P_v z*Sfy&Y-UAKOKBSWnFFJfZc_t!M{o^TkyjEUMNT2KcmD6m6ylr{)IJanPls*jJWVrF zYq(%Hb_x#)4mbDH5BKfaWz5K-)=-=!sIT66gSM@;uUDa6$#e}X7KA_Mfq$sKof-ce zI=CPIC=l6`{*S-^y-9_9eX2avu4H=K{984Ab=i_dM-J}W`sUin<42DgK6p^SUZo4Y zXu6pL#xoIgfH{O&NLV;dWC;ITxF~>6+KBCAfh8x)s0Ego_U@F|7~_L?UGGR7n5*!J z^NZxoI-pPYv7?5~m^R5qR?90ZmM?8kv$E=?=lVF*!e+y^b;>&V!P$@J!9VVQ8OT5W z@%KjM@=D5_Tje21ra%b#;xid1j2(S&-!7+LyfJmc@WK5D_3d8jm0SuPJig823^2?B z+axWS87xDfLLpyc(ZRHTpInp}eEf+;c{FOzsD&JC+~`=nH7UEpP;r6mS^D?tJa**J z1#@R%a+E%Q-rSe-WRtEc8mL~@f8}21Vo~Gv^(*tgiR+(d>i>!ScbzR-77H4ceX(o# z2U`@qUkYsNpAAqhYd7>052Ttner&X7dFuu&H>7{>emy!A$odecZz5Pkm<7`EO{h|M zMuo!i{qNZw#K8})R**w^s1T~>m|gW@%r<5@VBS_Z-4u1gEB9$op7p~DyS6LO|7PxdgahUFXdjb zY%!+V`sQkndL7u;)8}idcu3QHhMb6zgGNX4aVkWSEKIQI-{%x02A{RES)7CIsSv7H zOk>@UH#%diS?1-TulJbs#`GhH_Bp)zy<_jTYTgtPc|pd<00k~VyZB!M zzHI(y6um{N>J?lAgB2uDA)yf$#-ig>@cSX6Gr?!GI0uVTd**Dgkhc^ls_)UZ;izE) z_U+y6Fgk~Yu3fYGnTJvZWOxKGy5~o5Nm{KcQs7QyA87q=)PL4F)8M;5|G8eNTrG>= z@1zbDY}>cZsmbN*xgNS5*9V8h+CA!651s`b_3zoCW$iNLGz$u_=8J3QvlNcl^6zj8 zP6OYLc;K^H$rRC_W$`ihWU1lkGU zvstkv=D#|~4iTOz0PNEP3Z57Q$IkwTnLytrYa8WQHo zeDku!3%G;mkh)E4hY#x8uT$f)xzjTo&WJG7Lz)nug3wAN%=>LirtlY%2{lDKI6n@) zLoKASfyU8D`+B7Z_v=nSoxbISsPDe}bE_uxot>g4WB8O`Pz3yFN8zp4fXH0FCD7niNJ4^umq+?8rOeSpfA7tqIU7;Eu3-UdbFqk=0PLEFl3HQ+$(OL zs77@{2hq|+^GyLO&}A`o;+XzjnpAt`ab-XgBxYdCW-UxX)X*3UN`J#C2;hqcxFpez z4Wwv?YM~MPdD*o=vHh-1Dvcd6=$o&<^32_DzWU;?fBj3FW)1v43dm#Q;tgr0FB%$T zgd8-DMKF!%)P)zK66l%ux33)GPxCE7I!!1s{<=^;|NOI>g`aVBturu@Ir715A()X{ zi7MU8bYLM9jbylcdIIXTt5+V_yPXx7f_by1^={vwR^cc734h{AQ$SCAR~D~K!Q|;) zND6*s7D`O}q5`2NhfApp6JfGx*dTyx%ABS$2k5Le^1B%=)uoE{j}Q4k6M2Zl}{qkcFG?Lo`M-o zp}|A(0<43BFxO5PDE?gZ%yP#8amPEiu3s?cjb3eP*Dm}xOEizB01-LSS{5%TW%3L^ zM5F-uHUA|rPpqCPDlo3QW2Iy21bn(}EL|Ix9yN5p58rtFwxIChi;S^Xq& z{Ap%Ht!LtYPjrN}>%d`7*})A4v7!o!6V$1pJdl&xT+Qs&G^q zx3EOYFH$02jS_j^ed}<@wVm#}aNevwZEDmk@F1B@fe)iHBQ0b zDT%G(f$pq$_U_V7geE~|1rD~IJ!8si%_};r%n?Q*loG@;b_ovM`;}Sf6y}N1zOgV# z0|`MR@LN`RzE7uS-+uFr(;j#c-^>WI+j9u^8o*{>4|B`{Cykz{6{FEcI? zGH$eDi*_0m$<(7+CDDinTkPAp*^$ow-~arNhqKCLmBIw%EjJEriqdx$}i-jw+8F;zIayu>j^~sFaCEFyi!Amf8dYqKK}UQin$_Nb1YIIjlgnv zgWgKXX+9bOKIPB*_+77cZX@7lEQ(INwi&NqDyMo>Sn)9n`}b^ry+`{FRdcdOwJB!K zaYzcxW}Jn71xFlLelu>~%|0Cvy*RvDgkZ3S+^bRXZCkhKfR)h*1^?^6{;_S#WfPrg56~T90mOo}HRh6?<^Rl+Y{)oTyeTWsAZm9^3`b8h_INlla#^1%Hc=@K<)Q z@`%!1M}!0FDEW<2ykxY6eYs0yuvyc0YF?{jn`T9xjl2?WWHsUOs}n{Kb5N~7hzVF( zu$t4oS(TWjhsdcM}SZqaA%U_0o@M7R{A z@FV4ip%`BNb!Puhz~4E>k^Y~G|M7R<`uO9IFp25Lbx4dUflH!ia?P?+mnkqNFP$fI zk2dwt`=Hl*JE5^u)>L$Z3udRyi{6ijJR1TD$p}mVTacsmsP~GLkYdP=BNmGFv`Bok zt#ZV_vWA|rsH;3E?WwG%1>TzYg`w=Zp#kB5l^~zYIk43FYT}weg%;e>fNZo~OX$A3uJaGN@gc z1(y;GLt8@UWiC7wMmx4|EqXI5L6QfxW++3B;LSF&yb}yW&QnouLt%wsfzZcjwL> zbe^h+-<-Snx4-_iarwLmgc{Q;;Fr!GDZkId|IZQr8;wpOdO)XowF{)jP7w2QA|D>c z1C(F=^UV5N4F81W%Tdg6{)fNN<=uDRQF()*8DvBPoA}I{Wd>NU*i(HwHrls$FB|;u z{dX43pYQkZCtHFE6u6hzb@Siz-m!O>0R8u(EglZtsdk~ph0|go%!b6!ugEqsfnRuk z6a0hnV}8ny`Y_Vr`N61+U|hzCRRllue|QXk z(OryP-^5zOyESN8>JcCI0-Yo4X`mh|>n~^4|IdRz>pOb%s1vH)TKkrXU<>+4O{@8h zdRodoH=s-70|yTL`P;8OfXM^A7A;%|dE$}HEMTn~dGEIRX7y**f9TM`7M?gz=7HA5(+Qs-+3=NUTG3#a>N$t^Z2s2Kqu+l0 z6~$(K67xliBK+wFUZPGWg4Gb4@Qusn`SSD6LPi|PX>-$Chdb3P-MmTx_WW{1@hrylzN0cn4kBj{Op>Icdq=@xDkW@_Se5q4@zR8@Q3fdJ@)RqL6c*d zOH^>+vyc_~MYiL|j{ff3uS4OTYQ?5ty_TK{eVYxcpQB&Zj1CBOOs)=p@OEx^I{xh{ zNB!q25B_>8{_8*b;Mjrv`+1FCl^()fN<$q>r}v}j=-)8^xYygh_ues;sMunC^gN62 z|NQOZMGL7t@cDf&d7tS(n9R@uoXn9gW7NR}jvU-$Ct$Z~&!Ai;Am8`YJYg+Pzzn~T z7Y^hj%Hn8bk-{DkotTsI6S8B~90uj#4%7+$D)9gOuYXJ)KZgAhGQRw3zPva=4iR~7 z-Lgr`R2Wy7f>8CE)UWA;mM@5E#5RJ=$xR>Y+PKPT{r~U}kEAbA`Gx4|og7QP&a|FEN_`AD^W%sU~&c`0t;1QD;8A!cHrgttm zX>ezG@t0qG>d;h^4t&q?u~M&CTD3%ev;%xaKjV@w$l5&XjoXSSsC14mzxZ4_1AIb; z6mQD-QC%uME=XX@N+sezou$06r2$1za9u?F6O&Kmd2hQ$+(l2gQBi&8%1>KZ@gSSs z+oLDKP!ESTAA9#5d$RB?BE>w$CFS9-y}a=wWmBo}*ZH$@k`?)VfeUowB@kT&zW z7Y|c#HvDq~7V^%~Jq>@gK2hb++L`0ix1d*<34=N-ib}>Yd8GNH?*DCp< zcuf7DRMf-Dg-jt7vMS}i%MdhC?AyC1Y_1Fv>H*%fdsoLw&#`^hO`Rk`N?3BSUxI=H z`3UK4|E&M?qvH~A zjw9f|uy?shL%V#i4J!+exd{rU0uU(3(hQ&kiWkuWTq^9$74|D(sgE&I=&`=e6*4%aPTX~X47WSA#&W-qFmytWoBdJ>iiA{NRTRd|Gm<3|nSH4;yO z_iI-!8Qr_(g4fFQYh6>aW@f2w=znWnF*mgba`fOi_@7w+3jDM2&Gp0TMEEc6S84jF zK3{+J)n^}n7>YS|2Qv_yPo=B8aF5`D=cOSy9P)~C8++E&*{N)!G9bl-ICGMrz!p;umv+UiwSJ)Yn zM1mnz?H?^F=C%C?wo+p?F0#oNM6G;xsQntO$SqWjIFWiU-(w0Krw{f(vxe!t)2&DK zX*Iuh`N3VAy>s-C>&Nk@`5vO-oBP-Et}0pEW64Zy)}?&v>J z|NFoHd+(mzis7JBFvL706wWEYs!@A+<41nV0+1m{Lkx!t&{-N}3u@pZ?aDnWxJ6$o zCtv}N;1Ey(^^52NTua}+GfD89T!U`F4Rs^NW@WRhGrxNxJTnUhsQiNb<&VMx34*E` z+hjNvo_Ht{nh4ji!`HxlKz>RO&F08KeOW>1^Mrqxf{p7|j_cokasO(4npW7mbF0jb zxwWbo?LQ6uw~6uJv1PprOr0=#Mz5-qhxhipl8--p58;?f%#Z*7^{@Zlym15MW2?gn zz6o^d-Xx?R!WdJau%l8WR5k=0tA2R=`1`SnbmW4~LUgsyKW$Pvo4=}>^4DNdS#^9m z7XYq{h`+LuouO7dkv}8}CXI?IM*3dun+p36S~E?^&^HRLxj$iB)52-xyn>3DZ;DP} zkhm!vaU!0|Z3?IvcbqTifRHtv?Iyc_8MEI?w<7&%b8Rh#r+CB{>Ox+LKG_Tqo5{er5|2~HmQPE?Ap3szB6s|1R(GcydhYCV^DzNf+_9A!k;&nR`4wR3*MGP$sI(sk%8}~`Lm}_ zVPC)(_ar+1Vy~FQj$u@gmI(MmkS2`$)-tOfva8V3`Q!D zkOf38_~xsb`9;jaLhwmx!6kY@+Ef})w4zzj^zXd$4u`Ai81Oe(iP&o$nycOzsiab* zBwn)Q7xtcWOlI@6mLU<5r9keOFQ9LjnNjy_UC+aQ}GKi+rv;SCLJqId%NV*2VAFP#tOhlTkaO2cyJj=VUVp#qbK% zU77|=QH?wiS<(Mt{rd=k!n!zK?NM1cnXXfH7%GqWqP-AU>AI{0*L^8;`qZ{S9!y7FCrhA;NSoLw_*Ld ziQ)ATNjKDX#KT-tLP&6;lLzt;qaIWj1yPuYX&<_Y3aLWtuj}5bfl5($YHGk=wD!UA zxgn0mm}STta2jtXQv8C?mW5MGC}+n zGBy6UZN*&i{7aD`-v5afxQ-zM`n0H0&;s;de*AGz_qOUknn-0CXj9s5%>uS4k;5ew zT@B!q%@jmw=Cuh=6rvAQDDre=A81ys*pEMa7Yd;<{G-8oaCy_x&rwCiB9R8=q@om+ z5m8#u{pbGz{!mJJ!^z-NREDMNm3{%+gyo5#5|S_Bs7JNRSw!_{_C!>06`yOEAu4lC zZ;Ut6x6nQp+xgBNi$?GptLKXa-s)!UtL5LjYrA+OxcCtNtN(x<^Rohlpg8{AqDAM? z!-sUJTULwjupX^UlNAK(iIgAnP-!e7`iHtqZ-E ztt#YdUpl?wRTPy)kG{IjVBw#*FqL=;4B7Sh7r_H#QLGRS1s0-s9`@9=MP0F9aK{0E z_0Ld$1212|KL-AR|2szyj2=FCbf5M^IyF=~^#On7t#GEag*=p>dkyheST_$=NmuEI zr#TBCe$FQ@o!WnH)Rvb#_`8L_^m$6r0}ieO;Q@b)=H4EMEVy{snfOKdit)m}-Aq|MCB8 zUD~y*QefuPar1^YAKxq|KVlspMKddW7?D5yKhZknA)9B%KgK_C{2P|e`PUy4e}!9Tz`EB`mBQ1CSVQ9X$8FPk-<6$bssKWFNH@J;b4kh90`5_x%x zs-i6En-vgL)~Q)tzV8(Lt3>OMz-I-z&`-m^XQ$S!s};o6v!+dWV_@@vb+c2^!2evT zKuZZd^zCrIMwgg>PUC;^QpEpd9-#lH@=w%g_x0CbH!1VH$VyJZv-7{~H^Kj2q!K86 zxRQAM1DSaI)2PDB%EG5n;ul|h-l}}|ll=cc;Qv$nZ$Li&U$>AfhVz$r0m_Mj^q;FM z;$B48@eKU+|A+P8Gw|O)|9f<3*}8h6u)M2{d}80GU8_9nQaDYNPD_;+gv8=5DD7G<7>5*NTEL;RVD zf+80{o)G_>thB`9f5kfKLyHOLPLU^sWKwc(i^qWFJjv^Bs>BCOJ=--&oW5S9R_4dsb4{a>v9qxCvg|G7iaLpf#tzP+Ad z8m|f}xnQKm6<=ns(w3+y^-$ufRK&E2F;DzHZu{}rPxvI!kX@b~|5)=O{nv%q@9JIf2CZ}{);p5 zZ-0XSgA48+t3SLg^xW>Gl=lYq?D$&Cntn=LuCYjAU9w`qtRV$vmGLMv?gChPtkR|a z7M(#Ct8}FjyY{M_Y0~&H6h2(gNL5;#axiwp5X($q2{ImO*e@Stn&;NE3&A|`XMh%v zIZ^*l!HUDe5UHZ7;I@RSAT?8FA2pjlzkH4PWMxa%(jb3p;5n9UMT zZ2c<=&L#C78rP)o@v0O<_~fJaXHK8iqte4+VJ<{vC#oXR!d%SJC7#}d_h;g-N8+6N zAHyH=@-MHj{utrEb2C~P{90#=zkRA^T(@d@m;$q)T=vE1pB2viRHXmG1)s=*Ll#EO zLZ+W+m{Fw*!*?o|ar?Gyq5dD(%v^l^^;fm?r)^j;>M;=fg!RW*@EO)0&oaiJ_p8K; zAq0xne`C!js+6@~&LH89hd>lVpcA7sVQ(`d43-LQeYK^(Ek8` z{!suhpj#XGI~P>{)$HjLV~t4~10wui$@LUgCldaNHn1d|OCM#yF*Cm;@iHF;Pzkh; zzIB<$j%%-st$)E^%E=e+*uLG=DDw(yd1^Zg(5#sD{AQkb$QSsY#>V>};)QXI4Q>r& z3v)7&;DV$4^x&SuhYqza`B0SdsLAWdbjqu;KMM~JWV>8+D z=z39snrT=L(`ctQh=20ucuG_sE%>Ig;2UjYL>CT5gTGfS08Uuu^D)VnDps44=^B-M z?)&e*6X^lpNR_#e&$yAp6e0EW#`;eZTHu6vG6)Z%J(rnZAm)ib76k^OFdHjOiRVT2 zZtB(q7&mIz=bwBOh%xBKCm(;*tju%rCO$$7fq@7N!or*Zy3|=^``P%9sFS%}sp$OY z82(!wKH0NPL&#HpEubP{YmOs^^w%+>T>L_|Cn>)rA@Qd`OROIFA2E7`Fgr>BV_}}C zQWO{UpR{XYT0{Rsi2OD9HLg$q10?RhLjG7fc$35c{)g|u6>KxO0A40q1&H}30uV!+ zfyfj1UP3+#)18~vRC1TON9}oumLLsKo_p5N;Ah~k{zLgK!L%)rfWO5@S!$;ywR%^1 z$fB4Ew(wQvD-!6{t<(F*-p%ps;}*6Qx-Asqc|lz$K?5Id<^qOM0VJWpFIr~pQX$i< z8PnngKxGXshKA4Z$9jpaYY{IsvTpvx+&hWda+&rM+qVNB%@dpO7UuXn!!f9Y*dS58CGlN;9{!d9EX21iaevT%`2YQ{e`!&>f&_$Z z3LO!Mv{%4pqhH7NZHgAm4}8q8BxNkB;#30iMi(j%elIn!Mx)Hje?`%6+01+P?AAo2 z|1CH;9Ym~NwHFmdPN~_@PdbC#?%7XxA^<{26B9R0=w2p_)eIS+xp0g!4lo4h0DUKREs#u?a6XF%Z2O za&x}h01cC|L;Exv{rULU%A^S@hW~yt!2i{9g+#wW^W9wffV7ME+6tW7J(~N9Ve=tErZuanPz6QQJeT!6Qnge*y9_ z1+aoooPyjAp0N%+N|Hu(eaWKvHohSr`1`LG^!`0Nb|{xgZf-Hra184Fn-qQ?{+h3} zV6`lkHsG&~_aA@%TeXt;70rb13LtVQ{Ge2aQL>FiEZi&g{=e>8?h=Srl6!^D@?E@MFlI@_^JUPaNT*E015GSI7rtp;k)XqGFz}zWOSP{I{&Ly5Zt# zZsvvZTbdX4E0yCkDRYRU1S+T5_0L25%x}dh$c==}mQZ1k2gNT-$&D%%`s~w>LM;MSa#&iL zJ5+oUi-yJzfwzSZrpnTTw28GPj{ohkB}k;fzvB=}*zT5!(&~DcH0I1fxj&+ z6$vGknUxmV(=_U5Lw&9ndku~@UkTf<-)-Pc;VeUx3{VI zJPHy80h21S?zjn@ZS7n7e_6mE4svH-6hpRaa{Bs9*#BkoSLnhO3I_buoE<({p-?Up z$1r(blaA66dpz_q(O#xL!v6&G2j%Ca#MO$)5N=*FQ}@;lcyqb4vDhsr=W1B7P*5js z1@p(1Ur=Ex6RXp?F#Jz`A1KI;Xs=ZUc4ue?s2s%D8Ema$&wupc`=Lq6ETE$Sy*jln z^C-4dB!Py+jR`=5!Sa9{9}u7sjLVM#@(_WmT4+bqG=kaMo(+G+H_4aaUxP~XA}8=a zuv+^$k~H8-4tOKn!txV~iJ zeEANM=u*}U5uIZG1m%wf)dupPz#u{PLtx9ySHg5 zmF9CJoBHct)Go^Bj5cwjHQ}6f@I;DqaugSW;eYa(#3q2ok-3UA$&Hk~D@s?+eb>Id zyYR3mh!=1W$Kbv_+E&a;aweco%U+mmsC`AWdEy8!3JDO-JzoA*;s~ClP2cWCMN{;K^T@$x|!Lfne~6KpT=y9p+6d6cl6u-qtN=j?X;^P0XTgtZCT|2h4so~g=s7Zk3M$51FCOX0^YJ!Tw(aTP&z&KXr#8WU@pMigT z|CcQQ>TC)4AKtG-`PElnRxJ2@Irv94hX{XBjcq9b{{-5P_1WS&@=JK>1DZlsl;6a) zET47c;MeIq&5xMpzyEvH%H{M&%)^A`l44HT1WpTqMBIcg5WxTNW5EPMAVhzttDF%T zVxh2&LhR>MZO1T#bWF8;#?(ojYUMWsB_p1TrqMSnWC%B&IM>%GOazpIXXgq5!q}rK zYoj`+^+7Utv%jYDhq+74pGpcw zfj=Q8B$M*cbHm@TZZ-W0EF^jF)v-m3^3VHIRE^1Was?!1@`Q7JVZt3mU5HU~5$y=j z3ynjtaf^nvfB4SxM^5&?dH$dZGv!A<4yd;bk$`_}k+IxMPr6ZJ{P`5_CItWf3pZkO z^fZSi;1k4%KY`q#c9D&5Zg4sT;ng|+@|PcLl`F(3LNq1j5u=9Q>2N`M_)CX9XWB~$ zA>2ABQedITitmrC7-;Y>ljq^+xfQX74er=#Y^O#QYZrRNRuP(}c0n_RPXZ4N%#dNi z8yb|W8K9(zL4_R|gJ18hjo*HgkXd{FX|r;<0{E1_Un2aijM!&g`h_epu1nB=9tzZM z;rgc7jrd%qCwKrR=3yp?g_5_aUSQm);i^4&?9bnP?Fg5y?OSVhlImhtW=kqnl)yZp zaQ*9pAEqO*Bi2QOg($7cAx9w2M5Lyma=Fjfhq3che=qvBIul zOcW8O04CVX-Us{xf0xp$%ms^VU5f8(@@i#1g<8VDN!eUM^MS8NT>*;zqYIls96nhx z=YwTpCy&L759%|qRuk3cYoZ5E(R=_}WT7y0K(zrSiuoIs&1LtW@afoFhrjyrGqgW+ z;Oi=!z>kVZ4@P@bkyU)v23!96%oDeTU;+e)M{$uk$IibE=4=Y=AFo%n%v*;K#15~B zjwTpCW_XVl)knOaXug*>z=@_3Eo8aH@U6ltxwLFh(@{JkEBj9y zm&p~72fp@xIdTI2M-MvWp?LPl*W(}YB=uG;4^xb><+%~~w?q#&H~UoDqrpT4HH$pk zt9@e+G1paS;|B02PZ($F%?t2ZA|F9cv`<35gW>-s%oE4oo46wme$(jahRs|cH7<;b zh~zT$tCc&rf45~j839}H44huAYuQ1Gh4>4M%BT$uCcbVGrFG^}xfuRTsqj;`qhEzj1H;J7###x z`IRTTx2b>Z*t?#ZB<4grV@3|=`l%2*1wPjnTQ5%7sTZX!zlGaP41RbYXCX^7w1RHX z5JqZrbQ^k|qjp448J) zh=O?GfPaJ1IRo;i;jjAP@WW!yMQ2!@RNZ?cM-wjYzb@`}ZYq)lZi~cIUe({syGj}p z1GOLrhOX?tZsc~f8UfZW_j14P?cO?i#4b)Nyu!|A4eE%{6wFCZg{T3=hzAMLdfDZ_ zJ@cG(3OE8~C_Xek1<^tDo&pd%V_(07mi{-UP1c|i)@YpZ-n(;)%0+S-DendoR)hAv zj2dr%4i2(r%B&!hSpV&Y2>gTpZLbUYm*8KaUP~~)BMsy_A&CY-Z8pK~%Kqy;%X0Bn z^(%Yy(%WwxdGDR0QE%#b}>Diqi3e^+9m6=uDs-^q&?6i2{e9l_)>d_-ds#PeBi{Ot5slB*J z$P`>QTNYg>)_l3=?+yGjtw4kz(iRbgV2{hgz?2HGVHOOwalKc!ZGO|zlB{aRl<@=m zcJJM_ZH_Fdxjar8XzKsSM@}mEw}_A!{}BH}Uj4!Pqh7Cw|0De0K6>k(+V9UCm1=b66UJB%JNWc${Qn9AnyVM7O-bk^suriOJ0mPjiA7KvGrM5in|PCLI_ z@J#`&NNfdBG2!Yc)0CRAVj(4^QdPh$W`RPobPldhukL$xZqr(}Y5fY%XB;}PPw%en z@;;uLnee>ASBHRE#MfoirpZbDZ(26We&tL88aehI$AUii01t>vzTZ=Msjfp+FZ(n(Q}Z z{ffYxvJ(;n6`leqx-fPKzyUdDxi?w6HZ9k$UHxv<&AZ;CV+BYPM-H4e>h&&lieh-H zz#JvM`tpmTmI0j>@#4!#;p zM!+^8JOSiE(E+XvTp?%;0>KLqK5(9kBI`oo0XOwO=;y)&;L5?w1ug^}38-Ed69LEz zfR2C_z+HoT2WbW{1ju>LVfo`gQf)QGS9!UE1HItLp02h=UVz(^ot0r}7Q!iNllffOBh1ituH4sd?Z-vVaAIM|5%eSd#XXHRGA zKyUZ^{vNF6J<02m3dE=cx(D*}hS zDA@oP0nr9b0Z{*f6cj8$0zAE(tbs%W^f$091=e3c=5sMXAO_E0e4RQMHdcPj_w;mw z%m;L0Tu5+0OaRUg2p?2};KM;~10pQ=M!+_IL;mlFjQ@!|xZ3}fKmU;x&R5VtTmaGe zoRo;ptpHGB2Ro9np09s_^%tNa03^Ya4xWzI;1uRR@Za$?k^}kw#W=6O?sI^RwZWnl z=vC|f#03zY z0SR1$27nUiNdSQoOaV}%f$9lJ5CBgPrw14K|FP@K-}Ijg3Fwdht9j7tva+<;-PHy3 zigV|`STqFA|3}ju;2dCLU~6D;kdj@bH~;H>{vVP5$JhVL3LrXToda@_sR9=TaT$bT zke>r745+3+$p=xu)7kEC`2XH@(vt&w4uFki&W8mrD7ZkE0>FQD`3KmO5Ukh&<_Al< z!1+PW2@)PKr$D2{pT+D&guO^_{{P_f|A_p*dHt^p@kgc#$N>b$izxt-Mt~uRp+H7( zclsOt;1Ex{dvf5hIPh%U#Q^Mdfj@XGx4F4V?~n66FVY_HSSVnAu%-+s4%qiE&1hv0RJx& zpkr;R?%g|}nu0DhP(%Rc2RSDwuRxLs_zgTo`#(LU{}ZnNq89)kKt$llAP@yWT>$Db zAQXT=4AK}E2ipt$!LdrFnljGnY+$F*ivgBeF7OBKvfwZy06v&CK;Z#t52&*Mn*rtr z%~yc!|BEjBf6d2&SpXt3@KunJo+m6)=)6~f z{-RfbEGz^GHkStZC+Nk}Rgu=a4UUWYV@T4282#<*-ws-BXlMZXHkdU);kn59fhj@S z1E$qq`2VL?JIDWz?bbnE21;Wv1ptPC!_P%CX5ym4f?05A%OP4*Nd~N~|2e?kJ6&x} zV1Jn2o*oTlIRHMW;6M>^v3dxi2{0%y>tF8w&)^SO8gK>3fq4}anRpW+YR z09XQq0N}BpPz8AlFaekafQUdW0Ki_XQr%IK1x^kI$Z)^_BDSi6G(aA>JrMCObe?nY z{}A&*Gy&uT%=#Dp{~Z43A>g7GJJ+lK5GBr)(my5wU=mTkat{Ar;rE{~06+=&DwqNnq6AM$X{ri zfV+V00EvMQ`OEqL3Dp1PEdYPut6&NM+yHt&D7z5ofE558fzlXgn83aN{Qw36W&(*5 zK>lB}&Ho;an*VZp{}WzaOaWkmKh-%94$cKSd^o@su*!cpz^}k$0mcIF1cv)Zkqvwx z7=QizlL%bE1!e&tq6;g4xd8AypALT*0wDbF2l&;Wumi(^KLmdc#$U|;Ps09>Z~M~( z7go41#GkeR=J@yH0`q@_{Q~*FJpUho{XcqrVTC{c3-G)cpqBbKgY>UkLnvjX<=vrt&3%D+J&=E~%<0 z=z_-xz)L6u4+s2X;!$i1fiOc<6=d)EX0AW>X|}ol=*(x!bExH@)^tV|!l#Gl#?qQl<^QuoGsbW0pTsCx--(|+4OP9nTvt$&$_ z5YJ+T&XdwZ5A~~oMEn5%Z4Rw>@FARI7a@hnAYMvzdvIz(OjK zUv7Arb^Ti>6&Ja^!`WC6^au9~biQMlni+X+I#u{1s99aolKI z_Et`+$$N2bEY-F;Bz$?ppdTw;D?h3}LkAUIP$y@OdReXq|MVnKS51(+c0e#hphG5X zhCctP1yK?aGU=Bu?5&&Shr~BX$nqFoc~CG)BGb#5dc`meMnAVsS?RSfsvOVzfbd;o4dUTcNK`Yr&CM+k)(#aH}9XniJRT@bh zcx_G{Po?k~B+Q$FRtFD~^5T+#Ho>mdANLMBdr3yPS=LJKW{%nuS-~905zjTO2Dk5s za5G=U4IAkk{(hX4L?6S6M8fseWL%X8jzijq>&|U8+TU{$y;KCNpp>!LE}!$v z&Q0!cmB)#9u{++>(nG3WWoxS;9dc=&e|`5LDMVb9`DvBN!zgJST6SiJ*$-v@2DB3X z=a()h7prAXVLn43W(`Sfuko<>&K0GCFTH|9xQJnKhaUy-OCibphg{HFF+_86$A?C% z;Ybe>VHFli{gM)B@1F9=`wqswkh$Ta4xispzBmi}py_1a?mSO66q#6JyDywt(L#r) z*Lsiss)Y`Wk#kN5)+_e47QcD%kwB!%-95yn&JN>CTPjz-C8Jj#ulQ1iDj!McEbLnz z&;)PO-j12rUR?~8GtK`v*E*yh*h@EVc%DzNGgm9p`&y73q}05 zHSvoi2JsmPH}RR1<(n&TQ_1(?TiHP!*yvB3n9HgGS9A%=;c-?hu*zqUIJt#nC0^p^ zl=w#>tHX(Z%o}EmbokLP%dl%zCvV=4SkQ0$)Hyk2YN1Ip3nWXB*fcN+I^7HZoW+Tq z$kidRSx-@v>Cf}kakFl71&u~Y^#;}IO^0;8J6sTA0(gbDFu~zIlVIA{2 zzkly9j%A;~`Hyyrv>mnN2&mGcZYptO6!3IMcUQ19WDD`Z$q7gE+Fnua-Rw`rY&eM@+{Kn2;HgBKbqf9n!ATdeW+4zv#Hl?&bdv0y zi3gu0Q+1b3x7W3zxtk9)T)U^b**S^|N56dw<)cU}>6eB9zV&G(V{71CkV^2rYyC^PzXlO^f2Lj~VMS8-LQVaRe-H6z+@wtUP;Kf&8>>-YCY`Pya3eAzAF zsfwh}Q3%dyC8{S;a&T?FD887E%kuQf#rJq<8R(R2^^~<5%BbSTkC#a~OsAd_W_Ve~ zo3TebP6^J1%xB-UmW8gb&Qq<~laEMcXkX!tf+&2(p3@<^++)_6?JrzVr)IA~iCk|+ zC*@5wGP-vs+rZ*&DI8L{`8&R~aUVY-kSW0SR2k@iN4_G^c+C&9-6CwX=t}_ZV;)h2 z6{5hLvA+fqO<4#lVW_Wf+(u_JimoPhb@{-uw82qTq}_da5a zb7Vfpk>gx4gpxEC$&i%GuLO&Gnr%NbR7t|y@2v^erj$455L!Edcr|5~FUX*0EU#(c zA%FB}@6eQ*d9rgjA1?fha)T1W9Da`moDo;%)u&{D(hIlp&>S+fL-IUT`?LWJjD;J<~%s6vHH`F{dl-^oozt+9@Ong z(AFp9Gl`^GeN-L)`gWVPTU^IG+PNr&3RB32t_;BvjscvM*Ty2z5OVwOigg2|f-dew zp2g|Sx%Xi-{$e-p!`)|F)TuK*V9XM zxUlX+eoHi_W_v2U@m9>6B9KZEs;A`H9g&zJdXgfA-B_Lu$AbU7qEJcY!q$o;c=yvl z8zL~CUOMvaKt-46T7K>BWm6{=Vwh7`+t zuQC-`u9K7;a;ktYNG&V8TUI7*{plSsmUYEJj!qn5u|)>pDO6yeb4X>m%j68^-J;eH ze5qp8*sE+({3JJvI+g;N7dCS`*tdD!Zesi>UGDs{&59H0b}v&^y}EAFizFpA;j+Bh zx5N!)XniV|4^S8h8(o&YJdE^}H4KB*S&a%jYO0z3`r^bgT&7_+& zl2%3ZA;KotW5PmMgliAO=6#AtGYJLyNz*D`>eKgKdDH!MhtTfOhKPfRr@xU4@=O5I zzE1-8EG7EVqXe^Q_cDHit%&N32X|l+Nz*xYMsu{kS)Ivh;YGzHeD6)J=ya& z-^pF};#U?1Lo@VEGg+BBC@g+vQbet#?Hc|o%A-|09y}`91Wp5OxbZo8J6m&fY!R#t z%x1Cn3rxvU$+$O5BS$j#;mo5j>PKw*8y(+j7Ur6pJ%c@<_u>-`Y2jJg+g!RUG6}W3 z1gP)Ni1<88@xHJL62_^NShPNU5S-k=8-hJK*8og9;zD_d7QvGe$-T}qb#Ll9&*lJN zjkRIC8zg}NrKIYb$PLVzT=)p0X`J^^<*w&&$l^+~*eR!s2#+6^VpED^u-6Wy18Xv4 zb|lQe?K>+hRxDlHQeNTHXVPNLPGYE-B6DCzb||aC9A4HjaLxI2Rn*=}Pl(o6v(Y%I z*ASIN#8yjY0bf=>yTY(&oa4Y!ve5V?s=c!+xXwA%elW+*zUJr^zy^L~TLT_S0OXSC6M zq*m(V&@R7uZ!ha!hycqq*;TT@EZ#*^(s8;=eM<1=wa89k*I5~2OIvoLB46T# z`5*}e8I4t3#U598r&purSzjs1rrY#q#j;gC{ z2X07;4L>SxvpZ#DwP3%a&6`*@txzO{UA2^6F)_0FN)0U%tW+KDQ4&@?jG)TPK;T$( z!e`6qRah9Zabz|b7TZIKBS<44_mAPz|r z$x)GkPP1qevSYE=Ig!4$dkr_ppKY=6M-@FP{04N0o(^-B&is?hPK~^QZRwFibEWl1XJhA=0v-d`#zUs*-J@_-s$ ztNF$NG5|jFca*%|#xZIQah%!y1SFCtcol8)wt;7MBzfa)MDAMBw2920-kq%$+dcPY zeoOoy^>t+bcqrc6M_9~J6KVcJx(=Q=ukOR=T}??8GI%Ydu$d`s8$V;(}5?3zJRVpy)ER3fUl)R43Le(^D&(p#GjQsb# z_r*^KRTgODMBI9-hFgzwKaIskmpI&8d*s$TGW#v|YAnq;Fg(wM7sOz8MAnNGzN@*B zZev=mJ>fLwm%dcP-3yrFgtW*gc_F#hXP+pn&T1)+E>i`22Ym2Y)+Yiv=UK#oTalB`Af|h-6uJ^+?G~>M0<`@$LlRO^~#J&Sj6NT z?#aFIMxnY$7W*d663-e})f8IpkUry88!3U2miTKuXqEX!70rEInH^q5(19O_1iOFF z6Q04Y;Pu5SL%pogcA>}K(WNr|@*SKmRh}c+p5}8dUMy22v~M*D9jaq|vIB0Ioqe5L zShY@&b9H6nD0)qskuC?QD8R~@GBh+}`-5v%_iwLD$Bb^IS%C}qCv9!VPH|eAmVq7w z8{W7}y7+O>Z1fMisudkOtB)_PPxB`|Ze1KQpKGZUC#V!Zb|xZDw6gc5jMt+hTLIS8 z4?GK)+REt?5)zK$WDJ1gGWm1ufANuCf76#0wFtkHMr85j$<@`GjQZov0Ji~~v_;&y z@1gadNErK)43#L6)E1pbbS%$Ek<7!NxFKvOt?h)7T*c%$QC70}zKcDwu!pr1J|UZr ze!hV*`SCSJ5);wL;B_^lO6`*0CF?o)PJGSZ-mlA!Ow00RJ;KEi6cUfukhiw4t7F!X zn5wtLLhO!H_#WMC>#$U&kMAOupybT-B5?djycvXI`TdlY==VYH#HNK~Bf*e3&l0(s zYMcjm@1;a%1;4xBnm8J$0%*Isdvzw{law3JvJ=TuuNlWkF!{n=12;K|)pL(6l+GY1>+?ba{W6>Xg$4HXDDd@i>5Ow!kOk-4Jjl+5IKE|G;+Il!N2g`tUF704FF z?`GV~DCNwxuz@$&zyIF-ZeF;{uRm|AxJzq+wm=tO@)^Oyz&Xb64cMfHxSShx^mbWp zTr=(%)nd)KdCc)<&&cv6vH1c{>)F%&zPS;+qvHVg8NZeJ=2<_whi#|CCzJZEF~(Z~ zaMc3y0`dS%10k;edl`LlHCwYgDyi5pG9dlOF)SvM)puiewoHkqOoHdp7}vW^>OmAc z&F%LX=(Y?``Az+%eN>(hE8_oX3yj6tlLlBaxSK|2nC^AghSr&=W6_8{XtE&Q7wYmC_n6u4DK zW+!83)Gq6E*T(Ng3kC$@_*akc-rG{n%r7bmQ9M00Xnc@twOpGsgF$ngEQ}VhR8!h9 zG>{C5{j|?K+7YS3yis=F_GtqyCruy8We+IH{`Q0(nZ`g?saMS z;gwI862Sw}_+`gSSiV-L{+TuVl+C+70`0vW*XmDRWVnxoYOQj~<^^mgXZqdoZD1*Q z|3%FGM2=_8l|K=57Ex~+Ph(~_uZtKp{9?oX}xM5*8Gt-CL` z76xY<=nF6fbMC5CgqQDX;K^2Fkn_Y(msTKyPmP&ZohF`q=fWbngokurBwtNXIQrV0 z{yLLVCrMx7MwwHmjNB$d6t?(@3ue7!3KxA65M8ce&^r7X2$nHhu$*e-W{OlN+yzr=Nk z4=a{pfqb<>mSbC49x>oW=+Vn!h%@kvTu?I zEtrD3o83&hOm}rI?Z@i`$v5VK)|9fzs8HDlE;Ss=ZXL$6NT0Ujms8e>l5cDt5P^HA z!*j9W)s&Nh z&hhPWOpdQ{X33Bu*~;9fx)V#2nPzIkh&vT$*!+jv<-XJ0%Ja|cGI5f<-M-kQEhNbk z_ukPmik*Ms9+#kHv9x1@Mn#^HZ6OXM+~>p1d+I9cHMwDoO-7;QCNcySd{T?Z z597706$}PSBghvFy27;~WHn7tG8C-ej$|`L&0p9lN}~wp$+1$|$WA1<>ljGbR$*+Mj%Fi(4n3IZAKOS3~6_z$T%_`WS<@(!wYc_^WqIDX-s z%zX|(g&J>mXAJvto4FquroW)=yV-`ho{2d6DYhQPCL|^r@+O+Q%;*h4_Q{X7Mbj;R zPN`F-?4CUz41ww_x!ZC~2s;agmLkcBOeHr7BHD>{cksENJ<x}p$>Mf0SGpW>+QuzLqbwb$%?Hq{h^s@~nwlD!jg_v6yuLJoZ2iiA`hvt_h z6F^yM!+Ji>dKc<&o!~&dC=ia*)@eaZP4t0`SG}*B7RGvvfAw#a;Z$p$Y(}ZE-y9WrW?0OIBXaodn7K!rveDZPXvV=XLM=I#%VM*s{%Jj^Swa7?`ks^p*Gq zA(UGrT~wd@*{q|;lKtn*v<;=G`Y#b)iq|)f)woAOGD2dBhuvgzknca#5b?Nd7xw z`oR6OP5{tTVT)w=;T+zFp46QCvRj;!ylg^Qt2PsXb;Al?Cw>&nYFF-m#qJ%7hcvb$ zmR5ixL;aNJB{^fAcig^|^Y5V@tgjpkETd6v2$(XxALR{_OV$qp-!o!a6D{Vmp+^C2 zzMnqmyxGYHq{y9T%AL8t6OlHz4H1`6p8Wp5T(EiwL6=rY%5pllL zQW=9}f6J_#eRQT|X~;guU9Uar_T7I=zTSG;+IP#fjWLp`je53aRX5ZB6TaBSZxO-! zAG66O9IjxdsV&(ik*J{=-(40aRWcr8l3 z|J=xb_Vw3&{nQB>gj7JCWmotRRlhO9u>M-9wHHFR8@6wb4yk-9tMn8ZaOv2`cKDL+ z9v%8ufpq)*Ns~ynL}~m)saohP`bb|VfsN0!8Be||e@aX&Os^=ku63`@ee2`o+Uh&f9~*BRG2;AgT*r-gi1t%WXvRY{z7l7t*hbmp z!hX|cPpx!YpQg71i~Dk*b^4UZSm~1enn3t6_U})|ay$#M%uu??>=c%~xHOD08^@%I zHBM>awFi_vQM95R%2CpyNF(m&4w}qt zTr#UFkVR6%*Q^AWLvv~`g%Z1)M)SCLdAIHr6}kO93#4J)>CxkW6``!I=u+QgN zE_jTyu=YJ9y&7qH#Z6StRv<~6*%=+Z$NB*J{ms^RK+1$5xr+8^2)mR~XW`{c59vDG zdQ5`wU-EHlXALf!hR0g392;W_pUT6i4}S*G?^|b*;cH7-a573T!SGHo{JE`x(vs%r zc#CSW?XtE-tl#VqZ6<#lro%Bpx6OtXz&|iH3burKJ0cxQOSfGmlkL;3Mbx5}Z23&L zU7I`i*Nq!wR>D84KhSuDLhf0p88YP^3_VApQOLpolpCin% zJufS`eP$$2;!ESJ5!r=Gq`|nXPOgW2>^sy*H48@FB_yS=u{f1m(u%1GwfDekJq{1* zN>*kF*9eujul=TpZZP8ZIkiq)Xk2q`ALYyr-qSk4k#635SnTg(^;2Xw^XPM;k@=;5 z+H?=7`g-=A?DbtS$VRR7$^gxikf$2kbv9gbp~PYlbg6u%aY1KO zZS$zEw%E3#DVouyKrQANXrZ2lF2C&Sccq^2_VJJhogYe`Hk2}+;QqZA01^H}&G2eF z^qG1=WuK-d!RBp#nbiZVs~t=t!O+-1ZPP6iCCw6TOed|)|W8BEC6S-(Uk##t`4|u>6R+J8frH~aakc%mNfml zWTw)XYuz&I5IDtgzMX&ejb5UV0=;IE1Fc{mJ{oSZnVS)cH(zmSz1EGsGh*I7aN|ko zXqy-I4Xq;dLJ)>ijD7#>DZIh*G z?nx_Iad~VaqXixEtvxlOM5H49hY{k~MIj^O&;dp22_PyXqM z(##Ld6ZlhFI;f~E{7xsgfJbuXj{qNQ(=89dDa zbxmEiA0_56pGmeU1(Y>%*Iws_OE1tDuy;)R%p^!K1=8ZuyWd6xF1q;s`1#RHY*_Q5 z_2GcL_EJ&-JKwV1NJl*$3)k64qtGJz6i<)}wh|9#WY{I6Vor0FU`NLO=;rfC38yC`C;AZ2?PC|qghtid zF)?2-#S%YO+(SN(3u5Ln(-s9V3&Vm!raj&FYPHc@O)LE058K(M&PJ?J`56zp?uO=v zq4M;k2;tHbdI<)%NU&+o(vLoi2!REmhn|E#_FXcfBa-o6-kn>*>K}PR(*${^V^3z4 zcR5*CCW>gbY5vA|#^oz|_%&~ACkTG;tr~?4ICy;`)~hs&cMV(`^xY5&V0F3o@>3BW z^G-Z8HcCQfO^#L;OMJ&~4u8}Jx!C4AWRcddZ5*^d~^F3_cV05N`iQ=fv(ffec zqB3wiew2Z)^%$Xy)=4!tC-S^{dr+Qc^{H;&#KZhA&Ly?bmVwnKjZIl9xdWEHARdK* z4sn}iEPV*V9Ku#5k`h7*)ecup(p3s7$_nxwoK9*Ei@zUH`S{c+O04hov%%5HZ?W;A z^0e9a)N(2-NzRUjnL4&we~IP6<@ozKaj#twG=aF|7SqjbLy07)2*8a&{Ee379)Dmv zoijX(N$*dKbcdW+8tSRn>=mn6p>%_ z*6oZq`0(mcta((;qK5PEuVlH)lQXxN57RNjq}i`te{^!}6uS*gdZ%n_I3jg;p6OKH9Qpa`y&On6C=Cw(S`D`ZDL>Et44sdy?zb=hcx_+i5?v~22_`Q+g0Y+o0N zbQq?U@!Xt{D!)Oz!opIOYRVQ#NpxD!k>Jp+2jXuv$0!1q8=@$&(W+JtF%A9gL#qTI zcGYEsg|5vn_@HW^A#{j_sMc2$8|K2$$%eRn6+h75+79oiPyR}O{dt6?b68B7zHjv> z_hKW{DQSi=713{w`n7rGz#wU&t>i~r&BOBZB*OFQnsV1}`DCL!Q_9EEd(+M~58T#; zluOiau#9M8zl(cq23LIktM`a5WJKuD-$&P5AJ+YPS7i?;lbbI3$K|gmmSTxH7N+}f zD$FM?*=Jd$I|A(1$e~q{a4AwU_F=(W_q!UEKQHEB5%;aM`LbY^^3S4d22(93Vy3Gs z-SCVfl-tF-@`4e3S7_Vqq_*9gcTY&>k{xjv8?KIdxss;WI1&4tu<8!q5TQuE>H>5F z(p$O4*&Vls$uooS+N&{DM%UY@&65^gtLyC#?YL=n?c#FV-jQXa>w-d()Wc(MIX>s9 z4Tun1Sl!@WoCK(Uo0N>6*4v6U-V6|{(o0yq8#2ohbhl8NX>EVu7!h%)fp|o37GKK6 zx;GzQH|g*O$cbH@##lU@@&&Lu)=j-!#3r0p;%^3~-h>PSh_HU82$q=_fVfwO^Og1}0hc)M4Fkwi+8o*#G zfA6QBSV1ZA`1v>Z;~5%wEN`}?0v4NS5ID6RoO`zk@?ac%wEJWz%HUb%&pz18H(A8m zKx1IMfy_zxNOteZMwipVJg2W{U)|hdkUKO%?8FVUbmdPxl*h~deMb%deE}RSE*)F& z61S($3&pA5$J!Y) zPgRa5M?phusAAfyA5ik`6#fO2_D`9e6P|e15xnJTx=M1o&|z*p@S??i;Qr*|WTI5e zj2d>+HPg76EMcWSPQe>e!M3H?+*dVk&-(`c%nyoLM%z}3$C;~rS46X=AybWMZ8@3Y zD`_yK)`?$AYDRsK_M&UkF&ZJIu`1XjxsvspJac#XrX`Sk&)cFnZnsHCTmJ^fQ=R9V zY{o`WcO-q$H#0m_XYm5?&K`FP?1fABqpGPVr2RIEy5yx5)!HfZ1aBO?_M+wqX6?w< zd7kdng9j6=xFQ~HSO=lmsksivR%4E<`SF&!i5nK|T@=cRs3t3zz+LF9L@>lFF0w_UrU1k8W6sotDN0@Xx%2%m}4F|{~ArJ5)CLd){gn&*|I1LBQ zE{O;RR=V}V=PB%x8H~0o?}+1MDfxqgM{LrwGA_bkFnETuqII_e`_Mf~Kv= zW5&lksDo+?7!IN>ZCjuH1iPd~0ZUAW7<-~1!@rcuwdXoz z`G`)3hb<5_^e9oMHh#T!ZaRMO=xxFUZ%Gl+2vG`O$6LJ<`sVTM(Qh8;NT>2K%7C^C zurAKS_+Hp;XnQ5-s87r)+Gyv)QUbb1zAz|k{$-r(&Pa)B1wo$vuKNcjY-ID^@O3mQ z^;e8aZlWzFv_eWL;ATX2PZ8#DYh-pdaeKf4EU-UY&sXji2aCHcl2j*ize+EV#@Og9R@o@@lcnzAVRb*+Zn)?A_UC5moM- z^QX<)DfM>c+RR?&oig~oEm%$C_r;dJZHLW%4?SiIz`+`voZE4F*n70MHhQg4{ebOZG)29r@+^tG8yN_39&LV2X4qv5Nc?FVx)El%plI{2+rblRwIT}@VJ2)b{ zcZ7rLE}W9zs@&T(MDUC{osc@{ud>5nl=0n5@p|*?}Dz?r= zg64}`UKr@=n~|wdT3}Senm)X~90`-T zxwZulcHeyTur@^N8X{?Tn6~f9GP4w_l~7Rpdij&bx-?t3)=|D;Y7JpgP<<1>>;C#% ziG5i!3Ujv0SMz^NVLHLlhl5*PLCj1CclA4ZR}9g&Dk-yKN4{*V?e3SImAzL8sz@|` zB*mY8D~mrp)~ZTKt`x6~oD?cBca=cr$Fn6egQV;AmJeV$x}7ar8guWyArf@CJ3w>B z?}NR(F;yWUaTgKnf~R6zBCq9D%UU($PXAlaWnZjTBmwyecBWCH`F+ z@A#vo9xjAmU&m=ZVgUVQVrQ>P(n-^amAOVcQ&vJDe59A;?_nQ=5U-Wrd6X!2kdii~ zE@xi#Mf+5Bf%(&bzQO-jP}#2-%Te1kAe`)=u|v^X9qRL4l3s2ntzOU^d*vgw@cSc?i4WCvx=KwG-S?#%p;)E+ zor`que3M#}+=uK5dC5bmD+*^d>{(B8S&!Al>vk9%Yk+xb_k&Lt5_> zJVC6p?dP;P{bZnsS|&$)y=#r0lnxNkD>sSWE^(+aVyJwdC|gjyzkhF}Y!a1E7nG1y z!0TeiRQa_G`Iw(z_c@=mgu4sz?K0G`8}{!(2-I(0hJa1{9kGh=arcSzZlA882`i~G zrJ^`}C6aKOi|WyG+q6y4%%eQK_qLi5_rqGrQG{=Fx6Et}BaB+2-`I;+v|;?ab>c9s zQor~1k)8>ldj>T57?aQ3{n;UnnKsXp`dy>Xu*#;{iA~u6RkW0CpKfC)Bl6CK;mwf} zK1J?js|-nV&PxZ(haR~gEzdltT>Tf|_q!TXUl$)PGZ9S9iYxz=+2>|T%!N<+)f zI>kNgoW=A+k}3)nzP?`bO=?@YJg8{8GZEoI=$~2vWH9{7?mDhs0sFqMRg*9Ecg>hj zurX~x3?Vf81M0K~+c!3#Q#Mvt)=0STuZqTG(&N78iW4*_?Q2d!waH@+B?`G>_@wga z!k2Fm+p#-Ru!^6)1Wj?#_BX!=?rL1Y{+&}-6v7oV;^-q-knuWw2X$~ZbJ!n|t&78@ zxub^U zWHjGAHkm{lBgP0bu#{`|^1nk8Kr3;fqd4vwNy`x_agx>g6*OSj*&`AZv(<+F<< z;Ymj;HDD{{%TdZCC!YED#WCbVVD@V*!vZ7+VNC1@kp?@l1c&Z;PhF5P<1VdfbwWoj|vfnU&mC&Grp#s$nhL4T63BE&5Gejw- zKK<-s@cAArro#npCV1_$5vrFzfl zv46ledNFZ+KnOa(TGD0sLsa!Fu=Tb6=vz!B0*S8R4 zj#d@8-04O0h_^8Qj%7?^)LYyTq8`*dQ`jQRzVki{llBKJm1N7sRd%&O@4oxeCuFxa zh+q+IP8xTV*L@Fh z9(9aU*Yo^5n;|2c-qxSF5WS+1e-K0;zwb;av zb>L1Oq)}Xz(VyD>F0F?a45;gq$%y&!B<#E7ZW8?fDWzcy5xo{s-8SgK%YVwgy0#%J zt_oIOU)UDkd;xAGcUp(#hlm;CN`iR-Wmw%*oGQ`#+Dn6+*h?l=G^Uj8gm%yAnA91^ zHg1~Cv8^8#xrVIPoCn1YSzLyw5=W|!wi0%y;?`05w2vjJ)Z-Et6U-}c1@`hr9kEd} zhD16R;+eH%NvtX+UtX_`F13V2TXrn!c|yFJJ_Nkj%i-(P3G(QLyu`K0qtHWY@RWUw z=ajQZX;K*_3hw_*>a~meK?wdVlxvkudnzfMv~F?iQO&XbVqwNZ*b0%PB-K6O$L??z zI8Y%9ORs~D+$i-N-Jc!Vfv8ja1efvNP(yWXmo_wGj9TUmgId@o=IdV7oHRaa>t;8O)4UN%V))?Dv+6AT zEoLV7VWiNYX5(XZN80nQeWP5JChFu(#R{{mqn?_GEY`^O_#Ad?UzuPD3;6fDGm0@X z0BGZ=_mAuMHq9-4eQ9k>$*%Ohk%Jn>C{>r_sWS9%mYW8UYksZ9)x}GnC~#1_MTH23 zwTC={&pE=qMK9NPbs>lHM!!2uA0%Y#efciO)O(a61rffp-DrK#d){p8SYG(}Oq~w@ zetl<-To7120y2MLhAY&(nLPjQ^-{=*P0LO$+i}B7XUd2xmO=9;m<{3nFkTMU-L6bS zO2w)w$;lFK0<(-O#AA9A`%?LOPY4KI637W6)2`a<-+zxs-XDp3dR&G`A&AERl8DRb z3vs8+FVY2mMCwk=%?=9m*AtC$P`Mo4iaCrdx7+}J3w7@V`c-ReLd(nrdQ zrOxNak$W@5wdsp@HKu7lhhL^lRfhAV<3Z8&om@eM+(ddVSSPNyQ#8L+bpwVNikxZU zcfwEa>%T|kyv_67ZSiB0Zk{f8z6n1!b|39q^_)>>%NKdb6s^wWCLx(81$|v{GK@UX zzQZwsP`MDmJc1r-2)NuEd0S~-IhhGRhCWqZrq~5nJ8tT)kbK*ieaBg zec7EIqNV6g>*Q8K3kiHODG2rf#n+di+PsALS#$G65mgRj96+iBI_MuQ!E$(BpC~7c zu=XNi@IV*J!s(Vc$;SZ}t5a3`uL|&WdJeS&cR@{YB$DX+5P@Z+5;T23^7g*8%31A4 zYN8G+Iiyb9=Wf!O!*`x!oY8MFg>me`##wesa|-d}^FcE-#isJ;|?+;>ra9adj@r9n4z zxuHSv!Q4L6H!Ub-XMNxa(>?U1WGiMiOT!N9dyb*!!Pj2Y`1O;-r^k)c!nOU%1tFu! zWViR%X-U%>!xDGGn40(2KdhPd9IYtlCVi>P%*ZE&unDFadAHfl7!4RC+y0hXHg-Oi zsx}<@kc6DyR`n1#0lllk*<@c-gSQ>A-UeMpAifDeAWI(jOS-DhZj0cs6lfAV=8W3Q z5(F3ANu4|062sm26}AYKd-a}8#+*hmNtdQ5YCJGG3E5-%kp3{OnrB`in*3F~LuSw> z?;GbYy5LCwftA^$AZiS!5D2cf4}VakKaotD)9i1-*A+GV5SB;bqF;@{tSYIfl4Gkp zQ3%I`h`PLBs=QM3iSf9?JTy&qCAo#2XD*yLv`R>lKZBuoi^8F8Q_)rKf%2w!>>zq+ zkxo!pI8K+Gml3J#Xs*k8oh!#one$^iZ5QvbKekcVFlAVY!{lq3+@&Y^-p-os-uEG1 zR-;#ZQW%y~kMi`c?u5;ntoE)dW%~6FCfmx@p*43uGmVrUr)u-3q2@x{6u#Ec75@6a z0RKP$zfGIWW1wIj_EUe-Wt*vmqp0BTBGx}p%HgnRN1tYrBuc?jWaf3uaow4`M`9Xk zXbUMsfB>A(8^*_bsp7g?F!Q1cAqx%qm#Fe!YqqmCBX}Fz4UVVdhq= z1tBE%-fK_1v4m{uhG#X7bTWyd0bGu?T{Fin*xbyyB0ZET;G3|&W1U@6A|CtRpd8xkGWte|U z%obRFKj+A-=%Wz;<32az^=K?m0*O-u;2ewN6u zGz*Us0TBC_fWJr<(uYJuc z(Hz^HL#erL!36%(RfVkx?x3Wg?V|ufhSSU{0{@FcfMErof>`aTQM~TeXQEuGpx$hv zqf<4#n7mdlajcqtZrL)3vAP7JgoN>&;F}n-*M*i?lS24!#?Ea0Lu)ew6g8&~0Hq|+ zt{N%J_JqBx1fD*}W!N~NNC0?Gx%p1{~tVv`q8blesV&|VCtwK%=c zG(zAA!!*kvOTGBTUH75g>7bM(C?yFv=T;DD9@XXWC zpo$&=;VX?_t4G?!^;5P-ibld@25iq=6+Mbr&*mWDq+iH3tI*U z5yvsgr4pjZxgAnUWND^QXR`$%1ePpWjNf{K_b6)s03ZNKL_t*TE6}M;SQo%+4@S<3 z7P;kIu3bM2Sit-T#UeiZ4`Rjowa7Yn_0fA_&6+i6Hd|py56`Nr>eSpLfbpgv^TAX*bL@j$$pGmf?W5zKp%6R(erx8VJ?!-|9 z&g{t}69TPv8?}bwojB)s*{N$iH^8k|LBpedDA0EU3X+1hlOotLnSk&$pKJeJlu<^~ zN23_+>KINtjBo*QKX@{74cBq;D1ckY54( z-$e#Pfi(&SO?i&AVA5u+)W`Q-fHFkd!G4uGzV!LeV6VOQQtnw4Ya+3@r=Eq&W{%in zR7YHJfaKx)e^1eqVlF>%NTA+oqtm+#k3IGnI8$xo;wU2ggSrN)Qm}zmTV)0wc)&|= z{2o1kl*DjFJ_4|a#uY&sH`PARz{PB9K8WLwJqDdLQ&oQ= z%d!8~|BoV+O9>{YCNVf#1EP`#4IAB=pPuDOkHb)X#6uLV9b zK7Ue1)^6a?{yM(+*-v3$(PGpaO@{)(2+!jpK=7<2=`2(r9JJ~aaKaCw$h~gO0S9Ch zy$}K-s^H!S)~n2cP}a z$H9{XlhakYOC{HZMMBgyq();V3+aej|KTDz{-UGQ2s03bIsu>P&JX|Xpl*QY|97{rW^m5IA(f)e z#rzZ02A{&YhcCwe``f=lwcf46psx43@{}!YGQsApGBJ%Qx}lgSg<-z46C?^amK7n8MU_RV~b7 zT|jToPC#rvh-wZK8Vgov`U?&&RNmgb^vOVX&y^x*wA$$OEWw5i8x)F+W5ix6GMpQb zrb+>18A_!Rjy?KFw5P`kq8U^PxZVjNALbCwEa&+Gj_sBR{=W$Y<}aMcIym{T zy|Hx36139}I-QQXiADR;5r8C#(QY;I%*H`PNvXguq?uyDQdCl?s4|WJ13SIo=ciTh z4x7otR{u+=)q%Ja{^wZ-!w=nxzxk~b@t$|R9fL!osMhMp^fl|YT^7s%M-FVA5O@kZ z5PtW!?;2Qg5E5-9c=WOLFo|T5i39}u$kGhWR@+9R4mspt$m&S3;4>=tNjgQu;t$C@aYepgV&w?8f+LGLPPh} zpY_@?2I}wok}yY!Fwq%u&!k2Hg+ySW`0YbTlqwZG{p==m+HFKpgecaPI}35NFnk>w#{sG(Ew0|7oPWaA_8|zLl6pkf*NU$DJ2)KQ=h=W2Ok75 zhIXe@nEP+{!PEqeqZkw86KHfKGRcD*P7nZu_g)Ak?T!qr-04S1GzD*|NT!N#EHirhfRZ9&}y~w>Dk?mhWNl1e-s`9=LcbQZ3GBPi-pH~{<^Ip$|C=0uDB`GAt7sun)oX>& zFevf~eg1#|1hDI&0nhKB83AOOn)HwWlLDREB$jTt4PXDn-(vs$_QlZ1sF$2oB>Yy8 z=>7}#<$a6jVT5uX{?0^e^u4pLn+%9QZSmdxR`0VYMzbR@K0cuqL5W;dAl;9UK$>P~ zX+pYGD&e354?w3r<^2610mvu>M{@d+j_oM>0JeKEkp7PlPX0w8Xu!ZF#sLN#vZ9RT zyX}TF%k)y;-4Ot1`lfM?kcnLbyu^gf8=CpHrL51IN z0K^S&hH~4D?HmRqQ2`VA7if(iXBI&JK|W;y!%`;n$8(lqO8giU+#D2h}_r&dE+ z>UaKN0W<8ZLtym@%q&Vb-Ub(GmbbPYOGFb=y5<2$RTE!tG|*_abS-~`2OoG4)mlAQ zk5QDN$r%HWIHsniaN&htL3zc#Slr)Vh|VMtXu~~7845d`|DQWxa`F8 zEg55UbVSuFL|jKDa+`+`0_~0=r6pFbT!Fp&q!oDQ%KFwHMF!9+0T9=0+m0R35h#TI zq$3dL{@?nMwd+{9d^c2jdXT0WGE?P+f=LFw2#79L85$Z!#v)(XZC0NM1lvp`G6A;> z+Mn%46U+R(=LCtz1jLq_e=~3ZQX0GT}&loT=I))UHXZb@*pa0Cwn{B57=#8J{dpWDHwbmj38{gWq zE}J&Yw-Sy{Cq*WtjRM%kJwv~pY~O^`+N~D8{`Ie--M>3BB)IbCJ9T^Z0D%=0V#z|G z4Tr-A(h5I0reGVizk|8=kP?W?7#kl`^C_Z9Npx50H(8dU-BDGkeSLjcvvLKpR>O<= z=axbX=D%<8cNG#4aFE|41Yu9OoBvO>W!k7>&pq~ll)7<45P#0?k};jA!Z2N}qExQ< zlamTMu?%@%Ge4oXnHxYR7o!$|xpzTdzJN%;|9gfF>+2=-^7FP;x9`}cEwSIPN#)SFTMzsJr7655?p=jeRfr52v?i0 zEI)187Lc`pFK>>k_-O4>+lPd3E?%fmh}#gCE11%SOWe4o_EM4SBqf9n2WD9Y0N88K zJ&-o4*81mCo4xx8p8(Vbb2dWug&NyQ0Z<=Py>J(UlzJK@V3&|qkKM`=iv|WDgmC4* z-C01ZvC}L?twMZa_|5R|+< zF~D~22t+R;BX66NH=!0gC#ptw^VCCNbzrJPf&KmcSQK?U zBj?BaIXvTMkRGtTJ%Am!E`WMrt(t{F6d5oEAu{xo6O>9N)v!Sd-)QGHuA%^ptKViq zfbkgNjdvRfm|^>+7yP8%IR`FJNQ$~5Dek}K0gQZJqv#xGS1RVRF~-33b>v+6uQc^G zjv{p0OjnpUJ~s zG$GL2Q$}xZpC*TAo&Z*%Fs8TyDb+%c#trB~?s;3xZT@*G1nTSQS1>+)c;2)u+9*O= zH*P-Lnp-#PX>|WWc%_(*vKS7)=~dl-? zAhq_??U>uWabBLJPd)-9t{{sdWI`azvcPQ%H*6vSQo8_Z*|ffLq!b)uxyB}z+o6bf zJNWxWW1A`f-=}2sO?X$+=zxIzW?+yaL#31;iX(0PWq0@AJTn!y%`%-cK)+E`dEkbv~R&kU|lB=py_6=9RJ# zQlhV~4?UHNQd}100>!Q#d>QGcXtvSVAufO?{{ie_^nJ!4h3dS@4U<1x7>BI33Vd`?KdQO_9uivkRlW24Rn)C z2~{Me@>2xjBtdUaNmT`UDA&vdx+yaMz4w6a!Sih2S^)J2%n9Z?py>Y?xhPUfM7kz> zF8bc%6x=&=JkaN9@$Eqr2tVL)8-4{ON8vKtxpGp!w){Dp3hNX5MLM%8Rc{;WyDB+G z2~Vc$GlqwUaoMGpVvmzvk0yF?A6j*t0B^lCDhOV4z*3ILg?w-rRcM%+g<)4%8i=s#+ z$7r8_bZiv=`@jE-{ZD-}8tB1I4?hEMVGf%=5H#Vm?^6peec=aHTF>VuJ(u4r<0EEC zI-{Ew`h24(LLA4|1@MeofuZlR`xnF(%{F$73qS_*u84creg*(K?(9C9afAME=knzj zO8w3z{Je|R*8*=Bln56^HQx!AngRfmikb_!*H9Po%`Ul24J@B!YMM&RUsOrES_S- z*f|3g!hjceZgv?vTmj@pjxmSL{CiFw5reMf=9udYdR|2AT!o+d^AWM`Q6ThmnJI7C zY5ia-6F=2?=(Iqp`|z1=_cn0}X4wXV>bF=am({gp3@IyNpHtq1s;J2_gA6u=!m z>n{A{l9-~N-ku(mk_b`?yzJCdaP>{Mpt<}Iweqk1kt4H;EnLCp`W|~n!WbZ#dww3u z!riLbEUd|IVD|5B`?XlYL?t8~c?hBeg1Nin#eZHP07^dxJ~<>9sRQZo2DYZx+2Sv=D}Y zX2^vPKjF#UuP~9!+uzIwkHY)ejRJ%acEi?~y&xph3p=*40w|hP zPLujEXv*@sw;7Mn?x;cwZYInuLg_3UM-*`taw=k9yEqm3_hwQOWJ@{WXCCb5bfqII z@KNjp-RrMkB8zV5N0gv7IgI1_Ch)f3IS-RlQ>y=-aD>_nS0*6a{OdIn&Smb))>mf$ zq!75})}Q00Cme@MKlvA!eDFGCtvbB?2HFanxI$hNSeoMyC<&VsMYZ^xg?$Dk&Vo;< zk&sfi1LrObIR_65P~qoRTcr@ooD4X(=mjq>+lsM$5WpNIdhgs`PCsXt-ydtQz1P}j-#asuI|I&oz0TZo&fI&-Uh8?D&+~bj z8IEZh8@NS8lVw??)9F9~P=6+j=t)f#?24PA_;|Y_{OXu9GxX`Bp_)c~w3a$zOHl^p z!ER1%8|Huh{cEH%8A_!}p};C?Btn_vzi#L(}|Lk{M* z*Zvnxo1YXVv2r3#Kwz2yiK))eGfai-l*2*QX*x<_t~u#Vy#VT_QYl(nnxmX-)gKKvKK@(`W@^eI0rCg`x2wV*l6v7t?Tj{6 z*OXIr<#WOPV$WvYdq@Lc{mPdZ$rTtL-MR3~kLL%OdJ*4}kP@u#+L+4=!j3h^3EF-` zzF4AvaEM~5OwDmPaPAxyUV8=82bNGPjsyf|z+c!lrfrAlN4+Kz9f|u2G6=IF&2g20 zzF*pQMR%q0j_rHgF!-J;A|19JW|NL}t)n9%UZYZ}P_9(5Exi@pmmohH9y10OkVDqs5BzhQ7_gpphx$MwcNkftHx^}g?O z&%O6BKs%ErO+{0*zAy6c)%}q7$Js|Uz1sIh#oXY~2>pY@6pAGr$7R1+v$)~f?=Zi* zj%t257SRZhkD>_WV?lV@nnKVLp~gc3>VBXLxct95WiJnf`qKd4b!l#HB%Mm{5&{q} zXJD96C=@7E99&Pjq|vntAJ@TvI5Z$o)Nk(Eb1s0qt3V`~Od$?taNqN&lA^!AKOpri zQ5P`o%gfh+*47r>T8U`GC0s}MA45S#IW&sJR}NUR@GCP7LjTs*e13h5wy^F(@UxoG zOJ!i#De~Lb@YypD1h+&Q4sHOxr zKVt}EECHxSbXOlEbFN%XBiqEre;K$lH#VM zL#w>NPWYQQdrde3h#-;T>xar9IY->HGHlws8N&>QH7Z149U_J_jlb%x6{Jx!%yI@KW<=H3V*l@aZW}-V`Gtt3QRQ&(IrPt zQ!e=#tBu>*^pT zkQA8UOh85WH7Ha+oj07?>U*TJO|0Lz1>Y0R7Hr$96MWf-!YA-i0|e04)<&yY)wR6R zZcF49=p9;hA5ppa5h@6OUma#DbNXXRK4vNvS-eyN0!U{u)4_eqW_ZI={`+s<&$;KE z&GznI%9YBPbN1rG?|Uwb@46Fr^1)1>b0~}dxPfA!K(TKNnf9rerkyDGMhHj8-@fpD zgT|{s*rr_yL8Vex5tN{jGF1ylU&CpA_(?9>jo}>=Z!swLR|cibhRxDFj%)?Bc7en&TwSt zq9LRj3JVqC#HI&LfD7Pj_qFB@0b{Rf#!v|;ZJ{#h422r>_xE927U`6ooDU#f2G0wM zW1yj-k+$Y6zUxGXB7PVWl!59VsJ_0|vP&L3%T5-4mGFxn?ojXp;WrG1*S*M(FaJEJ zoq7t}y2qce8yEgswZfvC7t(z2sWea7pT#e3qA)T*cEe*V{Ql)MH)JrZlydENzFXt{ zza+i+@5#{j5tG1N9i)B$N71^|P z2c}d2VOJv^1=I~b35_AK=ib~kfgFHx@PaQ%7@Lkaf^dV2CA!5Jrb&?oy1KeBEt7OQ z6^?8st^^RVYO!e^EiKJVo7{<8D=WUgStrzykEmObP}pP7M^;B1!Z5pUyu=>mfLkf4 z1hN3+*1yON-}*<6U9f=d-M!(=`JD;BZCO;xMQ*uyA(I!Jh1D{Z-!Iuhaj1uBz0dQD ztN(+!b7r$-=_@-fNJ| zeC4lcoqZTq@VetI$pe6}A7=2JcvC~%f~YP*y|2%p49*26o>OJYq;^_cTB$ja z0s!jwgJ>3|ZQ1PDv4f(Q7UxMh%kq4yZa}>C+3sBbH)>6c3!t#iq1IE$zW5j@3IEle zaj7O=cxfrV=aWv^q*L~oJb)L34?WMrG)?BsokOjZ3$(som}0~agmf)T1sP~F-o)7P zx~jf9;SX5tbiMG)`@ZLr=~>2&*L;)x=j=~cPaoBt34ic;Y|CO~c#xZJzJ+15h9GEH#0(Ynh`Ke3>!iL;5bguSa$4-BBE1*oZhr)6XkRpRi`Ep ztZLL0K0s}F8qX1!ND%PmA^_hPR#ZHYPb&V7?)#%zf4zyMm2F^C_YeaE1GKfbkm`0yfFV}ha96G$Zx!F}y41W3@W6gXhcd`!yPh=RiuHD&g5VEglO=uo~j08kc0TuE`K7aIl@Yr=REt{O5Wz(jO zK|Oi~+paH zW%jFX;kxf%L3?{UJ$(a0_{WR$8%B@_Wzo~q%`Lax$RO@`s+m3F}@5zep;4AI+Y@q%dv9(Hmp=O zvGsX8EEvxV@MDTjJbZJNz=V|p*VX=OY^Vy4yo6~n4y8(!YU3ncUA7F%w8&=CWYVc{ zYOBrzh*nuO$HDh}+S}VXWWPyxPE}#>l^A|PXfJ|~F_zh~!~qLy`t9T#|5UnO`0Wf% zxxm48A3wVK3bKuj^bQQ-1lB@)_OXTEwk@`A-NLPR-OI5Te3T7+C7xa1L;s4W_|o}@ z^O;Y6jJ|;(iltJ(6^Pf;(Z56kyJqp@pT#mwGMO|@jSXb8g6V#>YnWFz4RQ3@ALP25 zZs+ACOK5Cp2$VoOjSbl_cf+z10PUN2dy9#IPEBL+_ z!hSVcV#)*}=?Z8al#*NlE80UN+DED6llXupC&%<@Q^gsoIYCZI{k0H3O>EmDownJw zbsIS+g_TMxtIs@JNUVR28?&?E9kB}*+WzY^LC z6hp0)<1>(_DTeUEb71s`SA_8c#4?4j?KNBQqh zox_Jea49|ggOth@!O|znw;^9R`e_)ur3_5dB%4Xo+T28QQ-e_8z{;LcUR>YD;eU21 zKl{z^dG5JqX=um_CD74EV?%?c1Zs{$p;)4SXqf)N5s~lU`7Aj4Nbdgi4`}RPh3C3@ zg{0aWK`AEEON!OLimLK9!<&lyP+fx{0&v)@R@&P;sMVa1kWCUx12Ks@ol22PrC7CU z6{So^pwJT#Ky2y}UK9>gU4V&H0uxvb7$X7|>mNZPH%9(Bp$p)exlp$WcT!ya1y7zbd) z!hqGn2&c_}Z~xCXa6K3p8X32oH!l3ESFPZlN1x;P3ohf8jf1?rsh7T&?&tci{W%w3 zcs>I|!%=6T@s=X|QTmSZyhhsAFViqcr_(eyHPYM^WV;1xZC{?}R`+oD85eWI9S`#4 z6Hk!MW|-8`&ZKs!1nfWw_|$4b2@DJkGcY(zsa(eMd=5S2U~a$Rhs-E%!gH#1jZvb< zN>dd(Mbu{?h5{01E7V#3KnXbI0`vCYkCxUJsHnwGn1;bq&pr>0Z4}ED zWdvGqhQsmaii?{t_%yus6Ql$t76E7)ZVVnk)tbQt6r-dC8B<7ivUKTEEX$-Jn+=*a zL~cOv26%y$aa=(X9)8$iR7d+1raxKWiqXO!|#H{bf3OZl@iPNQ6@3bINj zRfWP_pE7I6e_sOuD1X-ueBNv}8{~3CYvW*nCs%ZF*y$H?%Y9Gr@Iw!i&19I=+0LYn zcA6R+NTux1Wpf;dVyVQy@G$*@!xT%R=3(C41GxF;Kja{@7q?o9UEg$c&6R$MQVD3B zK$1(KDRw<#P%DlyZ|)q@=?v9sHQJ{H;WrJiZJTU5O>a*R>$`?y{=cK2<%IF)A}Urt z`*5Px1f&A%S>3Ae6KX&i{&N$ozZ2d@3q{Q4P9A*Zaa_kCn@Q7{*ipK#PCRN zw}gMmi!bo>s~b4(>`QrSWjE{l^Wyg`o9CbZBfclIALFcXf>28iAm#$Z|7K_BPu2mX zQz;Dr$hCF2#AD00amXp>apz+%ao>ISl1ZnS)Y-%fwfPE1wv7e0cB4lA7I*14@PZ2Bc&g?1W^WIWwf6o4nGXX zb*NNpQ5tZ3j}Yn5DcdHSNwae0N^)kaV7OeTUij;#A1hG+85$3-{=`H8V1gThgrO8Q z)RmY36oXH$6HJyBZI(6-R9U}%J*kvUV`GD;4N$^lAOx%CI8R;s1%S+{kDiN2x3uOZY9*B$cvx z_UWg1X=5KppK%e7zPgPqLq+ZPJ!=_^0SQr*U0MdDQg)&O0O%Sm^U%_* z%s=UD?tOj@ix)2@ZKs4g(AiFNVQ39?@sZ?Qbc!a*7v54z>Or0`?>#zMj@0?}f z6mxo?fOx5J7@e^qS3u#bJzU;7y&p@AYfusfqnJ9!i0uev0h_(Qkw=Bvr?^5YM9Ei z&pwM~S~NCfgPZ^}vU!pSbY<^4muxo6F$<2Onj6&o{+(NY(ZWi$wF=u?g-Spnqh!s$ zCHnV$_Pk^G;{W$I^bZY_%a7g219aiHEsMt=d5G1$We$JGIXv+47P>~uZ@?amP5y=V zcM^a06-ARur9u)gY4zqS+`nWq2Of6@k1pHJZ-2W8+qRh0-p1t4cAAXksb!qD)D zC?^hj3UqdK@WZRW%SA_YQq2!42tWY>@>h(J<=ATS1og0#N%-Y~x-Lak#=LyjfBMb|ubE+&8nnBaZ@s_(C+LMp{SstcfM(cm_c zFJL#fbKfIRlgs7ErbS396_88eJNaT-Yo%HZiJYU3Jc8Qr4h06rEq}fBH)FnkeJ_8# z<(FYv6ni%Dr4OFLU;X8$>FFONUl_lZUlo4KGP1^1xTe*J7uf~3Ki~saU%yDeG1QQ7~UnMY-$4>bilRLa_DHC-u0O-QYJ#Srj9)%*}g9dQ^9 z4ULp5l_)}^e8uAL|AwsIstTzge^RvqPuh zIW;9FY@#)wRJ+#3tx4==#{bVW$#<{kUp{>?AOF}#>F({PSSs(dkq3q-q%jTn!##J? zZ*(yCsFV5KA2%{os=aZWppt`e9zcD(v!x<{aK9Wp$H8-I!L2H8ZjGUQk>5SLn*9zr zj+eKW`1P-Tg<*(hEt5MtXl`x_GU-Hdk?VPZ5)kFYqqzc(pJ$T$Dva{lW4<0udJ zhItwKzSKXbcOo9c1u#v@Lp>aO%mQjPM<7QpdD@ZzSe6)%X5e%GgO6gjO=WO2A6frU z5!7=4!r19~0AcFS+cFP832lVgO)3|V5C!l&-SYcxEmQ)%gQHlJ_TzVV-;3vYG-R_h zHfFJHI~wK~D3_Y!P_9<-T#uHP7EV6l7~uv4Jb=MCQqVZkCx_Ig$-W#a`(S^TU< zf?t!j3Z7G8v{2;Er&lm--r=n5_xQ!ne*wNnM|%rXCbiSj)L5qk$_YIMGMNlt|L3pr z_m`bTd2okDrkJz;{*poNpU92?6Wu~$6i*P5;XY%a%-0|!xisf?TPwu22-L5Z{ z2#l4+iVq|=X^gGY`3uXk0?Qw>`n8I7bE_5HT7`VE$n8%oW72*Hu_2%0r$7BEuH(|) z+RBtk9ketzg}wNZ98R^yNG?zRz!157LF9F$Qhephf5%roegRIUpjq=!379cOZ7OIW z+`A|jq*fT=w38Ol+|o>`R1ryJvHc6#{~#N(A)DcmhabUho5^slAP}nKgi1g~u)eFp ze_0<8PX(S>{~sp07NG86MQ%WtGU{e&Ki&;# zcb1Q3n$f;EHN09)SbaqixDo}_%6PRhrE-zm9$!l9)Y)`7t^DXmKcrTz(%#m>lt~@5 zHa7(+-m=}88&(ny4v$hQiDV(yb=kIUn;nx4eQsFNvCOPYSK|akPuX<)`C=1krsTx*=JB0 z?T>{3fyHQzRNjhokgKgq*|?x9Xg5$f2C4p(Jc#UJ?JE?#t!ay zdO6jKu$Dq-s)|6>VoJbe_k%@aCjixTR~mcwLPc&E2EG$nJ`FmhPEjT+Ee)c|9+oxsZ3jIpafc)$)wYo5~x&bM+hiBAO%wVWCa2$F*0c>szF5W!4gZG5-JXs$rDZ8pFE{qHeMgQms?nwlE1 zQxOV~2|=Y&C79P{a^@MQQ|{ZU3%_PH>S4d`SIR;X3k<~J589BqUc~IG8>=<)uq{f( zg6QIN*r_;Xmb;!=j#Dj%KC=+|O5{(6N}v`fMfY`VhTiQs{uy_^mqPUzhJhguc<|XY zS3tT0feYZ)D!5gF1ge!Xw>`E5GuuY7X+N&M`f7@W0&OiVOz8}iKv41x5(!i(1?9z| z@-xtDJHirR-My1UU_A+FQp*qXp0iG+rL~npsT76(686xxMCds;I>Nn=K1a4~61{_? zq4k$&$amx6K&b@O9)W5&T+)Dl0ti4XMIp%a$hu@8Cw8j^npOxy-|z?x&8N$*H!<_5capEd-Onx$1fvqOmbx1t518jj1n?SG9PS%3lV}%r&5vT@ zrfG(*nx~*MPeB0!36w(@AVdb$GPP=nJ05=t*UVCDKY%N*x{6$Gl-8DJrcCOft)-bv zIwdAN2Vq^cK0m-A$~6`!K=dVy+yOlV7;_m6i_*Y$&OGCE5q&6?wE``5|4hRmC9VGx zkCV&JpjHjeqZItO@F(N}sE9YXsyh6CJB9(}3IiTKF(e=_N^&Z&I9TTa2ir6Pa8`X zeU*UEP`mxeeGMlNE7o5@bH3+r!pto5=g+55EQS3E;v#5(u>RRB`P?YKf8Z$^Crx8p z-(Yker2zmhm&n7SoR zSn)<4{k=Wh{F_D0KlvQC_YU#EA6JC1IE2Wd?_ZAqdym&>%EP^U;Jp`+$z&)LOVncUUr+o=(cIL?!w)?~u5lLSayd|Vfz=-i z0l1D%{&{)?U{Aq+*i$5+S``>xgvdV6uU+nF@1Ei)M$ggj@nQFC4Q)5F& zBw0$qNvTw(ToPnpM|(S;`RMz?tg51y{KG(T<71i@CP^+^#0B^&0&psd z8xRS-WrJt-*e` z7FfeTNW%XM4^>SIF(JcAySrW=;t!WRqn2f260hWp=WWDX0VjbQsFrc7CERM6d!JrH zckdvb^N!(L-}xTfwr-=PIdBKsTBueXMMzZ$t@9dD&j&N+!bSU7D-82j?>~#llP8le z7O7N3;n-N#zp)|9?|=6@oX&ZSjO1dW+Q>k~i-5uoS6UmeuRW9qq(0QcfnkD# z!UK3pIobo+zW>o*%wrwmU*45dscLyTjP?DOQY7`leZh&%K9)A86)@|6r z^n;J(yI1}%>(;FcT)QTQgQllpI4yo5q${BD0c!g%QTcb-I}c~>+yfZR6#}K=)meYp z1JN{K(XF@BIP+jOclFeNmmo@`C9lanQ{(??_Mf<*>cyRa9n{wz32I2rT`6v7dz<8~DhF-cPkw zBVR1x)MD0O@;51)=B5Uoc9ZE057Jj!|cB(_kT~4e{$^^ z1rYnGP;*_1 zr2qxE0tI~JLm!~py++9>QI0?Auxh~H={WQ6ZPyq-Omz>NMW^*boTS#&$h)7im^7h1% z<-D?NC9@AZj%$8=9k0If3WjMgFgPqS@Z$0G7!gR=;yr2t>Q)L|dcpx5dgvjH{pPT2{nl7=R#jv`y7hae`uUSZ@by@6<#gjT5NG!k(&PEQdJ|&n#WVi%VYN zfFq9QG+lLARL|GnUAjA@yQK_LSh`ypqy?qBVd+i*De06}T3~5VTBW5sqKGm!My#ibe1n%%;#YH}lkIBWcy4^xv zD5U)fTK%b#X|%|={OftI6w#^D*Y@P-u?v$V?aKbYElY!+)l6wT=CuC!9``vM9wqQZ zV0%vs2a7NAMPEnNn}wuIQNHL*xR9-l?jZgUa>y{xWiA;LYw{bNvVqV-QA!)fUT5SI!-@rgDAF5KA z8l)JxN^qam&?rcO+Zo!LxcF)fhSE^**FM4xN83FQ?1ta&**TXswP7tb15!AC`^xO@TT(7(!z!h}dc38;HNx@bMcyjTeJp{ARoNJENc(@&UGDZ=8 z>FsgAr_xAG^~GVSBLz6g|$*lvFE|0uzPT9(N1L5uD0!JC_XW9^3U8b5Q#R*&hCx^Lfv+}8cjxh z*MX0R@!oDzQ@>n(pgo<|H%jxlP))T6Zbb&^IsUcUespiU9Y^faKhYX4M8&CFDk@>? z1S@xDP@h^EhX zCr`y*$0{6}oRx@;t(l#l5#@D~z!wnCsZ+);o?5J(Pz}Ga0zW+4BL%GIUSskp-&M$r z)0}jZcCG$g1AjqwX&ZNpr2q1x#-`7SYX-sEu4B&@I>qpL4`x6Gv>1^Ww)2FtHpDse zCNien;Jrr7blu`|-)5rT`}r)OMf=3f&yQWQ_U_M`vg0;{H{)34<_Bm>tA2;Av zZ#Tt89iEINH1DT`(U$6)DumQ%50sKnCGkJ z#EUHF+dyG%>zFxZr}1`L1mf#Hhbd8pLc3FQe}1S`3GIJ3JUx_bf~sI4_r@eq*1hXjy!3MUEHR)%k8PwTLv@xDJz)m2mM_{kuqNtakYl-^))PzprBhv3_gT zgh;)R?6>6;PeD_lmqV`BSKPQ4H=IQ>W`B8U{jA!gA$RDFLC=K<#_47%S$p>oLXg9$ zV$k)5culs%(e8ID?A*aN9AkNGYT&)(hnwYUAP_0RI%ZRoh!=Ta_B&C9Bcu&+wFync;Z{_-JO z_x`WV4E+^3T5|pG`hsxHH}?g|TUL02u9il=JDYLGU^NgYl#ptt;az*6m0`D9qD>=0ITO+4ZYnZl z=orx6!Wr$a_rWC-xZy$W>$WMgOaV}q*8QdwY$;ZP>1q*4Ud8YElA*{u93ChyT_b`@MM(a-MYjZ9lm%! z$E(8ye^Mv}dy<;HLMx;KD?*V#j|;7D&Y=XgWc$sxrkqRa7XI7Sjoanv*?P|d^6VU{ zEYY?PS2KEm`ohIch|Y8AnwYnJcw+W&j>AFV8J4t;pcbT}4Dd=5yX@lYiqa?~jL@m6cUhBO*yb&$3yubiv{}TxMRv3HG5r~-s9(=7vX7s; zukjm_W|oUVjiv9um*j;sY!dVBQ&aLu;iW+9L-=au`)B@&?F#Qwc0F`f&38Fc16Wkm zoS#be?j!&Z5$IE^i6b2reBK6M?=3FV;Z7VZ$Vu_hf4C32=ah6BD_xC(6aG+nz)_uC zctWtMAPJy)OkwRYeH&eQj{}Y9^kNP1S{!<;)}C_&n%vvM$0wX7S8D`Qi;~a=lfhFH zyv`B_>IwIou`wJawH%Fx*IQXO_9UogoMU?5C7WDp%3IyDb5cPM*Te?|{yC5nvL3AY zqfBl>+Yf!MU$SEj>ri_UO zHHKK^-Qd=!^YEJPQ1(Pij!n}yKM*N7!V|uuzVd#jj>58Wb;G!f%BH^b3;k5OKd_zG=>$0*^~EPT zridB?H?0c;q%reM9bew$*rBz75>IF!t7yV zl2v9?Bdxh^{j+mm*lV`FNte}Y|2HRHMPKW7u-CkEY%Oi6T7lk6y;nA#mroM2o2y^n zbDpf=*gvAD*eu=4|H zv$W9kZyoLnuN@Z4>=p7eRdz&agq`W)9*?7d@yXNQ$SN#rhIcKCW~~+KVz}*MEd3^E z^gDS0PPJdxh2|ce1k(TdQa_q``7#ym|8QNU(eSeOZI$v0n$B(Tmgw}*9bUi+^GZ|3 z0o-2%F_x!hhD?^fi!p#l7*~DS&4`$ki1UykiKF*bCwlZ_T^;c-Yg*S(nZ}ofJ2UR` z%`R7h2Hnt}OEA#A{Fwq%Mj!mz@|yKz7Y9fge~W^k_Y~Aep0IaZtj7V15VXGo7Ga4< zT&}mX>zPt;pT(O6?rBIOFm!jhA0{(3?bT%a0) zNK`94f$CcyTF-a%KO7syu}8Vfj;6gW{M|>zr-Fx*kQPQq=lARmC=L))7%|)WriG-i ze%I|$dhVmy(*kXH&d=fr%mvQ@6)&xk`i%rb+)iru@QQu~u1n{Q75It3a$wJ`$K^%D z-%c6e4qRS7vUP9J?3cuj3)hSMm1SfJ(|yCw!))IBuD7>j#X1H-XSt5a4cv-lM?Oy!i*~Lax zu6OUsPrp&u7B*U$?&4QydXLJ~y`+pW?A%2XlZKuJ+}tT;#fTXzS?8?34R5$O6_Sy8 zyY~ETlWk~GcaffnHZ1-4N&cSg=idARLbX#mMr~|~ckj%_%n*kdH{FO80Ea4B>Q<_L z$98?=^FNICw_7!W9H>zj8uL_E`I!`8n0L zrm67EgH>}ShRu+(dZFW!9Na(o0be}Lb4exuxqqy~OP(p<$OYi69S)BE;T`})er0(_ z7)B5RXSDDsSik`ASd}%vO=1blWy;PH(sQvqV7v;`7&8A>fK2-4F81Ww8MuPJwvaeWNt#?*)TpFMuohAUBlK$w zdj5JZ4``L=4z%MLw;iPH5Esdk4Xh7EnANFZV$2Wz2q@04x3z5j1_#yzx~v5eUiE9p zqI_|N2BO54h=Z3Vs=jnO!}6B{D7<8FvXl^~W5`ExYN2Y|yEG-$BZu;DL6YPZ z|HQp37JF_G{sjDji$DUYJPOy>D$G+X8!xJ;I@75Ma-p-y)Ka;bkE@aFAR`5_aEJIr zniCUGV!P0&eM4Y<^4UbDE6W94E&9*3mge-S3n$Pc@6qX6kpzt`&!4&9k)lT_?C$RY z0AiQbkn`5d3~Jw5i(js>#h9$g(3|fFPj~c-zFIDHwHvFW?t^tuNjJA0R3Fs}-b_zy z0(q0eB~mUGJTRse)7c(bWwm5EE6=DBI8i+JHOv0-ysG26^Vr7U+j(+XE&NXPSIKK0 zmxH35C&RPC>#e|PU5@hgn$PaXSAE|&tU-M5)00tkWv8hGZ^6I#XkWLBQLi#`-NS!! zDv;JMV1W~WD}E|G^K_AU(yfaiBPpta8$+`C+0ci}9rDOMG>nOjafLjKkt<$a(c=l9 zcU$N{d-id5$y=qj6S?Dw%R$Xvf6W)tlsvq=+?F(Iw|-Q?CkTQ9G4?W)C^OA(%x?gf z%K{xkmh@gBU*hD`2Bg>>{j;2I&80m&_oo|T9c=M3|GrIS(IQ+6gjZu16kI*f&RJcC zbu%0*?)ntfE%rn386xiZP~^qW(jcd{$M^VRhc3;Ymztir-Pky5E6p~~uK&0TDdf3O zB|4vMP#-gxaV2C)ag8Lsns$sQyX}vWd?E6;2JnUsYKlQ=x^<}H0i!@ZAQ7D?f8bRA zuSSQHz>fOc@EQ(~tH0|s`i#@wHlKtGxJK>Q?Ui@kCdx599BqhZ1jxc$Z1>CjV^~;R zlU|2BpB3I8X1*EWL*ndRy`y@!L*2z+Ewx{*X+-p{tfeM#LBALi{_^fevhwC-4Ph^} zlqr(;1n10wI`RnAjsBny&mVg-?b=Wp)RH_QrBmNhF^6k8GES_3xGJFPg!oz>wN5< zu2EQHLWis0nWL+Lnrzdh%oFjb~jwi3gpFzPuw{~Oc6x66w@1$2lBiu75rvxUlIxoj` zSCD4olGikeVr!^?EAQ}kL8_rRLBxIAgMZrmfw}#2O(}v%a@}~Cj zctiwXzP-QnC7N7Oy*tAADsTKk^vz5MD{b@CR#y2}z8$e)Z@E>!YFkk0l{*%!X>t5u zA@OR>0e7U%gu->FhWY+PPX^>Rz;~ve0;6J#ZuzAB4QoJ4N*4Y5kg?arc?~@>cE`*w z!aLU$e`Ll1FraV1w<#8)i^hBOG;hzFoqkMHncXkKw?Y#kMlX3r?{C)@J{9`*^t*9N_;CV4UQPs0uzq}_%xh+C?5&ac%WQbZce|2(Z}0C`ygTnd!%E-e+#OKZ zPq|9Cf>`|PE>b7`NFon|s&!J#`0i6(0;+H%JJQKOEb{13SB!g5_8nbNbSBD8O)F%0 z49_W#o-iasF4K+_yEuZL&>N+%INou1&>r%W%SIQR%7`TKU4RPzYM{$;H|Fzt3dW!1lHH+>j&KZL_WgUbfx z#aQ{Zm9pxX&B^rfn*VPuG^$Qwv9{-2V~rT@U&qDvh#~sGa3!5Gw^M|~ zaM_sgEznI}cH*RhE;LRdIBifMZzq1r=XKLnEQGSEm0kFmGX=1raS+&PF-jpZLp-5u z2dtN%A3tsFdp{Y$iV%to15c*-W)S5L1;qH=BlRL zaAQd}zwNiq>qQtDk>+Scsb0}YTt&AP_^bN_^<0~KYgkmI>r^9n;&vxL$=Sf;8h_Pq z-QQuQIh~z8I6kBK<+uoP>Ee>$r1-#TbsBFmxi)7;U(=C|DhlcP(k$#=u$kTi_l(t< z6#CfGaMB0VyXu}(?!Hcu<4vXM7xMVneLWy`Sp&jD%?co<^?94z&!h)>rP&HyPqeB4`~qjPK)XgjJe66WM_%Am=tSEuFY3Ve?%+=JCx0j^Q%$~< zaQriE1Hp)vRBCHD+fDFCB&}_pFB=_tXJ8m(+DhX)6b;E+)DLVLYlr9Kwsv;mX3IC! zdA^=ciT(PY!ny9Jpox@OI|G=?{HtC?YT@CBHxv_Rwt89-(V;Lk2UCNwKs?>Ea9+m5ye0xn+Jx(

lnCUk0a-J< zOH*Sp?C>xVj8PjG>$FJKNSx(B#*Zd`SXFv8+XUB=!x|JzaZ7FVc%Pm%XwPG!nQLEs!~raJ4lCug!T;NIdS@H##EfWJ{p ze+wC+^T!=+3!=h-)<>#^ zE_3a;(E*Ac6`ehAJsp>H`L&KAeBNK&deeI@veo!&uF;h_F6e8r;WJy;;ld~#o^*b- zIHeEeX9MsDNH8K|;_KTnqddQDks!|@dP*gYGK-%)0TTlaG(X6+P?>#ULhs4qSR)k_ zI5S2VdGvYfS+weTxLeEow%^ob7C)aGcwW`LBYCN%E_V64Of7%Bdy=2J#mj;cJq!hf zC-{~l`>1d32>u5a*X zWoCI*E%ScL>&QP!P`nf5H97Yl+8( zq?0TSBwAo+Cy@4@vc;|cYsM?wC!dmspo{fve%8$)O5q$gVG|N0rOPW(yR*^CTe}k@ z%dj$3lL6p_HRRKQG20S&Tly{oiR*tsixdVh_wBrjsRvgEd{~4-Y32L4R8GpFRk;-EZ6?_I>?wYFg?b$=saM zgg3>#c*y}U!q+Lryd=6M#3#}pp&fa3+>k!f500f`Fb^E!G}tCCEF^^n2se_e9=uc+ zxg%V5e>60?ih&mxaW=ROC?9q1T#riHNt_c%WVX5Q{G6HjQS$vmmV}k4ZO6Gs>;Umn z=fmrJ?7ZW(!SSjCzu)ii0gPMDnC4u4j8TwJ`NwL(KVb*7vTfQiv5qD5hhZDSq$)Oo zd(Yi>#)|ij6mGj?jxBqpc3g+=Z&kAdBTTxwf!()%>Codz3#7aK02=5%p`={BAyHos z`xuyZMEmN`LsV4TMi2X`i2{)#=GtRsZyhs;@lVk1PE=i~`V-~GyWsX-f|J3tv`(@N zVxc7Oz8J1`YYUal5qrm0mJhTzBdn5qzUVr>N#XmFBZH0FlwR1s)U8Sda|3%*asvm& zgk6@wt0L8AEs46^8B>2U*D}$D_`Q!z$|f=sEsWx~v4OH09ONp$H%G<#x&_s!sJ~cZ zzW1k=>639-YJb%VnL52f36`j~C1^kJ@=yl~$FH>(Z8cros{PC2c<1C$Qdt=?v(5G; z3l~VdHYprlJ;98yjB%@!ok--JsWntHGn2$ge3dAJ|0+$pviGO{$J2wwqcU4_jvwC$ zERU)BXT!~!=CJmbvFQtJQSMSg=g_L^Oh2_Wtd3lk7lSsj!(ZLEs1s3QU8kq&%e>tm z&~ev|DBw!Qe5@i1+~5Q~OYc#&Y4~YKP9vOyqb`|vd%it6Kh-njIPE1BYBIW^(IoyBrOHlxWpo-Pep} zJleea6*KRJ6R8t_4)WJO70^|T*WyuM;!X^Z!Psuv{R@~P1NGoR4||*-N_xC-Bs?dU zp~8lMI_z_XWEpPnq3{Sk84So9mqudk*K9DAl`r(2``nrWfAC|#0=rsSuz6;Bm5|F&-$cVZ z1wN-Hn#MnggAU&l#olNZmScI)9!QekYpkNNTqrzzYh5Mj>T10%XTLuw?*_Bfv~z^O zy4D*En6w#`q*LDV;HSk{+}tSNQ}@ZdZI-j>z6q>Ugz$p7JxBuj`mcGUWZ9k2w#qo26sc#Uo1{!r(O95`nCBp6obyz0kW>LxcG z1#&p1E_|iC(TlSZcF_9z{fi#7;aR-8l%6kS+`@MkI3jlAK@Rg>VPbSHI&6>S8h4I zOJP-j`^rCVCvoeabm?qQO(wH`P_jZBX4?ego@P^4avp#{c-=~}Qm=t@fwyCsgJkg5 zu(B+SHC>cK@5>UJCt*p-UyB{Y`7-j&oEtVmB{HNbC*UhFb#-}Bk`0&TRiMq-LNIiK z8j~y}B%U1lg{h+D{wGl00<{~(8ZR*U69*ZLPi*`L0y~RryP`_>wBM}mVPJV!7!oOQb>U^$V1)v{u@Wt9$kxpFmgqnYt{+PB zknjhfTnVoTOu+48h$x_8V8bBL7yVIoRssz~MFq<=E?^;4(q}Lvs(1k=!sds7XD6iq z#L#M%=%)VDAUm=F#@TOEi4Ud#J{J%gj!s1lj50DW&lhUdaE*qEjK|dQ8k?T~`u&>{ z(~l;RdxiOmas>cr5tp_ZjY?!(QUuychTmBk-&*&4^rwdF1^=+mhiJ~K|ACyUo^*W1 zgz!S0KR@a5mvP4#9ge{_dNhr7UI9M4}HBF4N&O%FeL^Qj&VdsWthmDJ^LX z*gi0RQcqEyU$9M=&Z)*st?qhUl3~^UcvVH{r|jdBzY6ba(g3qORU_hX3c2I%fxF4- z3rh3z2TZ?8=IAEisR}tpkCDwI!wQFddV#}*wsJmaC<*N&)O__x-NN{adO=jS8Rg>? zD4|}5#Qk{-)VY;t*@Qw|0Z|*;5yuP@f}W)BTt98N;)I>f7~I4DjZnxmDU1RMFDQWg zq7Wh|L29f*c4ssvjFWJ5GwUR_V?Up)^B@n*QYN27f_n;ZpT24tPoG-KCd6aW+m)M< zAoalXO$rP}4%P%>o7-}S(8EyW7|{Bg0EMfz8 zKYf5X-<=Iy6NX7$#J2m{XdW+zm*n?8D%5I(Hevj2@M+aJF*{x;2YGoWRAO3MTU20f zt|$sIeSSeWuaDlfhJE9Vt_&q2zvp;e)??e`K1R2X#j(jN4T{W%8IZD)7g6ACRY>Zx z5@Gs$x?Eugx{3VzF7HYV6-J!X%M_!oBK~;jCi82krnOx(TUOx-hXkBhhF!`aT+@)` zX5hm|8#F9ciyI9E-p}a-V&}t}wxJ_3(r1Z26*%`2J;7Ep5@;uWGvj~4+D#z&1r*J~ zhmq`>FmiO&edC=_Dvgh1&WBIX3VxKm%g%gHV|IEPLlk6@YsM(rq$tIc$G1E(8{r4+ zbRob_KFl+eu?6^Kpj9+AkA#AriiPOcV+A@`f&)nXnk@s1ZXs7W-LPH_AvGM5y78ie znzr@tP^Aue*~fQnck60l2Om!YudyBvj1Z*V)NPhW;P^sZ+$ZcpJ?E!thJT2oMywbh zvqUrQEs|zuwlyS$rpcT@X=EFVJGy1cVL6f@Gkt81S{Yd?`I+GSrr>knV4b|J5l9Om zBDCwJ)x;9~UVsqAj$RU<=td!eAX>GW;njN<73#F{IMsL3D6F3|;gOjt{f^ z7|`F#vtHPzou9Zqf+`8qn5iXLg|gelGA8(@@K2@bQ)T=SGdXa8%U?D04#Nn87*+F% zFz<(-Mo0Z5<^E>OQg9px_bkC7ysk>O^^$2b$Vjlc(XvVc0cDQN#pATJAPY}#auGBA z|9HC2Amk!~vmX3po4es$80&^g7&Jj-Ro`^2cK2#RDc}vFpApLr8;y`8U<|2`lUb6g zlNwm0@m1r7-S4js$lqhyw)2(?a`HeKMu(Zjiq*8_&$m*u);9eKxvicS$0y?v#Lx7H zK~ot(2NoT|qaXCw@4L885U9Z#|3=r~od$88dSZR-OEWT?$f2Ntjw&BZ4Vwbd-hIFlGCrZ?qh^-RmCEM|aY5g#_Ab)c!aBpm^MP%pN4X(;kuV8FK@k z^>xt(r$?pog+Mr|@@Z%cv_Dq9<_;=NNU&a??G9^k#vpLPlCI=ue`He1r<8KrU+2}m9_^9Vxgt-n}50cHDM@-X~zoz zlY*FS@4jlcTT?29Tg)7_nZvG_-2Awpg#q z%6t{$-qTb2BQJ%o2;#^&a2>rF{spbG^Pm8P$>{ReV1LPsTQl0Va%pA3q@j-H!^I2gHb5ik|pVp2g<`1iUO2pGTv1!=WkMoK(b`@)Yj z`p2xwp0n*MTTB!(-)x^G8LT{DdO7%$8Jn$yOu_lq`b_BytG<#{&0G`|7Xw|3TNw9$ znQMu>iWzORHi^>i?(auc$Ib5!LBVic3HvnHc>BZw8ot4EuGxXu5~3FhBq78QhHTg`Y&Y%jQkKdd@R%$EjLG~P_SDt-A1}OS$3A9$ z8Pwd5u!^)~kP5wHi^Wk3=gOBZj5^1_Csp6{*R~T5ZdQNso$i!s2_>OJS}xlXe0FMt z_zg*fJ@0V6g1s^IofAa#95Od8+j4_fF~VJ?^|!XKlyNjOTAbdJ=zP@+a=W zN;*F2XMKKn+~g^yaU#^=skTa9=0NjHKr8^QYCt!#P+k8y_ifDXcQ}9k^aUh@0^>V$ z`iAtMyu0PK-Pj@JZ@`nOIPv!dZw5jcU=YGw*i+D7)aMF{9Q-=zL)qAor6M2>9RZ;p5SPg<*`#_Ju;D}BewT?Y1i<7oF9tDyHxlqA$QMZ}wAD?mMqoy68DWXZ7 zUa3%>vsX#vUP~4jphE1344yJH{HQL-{2>{?x8H+B$E3eaNI&3c`=Q{IqF`iR|fMP?nOB5@fgc?5dj1f(Kb1y)| zag|cX37Tq)6W#Q$*$$1m=bcPgyl+FP{M?Bp^_@nLAw9t{(#j~V9v%jhCc-R8H&>Lx ziDv_U;5l4~U#yWep(pzgGgg;MwnBBfSphf4|G+rGfmHlj%LwzqTdEY=|-Dr=PGN<8nYkKt^CZMF!>@mHgTCTt-$w?oB$CBigsSbtMr+oR^AMRYk1md9i-;>DUgV7Gg|KEe4&q7%OVPHg&OAUuONgWi78+f<~ z&q=LngYfY&DDYW}=&^EzU0j4YR#9PLeUF0@Og^Cx+%&sgt)9ZJtE=@Z|9#%o&yo7@ z$ad4&QxS*4j!Q!$Ppb|R7LI3=k2#@Eedx(!vV+bPGvVe^y0}o134>Qx`Kc%wIfWAT z3B0~Ilc_2C_xEfn0~LnKbn)F_c3lxd0^)f0`I-d1pz;?j96A* z|6IZOA|y%2BMn=UC-(Irm6cKn?T!K7wCMTw{#p^1FMI0a8nzXXk#ir*qiqC@p! z{8%ji`=^Yxe`|4>gbiEuuVC-7SAS5yxe`o$oPLC;A(HLT>Vp-SFo|cB$RO&d!orQH z>>wH%BRT9sf}EQuvNe)(Prk8;z!2+2v&UjSMHAP#P$**g-{2|#OBM*A@R*dw2^N4hTboUfKkyn0vnj#ScPx||E;7)R~ z5RRWMf234GXU1+3HN%^O17?TN&_rVVn?*Jwr^ZTr`0ZIFD(|vT!WlKKN=zh*AQ``I z{yO($_;EH?Xt)WyONzKqj0m7H(?3d2V)n5jGoph_O8Bk*6{^pCiTeJ;Z*^$6pyhsJDyV(sjBsKX(l42EJt8l3Vh=v1wc=UWErU){j~ zIl@Q)26Y8#um1aX>8hz< zrrV)eYOO}+4?)ChBR1b1mp>|g-Fz}{yfV;bd%V8Lp4?$V<4sc0$${sfq78X=&%gN(SQ|df2RGa9L#k##l1G%OC5~AOw%2xwzQj z{-alFG7HFv5otjfEEAWXoXMei5XaOj?}>rHNEn`Hc}r#1lEO{M?DzD=WGto&FF*#J ze-tw>9@vGyIBRK9V+itxFT8wLLcapP3W75_ZRNE2UgrIopGQ-skJLC3XGX6<8s% zUnr0)fAt%`|KoI)fAcM{GMEZB@>u?J#z?)T_78T78HFo6!yvEJiLB$-Xc4-}^ zeStk~z{)s>X?D?tg=v)ev1V_|1a5_Rj;QfZ?GJuzH4OGIipD0FsDLakNi5|L&%XMk zzd%8iHMj~_{PMP(N#d(caoT4IpuM+G>~PyJX#dM_yAcq!WwN-~XXZc*jQ<41b7`g+ zHUp&6=CSXBXh2|Bb>XzLb2$lo3)0`;9R%AamO2Zq?up5MuO(y?p3i`addePDw*F_- zQU(H1{=J4rRA9u>9Q zl@cDIkP&q_-I8ESZ%9MEF&q@2fr;x*FfWsah;`pJMFU>g-0;on>MFy3;;kOald4vK z!+Lvex55-m)@09Ah;>>O$m&?!6hZHt&-`wez6nc$7xm&8m$Bg6!wK;ppjj4>s;c@# zQ5Ram%((g!AR*g-XCTb!UP#wStM)*m=&ywZP^EkI!+T?@%Wu zLVX@9F0s(i@D2)y7KOy~4H2m@kv91h@--4QOgk;f1OuezkHerU379+)%c;(fad-;m z>QaFTsE>=XNdizOfBw-Gg>WK=eF1rDDOQ99Ryq_o6M7ol#KX8h`!^^BF?-GZ9`B+Z zMH<>C`WeNaaQX)b1fLAK&%~7j3#H{7hCQkBQ!JQ&z;lG;~<>p)m4|-_l5KH zrzL@pIcASEzsl96YJ!D62Z~9(t5_&&iu36*!Cwy}ToJbQ?P}*{%2*sZlpuTfY!+6s zu6p{SVb;^d1@xafVaQ!h(Ryr`neRZ;}3VQ0CYE-UTn~ zaeirtgRhrPsRK^qf}^^+Bz&?=Mj!=y`T5{A&WOZXf!1?x_<(2rBTKIlTKbYPVVX*S zX;RD6<+oBdXPs;T9z-Q~0&=JdMUyEV{X{xLH^L$5WQ{5D+N=qCJ*^(%WNQd%aR*O*(ZLq>BmnM7fu)nMb?Z3DRAG!{XYp3DVqQ%YhyEPy#!HHZRp>ksw)v&b&(SqR3qDNvP*38%Y0 zVJbglx~`M{3E059nZ%HUB_?`-NL!ZuxL-Q@VbvY)N;P+m{MmVPKgA(yz-h66N;388 zibGZ0i>d6B52Q9|B7N76d-ZfngMpF?^xb;R28W>t9_{B=i1}l_Ev}2aXe2e0O(M^Ka)8v!2%6lc1id`ZE8HX1@)sOFunF`E}r>@!k*_M z9`taYzlM{Kpc$lpfiFeKgel__-aTas6NxRa#P0&E}%FhvJN1~iYHL!^!mHk zGei50D3XYr?@c(yF`U8-vA#p78>P8?i5_}Zka8e2F{W{d(&?=FQ~#30FI!HO?@+qp zQG?mn79l3A_-}5>kWbw4`@vl>O6%fsY>zXFi1*|@hD;1jw+OENm0R?p1;Q?urE(X9 zBfPgr4u>e5@eUnbivUt96n$?sc5cLQJ<9)Ru=r&j7yFjx%REmnzjTwHoEZ|de+k+c zOdQaM-?NH)9McN>F2s!D?M^L$p5C>@(dyjEU(kB=wp86Y3cP(Yp!J{zs4n$?))pg{ zXhYRz(-oKAFUNQO!sbA2B+L+6qBtXnRQz*no8OWf{hY0c7I-fO{KQw4GME&g!oUoz zm{!$vP5Ek!d=nSQ=sVJVoo!Ti*ybw-`QqgA;Mu*@D=1|IP;{#Quw6&I(0ryvvU{6f5hi?<>A&8^FRCjXbB2we#zun_YuP{RiEhtYr;C3N1_HPmQ{7yE3ZqVcUH1@K;zSwI`~{?i7DKBV72mdzo*WScTS8h9vIbIhnP z1{2--N$kr!WD0l+9>LFF0tKMVdc%tc3*XcgwIfjt(`d=I!=EC$^RO zEy3OfI?Rq9`5=3dcuz~?@EfsQM1lw(kTAT_{_nb=*ffxc|(t~*yfGZ&bkvIpZ>7phBa8533;0XP&fr` zOPcQ11b^NEy=$juhkzMZMvrATrVUk`AR4p}X3^F-XVx5n&TWLqN;a_HpLUfRNq*e{ zpV#h;*l2~%MSjM>Y{Lqnp<(%_)9Q)h7^qY1#0Aq?*sn@;?+%VX6u%)D&14oVVsGDt z8YM0|kf;c-NaANcze#IX5V=o;`5Y#tbR;>v1iH!pcsvu?bThOLpwBBuC1ga++i{n^ zhKef^!7v#@PdLG3dqiq9!{v{s?kdEn;qdZ%pKVMmUQ)of{cmu^2)e+br`xS)w0uS+ z$73`thA4#e6m|3}U#ki~1d|AoxMLl@xHzs8TTg*wu4| zi`c({Pv{wsNw5`(K+;lZYd9Dn5G!fH=X_4_TVcyKn(#ePGI^0d(?EDw*neKo7^9EI z!u5>c2->9kW8`I>e%r_eOzzR`hw1rbpW7K0RIv(DAcq0F0f~G05te_Cg-)|IGLFv^BHJ8guklW4csrH>AJok67!%rbc>IV z^^f(W7^aLUSc)V#QyIA~9gX0nLv>;`Sy$Jxhc|aD&Kgz)*?D};;1x8OnTODdPcrXV4 z&qNZKV6sg?bHH>^r-6(NCGdPtLIt;>;v@9qMSX)z#a!!fIV zHohVg(&5*zosg5`3lC8A+gp1%So}$f^hp^`_rhT$hA>Ure|myQcEellZr{uTxhNOR zb@#EKF9K$Zg`$HSjR6WF4DZ-CO?}P%blca92~8mtWEXNnqQ}^EMVN+^23f>HEE;z_3DaN8K8F^zI7Pf-N@KeK%iXqDz7^nbJ~0ycbjOFX_+msx7AO znJZ;QakS)StOyZ>5JJ|xoiI%aY$)~d1W?*YE@b`L)(cRFrlzq%>;KX8m2pw_LD$zV z3oIb8Gz!vEl1kSu9k)^Ov-6)hbLPwp@R>Q8jQkA=q8;*71LZ(7L521T)2094aJJB+Tn#rCU9_WEoOg;S zcO?F`|96n$O6G^EZc!l(vNFah2x$?g6fD^GR!gq?gE^n`GbRXcIQeQqZDcW^;zEzc z9Gt)LKPtz}n=u-yni^QrYn=r!Zgk%SdgOpU%4GHMsSaf{9h6G*8W<#G8iyikj@IW* zbtL2;CCgvwHUR!YkA>S~RlFGP|lLwOAJ5p2YgTvMIFl!2F0A z{jiO%R`Q`yNGk8!1WeWR9x9^WFy(C1Kn#ftX-fZE$p?pX(4S`USA{)Y!?%bns`Q_rmykezPNq|G?raQC?yhWSd`gG z*7u9gDT_mHXq<69O*wiz{7i6P<>XeW)4GS6#lHli{y8el|ARU&E)uTzqftmynR z!MA@V7;LxHxH!3Ex5yUPl7Mt6v8rOOAit`yz}j5KJv!btfaG{kn#D~l6)$a2?`YG} z3M2di>0SwaFhjGxTi@TfQn0LFBRini1(+atsE(aL%WH5E1R|COpz(olsUH}nG-q(? zD_CIeQ}OV`%JiDn7WgAA#Q#K~+d1Ljo1&tOXWVe=C96B4JYZ72>bT?3OD54K-HDdn z*6ZEkdvx{ATFj6H7kmO8uGIPjVIFGs`#bAoGY#XSPvY-CQ$j(nFH}QO4lmFpIFm6f z;im?)VhGxCh*CXdkht>yftSTcZ=5UF&O)4nuk z(6RC4YL}FN2-*_Qltf_IXNhnn3(GimEha5;61(_y|6E|trhbS}p=}jVUJSuh4IHmqJv`V7L-F}H6(DmMIl6G)I0hra-AEJ`WNHTQ ze?01)o^Yc_&$9O!-xtum=Wx3gqbCD!DJm=IDe?jIK;5}|elDLQJdGPAtjwW7t^Y}$ zc+t#Y38H)=`PwgJDA?`>nw~Q+cgyYZ|G1&y|9pdWTH&S9@OTtXyJ}_V&VqNHP}8^?2c^d}08IbqeUWq}EDhgpv(jhp;k-or|ofE#&DQ2FNjUi3y(M8D3IkVS$} zqlo^CL2eY!2lCahmf(THKwfgSjsbRt&$3d^Be@$;wBtA(J|^#QKA92=2SAnUzac!<(mj;dy?qO-NM?Uc3f~yP}M5J#QKM-)1Cu@(sK_U}a zs&tJTL;@H?gjM;J-dy_T2S(O(n-9D%na~IqGdt)b81uk+DY*C;8l;uGEv-A_VWne) z5TTtA3QgJcMCcC?#dH+L`U#=}8Y>Edj_KQt|JNY@`yqp9{S)e-P{Mj!Nd;xonGoL2`w(0!$I1q_JA15JZPd^i}&yVzZBQ z6|6AQXd+_pJ)DSYw6E&j3fiCK4GL0hhyHnD{pifnuqelRzk55_b0Rn1`b!YYC;`VE zx&nvLBER@*-g-&FZRV~O@5bBG5zOFs#0ze)st2kb+mc(qWgOZL5SL9Zf#ju}(4(@C zSQ-Gwo3$b0TrGAQdi3I<06z@?9n>Nh-GBq_KE$8-=Nq6@q<6s_Fo9%N&&0lVz;bTH zaXWIMQlc=phjVkkE~kxaR_QSUu5=M9jeB}(ANM&UUP&z5c|}w7bvj7C9^A$yclE=} zHB$;63`^NBM_#}nfrW=?;9|9YDYm{Nr~e6`HVUuLrg1^DY>dSuZk`7 zG*^i6i4$)zso^H<#279^^QR)|Uy59}wE~&o`|)SLg@P-qjvv*iC#H|X%@y%cJu4@l zL-u6}UR5R`t6#N=BftHZr@a0S31n zyrAs@%+97l>tG01`WHnD!-I72-0>$Y$<26HPvG;0f0OSrTV_W$htHv?2>Cq^9Tp{r ztl&6I0YVwU5zmiVt7~+>-H+-$h8c~X^b$`g3GgWjMxVazME@k#?=|y)2uZh=5py)o zSm}$rSJUNDJ7Q!}0RVUsZbiE$i%m;J@TE%2!k zvneI>=Rc~%N4X4mUI>2&3=tEZk-u?!JU%n<`G4P}A&hrgOcCJ@}$xX?u z6e3-?%(fmF#Kb(}<@PgE8qI_w&yF#3T>RX&w|IhCm(H}Q&>U{BNyM~+WrnajH!?QR z9mg85f~YA--vfZGJBG4-CL;j=b&v1fduIK4Wlv%=Ca8n4*uS46I0`gLdv`MzfjQJ^ z-pL?f$zguR#IeS;CfcovUe-6&;T|cPF7WsId?GG2iuRzy$V%@-GYhp`(qin27Z?{v zSY~m$9r!GfEmI8SVU}1=nA<$&8YbXq*T|sJOXw55bm%gD-#a`pHfZYr4IhY z=f=Ky`NmK%`9}BWkpE!osfP~z=>3}J4?`geYvpR8vVW~=HDjQo*+RpK1(<VMi1-wP1MN`0F7{c44{s$(m{#bwSY7wmE^hFW{VnxLHi=n?_y;p zDXjx)z@j$?Y(#=wxT=%Gt#_=#i*;N_YMJw9y78B{Xs}IROs%Tl2p^b4Y-_9BPb3_l z_7#M9c7#q8&rvn$3A~3F!flv2<5iq2(HgM%DX-_Srki2w1^gIZbXpOxft5g@2-(q zU+8#26sSF_uyBRuB#vjW$F^pKJ&j~Fec0DdeN zSL0NB17sR)n4foxeOHQA$w@8dxPJK@jeDq7U)HABeH1 z=zr!w0gzI0{E{eGM`+h);Pan4rs)v%jd>3!Y@N15uaiM}U?<5aPk(DYr5hQJLr8I6 zc&zUbM~WWvlW(DPA2R@c+b=v3Rko+RU0G|nnP{)0Wdm^}UlFtvX)!`SK8Hw~wb;Pi zpntTwwJ^D&50=ZCx-hv|s?4*e%q(=!C>gD@W`T{Z3)ApY(}V!2%cB6;gjle~03obOABIZSJDyvMwVXu?%Bo1+$PSx+318sg}m_ZBhu zO>Y$7QH-ru4nlhpv1))F;lwBL&qm6Fbj#aZU!NV@ndZ_J23-UcIg>WL2n@NALQ$~x z99Y~~&ZWJKTYBzE+7U%){Yx~*renaqsj1I~GAhlhvZs(s%8n`%w>#Uz!i|is9+2yh z#Sz*Owf;A2%}B1#Yl@_Ij+#79C@W0tQZL88^>raG>5+WEe}`1PXg}t13*Ls<^_?c( zt9}$=)6uWKWj3ZDrL2#LfcwU_oC!9wWzlc7&e}|oFLz)$m*Ob02x*a%RqSA6WX-}w8 z+-K_uUpt>V%?TtHPY*R5>Ai%PG8kQW=PA`|vgIPe-rm*ih%O7FUhU6G_zE^0A7oYbs=7^y1peRuAhJ^G2=)teX552TvcAc--db) zpZ58y@!sqyY#>Gnu8IIa);TheZKv~pyB8BtV5EwV|F&sl?JowM`9{9y+M9bTynt=Jv_qv09p_mQ^FUcwP)( z8v|(Uv0>81)k8S~0cAggjTd}$ZU-(HUM0NLozMvmK}N^D5oztPRysg!RD|elyfX`-NC3)a!%D`Ikz%%d$WlHa}h4UO93UcyKqZAQY z73w&SYyZD@_smqV^-%H5cqNz_lq8pyjBS>T6OC+nDY4|eD+G^Da^&_Fd`Z>}sKkIL zap=j3mpvanxvP@_v%w^YzGz!bms(o2noYc5f7Gx2j%!++>Rg;I*=08>{l}d}J)Tq4 zt47@2bY%=+kcyy#+z8!*QS)FzBUZY;GXB_oz-e8}kXHW2O@7>vImV6a48r za^*06*}-Mc9Woz(wj_m>b*3J>(_A)T^$t-vPPfBwai1&1;M#h%7E%Cb(tC%aLzR9+ zU-Yz4X`+`aaE`B=?JmURu{+rtkw@`Me0p6m5A;w{sSBPf57K%crrl<^Mn##A#YULv zr+@WVyB-s6c-9;ppR3H9sVtJJER|`qoV|aZEdLexGmf~BUj@w0OAPp0f66rIWPDPf zNVJ76hV+dt2rl~Px&tU|3-bM245>#Q6Z(ktOAFaXXkeTQ1F9mK>LR(S=1S4F=Abu2 z56)TVeMoY;Ef|xiS&GtZ*UDyngWE}Fu-i8H?Xl^9=ZO37TB*I*R$DG&hT9e8ZbKco z(6RL7d?ETGQ2sMFKowpxfKnAt{sYzGV(e&UQb9X*Ytci-JeK6wNMvgMg(%o|Y6%vy zPZS6r(~3ccw%A>Sn(>}IrHC%_`s|rdtNaQX%1X@f`6`1buOI{wRv{OWXQ=YUm9#(% zKn)rQExx-g+P;!*5f5%kweG5+TR3;VI`&7m4kLcPCMO~J5A+Q1s`VX98eith$rBaA zJzxQPcHN3rDxcnI>~kB~%y0kdGCe_NNI-D@Bv$Kr)_fSq-n`p-$V?N^_@SL@-H9$%I|ra@UEIk|A>Pr9@O-1IY{_ ziHjHZk_L5-XpvZS{q~Dz{RvGzQg{d_(i)UpRQ?^(7lAS}YiWQ`-Twn?Sx7WU#F>A+ zkYwU$(81E|n{#pefFNA%y`)I4Nc4U&h4nUn8h}{=dhB5i4dAnEh{!VotyVm9QuCH? zsW1em49+XFRNMEfnVUn{IKe1Q6n^W7I<2C#n5ow6@vHg)?ZH!pXY-zFjW{dQ6J=%& zcqB!ORu*ODq5cilj=J(Il5btQE%lXlMKA68#s1?&sL=1nsc0l!vK^&SECdzq7Fv9< z>ozZ6=(Rd0*Uj+f0z3aY?>WIcjYfhGN5bXWFm0#sKxBCQuC@th_iwsMAy0w8q}sJO>P-K2a z_22e+p7)rbFB*uPG1*K8YGL>IzYjeC(RJHt(6t14;*g6U)Ha(Pm6cmaLnB8>^WkCi zf=dt)45gH=3Qk;%R`rZH4v&#iw#06!MgYK@Hs7r;!e_HPbqlp7R-NDvDegLVJww5d z{KLJs@%N-k9qH@a!Je>fCFRXdsVvE>YybWQ9xSo9S38X_HqVQ;C%rhkt}|^#!mnQD zsZiA^a&|7YR96^`WGnHlL6au)Lyr}ta*=0GR9-n8|Mau$)Du8;@E}+Hy9Sk;bDBi$ zJ}3t*1NWJ4p(cVmIxt3fDS?MWH=Hob{wKAjykk{S*EWm#Pf080L+-&aSA4o~))NqH zxv5o`%v;*?7+^Ux^FGcZZ5QXUI4Tp~5dn-F(XVMY-?O0+zBx%w z^Ow4fS5u|p_9v|OvV0|y4!A)l1uqg~nhDBaxVH@K=H35srWA(`Vh<;}^xZ!mue7_6 zQaD~F2mi{;?_1q3Cy4%bS%6mAPlm0pN^fzA@lH6%_Sj2&LR1q_V*@PC_7ENTR zyV?<(1-2)6Vj;@SBn@=D{lh);6K^OW*{|Ls5C+ZltZB8AY*PHPEZ;o-1T2rMA^EbG zS*Vy^a{Z|QiHm5KcPSw%BLkLZNw{O3V0pttI;6GI`UkH?SBbw!T^uD>$VH=5Kcpr@xd^y>_1Q6942^mLwCn;X@<9UiwAz&Woed;{sEM@ZC|M z!k*|%8At-#iRGAXkBxr>;y#%07dSiYLS`^)B-6AZ6hE{!ZYP?}>%vx)!M6C^v$h8a zr4fZIv*jM`Xv0;r8ir{DYJT2d8A*DCV=KGERg*oOQ@L&5&*HrayQGB_O*RO`?dPwz z8Fx=#W(6MnaJc;y+<=%5R(d|xK!Y>YPA9a>D@oa2Q(mOeT0q3YUx_fz;tEct4H)0`$R2)AT9R5HN1u;P8 z_IYhy5<@u12t5#U(Aq-|cVN z@4g?VsW1{I=Y4u&qvy)5qx!TErFW10KTNdYb40oGTzmq{nBC!jnNNmhig&J ztANQ<0H9$%y6<;*<(||36NJ4j&LJP*29-#PL6;M=zmvcMy-h4lb(<@v@K!{ggbX@e zstF@mYHWLP;<5)<7Rl|#6UT{p_FLSOwGrgKmw~qBB%MFpTRoZeeR0XF(6k__P;(;L zSasr_6%;6c5D5*O*W_j4d|)5xUZqd{E2U?TEEGgy3M%KxD!LYwFQ&xhq=P9&EVRXS ze&VWFp2CDR?)c(GQ}-9_@4%yQ`;oh|v5Og%G67wc^=F?Sh`DU?WcmE16*8>=nu0EU z&)=t41n=B%Hoekptl0Ncqv>3{wPri^c@liE`*3bSO^)rqJ9YwL;@Qm8vysI1*)hcS zeckhcs}Fp)_q*LMeF&5+(oON;!+bLJEm^?3t#=g=3^tM5r%k1Yyk$hl`f871;vm}V zW<^xV^;CmwxkJ&joLVai4|9gS{_I34u@d0$|lq#A!3)EQ*V(@eY!6yZDJfUVm z%m&!CA6}^kc*nQL6|Aq+@EcU2MGB8$7*B0(JWoL#j*pxOwgMT6#-UW7eYrZ%4MdDv z22l1Z*s+nHL;3kZz&G)GI+_ql%N^um$QHb-UTfI3dOve-``ts|rQ>l^8uI}8{>T0_ zx;e6Rd^s|dkF#&`GagLLN~04*o8$S$UbIz7W{T^7EHxnMSZc6SKWJX#TncC$OiYpg z@Ag^G(}`aJV3`*PeKy3G<$7%_!NNW09l~L!OHbf+J8t5MijqPSN9K=~HDh^Vbz%7a z`eFGJ^_C?B(itB!>pRfkDZW+o@m~(eQrdmFy|K~xpJ+2$@^)^=Z@sdX2e;o8mX@;o z*Dp_9{cJ$pyz(EbLujQXiH@r9^r4oUienyEBw6Zak36;Xl$^UPyItWi>WJT7&0Vsu z!{0d0SMr^NR_)j&|EN<|>kM;nDM&3qyBRJQz2zmbEdyMVFZ39ofiIxGcM7D3p^F}f zHde~X4-(R7^Q);^XJd}_O=#jZungqqUeQ3_=?#GyVDFD{Y{vL|uw16p8Os4$w+I<| z6>z_}WA)AFi@(`azQhffbllZ*X(S7t5imJFd@n*#*t9~Zy4$PfM=Px4pP zFVg$?>qnFgM%prffhET(30d}tSOpIHI-{^G`(68i&YF$i;vcGs8k|YWU1vi_oun7* zl9b}ozy2j59^$1rpf@m;e(e426MxDfIh@mja0OP%DxB2NpWPFx8Y$qxdX_t{7_7`y z@?zl0YAR|$=x%$4CtgsnxSn*5+P!@z>AJe_{+Gw~gg2zh4iTxm3GJi*4YYiI@L?g# zlX2+?jH)Lt(|c`EYn2B-R_b^Ees>#q>|@&+7Adn6e^-2?eu*ZEQ}Cg&=s)D~RRv<# z{jwn79v`EqSwv?X*TW7#4c@v7?w=lbO=vS1`<^claLJmB`1W0=V*1L~SdZ+OZ(;C&9x_8|ZET@I|e_i^Uad+V{I^*bq}6JvKJquZ4pE59>*w|TO# zN6@U7KR*Kd`lX|T<480Za6xgZvWX^Xm$whdDLg;R90tSbWy~3?+Ri4+5 z>$A@!+^b}nv}MBNYHNGx|Grh>2y+(CqZYpRA9WE0MB`7}CLhQJ5-jP-q+Sx8$+c^f z)qg{`v*`k?v09ZibXdKb9)^60YCMbPW$et7U$Cebi>eUdhzB=g)QOSR8 zf0d=&Zl~I5Z)OVF#tmCaypdGbbZMC7@$(*Q(61qWM)HYop3-b*?c{j>$p^kc_T}+= z@5Kt9iH!3EamxI<%|i5^BM`~~Cd15^-Ah!;RT3job;MBwgQLn@uy?bY*O8UA3T*`; z;uO{*naZHx^V~w0T(H4Jgrp;jOJS_Zwv$F=5eEXK1OT>KOsJ4G>4=o0ZyC7-=*Zs=HnRQ*r9?EYp#H zEA8C+Bu$pGcN?!IiCQJP2CdCkEWUkMlJ1}Ud{?7PhJ+{8K=Fs?`7c8ztn?f*j7Ob{ zU4Oa!JJg`Vho(|wb%0BY0g9Kqehk5Ut^qWpCwAN7Etezu8rm8is-8hZrZK9(-Goej-b+ zm#LGUjg7rSXLA{K#PXe<=nX>aldQ1adWFvDvO8L3Nwu!4Y-gJAmMV}b? z-ADFC^QrrTupo5pJ0o!W7crD;~qZ9bO_co~JkK|Fp%qjkQIt zZ?A)DaMcDw<@aWt)*mB4w#KeIzBQwas_}9$ZvQKVD40*mJ5GboRA<}=c0m*g=II}6 z)F`7VKABs?C_V`h5_qu@C~IOOGHlbfibrVCL1AhN61I=JP>4{;r)07?^8S?*aD!Jj3uBv)9-o^Dvzk8+m^oh;Omhn53L;pu zPka>}it_%E_sYcUKTWh5-gVBR^K-~25wyG*e$~Z!cr)SAma2QW9wRj2q`SY5XrYiU zP>Hg_U&jWl>q7r@rdG-xtORH+R;xTzlW6t$BJU%!li zDTT(G4fW6dn`8>Op7yi$c50g+errqHoojiePS-LY{bbnQ*i!Z3E2lFJlwuS% z!;CuRbe@Ln<(`f1_;4|AYJQL*X-ItG`!*|>hWX=W0cv$4zXSb-7t;WJb;Lpj$stef zwfR8IwOUlc-7yQ;6`|da;jbP*@l$kn0%@$vcipsFz??u_s6){9{&wAO>xpx+8&^Z7 zA3ZnwoK+2t}V?j%9Z;{?b90bOnh(#BZ?0y=Q8=2?CJTGxsGFI%$XoIgI>FW+tdo}Lp~mt6-3S3{C~$bEUoGRW_) zG4hZn$CSYQ21($5lNF%U|Hwn6>!nv^G4lb|qXE3`0eR_FQy6fMX*CyI$#fBQ)#epa z&4|R6U&UnxyR-aMz3iz;QZBO-`i~MW|JYlu_?cY~$LsNT2@B&Ekeqo}ZFo=4fX==|0+jmsN@fmopVftJz@jQ>c z1JC#pmQ;Vip{--UED@=J_itr~Oh-G&4^7`d^6AI&m*h)TME8x6{<-{@jIY*nZRR$L z+Yf`%dKnrUyyS7DIy0*#Mbs$T5OAx7aarJv+iW4%A`q9&EZwD@OkUj%!{- zz#GLd^S}OZMIu$f;q)EJhT)3yhD*U6>twZqbg3ON7>ZWyXsiP4!)AGKN3W1vE7Xn< zV?rss#Pk{Wgs`AbU`kr@(}Av+x5%I<%ieq)1|;@W9DhLQc3;3h@;!aeWP6e|nc>l9 z)OfOa+qC*X;Ik<~=AYF?>i0l0vg>7m;YUGE{f`A9Zt%z1JL`WpI~srMwI>DdDF!Ys zg~VK)%~88;x$dgzZ>oN^6QY9#cRACAitBKQkoaa6!XwUN>p$MdeMS5!`uV`9!*1xi z2o>!tP-!7^uK=ZgkL^hjEP^cWc2rjv=ff)`-%znwrnCqjYt8`8e8rbHdKf8WojC6mRG##WWRR?yqzBZ*` z8Kmv~4p&6b82`wdLWf<8cR8Yab|f7R5;8J|%vHtn$RIS4U$1cu({3^Vfw@46oa?A= zpCTlFiLAgR449JI3_?Ws{`q0Q|L1{Ih3{X1`qjs-;D|=G8-7{9cW2b30=L27dz2Er zKT(+Ur^?4Nw3<;!%{)Igor|cWa1}e60PrV-{K_TivJ%|cz1duj65O-x11Te9rmAG7!ZebN@Iq9T; zr5ZwGBFf(gM7PjG7EhPdTJkACOFyg8Av{;htr3dE+eHRz(*y}^CVdAd9^~$0thU*~ zTd@KfXOm_rNJ=6jQt!esECsNa(<|D^r$k7XxjbsvQv?Yh+OIn^3Hctfj5|b|AEb>0 zZH_+;MPdWsT~jM+y^|T6`+!2lng@ZrB`cd;kw+O?V8yN2mJ~UZ*1Kb06O(6qSgV!z&9=={0aIj+sa>j zNcj`o_KDXPzhTd>foGntffH#U&E`Da!16x7D)!*mA-B-7bm82~X@9WlDgSE{@!+;0 z)2bsCklzwm-`sA=H2?ai%lt)qyIz?xB5HF+01dNs9VHeMn&)9ci!CM}!`oxN+T~>h zyt)Z^KBTF2EX6cS!+y-o{_1o!AO{|2?SK6+b#)-;Sd_a=4miqAU=q7c%G>Fj#+Je& zix)O~=R+Gj_1c$zJgC@+Oz`zyc~HNyCT;UGO`skhds}=Z;v@g^7V{?~G5s4V@6FWT z8>@b_0C74^_RSsBs%6%hpl;U+=gIK1MUyMG^5%WU&2YsYA3fBELC%YbEK#%-UEx^x z1f7tKj{yjiF=$mf5U$5F zOCF3PrF%|`8E_lrl_m3m4CijYDYf{5A3o{13BNqU`5DII^pS#1)2MK{)qaKRR_BXM z6;FQ9f_=fXpHH2q^D#()Dbk7dmr~doGHTHPK;Fk$v$E+Xla;^hv;KDpm3H0M7bn?g zlcF!$s~AeJ@5d?8dkb++_0b8&It>wvHS67=Ex{(X-A`@X2BmT7@2}p}WPTF@M$)NO ziPm}Yy>G`7kwF&#iK;6}8qHe}N3PbnIn%QK7{e3z3aQEGF7_M(_ng;)ZR6oh*Y@l7 z{oVTyKG-hd)+%gftIr15gV`yVMB3y<8emIZFY_%v78r>XmWLp~21%_MrRs{HoP4Z< zD5LwiylDIRT6XmGZauiV`RBO))G;qenJs_gYZ+MP{Omc@?O_D?fZ_r4RkK7}5?Ls} z?Ushn9MgI5Yep>(B94%7iLebR2LTBArvzHDE$DIx5{T&x#ku}ReiL+OP|WLAVZ)vp zQV2ypJ|Ia%)pvl14ZtXikRVrXYa z-N;F@5sx!xW)^z?s=1~Aru^PsIQ5^-1QzhDb;VgDh1ltl-#>tUbbP$jl^GHl!0t!u zrHd~J`PgU^K3R%*O=$Oo6b0mc2P!#3-@#j&zuRvHz2+wo(rlrJ-oNoQlVS>21y4rP zym5|pxzcnrZztAw87!7HE*N-;C>gRmX<&n$_3g5EUM49;Qa4}RH1+>$n-$bgd+)8> zO{Z~%@Ye$hk)x%?i<_s-Ooszz=s=}t5N{YZggLq*Kh@p;y*=ra{M3FiI{_i$ zKOI@WfOYM_2A&4Mzfy9I`_X$m)~x)PbG|>hYgH>N#gnXGQF-+S@h3&8gD9r}qj~o3 zF2^hYEodT_MjQT&yRt5VEibE0t)!a7YZ4;hhJ0gpj?GiB?4Ye>L0gO2)cim`1BdSe znBQRiweAP{{US(Ppd}Xd_~mN0uRyFZ{GI5yRdG*&+Un|H&Ao5b#HQ`65JAE@H}i9K zz1Sd4M;nG}FzotSoC}U-Dgl6uSO0U<`gK-T`F&o>Ae{u$eOZ=5+!lQ(_Lpf%I*v?_gK7fNs`S4i}Eq;ll zxNissDg(|BaCpfE?G(Hu?qI@zXx1RdP2-H1Vwr*?AzF>dGCE)HV{79C7p-*@S?KikCG^?%S1g z`^Q)N3>IE1-}eTt4uogi=kI__p#FMJ$tbDAr7)cN9kX@*H;v_Qh>9PU7eYAEuG!KnyM9J9Dj}(|i32~ZN z?)HGkf7a9eiuD9!NZ4Kb>f5E_G_&fBP>5>t75$^zW2lo zFcjMCNAmRPM+8d`L5{C4ei0995EnIE>$*d@PH$5ifAF^sVH_>CmUjINH{KkkPQlc2 zdUu_jxdj}$)-NU9c-&)k;UBR7r)vHmPsN$~V=?Q!Yde_3#lL=MDQ_b12K#UA_%4h} zuhc*HOT9A;H#*Mep>&Ye*3&&GOoHcOz=27n7z&7;El2R?l!rH6-SLp-zF2+-ut5$_Ha>zwM<7Q!6}&8~Nn`va z05Z^Ywp)*TMd7v|xn@HMQwPa%dWAZiz>LqlqG|OrhO(gf3vn0RwPjCPkZWURz0n5V zTl(j|L?W;$a(?=Q`t9NW_C~^p&qAaLuq!YO<<)p0&i@vsY(04n5nzO@ux^ML5^=W3 zy!&(|pH}Vli}Ft@$$l8hpX(bX@lObSZ+vT)`>o z30(R~86s#7zJRYNFSqzHHI$Zoc?7|UA9m#O#7OD0anJn-qU7VZJI>QrB%wrFye}76 z*Eb;l3GraiQRDA&t-cs{i~co>S{cC8uwVXpm?3_t7Jt)+-qPQO$kO6esQIetszu%P zJ2SY9U*KE!OU~Q@Taao385=MFgNjsTM4oYZ;lx;!yJkZBd=SCaedE?{%lOqo$YLl` zNV91qsjXhShd%Z|uA|3Fk7iPZBP>f3Jqlg#&_i)gQzCk~Q(6|sC7=pPvH;-om3EaP zIhEw?T~aw3w==N3CW^61!8RDH9=IB9%<~Vp(&Hp!al+r{*?2S5@L7AWXQ}@MoVjD( zf{Mh`#>1WZzty>*=tK|pzU7UJd}VRnc%z;}Hpf5~;^_F~58>i(YaEMofxeLK#&DeY zQc>#Aq(R3gNvHka(|?tBThLQUy6`u`Le1ml#J8+RCvx~)(c023wdrXu(UQvXa!Mh$ zm`7O(UE1j`x}5MOW(a7z?AMw<*A)i5fe!K4h~(}OT%_4p-+iK%dc`k#DsgXgoQG4mH)SoI{)}%#>mW3I>&R`e`1BCnV>6x608hYS5z)4^j@;NY~5VE%%{m z5jBx?b7 zqhgblkOA*Gg%_aue2WvGYwTCX64W>mZ@1JpJ=>l7baisRn?~>POUHA~oKF1qb=)Bd zT%Pi=Ir;U#V0*ozSM){4Dy7r@>~0{7iPfQHme1UIkJnvkYil?7W%vvw9Qv}Rjx#<3 z0d7$M7kSJj-C7gsx*~L8|E$$rQYrfZE=#deNWz!)mv;3#aZso;fn9!>sb4;h=E^!WAY`Sul%t<7%P}Sw!%hlgYN5H@rwww zdJ3@DlwpiE1$sB}BIDQR&&>?Ub%* z^{%j-g#02KjLD=4Jg5&TjY55AOXF>zl*8aGW9hU!Vhi9&3YS7T0s9Pr%Rwf#T{R#1 zy99zG6TJfN)4 z)-u>XPBU71wjN#9$%ouG$?*L(1gb$BE1$~isH#p;&hUgNZYH%MN{y8gE_Rzp-^M5X zX3B|6)y<6g(ULizx(4wYmC_+bLP2n8v@to|KoU)eWWh07BWEU$maRdBm-JwB|{_aYK(xi_A#vj)&hA?wJI_|{YR^A(dnH`6U+ z#j|gMv4Oeg=@3%Ct>2#-+~WZrB&X4!j}(iu5Q$sjy&1QAd4aXvIA2>RSGw?Fo~gPX zSxNWE1rX1bwTXu!R8Xt6Q9T4!5l3{Y1C#hf3hGwT ztz_uS7}$ZU<-TYSeb?HXp82w)@wiJkgfrObO-P{}5VVTSK06=Gcifdq^Kn(?%x%X8 zpJvt{z4|Y?@5vz8Xy5sMQt{m9{qbAY2t_b6apsR;{^BSF53?%=`2xpAp9V`#M+b6v7}DWXhd+!%wXOC>gUP*{yJ!<8G%_$UI9nlzZEgvxYF* zr~?HFPL5bW5y~wL+{G2=jJ$F7p{a4n--JH73Doph(f@-K^&l#~jBMfvId3LDNax}Z zx5{-sr5hkp$c-T$FoDhM0}dCp7*JqdVc9x(VnSm?;y&aTw|8oFA^0Ijj98g@;kfRr zZJq>=>ms-zZvWCR!n*g3v^%&os4GYDyF0!nRqP@@GQ;=CxA9<#&Bug~EqGgd<~W*C5EBTvp}ps z%A6TvcfDWkDPEn{5pn|kEMRnTDPd}mQ%#5*yP;ju?i!9>qj?R*K(%a>Ca>J5EoJ4= zDZ6!%sA0+R^vQ%UE-}?iZ9UXzP{nKbJd>Ew$HgeC*@QSImsWWZIrhol{c4q^Ealh= z#`$jq|G;fK_V%#y4`XioMDsG}nCn>NSNLlRP14owx36k{IdYGxE5#orhoviC zz0-hm`MOuytmkqccf*JiXVTa$Hf~?MZe)cIZz`!+eIPQd=q-13>C63rCe@PJre7!B z_j!xqTX5@&uf}byH$#2pA73;NJG}0X;P`|>=dr&prR0P6Hn zW360Zvjg>C!_g%&@Q=>!n=2=o-lXo-hKR_=A#`wuG?MqfoKoZ`^}0S?&RRUsWWMVK8-N zjq{p!#P4Pe<-dt#X1PB6*-`eelu`%=O$LMPXs_Tu5Hx(y!@mj0fCa4(0w#P1ag{?E zb829G;u^YauXY7k-YH65e}K-CicyH0xoA<7BW?xYSvsAd&tVDL^!U9A;w3PDH;H3` zpF|^p5{nnTGdN}6%EO7JaE{(xlS>LN`3%L7FaF z|6M!F-njj}+Wn_JM0-IUjSK5(PGYDgA&VHJn;lX2k@R>)hyiMBWWRAOPUa{+_mX@O z8|Q6#dCY*z`ib~p{Rz=06ZF10cQ{!(kvC`5cRGbTG8d1evwZ*Apspm^*{SvsfbS2+ zvsbUz8}-qh9i)p2wVI%8T_6H><%bxteUP_@Zo*gfU|Gpg1oCp}CM;DI+^N0BTFK57 zJJb^`5A?4*3c7bOp?r7kT=mzg9FGrrb5kG)t1V@lqsskN`Nj@7JJklv@n&t?eQ0k! z(&S!8syu>Y@f_#UaVm;ZF0_#hu>E0qbB0l0t0G6x6VA4~3blD*nPAd>kj&AGd$L!1 zJT_CuMUAT&tf;BMugXdHk69aw_N316-!e9$NXdFF#=CdqKBAvsw_J6Vt$ni=q;*&Y z9LGwHOlLP=ahg>H-YL59H?t@qqLy-*-4)U$>C$};GH$QTNz}a6=gN_(`iefZy}345 zZ|tv2#;5hYwEqEw*0%(_S!Q!jTHZ~yh(0t!2UeI@lbdpSGJdLDdjGe@do4Nlg8O{` zZ>Zn*sQi3IftNMJgQ*WyGhRuG1koo?h^D#Jk44gbc6={D*B*HO!hR(K_g%u7m3tg? zI8@e_-?-%jC!#3rZ+@ekIs-?1sJ89fU*|W^sf)yB?ET;>D-iHJUH}Or2HusGe#+ z5>IliuJU5fUOs%H-bFQ|Skmo+*kqsbSXKyv2wW2G%_RUGwAvH3VZYykY(U!nH~Qav z=N%zsGe;Y)W>LBF->ULHf4N)#QM@!5+S_gkX@p60blH8_fvW~k+^Yz(Ak;Sy$-5C5 zoNqV*qT0FS%j8eoB6o|@?SDTCcFVEge2=rndBsS0$>?$kE;3SlUAi{fcS3_KOqmX! z)+Zk);jK;WG%Apkww%DX0zgs}UO5|$SN~+(*0<=*Q3acKWHHqr%J3wQmvvAm+?#8^ zy>5>e<-j=1p_Nsvkdf+%ObM@;J#s>4h>%VMY`Cl4oiSDJzG#o-u+MUrmOpLC?Hy|K zhy8fR+W9AsB>stOre1vR;3d{kJx>ttBa8Yzk*F_TI4Q`u3FIjP$|EEGWq|)yVT*?V zE1;eWGA5R?TdNXh@GI^&Y2|r-lhwPVh+!cQTZf!c-rZ&n13X&^PWo{B3GvYRa_-bs zH)l-C?W4C6va5BK4)uR#Yj3GDD(j!yJr7o1((LH|_|1y9bfl$WDYyzVno6T;kcADi zx18tFdE754f145=jw;E?EZY04Zs`C{Te{G<$zN(A2T+ui-@qiS@OBC29kIUr^1d6< zr!LLrA`v9AE#g)TKiguYIl8l9) znG0zX)Xg6luVmR=w^FS}TVNQSrifV^a^4%1$Z=G@W6i}eD!8(?;SMPt`SfdJF_9RC z!B5tC=3U+E^!M+Vj5~;r$Ju;#j1m~`@Qw3pjq|+SqC#yT6sQz)EbW%Gxoh>U1tRk8 z@U@KNMSOFrE0hDonEJQEp0)lKrOVTbt~?RAk8J9b)q>{|80&81A?Y5<^6=+-DX>6RgHuLC&UsQYTT83#(FB0Uj@-bdr{H}?#`8VCRS!ptTq8zrfp zkgSDpt;rR`g7AX828SCjaI}WJWX!~fFJb+gzfp6&0`lk-O*gl_(!$B;C_`IeI+ONH z)aV1Z{$YF1HG^jwX)Me$@N}276U#VLrP#E^l3P>B{25s$-Uqj|4#=sE3hM?V-HuQ2 zSE;5mo%<&bxPX(JSf0aklGHM^?$wS@4inbvLB0lg5hn6|tN`_sk&--JbBRqhf6Dk3 zPm4C<7a7(kpDK<0ujVYR2yRbxZa-uqd_+5WyWy>Is$9y(ZO$ZW?<4+8eW*fx2eAwX zZ|l!5q67xdt{_6Uv8l_=gMyu9MbR+-W%=$28|#1W)dnLX}2$J*q+Li^~jsO^qNf+Cv(zh+|Ov+2mup7UsJ!gn%e|<#KdieWR4HmX4 zk+rVysK54Hz>abOFQ@ln^0EAf-uQ$5|FZx_Z8t@hmXad!xWjh*{7mmMMj;u^D~kx0 zacxHVH=get;`S-S#B(nPXMb3+pR-GbRlR)2E}cyo6YSM0({3d`DI|mh6>i0rl(exP z`#D~_Z97K!j)SCA6&fqP+x0rY2nZ`kg4Vx}69h>j(zb)>6+0pgzrBRNe;A>UrhEjq`caI9FX7JjvacZ|p#Uy0-wn7Q?AS`E zqKA*7(Krl^I7{m5)s32_#%r(GZ$c_*m`Tpk85N zcQe2BM{N##CXhz(vC)G)rYeB)|{TUPV9+HsArBB1*Pars-^ zAZUy3M>A%jNZ6#40XY?g)pk;kalI|fWM8~DPTShAIM}d-s}tlKC(A@;=dxHw!xV6- zfciJ{gDv})a++KttF@nncL0CKp%r0;Fkl4=Sovw54y2?FeWt9!Dbe#eu80%AF0x@BOvU5IC4g4Vw_mk(*I;IzV2-1MC!yyFu=>;(e)CK)Vywnt27 zX@9HC;(j9aXcNanIUFuo$M`wAzQR8D-_-Sl^C_3kAeIHETw}_C<>y*Vasx%aZhaLF zvXvxAx@PjkcZ+3Hq3;L-55VDySJ34!4Nf47csudR=&@ojQfOO;88HAf_T~x$bt6l! zZGmC#+gy+N4pZ<}9{Z{KAkdp_+N6!dxT+<*az*_(>k`$ocZJ={Pmw0O41 zez-J3^GoxOsf)y!q*xFl355V&7l43mf5d*g`@0dy;$Q@@Ajkhx(- zmN4uBFPiaPZ@UzFhT5_rFA&YVbn8vupCtHw4*8qZ0i?r@OduVi*RYLMD`RtoWS1UY zVeD$U-vHjD{*B*x(P%>YwDavvJb{W+PzOpwsCVfYJ0<9NV_?ncxhMneXenEQF(WLt z<8j*_Y#d@a;jd2>WjD8VI(cr-3yrI-rR-R0|Et*5lg^!Q3VBr^_>HLdyKXqEQhu8Q zv!UFofU|i!p+YmJr188@Vf>f&WbI6ErjOSrrO`+FdnAGmfhVwuD&bv+zJk-7XESYsH*q))!*dR#y}!XLXYop6!eF_j_MHMLJgP~tpT|5v68RQDfOgc|v5+UrWYGPE2od2OqCqaq z2EBnmPMi){F}fWg8VV$C`9%?p?Qe6a@FnLi{#cgNc62=Y=Lta=T&;0~%kBl6+FXyZ z1X2t6jffs?>)bpvtT2w-PVa>=-|~{X?>>}R`}6v%nv3lNL;2OzZ*Osz*nLJ0cedUP z8V9&2P;lkh+P=J9?)kGa9aA?hB#K>cRc91ax4H6jkWH_l1wIz=`PF!$iImah@}Q@M z&G1A|=w?$I^nU7$YFpWjwMyMGJ6C^~6Jm3i{dY8SSAUH&ERhJ1oNF^t6c&r$Q{L_8_;IW{+P8!mwy>G| zU6hvNXz6V2vDn*At2!IB$=R3F~Fk>aR>hUfqs0T3i;(4tsv^WU><@B zDbOcM>SY35=%3U1nWYd65tY?oaV*3bK^RgRG8%L)>%4@e!x#9b*pbw;yqqQ}9lM?W z9v|cg!oN9A&iQa??g3IG+)bNn!BhAAV@*1U4Y2Bb1I_!kAbBaOwlwY%J^(nKYQo_b zj9OQ~GXAfHdx+1T{xZ#(rzP~_v6z+($!?@*J4#3du$CddTgx7Gb^9+d&>?oe=e5Q8 z-J3IuAnIr)q2BdV^4_?p4b9D0H~b6>wVp(R*ni<4oI)XU0rzoNBHG_u?!)UhGs!2QFLXFb~~DiTP_86HSR=s54;%uFthPxuwfM|xNjni z_5FEKsFFXg2KB}|Q!k%fO^L629yQ2q-;J{wP5X6Zr{xZJ`WgoByOrAPmwKF3{9z5h z`uh_tq2_pGtRRPh6t$#0O7xaPR0et5-6;61cwrb0x23{KYxM* zSeQG1_e3Xn#zj6*Al4mShQ-U{83pdX2IKEB=o9&;!-epuLkRRh_+z*c()zsmUw#C! za9CzM$Xis%7Q9H?B-$EuSI3=i^eG&Zsh`&Rk``T}X6}pa304`Gi0n%=x-y@FTC@-*xnszxH{SM6k3i`w%Wrl_4 zLEGCiDr!RV-Dy{R(|UrnwY7^)1Xkca4-ZZFow5{SWjs7%G1;(t(eD%OrQ)=QE&c2a zLy-ddXgs$O_ufM7K7*xZU@(>VKGa3qR6mrcC`Hl9Vtqzpl7vKyfW|EF6|;ZeCFlua z?+#}N5AGH>ex?GnKYsMpV)B zykz2MLsbjImx_}HIW88?VKRiF2WM?GO5awi2A;_K*Y@EUTn0I8pL5Eeb1IyOOzfvdYO@GD`u)+J&n!Lg;Q=!NwOdSH$4Tj= z88y;x{Xl(VbT*7ZcDW-krFWEokl-JYSLXfvD@C|3?=MghN5>9$VfE0XP8ue7HG+o8 z8u!&q?Iy-o^e9uwg^ePxOJh#o35ZJ#g>i2A|593=14KQ;+QW}fH1>s<>0Owxz76iQ zAFm#}VyV>L6AIV568$y|g}6MnFWqRHeDtI7tyX%w;>|K=W+P#9p_kBi=OS%HNOip9|q^i?LX$>B!zD5j$Us=D~T6Gf)jo;_q*vhnF&#JfvJ;JO$IDO~q1a);8%ZkKEMv@Ra3`$9hq_f_+IZ~u z&q!Fe($elw`*SwqI8~2q{#|0;oQMv0Sq+G$aSEsxH6A!QoLGJJY-v{LGp^8efAV5A zSK4X3j=;u>=lV;q)%b0WWIK!2d5CB5VR%VmC1v4mIm%Kx%xRHjLQab>Jo8X(xJdW?l<}4TE|a?bUY5< zWqw~9!OW{2DE19EjO@RD;io?O2I}$LywlxMqVp^qhymq}x=K1z00!Y!$x@V(c`#xg zvZa9U`PeCY-eIbv11Qq(dRhC{tIJf7ZaIvx111d%KV0^2cmM_ zpv=gUFtoUj`|s!n*w`gt>&8%gd@nSX0PCT^R9y>&Gd2jy%&Z1{(Qrn&%3QrNC0Q|N~;#%KioB3DPu*%RDWUa zBNK^4EIis z@1^%&0!CpKy$^nsQ7fQCh$Jq6%-Lxok-Y*Y*_27#syQ1hyr2$TZv@}$BKMXw=bdn^ zH_x%a+s=@8U`wgNtwB8D6Fi5%MZuNH^s|pR;S`BMyq5Vz3UroLA{ILq%pj(oXCF1m zgTbVRY_Z`;zSe3Dw*aqpJj&;k$YN|yP|m%yxodrV**>G&HH&JOdB!>!_81*4TrH4z zR3b|Y=U0+B7^QxHce@IQB;K~QUi5}rJl17~f7_vv3_OuucsC>Gvvnj%YR&|^8rb#F zEZ?$lyleU9+&5OCvB&nHL1^FIl6&TQtL=fSe0$Atn|$ zkEV!6@EKN^gbUDFYQbPbdLgf7UQLv(w|zej1HHA2_a$@^vKjGhjXdPC;w=t)e>UIO zCDwR{rH7b02$^Yf-mN{NDq{C16VI9vF47)I8T=P+N4&m%x!z>P`QcYODs3-bOLp3< zjz7X!!(^zruVYe5sspdMk9du|VdA-yZygfC%3KI%VG>xQ*g2ww`?^oP~D@-Vvi#f;Hd z`h7**p+V9Ue0{H68E!i=3KFKoryc5_r}g<1x(Os>qCJZ=CzVu&1X%DtP<^4!K8UAu z^SW}hhKlL4gz|-XB!Tskvo4oW?IW~TWl(yOT+m7Nn z`_@JS*pj$=X1lqi)kDMvTfbv_KDSfr(dQdh7EERJNVH)Ma03E;whd+d)};4jgrj5* z=9QC9&Ef|k_UNkDck^s+{(8VuYreNCG<+O&QF{eUS__h^&aXfF_@;$lX0$?qVb`c? z|Ch4Q;b9xIPT)W?!979M6f8=%@2KD&1j43NPB$n;*Ld()E=9=^C?mI~A>NYv1UnB! znup8Vpk{~bzkC5bp8LTzaQO)JBcGlGT4L>EXBqdR^&HhTq>4>>+|iPy$1Q z;Fw>dFep%>%F}xqbdi{(|q{ zN9ZbsNmoTj7OYzo&fzEjYO*AU0FY>E{QL{{-lKt33}GCbREVd-X@djXYA z%W1d(=9hTscf0dF=4vJ<2X=F=h2VRPTnCL&!?%2{2-J|e9)6t4Ys;7?_9aI%h;xpc z9kQGVu|Z*RSY*AKtL&&hKe}Ayj#COLn9%GrmJ9}i1&92`&EGk913QFGrgS&udl9 zrZO2L1qR(Vo;Iu*2>D1C8&&q4V(%Zc9Lk#opj0m^m;AERcuQ&TRFP39*fAFuvpNio zu-r$&zDX65=UI$29ovm-aqobJ@plfC%1N(vOD?;MRLJyI|+3Q?@d;PuqUi# zxnHs;fpq7kh-S!!7^ksUM5&ulE8u5Fn^6mRmqR6(yv8 z#V5v>%)#zB!{HZlKtl?MIK(gc%u+tFBv&kY&xyI{!;Q>n3u$P_>;p(i?J);&*rN$} z`4r=ZSvq^0WsU{2zTOvqp%9=pH)vDV2N+x~b0tx(7N#$hi8pGlue1*$ z8ocoIE1T_0GbcnF!-2+tX%8!Q!RT2TP^}|qTN7JD% z6D6m7%!$wiW2Y1QS<<(oXXJZ6{=BqbH#r-j_2JI22}7!seij5H1;}K!IMM1(?bc=3PH?hS_%`^M8u8xE9h2G zJ@Bv5z;;jzH$C^D?%y2w>4_@w6uzjwepJ&(Qsf*?HK2$avDfz%KKT1#r!f6;zqjt~ zfjepJ;dM}m=lq2~oXW@<_(uYktn~oZtu!2i((s7}u9;j$z~c?+W?$lKfMvFb`^9e8 zf6*)M@qga$XHyoW6CL#k1<|ldyy@ut1x}0bD!~rF_;Y=zhT-oTje_UtqFsZ5YWA>1D*`h&cnpH0 z0hg7CK0SO9qZ72p1>xXOvU$fi5nEh(rt|bSC$RS5%XR3JE3!_2ff;>Rmx+UR+9?^| zJCM6}b4gTn$+d8H=8TiLG}h^*zNhdV_ZjWM----BMcGBbK%d`X7dS zi0}pGE*>htpdB|A6Vu0yzBrvJ-XWpm>5}^<{kKi<@_pNl?TH?@Pw|%pn91#`<;Lsa zKuBg^1#-8Ip13(3j2VLI)Tzm4U-%(;8FK^(h7e%!`S>}IhaX88J@M#h8^An=gN>voS> zq-pWJE$N#^7b2$=;^@?>POoo}mUsJ|IE;)i$1{>_UT zZT;kfRxwPxL3Ff$FGG%e_GmjXWsFCPmlUdVAf|m|yU9G|qmsa^(}}ghw^qMeW!4wl zm|Y#3S0xPTy&+mb-NK|i&zpk*pBN07SBs_U(IBYH_uoeQ{53;LU19xh?^+Sj(8s1R zLT__uN9B_{YFYnkymsf?)T{OsPOfn%)0HVAq;l7Yi^DuNZOUz2m1zZ+3BfjZAD5U^ z;$V-yF?b~FGxYyi0QOM4xA>M0-|>lYy(otUnI}mqUk9ynekJF)QDV;y6{70oLU9#w zQQ;~QxKE)luCFSNtYCs`B<^p7Jiy5n3e1{y@frBW5fuE+r$t6M>f@65(Vkk@Al7L? zMos15e0M0OQ0j`>{5Hy>&lU5pJYiGneu>>!BJ*uq zI+mBf8F$EhDWpzQe8t80-Nz+_R5%RBA!ZR15|uxPy$@7s|4ws|J{QRJ5i*arXs6A{ zy?-NxLMY(n1yyxl(5V$H?>oBbPEWt{Pvx{%<8izmeKHR|#joW}xLN>1f&znii9m7> zhVDA>X2Ie$jYu4Uj=%l~$Eu#UVe=nG>RAtQa0B|ZNfEiN%stwp{`~EraVs63)DYwq zLx2Dv*>~|APsUp=tj~G=L*$OhIh^Kt(r;r*JKB_GksY1 zYw|Ze{*Uvis&4<=CDSn}KjQtuh&n5@wi06*CivAwzJkptEpgciF{^N{F7mI@l>n~8 z#R**4e$~E*W|`EGe|+nQqde)Bdq=W9%Qw*Lj@}r_D(FZ%;4r(`*G4OWn{7l^kc=Ls z-}GNh{xobhA_(*#%Sq8fN^E^;r4|2uB36$QNo0K-%=|G0F(q4p_VFLlysIO(#b+)q*p^`}bTjvFLE|>;WF98%<>pa=PSL4iLdwqET(9+<|~F z?mP9ojq!{NM%;XovEDASvm~6cDaGY!rzV||Kw#+-r`^GW(Mf^Bvt&8e#kpf{&|M+K1BH_i-^VU_WT_V5eOZ1kO)*fy6h?0Gy7n{e#mrKHqoNgiVuzNKd0rokQT6Yzs&TH!`6L;?dw7*8hlXx=22GU+!KbMbf=FqG0@7kC7 zX4ms?6nIUd=sLFUWd0D0$Hdh-GkF- zAjR}k5RzZ+Ep+C(B!?YScp8*=HG^P$s#fcoeUULp9u`KB0BfGU2;z=)znRKyW3|tH z%lKQY=hO=?TT(H}&brLPqP4xvKu?5T%{u4SuQjUoRIKeSO7+PLg5;?w+~3?}p$22l z?MV8xR;Fsf;KRprqe+A#0Wf2pgppI3`)vlqqZ-KDS<#1cmvw)=GQ+)M+qRi-vju}+FjHbhVdR>=rZK!X_+`Q4?G!vNdwE)u_j^`Cj`DEJPQq_qcPE;4 zWw=h$ocu>2I}h%B6EepILBZdqtGN>o()Bsiz95)c1qBZ^TQ31s>EXDu^5D&agSx*R zd%@R7StW8bt^pX=;1e?~fr;%8ez!vpF7bx^iy1Gi{1Q18F%dXNvuoksH&!1jJGgM+ zFMr&fEhA0btCVNjHR%)z+tvU-Ji7-QVb}l_>iSzm(&_7A$ss7nKCJSx4l0y&iB!#Hq*Ibcv z6Bq4+Q4H~9x@H+dYc-(bhIgD0RnPj!r@J%D#1>IpkK>k;GzDn})rjtfmB8VxhN_h& zI4sto!A5L8gv3D;ld#Em=h*_fs`beC;>5d^J^M=+4ln8C1_(dN^Su-_X7#e~f!Fk^ z`|`rKHAUl^@8O&Lwg>rrk_YmBd-lN=v!j)wBN4Q7d@8K7htYNIzK@qVP;l(JeR7jm0g*!Ozx?!F>ho%0so;xQ3sN1pvTB>n-}7EXv(Julkn5HoLeoVqhRy zvphA+40#y_CI#l-T+5TWIpZ|>dm@K53RNpcVxJ0v_bU+mGWF!DM7G5WtvAJA&Wv&$ zWA~N+WcBjg?u=HyJ+b3Bwb&7oboi9n7XsLPY?z%vCqQgCo z78kjLSziU(){(|O{c+~;^rG%kZ~Z*1<{EbATI)wj2;k2DE`h$QiTQ+KF|C! z-<;Zb2WYNT%)gptgB^uaa}w)D{IFc_w#XIfU;z?d^Q92@Xk(}AW81|mz3Q( z8RBL+fo#Ze!KeJMV(rvU5|wbsD7LGQM)<$52V`xP+&$Cb;pJZ!8Q%yc@pnAsCLxf_ zQOH)+?}vRPIDdf*!3DgeH57JbyEJ3q8G8oQobzlHOlws80;GH<({B8fcT-l>jt{ph2|hUu=7r?9cE%(UZW~J{O5*d9cc5vhW?Zj z!Qt(MCygqNUFK6UQP-5BNJO zVau5}eFR;Mq6zc3cs@&b^UpWV6xUgIVKuZ7F?s)vW2F-}>JeAD5bV+tN>}iBfcQ#P zXja8kc^LDNpGXP%-R=;8s{Dt`k5)J3@oI?}qqKo8l9T;dR zKonyh!pH1E|32bI#Kd)7OZ3+XphkVp>q6(#Zw-sv4fI(PjxzzTIK)}{zs5YQ!kG~w z?kTGTRJ*&(!<{X&yFJTvXG8}R;rI1F$_6)LIt2C}b15SGZr)^X(UUq`ay*LS8^w1J zp^7_0>7d|byMfY1FD5dzYPAY@&NkP4zxnB{<;OWxq|FYSPWrQt1fyZjLKPfIMv8E_ z5fvi16F68i6xH0(0G4!8KQ!eM(3iBA1_}}jJ16fU+PI%bOcO~g=K=4t_pO;LGg&Qb z$#)v;GjOV&WYl99^H9vTwU;zIPIBw9dxPXvs(hx}`rrFhEuswu8Op@*j3*T(0e>M^&J}6I{Wxa0N#XqpZ-q;PV7Hp-?H_$kJ`$wylaFm&`!SHp zO+DH=qtZY)S#c(8lM4E;%Q;d~!{J}FN!JbACy~?4tQ+~lHSds*>Yuy~?n?NwiyJeC z!F35gSo$y**MI^J{g=Ap*kvqf!CaHCamm1tzx4Ut^%rrH>OE|reab)kl&jCf!9%TY z{?;&WV*W-X*4vG-%-jFCOxWQqEGNAL>IQxd2mc;=FqK}9vNxQi@IzErb+I%MY}W!N zS3n2PtHpLdgUOGwGl!V@NJMjTOC-#YxZ^RV<(@>;6%nq$R)vIJjOE^v6bOGz_V=RZ zdGJgf{orvCf<`M=g4uw&uQ4VDYkn6OW_>qS|y6M4ZSJOLq z5-R^RiR;o}%}ZZDte7F!1V&L4Fa3`iC&Vo++VG_yf{n}IZuiF`fdxMr%&Y$EInb)& zv_{8_fpoA;2tk5&m?_Ie6i$HuFQQwWFAILIe9;#z#NsRSL!B_7+vziJ~aPRAf`4@!a>xNuMM2rPbl~18<^JS?pByLvAMI^IG5e= zGCyDmSgrQo!iH?-$}kUq3Rz<$C`-v@MVCY|AS+|oQQ(k8ASC7FXX#Jx#lg0GeelPh zGo)n2u4y`1^ba2WlRqr&*3V#qCTuoO-IkF|Y9V9t#{}0MM|A!*NBDkdcA~RBhT)%A z|Nacmrm{2!QM`MbUjBEJj3hYhO6XIM#uy;MEYTN?dVo_qaE_3bCn910d7q|DT?smH z^hRRVnsPOuM<3!D$NiM1ubL24z}G=ZfNMh`&X^9Bi=HVK>N4nl!n2H!NFSxK4u0&N z!N;fBC%pn#w4h%g7jaOAS^C7aw;W%|-spavld1m=KDqJRTKS#a?&;?bEFr&|u!ldT z;^o-eF9%XXJ>$~niqpop)D!LgwjyBSpV6G*rD_bg=C7Bu%gy1vRH$N@UOj$^i&-qr z82?8tS7spkH>Ro8#TWagSX9qR!}rg?Bq?7kPq*2M|JcWEjczh%RdGK`~jB1;E3=V2*5%r+?&C2 zY5m2*T{fLM6a1TAH#sU*wr?LT`vI3BR-hJPABh@|I>}%%{7L8n-3o|t6$>LYO6l{9 z_uMqlqbs=o|hXe_ze!HWn^@(IK#xNUjApU8LGE&d(xvE zQ_FCTPC53ay&=s9v{Tabq8N#F1&|uj&pYKbW~Bcm+E7wS3M3vdsw%st;5C0NVxTp4 z$afB(%Q@WKh^4S@PgL z6Sm};{Zoy&l3TrEsT40}ed=sd3yw&lVUzN}msr4gAO-2b%FkbeFO13=RB#*UV86iJ z4!=HkXg_{>*DeBVj)_WLnbYyVYe%&ZE%3%s?v;+s8__I+YzHYdan=sAz9+jzc;sI5 zOvb?PTwJ~|lKKt;Xk?nY zegS$kd!Kf6>DZyM@aT#2B<`8^wzZ%(*DVeMI~-ked4~6Ddt`n~JeNeCGf22^+Y+Cc zAyyiFUlOaq!(4~nK}!@F=|FmRz?BJ^f`uB&yH$Jo)h@)fnx9zLW+<1+GG(8^Sja*t zkDcKWe%!cK5bbulrT42d%rCzxqk{NDC$-e(6Hx}z z4^MeJzL1tqm0iq6C;-U9>O*;y*`|QSySSF3F+&Ja+UWkrvR>M3$u1$yRz0@PBC%ps!7~`Y^ohKH<~<66Pug?sZ>7s zwJ!;4MU(BBx&)`zH~xG0FRw#fxHM&ncLI$|sJjNXF7GXUA5-cA`aHGcS6_pQx(j)! z153*3<(fOkbE-~e4@>+lR;SAkT96c$t@(iO0v#nk-iVC&tA zf-gsxl6mrG0iR=V)K#4(2hPTp){xZPyvzhNkio*$CaR`lo zg*2}6h-E42`C{#Eoz}E;-H;3fn#W~B4FHhgO(XaAVPj1DeDAq@ArmRKaO15p^Qn2E zPWS3bK(?`kb;Lqd$fsUMcL|f3Q+x}3{W=P%Tf`2f<80$#2*}+*j zSaKVEo_73|ZaJ<9Oa|{uU?*Jeul5|}H56d~DaNWMTDAOJQ>bTl7V=zBO?3x&NkdJX zoKSR^GmpK`!F$LAbbzmjQzu?mzwI)?p_=7#a zUqvMCqW5CLqZtkf2>H!Y;k@bJ;USQHH9M}qsJku`*vLay9|CZSXlMLn<;|z zshS3E2PZMPo4k+wMM;$@OAxG~2D=kt>Ke zh%jaDa;A_pmM6^P^vlo6aV|N;KI$Pze}9UbNpiOXo$VOQ`TfrPtC=@nJtb&*=D+d?iV3o@KWw~aN0DG+{9c;ccz88hVK|eahl*OP z4B&U4(0zFN$rbgk?5Q3M!Cc0yX%?PV;^E4&_F^A}VV=E7=AzGpKnVJL*lyeRD!=-W z^+i>%-OWq*%IRC}>`w{!cmH6&%=#ut=hJMg&Tytf%$h{D zSYtp@^eJIp=-kfxnXIvoJ2%8Gbh4n2)Ko|)!C5TQ!J_9+mZiH9h9S3&cag@|a89xj zM1mjzSjsEhuROw!L*+v(xytTOpxkXGzB_cSeL6>u8GXc(lJ@{E+rydnQN%#LrE({l z>e%@vFd-wU1xk;YtvIGA+ajc_Dx$D@7Sl4mPD~KieIfEIagEW5k~>CB2bM^ z%2L`50K|-5rw?brS*tQ?E9~SyH6GsF>JY7kba?Yxb_2M2A7yS-1c7jy$@ePX&Z)_c zjgLm$-*X*P1-8AvnevzEtBvm7qSiD6Iam%QQJ!5MJlqM?#yY;qxO`%sQ;Y6YO zWfw*}VS)k=`#)ugbLN@_EdC(&pn}sp>HyV-U5q|HGZb2nG2VB5#n^fC$6lp)%v$^r z^`$nTje5hDWR4v@x>yS}z1DtTOo|GA5O)}S)AN48ssM2XCU;#fF&ue|I+f zu1Iug;##oKGDpff_7&aku0{ivuDsixzBuP{AID0RKP zS(4VolM0{YCw4lD>$B)Kd;?J@QDAu#y0xKtMDCMUSt3PH6osOv{EByuz*YjW-A?KzClK zrVCtA;i*SD4-6)E!9zhF7TrSX&CZRM+JOcqizD%%fU)}^L+|m2@ppAgyIBY|upwK; zVMFg*{fJks4k(|eS-atW5-V(LMy;0HbsSu_AnaH67e3+~NcFsndZ0FIsw^xf7dHG# zk};HJN|-kPjn%_{e<-z~f})~PEAH(C2|e5dwZ`1B%pkBS5-F*g`R4_g&hsl&QnbNrE=Uq7?GK~xqNb)x< zLTzh46cT%BZ15(}eDRp{(FvbDxsSxd*NvWbn862n6jmFD4OEIES1*DBwu}NFlEj@B zf$Q!o47G(u*z(i`r2zC}xC6mwpGM0pyyZX)zK^h>b4bi!L(t8W1P6#(0HUh44L3i@ zluHkS_^%SGM-B=spdp@)n{gi6>HmPqnE1Nt$MH7&-u+mnZ+`>J_2DyjzHeUPU$6u( z=LnVn;fKmvo97F+ra-U-;)9+2;v%8xa;Dx!o zlRs^WkiY5kw+V2<_R7QFtV?OhJ%aNc6~?_qvPd3yd^PAPR>JZcqVu;BqJtSSKq0Ce zIz>)_JcCC@ydo4M8-vUW!HK^7s&-5@f4v3Yi>juj64g{Ta%5BpNCWo)d3tJ>0c-XLRiov^+HDBw# z$*7H}28S<>7_L59fnPu^GzBk)&I2;5pr6g6C3NbYW^58TAOXicSYA`IS3t^s!hhHm z&tpr}BEIVw##D@a+?)4+J1ll=KnEnR=hoD$_&N5Oa}A&Pftb_)N05wrygl=Q53XOR_BdT*JbOSkiTaF)~%!> zRngjWEW-H3?gbtW=&z)uyUmoY1c$;aqCJ1DOcBv*Ji4pGIf~%Q?b8JdMF>&h_{p6t zSJ&!M&jL3tfMLxzS)T_No#d1*9?T04!FcC#F_GZqDd$0T-+Q&F(z`{3^w0|WoI?<7 z-vBi6PTPR2231WckZA$0fCKKx^8fttHG#>7JtT?it8UzwMujb_*1x$fXgrW@11gEP zV3$Y-0N^z5<7ixzl4+{%D_rf?_YKWzM2R{#xSW{BPb6gk}_aq*vp^g6QZL z?)-_xrw8t`%HZT?cWZAZe@E|mz*wqE=)RK}v1o~}U`~CiFb!aOwA4~7!B_M@T1$WU z_FaBhju}tmB>2;F!SRn$@Wp*Nk^IiLEYe;*J>#KN0sKEQz+~MM5A%aBGJzqT-#5kA z5$um#2tB>?%wp_wK_7Zi%JVuC=?zI|J_^{rfbIAgnA4*mc#xJV*q9IqB$94gh$Ho~ z{K2HfF8VWQuSUXmr)ZkW8d1Tl2+GhAoAA%#a-UdbN8DOnDN3!h=2V#|oSmS%zMwPbo&T zC0y}Xpap;Gi1lfrvA!k&mAd#{c)Fl~O1o3*0Q(8yg})Sj7%va$M|*Lb6fu#1la z9P2VzF_`s8L01X{;1uG1n8e`EhaT|7z9<;8|4JYMKVHw~#LR8zE@gpPc)9YaXpi0y02teWsnjKNVK1WgoI!XxmIeX_|ky! zX<-sd6SGtye#8G_&5Z6+&`mvrJ<>kzr#MJ_vbVX#}L3Fjxav( zbkDC!3vhO>yZ=?WMDgDRw}Tno1aI#T6U#&gALD8=Y79lk9T|jP(0U^?0v*xQP(aIR zvKOPa)MPEYimF{xkdciJaOlll#}Z*mF;+oee&ljLtPP3qiU3-#QC_|6OVB9TRO<12 z`U_IPm%J3e>1jzu^6qQuklw5t%kxL;flh2qn4Wuq@3f4syv2Q9`R4wYNsMh6N7BU` zcxM3Ww#}?44fWhvH?l8=Xmd6AXu!@u$;}fx(A|OLJY&b}_n#~_%;gdF=lX%2ADJOm zfzJiXZ^Y?!tXErpO&%PY71EXo^B=8NVJB;=w*eVlCei&(HMZA3j&7Q%#sdsDbso}G zdh6ek@#>X&6xs@6EOSn~?2r?u%i?cqhhZLXgUR~dh_$Qq0C`?-9$5v-tpOZt2Wsu= zm(66G>U1w&ylA~UYzJi4Pe&8;QIzA zC+tK>d%x`k8z7~Hn9nfYwZg$8&K47M!~3GGutn?5-3WAF1IRMevm@|iuu$t;$Hp`* zfZawn9kerW$A8Ddg!r2(i*EYAT0MS=k59;$6m?a|%04r={qU*>G^Q6fQD28gXi(Z8S%N)*%GpOA0uHSU|%UP zP{9?RQT?hNdW0(VXLQzLETC%fDWLR$e+5B!Ooq{70PgHpiem8b{H$F?3&!m#^1t?m!7DJTH14N^w5kz}-$S|M}JTIpa5elAi81w{{8o@$*}t#T7qFB#3~J zae4^+h87!5e@xJ4JKCc3VOD(Q`1scd5P#RvDA?0QCM-cyYPH&DCkTkbY-epX{s9md zjx^!}s-|@Pb_RWPXqDB>jDE3FxE=?Qs(wY9ct$OWeHb$tF~<{({)Rl}MG0mhs_E-3J#eP?%4fWH@Lpe_<@acNyv@TS!dlQOV~oroFTSNixQ zbiy$)iU_YJG0rE^$dGy@u_3IP)|T-G@U>yO2;{+MJOcy!bh7aiE+)S{4KM*A;i4R= z4ud#fNh`)e0ux?X0h9I%U#U1><0s}MMRpVai~`o$SJ_PwyMhP2-RBVzj4lUQg zl33sM%eAkbEk{qUxSPoT=mokLfuiZQ^h5o4tjVe~j;Zpd;sc|_rta0xg1lpQ97BJC z3(B%(n`pXE`-e8wbtPyLFs0Dr1<&`pT_@olrwnN$aG^VSe5Lyx)t2xGYY_${njiPF zvRO8!)S+k~Cj?G}cA84%-h4o3W#RbC(n@a-ZT-kBys1W6dgl0#ljy^{AYMew=LtQv+xI{?leVdD(?;715!I$N{B40^}OhX-I{_e-WLpJici zJD>wVXe-GpI*mA+R9B8erH~z!diu#` zxA5HR@9x8^S#fmENUuJ^j{*Qfb?iGA{9ZP`?I?i}YnS4{{U}TfLpy z+=V7|`Ll|@%Nm?sYoe0590SX9HsRN|o0}sIMKuD?Tl< zLBf|-iK^0KuNR}^P<=wQeAxA!>gL9#R+xD%%?QMH!^8kCnJMs*iPY92ho$5I+IW_OeGqT8iopF(AIrcADN)-sfl8eHPV-x<7M&A z2JTeY0Nnx^HsAvREpB>R=$0p79zg}>VG;dSY zArHmynSjc8lNm{M&zqJP`Z|)pdO3=Y0&uX(%6Q~jE;K;Z6W17U>O}J>d{Oto9T~@1 zJsC8y9T+7K0tVEXN1cUU4noEPUaofkq=+?VMOF6a-!ZhJKZ)uz3f;2b8L$5QCo$a1 z<}q#`weg5!^zLlKx5Tfw%5u=8jfobyweE$MFu^?=>$>kpvBryf%nrW8<5rC|1- zK!T1KTA3_Ft6sGZxOYGJg)lJV6OY^gGS)!spKv2iSUtcTS;;}2w)WL+kD}w?E5EXf zEC1}ID-(tlx>b8Pnj(EWSM#svK*bDKv!xyFX!x$&f^z*SDbPwFiSU@&Q z9Uz>xV-=776GX@S8FRL$htffn0iA(xEw3BQ4TVCV?^>1!p^Wy|y1q8*A=DmO{=mJt zrlj4wA(Dubruc#PDxOU%gM{1BzkiMRU;588F9V8Hv^{gRElH z45w}iQ-6G|VE*dS_n9t&5ytriRjLuG)1JtHx>n6rXJ-5lq);@5^YugV$@2p)GAd9O zh?ARr2O1e(|uiLo8t^nfz1`FBUE9hc=GIi>pu)Q z$rR820Is?Z-!=OIT?2?9aqeMlNS#YpB}wxZ2UB? z`*zPR#3Qan_2*rCcQ8wDcw)ZJ(=#7DIsEk?2)6Zk{1n8~LM((3c*&ElQOt>3h-amO zW%zjWDZTX~^W#ZUO9$bBk1mWnFbdO3hl~yn34ft~qoZ&H<*1ouOJRfb%FztB{JX0h zG$=3ukZ>zwBIclBW9*mCruOkpYAV|LP25UaALim6I=^^Br>Q+cH}_l@x_>?m+$pNUR^6>guf?OY3PgmP&tc2i2uX3|JE8=-(=mr z|8T^z#NtK?*B=6|HHk})`hb4y{)F6=$uIsEw%6}>Q5rW=#Eg|KT!GP&An^BL!zY-a zNwG!~$sKccQ=mJa`Ynbn{S`$80Ync;zbyXD5r*hJy`|8hHShOcjf8rl9Nw#C>-~c@e8d@nDdyb5|~(=Y%`Rixp{ zFB@&rwG|aGQqxj2Ew&r*}hVPs$=2QZFQnzKlqtnX@sGo~YdNey$BtTU; zlGPFJP;Ap~?*gmA(b((dIQOn}g4l{bxY)->sY1RXt0v>%RzFCJ7}TZu*AcNbf|E)7 z5V~{rmUpg5BZ~G(l#@;SuqT?vELs?2vU;njG6boJ1{EE&0_csSaqj&QPmioi6){gu zN=h2=XUsDGY3DjwbK%W@-&$DlVBXRtp2_NMhoyyV3u|6N>qsfOBZe12R`&pMnt?m% zW*T}x9Rfb+jq=ns7iQc2d z)^DYt-O`ymA8*h0b5H-=#eja(171Q_%-vYjZM-vixdRTX$T?m4#Imw4^95}JXjA+m zK78a5=5cAxOO?5i-@lnd*Mrxh8oxxn+fx)+J(nJu%vkuA?p3xH7wKSzEw28+ymNmX zGWdORVe}e=pe{~F!EPDW6AK)22fg~T<4Y`X5^YJ2N;>b!92`HNG_G{f3(pA;`$S|W zUaiUB)MY+q%}zZo3=37)R{xIUDCjpXU~$W;q$4|8*TbMz`X7Qx6 z_dXt5wO{9E*>`Jbz-Re?I*F*!QOr!&l3dVG`KjFC;iM`6R+L5~S9 zGdpDOLiz{4NXkB&<0Qc)9uWR;*Solx$3y6gZw% zA_5iRmwu#GyB!I;w_S1xq$m;znqY-cWSWVzxdsJM*98rX3Cc=_<@@MjP{eln9BN6* zjxGWEHx?O3JzWH?U3HP55)ZMz)`$j7;DD52JEO)LP$3){m%^W1`u~Cc`?1iU zjM=kFa;?Bx5S<_}GmPk&+XkMw{j_Zt zToq~t09YYW_U*7p-x{?^;mKG=7#4`crfih;Fl+zPpHBt?Tt}O9(w?22apEeWwv`g@ zvqGOs-`6#%OA*YOT!mqEMJnRCRze&9vYwXM;VATYzDPz=J**3Q>dGmjRO4|lTE9=D zLjDM`)Wf$*$gM73-8$PJ+&~62ZO(m{_fugAd*JuO$@!Ogr;3jE?;J_({W+RkMghY` zfS$RDKQ0UnOBWYGA(nH*yk^>z2(Y)XU(C``W}uwTcN*kwc&wX~1GrH#Y@(pQk4Qct zF_A!cpf!Dd2742Pu^qQsJHru;$$7u-z|=C5p7Zfz-=5_a0fN}6u7Js+lNDc^lDOhY z?MYG&$5M`0^ATe>mQ=sAo)?R{gE@dYu4Nw`#t%Q!+soxFBo;FeW^F%Y^2};R1*@*#zSn*Tr zHR{(`|`dqD}9064-CHR<8HIo%89+oB5Uq}M5wb1R$yBgP{ETI|?DC5YZA z8-!b|D~{P5{Hlh+y=xaU;KHrN%5m4r$voOaGmkU#y~0~w2#7C7#Kvn$oK(wS%8`F3 z5U~<_l63+GLfAf|9*mPI0tXrrWtOfAjipR*0z(0N(CerP|9Sl;@srw?Zp;`W{@g>M zz>LSMCsdDyfB#D<))zZ4{WUf=CIJt{d=(fyf6m($*n=M$^;l|!V1tBnMe7y3c${o! z&_WS;9`mEuO36uflc4N#K&RIkBeJ$V%uX@*Noqrl!=93w`!HQip?&|cqY<%Q@q@5h zPVo*}fbzPB$1;fKanIv{-FdHa5l(x#2LZDRK7QqeG3@o~%bT|QV!rzr&OoM?27>o` z6%PS>gxHg}&VC783x|Itngo*ZqILp~TBgJ( zv-7_>%|nl1o>2>|&IzN>{E}nTDu$vFV#*r;76uFisdFT6j&2mw!q(KI;ie>_(gaeH zP$rsDAzQZ6w`+6nSXXs3!m8{Na-Z}^6lcuwwoJhZ&@P6}Ssj#Le0(^^W@CW(M%G_P zP@3L1SKUzRoZS+1w)h-?$YAa}VR>)*r4(h<0e{mJHxpAzq@aXJ@?#hoA?r?di)w6G zv-|+gN|;@(d9t;(GzG=>OvzLGj;A7Ba`B93y@f*oA^do5!o0Qw^LUW4IGJ5JdDVR* z*R&$NksaH4ref|%r$+=v5~vX13GA5bQ!wtASjbVnJwk*vL%XH;5lPKwVtF>0KF^B3 zP&A+6Ti*YEs!xU)nGzarRfq-49!3;ENPch3Ow#=zRI|C1B~mGI@6dr)f%l zA}o7Lip+w4jFUasoqB<|`NQ3Pp|~f^ zNIZAR1+hHK;$=zos4Hy`C9De_&^*~g-I#b?{NOm*APR}ChbDP3j)ZlE_}KC@%l61< zF@iDsIzGj6H}LEViYn5Y&vhVTN9+8s5=>#N%}YKG21SCB5jBdxM>q=mM@Qq))xOtD ziU@{YrtsYm;x>%GfngoPX8asnZ0M0UjIO-{4+Y0RE_%uf5!LbZ_8TSHQHj~Fo={-7 zNzY%cL}|Lsh&1_bCTzX>Ii{w_(mE zjpfxFUOqmwsoU-_{9y-vsl_;GnR^I#kF1qB+DKKU@A0#K68LgLWnixyw?s#B+6-(v zC0|e0pwD5*Y>N$*o3;N&*7)ifMW9-{&_gaDbNWl0pB%&_a&_5prTzOd>2hMHNREUj zh0PT3C!D1zYWWs_81*G!&ZQgFeOc8V{$k;EV!3YN;J<%woVw$l3$M~8(x8aDVymI{ zT2B&S501qJ-7ezAA-e&=-!mbbD$AnaYu$#xu1=M1p1l=`pa2q{PJ9incLy$(!lDXl zYkwC1fWFHT+k@WKzHq0d&&8LJmrq{k`1fb}WwDPnSI1SXdf8g>hj$0(q9AYv-%ou? zSiQF)r>(%MkQ~6sCOE+0S055K3aMlrM4Ifta~Fq%43w0g8>(OnpC5gHj>q426P2Bx zZ+{M##6YV{4E*Z|0Xx5h!!sTpQ>pd~Wg71P=L-;dAfsgKO%Z4|aY`^KV?Y?^{a^~< zV)TCRX8e<_-RPYZz|=5Ww?gFEDh ztN|e#tHEse0y`mZY|dC>U|5@$1bqW5JAz4OzC&luoiD7zIyh(EXj_%0=uuyvW_7!E z6;}KO)t>;bDbc=&;_NW9%pK*3{BPSI^YaI4_}i$;Yo(IVhwSfHy@!#-@0=K8tL+fX zh+ZHz^DczQlUUqA$PXw&#l&9@q!WkR*l>Pe1AFWY-fQIX#n%Q#5E{u+6w(*RP^99i?#e zp@oUA-zo#?cH|~DBxNgcbhmUh`B-6M|GHzv!I>@q?5L<0<*r!Uo=*PG_dprn z?-f3BNc)&>7)3(*K;aQ#xOgy|--mQbe-)sflWM@7H`ZIMPengl;B;T% z{_g&@u@4XtcA6(k{rG;~VH}0;p18QU$gLik0UyIG105`%hHvU+vc-46+|2+fq4l3X zX)WIEy$6`~F%(`;8Eh8b(~HQnP(cA($n5{_UfrCTL_qd5(p_A-(E-+eKUjvlJEiu^{ueN#Ci$~PY%HTo7yZ)`(D zK`w!iz=F+vGa-Hifvm<9__@FCp@|DY*$8h~^NR39aBfackG8l)@+%J+`(6MxU5O(w zXl6DF=uwDyuNzn+x`cu{<(-7+0mh3|&XOv50q*yaCmiGn4k*&wLgu+5HLbEa`=rTH zs{07>4reWYyhwsi!K4GplxM>s6v+G@k zi%U^`Rv9j0qq?vlj;*ORH!Y*y%ud&xt1SGg#mkbs&jXS91k=qrQq#$W4^x!4Z%i5S z2IWgoWthNAF4w$J;?Bgg>z*T&#r;n5JvIf=gsn?3)-U&Dy~p$=&u_A3QJumR$<&Ph z4pasU!+~<8#rAKM5xoRW9zG)bgUc1QwA(ol>VKNr_n31vEu0#(xrKc%a}*%g|4h2y z6qvpI#lj}!YzAyU|8}KbAj}F`rUxk}Sy-C^CI8p_%KzOM%|rlKevKWU(Vshs&zX^+ z`{2)3VM5&`Jg}bE$M;oM0kmhpAOyfqIaXjfKdda!vrdU+2=v7%2mbBAzhkjDE40Lox3R4B~ZCP%-3LzAD8vFRm4V>0=e~ zfNK%f6f2N{`J)hoqKUiVr2lEEN9}Laeb3Pl>O=`eD?InY)NBRm*G^Y3DGuN0@dYl8 zh=hG_-XoRz!N&r~ouh;=2n?sa>F9TNqF6}Cu>^+IN z@lI(nc$!#k3pD&VRVm7gr^h^{`4LOcI2zh@6D1A;q+B#Nr2DOn`*4a_08L_;!<`vYde%({-T8ku`DIh?k06kM7}!+a&mampT#Z z-gXi+J~>fhSa$Jd$xj5X&2E+kk zVijVR_}GV~kT&+mLOWpn%2MZXMb}^`&x@EbTI01(%!+pb@9fCKESKe*9V%iq)~k`| zt8?3BOLFt-kUth%ubv*0%HKy^JIY_{qFsFJeGg@t{g>|pnc0qdy75i~|I2B5YsuFG z{O_Ko!wJx%`^?>0h=z=G$pzRqg1De?Niq;7^M* zEfRm{8Em0I#j${Hcr8S2093_TeOE{}f95ZeRcTdi=_#WZYsCE0#n)tN{er)p99>cr zs+PjJpF#98o9_z$`x*QM-}KYJAfOckRv62I(RI3GGR+g_j^jHT8KYD2ZlVof20%Vo zMZYk3Bq0qw9MSm_L=~L1V~zY#GaC*OH(tPE^}Y^+(A1Bw!Y}-p05PLFBCO{R*EpoW z(M8OGeO)4+kudn{cp+fWL`V744+FBcX z`yXAn!rVpUpBSD#r1ug zPja*1vSDcd=Gu6v za+%R~yZ;0jCsIYHC%&|%%{|-BIv`zS8n(AlTi<#0 zg~Pxv6D9@W_Tu~d_pj$>;sS(tr>2ky`JVlDMgZ}^cl;fGoym(cz32I|?pGROztpM* zcWdw&k(CSxh8acb%lDIm%#XB^viix%zW&QNP6!gKd|j~ba1b|=SmN!$S2Uzmsw5ko z)w7J!eWW?(WPYg{+w+YWLFRPSbTTeHRb=91SHq>HD>4q6kCj#?xq2uoVk`h+huj}V zdZSHo^iQm;V~^gNU6%L1^)TV^y6BHhSNUUiDL%gMm9@OmvFv7g z;16Ym1JbLPHF{;eIc4^)2TjFI&2E9n&6`V?6;Tl8DwQYJrSP*n7e@K$Xi@69wWaI$jNvvM#ZKfmMX&9nEn^L7h5JO{088*!Dwk28x zLEiH;NV5FG!lA^4{9aLxq>|2CE#)EaX3}`+V*!p9Y7?Qb9R$qu~;s5ONqyT zT6;ErZ{#>D`dsH&olshB8?ql&!pXn%P-n{up)chIPa9IJozU z!6XPF`XKubcq*nb;xE*+zW&QO3O|sUWxT*$Q(Io*5**XXK^!C zm4zy*0jAjnu=!j?@db(COWvT)g1V=ZpxvP+!-8Q#g4bka1Tj!CLzl#X0p*_oeQ&2< zvaDI0S;!GUkn=R+e0Z9;pCn%cj(Bgf*SUuiGl$4969|AJ<~;Gjeu!6Ex?R4AQyn&E zc)~3-%?mJ{uNRq1Qp{?-%&qdeKDM62RN>kx+r6_ifC4)nWXjB-=@JiTB?{eqIRXN! zc48-Ot>|c7@>mm$V_e4mQH#_hl zzesto^?PTQ=R5DEwUJoGz6kQZBw(JUd2;5mat7>d#<1P;XGszVZ5KIn_$Ot8Vi~i( zqvJIlNeTiX#m-0$J%*HIV5Z~Rf_Zs)*D=Lk$Be{%-X(M*ZJ@ei4)l{(!=~U(pwY^U zCFo4)8QYHPwdwW{hZb4!f`F{&eNE&&JXj`XAJWtq4L^-`dEz@_v9{5S4ckTU>6%A; z`z9&Rq~ffK@@Z&IEsQR5e+niB2i%^cAuLSE>dTAp;J>sFF7wEZ3qPhkv-T4}3k zk{V;Y_c4SU7yQA3==Yc+&%lT3jRbj|7HA6W1K3Qw2cTR(1FW*l18uJNx@fq>357y| zqVRQKnRpjfoI3lb?OL9QAOIIPZjlUecq`=IeiKCdGJELz_w=~n46l2J5H6G*xCncA zMZ3C0w7#)1+#ScR21iR*7s`5+C;@Zs)gS^E)_E*|65EkLh54TM7MTw`Uw!2jAAT47 zJgkwg5|YYW`@Rwcz>ZWiWb^KR57nP+JzUqebm7RO3gA(ts>xO%K6s8^oz}- ziig$~ikr;zYdSe1*ztrd=Oz}=ficDQZgRb64!WNff+UBnUCYM_-;jXa26)c+PHXT2 z2HtxNqRHA~kTkex`R#q->X#-ZPbrT#j*c{%nwmT0)Qy5+(PX?`+mqV6@4m!vz8~hP zNT5_vP?X?2Rk4{)Ng?U{GIsiU?6AW$*F*8ky!qWoq*_uKiRR2||5ETHuC!+IMq%ht z%ckYSntXWFjpS?773AqCrhK6acRIz|+nQ~5;^p?zj9(-e*plWOnOBAe2PMCEO**e` zpTiE9hIk7v%h`&M=3h#9M4G*$UV}QH1fbh<_tGf_*I~n~GsT1D@v9^_kk%BZT~%cx z*Z6hxnaGm~B##76YecdCbFrW9X-_R$eFd#V8|z$I%%poU$KRUJBItdtgph zF>&#RhK9HrTH-Wq*L`0QJXGf(3WH&SOpT4q>Zq!~8>8aGMx?^03cfM9r(p_6w{&;6 z?|Y6kK;ai=4B~B|e|F_{&+N8bIGXDSJuO7p-j^PQJ{96>=V*!`f%87&$X7!!Up4JMBKp=7_*WKR+W?)3ohnW>-%)Q{eT!9_0b zJZXPIm=!DAh%z_LT zHpW4eRmz-a50NR;oDZ@tJ#RZIAA29MO|U!6TfH~S<_5z-MZ*Q+Tdh`3>-5D!$%TVA z5Q8nIFeHV*mO5wU>L527FpF~3^`dEwrg`?0Iz!Hk<~bDMohR8=B-AmX`&&%DAI(c1 z*QekY!e`O8Gkyi8B?bVkXDEdpb6L4p3oX;f(9<*JF+e; zM3e7F4_{=|52JMZxO@XE>(F`d4dpI`OJf>>5r0c6Qe^u?#7JWQ@#bx~Tw5LxAn^P- zyrS_<`%FZVS>s!kWjj8u=eeM1>Q|0k;lloKfYe~)D)dA)U`4!}s%&23OH;zcfm@-V zT*9{e?K2;9V#IWVuG>fZoC6Iva0mta#ALBAA`0Qz5#=Pq&~e*7?U zb#+Cu`LubdD@usIb!ls?&G1S1IlVIqe^Dd)KVkDn_f`sfk0G=}JRe;B7w?lmfRT_s zwyS(CGxRl9kbVscU3oA8Y=iAYiG6=YM5+9%q;~yD2h8Rj%xwMq zy0BsYpDgHi+LLkw?eYP6N)4CmQ&`SSYdluLxY95=26}f4bJUyt^T#AiO`8 z-w^&RFI9fVRpM)}q{USb!p%4agJ=ArtLTU!9jZg7vZxj{MKh1UeJ{I1C**%XkX)S3 zeZXNZ4-d}{#WH^KfBRnhTO@SDPN>Ks{gY+U-$pORIyW0>O)EJ)@X}Rf63-~yF+n@LUDH|6nB?EzC7Q|`vcBoW}TgV)>@Z6 zIs?B;oM-<*KY0t;Hl}(KrT7Hc3Z0Sj$UZY2y}<*Dh{|I*JXG`tWp?K`pa6uOVdQ%j zmOxeQ@ZLb#Vh(U#$M?z40Q|x_Wou@U<+U~G8e}t9q)*AoF?X}hrX@JEcWE=BAM%)d za5aVGhkgX-+&?m->B@XA{oL$*Z-{%y@%^Yf8yU6FjtHPH)KlLcQsfJ#JdO_pZa)58 z-076M{v_-@k8$GGrfX>MK8MU>B3&45HBpNntUd%z?VVDx&lJg|r({=_f`p6oMkLq+kZ70YpBowh~ z=mqlmRsj&$5wFrkyROrJ_#3x&fwrFGMC9Gd`;!+HfWRw z7?FLBIds#r2lF09h~Uk{Y1gj?MvDd#iP#bVYLMoxh>nhqW(sEgbf4L*`^nV2)V{D5 zNS&%f40~$>gr6eANuYh8;gWGiM}%Rw@>jZtl8kcS-M$AOP#jk&d8K#q%a;(o+rAkD zfz{Cs)-fv9{{9_;WlPn2{AI4^bdL>L``o%ibPQV8M(cZ9Js#RboYArE*mAaFm)*lj zLpGI%&AS8KVo7>Q!j<*f7xTuz;a`84nIZgT;vQ2->|*6wcIutl^a*)Y^dox?n$zxI zf{u$pTLdhw<*|wp4>>YPYEg@k_@=N#+Sg|MZ^sgS-Y{kZ^{zDr4S*jEi?op|ri*3g zGm_EWmZo{Ub}5)dRmmeEK>X(@9a^_3$0jCBY-}jGW`8qbfHxXwFA4lRVwu+L&QFZp z-AS@#L9*Z5S3&#_T_zzE&I|7oz<@KVKR>g%KXFfHOOkq=?tkR6?x)#VL;K+PxomB{ z7Es%>2sRcy$|C3oxGny?uy^z!*?5`oG`6sytgt;^T3V~`G_SnWAfMDqvZ{!ehHmeM zzeu*_9oe_r7c@fMv<%pC69YDOJH4RlXJNc(yTX0=p`TFBA;HKcM66V-4WwoTVGen9 zO--mhWuFStIt*`6Ne?~9!l=~ZQcxm`zTdaBv_v8rOW@an69=jqI*={`Mt=i6&+fsT zr)wA($YENBUM7O@07s0;y9ND$AG_jz-lj%YGJa-;7zh77NS4yR(QFiQo-M0zI+$Xx zg}EO*pR;)cl>Amvd# zGFSRkF9yoxlJi2Z(~Qu`BUDL{>Er3?kI%e4Z zqq8OI^8^ti1z_KJ00o#Wwam%h{F6zg)OMMR^~^yk!i>72Xv5k{|64sA0;&GeRh9!HOC7@1J?&sy+DNEnfZ8T(gC{4P7R4n_ z>)KxskTl`b(=*r7!UGlo;crHk*l^F-IVPkxGxwj_LzjXa*8sSDfXMgqDn9^PIt42+2JVm-u8bxh$p)C3p2u);2Z{X>Z@c z&-whkfm{LwNpyyai6XK*?QdNvx+$81e`yGZe?zvdhs3^JFTP5}&dc*ZEpChPSaZOS zd}*P{=?3Us)|xE0Ux!s0=QINmhTnij_D>N@osTjLVs zrsn3lh6d;HR=AKo}cV8N!DrVBX zeIAK-C{}5^`F5nPh13etuL9>ilifH$zkk1zt0AS_b0s9}g%~PI^;XoJe*BY?C6?|b zocb)4yI?fOiRa$KGh|q)w`$9vz=z8lH88qlk3GkyTKyW4v5EQZcW@d@sDK2@kMCyT zmFoH~X|~*YKV>k3G}hh8HtxIbWdvEAZi>^OcVwF}WjY{@Yzev}fk*!4%!@q=K97n- z76WU!?SwfODdil5*3RX29D$dh@>e6M`8STI zb&khF#S;zyV`_b8b0gEHq@_Zt;EenFLk<8$S0X-D`z7u{o{^IN>(`squa6>a5!UC! zynyfJ<2o0J-qg*7AI+!zOYX`Q)IIpd6u+nS&rQ?%!M;Bgky5Qpu3Es~@NCY7p^J05 zuxZG2Df^Ad01u$}KKk%TJGT)7{E>d{Ekmw=tb?>)5<{qm-c7=LB`G@(W)w;P`}K#@ z%}0B)DrIW_ZI1tsX`IaPz1}#U%W4sCF%k_v^4%;-(R}mh8MMdrXdWRxq2#%Drx)mD z)@tf*_ryb9!ciE_8;|HaDu_G!9!zwr@B{>uC% zUoyw~18H^Df`@*%13rCH(2iELo$+SVd}U*7Yz+H<4WleN@#%j~oud-IPm{;4y2SwW ze;jY}%?X-*9Njr5UV;D^2h2;jS_Z`mIhqQ;iIb}S<(vhB*AU|i;RhzzORGP& zVj7qeMa*JPKs|Z6lFr%bi?kje;!-hGU{etqzDXT4ySbRUh0AG3oXhjqJNdPhv1wraH(pv0p*GPzdzYBR@E#yd* zod93`%L)$wMF+tYw|Yk zeH4*Pa8$D%HzxO*L6 z$6<~{vMN+arRt~xc2#9D&yKO(jSaIDlSVt&kao1dE2&rX@nMl)UYEzt|2sK{mJ{2c zK)4>Uxrr8LHVrqq>#6DVmVI75b=b7kvx)?Ty+CGDQGk``v=Ya&W~Y&1ZN1W=fB3WQ zQbz|eJ=id>wzU<5{$YKFYHzxtbvD&u;BzLrFh76D@UXJJKP-|0`>*$n9eqxC&cWO$wu@-FlMIT|9_mSzf zTeaYzBT#4AM7;EWWf3r27?5uO&bk$Zt55l_ZE@rP5;P69qf+N3>+j_-g=j;fv8qAH z@2-gPnSMq9QPX5Ss4CWu$xHal0oS#^*^@~ucMbUl9#q*9-|-35W8beoi@=s4uNax1 zu3N5}gm#{6HFgg9RUfv7&g*ys30XYpdzuMsc2nWE>qHWzC9!OP)2S2TJ`WS=ZriDf z3J^h^vpR$Gl^?A3FI%J=*aA=bOx~8>R{AgMkB_SuLBW?dmDX!IHgsIs=%p%XfH5_6 zhW|Bzh}y7@OprF}tR3)2#2+g$ja&$lH`}&ROAL^I2Z!JR-W)!UzlmqioB2ZBpf;eg zibyo}{<%(r*icFe#Fq`TZBC^WNy#ZW-w$~GI!Pi!L9E2ISaBHm70Rw+4CO_0yU7xN zmJ9KyzxfMKdDH)%2A^1_K!MXtz}+(iVby`B+tqt>3($u}EwEQZnQws` z*H-(GV7)O+>cTQGcwtOjz3Ya``Q;sp^V67!-$k6Se|?@vH}Jq|^s8P-O=WM1!lo2X zdRR<4Xj2E)WYEfQF-`U*X8=C-Yi+pHt+2Wg z`w+nCMbeaY=WvEF{idDZea2o>;Rr6cp@h=Eo* zMW4O~9X)rB;C)i%74W_9Y)r~qhJS_mtR@)oTd(6B$MttKBL;L!N4ayMLQ8$JMQv8rg{YNIiy0KXZ@-7OON0lF&#+tx-V)@8q*{SBX0pl5sOq@ z?v?HNYg*nTjFK^fZx{C1#9)VwW}K^}Q7-_1o2`b^%j|?-5p(5jf>V*&aT4`cY!V>!0fmUCyR6xR$jF>xW-tnp=s_103Eowu>G+eqm9FQNQ9%9Xg3;jo9w zfdie`z;NI5M@~stkkrt?nu-4N569jz+v41>1FsOdM_f0 z7X$!>`k2gTProS&N9Nu+VE(e4t992VTyGrP?MbUIczH$ySf&w$I-Zx*GM4-+3jdoq zcMGszI;;d$10L$MlqCwUmNokNM57GG2;xa(J2)R6k+sCtd#5xLxfO}=K=Ekbto19= ztxICv2ldfes}jlHrvrKT%qm}_@Nr!S;W?85lyt9%WOR{0vkL>2d9=Xt((+P;Q`NitxDU~&G|Qbd|9>i1Dn34 zSg>vwmQ5YsChWIvrp=`?MxJ9xN2oW)&o@f^!sQ;zKX7n8hdlbaiCI_7O@nl^)UXzD zp(|#1%zy(deuUyyP*G{p*X7OEl7Gto-nb>PyOy5e7PGL>o1@ZywxFY{nrG5;Gg;iuT*XHCag9h2OO9kj z_tOo?LsyRkyF>Nt`lfqTUCy0}muKaC8ASO8pz#Vd#h^dwMyE;eBk&g*^2XR&Ea~}U zucQf|=deOwmaYyxZE(Db^Gf#*6+K(hQu9HwLa4b1+)>0mtZ>eY1?IAwJQZ1zBD&=T0E9o1SzTQtbbl9ils7 z92A;8fYUe6ipVGe7m`j+9FQ?Wc{~KTXzoor?tn3{Dg{XU?fAb5p|rr9Ao?TIFj{e{ zU(08aK+vWhgrptHD_pwKC#<@5{dO0CY-`GVIy@%kJ`|MBV*7dBDqXLi5?}bc!!LmU2FZaN3e5Zr>l`b*AbfGl8RCbeNqHo z%K`TGyB_GmTh#>~>d66UyhwQ+tBP@9hZqTID`QvbWKJZRGbio&gQvdpsrX=ppXTWZ z5l-D7kz^3S%OG9wptMm&P#wHF0sz^=ds@gJ1Nb%o^bEIJVDjy}^1`s8%-q!RKe#Mk z|KsEw13BF;yi+(1R6MmK=Ak!E24Lv2sV0LzvA!nxH&3zeBO0=`m!a}uLcUGC6l;SGzxrX7R650DF&vanrD5Z(^*<-90rdSE^3GhWt z`aOMm7{v=j{}fT(<6h(4&ijfe1S7MB$oD$z9tcuW3gSMDVOe4C#`1Y&JGR*b= zL8xqS$0rceO*$`ApEgD$o^hzCv)@$d!$`2B@2kKh;@UW2)T#1ZBKCcHW8%o` zs1YXi$XA3tK0Zo!d25)2Dn`bp(}$1gIDHu$FV(yu6WA4#XO;0xn@(dY=k z!(Ea@!!MTuTz~MUIpb{|7gw_~JiM=OZz8P2NfjdZcfHH8UHLtP?EWE$An~1+E zKzbyk;ah(Efp*|q3*u~!vXb@b0i{wx@Zhf5Xei*JxCg7rh$vu`Eh}5b`=e_&J(4$>h&&blO@PbK-1qF>~UC5vHaCwGAd&GJQ z=zA7aEUzLY={v6}!kvI)V~(TG$nT2ow|Az2Fv7kiOaCe!bZqpDtM7S*>34f0;&-#5 zh;s_LILTm$kC9kX%67go8t3V4^bg@$>>N!e@xoFU5^Q=YCaX+Vbc}_Y^2II|Q z-nDX=6H-x9zVkp6>)SeVrfT=HeafSA#xjoiQxa55n z=I!KajhR*nX5xy^wlNdP>EGfx%#=`(Wrcb^S~t|iofS;TRysv=*6gcT<0K8-$94t^ z4tgGW$;4gJc3$uH`$2;UYH6jI=rPhGN9x>VQYT+E|4X%dR&_}{VwNf}=R?+%(6_dC zK@ROH$-b2Gd+Xq}?zz>LJajofyMG}BfwO-;EcHgoyfn&#Q{X$TuT?rX4+lDY+w6if z{3PwT05agjVTAkM`~E3@d+irq4-Xv&D_8)*_{;=6Of7L+dIjC;g`Fk(t&fl1jbHz3 z*bD>M@JNF0Q`}WW{pjx@ON&B&PPIk6Eq~L|pCik@hU69|mnQx!%7IXTa;FofRF+Y< zS{plge|6!yVz#lmSlK7IXtA4>iT8As29j^@=Ic=eX}5gl3*D|cG5^s+Y1uyMef!x& zGd{=t+EoM)mw37PUT1`X{k$J#vTh)%EUn&Cw(?-SvHQ?Jll4CYDj)fd|E#ZV-OV3QOQ&7yNZk#J6to zrh6geSUsC)%JUn}r(Ov(ZocHfL+O=BqYr8>n-LQzTU?U=o7kd$wg&r?#f8md>$BXn zqdhs$oCpJ(sdHq8_Lb};4z6GbH&E0sLn zKN>b8zW29cQE^`)w6H-x#J|{^=t7MyUl|#3_y4sU>9X@qJ?Hrnlw5{5r@cGoa}vZx zUwUpSBn-4W+cR*f*);mkpN64GyK4deI;1ZjH>3}7yxT7?yPv7X44wZoya@N)nTuk4 zxcX#y>3J_@9s8aY;uTn$#S?(nO$rJ|={;6RC4g2Q?HxZP;s`_tk&y-ejRk-rUItD-u(_L-O0P(k6 zcz-8$3d6Z&H{Yv&Y+w~x7Ei|pYcl^sYrlx_%Y=a=%t*PDJl$~F!7O8tZ#fI5Z?mN9U?k7`ChefSk}f3 zm%c9yy$d!+DCq(Jq-jne?y>2)$qVRB_qBm|!Hsi!Q=RWWw1YkZ@b3_N-2=FUz3$<8 z#c%$Tkk~4;uscZUNe%6%avt4yD)hf!vJG??_E}qv%)22PN}*Xt%Z=LFOBg{`zHbAu zsqtwhnzShD&f1TBr_3t>(zjH_2f6ZzL1Nz%r0=sFz*WWGsd}U^rwYlw5r;p%aj>S8 zkRkHAS6p}Qb~ALYqL}Y6G#_~H>iwKJ@009DQwLX|^fItnP4@3nPjc&sb&m9Z@4XM1 z?)uPt;S23^qE@XEsHl9S;!9IJ%P%UR_j^B3V#t`h6{XnxzuF zN=lAo38T?;is@}Y19-em>pA#@Ap#iiMWqiD_#my9zj(YIC-zDUdD^8(7jy39ef>iF zr(fe&{}3H4^Kv0O(cJ&WWHp2zme^bTS@QCRLm=R@AUP}&g*>Wh6S5-#H(8eX7PxL# zqA-x7bNqS7+`|1tz5=64`5ZKatjQ7ue%*Q*vUhAoH}Ny$^Z}lz94+rOUPTKLSgPB` zS}+2@s_S#v+sPllhPd#0_xZ=IaZ@kW4nk(mn^NGh2i^o}o(jJxeQl;X^O{cpq00za zx!V?<0$deM)G9ql$t;k|@M(5>t*2GZ*Aq0n%Y!vo&ly4-96C%Li^5tpb?D(dG$a+S z;lG1BmfZqu?s!~pIU6bPdKkWLfo}7!@dy{xgvi`0WPrC%fBIK zsx?Xp<4clZ=;il8oZd18D7GmIn}f z%;+3<~ z*0QUxPT2Sj_1@8`1;Q7TWpg=p&?V;7yDt*&3rEeuaIB9;Jo)?yp0v z?*^M41A8G_(*z$6|}8k9%t^z$b<)-6Dh$ z^Z|42HcEpW8hFLL28%r(_&pTA6~r>JU9C7tFeJve@~Tz(MZ<$>^v|FKDyhe$A?4kE zu-38f`1*SMac81AMg0lkL&8_za|qIRG9)XrdbluvElLi#5r!|idQk~wndAo4+Lpyr zJqDCg2B6P`nCIUguAfC+MhM-|httNXMRf#{)s$@bDV-2eV|$^}V|@S&6Bye8DL$~m zGFDxGs4p*1rj#^re~jE8XfFAV(>rH`iErEC`)mLZpi=uTJl2Vh!O0EjhsOJpT(da# zEp}dtIiE)LKg>Y)FUk}rGkCZ4l4$%TZKe(dKUT-Rl#IR67Xnq`!s^&KJW7`&&4^{Ev*bhJ6HtvxgB8b<(f7|T8-Osc?bTn;(;q50>n zLkBgt)bAoC_+O`uC7cZI2{8f^dr3cfIc}2Qb9z1O#)pAIL-Dml2>H-^7_3;U)Y8i9 zKQm()vSrPd-PcOuxaMTmf;S4DYw4veC^D;<`KXYb#^mzA*{AlLy3oL*2ZA+t`Xy|h zb#e1g!Py>hds3-kJWL3Gn2OF%l>|IK> z=ghzlRdyPr^Wcogmp3G4jh^v1-QCzX^!nGf!@z=d=}BF4{t+=ebi79C5RHc)9+mu7 z5abOTE`zpQ&1vah);sY6YD#P+Vy{0_3ncxmrI9yLPD=HEf&4eo zevv^HkX(D6gC054=nyct-L2;irtdaAaE%GkM+L|YgIjWGUbwN1C|1i=Kb3{z4`seN^@iJtF@gZ%g6C=#e!9XT4hR zBKGM~tedMfFnH!ekV?eBy8BBM|B5Z&>wS3uv&2``XH_;BHK0mo)Gh5cT^{-uCNOuy z>vuKLe);fjaXayMy^W&0c#rB8^A1WN=d&8^Xp3og`ELUXw#)zGD5Vs&cJr>XJiL!o zzSlFuji`TO=z}f zp5wcGlrqJ4CuR1^y{qUC?w5@Zst<$=QwI;_!46U0g$96lW{e7aPLJI`8-?~^AmTDnDu8Zhl+y2A@x8 zU*D&9U|;5%h1UxxgHZt&ga0L19WW}bGiK!R^7DJPV)ig*5JMN`A->9}t%O;nE^DB$ z-?mW4O-Jf$4QAMKjWo9S^+czPC#@f8leeQ3<1sQ%%V}^hz(u`}zNI&~QP8!lS5P1hvW%nbAjs+aQA4A31=4EmPw1r#rHED9;@G*e7pwJd|1yg-KS$<%lX03{N7 zcm}1t?bh3SSVi~Tg(VQZ7GHKRwrkbUqiOovx52R+T&y4kbb*~9#_eO5bMKoQ)N z8@P0|G=(RD3znFCAA-b(o=p6glA;i2wuK+^O|Kt;r$&G2hI#mHc?M845aIlK8H=d( zzjLnjQ0y0_w;%O){GM*z6-GCL_-Pkvx?Hw7hFVvAR=O{%n7K;7TN|4pX25WJM>%3D zxALP~+lkY~@p~t|N0N!a8fh~((IS;yZwEn^p>N9}$FvvJFltt^LEUFX}M`_HAVgh&?mR94rV(7>%{bDmLcQ^7t^v@Q@@55t6 zOE>=vMagRw0U8QY#`RU}rKbo0n?5pzB7pWg&;Ep`V4d5hV&ZuvG;8CEv|~rRMxlLH zrg>3r`w(uW-)gDK@HQFQGh@`?v05Mw3xM=-$+CfQ*t*Jj(ZEy2cI(*44NLN&z59o0 z#Gcb#PWQkvHB>t?1GPIUDDvPX zW(-}^m>?)7PyHQxE&g=;#TbFw3HI%R-sv_M|BsX+1VsH;6^EhWha@(iZibZYsSRXQ z7YM!)qPfV6$WyiD$Rt>{%GYE@-eMl&@#*stm&v$*D%_P9jH+aYnd^_BFZn zV!jnU&~HywHGyUKhHVW(-rnmm{`Y>RoowOa3oA?-KFX;I2(5LPfFznCBly+7+RqDE zo4B^pUQfGwn!8`@g*{HlMFsDSevWtmJ3fDgZC&f6yiq(Sf|&mw7vPPY!CUS3uv{(= zR1tGI8YJVMcayFsjjK~r4{c=n@lx=0qdzz-@ur6x@!z30{TH2tFrnBE_wPL%+w}X} z$-Nou(m~kw)Ds#bA&sUsFl%!9>KYPH(e+5K6>WNZ=HH)PwT!|eP@my8<`%|w0(MK$ z2a1b~j~}sJ^?#y_)Q5g#J|8hij_wYsHB6)g^OVN1Xt>t~4Irwe8(tAw=UgHeeKZmv zy3z7Hno0DRM3WdLgJx8Km95Z{jr+<3f1gnRu~yvCVb0SAE@*yg8^U^*Pd<)Cpdu=0ZWCu;CROZ2D=z5O3Uxn(vpRgx>}F#*ybpi}bb zt~apgUA2_^yVoJd7d{7g+i@-IPxqgvJTo;C{C&9#Vp}K$?gpfPVWw@TCO2IY$p@q=V(JQc z0-<(J?@k=6_w?N=Q(9p7&3?7xew{Jz0Hq_jle$ENQ~nFU4^3ZLQw~x8k^>f%@QHh> zzaM7y6R~8d^;y5;VN1`oWTOO$G0EF=A>tB ziwVoPu4o1NDxJ;s5DF^DiB+3i=5;$?9Ln%DVqE>7RHXyHxEU?fb@E;qUL;m~x8xt7 zkIYcMxjs)N)7@D}8*os5n8A=)vJIEt(eUAs?nmauzqlo={nx7p!p1{F&UZ1>_{cu) zl5VOvrQF8@$Vh1-OTq&7P%TH(q*q?yp4e!mHuJ51Y5bxTrEl%#D`Ds8s7GUr=rl{Z)0spq$*CE(9lDq8@|NxL=M$#h z8~XYsEyUAYtH9_DNh^1ik}jT>GYChVG-A822PslD2w&@u1fjQ|Ea+>2NxVpWp~$S{ z_y`}p$*nbix<6*9uA^3AULIH>S7jZ&em=$<|m=*DU zgVc(hzAYXWvF)ay9Y6d*)MZh|kZDUpDG{z(P|AN>Ca7cqnE!tHygjv4!tY^w>`Y`@ zs&;+&^n6mojwR5r1=i%Vt|<$Yk&ZFdbwx27$N2bT@!zXLHqxfaneiBB0Fx;YaEF`f zEH`Os>AH}{m33=qf?8tb*{1vL8wg+A;gD4!CbS{hlN51-jRbtp57Vg#JB(ufj1BmB zr!S9!yv$%F)6VqZXhd4@YUpJgQia!oS&wX`u$o0;{4(*+oSxtfS)g^1dYm*BwaO zLRm}&2y?^B3a1sDXqBuOSAJrrGLpOdR3DWk@iGB06|8Tr2)}*%mK!TJKt_b)xwM~u zuSngdV~d0kTz#ryzG)f-I)Ou)wi?l7sXDoBCZuV#9{Sn)3o>KfK%uocrTF;oXnS)g z0}~%o6J;lZlkjrHweAK&(lTy$8c@v^YX4CwA4#=xyOv78i?SbBwlfq5o9JAL&u838+|b_@=P~H>GHel@ap`crt85IfwNtc) ztS<%PphwACHzKrR4(EvBNBNYL85t53^IArTMkB1YQZ}cW+8DTNJ zZRFehSV4$LE6@ag#xD;gr3n2z^;Px&dkRz596SXUNFGJ6!U5&JYfQkO5fr@V=!1~% zb)k&;&aBLzh30r zJ9oX@`2;HgN-Kd_jLUF{s8Sa$wxt5JZQ_=E>d*}bD_7uaEUHiAh4DAT?y8R#YvTb4 zyhs3aa)45+d@;^*a6knLXe-d|&*I6&eus0_Zz1ANSrb!J5V)#iCMJlhFp`orIO+6W zSX4Y=vXJ>c$D9xmnUJ1oC2PMMX)7eOdwEN=%1ZBKh}E*Kf!BHnUNmkchn};|7hd9} zILtio7o1}UhWOqtJg8z4`Ym*$AlI7!k?^pDCj*~POm+Paxby?BkOPjtywX%ldXpgX zp(nU%$R`&j$VFl<>27c{N>G!TQujp~i*FjFS|4R@+q9WvV&U(-;B!Pbd0;?C7$BE8 zG=Vimwt4l>-5qXyWl-774Ixj6figd82Yz}+PG9%qFdS?4)2D}`&6mKuE3UYWCsbS5 zTOf!~7R{Kx5GnF3Rq_PyTav_G*8o9;UFDXJF~5rq=toVT=Ayx^Gp+FcOMBpT(UsjuXof#zv2x(>0~f0?05T z99se~^O<0w#Hx7wDk4 zfW~mrxhchW13#7hHBQy?-^VXJlX~b`dEJQcFZcO0gvp*7ySmP@tA7eIXgaBl0$+|f z%6zfa$upp59Oe5Ukfqrvn7hU^fGhX~&R!{;`+@KI zZIq#;gKCTvRdutGg_PQZt8_0vvH-DklQ|AL&@Lwc{WyL-VsXs_D`49)fD++4(Yr8# z`*X794GZt-I%VLKyS_tImVU{)1GM|4_Z*5~v&%PmVX`=Sv+Y@0Ui2JZpTPVg=P8+U z>2UlL^M~QDgkQZurHu-P#0PG^*ob&M5_~nFNtG2M4mkexTq?4xj17kHDscawY}Dyy zK}cGVh29K9N;0IWv3rc(?GT7mxlK0c{?0sM+5Pz6DE_7(B5xG$&3JG)?-MODI$D0A zIr`k0wDkMZAuby`e#KW@e5Za|@naj^ApHnoG-qMyG?e16Y6y$*d_+^hiZyuVHQ%C& zk@xAr2(YxWf?)Pf_Gu@-60-KJIT!ASsPD%F6)S$8wf(zTQWO1uv=L3Hx5YtXSmuQxu#`&a$o?Na-8||M#x8$ z!Wc>G|DN|#BClWBgq7OJr|Z9PE0kGxlhQEHY}zJV-mjM^2)qVJLyTc>mFMKLr%Rjz zM*y{cV5{~qdO)SrBR~++LAQCek_MHKdVvc29pDQ#H`n?F;JnvzgrQLcWD4v_y!i&v zC#%fPrs;scbVqahy6v1A`mT~3JC#0(W*uT-gUp2e$Y_c9@@Az*$_BrLYMD>}`B(r@P{=M_OvbH8~$o^M>sD3(Br`#s3 z)23LI(r>xObz1~`8rSEQHz@=I;KA0F=Y#U$_zNsiE=G!)?6vgj%*{2j5@B9bTUQrU zRb`KO&3YPYKHLgS2VyH^ZLfm_+s*G1@~y3b^ofmc{@PMWE`u>Tsv8#{MU$Mw3`S-XhA>&qO`Y6s0Xf z4E4?EnXe1_U(Jxl%R~J400-RTtSsT~wzG))PF5&gw}aS|DdT8uLqn{T7aU=m$1N2j zx40R8Z1hN~-zps4PUnS*C*DbjOFekd{!G~GX}03t{DZrzx=C6A(~-K&?Cvo|uoKC{ zjD+rNRrieIzK8XM#$HuWAP*&K zT;O34&wgy|4-@25;=vRj9RQznTGI+U7A6-VGJPJ$lP^97mZ3-xy=tf$;AM|sc54E< z@H_a(ork~G*aE4rZ5V#rIu0bn4phqZh#TJ9E6#h(B1%uU%A0iv5w#z70H+=)-s_!r z@9c&pLAekfHoqze{LOGei7i7<3x9n=9bB3nk<;w{Qn*cCHO^|eyer@#h>Q>~l+2<6 z6y`G@1h%lRSR1*=ftu6)++1AWZCqw1(3O~x%T4dtIrN>$F_WgiB=}p>A*BM<(r7LJ z2KaSk8PWzHh8V9HRH*_XQ!GTErG~N4vB7K=zx%>!HlnkOhA#2CPqQw$19l^L#Q0-> z-{MqOia={ZF6n}jAmz zVb1%T+VDGT8U^jnKN;JI9JXs3PsTU{*G&QdD@d9GH!+V@)vZk;N6{3hQowLRFMx{d zwZ;j6p>N^(% z0MLWpaM!lA*#Hm1(G37;2V9cu@vN^}fB z!j|gkqNL9C&KU;Z?X>J*`r>}}Qd2&`0uga#wyy7E1rYKf1xb^lhhhwpW1z+KN1xi- znL>}+uVdSJa zf4u#5c64-x>07g}H~H1~bhG2=Kff)F*Mx~UK4|i%7_|@E&FVA{qxO7Ml4;lJ85w&| z+s}St!kH!A%QH`G98d{70IlKS z``%jqV1;Cxs);rISeq*Ks%ailjhX$2Vxf+oj{dKvEixg~I!JyhUz2redYWQY?#-hS$#0bk!1dj8sDYM$&$OVcgF{?mB0(ll*dgv~ z!MmCe3mYICUy>+kvQlL7@lnYSCV1#-A3b2$V!fY9#L98a4Ygv-;=Mb%i5nLd40_tC zpX0MNb>$yNEfP$f>+*;53k4F?GCri$cG-yb2h)Gk&tbAbaViuHNWm5oPb(=A#_)ND zAg}X6PYBFugjb1@6614*lm#&3RlVQ`Wg|-9;iJvDB=B{wu`BeRyLU70ao;Ytx$sqh zf(PrRB}WmlvOl5kzCZK4P(1hLF8UZ%cge>5eRA{1qm=4}rzy$s^_vSwCPFfG z+})EGf~I$u1hIGtt1-!KAE1dpGkH!_o_DPJ5pazpHo~vrAm*M60eJsAG-U&nI}YEQ z-d6s57RXd9zZGq8o%dGmDN55HvlsIJ@o~cBri^YXotpQogl3TUIhY1XgJb16j0 zSB3~&$*QLCm-l&`leDx;+Y@uWH)h>zZR$a26&pWJu0KL90v9;_FoP*AP6ZgZ*_RR- zjhCYzEj!W&NdF0m7QyS5EMVe49nYeb?*lN!;#`#_TT@pqDqnr~AqY>b|G_YPu1pvl zng;oI7-HIS7l-k>C;l=vAUR9*LH+*PPL`e|Xv&ed=~j|5S@99N`9u-`_Y8=Zm7M&$ zB%C}ut5tQC%z3(s3uC0e`Rgq*IH=IN{lv{9?v^sk<->S9*`3}M_h!@AOUPHjqP|=B zvVG`RaVkA%vRc6D&dZggj&TGS`5g00k+yS&36MMgLrJ=dG#P9okMxy-Y0I1}XEHG0 z<@(0$C&j7@_wPE!Hb|+ghCQLofAR1ork*!hs2H05v%DLS2;_q8gTAnBo@j-r@C6vM` zqU|3sfBqxS7y&F5%9DroBEt(QQ3ox@d5uNE+_0t|7r;v6L-BC{&CnYtl{GWSdXIcX zX!F473Sw$EN~YTKNQl!tad5y&pF$8#n592ohOtU>P&WYzMX&m>`ms#DPPee8qR+0t z=Hz54WD!U*tEL>VB8MMEa4vkAF;FNgN%rPRa@%ZIK%VXm4z=>dBI(3U=r7JGPim~2 zcLY2fFpAwCl?PRFcdRWn4b2E-w;7|G<=S~;yJt|N#n5B4)Pq{UZQ4c@R2Vxpj+g&i ztjb!>_ltOO<9NRbQ?CPbqnE2#gmkxlFV)fXG@NW!Z{#`~&C|uK+`=sZU*6dC{F0oL zVWx0m!{l|64w_7w>h?R0Y<&72JxZmM9cc?7o2=NXlB=AZI;T&#>#Fq^HUAg*dSbaJ z&>!lvamUd;&c7-&6S((2b#p`HA?+{A7WR?A2|oafLAFhlomlnl`;IZH$%Z~T`T-0K4BXt^>so5E$}-wKD6r|%;AY{?H+2I1PBG5srD`sN z;CDiLLB6EA1BThiL?+!OG-)1N+(D9umsA^{2w|yY9-J4G=HTxC;Fc5UPOiw~qEJMw z%GIx%1D~E@ePRKmKu8Q}3zdiZ$Hgi2+RLeLGGp5r*Ultz><~NgRZp>mJN_}0AuHi`dAj3KHBoO0K zO*Ir>6j!E0I^l)C&V*Y=l5G40*E#9`_iCSgLqRjy8xmoK5^RC~PO8zarV4dw8h+rf z96Y_smlaE){Fd<(y;l%_2$>r?eM1qC5lgV{`CF@Owr36xD|d^A2AR*|OrOsu7cyH~ zk>*Kb;^O$;k#J)YTRMy~afz_*Ym|-(za{V%%VS8ECH{VJc4kpq6J4t{f36qjM|kq~ zukG8OJNy-ztjjI|!eO*<2G6AKMO4^45(nW8gz-W{xkW?_V@gfx{@69fzB69O{m1{K z=_>r1e#7lXgLFuDN_WHPZjhEv>5_&K(%l^bQUcP=MuU`yq(}%zOE+wHzk5ITFWA0s zJaNu>pOgB$NPG3lXaI+P>)@PC0PVhX`jhnO;AXNNyl8wws<(SPv9x;rQf#Ni((bp( zzRrZ$`Xv+>6&9Cvi2RFe%@I&zx#nM7%7*jcJ|lcpr>RB0qIwV?aUNYPra_iFHzf%g>9nRD=i zd6-vY|QQPt}k=ZXRKb*7)9b0a@MeHM4J}@_S%c5s;#z&a1=I^?(;rg2r)^ zTsXhWoG1}Wi0zIR%im8`ItpaG%}-uRBH^X4gum?M9K*9=FpG6_`k9Z~_@kv9Lh@aa=aqS^){ERH3g_Q0ph?db-vrIdOa2nj!+qVR&#@ zmxl5vNDuW~vazQtC#-S9K)w));i-RAFD zhvizDn6Bisz$le8%o;x-}7l(Axlao zIzMSvWzUkP(~qUdY44Fd8NQCi|GCjxnh`E#6)IO*%e@E}z%KJaa}|=o7}OA8f>scq zoUFAcPI32g(zK>4SKBq%G9f8pCZ=47OXFIPtucKU#m2?`vA9b9kty=E4#VW_Of*gJ z_tfWX(WR!is8v^O#@RBNsBl+T1xepsVV_Di4`yL2Rt%V3Bs?Vl*Hsk6{wI-|j89O~ zMKx{NR(HrDVvyy~D+`S&JOmW3*03R3z88|o_3BwjHK`9iqb)t_Kk$HqMJ-kI^61|j zw1?$ThcoarL37jq03+&--CA1y-~e=^{%xV>P0$N68v5e{V$!=@1aBWRZJ_(5_*R3r>wdtP}9pfI6prGE{%VY_Jy>Z8y`co(={`pjgCk7b5PQUQ> z6`}An22cSLR3mM*2p2J~#JTrEnEFPl6ryYEaKApsVt(K7Iu@6D=q}WJdEu(d*0z$! z*H^-jp=@<~&ni=@rMI^bwn3vnhTnFy%kewU0(`+ZhAad%UN5mXP*4E*^HO%Jf!3viA3bezL~q1w6`%PuaUa z?<$L)b&S9C{=XKW2uILNS~*s^R-|C=z1Zf5ttN-~F785_(CA;V7m2JMQm@CG7@nzD@=6QgLg#R5-+VEk+uT8Hi>-w{Vr3(pJdso?WF^EL@-}o zOC8US-*}UC2Vo+7qd=rgP%Z4F!A%0MMd(4^9*OrfoQP(Cgiz;Jkv1Y*VvCGPZVhSb z&DYbI5FRI?^W#=uzYjX>*_`LODXKZKAzv6|ys1PF9^eiaZOs>aL%eolcgE|RbG`!5 zwyAtOXv?p)W05PQjB*QA`u5Y#vjaKTSFr#);hoQ;BAZ@+aM>9=q#1zTsz16iRjhK) zIx}D7BhEizThPl%jt_De);zURNd}}L0OiN0r^SrV7Tl&wKfS1npkgcstlG?Czm;wm zY?@V!96!o&XEdryMdctyNtp-UQQR;309+Z$N^QyTYDzXg)CqdQT6u>dM_sVM1St6H zQ5&u^O_bY^jF6;qUzJ1dec1Q-X;FE3pRnXUgVZP3(yCgo2=hqD9wY~-ir>AefRhyp40Z%4{ z$oa3$^F^r%@}+w3@G)voaRUOQokl+NXvQs}gvtLF8V1%%Hhpm*NcgyF(S<^XR&0DQ zw+5`l=294IfnKIg0&u>jRxz?}aLYw_?h(_MiE7KMhVo<(hl-Ff04T~!v zdRnFMDtBl6=zzu!3fGIGzj0Q~$r-njR8ykGa_1t%01;ITJ6DmEC)*Q!N~w|EM$IqA zEqRonK%9ERhDr+$PhYz%hx#fTST)tN&wNYU9qb(a`Mjj}(6}$d$HJeaK8M?3b6)jd z$Pu0F33I0dt7y+5$Z0m|B4YDJ2+_YaR_Y<3)$(uDI^E1yv^rmwp6~EcnXi-rTp_VJ z;CIV|Bt83&BesKHe|laJ*aJT1FD|w;*8ROSrZQu;^9axjqc}SW?C+Ykz`&LD<7_~_ zB2qL_t%a%;$X*R>K(|B9gbC%N%A5|)x`k!7x?Bec+|E67Z07coiy^&k2J<>aU>u$v zI$Zn#;?IAnq|=(til2OswI#{bdNvC2Xe>qg8V(P8&xOvKTm9FCS$OXhk?1Hg%Ug~= zU%G74+4k1rx*$^b#1JDgk2#W+uqqmgXo}3Yh1yU9+IaMmd26Px>Zzbd4iKwH2wC7u z^S;MxBsq*oI;*dpu~CdP-)%MrLW=_bn&ecoIwB*U^v;GvDF!WFG9N@!?sTzdV}*u> zelhKd+eTi%q#NfayrkD~NKMQFezavnib+q$iu{J`N!0*g^U{0GuZmCg@GfUtT=x9V zyXJkk;e09fxzQ{5?vE{=S1&3Ln-?`HR95fjh>E&DFqiiJ8|Jj^NP6Ee_I<)wu>H$S zLfHHQ5qfwayuTU$fqqXd`P|xjIPU!bexRY+DQTEvJNMAQ_3>SxM!7M8 z-D+=4{o1%j!+MZJ)WadtP2V&fk;hbpt$Rx6HqIw&Lu80A0r=Lg2h>A!dOv;DvPCOBHnM=H$V6u;Lx#r0 zVZX1S3YeJAzebWvxuD-Btann_(JM(Bh{BTl_kmdD{B;2*2I~j*o$QUTs>!t|2*7Y(0SZbF zEZ)1BLxx=nrA)1VxA=VL_IK!N_D@eeyo5OldHQWVc4|tg_<61pWtQXd=rPthtpDs{ zgeY~s*BhCVJCu?G{b{AeBQLm<_HC9JfUccTT07y)~AHf7{+&SOae8geT<`2Kmg-_fs;LZF0okA20uXtO*QvI53 zzl{ctw^ZHu4UwX=vDqLptjgj`PHHSC%)s@MK-&{m63OxBLLHopxkV9$CbQPe>ko!( z#FxYgs3_^rw0YK(nJ292mlgf+30-e8T3TCI*QC`P^+tn9#2oD+`Us83#M724Tq}gQ z;K1&Kr@nPwQ$HAUaHs^0O~UR{iGo^Y{NvZVx7hq`68VR3N1z@9%kQ|iNWK}EargS4 zeKxFT$TX9jOU|9o8e5C&rJg&C?m38g(=Dq22ny=Kq!5byY>{FNQ^)m|>Yvj<<4=ws z`N+AG)=W*lkXmXB@4&ex-#Y7A-SQwd5HmT~j>VSrr230{W*4;S5cWtydhW3dBT`2r z6%a78cd`pR2bCB*1|y&=D#+rl+2%c(w&Vrbi_7dz(bUFl-Jo>Iil0Fg1b>=lb$C7& zR_r~yowy9c$u)oGH($2)buG%FHAc}S;yPAIa%8Q*E$ULveV>Ctc*8Y!lZEv4pl#s| zw?txXt?IzVO%tE6Fan?__7+QckgT#v_pVi_HK;V^%$VDoAXh6m%9KmR17SEnO5Z5S zH!z7B)z3Q#R(!OJ?hk`D^&gWytP6!J>l8YKJR#rTyl1G)Dq(ku$@*K&kY`@aP_h_l z(7*N?BZ0%F?pwTfANgpD-p=ZQzc;8zWsL40@=&aKS`OA~eOjC(3@*L|d9jYLeC*d|*9y#}ZeN?!-KAw~U=$#jTrz|FwVcYVY zM`w;f4ms)b@z)7qUYqH6HUpn=+6Sr$pY0<`9V!NAEMM4vb$Zxekn`*nsfXu~BnAgK zJy{F?qcGe8g*r*d7yh&Q+7!zJKL+{00{8JzfU&Vkw)g_cr+iQ;FOBiNo6>~8BW=Uy zT6;HM)cCSc^*Pg-ddnv?L-T8gnAjBW;TuaUyMQ?J*$N#t#4LKY+(d(K%-{BQSb?(m z*|_c#d(k_QvdKzOIkY3TDw_)&n=r$H$3qwV8B_DeKs2dVCccW1gV_9f42PS^X$oM8 z6ph|!lSb3;nu={TZ>tn8RgB%>AXi&(FJkjEia1B#Hal8ii2+hp-+H! z1ibr-%ocBT>BgHiIt5emky(Web*E=ijNY=7pgjg(n8z-ySJI43##WRTdddBY;!Tb` z4bAf&a0YWK(%%%4gG+199SI{&q9OVKn0uC|NPGAzALS1hvm%fb$kQ>Ttg||I^3Yjn zjMeF(;o5tE6#yH16^Kf5A1sz?+VE`|;!PBMdtx)W+O&0I)E~e1@^1a^r!38Hkxy~E zyBnh#usjq+8YPioijSB{vSdze- z)TmhF!1(mNsal>J1wf1E79;ORmyN-L1B}wAX-84-YmA4G6gg?_ZZZOJig&(Rx34)9 z9fo`)UD@Jgtw^DP3jwfZ>F6gV&a+_<^PtE8tUcr|M*9y!@N!D&Je$I*0?y4dJYs&# zPtPl0_*!!G)Klt6jK*&OeD}<*S##=X8d9a1VNZw_)u$}+UM@XbrUt^;6E0gXTQ5Dl z^~pk9TmrGRj$>4@?7|+)@j%eG%!HvzYqGCC<63`1NLh_!MCWa^qvz$v&fZ$nSp!0U zp+GrJKs((Ocax!{hGxbnGVPq_f_9;6UuC8$JoE{8qp-P-a&Au|aLF__4S;s98`tM}1yi;| znfl=)ch$sTrh7A`+3S>+1X!NZ9TSvx@aG0=Eza4_a%0G=@P}|%R%4?U%jeJJg?R}; z*_AC1^QVWk3ov~B1RDWCC!cIWQtf$ygebYgq|_h9yPhUrT%|>6{8>v87=n%Kaj3cX zpjgOJMfmtPk}1SWQ_)b+>tNcD{rG&-dgUtG?XXlNy8YT8)sI?IoArJa#mcT{)}Llw z(UEVQeE%JkJlA4$WEZ9M{@#yj1yUNqtt?$yVZf)-w3e(kQ*SSLuv_C3?WaHm0)9Z2)$oydhn55#r} z!V5KFcV}_dj)d&2V9CCBHB$rE6Nd?Lx85q(17%xd&dm_aTuZ=(O|(oPJb`z7`P^8F z+4-zeulz}+5}=`><&7wd-g`ZR&JE!GJ~c2jj1 zRVOX+xwRn$&ID9MROgnWvJqqb_iw`X^q!Bf=cmzTwq_#Sr|#Sf@xfWIGIs|Ju`72= znb6eU@sfZ!&$Y?ryFFrbvp3!zogpg3Q$~e}kw(p*<0aeSFW)5YTj4M02JH4@tSscI zgP^^Kdb9JB!SEpOjHdMfWCTR9+xE(0JSLIb*2_O1zTOt=7RyQ?b09(ty0xUOi3$U~hWyx=Fk5LiiN0R;%@L$Cip|AW&=miTQ=!Q}@&6*ZtOChHPN&CtYvs ztzalJfu-%<^U}9XBJn%YO{8kU)r`ICw;xdLI69?udN8myBOitep!|ICq z*f*fL>uW*88Y6wuI5jW&%_&8Xn&au3s##{V!Jpuvf`4#)YVoVM zfaGK=^CPdUv~X-Fi?l(3S;RTb{P3{~yMQ_HbLH$x*|+_i|%i7Jb&c^ zBYBd3173Lc=jH6_UBXACiX9>i4bA#I$fboAA|P{j7meSqkXa6F2gRh&SkEYehD}H< zY9Tf$*CZcY15(&yvXH@Cb(Qo{!;CSXZdVF~UbnLdw&s)21rwl*X0=LK+9T@J>d2-Yu0hN3=H$B$)P3DuW&gI$VE8 z?kJ#q%Hz@D&TS*q;nbVh`-Jif1rwjIe1QpCz3RHgfw{ztiNQ(e`ES+n!g8}GeIW;% zxB1HYy>0AHSiw6>q*e&U$Ip6!$c?(cf6V{NI7VTT2PWv$zF;$eZ6P0iRGJ4rUOuTL zg(ijaouDK5&%?T`gQG8q-?Q~&j*|yO?p!?UQx69;%2yKTCjEi`!iW0iRrmICP$2W2 zPw|4ir~m9bh~|86`{kYRF`bxgyrUMoei_rzGopi37?{`Do}XdEFC9f)S6G~Ozu1-$ zomF`S_)!PdXrD!d{jn%Xz^@Ls#PLrRIrGzdf7*dXZCKyAndq{?ylwfNl5=bXo?u?r zZIQo%-&v~yeNR9I;l!=ymFO~mJPMr^az3RIH2v&GI}E7Krl+PHIbjZUQx$5>ffRDW zb_gCd$NZ(`d>pdyo?#xB8}J(%?~?KJ6_m^cf%`B|wLwdsBci~bVR_~5Lj=<tq%jGuHKWBq)wBg(-> z8T!n%L$)6pR##9#)VGVB7s8DMw<(t?H-=u>S-<)H`MoCMCTrnG3LR@Z-qbf$l0=8> z9;Ke&@1!E@zC_#5YgbXd0aAO3mZi;AtAKYzF`4PKuwB>UBie(a9Hv+?{Jg91BX5qE zyvMmjJZB#lHU4cV`0eWSh4}S+HxS38lXdvL`$3!QBNy!|7T6`3ON!-G2h4ypb^`bl zoJP~hMoHIyp4UKMj66PZ;XJF^{9%-inwr|z*B}cgBk(oCe_k6ZFZ>j1!OMln$N1+v zTxNM!QqhIgB;r;8$d`cxbFDRvgq%CPVRw1Cc_BARHmV8nFjd^wbfm@sDA4n`9UQ7B zhw(F$r1_K=*3w^I%oPGL^T#=!7r&7fp*sk-r{TL7(b>JUsX#BJ%<+%~;LKoUG9mlF z*Xe);S6_esR-08qsxl!FRI(@#0TS zDoeG{{i_}Sl=>Oub2TpBLFoDitU^QiY3EQ>wNW|qELI!}ft%Nzl3j^8XRSe};)ak% zc26I3pBd%A>v?4vg{sh3A0_wn(o@tvBI+r<<}_6#Ffr!&3!NFJ)5ClhKk-m@b;FjK zNN7r;r8lnrQ%RY48)<&udy=B}cb=|<^_a2+WR)u5^0It9j==9azo+x1SuS#zEK{$1 zk;m%{eq{I9Y7L2$nAQ0MdFW+a71tp`IxVFbs0z8ur(0I%*Ej$JbeagR*^4`r*m*YI^rF`qf?bc&$ZIDFNrPg+KOg6oZ>a$bn5{JApMd)S3fY9gv=zV{` z7T2=Wv7cYJ_Yi;<P2dyh=IJI%)dl$5xXMfD>=h03}1!$YEW` zWD{hq5~Y+JUrqb@ZSkK{_@(xJwq*#b97YOmDxZKztOq+=i)D>^$R(otrRgr3g7pV? zUp(?4ypzPP{2&vLIQzQO-Rmu0tiu9+fP#ezs=)hT!D^+hzfs{M!3Z?aQz{oBb#nMy zr{taeFV*>zsAagSs=6~2RQ@4yj9d6$%8o)aJcPSs$tcO@&Wn7PlhM@eKICffx52Td zVS~lYk@{x55!)3H{E|oVehZl{ngN*Y9iNiICib@=$HU?zHy&B}X^wr)-wVnQ&ZdTU8UP58#9i54WDmZArNfx9Y^6**-DC*?={<>V z#>ITl%s@cPFk*xiK}>w;f;E6ViXy+jel!E96or5hKb))(aJV*R$X6VKn_1IZ7FW?s zaogyy|Bw~wROig?AD*7>72VW3&1fo(N2B@b<9sCoX0k_Yo8(0g`stUx-K>sFa+~)3 z(CSDoNcCVkF0Bs@`=UHH&_xqwn{z>pNAT0}{vH&P_Fsz_jZZ~RW8Y!=c8j*eW_8n# zaV~s0g?jzGiU%Jn7RMui^muk1{0gzP=sP|*fTNvQvF9y+OqYd_!!^iuu}3%u;-Cvj z$v0S}VwSiW%+Ppo-shZ6?aUyB$R8le*}?ey4^N`R7c+sxf1E?B^wP~|^~Xf(7tMg1 zfdP06K7NKxlF5rrfvkwLU3x#ldOx2UR;en3XoQIOP<(TyveXq5KFVpdypu%z;Dp2_ zWeh4?b=CC{%&RxFWiD%64(D|p`4gcS^0>3?xmaj1by7}^ph#aA+Y&wte8zN$9H7E` z-4)Cv4|op}WOMw8MYX(GE-8{u#y0M!fwKEM*J8k)l28qd(0j;!wVR|%e0(BcV9}8+ zi_Z{qPuU}(v{j)grQDxVVE#m167*hRz%vi?YWEeh>3|1EleJuEF%QgRC4@fPQXLov zd*7#h!gFT^b{oV86kp^&I7F_t&mpVWC#XGaX5|d=qJ_6UX7O>*VLNx220Spdeo|5I zl6*XXvYC=}rM#U#SAc*w(`9XNpnv_cMa5QSb- z{DiIQ*&SI2zBtf;--L^I_zQaQm!UmW%4TC4h55xGZgHeT@!Y#7yuQPPDa^<;MtMd9 z7oltkuezM8#fvGn2=Hu}RKLwM;QI0koXr}wd#phIuMjRE*gsw%ycv%3rV#@-Az*qBFp*FDN zjdSFIrvnS6>c7VQ-eUEZJ|x|0c%={1j$QjD!JqgCOI*?cB)Dt}uK?YRhHF2`F{KK} z@Ine^R50`E7X=Zt_s)F>(`w|v22JD3`Q`<@|Egh{`uEf|tXc+xB*FW)`Orcq30M7@ zc)WDOgr^1)VWrqx5$OERJQLCF%52VK^H`w9NwZIg!E^ZgEF0;$jEFGtKUiQ{e0(N( zC)S@FHZ})NXO=O5x_0(d5Ddj94421pD02bMDN#59!NO@mv>2~`SrpP+FTkpQ){L0+ zL-$}`Zig&i$;1U>7tqz|d(;Eo+d~6%B)<9hzg6}!K*tnVLgnqCgr2EXXeuCiTeL}@ zYq-Q9T3!J@KG|^irxnTs>~ggrFKVi7h0Q}zHwiP}8U&I#gvo???pYKE;C$CZOn~)# zB-p({m@asraGY0wyy2Cs7;){h_afn4PDfhAYY0F=kt0W^$Hp5v&&jw-;F7m@5OEw+ z@QHUeaPWSsq-rR_&h)dO*vfmqB7oZ*?m@dvLi#T53>|U1t1LY5qjkqFYmvgKf5i8} zX+6RsJ$`!&jH;13LSXN{ShQy#;FmM$o?O!fBihmpxb15{qx&((#=WA}ITU)Q4%2&C z{H7Z#R{xT=?ex2m^RU$J@Fin$=idDqPz!d8IfX>&)XpT#H;LBifxc6^qqH<|Qq8cm z1N&~#sO1diaW%>lmTp)-N{N8b<51FAvj=g%N74;E2mQrv&QQX}9=HU~giwOz=q#EbO7J`rD3q3I)Ks1_Fy z=g>qmv+0Nben`~-2p5n^MyPhY>Z|3(S_J+p=|2MXn1 zOgey|#=St1^Z;LkQ@_+~bl%P*TMkTf(pZ00vF2B6r^uN`j}t#!`AIc}hEDb>;eKH5 z_Vict5a5C8A*AU3hl8*TKLM{EAnv%Ba=|l60h-N`qdUFtq>=0-?4c6Yfkh{kWJd!& zw6~i~j2Eriep^Y1oC!En_yPJhrONbTGPk#%fvMkk(`L?*kdn{4JkDQ+>jr4~gxcJ7et^OMSIJM9FYl~hI?|?BX>)r-94NCM zarXNfEZg{$)d(0XsHZn@p1htBiLT#k_$pVgj2{j2y9f!O_jR`|8Kp8gJ(p~O7@z>d z_yrQnBi_B+R-fG zpoTx}fOh5KPyWucNqpVMx=4_GK)~xa*%oHvF zVdV(a`FHjnb<~UMc@0~(brvB%BO^0*W!9-Xk2~qSXfNs{w`IculDSj{(9Aew#?l1E zb<-*5aS({>s#@(isTOj$0P=1{tSc027J=5QZqDd(r`z@1E`Oqa$NDu{h%#+`q(u_l zV9^oQ{qR%85V@VE8p)58svnz|VI&=)@$fSLO+YQeh>ahEAtDn^Bep!qVUTy5D2d?K zl2TJ!o#w$LXlau?vRj1THfJ!9RdnLK0lp1aY@ey?W8`>wd7%%ErL&(;;fmkiD_kHp zoboQ;QrL6N7=G^<=`R2+`6q48Fp z!qzHP?zS_bX0|U?3Z7un>*&bd4#_B5tXWeru+QYL6*$x_kFckBI~gWobDU^a!bo+~dO zR4OARt*n!pp#&|mR8&UdEeucQdj)F%0Ul_3qUsyb@+8VV%J$NN*Um|JK1RL{mf&jY zzjT8KrgttgT1a0n+ei?w;n96KzQW$b@OhWJ|0YX-?ZvdbZ-up3{gl3N*?XUjMTy!NGAWky^w@r0KCc6w-FXEJ^ zRv)!C-Jm@KqeXrB1>IdipzgEI3uS++yIRKyA4xC8n(uwoFeK1s$ zVc6DA2ipym7V)L!sMOoe@wPvCEj5~tEko`-{@YvA{@L{H?R}JI`hV_b!7Fq!vrpZ}gC4HmH#B9L0*M0Hkv!669m3E{_i?7**NVZj2 zn+>WJpveW>IS2wwddk!}>9E`vS~a!8+x5zPz-^kI4PkVU3ckRsy~JRXzM9g1{~8b0 z?ju?x-al?)uFIdkDBFn_5M&Sgy($L}RRk>?l9AGtV5m^rY?Xv16W!xyfM zHf?PpRz(D!9$(S!?z_B702sST4`+Mre4Llnvj)5c|1q{kP$)>hO@`AB-zUq}j0uPb*_wx?3Y5b~V7)`4a^ar=kYRxcvPd0zBeA)FNTGJ6|N- zP!~;;D~2ls3t>J;u*T!GEAKeoty?q5IP%@5@|m+^%Xa&j)#49e$0_ahKU$D{8Uc|e zJPzhEIbYqw3^7U{BywZ5#>l*^oA(xDMDZltq{bQyl}NeV{a5jY>csJsV^d?iWuY5U zBHusngR~nAhm$jLgfMFmKp@-StLEJ=sxk_8s%hY~&u97`f;EQ6x(#5{Vx?Aco^jV0 zyltcK2h#gLesBeyQhS?amgmPW^QA?j@*?6__-8mVo+&g{34Gy%| zP?p=!=lv7u%EY9`KJFLEYJ2cB9!vG!hYvM-*)VI4!3$?t5KBwzV~xAX6;YT-Xxq9Q z&cR7p*T#+`aOPbnG~A2hPG{T;^tt4;J=U34|RrIn*(%@)2T1{A2ns6pxL} zwxum?qzV>y-(z6&_2oOvT^$IOh{dBtvqK9MOzp-WhZg0bvKJ-=azjDkFoz58P|;Caz6K`LB?eTx`Hdh=yTB=EUe z^SVhax0U-v%n^>K_*WLrR6@OXu|I66V;%XH-8a!^Y26$fTIlAYJFic-3sM8I$rx9#DI0ao*eAd zu7)_Sf)s5(yB1!K_BU@|yThLSzSjwK`w%s(wN)h`-gIEznk>B7af2O+E_R0jfdbY> zgdy35QDTPFY4Ks0Z*`afNMW|GA$;S9E=GJ^0et0gD(PoW1pq4L=gp(o3zucDtZSZX zd0GVbG(WHV`I-OSZ>jqRL%}`qEIST*c;P}bUrF_4=gHyPT129FbpwD>fo|1nbTWN$ z-^Yv$Wh-x{Xv`WcX$4v1Y4axc*@fb$8)RKUC| z*nBq85m{jpyb)pzxJr^^B;ZXMKeTT~RnOtv-rFygcX7`s(;aPmu37}xbFN3*In^RL zN7)83=P=by$jFUpAZRSB+2Gk6nA<9`)xQaM2Ryg^1S3dMc=sc%i6k%d`h;_sapx)$ zj;X1i!OuqV++U}Ltxu3Jpncr0Ws@Vo?hFIZRbnI|f@W#p8LP*rc)TK2`WpmxJf2@%totCmXOo`N zLXC)xeSxYn_{&&M?IA}qEQ?)QGVO-d8%}oItRbU&O?$zXFH~ZzcHYY@raqaNZ>N}$ z(Yl2&yaZWrY^;JFavVL_yyCrFG9KCRpmeX^_Z5z8W@9ApbO}1L07TtJy?c6t8G?77 zyf9?G!C5~*s1!Ad@`{`v;Pc8N^qypxQ=FE4aTP=hIZ~Q2@3NnHP#pNn#58%|E;ILZ zzmX_CcAAm6WPbBMg$!HI95j|#~DgOQ! zM`{+Y2?uq_=$ej@YRG|Bu|S(241*erLU@q@1VqK?-xn5!zhzegN03cet@D#CgONTH zs7@r2Tg2#LB^g)lolcQe@LM@dgNBLt`)O5iH3;cZ1m;ex{vEi7!IEp`@{ z1$snI7`s3f>WsGTF)TcH5r%;o+(7 z@}S5rd?y9YN=0Ep&R?2}_33TB&$|C+=rkH?q&eoe&qe6w*Q&LW0%2h@SZ6EjbRR)w zqYyZe!so;x`@aJ~-H4q6FLDNMuDgzeW?Yng;RV|iTHpFq*fNyXr;ulYO_L*FVPjFa zEUc`nJ%05x7$wT(_}MDiF%z0KfLeX|V74#>`0L@pb8Oi3skcHSlmSa@g)dwHPbL`U zvwtbS8fMdQ7K=WnTFGgDrESKT2Q!Y19F1bM2JO0%TL1`hc`I^Jjt8?ubS3#k1rEL; zgdmH#cM*`mBW=MAJm>SK*_n&>ru7k6Xs}7pzk1QDKg+F^O;Kl{?o!sAxMeP-^=A`5Zwg_Yr51UE*1AaH(@xPIW3IKr0_2f`kFLKI zH}QX87)8+eh(6fr+vU>zB;enN2a#F@D2l2|9m-@MMcU491LSs1XvFtBXASI&Z?9&{ zArKI|;cF$1H%hlGy|8faKI+`((yNsLH;Kg~svYZ(gNliH#r1D~)$PE^v0U?*;lCD5 z+MhiDJ@jyncQUoQkq=+P>Dxcb1J>5x=-oxfo2u39 zTb4>NuL?$38{8wr7+*7hSE$8BmFnl8(CfsjMe*n~{sIq1Dnq2_wzh06{4Y>{j^i>$ zzEC8X~0DjuyV; ziM>N(tk6hply($GcFgYv z=qYB>KvdtKc+!5B;vEaA7gszG5xx7eKu$$vfH@un3wQdpz9XZS{c^Up3I|Y%xHCcR z%?*ryF3+6rCRw}SR4ryb?)-5XN01g=ajFp~S%l}Bg&s2$0#D~xp_QfPW(bF!JT5+J z9k-5Qz^NlLlbW_Epft>V(!e^7_MQ%$7ZQBkFl`i=M|-7q-T^s0vrB1UqyxQ=4+&+dM)5s+T0%y z81|oF%?2DYU;Afwy`)Q>P!&keSU*H3;nSo0503?Zd4kSO2;ap|U>$XrU zNd>a=>vS*oU{7@9cg%+U2PB+po_q-P;@<+7M(cn8jPZGLDQI30IF8|33$o3&~JSF{L?$BpfLlT zF^&&g0Bd|Y$G3+eb!81RLQ?=otrvY^YE9fPhhUR^de_3szUn8|jn_;-d{u4G&e)rW z@Qqb~_^iGEXS@A{jl@+G#)`^GXn8v3QiJi3=L#kiF#{AGgK9hvM`vQ3PjzNDA`1(@ zxIh;VIz62{*I!?sD6rHt>_<&Oq}cjl}nN=>E+fuDAE%f39lDqv`U`&WW7ktq(>qo96R=#1wZO6(YTSV6u`{ zq{CPd5FES{cCUg|Ow{>=Cq(#gTf<>5A=eeOdlTuyXqar@b-CwPbwBH+ivh=#kwQS< z)nwY0gjj%Fo7xRbU5G|EXL4%R@%CKn{mz^M6%=cnJW%)zgS*NRX6<{#0I?sc-;qHx zlBeIW#pAvvZ;~PB=OEzyIp!ABsMc*z`PYw^HDTRv`JINgwlXrK1tpyt+O*4?A2V7r zgnWSn<#B{rA>?S^_1}Km<45RTuP#YF%7i~)5TM1Z?<+M!6v*ffKia)$vH%@aGgSli zB7%n`_>v3Pd9DjJ&VsQZ;-j&!>(IWt&dsR(z@(&P0kIeJ2uKAKKC$iCb*OG>6%-%AKC5y~&+{#yVqfAY5{Z~ZnfWJ! z|HK`C6iZwQ>1^63IpcrnR7JHDBIZN%8*uAF%zNxGMZ#eEi02_qpM!jP+S8*j=&QUC zFScm98Rne{OT;z^cNVbTbg|TWp761{$@cwjnwu{o-)}L35v%8NCs)HC_?r0)0n=pR zrv*tbyrWqpSfkH1n-nWyRwv*%BW?WSNfw2&L9h4|UA(7qJpqFz)qDJexjN+MTFTKsJZgfapif&A3<9|K&!Yyv+j zbv!lM*ZbDH?!76TqBX-VR}Ezo#GbvX6g#zG9zvQdKtJRO`mie#XjHkctu7-o(MPc` zmHOvFwMjb2Eeg`FZAud0;G1CfFEpW1ujH*`@%UCEkF8TcUVYO*0YYIq#zd$5pW=#p z!6dyEIpN~jw-9CG>qk{2B+&OMOjcEyA~LpL2&J#|P1Ew_lt(zxVtSOIqteZd$gt~W z=NCT56zvA$ypgr$F?WVauoSN5TUiMt+?hjNz*57zie31`(=vzQw+HxXL6!Mf6SWaf z+1m-l){+kQ)uEq1iFagK6G?CQM9eg6Y9ml#f4=|(SYV}VIF1Q^#NLGnOeyD*KI_e_8UP9eID{qqCj#K#~qe{tuG zosM7b6&6j~qPQg-!vNGv)P9vTc5FMc-8iTcJ(zBmPiM8;8y|lLP4wwYD}XgYirv;$ z@Kd$ zgXFw0Rb$}!e_F-NWExyLuc;Xt$jbgA1!K^EJi8YfAi+6Bn+F7Zc~7^ zy6iBL!-~TA4Z8AVI9jdVrF(|cXc_H+GS>62T@0$?yzRfVlB&#S%}3WboPm?ad3kxe z!?ZA7ghUSNMWu;k*IcF+uUA`RcQow@X4<^CcM&$zU4)vpfprjgRGd-3&(OBc&REFP zcXYA4r1txElc-%vAsJ#FR&OLitU^^>R}v_nN<{j!%U=rP5n8HGACp{mVoh3Va{XKk z=YKC!b0iJ0i?YnI`jzfGr%!s>o`JLn(vS(f=kCtvq4pz(HmfqUu}Z95!38KmRb;Av zYC16G|7m}NE0NLZ!$b@K3$o^07vaWEC{U**oK`a016~=qf23oqwuDy9S!6#lE^puV zSt9o{V4&%!2ved+-0E$ZHt#X zVv|98y$DLcut_}m)vSfK+pdhSMaD&Mb2{{#j`O>=9Skv$;4h<#*^seGiSjeX(c8~= z9*td$-AB|Qbm;vE@uI2xD7E&-{WGg5$bR6-%0P1AfUlHA<9|}q$pXJ)%x7@Z z?6#;t#k6qy{r^bX3O{Bkt2qjg4N}nE>eOKs}+jpbO@TFmF z%)Ayz=|$Wvd49p(@g2eqFY4{_tlc4Mu7H5V_@a^J%u<7yC)GsY{7St+C818r5O7lO zHwyu&9P=l%i$~y%QWmLBy@-==p`jj~OvU`x?Jti+2jCu7&T=Zpq8OurW6H1{VS@|N zsogzdihxQ+`Yc!4oMOGI?H>$}u3dZ1qtqPuO(>{?iyszVbO|Ad^rj*eu~4o^o6?=w z6Z;AWXnSnVDtuS%{_zo`!ki@^lwEY!L<|%l`0hEDRozt7x>BpZ`htd5^yL`>U5jJ} zOn&xoDs-kflCt)vQN%wn);HuYt3qSS0^08?Oq4J(elh?Q=f%`hjDU<9?o~AaaH6%{tvXQ zzzjhZa%d*VlHBv$yLZp- zp3s{zzNt5rBRgO|aeQ(IBl83(|7tx5(ruw zu~Zj#<$s6VuBoYsw{3xkz`Ko@NIS`xT4@F-6BbbW$gz~9zm_Rn<26l9sTX4sX#J6Y zBtBRtfn=yq_#UK;0{IWz3%BngJHFUi*a)j?_ITq5Mty&?%<6;NwD$OltK&!;U(1yr z(arw+mQHyn+VAs^4Z7K@xahmYIM=O=rWLiadgk*-gRH(kBh>57H~qSYF;2D0P>6j{ zQq~NqGQTKeA#VzVFk#Cdy0+VPrwpqXwza76IR8Zb0$)ZIB!zm*Uf{|CW{fmY0S(aO zpuR}U{J!n@$(6yW!LZF1XPC=JLI&NyEI=Smq7g$b31M^mQcT*Fg~&R zcJruyEEi$NPNAD{YOrs(e1sEqN@qQijeC8qhbt;5Ecn2m)S@u+CzK`kcnuJg`v*oi zVi+e&HAC$Yx4vvH#<^_(;7r7~16h2l?m_>i2kR%NIN1EBRXFI+dQZ0!!=y5#`0;hg zQ>2_=xphfv_ut#%7Zl+ye&OPH-hT+8E(*s_U3Trr(yy?o0D7%Tf%E9l_hhhC?W}M9 zx@^gYO|}9x?Wgj(;nxaAbH&JMhOE({-|7+`6J9{Em3b+C@yFn??a_axl#kae0 zfog4&BPlsZQeUO0vO8W~Rh&u(V~2j}KR2ODV*E0EnC)&lC6@E~6+JtK))Of`QPa_( z4bcbRs&0C${Q~E=E>PETOhmWxZ2h2x&Fq&Q(beY=y$XZ6qptaFAK&V>Yh&8L+ZXt< z-=OxdIx%TTC~(ulk)iLEC*oAlgfgm>BvaiT4@?Z3q}lk2)ezBNlQ*oa2NhH8>BtLr z!h`pK$90@zjJL92mu=S40^jeQA5liXeRyII?eC-_?AELY;MaHd$;z=J{W0YZLq-}R z4Xu zXbR@)3rDbqe?wdA4+^DUx)e21u|X#=tUa$#E$}BM7e_<)ZHH4hot7IptH9(J2|8?0 z0#x)jd0)K;4n&KOg#X+BUUwwr8Wr&HxePuPyAOWlwDqMiid0T9j#nY%XH?P|^D?EL zw|Z#gR8v<+WJ*1z4}g;*rp5fT z95gC~F(5NwJX2(=u-qyOlPnS`)dTGk7(QGB(8smXnu1QrgVFES^n4t-ZGQ6D2*QjJ z`9p(wqw)6PCs)gljYH+h>_*R1^Z9Jj$N$#?Z11T0KW@|6ZTH2HV#M2oh_SsILPVRg zd1gDt10tk2vRqMnBPBo&nOvKo#Cc)3i=?)<0HF$~Z-Fo9{VVix_XB_{rcCL%<1{$6 z*8Xh=15cH{swU4EdUu24+)Rgw?q!MA0H1)s;OeK<-b@yqVeiSeth}NEs=TQ~*&10I zt%8YliH<+yhTi#+(Eq!Fk2}Hn(52bttk{tf5Kjwpq+7pjqOA>V=1pG}VV_hHxM%qz zHTBkro~kgzXAJkdwVQUkQh>HsHd`B^SB^JGXeh_Rr;0{s4444k_sruBh`Vpt~*=`Z|Rx!$)AG*&H>(^AyAd`E?EyMD)j zRKK4b2em_POjkVTA(JAtnS6*Cgty{I>0NJCNjz?=2Mcoip@(nUX#UM{;!EdKH*OX1+7md`;dM`Aec|;<*wDz5FE_`ToBxc|?+4 zMa8?t1by*eN^{b+E{6z3r{e76>puktqf{pybn7=1#i`Q<*u3JBA6D)DJson#KWAu7 ztA)*}JWp@DwnkH1@cDN|<=`g!teJV_?tMk3{Voj|*8Fym8~RyQ+1;pbK?8Nh0?Zm@ zqlUr1=-|N#oyZg|j#*Uuy&-S+>GgJgc-6b6A2!1&3-4m=kjXKEviJI41rxOZDku@V zj7`Q>%?j;Ya$CN%>?yDJXbenLod3{URM6sRsZESW@Yq5>vn{WW9HmBvMV|b$N-y@J zMEqXiZ9%yk4kV8H-|>i$EeU*rFOPfwn%v<5H&X)5U#HE^6!c%ySuY>ISvfoX=--hH zTpc-ia^5iy1YJ#pjwf+9{J5lUvNHcP_j6#cFw%NJ9o~M4U(feT{Z-Ydw?0N7Dv#fWdINd~FUuEcA9)0Kg!kmLXyf_U^w}|krGbb}c-%OMuG}~RTfA4staG8FU zF2(=y{@I_MqlD$?1C0A{_)(j0 zrb(~2;N#3c?`!#Gj;RrQ6vjGAq`r@}Nbk3V1OG8Lo@EPb9R22T|J`@D_9yjq#y`eB zCUnRPj2amZOGR@~!lDg+1WnMjbKxX!f-V2MlhvEG`{!moZ_U}NY>F2kLB6Z$(qFC! zAO5ct&+LoLq7iyWOmLD1-i;hyj38V8)gVS9PVCp*rktsgfB!H5rrFD&7-XabWqDS{ zFwrtR6)O-+jC`_WBnG`p(7%WKx_iz9c4^Hn+W*qEp78EZAk1dWrY4!futg3yj%#b@(_g; zs`@B@uQ!9LW|W%{2i%7PcigjXcg^p#3u`>DEC57m>O;}GWV@04ugzz_m*(`h^xd?$ zr~E&vxpqy4;gCA)_3(0dZrrcpl{IZuOK}?n6$Q=AXmr&EfN#$ji@@s<%n2~~&7m1P zt~CxWe=zcgUgOL|1R@CB^!49C-YB0Z}1qSTi!3o*^(A{340l28s6$ zEIu#qsLB^xfPz4ZeX6h980TsuP?VUue@YuA^(?69k)kAsA*G<8=lUVd%+7Ao>}7|^ zUo6FoO;N3gVd;eGmg5&)G?>d^q0{d<{FJf)$#$a3${*g;tOe4j45+#CeSoVJMgMZ? zAbBU)@g-$U-q7dyf!kGsJ=@Qlj27Zc<}ZXz&ldm>v{n=)B1VUFc#z!c4<+z|w0YVo zVmgofR6C5;#7IWFD&*TUcmPHm{7mqx^4kI~P%8*u@4DRs$A?q_$}5^pZbi1ELUHr_ z*XEM;Nb!>$mFQSIa%8J*rEvph$8GQHjTRTJYBAdRG-$dPCMzE|zP7I0wyVcealhF< zW=3^g{44tJf_iBp-qE^`iPFKIbaz${ZugHZ!d8O}Gc$#~vEf{c^Dw+Bh)DMKBYi)? zH~1NO!qhz-Rd1`e<6CJ;t23q%rw`I6liOdmO1S91KQr$J*crX)G^BEX|2WDw5ADgF5-ryRoShy|Y56Kqz*Fn;@RhM{Z=ewQO(4d3L6@XCGbzYnR;Ru1yUEFa#{_~GDdGi{7UfPC6${4k+_6{#6d zB^NZUyX(sG-b0-!hAm(cE=hx=-V#37j)Q*Nj*Gt0;>J$00-s?zI+BPu9uwIYKWtMH z9D%KVT95g4(oW@4l)rzJo=yw`eJE5ir=K>2o_Wys9YTI+%(!=<+S8jDJlj&oeH?k= z1O*6_kI>m#2>k!vNJ1(2>`*&bk` z%Sxax%T4=ElKcWR7OXrJJfC@I9*Z_c1GC%c(cW!GJKpcFzhgMR1B=>@!Vu7`2am4r z3l5drq79wa4xdgL<5V&xTk_YXtMN_h?6d~zV3$88$;XvRrp?N)m0nuo0bBVm z?3fMgx%E3YZEXZej-+*9U!No1qiIz0xGB5xGW%3>@S9n4cHaMoMb&l^}Eg=y%GRd-)0q6o$V-PlFBQSz`GqK zCLMEk;Dh}<7UX64;RC@Gk9H5{_Pa^^8z;QJpWFZ?eq1ZcWv=NR7) zOiT=m0UL{6@MW)C_~e-@-|q_8eVj-vX0F;RB63>FuGjNb@*shMR~bC@Wwe^EYc#x8 zb3cuy@0mHId*GTuAC>Ng8*K5OGhAHFP+@cB%^-$OC^BHL+i|T#4r0eL$Fk;Ot)BS2 zxZ;O?A!cjN!h>YP_}_#uME8fKHest%R;5H+DN0?1VL6$Nls-bTx)~H)(@ZjogCEsf z>n4N81#cVHLYREtx8%Ni(kqo$VO5BFNMlv%%lVoh$g-bUD_Fq>PYdy3h;?ELdFR?f zfrfW!G1pbk1Gz&k?qZMKbyrp-weO{6Zfy1&VQe9&Yr zBt5Q;5R^&FCRKj_OsJtCfv%;Bk(9VRjY8&+*Q-s@AFfbW>M0m&&h%rE1HqD^jRgpE zC>1G}L1D=5D4`Czb%3P7D`guTS7V~wmKF-SyNRNW%$HJb+?N;$mJG!kx$W{2;c2^M zhZHD(@c;ghGN;G7A8qz5^*w0<&-OhRe&67m zE5t3sfVcPj_jI;*X1+KsEP;GLyfKGs*f|6#`Js?9Rjyf=x-&Dfmpsqo!$j34W;~E_ zS;xuEtz9>nKA0C*q4@)a5&d)plh!woFMItb&Bc;!e!xMPQqxbXr~9k_BoR1A z7`HHH3KLt!=t-LY{^=7L`ismjLG)H!0ZRtzmPf%QN>r-&16dmO%i>A3){I;fdn~}@ z`uPU66H*V~e5NK-tP;*a9v)9M+XU+`{ zGY8w5w<8_<0C=SkWttF?PQMW(t0|HVi^JzY6OT2D1xO{yT^Bm7&j!fEYf|2@)?5bR zIFERltdjpl_dy4XSc}Mn^abm$Ji6E4PDA`{xETpCGCy4#`OJ%`o*ku_mO5tOQ6Qto zO@wJ|2txaN+tA{$JIC!LVVh_*NDx3a*{P1O$B#MLY^(*9k@`S27G?Pk7Z-b@QBTOi z%bMKT&IEe=YIwrLEaVs6XUd0I>@XE22KZpE-;0P>>eypF%^0cS+sG+sM39a6x_2vz zwOAGDLd;tqg#|d%+IByo7U=&YD#0$)az$&g-UpkX254H%|15VAlzxRG{uT@z0jiR- z#U>kLATT|c-VM$E?6stL-)YbAvX(o$&%Ez2Y~gNy{h1JFTMlLNc0rK zsxmniZr|o-40Sx^t~q&jyA(xaiog75YG@KdGItE!%~Q&(7=*^7#49olgXQ+wvX-Wh z`jprbYq{8yF+bx`cYeQEb|3hTg!|>!ajPmZ8s_6tnKfaV*H>M1?EJW*w9`l`7)g-0 zP0Kel0^ZTl(c7sV2+(07=e}P{NX-vJM-L14K$)cgkmjI^!f_VrKZ;7 zGW4IR3knMM4L|aHPT`QZawcr53LtC?kD~}OQ|M`aD?7)061KP8uO4U2WTj~jpV0Ot zasUSOt2$z~nNbFqX7j;w?$-G9NwvkKS-Quw3&hTQ(#LO9XZeGL-$bn+6QWNeg|Wk` zLXW}oy*f2Vuo}Vk;IYN3ec^xNGh>SQ?+5=sz0X(#C4N(OC)&a=w4*bL*WLx?uO~KlUeTW$=@vY?NIBW)r zxV$`H)Gw3K>KTHYVPx;oFS&_=nZC=ZvlTr$${6Qr{Wj5MAR-y)vZT#sQydae6wT`E zB{PLqUoQ^Ou92`Yy<&;Blwy2IuY0s5&OO>u3IdIiz@p#h__(_-dy=M*$A|=-OSzd# zx%}RQ=f{s*9iK-{w%KDiB)YG7z&}%qe_l!8bNLhENL*(JsUq&cn#RNNh-La+sCTF% zg;1bq`G&xNk}lGqoqrKdDYdRgha<+SLDj6B+AD={b)lg5R4^fFXgM`YC-io?*_VuV z`IJG_wkh}Nr>B-!1yzQSYagQR5i>bSfC4TQ%YEOB1kk4J#wJb8ngUC|OMiUKAIhl~ z2?6Cg>bBf<$y&C&^n073v5CMM($1zdDm%O?J3nflpH2f0gf*<6`a`bLRG2n>xsFZS zC?zfT<3@X?vIU(MJ%RR;8Zy2%9WdDKME;nRSuS0RtwfCw>JqY8@%+gw%12Sw|zMQ1THSbz26E{?ClTy&dK#o`AH@K(9)j8 zvr(n`)Lx3vKzvwDat#mZ8*y62lQoIvgD;1ht+cz@Pwy`|OhOC0-KNv~-T&OW6`n>_ zkw@#DvA?poPkG{giq=ZeJ!3~Hh60NAEo$l@Ilah&T_WV$Bwa~UyHJ$eAt~^W9Z_Cb zx{W7&gAi16PnKNR(7F0HJBqCFxVM#AFh9VSNHirgvQNh ziS}0v#2ZU8xajZQ`!vn*S0?QZmG@yz&&yiyK#Wkj|9-nv?Y{|Ap!_*OBg(&JL8;*|J=ge$T{7fngQsZ2wcug2(Z0IaB0zZoWNKWmj0mDugtTAQ%`0=Oq>BZzz&d zNA`giU@+^{G;vMLg*2k>M$QcPLr$TW-_)$uL{8*CX$pPq1?#WfkSp}@Mri*ohNs>~ zarP%I!-}04Ih8rIT+rD@bJX_-2cg+bMtng{UhhP}wb~n_EjBR})q<3WxN*U|eMMpn z6lB@Fht`Cf$b2DFFfp>z;&Qm(+!JPf`r%~DDK@_sN7q`L-`RA|GqPeFtzMuT2AJ?n z_&m%Kh8!`~YJs_g!2%il`ORCo4DPl{u>%p{9^Xjz7@%8>8kYJ@p<(ue9MED5yMzGR zOtsI0ODXTtn73r&Jvd0aL+~V_+I0~x>jX0eU2$Wvv0oUlP|kF?($HbzUj8j->UL;) zZqR+#y-KM3l(FUP008e^CN6!&(+EZ3F3_paO1`GHeUL?jFD@+l;SZDj+&0WdqQ(|l z^Lgpfl3APC;}TRxJas@!7>P`HMo!I4N=%*L0(63tklXBBh%z-w&hm!2euRHC zHU!>83_zt+M5fpv=#Rg)l)ZC)?8d#c;?YRrC-Qx+OADD7Y>WPN+>A4rZtRtHK|6AC z+_hkcD)hAFZtWprSx5D=gA_|^bZP#nhd)=1$h_ws4M$Dq>_y%cB_@4@$xc(QeBaj0 z!-IOfVt-<=E|KhNuC@B18K!p;5IQkmYVDwY|GCT@3mr=LD4zxpVf(!8Gq+o} zSh?HSPMb6gkG)f!m}ntKWOX*553#%NpT6MqZfX>ak*y2$Z--jeae$A|v7ohP<&^9_ ze~U5K)vz)r?$LsIH-P8UZ8~|=w#%n*`M%(ze2hv6{pC}?>>=XBw!Ep%T4+9_utrSA zjp3VIGK}JE3lBo)_I!zH##>C#;^5h&VgBT~{cTKTc2+0t8LgNQ$i?g^AOEhFrd$t9 z<`d_gGhcS3@1wrVZ2@0)NQ9$x2H-h++HU(e;a;Dt$A!}cl4o9+hyOA(x0xwK+!I%} z4b_g+P?24LbuvFBWI$TmKM5sGsD@}AexH*oE()F62QHxu#k~LveJ)I9|HMvifF<2S z7T_2@vYI^8dOetF>hj+~E#OfpZZ2GmX}IlP{oC2bxAEzc6S`wy@CjO@6O0OF{i zE3<6aeG|zOMjtm*C7gIgg`xt%EhKz1iD&Dkw{zTK`Ocz zVX32B@!iW>sJ9c+Jr;9EDYS9OB|=6CZU(J<#e;EG|H zqo--zCGtzN`IN#a@sM?ky1(C}@0qN2O;cs}gxu7~sGAaf9&0DR_$BIo>L!Jdhf1jQ zGQ3?Qg;%>8dd^9evnb)y=RN6pOYKB4B{3GU&(fW_>R4Pl&a6%7N_RJ)?sGx$onD%# zLcyy927rhJ)FGB-wK zd3NuauP?7RtIZ_C5aG)}k~5hU>j>+p8BRP#dBVe&4I$}t&}CBc$-@_V!aZp+C7q(h zK%Oe(fdDgB$Q7dD0OdNW;04>dQQQ#dXVgR88a8!=4b+67<;=M#@t-mIsS%H3#)(n* zk}h@D>c!+r1M$n31-FCA2A1>HrkItU>xy|=a)`QbVNmsYgC?S9JaZq{w=Gu%i5D2& zNX8nVT?!js3y@s%UGoL3SW<>q9Bd%Wjn5=kCp}8v&lz!PL?h7VC7}sAXiarA5;T0L zU5x<>8+{v~%@r zW`IqaP+y_f_c}mh^9GOYA)>V}p-!uY z*G3h?Ujb5>HP~Mr!$=0ID3ez~$9y60Nig6kfv1QXUVDDrpww%Xwmch?a$Gd9d(nLV zx1!eb;UhPyFb`Uh2Su1AM)FrIN-73;B|VgFUD+7kd1qmQ3;c<_4)!DQ-%-txS9j)A zDdPQFlwgU%{PUUhY8-qhmHSL|DuMTD)fbK2lRGUvYDdC(p&rhC9u~Y-LP}P8KnWd8 zaX6--4R#6z{QM8s(T}qS?&02sIj-6nQ^3Ym9iX6vk>xLmasO4TN6?XvErLNtbp;`& z^|77i8aYYBK&-M&32uc!O&@}>0wH7ZusS5n53mJA=BnhbB+1!$AGE$Mx?P0^DSL2*ra0az(T@?w z^N2oCf}L<#G2E@xV#D)~hscWW!@q^cr3(AZ#h~n+6KMlGs_cL>y~=>U zVdg?SHf7&~7iaIs)%MC&;8b_pgxK~f*~YvcBVie`7_4`{9<_YchgSPa*rIt$QjW%#XNjtppMT`!*r#~^f z8e@bt9z0H={~ivhb3P=6qFssD#{>ktKebnse_vlZWpJng;Y$9rd+Or0-fz(HC|{`k z0WlhjSarv|oBMSsp~LWlP#J{c7XjIsB7*q|$EAinInL!0R)j6jM9O>GZMBU0_1qKF zvuW4WEm6*J!YB4>kR)1Z%eHD9o>WgI2o};U4?X{afPyS71*i;9*`Bp_mt6UbqLX2~ zu|5=2nwKI-%g6bj1agzMg53jkbn)KSz_*vpS99++eXAGPrL9p4r``sJ!f4I8v$8($)f62Vk1 zw<3)$zBruDriO02ViU7GXjFpj5sE_X;Pn_x{15*e_1p2c+RIidFln~ak&}XuA7vi4 zfzssHm5JO*F@_9@wb#W;iM`PB5QZpkwMV%2Z8)oWC;|5hZz;Ien+&iCF1*s*{nm&V zN=vK+>M<0IqB{Nz^!n4TuCCgfd2nSKQa7!C#%gp5j3Hj+;m|FhD?GR9yPw{N$OTC^ zGlgjW3gh{6|7qKk4$eI$vB%-l9%qtQ`jzM|`|ZU#HD2O98Hw=pAhJnQu-Hj6jT<%g z{6{MzO|k3alYS*ZG-olh@uNMKs~UzUP9ELHe5qpU-K8Z4PuccZwVDHOVF3`V&on5U*N6RQgs2#ft9ejrLy-_npM*zVWq25212p z`ysB=;$yn`m;A~tInF}(2W%jh$4k0dP(%>{`h-V1bNmlHBl@>NS7z7&@Y#=#^}C3< zXjeH(J!kvfc$*WOZ^%_Y0m)hNQ0E z_ID1htM*jj>;MJ|)JMPr^W01?jGEK+EbsWFp`#?ZB^8lY3KPcFT0N>6pSGj31(VYK zHbj(7AWv8SjkMSoj~G&q%!QeEKn*!i0XGTF85DFdRAmQKd|b~D*=>v^Nkb7(R%GvUl=QCy)gUkCi+>rh_ ztIkIk4)H^V!l?$I$I0;j7@u1WObvz)hXPMUn}>Ld0&+nu_tLdos#ZuW)KU>A{#RJS z&V!cC)l|B#I8xu9iPuR5edn?(dA1qKDSZCqvL4${=SRHb^D;9<J;x1%tAH4v$|0a@<$62~W>BMl)kENH!HMHYrq{STQPSI}c)@As z-tP%$=GY^f8?;!cvljXJ1;YK`&U-Md0jmvcmJ}63@AWsgGbhi2DIDo>MXI~qucPx! z$~Jmw&?Y{4k^AA&k|_L^zt&oB7q>2e_qNPD?fP-`UArp0G3AuJIM4(G9(S_%cV_OJ z7>DaO0i*Xq58Z{&I)li(-`}pdKR9n_fWvlCggpb%8jp^84Y_LSxr*~ka)%0^ot?^h zv&w5eN!$urK4pB#5bQ3V-{ME2U;1MR*nbVje6*L&4SF9S+Tu*gEYm*+D~!jzkRTiX z-H645I+8ve>%VG(2$-frOil?t)W7tBrt>>YeIOtv=LS_1U}=>n>FIi$)(6u)vIFVz9f$mrBr zkHgIuo^5Vy7+>7ClY$!bt)`DSGo%wO{AKpb-_?NDh>GHnr;l*FPU(00WrB=lIn$SY z5Kl)`KADS-$Yyoi^3|y^xJ7u|VH!9OE5QtVvSbh3T8P z%^lpXuHVu7uPbup;4#2W$+!mPa-W3X&Oms-!4eO1V6imIZ>yaZr;k4V6r8ghy(jD5 zSVpXo#?3U1mU_qlt>I`)gZeIx&@Re%#pyZ7m0$x1IvF~|jD{SeYA@|;5(oxhJzF4y z@fWKgNiPF{ocsbg`3Qs5h{3nmUi{ckB~K+)`jotJQ;l@I{Rhp7_yfNaS1P_(dOwcP z3iSH=BgeZ&Y98h<*1;i&yCQxwQt(6KLtyF<38Tsmy#_rk(YHkllDZqSbK1uPJINrp zkvE=$@lw3KJ;_hFFqTp+{KxVP&j8Y<-FKol`FSMNuq{t6xx-A{nc~FegKRW+MEn2E zV8&$*E~cz46EaBjpQG7zbV##xTK;qLmf{936zqxHJl@%Zk@;W_#s<#Q0MH9A{Pl}D z^lYt3h4pVjWkCYYry4d`{W*h%--zxg!L1^`)x_YUAe?Ka1g_%a@b_k)kdWIHlG$~3*DllaG zqL!Xqgk>a{PFQ6lyI2abGIjiFCP`LJCz3rq2miDD6U%&xD46|lOfKcKAfT*y{wAy_ z&*%WW@s=_=%3NB4Wr8r1@%@RY7jZy%thw?hv?0C}fa8l}O&ckKa}MGl$y7rv3u+Kx zkl-e8qC0AJi6_wF$fIWuj)Y2caT@iVj

fBM@8ku^-6_C)%n7DkyysFxE)b9hmoRg3Iw;EzFBjs*!qD-PaEQNjkzrbQrX%Kl z9%!$=6;Nj>#-Jc3JkU~8Y;>l;(ftR z8j_zDtwmfBksW3i4@=toI4`)Qp~&9+$8U=K5?H*5(7XIKY!_Vh#RRIqvWR0I0+|DP z%}fgi@4jdkVFTV2FOYW|Sv*H&iw=_|69VWj4Ux{3R`BxNrT1iYc@9Q*PfDt#FMI*i zM->XI2eUVhRua#bn$P4b+XK77unv{5l*g+#(4m4EDfK&5Cc;y3vZnP`%oY>eq7?c4 zV<$zf)Nb})*Wn&&eM-^Y;54Whvfk#yk|FsQUGz0wzMSUNA@zi3MeD57YAR(nAF7*%LMGwZgio%zBx* z+VH~~Tgc1))H%*`t$0nV-wqkH2g@-mur)KGxDniLM>&N3px3H1loh8Xn?<7G4i6Hk z+i)T8?uVSb^tn8{YTjA%RuUMK%g@tW35h_$Z^SUrh4+}^j=B4|kwZSsj&E}3GX5oG zdF5E-^5&4ua**Iq)5yGdef~2a@3QP8sXScFA|>1lgbbop3FO;O*9O|!#2-g|#Ow4& zO$!02uIzodtc6Qpw)SsJ+P5~vy~J8OSX*ymo52G$B$&y=x1@cru-7?~T_EyIY1D{2 z!e;D8SQg!*N=4LZ4-^kHp;pcB%kmp{j~dZ{-XQ(ad~OB_{a(e1fK3CtMOUulcg#{I zcTXXraGp-mJ~#O5Idgb>fLlf@cY!k(rQ>w-&Dq{Y%dECbj3MB1`y}CTNuEnD`;ZZ> zf?hdesH(4#!Gzd3bdFGRdiwLi4JaBc%)Yj7$Zhcz@0yAi zP)?E(0`l(@qvJX^jOY%2>+r(RqJ1rGzu3psf*AF8d~ef@*4XX7#7q1pg4}*nbw6DU<)dGgr>)f&Lrwhc6(|~lNvO0bgF<&U2L9l|F$txw{x5DC? zf7qM{WbZP{x zonIFarANmLztArU>lN4jx(<9Y9tp3hvAK8)!q^fl7u4JjxqkOg%0#s{u`?ms@L540 zdZN$Wcp@-UJbk;?^h}6rh0qNJy{jQSdf?%@iYr~0`mSbvvbNg1cP!RP=pE6N^`-Y> z>9ngt%+1R_iN&ouS=o{)w{4G5D5wVh-G$sn_}~eLH#;-BjpCLp7{p6fe0pCoR}7L) zE@r~gI~MmhU@LLcChSPc<1e3_olFA~NwI=}0TE);43Xnygx)N6^`W+~g68a+4{C@x z|K5*N(0K_NHDUxRj6mcwvopDkg63dEbNy?PdBv1}T|_=UbvrYe*@Wc17+sH9;2j?e z_K~7RbBE~HIg_NsLb1{3`m{KL;jh_(`=yV9td!wHnKR-^-ADjYP_;%A;ckP$i!N@ZwLY~8F4E3AGz+P_cLP!odeRw zM;okA=P}7tsv$xvvZ(O0*N~{|Ye8aF8-iPdYL%zu$7i0c8!1WQi2nqd8XOpN?Zi>P z#3nwK(!IN(;jQ#5&{t-R|897<67RX|7{ZBy0-_wq-&XCTqqkCAudAFs5X1p~3Pvhh z;h^gZax^uAz1WQXs!+;f>gfl9f9yPL;UvbZtn5lcnVz?OPg9G_TT zuHZ$|9z=F>FnmztJgreLC4rf+C8Y(}yLA&>5-kxDMrVD2aDo zLjp)T)ATThp|en~$~HkXc>~;U5gwzj3PZZwxYANOL~btWN?F;xsS#P6 z1)(e7ByLywrK0g5r@Xh>adm2>ufAQJ++{C8S$^YGx2xVg$=Bsr^9EVIh+EcQjYg>^~jR z^K-Y1t+eiD6pxL*`}J*_+3iS8 zZe-qWs86s&k#Yk^p;#bj^e=Zce>9P>5u$is`Y}F|rdC}6E%LzFXQt0^>XeJVEV0>u zdy87SX|u%LWK8nq8%kS#p{;iiZxk4L-w&fda$^XadHHqtZ?eBPsY7O@56Xz6+!S$? zf5wWXl>poAGK?JT%ZXBSx0VQXdSA6ESDt@8YT8`B)~LOG^7a+Ry?Si~sIE_+O~tCe zgX=Bx1Ki7zKLG84Qsuvij%n3^XkE8CnX>nXB5uxHV5&x8qCsDMI8`j6rBs)#89qox zU?ttZ;)~cJVuOM}m4V$p=JIDhZ*TWpM_MMRB3Y=N)3yJn_; zcqXm2ZV&*-)2dx3tePZ%6 z5c_c4hURy3Ec3eotA3YL?jf3~GT>aEII35A&~trZZa#k_@=zP~sq?1%{z;vl+vsnO zBg}>HYoPI+BclEmmgI=~kwJgoex)d?O!B8)@NZGPzlXj>{UW9C2;WbW4 z*M(;)gwX7vi}|f^BVO3{)1;(WGHIba%i+cdKJca2wtl0^2~_m8YK|72$f8B+-^{wW zg{S4g2j+>SUfOHr0YLh4-DmPd?{y{KuU7qA)5*FfR^RP$FtJ*^!~4{5SGDuCireRg zrtfE>kByHoP?AFI#)H8lD_8qI7y-pMCwX>mZhk|rYlAy4-KP_X6KVGVmQ;r&@Dbvk4C%iO=S_^&mb1Y zq2K-)G5g^+RUI;ak?iA_(77qL@x@?paswTU4@q)0CmRhi?B-=dvm&3-%FRAs+Vm83 z@q+XPkEi6vleL(frz5)o>%L$Kq@F$*?*;+;(i-^yQ_h4)Va#3zkCxv{GSPiV0Lc6H z=_HWIj>`zDwr-nL-%a#sHv%A4X9=$@N#(JlI8zV5mw!#{hjG(iQU=!a0uZ=l$Nd|(F^57l#SNe zQoYy^0_7v3rD00qQpK6S2SEz0G1jQoY5>_DL1DnrK#X#cmR%rwsQ18Kb-ev()WLG zOx!3}-(3}=6XiasEBF{7(M>xisM9eoMV&9P^gX&Q5CW zb&x>BJb%9X^P=I*EMhPEWHG!JqM#@BKbo$>E6Ok0&M>5OcOxLEv@}BrNFxX+NJz*J zkVcvr8YGo&5b0Jrhn5Bv>5xWZ=$v?;Z@u>iuofK7x9>Uo?z^{2kJG(Xb))(Hui7wi zG{%37rqsje@>}X{bK+3L1=KwoAH=u7>xQT5VEfs5j7B2D4P7Smu+2&?jsWLZK+|$d zOH>y(#P|5*?X+||ttZ_>6@NAQCYR+8PBpFgnc8YZVO}y3ZEdf_f6WvY){v2q%saDX z23owk?}(50*j$*s*`gW8q7`0`t_^8Vede{;wLjyco30&xV;f%aCoS{YL*-#owO3$$381spci+0rQ%aMn5jKzDexh zt&I4u*`6JiOl`V(=f}~HAIBCbuHX7%?;{6NvB#2Sn`%kY4PqL2GJh_4JrJc85BkR6 zY`wTx)s45Wq4JzBlL7s;jiqI&PwQ)bcWs4oslgmwgU)eRviTENug$;U!;5(p8F+g> z%6_F!9izZtWKGtV=`C?*FNDSAn2hc!Ta>M%Ml6G(47N?u&@1&pf=4ayXxGcdU(w|! zK3(>7FT?V)!GdEyNQdscbXV!X>EMTq%L5bVB#$56>GU#UA=DYkm&oat#>jV*> z)N3Zb^+U=E6p6WNo>O!D6%bZ}J4s8L7A#(}_5#nRKHC@*+Y6a~IFIw2`)WsQTxA;K z%nRY;RaDdg;bbxWoi?>3m^~BD8t2R&=M)ly1PZ|cj}K8x%#WRu>e^tU;=;b~?h$7XW-EDVwJf#bxvM9iZ8>4HLg3Bt{|XJ^uNHu>PkRvLrl5q?rjb=1 zv=Qx|R&HI~W@O&Unm+RejmFKM%9PYXQ83iqW3r1P;i)L0;8UCHAM^^u6Vj3DYGKzb zv!oAUH3aB#B<>502+tdlgN0T|rArsli7iugtdOFf310#k%g{opWh7r}_xRst0T^d~ zhyLYM9PguV&%oeZ(wPtM4Ypuke__S>%N9x`A^x3@ru_d(M?I#%Ss)EX(=g+M*WxNk z?OT@kaz?3xgmIlzjszdCh-Ae&s+3Ob08jB+$f6cV^W2^H<#7k|2ap{|9JekK2@~IS^(IN*{b4d zk4noKCaUKR(HFCA?WvC&547!3zCUF|SDVeVl?Xw%EE@tbF-w#)aRDXrMZeB#83}!f zvv5E3oE1Ey2Ps~-dsk+Pz)c{pztr|gP`{clA*-tu+!&23^+@JuL^t{ib-ZmPz{hKj zgR2XUT7&7&gUC|8seEUfi#$uqPe2Bq)dFv^gym!+ox3P#?kM+y6;ARENAt@Ix*66_ zq~0GcguIZfR+Y;fjQjamQEyg`Bry))UU&W&3w#LrMSPPH9Nagj-_DcO4vze=`f4Zt z)g2F=;$3zLW;F@;LV16deN`78W-#4s2{b7HhXa{4-P)f`ctJQQ5bm`?i~hAEpNudm zuErlq-5nxD_)3KgK3t3h4_tr4?s}kw$Te%ZyHk7NA*BlI!E3Z2t$dL9{RTfW zbmKaMjYnrJ>k=W}NcD&OS3b8=S)s4*YIeyvlr6d&E+yIsd>tjYTI`6wf#M1yGq4Q? z`LIo)g$#zo(sL@E-;vlypY;t-A-ws+=x?w`*ke#1fd(&}+nTW=3M$=qUJ0)y96 zPZjwZ%y9ST@_KNlGnq}MIimkrH&$u{x-Atww64LkKG$d?YrGuDO;t`~pBv2C*1m1+ z{4i`L@ttbxb28e7x4%y%=hYz;ZoLd{pU>mvV2|)ejL!+8g)4uXR{r-F`vqW6*SwpC zTXA}?XmagzeHjV#ABiE#sD&SM(f`VEtsK{Zc=h|4`IB26QZrABRML8;=fn(749s-~ zNCuxK=dbO4EGm@c$W;ysdX&Y)Jf&|L^_ftHX%s&@-l(HM4X!PnC0#@-iMo==fHt#c zLd?R>5k&M3DMU%Vf^w?3qTdXvwCQV%KNy>^yps1KCCs49IeBH!QL;YUeKpJ5a)P^% z?LDc)3X&&Av{2heSjQdVVvBtz<@(zaKu{&2OBpGWz}#X>uZB~ zOTC`K_??j`W)M8Xuo&BLA}*vkxM)-*JcJv`1tij@`W1%Z()o!i!EwSjTk&=K&!&Dz z!qXxmPM1Xo$(+MXMmD;GZ@F`VwmpmlXj#~q)XL3&kDxTWVZPNIvz8CArX;nUZA8u0 zZFn(8OssD$;__-9+YWwhIV&UusJf4j22-nIzTCzap}62V z&EW*dHoV4iT;OkdTAY+=t8Un%{m5C(_Q4C#uXQ#4a8kj9nDMt6zPhws4~}OB7+!My zl_fQJw9d)3>hvn<#cM*t(&^OC44}VkbuatJN{+{``gRt)o$oC*tW}N?53=lEaB(2& zTDVuWLTud9{B^Ojx5J(vr2%sXYZB;nJ97Q27K|C-+}5szKNNdt+%Z#PpKP&vvUHsH zp0(^uEPkvgSGj6Ux3bogR8t#ryA#U4r-@qF3>)V4r@=Kc#N_eTa#fYw-%Vup09X<} zvA0>b&_-ag&2fgs~MZ~RI= zw9SiZIX0~TeSY?FeCwo$9ZfMQf5#$40f!siBmLKSj;e-+kkbgRNVP#4>VhS3@UdCC zklBaEtEEueI8IM1<|RM`tB;Ao`DwIWxGSFW$VAW5k4<@-}H-D`!MwMKmk zqd+I{oAqzn%h1-<)&BRNn%~vXGG_3u@K`0Zn0!xHPpvFUBB9f)PN?0c(#e&BXwW93E|@n$+}Uyu0( zh79t=#rNJ7cHQF3e)g2-k!xY8)8hm-=KjO|Jk@6cut}qJ9%6X5haK0J&;}s9OJ+O~ z+RXoQS8l-bme^Xm@0l{+FYyc5*MD`acv2$>AB04|9wc!q5F#Na)OUf$C@Ir&$y zSwqOkNvya2Mp4+XoY6m4o_$H*7sKa1E+Kfl%bke03aa-3`p&!2;Xg-JEkg(}pGHOk zh^x;Z^GE{%#slr-dOl(6IOFYKTU3Jo_mUBrX;jYmA1lj~D%r}^Z3bBX-)~dx+J?C6 zvY-eth8MdZ@CbDY6Dws=7e*-8AM*1f(oP`6Zbd;m;j!|j&V?pgonVMT?^Z^1VoU_% zoL`QEvza3X55;}g2-Djo&1TUYaeO@DPgyKmiQnNHg>fdeFn=Lv62U{ zYX!D|Yil{wl+3RuO`msit_uDseGj4GvcWernp>Zq(osAy7>;z%p1vMg<##K2lSu-D z#(?#ILG@>llhRxxL2V1G!;Sxej{O&G&B4YLiW6dCIC^-5b@)ef7*tuU9z3e&kAb<* z(5twFgu?cA=H<8D1Tk6oOTHWNE$GWd1A%l3fOgg_7N^jEm?|PA9$N2A7okjt{_E>p3jj9J0YFvzkdXAYRaIT%-kE?2k+?I0VSQ$$sVbC{L;QIom7;oDQuAi66fOwVg(# zn23hKQS$=m|CC^S>sR^O+P}TB>wq18cF}^I5Y9$!g$I5W2`9xh@+9#6>+OXEX)U|- z*(uuK4tn^R!zNYcW_>8+&t&S?a$*gBic>qy)(l7p8e0Kb5OcC}nX0)UaP_!OnUOh5 zI!A%2YO#69K3@ALFybkF7j<{Xj`5dulKHSj{o#0>rO79;qjI{b9UBh4vqrmP?#j?w z>p}xTAud!Z7gxonkiaPFE_TXOVFdBbie#I?RME>K>Yy>H9Uhl-lOUz8sOvgzaC(K% z@LL9H`?$uVdvybErT&-;cd0*clu*w};`G2h=AMlzvn{KF;mJ{2#IC$;OxRR7h1?l1 z?G3R9ZC{-L8C{TJRU8%WB8JiJ3PIS(V%h2B+ixw0Y0UNS7L6O;PYmrLQIE#*XMtVz zy%jJb_R7Kf(vitr3jVy5el<9^2P3QJC)p1bzk|X@EaSU*A$`Nob#C+wv3#o~V8jFG znLU117E>_@*Ir0uzBcFE+Ixgk-|$k92_0`mA-{0oJ%lNmc1ul{Ccb`WPrSUFtWR3$ zi&{GgvY))`?Zz&4Zy0k7#^q^=dDeSU-BIDGmA;C;C;|x%|uP@8{Uj$?tccg8%bw z?zz(6JdXSZnxXBa#ifWS&ecj0sVr&XbtpM4by5}3jEa#c+zo~_{FmsZO*)cSU+}d+ zMvuV%^eoFM1g=cV@?3DGmsbf#M}wkZvTsd>F!5(FeYe>q|Bk}x&}ETSAg(3q*U(9) zD~x#0=-!aJnuur`qvegt)eSi**;+{|RNc~&eS!Yrz<)ay;S^Mb#9!*-Yy`qYEA!v+(h4riql+Rsk>o3Vv4y= z*Td1!M_;BpDvsb~q0Ixts$u@9?;`YhW<6OKlN-}~`6_o+#t#+F0vm*6sDlV@j}x)S ziM}Vr^uTi#(T|D%&7PIbB=W78am-y3mAb8;P4De~5y z_-m9;VT!Z@2It8mKZeO-z(jL-q=W-84e39Rc6}o+AebmX=JEP-96!U<9FgKT8t%1C z9fz^cZdJ$#$*QZvatB*&=@wd!sNV_?(0$)C7970yuSe^DJqSw1i^frhcu_RNCwQMV zlebEqWu;t%1z(nBt;wNvvB|!%68xpR(F@=8h=L|)3+s9I4c0&s6hkhhw8cIm z&xL%b1Zyi4KfHp8Er^4p<}YP7z`xD}GQlzo1rI|1*fa4GPMu-V6_nVGBYurCg;nAz z_=S*5&!b9M%xxA8U2Z)K@nkDQ&CZ{Se2a*?*{YD8HVs~?vg&6=t@U6rvuxl-&n?ga zw~yQA`_^fX{e71@GsYd3()=deM1?x0QlSGS%y$a_;{FSwV=AWGkKI$w5Q)|2HD;t; zT3|2paI2bqg7vym^nF<&mvMd*yAdZqS{}U0!b0)B1h^Tk$F&~f?s#@~vYBPh{Q(>; zt(2imOyg9DU;)4P$l>AVdCYmpaK0ablr^p^-=@*I&x3Xi1s%11 zXFYuC=M1vES>ijHT}6{QIys4mi+->!M|J)kftDSzLm+*ELfz5X#untWXLXyX)!xry zX@v^8{o_Cp(tXbVDq8Y;uAU>azxEnaBdlnLiqMU7ysD$9ND%`r;a3mt{_DnO&j6rM z?ocbsuiuqIjKIhFUgSotiUS#c%Jgg?M!<(zxZpQ99_KQM-t6k~&%%qV&*lQwe|n#q z`u}k)swv0wS@EN<>AH0!NhIO^7+qAt8($LXKj!>S4PfMeIms>17dO+KE#eKM9S#nV zKH-l2D|_5?)yW*u^G|X~vlLbHvS{3Bs>GX2Wz8|I;Qm7PtLPVHJ5%ekkDfXS7d%H< zn=2mEzvy?h{W%v&c>Qsz-$QSqb)vlet%~kwE{K&^(>yu&M~Yx?J@L>heyeO|M2jmc zL->dM31;~x{YIDs9FheVPcM6=w;>gi)_|aLhbzFATp*Lv{G`;f*QfiA_1CXoYuCqw zk?KP!Tdsnq)B-SqR82f`Xak+oky(6Jn_AAr5&4_pPxs--KW(yXh!queZ@Q!}cbO^O z^1Z7@m`xVLKco9hBL85a)xr2S+j(jgn3@~`ipV!?A?7W94v4UBhKQpER2ISX^dQ8e z`Q6_?J(550ip@Z8k`uYZ`b^z_IvyM?Cmz+bN}YYavbpTQn`_v6ff|KkiQhY~CYX*X z>BvMx-pT;ROv;`%@`GQcNyy?kxJ7YCQa?nK9#5}4A%J3$PA6NF7*0*@A;8p%_~=F4 zN}RxE*;gO0o;dwFEjw0&&?icIk7WM}m8|Z~fdJEEIt%J`p=hJh-}x9+yc6d@4Vfy9 zKQ5tZs=REgS(?)8S1sypu4JAREuaHM-Q~n`2Rn9ZNzesSOd{=#`3n@toA~K#kiT#_ zqfrHf*q;oK=p#bq)T~33aUQemc4l+EB8dTvQ`h%3NkrInn>~k^ zHHae=b3lo8{6xX{U`LmB3%ab^rsIn5Rl&4F+4J(FGXXeB zmPm~)2r4XBs6b~$NYGQFOp+9gZz9Jh2ir?Lq zmQh9mL=zipCsJA2S;t81t%}$C_v`G~Ljl{ntAh8&^f{`cb!n!c)>1NVESb)1dF&}y)lKz!bs?X^(02juNO>R5?BN2Z6OV_|XXay$?|RN^od<&w zp~SP^-cPHZpYVq{5dEee(%)(o7eGi`<9lhXj(|*4u~JH~zH{yaQ5aD7qDU5PtlUMaFeOkNn zQ;Cy-C>7JdTgEb1$H9qo$@T4Q*THRo=O(ti=6Ypj*26+)`p}&K0C=GL)CRn#=k&>; zxynCwGJd$g%n^;0@htuF^!2&({H6J^XyBX2jS>rCrs{8yp06`?;sN@)M!lk7tFGFf4#Q z3B{D4F@Q@pKB%-U^LJM~-r9QE*B_LoVmVQBAb^$8eh|otOXy_5?_NH}eE_e!&U}6; z1ECOx=z?e%=zAq_aTc#wd-ZDDN%OJS1oZ`_%%r68bKkaTJ5EP<50>w+>!X$!(FwVI zXFy>QeW+o>z&38>;7db0`_xcH-qFbsr!ajjnr|J@7AwT#5pQq&%*To*upd5cYlIBn zrWH^#?5XRTf~JQGXOP6PdV$*KwJhWa{kNj&vTx=y6=1oT*|48wW2M?S^%OdqcaNNt z@o-8%N8BTIbom(&Elu*6d`MW>yZC}#AUOWkCxgSA-1@(nw02w#ww&J(bb0&Ar&a7H!8tNKzp1!(K z2U6Yfd|A~ABL#5zLu83@4!Y*5u&4;K<-v&c+z*-y*mZCtepN+Lk0AmP23^aI(S7z- zZP~hDu0gdbApe!!7bv@{YPL9G63+TXC2_Hv_!ILB7=dpaI<38cSsw5*QTvQ(i zgoo3wBdktwZ{axmJ|kL5+k>MwGR$y=fS8?3>V;{8Ld`(;KC5ZXI}F!>*zu z!zv7}XBZTH8E5~MKV8tl#mm6Ngn0Gp<8csAGEv8VFLB+UdhhF4*Ffq-g&Pt;XChI} zYE|Fj2BEkN=SNSK*z~TSK`0a%aqlBlwDdy2On-FtLHrSVcnTL+izuv&VS!l;pKOor z>ud_baK1dzHLmUv$`SExDYpS1Tn;$Li)kbaCt66y&+&plJC%h#AB0CRwi8*YQN<}D zq@DjwVlX_E;+>o~FMtr`sk$883#W}TYnt-E`dsxwK9~ynWg3M~ zZS~^(=Lq)QzsV;1*9rp#0_Qdv4sx^iAr>avc5}0QMGw{z2vKy?Z@%r}F--y?Og<#W z?Bs|U`QlwET#_^$twc>?G3s@j=Rc?CmO>9}<)SPx9<0FSUZ_yuNi5(a#mUlx+rQx+ z7iT9dEY4z!|7+$mZ*J($9U#%okaT_QVsYb%8k(71Q-^lqw`vmYF|tPAcf_$KFWh|! z71-jGd3YTJCQJ${3zqut;pZIEbhz4?p;K}U!T5P1KP>k_0esD9tio`X7Z-=G05$w; zhDn}|gmI6ZP2e3qgC;BZOxZ@^myIxeYaB5gL?qf2;YrB{LPUW+P~lQ&$u4lJ?(KVX z@)J{l{Rx#qkuUUFpJPcFT7E1`g8C*9tWJGecTf|P+C;qMYo?H3?@hYy(#F5EWF-w(s@QbYSH``5Mna%AsVl= zISLe0p59dU7>{6hQm|gKTL53wVK7cb?)Fy+q|9Ch0>?$TfI+=URGRYQp9+_7#)wji za~5rr+WC9sPJTy2 zgJbU?D$&;m=HoYsLFcU+8V`iyn$s%2IjYgUeC{*yz31~xdp`u$JvJ&xOwD)-tJu^2 zto@LfA$*#7LIl5H98X2a`c#`mj36s7$J-}2(dlG-SH`xePV@Vw6Lyh}`eun@ zIXpbf+5Nk{dqN#vh_gj=O%U=~IAra*-bU_xEz$QXS3WLZJYq{yV7S}3@?^^u9sS6) zQ$;SYg&d`^dN=99zrBgW5SpY-qV0eCj0&-~hJ1hXGu`iYEk6MJcF6t<2Ps)s=uYR8kCZ~ved_S)SCNLD_!Jfz1;aF zRup>shurUQX7)N_GB|DTXQ?3|8i>Wy>~J#?0o(bbfC2o4mKxW0d>t1 za}-kn89|2hx>xGwJufQ)j~lcX@*6TG>~BFCn&h67&U1slScXaV1GL0spE0C`M>m-u z7gSb3_~kZ$DEb8_k4> zY>(0y83PBATx&g;Z?NVjhn{nP7GAHwGZBOBNoeN@C$PF6ZDZKwbxmBMk3yhY051z_ zc#ijVBu>l@v$<2SCiL@cMejZV_G%F*ZPQ^8ANZDBFRZhI4)Ki4=mz{m2$6!yGzUFM z4Ri#pY!fp~O@d%(<&@hTZpM?P+i~ZB{dWpi!vPs$0WyFW`p)>FnXl8n8swN4TF={#= zh4-g$*=X>!cDYSM8>2B^l1Ox!8O7?G9Y(^dt=z4i#q^*ymZ>r@o3wC&_4d1{wv2@S zAtLy(Jf?0!QmY#Q2_h#B;c~3^r{ajusRb{Gwm-Nz>lKk9v5LveYktA$&KAN6t`SIi z=;sx(dUlYE$Unx|&DpN?EA@uBqzPGkx5V7!i`Wc$^$Oc!d$>t{Rj7W%8RofWwkvC| zjLlcTP&c_QD&Ljq*0kg(j->yY)7a- z|DnDB?cUL0QE6>Hko2)T5&0YN%>()nEnUtEzwYVoZR>D&pPgPoMPRj@aZceeh|%ur-+av#1^XvK6kwG*h83AeVycOMTUR7b``sDD=Mo0fmz= zqi%(;RNc3g-M!cD8@v1LYioas#JyezSNg(eB7uyVRCV@Sk;Yf4d*62IZ3jrr#r>$F z5?Qv8-FJkp>{2-WiVIZNtgWk6dem^=#hzsJr$y-*yth;+Ge0a)*BAflYRAaK;koSg z41Rgk;}ROjMY>>c@NC`!%pKLRZ6v61^V-FbPJ6 z@U@lA?0dZzcK`x*B?RIeU3W^7JsmgyUkkwOx;D?pzEO+acDuxYA>WaeQnDhJsc8Lm*14O%t?-!d*i*;BvgAbdtT)76>RhuE^*fy&Op?|2g;7n$^j|qOYyd>1KWsMP1X5!5>Uy)oC^VQreuq z(gm()lquS0jdN@;td(S#neOS2p}x_>o|iBMgLQp{+bFQ&s=ro*7LU z{d1h-_<{>-fk^TT$MYQ#s%RWh6Ap*S5goshhb4i;oX;iWBE}&OA2~8UoRvmDRR#+WiI4Obthw4p0jai~LTS|St3`ZnaLge- zANXEbaU2cd(~s&nB!tDEAj=&f%5;rqs^<5T3h@b(HE3~9w7zSsu~C9575J}4K1$!O zw4DE5Y36gP2ipcv%b#dtaJ6T}=koZrE&ckpWOvWmr2Ob);HlwQUJz~Zn~$2Us(P+a zKHc|*)iZks4nPj^)bxtlTXlj;o0-+eJ6I>9j(O9PVi|!r^GQaArys|d0#aT)9yB^!W0gkcxOFQ@R?IXZB z$A&p1{Ah2P->D?vhJLon&5Y8rL~d@!PQEf9)?$5<>u*rZRp8&`{DRKT_@g`pGB#;P zf{s(NL(nR4YwwHVOZ<8T_b=Wi@1;)dX>&eSZr0qB)Mqt7h?-aTi@Ct`EL738dxVtXMWx|Stc<$1ur&%d7`uvL z225~uG2=)ySg1BAUd@tzON9DCQ~YyFrxm^Pg;xFSz}{^xx4(_=`(NG2!UGla1d7J@K>h{ad#X7a`rz+%pcAsI2?8W zP_zP-WvRbX#feK7tZN)EzXvuXcz259tj&JdNzHf9pA!;=%V9GqnF25zAGvVeuhE|2 zq@QTL9v3{Vw;p=jgt}Qhi;;C%pCDfzk(jj@+A^828jZZDvg}T1-2d${`3|tpU?MwaS1I_;606WTbY@G6f!%bEVAgJrS;7|YBFK!FA!!Ummd?ovnC`$U;k^uk&@{v!9lK~uHdq$GyoJrq_ z>k7ftRBoEM@y)f9D!5e7C`>yY8j$`feGBK{^-*JcwsfZ}se`pwobNH>O;%7c~*z*56CwAZ~F~ z`YMCqq%1ECQHMXvMQnGRL*(^S>eyPMu`iLU;$V+_qW&uh*1Pm=w#A&(jOdE|lH&^1 zgH`h%=YA3d{$)PwDr!0k7bgKX)vG9-620zFjb4mO)ZX8OPRzNT7TLk#P_mxf;9|gg z!~dLYwxXcDIex?pvL(rqD@)@hY}XhM}(C{uz!BTFV~pR zN;%um?q~XAJ=nmnIiSF#Cp1KG-yk|7_<EU@c;CC17n~&r z5_(t=BBFz<8px&WTLJfIIk$RzYX{p@rN^RUS8e}P(chHjWB5I5+CG%0Yuikk${#>ifc%v{7!j<6tEBXXS+fvLI*~T-7Zd@GUfcZ|Ftg1IWdWhi|0o4%1d&XrYCtdWA!r{$&n%BUrzF5D#)J8HEaPV|%S$Tjq9t?+~JNXND%sj=^KJP?YePxhn0 zEcZDmzE2(S*?ijjL{u60;7kK9Jzl3&y@NZBd5lAO9Myf*9=QD$Iv!3$?I6zF(Rl?5 zLPH+Zt|oP2Fu@kDo6}13192YQPuI)u@s?b!*uubfEd3)~QM*L`1QpxNVoF|9{oP|3 z9o&DCw=QHIm9&PTVYm!GKy#bjN(gMqUzAudeQPHSsIq5|ZZ>Y&BXkmIA~1&~+U*no zU!m785MZT-&HQ3~4MskqwisBZDng^yKU?)pfjT~dDpWW{?xa^H?{)h}z2(MFvQRHU z;Q5-o*xT0wm(|(x9oF)en05M=^B zSd`?y^W1_JPZqf4^*P^lswJA%empBi(QR|iJ%JU7pA!KI z5{yu5F3A;tW-X%(|vADw?b;P^f~| zS#Yamd@Y*5dV3w`A&%7(v+RMP1h8AVZnxFks*XK;mzERznk?D;Lo>;5c72tBd$E>l zUq>HrB*-G)3|7rIybu6d_x$2YO#j7*qK_-Pjk=HM`!R>3wlgy0nvRH>%KSf2R4LSY zG(oc5haKRzM7O3lD3y9ne%L%kOs@D4#u6W0{*1@A^MH47&43BhfmWIJn?&N9dyYcitWu8};4fBm<42+F1Wd5nCFMQPSDd+Tfk$ zm+s>pfC}=pyu840?aHx6PNvI~?1QEH+|sRn{lKAqjMo}6D9VnI!s02^GZ zEh7(zMS>#?7w$)S{~7#S91l_5#CsO1V~eB`$+}8>LhV(!>8)N8o+>Y;qSWX(VQ5Sa zXm&%FDik>VF|(4v-+kDEKUt#A)mu;6oB(UB7h`61(eJV?-<}Pc+?=L&A%2yo1G@rp ztwP%KKc`Az;Q|jFe0;}qawF;a<-Qh?B3jCpeO;i)ssD)-z|F8cG-Weoc>V}2SVMh;E8=Z)yK zbcjqRhLy`I8H2#-eBQ=UDc|@Ex4|)tr2NWzdRO5CiOTk5?l=;gy}Gq+=2B8^UfBI= z3$X$@CnvG`u6l4HxCYxF&y~A7H)N4=gL@SBKB`n03mu5flnR#PYiql?^$AAwRazR) zqZghl?uAs5cRdi+1$RT1eq>61?bLR*Y4%P$qzE-$Tcz6dJci~!;sfnuN$15hx8MJO(X*eIdT(b#P&!zrdhN1iv1J|MfpVVVRsGoBxYbnZhDF zKVTVj!W_6kka*mx2aDS`ez@^FwOIr<{pP*%a_@d^^^Ozv`o+Hu`p{=-7==gd0FXTT zmD5mRgkqy6Rxy?O^>Q4uSfsm+Z0j92`yU|1_3e0;L?Ff$n=oVoRqx#4FP?}o8q|GG z8X=me{@$m1v(%IH{emC=bE-(rk1684`Z~;1Zr~2~PAy?8${`TEg@)p1?j$&ncsGrZ zf!xxR!~}6b!WK?6xm%Ymz9=;uVXfMUFL-*qDCBqk>bawv_ZlsJM}AOb`p{!pr@78|ct$%*>fd+Vmnc8n%pUwnfq7@B z^*sT@VGt)?Qy&;pWex<^v5)Pm%K%;p;Es2ZxLBTooi&(+sV->Zg%c&!cOEdqk|e<6 zvc52fm34sPYb`VozRk}h5Z_CAF9m|8pf9*Uc|O}8!GebT%J3CqE@|I$DHsOYJ(7Zy z`z{o`ZDZd3M!LDCEj}VP{dBOYx&tuQ?7BO2HK;LaIlNqa>3<dmpGY7e5VJA0BqX zyC<}GcC`r3zGH~wys!`B|MY90lxe(#iT8=jRUha_7fR0?N}#HLPf^4TCi~c3^h)qC z@>{oFv)q(3@+hAWqCsRZ2f%XNt69nnA$6W(q2wBHf3JNEY zKwO}f>)^vHWQvj1G4SPykJI12!=;~T#NoM?;6^2|?Mz~iDz%xgDhgM7i5?r?f-QS# z*_quABCdx^Jx=?-Pm|Tz{!9b$pW9}}U!89}c(t>%J6EQP!@O^AD_Nk^0~sPknZobI zO@v;Ld@a_xIb21h%QfCIV$OxISt?QQ#oTVrLnB@47ezSNVkx!}D2(U-R`r z%#$_2SvKm4{E65>Gt&;+2lP65+C1DAufFBMP)CWnDa7^;rkL5h&dGXmAI0b_skQ^!ZPZJXc+6fTVnYb9w&>Jqv_qZ5^Vl&Bxb0i_)`}D%lBe@w^6Epz(5^<#jhG`eA$TT zWFyrq1b#hY(S(|UsYU#mp9HvAyB+s!+a z;GJg99Pb~CCg>IBpw~w2WYY)xI6Um#ce=qhSk(PAAxpJ#(=V?o&yKpnSdf345bPNt zc@!ihBz1OYYIyXjlTlDWvO#k{z zdRzJ8wo*d(z4y*KH6eQ&lTP#3E~zz+w-VpQ7s-^UdO zoo+QG=4%!PHFOgE-uIb&-T#Fnj^{${CvS#CUy}W|XAFa#bH#pn2`uQIYffcaby@r3XcpB~HGzRG<+%>3IV4H;Q=&%0b7F;@%@uP%cg z@R>x=&+@N9^YAgwh*_ssAqrOe=qNlCewEo4hKHLIXseNxR1?fEyRm>ECZ{&}_B*CA~p5_Fqt9?++A5NIP?TOANF z6nshu^*iUJ6S5fjRGIF+b+TVh|hwEV#@F&AfqCofmz)Yig4oVX!`6d|{9w*9iM zfP*CPY2OZ#65`V9WcGSXF7;Pc*1S2$mGWv@G}O?4RARq!90mo^i6+$TWE(9JFAB0W>{1Tcb7hGZil$ zc5lDBJeVKfo|XJ+cgFjqv&$gWz1n;L;Pd`14e|Dde5A(G{wSWqceI1?tpDc3mt9^D zMr$obYSAM?-~KzJ`&|P|6vzE7y05o$#mfEfcDQ zYWPikOv6@R!N^`QLzbZ1WGytN(BMUXnS^nAy-5(|vy9a+Riy%(t!M4&p{pFuv zAnP6-QiKeR<4^y9`dy0=`?m+AJ+x2-aA%%GI`CWyIK>RTQ6Y83QCt+iDqaA3k-=CY zxuK6LQIt5_6K04XcB8Exw_a*K3F}jTxC3_x$WIQV@(P-3p+Pz)aTY1npf6OI19@qQ zHIv1L)7{*bpx;k!R|ar?fhC~WuY~B_IK^pFdy5-KaMQ6)S}mWcD2C&UV{&ip1!;H z?`kVCEGltoWo07Vy@*k)E!io}a{R-V$(bM)l|I*YNV+n2gTH!PV6X3A%2!O@~A#IwJ=rSr>%wn*^- z1D;y}a*ihcd*!)Os)w7_x8z8*5kk)U?03hS!GH1tvnp#Xdc#iyl)g3BCU)MDyMM0C z)~L7+t~Z^!ALX{Yru3w{>mz+WjEuA3$M3;$K@$hNMN8_ITP^i%B3{vX5D|>Dx)8x7>9YlKRi>0f^_6YY*#Mch@fRuS`{i7 ztrx^;u|oDXLH*tGTB`TM8-wu^*bDqoAi&16VpZT1`KkwNK6;GrWrqXh&&Qb`C_?=^ zCwlsZqyi758ehGptmP;$=jXubQG`KV59TJa(k(XEdLV?HEe9V)Uv{knxszGrbM-bv zeZ1LET(_84??jlJJIiIRGDjW2p$`yxRcG?phMhwQ3}2c-oAbEijxHSZrWRVL{H3Py zKBtDI55Q)318jC+6N!Y?wIA4jf)lJ5$&@rkD!f=mugXFvY~ins`zqj8=KVeeIDqV^ zDM>o9E0VJh=etytA``80d=$k~&RW;ifqmE|lwoFNV#u{SQ`V(D6X<>6w-Ya_Iu74o z9;}Q5Z|A=S?b`!a%#kUd2DH*deO3as@UzBwJJIO#^9yb={>1kUH9Q$o)^h3Qfsp1E zFZu4v(eCfVHEb(Ojj`NOWIrv*GeyuI9|k_N8Ms_0F3G8{W+$wq`?wa(e|cqiKc!F? zKd$%pN_VBRswh{Sa+b9QLjvy*@$ z+Z9x+cCH6yf#X?XzSQs^8@}DceRa)eoP_+evA7X%VUqdAeVwLv^JA6!vz*}t)z$IL zu3f2qXY?L>#pyq!D{@t$5|6*z=p8pA<;Om5@SPwGbIrHCD#N=|c98xvVQ_R3V)gkE zl-L66RiRhL6<%7qfQ}ukj#L?CoRVVVUjkgGvU;_c^52xJm`DC`_DEK0IAm z5H!-X8;oNc@Sc6hO%bXlwh72wSQPwoG&Gf!Rr$}$$xpaa@loDQ_u5Jsk-Z90WMyVtD|-}`70TXwbMNn^&-eF->yGz%-{(2!Jm;L} zOpAT_Av+5D?Q(VkDaCxhO;cUXK#ZOO8zvI4*!@|x? zFCce$qh79sgwFM(_k$ch`KlK$c;Hi4k6U$LnF*&>?7J=6c=MgPah0?I+kA>o0@+4< zq@C8lKIF3Dlmc8}Lt;NX=9pu3S8hJLlB=|*C$HFFzj(5KZM^RaXp0H81Z^>l^4yrF zeJ~Rd(Y(x=1oeNNyt<NY$A9dxRN5kFWTTspTqn2GE(}t)|YiwuK4t6;jX_$TD-B1c61CQ8| z%>4e~5LYng8tvGU(9-X$X_L6z{}R!ctJ9AUmbN zC6%BoTu3C{qRW*sul8=1$xY7}Txl6(9E{R3+%FerF49Yi_3h^IfGF8 zV4%=VC$Wz$;TJaNQsw*(LFu@>O2kop@V7vyaqp>pZ$@uUL+yaPYVO+Gh^ zbvCxv)_xNS%ELs$NqH38jnNBqtcwG|H!K4B_I!X*Icoldn?_wcqkp$Nbo;$3KN73*0$`9?OY~;2!xfy5Livq= z0BVW4069hY1|L~aDoc`lm>z9ee<%7YlX;`RYvdx!iKx!mZg_ZRndFSAFy}@M!JZ`| zWx9*n^>}GCgZ!2l`}T^of(Yp?9I%N)-dB7sW7emR7z_C2jotSe(C1HUHM32u*AfN~ zW>}@c;1V5?Oz*1(+yy_G!Me@Sr^kDxHp{%;>(7G4T$a|u60R7FJMX!OG@f|oJrJj& zflFS#<+NMNnv?HTw)C16!iu`{dkG3Q1DiFB+^ZyKU3CSm#h>qVeXgo95TZ9dh0B-2 zTb^~v+@4gp8x9Y#>gdd1yTGQPUUBy}jA3z`B??GVmkYJV8kTAn808oV84A(o8+ASQ zevF`pUVcd&aC!%{9f3XysiA>~QjyIO%Gs!4myI8o5XuL$)srAHL z+&g!Cf#^n8>zem6aI7A*r;Y-zl!a0xB_&rQC5J1~81OrZXW@xLIdAj6nr|@uWIxh8 z(o?quPR^JyUmEmeg0%pBWJ`QR-Cf3dCaQdB!g$}AdA21OZ$;`o3#!?kyZy1?4bG`m z`HpFE?Q)wS>RBdhbgc>Kv^OY-FNoKU?>;Iw%F`En5b-y$j*K-aseWmJVWcmxSInqg zl)mmw^&B5v7)?DGNl0Zx_GJ1kf7H&Suexj~<%*Jdm%lrqGUo12*HXEg_~VYMIeNw3 z-u>tSs)-lauXnt1H61BG7M2T|%1yLrinF^?{kLmTC)Jw_JZ&`FgFejBmU7Xe>2SSz z9X)qZaq`>pmFpQcP5{QqyE=AN<)hMf!y?JAo{|tC_cG%dqTaTl8hMhv{X%)_dm7 z38C(?km`X|&@k3l*+NB;-+7xGx<_$8AKG_P5Cef7v5}EN;ZOs9%molg<4kvxweD(*Wc1YmPfOL)z+hG^ud_>5;>qt7$jSdodqlJwc(~zxyq}7I(+Dp zc65|##d|RP^Ia7hbH84R5j2KO(Ezv)K&UdRG{0`quoPwB|0B@8e)Lxe+jt#T{awM= zf<)Sol6FvspeGLuQ&7gJTn1Z)i4SnPSQ%kZKEEk;N`qV1duFb&$UaN*nFt84@>#b( zt*zL*KQ<<3Qtc}MO6s}q-NlyQTgg5fcY*Fc@3qkuFK4NZX@_6mehj{dO6d?A!W6$R z+Ar3^M4{CCK6Br($OKN`0GTy9my>g^RrARo{fPSOP?kRR z)DzBA3(A^kKS_4jr_z^jN@&HD4h=RRnonyV+<_d)(Qa2pV;JI}S7ANIi$vO`+_;Vs8=1SF{`iV}f@?f&kgFuoZXLz5LZg`lP3k1qZ8u*_}# zOX1`bgaNfL^#@NqGnveeIU6?bV3M0DtlC#a)z^A|& zVf~atM%2tp?ElMkiyp%5y^4`kNVx(i>W7=w^JrxnC{uA?o3ru&@aYGCW5a?#|Dqh05k z!kTDDX_0IrL5RN4CHe#A#T%y89&FLv(BdLz#xNFz#}O^z)P7?HPiT7e?Y<;-^ML(2 zb3L{EPD9@k2UykPaUVqRdT+fRgH<2;a*PBGi+<|AN6@HYC2~aZy00#0SEmd_-!8Ko z{RRR3QT|E|`<3W?X=jM=h^~zTF!pcfcQO;AI6~BGJedTE)yTb8h_mvx(!w*gT z6u%m`+er0BN>*zhKl|<4^Z3P|#~c$<4f#7;Aq*KiUB3^lAdM1=<1%O+k+|+~;=p>J zqeHvZ*JDIBvJgfsZ}lOdBD`E5V!6Wmmj*(!PyJ8}F8L_9aRSpIJm0NP)bq2b6LaJ? z=%I%Yphcb})?L>K(CwqRpCB(tYiZuqyon4w{wpQwqThYPI=gJaXGKxBeqN@{0EE<4 zo)}`xX^8s%Rn72|1!r+56nA9A!us+w7zJjrvmChlz3zLiAtVIxvs?7ii@R}EAu8=B z)5UspK+MS>cDx)Ivr3PJ66_xeGKd?!xSJP=`@~8-?5z0$2%9hsqYvf8Do67pS732!u}))*zL)^4Vl8Af9Cra)e&@J z+7E?eJcQ7Vw;_S+zW3TU*^DmWYp7g7m^ez2k^yCrn0LhaZ7Lx|D+vUzdGQtc~A2l>}EEGZ>Fz~FsJN9-Y&7{KU^zM9ocx-2zr+W z?}~7|iwI+45)+dyuc$dh@-kTdZHGq}vLV>@t>k#A-fQ}6sd z=Dl?Zv^y^EegQYmcJ%K!(uaD(ABfGLO;S-~K9bvpljdj;yR<98@SmVr^_q0#`l9G; zyJrv?Ra7{{miq^uQOsbQe1~eFJw(aL8X2XxHhIZer4x^@Oqr1(OPKXc7Pu{9-|MA! z)$YW1t>MYY2DMB`z1IdmVf%{3bVf4W;=%%Wsxc(zy4hCS#r!DlG~}_RTD7eXkJzQh zOg5z^w&T^MQS5SIpKhfd_D?2hmevnGJ-kHu+n=m2;D=@OPUW?JLE^xD*&NVXJ+T_z(U(uS3ceFP zeu&G5iD249H*foQ){bm7i?rDPx}q=q{pU~h0hykv%xAIflLeXIeJJgJybjN2o78K6 z>nCL}5Wk&V2l*D%#At0fy8Gri(HMPx`MY3Gt;VqNkQ>&2>FIbKt2Sr$_?752p+0pM zb?CdpNG0ffh_BN<+8(Xox-UW=cn6k)`X`;PUQ_+Tl^`E{%&bg>xlKl~z;nSc^C~9> z^2{nRHkUl712bUWs0*hoAxEv0E|Nps6-q>BY#DKsDj&_i#@;$AKej&FVy3nHboaXC zoMg{tUg(=|6rn*|c~4%mBp4$oJ+k)QpnvXApB zQ+DrXMOzYIEF)C?IVBh((#CTmFqIv_bPc)nOJnmXi}DmN#RZ}xM|buwef@YnM2Hm( zz2#fLJX73Vj~~}<@`T2umT^Sj1VHYraF)N7AUw0&>({+3bO}21yiGnQ*UcHH?TTcAW1DEjwe8&p*{bpRQyk1|sT^29>z_1t7mCK2ZiPz>yZ$f(u zyN#>Px%1WsWN9p38L+QqsH_0pT%SyV_7EL)Vt8+W24TAsBiYE{K6cj@NA%<(L9cT? zd1_sVL|%;TRaNHr9wiKYbiiF%F`05|={d#z4Kyl@KhuWR-IGtcY`Hg0iNLBJTGn-1 z{((ez5uG5Ep82lMF8_J4`r-kaoa2sGdc+NMg&sz-6fM1M;s3hX_igMV$y7c}Mi$a= z{B-oqPF{B|t*h$?sz;@u#MOp3jqm|2*R)L}9R)7F@Rr9^-n^Gy#m3jvy2{!bjUA~+ zrx=YKG!Eq`eI#0}!{+R>FK%^Sk_F5KEGdxgMBmq?H~f!dQ{2f;?j6rc{RPRqCfAkp z8qmi{gP3cZvu)usf<%)p1RrD-D_rdgy$h#5(Ad16+yOy7%wiyAT9|35h7aui4TZ^b zMl^Npkd%z6II$+RRt!pTH8M~Tb=mQ}uQC>-hsQr}+gF1yzTq(nLd^?+z`n`zqoTw_ zkOqGL`PGSrl+8}e^tZ92XGND7J*OabQ7qz9Zy?wIVEDO6a6#xYE@Ug*?I0_2bnP=n z(L5195i)Czc6)Cr3+X7T2tcZ$TFO=6h|d?OKlfY|v&H36}k=an1+!4s5GH6i{Cg<5^nKb_q7!1T}P6waTD)e&Fou1pM^xiWv15iVKMN@ zLOU6-rY3V=rR>JMx7$5kz>_(H%9!e5#cD|;=6(z>lz8e#-7WZz5v1JR@S=WML&}Af zZj)VT#E#qpW3r?rfCA6ktyuB_yRMX?j_Mq4lnoo2rya?`4T@J$4j4h`p~YxI4Ke;} z$mx4c3<7&v#Mssh)JpdE;#CMQtP2#s?@L`3?R{+f7yle_@Dlsi!2vSqh=_-yr40s# z3p!6WrIOnt9qOiYUnPHLIq;H$o$Vgo-abK^h$i#vqJ6f%(JXA1j2|$gciRXCrSP$7 z)?5p2tWs?xrq#TjYyBevyD5^}$ErgM*W`n$zt@A(&fSGmI-FpX%f$FI7xsbwN>-PrJ{#Ps$cG^9n42)IdCo?-Qni_Y_tl-E{~^|8~>{SAenStGqW)bAM3LanLm(4w_sk@ z3$l!V>;viY;9@24exhgLGP0^Sf1EIjPC)kgC%(EkXyeN|k{Fhwoe4G@?DmG4_cCXD zt4!8iU&GLD>@jB`mvDASBF+E7!&$>q?L)Q=Of7V4|74QJ<#*MA_sD~ z%&k2R$cjq$iIc~LlbUqqGotHzMHNhn8wh|8?b+`x7C>nwdW!c1$|2Ju?t_D&S)m=eOJ2nyB>3?@y)$m%@CyuNh|wpy@9IDL0prS117rt(u2eXClf6?6z%qZq9=jcUXf>7GW#Qf<=jT$N6 zyD%>gH9UrqZwQ0gtZ5Eu1^m@h?k%b+n1vEjXzJ4BK+ z`d?l!mOQwKBYOHL{^Uorozi;9?FGM|-Vqp>O z5vA~_h!1z;9ywzoS?wQ;iKBiiCu}GEb+7JHx$&G3o5BV)`B5+{SJimmIo(iyz3+Eu z|Ky`Qc4kin#G(dNe-pjTS}TZoNl3NDJ!V98b;O=bCzU1AA+%JdT;3%R4XVqm5zCZW ztX(aBp#o&D!KT^>>5j|0%ZzBVcbOY=^@~aL2ibtJ+Qvm#G5x^lZz`gr2`MH9=lwpc zVwG15sGf|GxI1WF-0%X%OChv^n1L~ql3%J#5ZXUL6p8ce8!#)p>;cU5HdhS$Z@giM;}Zy zDEvi8JA~l*J&$o`LOWefN{16@xlNR#%*aQAbD8rEvcJy_sLVsFtpGhTM%5!9GAxrS zsm8^Uq6m#3JI#3y<;=?zC@R-NPeA8WDA7~ej9Lv+7QNpu|L`?Ux-cZqr;}c+{;qf- zxnzDlUq{97IC54c2yfZmDO^?Vaz--a<#%ywZk~d+ICXf4F~QvkST6dag{7sU9iD(l zZD-2lxz`(M9P!<`uwYD??{%ZfbU(wxOO1NnpnwH{JZ)7V8v6MndVDx==9bNmApVIy z4rpK?iV}a9@1`rmVIvpGiI=-#6~(t8>La*kx2t|RMz(|ZE6k-d`f-fLEx8OdMUCtp z^bR%Q@j<+sft)#weJ5wp|ZQMh3n9#5S;FcFixs=QSDIbp~jKGyLNm~cql8_fD z4$K?29~{6rw0j>VYR@8~^m41Iw|H{}ge1FnEx7rpTs$Ea%||@T!F|eyE39wJ5c_m^nG6++?;$p2uY0!(0Pe>%uwqtCWT&$_ptN?>L$qY zcKZ9L_O+5<*R#v^53Oa297|{=84^U~|Asdz&=sDqul0;x4jta3h(mPTxMB@+=~C{{ z8d?Fc6A=S3)bz_EzFRd}L%~#bp%Bg-eM@dmV+uvnyry1CdoNyqUm&_MQAJi7M`_0b zN45+=t9DTGD)@dRoYtpiy=~0BPv4_XqMY1dD@TuJM`8~|o>%Yr16^B?F#9h_6pRNx zwsuzPyDGtQo3)w+@B+AE!SvDf&VHTu^uXd>nj~&qIYYp0Mu&J}pFjR`3neJ`j_s|) zWI>FwGUVa!HEFz#F$rU_0vWy!4BJ#lkQwee_Tk3=d0^`Xg7R$7i?DPfVS*#ks@6y_ z%}tyhL-Cy~`dh-uE?=xJ|Bw}sMvj$n$*MOMT|N<-c)@>D38CvJ3;ljR&Av@g@CB0W`L2V0Hl(P)y4{dEi)}CjGIUOBvr|?hLi7q4Z`RudC;>JwosaNHejqQP%yzWxjgNWSXW-Q#4rHzo3HAP{*!Kc>2Kh1BKa!Vk*Ykdg_nkN=krv z0k7=)CwCns(g6xiO#Z7K`2doIZy~&%kjdDS)$&de!fPqKyBm6IxbhX|Y6=84R!q#mmrnRRKA2dx9YG$R%&KTp%N3S&n#J3?s z;jufLS{ORHyBq*a*M?6WK-jC(S3oDrOQR&ruP3A?>xw+BRsY+%d@pkX`U z4kLb}d)jyxj;OU;9f7lwC2L_KU+PANr}6yd4C#XL!?8S?pLW*!`DO_+@G0KAwSL4> zkQiTfJ%&d%gnMtg2{jMS5&*{4-^g-cmEOVdx{msMIHHTuq*J~ph7MH}R`m@H17vyVq~?iW2hG zq5}`~axRjX?ZJg4a#*V@a2L;DP&aw+3k%ho_pjl@U40?Ysd3S3#R}x1P%HxMZr5p# zip*1#*_M*Dxvq(= z#ZK+*w#X;KM%Xl#87b&F5=pzAh~w+C85a2VjxJ&%=sT)Q@wlgx&6=mY5HVUONt8s{ zgDd4W7b&kueLHfp`zVeZav7VEK_hY2FH`yU5fb zTs4k7BN3C=3w??s%RTXXm(@69dx)ORCKD%lN^(@RvlCrikP}2*LXw@Lu^%)Mm;n_g ze+MZRq1T4~D+bn^{y?*YK9MEsMyrR8oF!A}bNDbZ%1seq{fYXzrKnXlB?yt>Zn_bC ziO>6kR&33zHw28S^kkOJE61PAG^*B_Xcp5ViC>!Fqnni7om+sfx1T^1H9rCu$VxDx zA*}Qoq`P`W(g)n(sihB#+iwFCT(zAG^`Sr+&yxrDI6~IojM9YCNDLY66r{lbrkM{B z-yE+a2Yi^*R>udsl2LA4XX=Qln<1x~(`R5=tu{Bn{#a&2RM~O{k24_Q%oS6O3{tvj%Yjy|17TgWHE0^GR3vJT+WzS>e!G~@e)BI`BA$Od4UNMe6ES7iuPHD7^d zm{@8ws@;MgPEVosJQUiCMAAYGRYUsxw30(UU1BTT%m}CO490%p5Ocr)Nn)5}VilkS zmw6Go;RU13TAy=b{GQd=G$EYq!RL9>?;2uy2G6E9D^PxGv8z+-wkH&)j;TjEIR27B zW%7?uO#vY?gkkISptD5pqvvg$xrVXU;2BzoR_*dYh<NjR#;)yvKfMX?UTbYQdGB&OE(f_39<-%>ndM2KRM7Up|p)*t}TI%}ya8EKHa zI9iOpz66ER=nGydh`$nIrD|JA6BLFRFv2k|g5tmaw3I!;hR$%0w}J0aw`?Qi0*;lrx>^nwMhd zpcu}9I$FuMG2-gv0SaE-$V~c}D9{sPp@|*J5+(gn8WQnwYg`a`y($V<;>a=+DOjfk z<0e4YKE2bE%Sx}+Zx1|_jC>oxAGegb>zOWwiB~m9Vui}wis}};VwAU@eCw^z^Kc%D z>mgP%fsTK7404zWNp|XM#vdYwZa}^VLl3or8aQLrBED}DB>T>es~zWZj8m8gDr31m z2l-468y0z@TbRlJeTwh#1&lVSavNO^3QqK4mv_D4SOhGwYq$747c6-Wg+3=jB$QE+ z(Z5i0YU8YUnhtsy5pb}eNJ?*>A-VD`V#)(ZRtt$$M>15JDUS@JWiH8eRM18A;Oj%| zq^u}a9~k;d$<^%i^7j{?a=Y%kPoEwkh|~f@5_Sh&vD0ao;p29)k4YscdGV~kYV!!p z0n?XqP;52-6I&7)jdUB8TWE1g1cw303@A?SPe{W?r*7h9GM$|M#ydv5qSc6Iop#61 zxi2g%OilQ&&xSF(S#Hg|;J-vsE0~1>12)Y>3_d0B|5^s)7@!>aKb^psl*_%mV8I#2 zP}NFpw);|wDq5JBd&K#13<;hz@Gw%HJDBC4=2#7PP^<1+IZ zylMa7TB16)@A7K>IH5jVViujO5B)pbs0huHcDEsz5H(X!+5TqUHuLIsg`e^6FB`5U zIf~N97Ac2OVt~lNav84M$hS{MYQ-o?nb&mVRYzPyor((I;)%eEnc&Z}+y~B^p%G1d>wa zqA`08Wl6>Sm{X{J`%M8LNI47FXe9WZQiWBVEYdbh{@5vjRj#shE;rG4e)R@i2{&tO z-U&uK_pHczF-hA?8qjYZ&AG}SH(#!O`qV|-G7Wer2#w2PH-=WX!2PW-At%L`c#6y0 zp3KuKxiM6qvlPcS^wp6VZ+_Gjg6RfB;4j&WzoL-?99YdPeRIn&q7v6J9r=^x#!n@$eF@>{7~8pfM*uUuWs2;>&Wqo?C&!f9cx>qY6w#}X3u zJy}JDKmCZoJq{+oscYWU<_qE-p>B`w1FRKb|zr}s5`TM+^2@Gw_e%J1Mu=)NFv_p8#s3wXYI#2m@ zLvjURQD!_i$L-Xl{Rp#XJe%(y&v})An$Z0-c~N?a0v5=Ip@MPaChtIO=?mtriGTOQ z3J$Us+&}2TB}-W>aMO`PN4%2;Gy+1fym=cDF9BjMTrl z#cXc3JNWV5>5h{~%?$0@QO5%z^SThv0#z_*73-8RfroGkI7%%IEj@W_pVQvy=wv1* z!GSTNMSd^@{lW$Xs^FHaY&;|uZP2*lii655F8bx+76>@hcY9xTr1WlPlKygF=M?fJXiW%bIz97-Ft1(H=>!0 zgp}RHNCcIm6`}$MhL9L?^N^?nfQIWOeV9IdM2_vUsr&Z2B7r)J?MD;edUfO-=?C54 zbG56T`phn{UTy= z@!<9z+jS=;7Loziu*T`t_Yo+1cV@n0StpFE3HP+~=dRuYb04>w2gB!TW`>_EgqS-7 zHsEm$BVb228XR>8h}X45@eTNE8Bqf&P!}20sAEnDYE(}E_JdMG6^!=Z`oXTycS^0$ zx#cHuuv1@E{%C?lv%UnZWtrdl=!OB=Dz$AVc`e+v>zR#Kd6JiqGLf|*h& z3J@d-7ZChAHHVBQxNPrT>Puod@46;0uzpE-zk)V5&%5gyUSnXAhr^mY@2wQo8YA0Z z89oO~w?#J=wwLpNE?q9P>16wrx?guHRzJ?f-@%7qDn+NB%p(ZFyY?|)hutsL0^ieaQu|ndS=!B#fQ2D>jQi@IpH(jl_(}=Z%n}z9!-d^4 zJ^UJ-VL2~%9I4}P!6a}IJM65{ML*yW7Zh^e^4H>ks%Pqs$4fy=QrJVOuqc*XK*i%x zgbIkWq;s5wRUm;&I}f0i?_sxBUZFn2AF05H#ABhyg{Rim*$pbLTnKpH*S3t%1`M|+mB=`+bKM*VKEcg2iG29J9U z(sJt;d@i*;tmsLW&J?(vH(*|{vDR=ZzdNpdR^b9n9RHfNjA?k;Cg&L-{xy>qDo(Xk z)J(D#*imhaDWH8s4@IY_W&mdvt)Mfbx|Fz!CKOO_ch7}RVZY$+0P@$6&JTE}j@v76 z>$HH+C@o#}%-hIkd(%E;)`zsbQOw$U7K-b2_2I0h(%U;JzeWP`UpR5e+gw|nRmS#J za+Y_2kyXxs=sVLl= zdDxJvCWdip^;wL}tHcog`Rbx}!c%BY5$^*+$@wqMV*1xyJapRtY<{#%Dn2L!}VF3=whuDE&_()Tbi-09Y z^%{lYJGl0c@BU4nlI_@`DN!0_q*_)q!$R@PCW{om-{!+q6ltSRGS;Z97uMr)wAZ4H zS3`iII;PKj$s|*OwSG{y<;lm5=wu}1NSg%}O{R4u0V?>P&f)58`1AwDJfdim!JheL zuK^qzH-Co@bxo*bl_5t9Fnk#Es|7|ew7>8qg7M^~A#gM-ZrGjk5sFc=d?LS}CJ}+T z(wXVeZ4GUh7rH?^MGKogd^hu~gZSC6WgqN~cO%h_7NZ}dwMZrcHm%PrCdy#mN6oDL zt-sJTiZu-JoQbf07b=8%Lld((`U8XFoksaOVR+a@Xh^yAAo}fE+;{<5RKMJyaIphp zqI`Vhkm?aqJmZxYpb0!NglNJV`NpW#DCM6ZYb@w9$Mh%Ax^PeC>~qHON|vqhan?v- zIauvTa@p~UOjS03qIIlc*M@#}%OZuuW_T$>UtP9r`b`U&Ue%`95og-g^TWTt3={k1 z`QZ!YwEuW@W3o@Zr*XwLIL7RA^OX_j?@PJ;H_o3X=xHZxN}%9vaz zW7gNOQyM2y%S8AvV?8lC=aDk>>eLwMErG|OL_bdwd>aUNEkmHE3u z)Mm6-Krx065{6UgXJ>T;Jsp*o)Kd&9n z_?0IpusPFWjUjWpqz?V7kA9eH?*?d{P1g>G8akma51-D0^=62Uxexg2(b@p*OY}}H zXxgL;8CQ=uCozZ4Kp@iYUI1jsIyOl!4g(+NTRxBg6f?qfru2+}oZ>$>cp({aRB>=p zwnw~IAmU(FGauQB%m>t)UwW5MdN)mj&|&-TuM*Ca*7OCib zuWL|`pSET{)6^~Fd^V2n3!(W%Vcd{8MkaD4XK|$^lc$l1u&LOfDCYx|FwK6ngQ@S7 zFyy-Sr~Zv2*0`97{%7tYr}J;dEYD|_KU*A+<4ig8o(A3Sl7U_@G+rf`{?&-c*OCTO|GsY`r_PwrcAT$ zn1M-VvW-N4RUC`N3mKWo#OrTPW%j2DF~Brs$$q8Q427-V@#dD*io}Aa=SIJ9)w#bq z*3}^bp8sPc%T0bi+y8>haitjuO0eb~{-}IB?#9Mr`pOiZ|TB za^#bn1CwF9V<(=e8zhhEfvigjfb*++@XB{Z(>uz@%9f9(a@tB8n^wf9rA79oG)H41 zd&{z;_oi#IzgJMxQ~QwPn=r%>)cn&eMV8a9_1Q*V?Lo6sHAmkXX|L zsOeCzy(M`eSUc10c?qB5CnU%olj#Ip;QbvPB}F%4^b$KPBNPhwe&UCA;m4y7hl>fq zqD)(>9Gy7nJvuy&ksLroe(G{??|g5*y=`o+z4op(;Fg$zNukVLT7ZQgK;7j`>wUkY zQ9PlS80=rb(YVTZ!$2|qu!Hjeiy#6RuOV93oc+tO4W2YfROa*5MpKy&*nN@YfS9v* z#Nhf?G0Tnw?H_siz2JG`0T8;zHT)%wWk_zA@AWCZUogve0I6wUu%7) z3Ry=%fVHyk7f*hZ`b|yq1GuGz8h*qIu8bc5z{mpjFW0-)bYp>s;3q&!O;`1kvSm=D zJ{U1aewiHnib_jU)er#S;9EFAN(}x(vt9}QU%rZO+DiRcxp3!$$-~~lioM037Z=k8 zX-PTgOgIq85Miq|SY_!a;ZDx4dc5{5e@NSV&|);(Vsuyawk?^Nu?S-e-;~HrB&v)C zi5keFY37Y`{q#m@$xZ8bK;NR*SmK>KveXI5yWOS_etxLfn|-Eey?_5sLPB!Fo#T?m z$w|?2de9|6$`OJ%dogp|@$7bRQCMK#T@?Zr>LY z28I^9$g__DZ*gh>8Te*43pdFwNqY8OdKLr){&#_e;@g7e&Tc49P6dFs&w;DqXT!gq zee*Z_?3$Txq0me~k_^0BUVH#Rh9EpEYE(Hb{%q|$G3~KCDi1!pIOYoR`EcW43XvUl zB9BITh6(Pht7qfml+WhaF*^-?5kP)=>XH2tk^%*nCIXQJz?+&~5J_6FP+hPnalS6? zP2bP(oiU5!Y#j98xV9N+D}VhzPPT0@QBfZ1SE@ zQoIo^VNk)SpF!frzj<4k=x_90I-Td=6WFP8h`ahoNu21?HP}Na_@oiK^ZTr15~*$o zeM9R8Wm=;NQ7KRc9KxiPGK&mczAg1RtjjFC5pDA#NBbfNj*O32#6$`5lvtHyh$IAD zju7SfGLLPvvGVs0LEyg75Jgvy~s<2E?YXVNS_%Vck`Y8WR5| zprUe437$QO&;E3H*nE28)cb+Vexch))4iZ%h&I!|Wvu|`%jzzPKbTY(5*0b}(O%A+ zoO|~W(Q~|QQ^rwZ>5cnq58OJ(^gj@MDGxcY&_7_mzoX|KO#z3R*k(7XFhkq+E=m5I z=ZN$_i1!V39MJwnU;T!T;3tSX6UmFaBzK_&dNB`f{aZ;ThWHFtzlYUM*v$^sO?Ncf z=bxWyw6P3p@vn~|k|wGG{x?mE^QBkLv$PR(9rs^|OjU(0h$b^dciacmuySexeUk7C zR>UhV@B#SQu0fvD>qv&c_OuVplr}jbAa^f1q5nY(7w67=T*Smx5C5hfjLYe<6y*HM zWXL%f#!B@z8!I*@Kh>+Lp&z@H4Wo^|6R@3cpS;}`^LQ&nv>={;-kP9U6QN2++)gvZlz2@=2c0+-iSf_n&AH?^$*Q?xln1isQdgEHF!fP4q-F+U+xX=V(sY`k+Hh zgP%GH;@?f4bY;dz)<^lq`C?os&JjK>#Byq3exk>KKaSd?-g8|Jr6}ed>wCw3sT-z_ z5kf!YvLvI!+&jbJrGLorxIlZFSzc{ESN9;4kpCw}T6XR^-lG)#qZgB0uyeZy6Iu@S zz6SkT4yo+))ZC{|`Nzg={{bW|dto^e^B+YSWs z;8K6M7__pJnDOd`e*pQ%o5Xv9z7gzN2^=AWG)Y3;#-#Uk)Zut{zesU^suOV(6QnJW zQgyO^z+8~olH)%*s`*DpJ<8t*HGk2S7`FT4?xue%dd!jpj~tSijg593BDqE+RJYdD zQ5N2c>bM|Y+^2j0=BxVOSR zZ@8iOW# zc08YZmMr`BDG8Tl>`ExM>>sWDlMC@9JV%W$OkQ=*jxxSDVmCa{yL3tiC)|;S-YlMC zzOOIpK&&GL{eIm+l(D+^GluoO80EgixW+llGdiaQfpQF_r2N1_atRImvBMV6!gAPWm4AfY_>C&99)iBQzaA7~4e0`v(@h3BSk70@ZX*a5}h@xX$ z;llG{OZQEd*IJ9=SLbcuX8QlpMBe#!(#(LV5%xLo{kISFE}llOFaz8w6a+i?6M-w1 zjq12dBY<4;Kd7!ypR=(oAvd5WDOFMJq(AbA{r*98BtDi1(rqUqJ0^0%5V_>~5|gu* zEw1eVTN%yNk=s-N9gCpS@K5UddFv1|D@-!vGCtleNPmY9zlguBMu=h3pEJ~(a37o8pG!gUh8iZaN&oYs zeo6LAH28N<)B{BK)|d1%$i+CfG|HjM9(5ho*xc#l3P`0iq_RW(-|iv#@9AHGB*xRp z_Xm?deEHQjS|Uy#|4~%ip>}|oS%qCXVHT8N{4<$IBbGrW)(IarzVuJT(Va_VZo8{6 z%OKMJ9<<)*i28}B$jQ6Y@(^^MDAyvv_$mcbF1k@s#*FvMI0>B4@fnj-lpS%BRMmcSm^#? zBa`#U>mHSHN?k-c_kp%GT7%2dTne|xi!0py4;{_tluKKd0}pKhw0i-iu?vB9XqNztEdiu#8*9ZXUYyiz z$eSMMIe4Pw&*2l&lTJ|NIBnz~p7tYb;vcjU-WU)HIZBE)G9`t9MHw@XGRF;Xf6pbb zad{&MXyI~*w>ZSRO9oYT>l`2#&goS7jX1zdx}6O+0gJP6vU%Et*8NPK$a;~W_D2zU zq#dLvcWa8=0P!i;Z}aurJsWjgd;#3l7A9l`op}%K>3~j2o)MnJKh)cH07>z9#T!SB zdYg)jyB3_k(VsT@Bk|4jz@U`aF7fIdeV%Lf2l5|BSM!~ya<7R9=DAv>P^I*e=?tPA zsp=bu>#qlWzauM{{=$r6Q%HS^I|kpaHT@aVm*W9Qn{t%l2hnA<8joT z8?Pu-9`}zP(L4BLhC40?zQ3yfk;}}#jcVbCfnlh@TQ-}lG=)1|FHCad5r03RC8u@@ zOQ)k6bn5zlbMfU&Z*^tZP{tct)t3e27GCg~)lt0UsfcW?T)J?)?N9S5tM;miNz#@4 zvNQd6CN}gO|4QD;iRRDR>*?DJk}W3)+?$GN9~5PNq5nK4$oyqDv(efaJN^1OUvJII zi{R~TrZbi`l9pAwM=PYZiFeWR_ojVL_(YRrAN+c(-}B zF9G8!cE2m1DD23g3N-tlnsIQ19hOxG*s*K7#v8xn&A|1QGawauc0TH9>*eAG^*Di! zJi`0juyP8hL8dhE^S>5q$J(3^94&mLmfYL2zTb~HdYoxkt2p_SDc+zm>f^7qM8fv5 z>vgng=HHz?2LDa>8jtDgfqQ)Dy2)>nm8W)rQ4?{1Sws2 zG|lSVXLc3o3%OT4j}sUzijE!H){MQ!f1mc~a(!E@-)_IzuhJRQWfw5B*M1sPJ@37; zuM*GtyRoD|1q7he`7Z8|%p-qErp(L0)UWo=>jjCf>0+bM5EQ$vYBzUcoo-4_P+buu zO1iYWc_VH7>7^pQ!}X&*Jm2JteuZ5D`NIsK{pp#$#ty~G;>pAG$;ipWA->It{W|S& zhtSH2shOV=!}4_$Nm7zV;`TTpE}SBJ@-!Exf@y=L&Z;#us^O@#n7b(P?8x(v$?qw9 z%o6^Tk9WRqYmEM`iy-i)EAlNh7Hu%l*b#-!t>+{_o4+h^JF9XZzf?7EX(<; zc>lVYK-%xd(ATCGs^zj3Ona9jnZ#O17u@VQn2}s74tB5u2lp^CWad)#{NN8!v>q|q zf^*QhguD0b?9K5{CF}jXLzoINkLUhISZ!^L5^?9k2cISf)Z`Pqn;YdO8H0OU7(6_W znLhU>yH+kQA5R>!o%Fe%2nKGz*4saPc=Yt?^Jw&m&HoYg^j5~JHVG@ainu(~gzKdWG{Pcg2 zY41eYfb26DY*_}Oc)7V2b^33kNhnv>cxQ{KP1;a|1BCqk|0Cd_7d7q1qE`C zjH9y@D&{rA@UZ#2@DsfzHxy}OZf#mTdorx9kDAF&V-0Z3Bk(MN}-6(*(? zk4iq$ZH68yZO7Rh3r`a^0;s4BEj+z;I)=t>2Uhh_3uj7IF;@<_p~fURKe-m2t5jyi zgQU7H@(g%h+|A=-zx1uGS&CYB*RFL3eE6m)knJvy-`hO7 z(0XzrE=+Z)%%tRcQkH_}%s2Rs-u68F_*=uXc@2rbknE}8cNVPPKHRh?rOZIoA&_%t z2q*D)!G1$8gMmpovWtj)3y2h$0Y@o2exQl*v;2>eh+dqP5-@*?A*;@MZ^K|{0g{Xe zxr&Q#mF{P_)*6igIeTlATT)z}adV=CZ1(aRc_A1VjUz1xZGB~IVN4q-@ue!0vpxT| zC|rt~k#~{?kkwfwOr9H0AhAqi=Tlfh{xx!Jap)nLdxVO?Q#LJYS`FP%-t6`~`O&it zLWf;UISPe*nqh0`StpepyTG})tQ>rWZ0aNDEOs4NTR_%t-f+UgE~0J#{sYIuyR9ddKjqA2 z=S7|l4I%xLm^-ov$jduPMP(^?%oW3T3h&6QkJXHJ3b_a|uaG-fQ+=iT%Jipnx zdC$45$(MY;Kn`K0kTVz){)pSy_}x=OXf4zh5bU;3M_&~rHp0A-wUXz}?Yx5gpD$TA zBssP2Ib`SN9Jw0N;hXhZY1#-`ZSidcl2BxyY!-uVE|S}c(M=v?H}%fkgc;K48t@Rs0znWUJp!86o1ME6>9x zn&B8vz8N&R4!T~t9YNKH@mgi?&JTL@N0hX&R91xTf7*HnBMISqV@Qg*4c-(JMJJ+# z`kw!}$@8>llwTKhRPxDtkTTk|f*pR;xv?X|J&s%KnWFcdvk`SJ%X7z4BZlM~$TOTa zVH@ll)4>1`cH3jRB^-HV2!DaxAA)`Tm8C$iC`SF7;)rkqt|oD~(2As8IvfW!rjH36 z=K_z;gM8M=RCDKc&w%enCfj07hcY?%4!EPA|Kk*oPdc>2#d z@<-J|xs|%F-@l8<>&#={2ylN)$UU52E?;U{I!r#n!$ni&B#gYKB&oXrYHBCHB#zCg zo*a(NcOGy1uT>Rlq2yGMWacCEZyjg?dxTi7rD^OS2*n5|^0x zg$y}}J+VVeE7vM^9e*hJ3p#e)5Bc#9LNJ_3mDlWlQIu%a%kP?GJ0CuF zJTP{sCh2nPMw=cu*aS(Gfrq0Bndr)K;0tqQBLS-Gp`23Az=SKn^Zr=BIRVQAy4Ib+ zm&VeT4ghw*DNwmltg3a*2ic$nQUvikdM=l z7Pn&AX)q27qc{!XqJGQa)MiHoaYtea*j}E5afq~;i)c+exh6bL$_+|L=B)^ENb1cnZWXNh!^NYhH7Luhp6X4FuWZ% zKsu1+f3f-E0kiU0M-l4zhf&m}C+MRGWwn(S4+7j%LX>~l<7Cip`G^6Kbz3j9D2|A7%n z3!YsZ$QgWVse#+b)eEhAlk|asPk(UNP$fm11u$4X#!aUIC)tul_FK#}R|M}Hs_VGZx+@HgLlS@a*j?BJB zX&oPbgO256zJq3S+&$NqXDIn7B+v-I~D555tdR1I0%a@&~h*e-J#^w1>)iwF|$ zx+>Xgqkqe!1>c|<*sqrkvu1WL)=&-fC|`%{f>Anc+?m_Cawkn7B}JF_;+3Q0_H{7#^trTIUH>B#phqtP64gMnnd@ZP2`R;eoBvcMo=S1=+Z_8%?rwTCR=v}tXqN^ z{jBbaM32NzjF7ZgZ0V-1?v1WK9F~|)eo(eK{bZ(^KYO{&-*=&y!pPjN=7YiLXGuun zz>DQy%qbZFuoVf51vemQyTWi9yA*v$34UwEVY?ugJl>1Ev=5U#N9RD`;mP5d3NG4Y zQKdCw`k$S@Vp%Gr4LR7m`H*{*i~hKFdZ&fFhZoz1X+}a|;vNdc&RG-mRXhsi^G?XQ zo~??o6~Vx{zbw`#cOk{aP7Q}M5ZwWJ>q*fp1fc~#AsNv;^+Co0>bUDl$8ToBb2e{!xzl5?RnqNsWhu-d{+atI@P-W zDgNJozL2C|jG;tc-%0rQC(ibIDc4J@N`{(F>~52jXJK8xEO z+s>Ji`08OOrA5Cd>@5K&%dpaPa1E7J!0QNP_dt<`$m4|3w2f(MTO4hrHRy*&UyR&T z!rB^+9u(ghl679`c7phtT?|cox=#5W^xa!X5{#VXiEF3yq{?uBmMmwA6zwt65@xtK zkszw5Hl(+BPl&)91DN4(Mm(bcSr2AI{r7nqyMc z-|sMYWOFXFP3-qE3`!)wuO*8LV+8NOL?^&hhYPU_@L~;Up6^US8$p{9V`z77_@*A z_eHZ*Jdfj{Lr;9Q2dJJ&G*$Tz0Vv&#NA3xK{);v?CTOE-Y8YOOxVp)M5!|0Rvc_F3 z;m=2QZf^aeHe>{jIECvfh7(;ToBZfM?Q@H#DgY>beDYhsTTxK0nUxrxq50$zYhO2Y z>HDfk>KB-*r&UWmuw04 z@Rx!xQSa2?WH3bUdA<}XzNGN%8JH9_ehH-N{AZB)zO($p-%QyM!qqn9qdnw=;&?Re zybpCJ((8qSOi=ya|EmRHGLn|HyUR9UCh=vW|J|4ELCpc;{`b{3ulJ#bbc6T5l@wVh z+&L5>i8jl(gWebG2YhT&{rurpLEi5{cdU5r&6iX&-Je#&_18v1I9U!2Xj>nor!PwK z%@y*&zC$^An-rNz=k`yR#dSvH&h@qigjmSfs=8Y3Q$cJJNqRSh^}km_*xS|nfLQ$-0@LpMN|>a=tc!VTtB@&Z_@9p*-@m&k zP}v&4E5APciOzT`?>BeZPiSu)7G?@7^KSY;Ah?Ss*u_lrS82rYVml~{B z{curH+J`Tb+7|ZwiW1`O#aGLW1d2h{|1bN~=M|l^wXK}g-)n2xLbC>`F7$jLD{jLs zQ!vGooppnsUe1gjSum$A&n@HFSQXvCT6QFkr@t%k9o7s;1{~hUVKM=8KLgSajjiT- znCw_7cj*fCr;m4r9;wi`mxMVW8?V{k?!F_BV(Yoe0(1vrV6pp?`6vY69LpVvfNN#| zM!!q7twLFjT4O~31h}IAW!|q8#gAc*$UDJXikFB3hlMYxUS=J_1xSQgsg9=x_Zu5J z_TJWnT0$}Dnfs11w+<5BYIy3xbb!KCn@PRZu(x-OU1Z%?Z757l6yU`H@1x{E`6_rJm7=bU6Hh5v#+;eSO23kFVg`bp6{ zQBBozrTRS!%gEVZkZmEpzq<*ygzRbeR-q-Ok9J?JLw9;hM;jdeduV{}&zbx(VxBm^ z<>GN4WwWL4k}daH0kTr`?=kOs> zupr85_RHI-l>-j@xm{YBs<>USz+!CUfM7dA~lOZB&pqp@85aUj7vsy1Qt+m?X_6%d7VTrts=v-U_GvKRzxG$ZSN{~?3(R4C^if8fec zjOa#53Vz&0W7$h;ZTHTm2IS_kN3k$I-Be{Rpm3$f*hM$Q( zk2Rv_2Dcy9-ntm;EsK0V-O2irm`Y6QYLlV1)j=6-CzB?3hfROu$L=@4ethQi6iQFS z2zd$DmfgW}XN=&rQ5(hB3cq7{ppm-$KjZz-DthW;>{1TE5G`-Hr57L6D4h36=Pkuo zBY<|+#%z8X5&=%NvEyIj5g0>`mJHzoWBQSaZPG~oZvOK(c~x=xI+_?zVssQ&%& zSS0Mo(_$#}?Z^wwcUB4IA4!iUdK@3>O4j{7oeAW(S-=e>>R;t=qTMYJ; zw0YaBU@Gb3wu)TzM?dQ!W6*out? z7A=75Q#ugII|7>aP|8mmng(H`^|s2W6C;#lwWnyx2ck4R!ZO(A(ORVNQdDrZ;vib` z`dYnW40y-?oE2-moD!zfGREH+=yN!yoj@Xl8XA%px3!j=_kjp8pc%-s2pkwwoKFf> zw!+p8rd>FG*zkK?E9IRBH`XCZy$D#7Gvu@D)>agiMkUHYnyAQ=jK`tY&M`|A?H_-C zm6@~I7ouvDqkO*=;7P6To@KTmAq~>EOe#o%8E_}mun1yLb6s?9aX6yN4|uHr8RXu~|KGVlr8T}Znau_orYiBdq zR@)vLt3W~fc(a%e_)_^IstrviDMHUTAu+oHvkcvW!PSeeAM}$YMhkw2 zDoUX4Cw_MiPSD1aH(+_qz)o4yRpH?TK=JYQzYrkNM5Xo6~M} zP325`up>egWnEfy$_=55RI;Ob{F-2IYSo zAoj`4+q8eLdtE-w%whjmrKI-cP9o&1gkh76Lj*BX7&E&i(J7bIVXpJ**(}n47`JIn>F)+vqsb(!}5`CSs!s zWdiB@C^4>-GGJ2tz;loXxS@_TxrU49mJ`7GA}4ML#N z9tkyMi1jkhIp*k0*SSj?QYT9<_A_54DJfF4qeEs|H*HfFy3Ky{^D|t>K`X7xj-Ax@M3X9; z$u|oS4kHx3dQ@ZL^n4d*)eCHsJt$#)O1>Qfx{@e8TcsDn{g^;(NH zy{B;y$H^e zgOt{8#0cLXH(}a6reB5Z8A6!OEerp)F=f){lFOz-S)!o7H(cOMLb*XlU?<*PU&#N_n236}+$NF5JiB44n@1BGn@@hY$M~Kk z#2l7+Y$GdRRD@Ja;cMtz{65Jj;=5Y(FW%*kdeb3^9c6XHC=Si#w0^VB+*OJJ@mBSq zjc#@_xR82;g6RpbcO5EQ-d2Yy(jzoB@D9R-_2+je?QynEBwru}gy{xixyM(79g%&f z@;&p+*}_!Mkf%T8ZXD@d-F<_Ts-U^uC(PDNQ;l|AquXiu$E4^5AwvqA;vlkw|8{sFC!3KUW6X@CZ;uYiT^}k5OZ0nzFDjshNu00-a zzY>_bAsBf5D;%4O8a?{p^R5^!JuW9bBV|sj#TyHl{1(7-Q{(dauLaut@%LM?H z=4Ec^pm*4~4dD(Ob4J@0BY@*yfFY!odV>89J4#jIs_hf@_WlG&d=s!e@wIokSC`6b z|1UKsaZ|Yl3VtYX$Ps8h7rNf%6J-RCu7Y(|KChPH5q4GgURvP?MlY+c%=$1&H}e2zU;&SxgC>u&IyWt z!*JZ&kd=&98*SEut;2HY@=lI)UlM5BV%tRvkIzG*RoQ`KcPB|5%k!1VCwD{8uc`FS z1@rhiGzAV4G9W+cK%k5~i!~3vLOYNK7_OPh$mQ?J%kG^x{wr8U@E69xA zyV_5^MWEaNfWNgM8##T2_IM@A?Wy?Eo!kBx3{?$_RS9TJoc53sOoI{g=0G=vtJJnFvAecw>;?kFaL>R=y8hHrv_UehXP4xOYuwD&l_ zF7n$0UFJMy@ZtoYWw6D%t}+p)$^&igoh0lEX^`h@3Ewf~&Pz=09|v#8{tCZ&42wO| zc0@Q|V%3hEp$TR6*E>HIP;58#dBD2VJ7L;w;C79D$?%M70JFJcY-i}pC)kbs59C;# z@OK}8==Jg%E2W}rDki#6TUq+{eRpRmgpG~}eO{F62qo==aL)A&?z3z2`^>)m9dI4U ztYaa~I6DKhA~mKh4nw}#Yzx9)eU5%|!RBwKSQ(Zlk0lbr-wl&VGATN!){4b#Z0A;j;r8+?$Dkn-0-0Orr z#=Y(W(tkjiLerO;eV$V*aZb260%yyaJG1J#+20z3Z@isL4u)hO%n_e7jP8h(-SDDB zLJ)&I%*>$KuDbchrfAEFvPPT8NO0(DRyg0#^zt9!!cR1;f(}jLBv5A2720H(5riz27jrzCS2NYvlsBCH^=58xof$tL{JMOp>|*u zWxUa+L8gFs5K^A4+l0-+T`qPyc6AOT1Inb|mUdL#x_N*6!CNVC4%NT~AwA*wA{%XC zr7DT;3A8lK|H2?i723*Aof4M06 z1L~Czzj&A<#XoW}wnx$q>f21OfpYasWPaD`^9V=+Y4Z5FQ*e^*hIV*jSjlB-$kBv{ zmv=jnx~PQXd7@7~`TA`M(H{k&j$wQje4sG>Lt6~vVyHD(#9%L_Hx=&E(#xJRsLn=RB z$DmD}144aw_j7m$islB)m5IIy{$@75t#I~{l+9#ki5Dx) z2Px{rrxnCLi4&m;k)P*dJ`TswU6wC}sLA6Q1#L0BbUk)a1E< z-|}ziW>o0&Lw-b{tc`-1la@10!c7@#7@znE{D5i|QLDKp?2(3@gmtJ;@On2WpeWeB zU(ZubpUZ|21kpVHtn9+JEg$JYw1^{>a~Mu&ufDxby33zK<~`?XVxt?vs78+T5v;MT zydkpOwSU#{Tu6?AQhCb-!F83l!F+Fv?pTdF=Kz1W?~4jsiHoh&SBM^JQ)jZ$bm~B8 zj~6^DSnKJ$KCLz{2i_i4VIqY~F`e@pTN3D}L$Mu~Gn7FL&>VZeQC^q*i7dn$j#t4q zYeklgk%NCEu)iG61Fr&e9Vvag4%7d)+&8D;^a92a4HnZ+S)3!guNpV3F+B-~IY9zb`2Krf zopR5bh10VDCxL_VMJs2AN84XV;B-auCD7^0PE>=mr{3WdWpl?~N5P78cKqwXy*%_6n=gYMP(#uvR^nvf#YgdRJh?a>|FVJSbv zAgAoEBLq*}7>hkO$krDdh=bREQGe9_Vu-@uTF5rf11wb;K9!fA)sEdsTbKET^p7WN z9hr6DJeEN7?S0^#!!i*{G_aUEAx%zR3TE3A%4W}tkgkG+TV{4h6&h^?eeHZt`y%>V zy{DyG^T+GXg|pEUwJA&T^7X+qk6-B0PeW%Uia9pChpmf_Vz{7N0!Hv8e3^UDq(Jdj?*Bq&SvdvI*LrwwPUg0!6 zC|6OU%NAu>AIRCH^fWjrj(~qq5Gq|KS>=!Q`}cRhj<94<7CIwE1Z@W?UyibplwM~*;$8+|vw1-mn@$D7-^)*ZRBWUN z8ibft?hkj>#zQkrwQ1ZFY1a{@#T`>Q^H|;A8<*rK67E0Y_ z{T(~j1lt|RYIa0z{#9Mb#}t}SG@VE7e|#--E$Hj2|4%a}$uahbmOX9+{~S#XVA&ns z;l+;naX9K8JkDG87o9<2P=|N|#Xm@Vxak9Jg)e*1b~NWQuPPdbYk(b0+4QIJqe*fC z--*m(zw!iZ9jpUmdCaRhXZJW)ZG|2aXm%sr;Uy=Xch+N`dobgP;)jHBIm!sBd&cX7 zgnx|R_MAe>V{!4zisOp`l^M@-@6wKu_K{l#UWaa7ukhPc5JUdl7WP3KiDUU;{%Rom z$W|{Qx>XYP+U_a~;)40;tA*UXyVkvQv_%5%{W|?Hr)IHxsL8>HqBB|T6l1n6vU zK45>*CvCQk8%@z820ZcA!yqxE3rT>q1Na-{x=rQfIMR+R^(bt;ug*Q;R92LGTlDol z>@PX#$EOVcj_lttl2Ua}|H-5395I-tW+9?E;Li+?jXsQ8-ghDCI)Ac8#Ry>CmBKgs zt2%DqM8=7sT0P@>Ifhv6*%4zEiHf$=+CY_rSPI9^13gC5pd8@Hb6VH)!YR>fd~yok zmex0#w_w7}>CVWIkk|Op*=@eLT;{%JHFDQS!qGB(2OIwVCEd}LyL@)nqDIRJVe!YQ z51o_lVCza&!Q^g{U9-e{Dd|y5^I9H3zfT+R$TpkcCtCp;@r{TQ#xLxH=l&C_Uaw=q zd(DM_1R`w-8qu#m$1Djpo{(#9AP`4PNsMlQ=7=K zv#sJS{(UdD*Q;cex_z%?PoN~wj>}s)__!l==f3!Omzj}qn!hI9!4q}_95>xXBx0d+ zvgA-l$XL^4YUH44ulg>;MIXCVhXuV7+q9Cpj^@}2M)RKeKL68>xrH6C zuTf;u(1~UgIb%89A-+gmtoE*fl`Ms{fccH0(fUjd;$yTCH}TM&BayPctRt)oL$ch1 zOL8u7#)8G?ut)#7EaDWA8As&Zj6cQnV`M9@(bkXG8-gcX<-7+{#8A$yUqn5np>R+V zU=CG#66(l~dZk#gXV! z`2X2?iH*L1_wfKv{~Q%c`F{+zaAWeCzxm|$n$9pd!trvAd+&Eqk!wC3zmgJ0?)!c< zC1!tz#{MRPnsHTo4AWHT{B8}9eLb0~aD^ZZ(rQqrw7Z5{MZyPLlf%+m3T3LHMS6_1 z+=!n7^wc+8D1S-`fP^RFlOA2G8RC@559+P;?rwGa8w>g5P=wsZP?+;uYIm$T3!rZvQ1pD{pPc(I(s7&7l-V<5 zCaazG^GCNjzr3JQxR6f8lwnfdQf&sz)eIOht>4lV$fDx&FYwfLq|u`InhAKUygd_?WGgA=!w5u zC#z1LpkxZjukgARB8D1tB@Jk;zC;aj^fDus*{)u%Ec=}cwT9+my>mBUfLuAGvQ zNnoaiLnpGR{bTJ$XZF9a)RE9Dr0g2tM3ns04A{Ay)&~XCmZ8WmFx%HnlSlpBu{r>5 z-_lpPiDSGJh4}}ONkWx)op4LZ|6(Atf{WxcXcj`p-yF_^!;2GXC->(#s60e zV7*MwKYh6&&8GJXTKs3)!g#1~D?ooQVW;cqEBpX032{P?nHtTKVPN8fq+dNo@9nk= z7X}F;Vyk_Ba(D)sSN*JUMZbRXJIb3ZLlmk^)ObB#ZEZXz>t~zMYrK~t1{9R$>eT>l zRMVHdpv@UnGa9P=OkfPvUMmJ5t>03;d`@uq(e_-*-3Z2{%@}*|bv-!|2tEQ16qRS_ zcp!$@t5Gj0&W_RaM)Z~h{p$8Db|zBhZjlhvP}Fh8+t1fG!jMt)vdI@J;-(hcw8yJhQF1GKRB4_EXZXPzZco z34nmiM00=wA9hf0OIy&LvkrfeB|7jEYo}{pj9L5n8=ZH_V+_M zwD1z_>&b#sjbZjHVs9zEL+$2lV%^M&E$|hh1;naI4X~K^>w3a3O7FG^l~{S7dBGTQ z#0m3e!T3()ZT4XqUkS|&gD|)NvQ)cR<%>UM>EI?6(shC~iJ(aeIBOd>eLo8|wbybkWEI z0_q%-Z&_RJ`<_=^FF7Gkou2kzRe(x6_)DKTq<+ZhCm>cuZ_!Yz^+hw21ee_TPwEp6 zJo!O|?)txhSUh8tzv4c;vEMYWdGmVfb4%qaVUr`$kM$DbIB{=jVKcq6r^5Y8^JivU zSXi)dQQb9O2{ExPE1m~$eCD4Z&Fu!|LDl;+e5$owEBx}lHqX^<92+B=!qj_ua|2xd z`i)QdOALPQDD@|V@Ba=c5h_t4#au=eYN2WfLSBuHvmfS5#ZX+nE&qkd642M^h2Nj)_L zI(!&T=7Ox8ps#Y&NK>ul8pRpwZ)9mE_xH_!aF>|@rfcCp!GLNiz}lY6l>hRc=mz|n zHdSo>;?;XBdChOYHj(jx%b;WCg!E2QJj=b;3QixeA4uNRc@g2YR11Jg>S;3H-mLEE z8W})@3{9TuUitCBkZsu1CSvtpa`Zp) z_DyvH-M|N_sSyA4-yYfude~axe}_vQ!?>=T=+?4p+%V7hj2oi)F6Od+c3sHGI`_c_ zF@T5au;@E`=u=N^ps5}h(=GgBgbEQyKcuy;A3aCZvVQ>C`1JNI72ru{UjwAl*&GR- zkAKLHs<7c^9sdA)dBv0g_}i3x5DZ7F%|~{8-30UC?d$z&69qnh!A@(i0revvF6L}z zMYYo@%D$N$?0{ddH$Ih2<>mKR$gb3n6}-i~1M!{Y?)B3vVsHjXbRGW@Q_aK@0k_qg~U zhi)sXBH-~F?Zfit`0XE@ZqI){I~rMUc54&W(I#9C){+ufiNt3qMUX3@m$Zl`boc+Y zl)Q28%D2uH8u$)Ev>fZwexLtIYhop1H@}fe zq_+XDww))Rub62qP_RUWl`B_G=|nqYYQbVpjUm~w;i-W7DfveySOsXqXK0fV=^4?F z3)p4_gf{K&T)w`TxcnNb*dWi3N>gnSwh;ymx!O_4 zkQO({mp?4y4ENf^)}qh70yEDe%)Q)f-f%SxX~1i~t1Lows7^kAYHax6#?%*NeJI(y z`GXIZr%FGUr8E3ob>1LN9V|1j|je!sRjq_h@1Isq3nP(wVIKW(G4kx+xYigGRJp1 zuV$L_)y_ffg_2M@hnwQyP7F?WlF1lNo{lD4tG7w;#BDNfqb*}(p@a0nuho z3aGdNvvOYMAjQf)+f08n8_DXyT|XPG*|x%E#vkBto5!%4A%JcUR|d&5s%1x9X-Egt zAM+{PG!Gj%M(JqFDZW%n+)j7dv!TkeN^N>zv6+7odmhzKxx7>xBOshnyip;jp4;qV zj^W4=M}K(}8Ao((5leEx)Pa|-t6PK2lP+Qq@Q<8>nPu0WEVD2_v@3`R9-;RdA25xI z!ETKM_f|r?FL?<}%1yglJeKIu=vqoRPYFImrs3M&`d807Lt6L-?O1?G>0Les>Hten zpm75N%E~2Ds7OXbh^`@ug-wljI=F=+9>{}MDbx_C04$wOUFns5bCH}Ju?4$GjP%nM zt1nm{7-ge#Zk)04P!cT>4CmE6peSfhkNX*EyJplRQFD1XeUipl<&BGig2vRdgC5Sd z85=7FNy#y{m5pMLN*8Xz+ve_8w!AFdg;%*MY=x|~BZK$-%o*HUCt2TZmOnGmSXqAl zndeiTOQ=StqanfDyMpZFdbPptqISBu)R>0AB;`{&gi9$=7FAyDWpink!$H9Bawdgt zLy;lX@d2F=xeH4h1mTTu0fAG3g*Ny-j-OQU-VDQ`TMcP?K9v^yyomOatmw?8B-GVW znwe8i@a$Bgl>Yg!1NooT!zk;(S+oQ=vj!crEHPT#(W<%hAjM8{--Z)Xodd>|wc=68 za^y}+tsZT3=xyHWWKxq_=v_b4NjmaWguh&36*a<+qwW(Ax^8pYwIcP$BO$?7qV9Z; zmaBWg#8mw8k3526dT-dq*4B2NoPTJPM`_D)Jz7g0RZCJcMFehi+$MvP{4*Dl zU_@BnXFWA7;l%hX)RvGb>~&J=okZ&VFo*w#bD1cE`Fv+ilrV(zL~touO&@ zHhaH3Mcw-dqD+qAtAc782$So*bWC=G0gn$s{mwH6eNn)?(O0AWT@jVG)MZ-!&eP27 zMd@8ea%2&KRDCGx=}$AD~5u6tixZ;fiN4( zYyTO5o zPrdS^`iZ;fh_M6{;bAP zcP#$d`hL-KgC7;=Y!kPACcy&8IfBc~ivY(vu9ilVdB)(N@UJBU6{vc(`K2ZI>q~|Xrm`kWV`Kcl_Jl_SR-4{6dRzaEi z%62=hQW?IEh%=#t&YJ=Gu#NJyC(wpllcq6bQlZ^dd7|9n>c2y$0%A4XATzJ5wbJvk zlc25IFwK)z99NEv6c3^wh>YP76m$r%`fZcZU63@Gbdikz%qx7$JMZmVDOsd4^yV*TX)}+8O7;K|Ea;R#b zd!nzH^bXAogec8!;%qb~jXkM>mlc$2lwr3wVRfa??_d*p+pqMh<@8j8Ql@KgzO)$x zgidBJ_X}#fkw}XmJIBLP)R=yTes|I@>m<}G(8KjdxuM?M{G{fK%9a6z!)K|AsawfE zEUjnZzU9J(($vy^iv`5y1X4>TQ;uL?cL#js!Nu|PdC{JMgyk(Z6nGX@uOwNC933kB zD)RQXQ}fC9sebvnj*O22@(g*kHe>zt$3J0H+n+Wjjlwtn1d9JRg>aerTo|7IWo;4v zcC?MRB4kn2JD?zZ;N&rh`>>;T6U+?Dw{BFlGW!|MAMf+9WHC@ZKm)eXZN1r&?(~L@ z+HvJ~SNECAt(u<~6bRn-uhp{N@_wUi&g=V|xgpkk+9*`L4%_CH zl`=u?D0X7)$6vvvXz8z!)wRqsdRxWTsVd`W`%Lt$=0)Kj$rR+Ajhq;)?! z6Qa2No-P6MBK2Qg7p-u#?X7U!k_x?mVcZ&oFN5x73#5I-P!{rZmn;*Zgb&bplNKz% zpOYiNhaB}WgXFKJ`ay4GF;@=P0*(}5Omf;+oy`4!mMpTL+UZgh{q9!6?ukU&*1)jx zmE)A%U3Z3by;a^7n+XN1)8$|L>2tXCfJOR<5RbjK)K`+1h&X;Cj%63el+L8z2`r zC#Q!1-^xBjDuDN_@F`clQk4prC}Hga}A?cdE3sbayul zGw=BP{_k3|*1!ioa9`&>XPwE^>-G3Vee_F9VO*VU6qOZVq z-1-+5IN?_~R{Pe@oW;|hDrn_whkK*`lr+_b4@A3g z6~{?Xvup0sAkq7E7A)k|_g$!LQ*)P}tLEnOGW;VGC!j*_{%IbNNFq3S`53=7! zDqlk5ib5huua2){$dE13zw(WWtY`0)<5>Fz=B( z?JBaY_Dq)c5^J^>O}%vKqWA){Zogu0d~NNPO;*v!2G!{dLP!5Zs^L_T=My#8aU*(n zP!;TwKWIYT1Brk9e&$C#TfEnaN5G4?8`YLnsrxlIH4iH_X+LMa34KM%pbQNedQv(2>_tWY4CqY7+?P}9!%zUx{P6S zwQTll{|o=-)mTQGlP(p1&@#2hReW|yG93Y$kBurxib~DV2-2b_I55=R{AeECC*H-J z$8~i@>Qfdr11Mw?RDC_P0JsRn@4Rrw5Vqjpwz!c1;!ptxoB{eW#LKHbA^%0~Si~8E znMk3M?SF9_=~xt{6CzpscxrsNTPgTv$eOy&zAC(WLh zRma7|N@w9_7}uN?!0#dEftTIslSWs}Z!|*Pj799&#oKOC=tA$i@+-t{bT&K=KBWZ} zdF!no!hg@LWp}P0p6joi&G=t@fly;pA$PPEY$HaCZh8mgc+TwVP)weTICYH_^{GD1 z8dUsqF*!soCptzUSNLX14`h%_Tzcz&C#jT`opf8nb=HkQi&{eHH^_OO_~LZ49|DM6 zG8z0>EAkS|2OF33N%)bp{fH>+~5H{1OCFEu$Kw~793Hz*hdmr>N#E#j znD$V#S>$$%S1(|i)qj4*LwtO>I16xJTo!!XPmXI1FfrgEDxrc!6IA?TZ3z^~|{y2&W+*L$vJUN=X4TQRX~V!R;3x_!CJva3$GnsiYI4tR5gydQ_?`)NI6tcJE@&YmK0I*)bRFQr&0AXoP z6H>h$QVploru|?E&dta~DaZj@JYyH{@WUAze`5VR>fm1SBv6Rneb{-?aM#!cf7^bY zy_(n*I+cB{?iNaH_K-S+v^glYqt5yI)e>oG()h#Ua4f<8v)P&oYIg@(cRlY%WG5%@ zgjP|GWf65;TB=pSRbKWx8>Ot2yRKA1*rMS87g(Wpb6ZEwr7<2IvhSO?s^{Xx(gefV zcsNXE0OUTdrc$3EceH;9;F&a9@>UJNM(`_H)(sf!0A zUMoF~i!RG@ecBy^x84W?P0KLXmRC%*Zka|cV-mG9tWD%dzeeQIsJ&sqxdh>tXz zu>UrDhEn>8iFy`LJy-OF5V_3jtGBRs{X4X(epTP$cog+}@9v1w#?S8geN5lVcG6i5 zdogt+AE_+4?|W`0^h>_f zbbg#Gd`<09i&uDGjogHXc< z%@I!i!(ttjDYCw!35RAS38#(8MJ^tmp7CwB^lM`Yx9-87@vT4B$>3hS4$f3^@6qxU zdyFbtPhA&3=>^UM&W`(HV*`=8ja*(5Xv3&P?29g8P_V4Cjp^f~_2>tMm*IzRHg%pB z+4f?DfsT{PS!jT%(fyN$Kkr`LIS?O`CLeu-x;l3MwNueu5!Vhqh-}M!UN|3kej*J! zaD$P_+{9^a=!ZUuc^uv(yizI^Gig;mX05t6qUpFm*KIg?*&BDJLng;oV9rMjc{$h{ z`2%2@QIrWdDTQ^jY%-s^i^Sg7)*X;`ad+C=Xt2z^ceBoY38+K*CF}niT9}C9^T7E7 zTM=WuvRcoz`P_EF#FJQ`=Y)U&qF2(Qk?hY3$^Gc1D4$VMBeJ#K_<5U35vo zz0?|KH-!G|(8Wf)A|MCDPZZ2V0O!Mthc;pSjUZYjc*T7B<>B}4%4~G?ljL!? zrhN5cE&Uki?5UwhgY$v@wqh#RcT&b$Lb$*o1ai>YXseXaS{cCu<%`It7G5p3|J(04 zQ-!lOtL|ds*TW zPU&LcFQ-m2W&SSw1|xa->o=&L3jj}5C{jF%*=)VQ11%X_^Zx~URfO8zl%3qC6ee5j zEI(5GPPm}Wg5_u!lOz6=Hu1l5%187sH>)D^06F^sWFQLSI#Lu14-?vMfjOAohZgUW zeS@FNu*1JhWK0HGwCr^qM0$BWfQ$J}(H&9wHKLk^A4msjDw!MA?F z)GP40PSO-pNo;s-PQt-si3GIO;a`Nd-JWcoJYk4SKUX{~C<^6KkXW9ZS!&d{x-M!Mbs&Bw3`jSuZ_el778qx09xk|6%Q6DganO;KFZT z4<7KCjnKjVdoxMNwOpa|l$Hl`3#WMR9qj%6d{C^D&@EuNY3;CUo!WhKW-ec!J2zmh zA7VO(+)?%DO8NSyd5OuJJJ>jf0^apWS1cR?89S-;Awwg#f{Gyrel;4?jIpVYvhkHgW~+~pdP+~F2sp2O5}Vl zF>;9D^2QozPo?1|n_%lj_5DI}eZj43{kp1e^`Y~0;5KC3Z=>t6(rswi9A0Y=LgK?? zicS6EuFDN+DgQgLoe%0JS(jJA+-FoBhS%X}*R8ZYr8gQ-f_FfU+?`b%h~LqAAI9C0 zolHau~K2fEH^j{*HwOC46rw+?Vf;guouX> z+w?mK%NX3x3zw|;|5|`XK~%PMZX2{jb%M+$jc&e|az8W*H$PIg zrDDCGex4uPf<3%SSci8K+c7nNs9ge_6E9MN{#kZxiAcLQMYZd zL)U^XpaZm*n^&udj;@%l%VfX1dqlQ6`MvC-v-?gh;NUO+t4w2Dt;#QJgB)feli4U% zzoBoJB~X5UmR#A2Bf~mkzCc%X(B(d!Q`Xur3V!HVzC9xEicAST$~bomJ-5C?gr2S@ zI4~9Y*&h9xvF0Dxtb%hrI?B7`GEy##cNhuWE@Y#b&TJzm63ala;t(A}^W_|KRA?d~#A;V1qP7d(Rmp7n5(b^@_q&;8+~8icmq)x0;p zoWWQ_pTUU*IX6^&Od0szbOKTtxv)DlF_ztWbnx%tNVpq1E86%A+LUhnu*=5A#n z#i=?Jz*sM;)^#8QSZ)+Bl5e7V*`PJp&9S|TX`$Jqpw`2IlpPRp;I=lPo=7*RAWbZg zZ7hsb?99h4nAi+{N61C_C4KpvaLbGVDGHfPfqy2ltb*S8@js|1M?xH9ullUq-!}QL zpC|^yQ{bo{h3T#h6ujOI9ouRVcdMZx}IYva6iqGMN90N95(-F8LQ-T<$w2Rdn8A_ zIkZ55www6;4bE(dKv7h9_&FcigHWZ3yVT#4)9NnB`l%C#w{nrngIc;{ zNj0ZY#9J+%o#q=xurAKYfQ!JTF8M|^1WnP9Nwz2K0g}5Z@h%JQ_bS=PzkmWmFg+~q zlsYVE%&JvXTWMJlMcQlW)~l3IU>2Qm>)#&A`{AFs>jWf9YpENuUP!HEE-UN>?aiHh z6hvbpWjgEX9mZr==Gyr5heU`<`%uWw>t9)DvBT6Nc0=<^5W;_zs-r}A{rlfjxBEf2 z?zYu?RR7&ocs3GFbuJ`Vfh#pc3bG?0!Jgs&kkmjM5=jMzC%s~Kb5`|fF9_KtZ=BMm z3e8NdS~37Za=w{+kH3U13opzwB{}AQI_U4hii#of@d@mG(so50-EuB<s@9-x+C#CKQ6rIrv3$i)x>tqZZR+9#|ji^mZq*0Hbdzqq)P zjQrv7oU|&Cb@uQZOIu$YMC^NC$I4_T+0YH0Lxp?2Oz&&63ktd}Up&3<>-8;y=v9xU za~qI{7z8SO7jh@N!7qbAgP9{vmCqrF?39fZ_||xJF39KAL8-W(8G5nnJl%xhKL=sQ} zFK#Cr7?YrKP>gp>%nW3=l$P|E56%mD?C_lGQ*C1p)2vNw$FEod)5!DIA$&^Ez-&1~ z;*kuYgWL)?rMuyW8(x^#rZ5Xkc(bN%kDeHYy8Z2I;k%dpi27;BEv;!GVx9J%v!uy4 z;>)wuGRLUXyT+#VEons?AVRdtVS8tE&>}sqZpS8EZ@#?<3MPz^eT<;up8%*Bqpt2>|gU3NZ6ZO2II=q92j#gT+yds&`0`P~^dHebZAoEnz+;_P}`GqAMpGZEEpv9NU>*;CI0F0Y~ zOM;u?Q;GCB$7E~qq61chZdDLe{w`Q*8U~bm&EWQLuS688BZBT9s63GG)aofCn-()U81IUj=xc7$1i0~*_QZ+>Gb&WXf}og$E3fx7w{kr?Z}p!j?_oCg zI)n(%!qqwQm;<4~d`~l^z0zF6h$vsSnDbE?8v-DnCP!=_&Zmb|CMUz3`Y*OMR`}D2BUn z7xRb)Fk9>C@ex}S$G02H8BB2cIa4{i!V^n*7KzS zbQ8YZo5zLcMSuD7tT?U_nZ_<+5OEldOrbsQ|37{KJWOLyjMpXPM1?#x`on>!@>l1IJC3 zy}wC^C*~*C8Z+6R*76P|{zOUX?DN#NNU4@$E6(wT+h*CnVHq`R*%rqS=Md6|VKKh) z@maSx3~h)1E!#Udx-cNe3~zfK#tgW70HDw~y9|Wi<8&J@&OW#8ij-T!!W{2o07)@2 zpxfDQG_Un9wCJzLa?%XRlPJAPjr3;<%QOl9vjSAqJG-WT!bgbTU7R^B@$UsA z#zW_NMt_=%<12C&)Odh4&c#`@Mf6X4`qp9tq{WQ^`8xBH!9 zj6%8%HyoM)Lp?j%U^tVy7+`AsL-{I|6J6xlG&5z2Bp(Y1wDz3Gv=;Mq22XEO*L{=! zMb_@w&u=N~6@Jfp1-#27Z5>7D&_ox}pbRTgxC-q+DSq*};r34>LGjNJx2-769w>Wu zGlEY=7z+pAo^puM9d6q7QCYG>*_&;e3bFxZiM2H-C9Pk$eu#`oW@}y7nWDDuTxz(j zWp2fMxlBxWguV5|VSxJqz6DbQn*aw7VKu(wvFzP}bN<4hvAH86aNNJhup`7meqH%Z z%fVMu%HZU=cf!9f>g$LC>}K@TWvYjM!m9jos-YY)PF(AB6Y2>`|T6LhQtpG)R zpsl2MzYQgQ^9@zn6@OO`%hUAMGV2qxbpO@%#jEeaKX-5@%GW~1RCyW(=+qx9KUorm zt}F=QGyL4W5cj>pTnW6y%aQU3XUg`C^e?j`JFnMI&i;&Uxm7aRyb-T$PbWn3IJQ-N zzhEBjF2|Q0#S*`UM<-SMMrqJQdIxvqLf`MOfPJKL&tg`&ienLYDDJcySv%LHZ_zZY zPmnNi=k*uF&XN@5l=ZY5fFEhF^GFu901zy+o^y_);LC;_=pU^{Z*K`$_qXmmgXN*kUoAcfK`17+^6nUt`d2 z!}-!o5c`)6N{-9AmGPI7(oHKSY!njts1i&LlGl5x?-+)Os16P%49sKvd3KgIBf%_( zME+-;ZD(sCe(Tdeg#EWBht3a`>H9t~50!Lgn{xXiU8m3$+VN|m<<|-`y)+4(Xiz|D zY%rk0Ym=VeV~VS}(*e6wcW6LF(0pC3Sp-FQ&F?c4n_Iu`8Vh&Lnm@YSAkY9>o7&r8 zz~J*hDUR3qa_{9p;xIr8J;?(g^4bc7Iy^hoeYi>FV`rS^5y2e=U?gw$qrimX&glkVZ~ zL;;SS@|k|#jzm7GkgJ&{VNuG}Oal4(iKJ^^g;DK4NOo%&1o2yyY4@>5BKc zQgKFvgT~HPnFE`H6Z;~H>96FQSN%33({uUxo%pppVNG#lj1+=a6rB&-T)* ze$1ipGUb15$2Tn=C|i^fBTmJ8G&wM}0LZF&E#zM ze>BXyT;qU@WpJJ{z-{as^xoKzrbs|jdmgx3d^a&-IrQ$Ldgu=^%LKE~UEnSRU#fqR zn@W7sZqBWkpB+WZ<+7f?7Cjcc9+L11fQ*)|0{&l+7aMNrRBts>-acjd1WoC(+;wh_ zwVV(kCOoy+%nhVJT`&YY8{|IiEBw)IHCL$0l9f$>5u@}?t}hkg&lV`NgSR;phbblIXpVNPD3#5us26QlCP;czvJEGuWRR??uPY85lUW zaKr;H#8*PSq%~+H50;cg)^|B;IkA~unh0WB4{7$#dk_nFPE)+9#r(R-cvb{uOh92# ziL9i)+ZoSQe3;j8?+d_nrh*O*zKjhAEN3}qyO4u`t(9%S1K3(Q96zX3OVM9UGT_lC_b5hN{A!r{rptv)D9iI5*3>tr%W+nnYfEK0 zdb__iht7WTBd9^${c&mTqYZOb^JgDohpaS~uuSLjoorz!4JFUhf#G@ig&fGVYJYm9 zAoM}bI)wJ%AQg<(Q@93Vpy}Cofm7{2i4y#HiXcmofwP3(3@cX$jhhvpKKsG@eJp?4 z2j8j|s1uUb5&;me;+D(Alq0BJrRs(NVOwMTnC|Pdz=k-WJb9Q_8K5}RePd-;0q|lv zXp5{nASECQYSxI(q5Ow(mpS7fKJ5ArCO%L*el8ULY55&S`U^tIWQ2F#)Oq`(1wy%T zshx3&tLY!lDiB_RmH1c)w47c3*-!mgL5{<&8jE6gWj+5yAkp`&Bfp!We{4alfm*cL2xHKW zz{$gf?E2>Iay+Z>pjGeB;R&fc{MO3saA<*iI%wppB)PEdXmrt`xbGgr&B;nwNRTgM z+QEgCJg7TAqC$K=5D*FQ+8ysJC`(_f9gdbueMdo56E6D~$SBJ389hv_Nm^HrbRacc z?HP_rs+N96KlDL@rQ9C~+PM_4=mrE|Skw2g%ibu@x4+|tKhAaaSZhipIX^qxuS*}7 z8!qlSN7)+e0b8p;#r#ymM$6@ph;9jJ7S-AC-!0}JpYV$g3RjA;h+3Aa3>aumKs z@C3IjaJw9sa#)rHq?Mt_fg8_7=OPi{4D14xxPYH?Q;c-J?v={Y)6@67wS*-m6iBS z%eB}9%Mb!G)0PRw1-i>XKztG77nN-8r^WyXUSaODU$c0qKXl3QkCqcM%uH|;#ma|& z-J|@ywJ6PcclQdJQdQ*LB8pQn(JmdTG*Ryhf_;oPnK;;hzBegEtv(2z!W1x*L6+ zEx!NgQRJZGMdtvL2W-{D&U+_g-I^f4Iy3Ui-U6w+#L+DHakJlR@WcMb;p*E)kdF4c!WsIh%%Twpt<0jSS?__Z^c zrNNxbFQ?~|uvMqhY z(eA<@Q|<$MHQ*P7QpnZ;?Po!3CXYfo>(2s8?GE8DLxUa4)uG1Rjg53e_sO`bpBLVa z{dJSEhd7&gecc5_V5|ea3Y*kH+%>4Bzp2I66^whGG)5LMi1&u`f?lPr#bY(ZN^Y+q zZO(2LuC1V&m?buN6L{6l5kX1IcFDWPHNLC7?F{0#;a$k9D<(dSSw1C4_vsf{` z#CPr8ptP>`zEMh~n+=b)L5VNQ*VWP1)lH-mCS$ImNP1W1IuQ3Qrp9m1_h_|_xWyTt zMp>@BlC~gHM=I`ER%HzQHY(bIOB1!!PLKm6N zHpaeax5oQg{(9pZeJCdVifg&Zk5^q z{vhs0DY|rr&JOZk&eiVCR}kPg1B{Ts{|Qd!jNb(7gPJZ zd8Swu<&`-&G#dPd7gG?RE~@{ClVvgaw!?ZbvG?hAB?;rCgPK_x*Kf={=XEb$pMVO4 zE5ex%0QDbVx1l)HwI9P37IlJZT~QT$DZJ6QXnN#t z?wJS`-4m+A@kgvPtcH_=f7I9hy-EWR@i3k-iJ)?+j=w%b0hBP+koK|`!t0!&&?Su|LY0t| zILkIiU`K*S%&Wl(l}3r_JsI-x0~Q7~C`i|{NfEiJoWn{-DkN#KuZAC&nHcCq4rF)F zdq?WN-Ft6P?=Hg^Tt|TAl<-2Fkp{4}5ODTQ zb#nd2FZ%wQk3CdZ<$;?BP6rNw7{}(z^OI_+Hic102v_i^82C(K2jAsmxR3r}{b(*} zak{J_r^Umyr&j!7%to7wYl5;c*MPgQK2Dag-|)C;n3ps`+~KFWRA6cRHr`Q$)fIO@> z-#@jTK;@Yn$xyf&DrVUXUEG%>Ifik9<}m(VM-(futO(z1a|vpu>*5WK)vxdEU;1Cn zj8gnrioJg`Xt5CfBU36+oGR6$HN2z(8tH8d3$zIAhZ|Mzlrs#z&;L8$&gpddiiiErKBBETKbbbe(yk) z`9rL=+_zOOXx{gCVEEDN+@TCvgkgDz11LeKtQjr7Xgl^LWh~kEXr+_1&Cgk0;uEs`13^*2bSdx~Lge{x9eg+N-)0gK z6;n)Q@wx@%>Oo5##(cw(Riy;kDO|)3S-&lZvaqO#DCYp$yREn5w+$Msp5L4-ra%zq znrDm3^vazEdCJ79MYKQb71cx(YBxZjRX=$Cd6F@!HuQbBSfxjPdYc=KLlIn1_4u^u*n#@-alnk;T=>b??aPgEGgLbPgR-IMipm7DWcon(W^fIGj~g# z&2RoPP8%~}iaN~u9F5y^MOi24vg3^F=n&S81p0IyhA(;8 z7zq>P!TyD{&zQjwYEH2(pYo+naSMI4S6+umWF5?@A;_1 zcLXPh3_DzI)C#biT>BPib_*!-?`Ao( zQ~RM@^Ef{vS0{PHLcu(NE z4)wf-J;%THxz3bv!vFU^<@ZHD-?_$iCGB(X>!oaVoMovO5tWA{k(Rs*6rUYdgTTTP6Q14=Lb-k`z z#C|W>_bZs9)%Nqf-CxBz{uW02^<$?xGNaqDP%2)Y)7+V&WYLONm!?HW!aedhF|r+ z!wiRxd6OMB9Sy!dbsnmW82T_qmPZ}ka{C+*M4HC%N~ByqTslB3dq@wAfhlTvywE>$ zW8K8d?cc*vi^7k@+e4?TEy_V`N}#toPuqIj=+n-GS}zuVzX#gQf&81)MG)sZ_yq0T zh3-=*yFx1=RLRkIOURt5ZG`l zz9qab1%+X=JXsMUKEHh|V}07jgnXJyUqGjh?4D57s{Jx?L227+BNP{O(n?GJ_%lWj ziQL%H-0t;IX;kCGD|M+%fAFZPVg*tXL&hDuX3&dA)4?9=umI=aTiT=fPCOb6?#$fR zkv%}gX#9bZg-d~u9hzye>1@KY7lh}TiAqxFhD0Am$ZYcRpht?w|~*Ya+S%|zIZDxLRp)CWc5iT8=j<~;cZIs%q|ND{vYVEq`wKlb-bkJVWm-`@k9RD58OS;Pw+>E57zx{=Nig6qm|?BmMnv z8|{o&c{Ta?HJQ$6M-Bb$p04yZvXKC%@ie`p20P0@Q8iN{i9!gO-Oz)oJL`# zj0x_&NU>YWmv-VtxnVB6f17dK$dWmj2DL8cMV;#Eiq&bwi`KCzq7*&A4u+-B4Mrd_ zA22DYdi3|Po_!y~Pa7}$Q#I!7aYeluz<$jAr zS>T>L(fh)7);I0<6f#zYb@YKeY}x&?Y~Kp)=L6O-%?!FIsr_iX@5e~Im%nDV3Sx&x zY?${H|16w2fm*C-Du0@BdZQcIutWz*_5)E&F@-nrfR=)~JGNt=>$8_gaaMgdw6v0I zP=MxIT!F7bY~Q-!Lyr+|Z4vW}Y^t+w*US)zcA1$G(g$}3EC_bdk&*E_>$=ET>#KPWBuzYlx8XrhZ3-Nr0NQqmnkxS&WJnulq)hpi z-#OM41Q2lO1;G}(LdhZ5mokX}BII z*jz)v($f5I!U@T`*ii-hi>Den3uR9Ll>Xe!0E*URHHjos$)@!NeY0ml0}Sv8bb`U9 zdmKSzT3|`VLNc_?JdAWH$mav3iFsqUcy=Lae0~spEbjY&63;q737M2A7dRZX-(pYFx<+0vo@}A8x=o#&ZH3z=Br(R}h+! z_T0$!?}6wP?c$WVKkP9f^loux3cCScCQ;&i-DQkpB08r?jT5)3jZ~|I`nb9D z{JqYueq0kQtb0z;PgUVL9wy3oQ-0<(OCibad{vmq1~W&< z|62W_V(G+2#u@GJK6Bm0ZwHtm&2OCu@LDXulBLbp-F+xwmxCMdAs&svzXEW?%Yydx zHdcScOlZ6&xo)cV75*~9N~I_4Te17z9;Z~}4&KO@XLMzihERu1W#+6{B-8m>9(5>b zX#3k>-cxVD(R?db#iOs{ly~M^U{O%FbqX9m5*&QixF~47qsDT0z=$2bPsE_(fsz9a zLt5o&i7lh5Vhb(M9He52OtUhoo{&`McLI@EF?UTk7Y+)&d>lIaa*6=Nq|jVnz5eAb zhx}B!g=gA>_|c;PKrY%9^az5@FKzuWrHvVQ;S zs_cQuXxS6bpH<>s^RO)<#R#LHa{ChFYN={$9;?fK8!58)9*LCFTyikHJ~`wFFvyO) zwgp8*y)NE1E%cUV1|6yMD=UrnvKwDZnltP9&=&({fUiwV%tN!hcC2S}0_-M(bX7MBP+Bc z2xZ6%{GzAcdtDq;3M0wjm?>Iu)bSiq6@R5KZ|2?C9hJ=2UL8ujvQ$sJsf;)D+lkET zJja1zS_Cj)g>`R5_@~;^p0XWVpU*Jfbg{|mHo1ah2S+0jX)OKK@QLKD>=TKrk&p1s z*q4OX2lUtidu(7hKz%yjsg+nji^wMztflZQL)la)49Q{H7xqKE$8J5=))+O-KRUC2bS~xuu~7Hmq&{|9OEXy($Wh8eIngIhQG4A9^L}rZ+hw~D zPAD>V%OKBsRuWv8XbhDUsK$cu&H_X+Fm2vH8kwRn5hBMsx8(m}`c65&Ul7v%RhU6E zEQ1x!xGzqBf0ky8j@5Zr1`l}!E8DArj5snq&7_7Dy8`-?_i`0DXLhDlzahCNnd=(a zUS+yausSNnXU?3C$pHJ$(PO$)v|l*45?H-tJ+nXRu)%G8WP~AQcp~TgWH{m;FmW@J zM=2x)YQlt*z2r$D5iCx|W0V+|R;-Y!^fMJ?m^v~8&rEdYOF_QggO^nu5gjqf%-Q_S zBvV`|Z0o=c4MP7*<`-*E3Sl$jo&{mW!MhK417V$L`h8E@!d!%KRqjV$p>*)Xu*>&T zb*f}{s}I3}yCBI-rlCbaQc%i3f?;}3>BwW#(s{KtE;kS%xFPuxQ~sHG_pEfqyw@2A z9jye#FxmJ(ZP|{M`=uO5e0*>|rZ!3SS?TvoQ8(bt@!vRP1J9H_X0SEpOn4aQT(Q+ zbdnq7)Vu~c+SOd8Va&^4Xuz~sA|AWkr6*@F0hheQ&HL49%D2m#uuZ3x2DX^nhrNx& z1YUVOEXz~40=;F+VJA+jq2pQmhO>Yhf8Ba?%<>CKgx6sHq6hGI96;AN=SG(su;|31n?JC6aG06uj=f}BaHxEB{dT<%W7cv(!jVwZ;6?Nym8>o%a}{;P`<-{ASkGOxGefXK80V|h*DCXc5= zoZY*rdo30=S%wrKFdsrRDvYGY-sL-f%gUfl91)aRhD?O8-cI$ zLTqKF2GqTJ8P&|74c%!@D&^nQrX3AO%X}4}LX__);cXgO=&*AjtB5%vN*iCwWX{1r zheT|AasF!29SHJ8O+8hWi_;_-KW(L@Lj>!G#F+9?8I#mS0e7C5tVj_wYM@lx3klmI+GqXn2)zpXBwIhIawzC-@ai+Q2vs1As^`td*jQqUE zsE<6Q0(*`NqJ?n{KugO}eq#djj0|ZV{DeOx5da=T*DONhQ!0SYC?`l9{zqriq~dk= zKs?TW(!MKtB^0Ctv?J`6;rEocp5)?~V*0(X}>GkflPxXv__dGr-+Ih1dj&u9uJwTBe~Tlc&p;zDrk2tS#^c?-!>hC+gV%Z`9_R4 zgDJfg!HBot2D@~G%!9p6N>c+ngiS_L=S3V5`wtmfO^Jg?klhnaiDivD>G;w!@z+% zoty>ssRDR(D{Ks^9;)Rx`M=`I_g``Sx{>-Gf{w+TQAu=9@Ue#oRDKbt3J>VCl7Y0! zFvCOFzy0wTe10o%XjEH841gMN!&^u`UZK4-^WyH}55CcK-@Kj++vM4B%aSHmct5to zvtbUcJj^eYJzJQ=&)(a@4yZp_jIq;~MGMlKVH>8w5P62%ofCy4Xgy2AvVoi+Ayq8C z1^2m5huzlW?U6oiuKjU!NXo6%YZS$%Q?fcPw1gBO8PZa__JG=a%>0p54g&2HTu_<; ze(M;ic=|m%Bh9$B5epz&-))|#Af|N!7=Xqbvl!6D{~t|P85L#MwWoj~q)Q}*Mj8b{ zYKD?7QMwTUX{B>00YOqgQ6vlyq*H2!5)8tJmM&=+dZ?N2)^~ktA^%wZ*!MZ-+E?ri zZ+|+xXb`tV@I6U0f+1tLnepGLro=iT8s=u2DO--YI%9wF`u;f5t#aM*qk6=Kwr)oQ zl$I}pfa77)o?HkX(ct|XJ&?(0*d?UN;wK7nDXZ7SMZvwoZ-VIhuC98=l5D z%!6X=mxBO0+NW4`(T5hWzIicj^b-2Dw`J6Qk?f^!ql5ESM7-w~a%f}W*@ub)p#?=p zeKkF9v}|wwk-{2xT>E*sycAY>nE`qc%Vpn7ZVv}LJHbYTVL{(-o==##gNo}@XjR)* zXOah4kEi(yPSioQUxjCx{>q=K`Tz4pkeBkoepRNwiEv&TxG-zt3}7Z+(ph4wmvO`6B+}?ybF(kNLh`l@yKWg>W`)?V0t8a- zH653s*nJwlOy}gg&LL>^!u10w9RK zn%D=5DGzQ?8`Jt6cDpIodMV9Lw{omX_@Rcc%w2Y|k>(@YWvIr&UR}O=q8vo7m^JYY z8uS?iCo@DzVp!>>`9WSwTOFIb2S!BoNm+tSA~=E`#Z`uoj-}u9DzXOlB(m_y0&BGbA=8$~#CbO@_QvtRi8M@MsUsTbhs>9MH zMbz3i8kwXUnMaI8uLCkyiJ<`P0XaBuIzYs$<>;Z}*#sAkhPXe2J&yWN@x%y!s~h+b z(lRTWejwuhuyCoof2)ldVw|8DVzWJ#Y?FOa!pQ2> zKi~r(U&e)1yPlnxshmaa&_>pJUwMAzCB~la}c9lDkn_WHxGFTA` z6+u?P#;tFYiSPyC;+fe{bJ-^a)+Ja@Hc{KX_0$W8}FgG4sB?e`` z>w$@3jhz$Eh&honfuoqZXN1#~A9C4$Sdl}sE)+!@!f?}9>*VH>U!PNB%zeR%ZoK~* z8QA}dRv^(AX;I{s{q_5tSR@f;BdUTGt~A}Zdpe@f2?_t1DK3OKB;TtH4s(sojQCRz z0{`+aiKBYPQ49?R*?$Mrv;&Dqx*y)HoF9X0>)T#o)yDnn{QZjBZpJx&g4qN%N{eio zQIR^=!?g;Hu)lcY_eK~})yAa_r*5aHg*!q2^ke9UMHeM>>FM|6Ha6)csiLn;1uU!s zrL71jOaHd=Nn0X@FPl5*XW!);GdUl@0q%4Hbo~tyT!^4$DR{$##vpges!Wd-o`Id? zKmv4FjjOzi=hsM6Vrm(l$|5zUl_Iu)-p=&8@6h3 zf|{$6BL!GiqJ_;&;^lJ{pu|5`jD?t`+`daEUq#Z99q)7kB9yT(<7b7uuJz$!oHz2q z>}RgbHCb^Cd5lC0RgIA95X?0fWX#B2nyYp!qaXiqb4Z#lm(Ma^255wW6d!&eHmRZ! z&+zYPkg-5Jz=9;K5AI3Kog-bn17mX8bii?xz1#w92-yZS%gVgcvS28qZ~fqTIrOC$ z#P2q2M4{&l$6>&lmMa5xxJ=O7Co0hkU<@7x{1FqQa zg5AsZOXs26pBW}#+~3gHY~pc+IO8*Z)~7jeIe%CJSsC}AUw1#n4i^LL!jr+Gw(aO* z8g{agaaqTmP7#1&^ytgbzF6901vnVir%{28Tiu!Nz{sXC-ae*h1~UUM6+||u?r!rQ zM9|OX*`p&wKo2pOJTNsqpWi=41+{j>$=94QRf+!kD(y#BN?)zNJbJD;Z;s%6&)yF8x?!B&3?DzSa!0 zxlyo5Dm_ERV=kP_4F0AL0qhc&$vQQ$gO_`PdpPLHLMZV>6WU5AHwQ~$fnsdl4mw1GSol&orO*di3)Ag?6h27Afe!M#+gdz2y+1&+224z^jDbdB za6c}SxhFc`zrf@Y-w=);{m(qGknvAWDk0fr+TRsyI+kMo)Hq=C^FGn*)%gkiUS&i* z=8cdM!IIt)C9z_>p-8DFM)IBWW(Xr;D=EK=%=^pL==#*#o*Q#OU5L**d&(t&x?fXSG z_c~U_9XdX{X>~gRA_t%Y)&glG0M%3h+Aq78CyCV0CT@1Q*2Djjg7$h?aM&0chmE>* zExwE)F>VwsECD!uBL$^@20%3*)iTuq6VO+9nx0g_0}I#)|6-c@w}tfQP`16m$RnAs z{dZg)$cuwO+>g17f#6~=I%7RHV_n^2-Z?Gf`78%?O$yEcD`kX2Ou^JD58+_6tiAnn zRkZ%BCkxr?jsIe~j-8J)FE+}-kma|`WT4_yuko;5y}C7W#{c&MVCLx%JK`O?40Kqx zccJC~h@+(cv4oa~4Eux9+9!r7YXNu-aITP5ue%^I3vyX~a8HUke%j{ z=(;q)x1d8yEdi`{z3_!R8Ss^H#gH}5>*k*`CXzrBOnwZX_RE_@ou6+ppgnV{e}Z5NAcn`%dQ7)d8diog0S_ra zq|uCR>4mL#U3O8RuQP()hPc&mC2$X=YKht3Wpqp@C$?e30{t{;;dBrH3^a9D*??M= zfBq2%NxMBzzU{#GR^#H8Bl;+dp0ZSyNW;~FlioQ2psSd|i6gP_-AiRR#U1ltrH6X2 z5}MT^lh)MH2>XTm;{Z+VHqjmo9e68G-udc%HoD6@@&Has?a>)SqZ})8CsoBdTR#b; zk1k21B^jN*W#k`7mFCZp>xFs;Ar*f1OkMP;IuEHaBS(nb<8H}|HL|&$Rphzb#qQt0 zY3pH4vEW}^`#~Hb@+a%Aw3&5Kk(WyYAOg5rM1fmU3#D)iK{UsY^yFzM4jbi$Np@H2$UwS;+p{`&4C`)|Qc4 z>T1KMeUXj&gimL0{J`|yAH{U1-7St>$e|H61Near-TU20zn@(L)!LEs^0W{&6TsT1 z(jU;7+Wde%{|v9W_sKAf@yK606Hh6y2bg=~nWig^L{%D#&R+M78JvN!l2i}=yS_Eu z&QbX}RBFgpg;vt}H`PzfW2p_c4Z2J|zD#oIvGFL{X#J_crBC&ha^3k}WM#V%H@3Nt z8?=m`{S^QMf>1MaBHnI*)fM=ba3s*#T2G-r|GpH z=?Nlz%a7;r%%W`(w+G(H17zPV#LOs(xhkr(j1qbFi$=eeg|^%rJXQe)s36Wvz_ZbR@@Dkw^-O`q#JNj0@75z`!ak6P?YC+S zzSB4qK@t51<$bLGB;?1&-Ee?CCt7?3>b2h2K;0zcT(>;m@=h+` z+5lCTqX-t=Z7imjO1_|r*mjnL$o}`pWSohlU;p%fl?NX4Z-n4MI6~-N++YNons^Hp zy9+6v0R{%CmbDHMve5r+iAMXVtIvT9~M9@{YhWx=DgY6MPzYR)r zpB*dQWAyyVkVUcgzRVIX$#5e4eg6@~;Vm>|R}e1#X*c^6sm6z62$7ewv7qFnsiujj z@F464UdR2})cdga{p`v_btp1h^kocIX`=@rGJPqxT1bH@@UXB;X7ol<_^rBz|CNk41(aH})~*&^9Z$ z)Qyfd=^Jf{d#&Hz{h;lhRoppJF|jgoX;(>sbWI0*N~y^`Dy!z@N-CiRTAhx1 zXg1MWnMQw@?y2QRnbOkvpXYf3GFr;%D-YlYWb))j#R@$$Vq_})$YUp}GVG_-46~3e(3SV= zVubkJ2Q2hy3BBAu=z~^gu1tpl;U(u$ef+>l1e)t&4XG3b8TB9=@gQ@A##`=zVNJUZ zxqi7z_v=})!QY%qLP27%An_|2FUsqb9#a-zroziyub}c>XbF;Z*sC}5bwNjsVLn*e z$GcZo|5+(9|IiS;>-_1(`G48G#LtK@&iz4(|5lM-N!sK8xX>PBPi(mfN_>}Z6F-38 z-9uF`Q61i$eNByx4t}ziL);vcbU7BqwYDt|#w-OhQfOGa?xKVrR%hqZ5xVCEWu2x^6P_C9^lr;xlQu5j;aK@*qfJ%9 z2OAo{*}dOs$S5x0N(q`ON(lN&6*ai>lc+>TR1zVKRZA|Q&#bTG^LsZ6^g`sBQC~(Q z4Q*8m*5y<3^}nq zR0J|RFhpE@Q^@+=F#E|HK+;!@5mu7xMG9wx36+9If3q2hOzeU9Tyv>yvVYn@si3)D zh>to6JrDYdmZu}X1+m)^=ZKVCmwoZLBkv2P2x5Hk{LAl9A^*IX3^%o+U|6jA4cxg) zI4(nTu$|GOg;z;vSU`3II`|K5-9avzU=e8Vo{ALsxExClp5{gj zT+(r}AQa^aGW+E3wZZ4VF#og7^K0;d)DwoF)_3;}863uZxqNp_G9w@Tz&t)}>s0A0 zMe1VL)E4cw>p|Rz=4XIgMyGj3?+*V}We?W&<1C4VvHK$2a8nEw2Txa!_&mXUg+wIIn@&u>%>>JtGVfy&R2l}1whO4{_a)9y$ku){Xe8{ zl;%kFhlTI|NgE(c1BnI?edQmE_ z3n$TDf(Z&G4adJv9Q0LD`ePs#mTsO$0g>uaj*8t^O0WLW+!b6b%->cG?+xL+ka&X& z-TWy3GbAY%4*!r5-Bup&yEWq0dVG9m`pX8X-YYq3DT_M-InY6xucJRq|5_j>+B_Ma z^+ebIr(YFuc`az^xh$?aHJm;3qn?T=bBqw~qdQs%bx%f@YRE|R`U@-cbqL^=>Z*Yo z-M=Dbp{mFnl`F<)P++dcf(I;Bbr4k;(ftk zFpMP~HuKis*R<*Vzt_~f#Bnk5*Ei&4o(7>S!K<+^vK$ao_H!(bPBc$WUZ0;p_FTT8 z?y=hq%0Yl+3@LfqIPeR`#gNQR$LO$SVE14@vjqtq}z3g}XcK*mOSc+jaTUG5)JvKRj38SmA`udD%HxM8{^ z?SyYPV75NZ?S9|x2R)f#yV#daUG&Br8Oj9`T89H<@}qMNxo4#r?>o<2bPS(ts^`XdANLJ{+6x|MQEX>LTQS zgEg%FJ**La@fT*soS`z+k!i#YeZr(;)Txj@_4CaJM_XafgbFI%O4s0|0OAys9S4Z~0~;;Vk<@`aM~yzwyRfo)hT6 zSxYXhsS!nZQnqcpLzgBXbpwhR>(JluJMQ=oN6iqU}_uN#4y;8uGQtv0@l5E8j@1gP1$C1rqFe4t6 z;m6rgbL)GhQLDka2T)1 zYdV=dmkOL!uB+J1t6?8#qiWT~c71|AKuSH6w7AOjlzArli;Uj1FrZ-7h z-CKy?>D_Mp+=&c7vD%5O^qyp7A)MzsdRV7I+4fvNW^BlsZ1JI**ZvXsbhq9PuEg`(b9F-YvIw_rAOp>g#h%!u!d{ylmpXSSvP+xAh0ePX< zA}fJ*GZ9#-Y(Ks)YAH9zLwNWgGG!_4+aI6yawzc8hP*TkXTl8`s~QP2`Bv3487dyT zBFg!`y=D?J+utw6pq7N_1*?9fUmJ6wP_dO^S~LKMb87`MGo`b^pHaA^!Ts z;)$VC*H~VY)5?vXZ{+EKyHhxmq?e{6W7BMYD5_1a)mzrj23j49o-! z7iMof2p<)S>!~D=%!atcOoi!dEL<4(UFlC_BeiHD8Cp(_Al~c-ttuBk?N+w8F*^?| zdB}~GwEjw`+3U>DJXowk0}n31$>Vmi#Y*bnV|Y>|yP= zKj?R*BoV++XMMi>k&!gulk#aZjh5+QUa76CVS5E->sfU-c+h1~$)aNu zFH@RX?no)>(E)4puH2^m^C$bO-z8mR>ab z-FknHFWA~$&vZ3EMZVV>Rc+4afU7wx-||D{qoe$a%=Fp0KWJK70lBKa$Sl4RBO&{# zop8B;eQD;w{O42N&75NW`dTiveJe>XC4=RkK5vDzGRkN5^oP_CkT88sXc;7ga8h0>q4N3?HlrkKJ~DIYGucPfbde9^CZ>VN6$M) zu4nFbZXoB)FsDj{{oVG&<74XLZJm!$;3rXq7a?#B$e}OI7DftgZ9a^7QW0~Wf{s@w zHQN&b94o-zyrO3Nfha3K`k~ZCJZqo(n!V11thxwp(&pR2+{&|nr z%>LCGeL{08p?PT0>)N?f_sxaGzLX9MpE_qHXD?z@;tEBOwyT z--aq8e^4>2!HPk1Gx+a07&PEFp1(~UZC`Qbo||&u>AAM0qh@@6_kA&GkfpQ!v;8mZ z0o%W$Sl&j8rvYeLz&iNIpH+GPu~rdUUGeGDGkG8O`0=@!XcxPXE1HIH?r86Q5kExp z$*IROLsT_D3Q3W#mGBASSyK?w+)nuZs$G5bHrGyGcZk5#Hxd#u@&+;G-@-9(^v&~SwE5s-jY1to~EdO|56nc^x5J-aW?4E zKkOnizx$<>6ZemrtML240nT0GEGQAy;qL*k>cbsY#AZe>8&>l3OYmQ>74~39;bMVo zx2IoLtalu9N`pVG-IQ$8zQod30iuhb-< z%N0%*2VQ%3_c^GgeOm!8Rj02`xU_|dMkh*xd_~f8{WpWFfY<*L+2q!vBieRsDShjf zCD^!sLa4zCjer|5F#%|-)T0?PF$RidMLdOfAq;+kEV2<4MZ+V1{zTyyPKYF2A@j;% z>w}o5c`e6s{o}g9%LAOMpWTF(n*~I)5dL#F{?&A+EUpQoofQizE2zSQI2%DhF)-5x zQZz3;ZE4isq?5P0N`h?|oT0e{4@R?Vq+wIW`J%JdGsfPKL99zF(i{g0TQZp0(!VD$7 z#Vw#)qRVGwm#;4Hy32b^G1Y8tHnsuSVfEDOsFF0p$Sb-VD6G`N^tZ}z@ewBMDLdb} zQauC_Yb-uvYZwC4fDnUK_0!5;J+M`erL()EDz75LKb0slW>as4)gT=_m<^16QfUI4 zRs-2MZj%!fdBsWwT4Apb*6d54E?lEKTo$4 z6c~DdpnyCSvrcx%N$s57ew{wJinSOV0Vdw!cAf^}ex-&}y#wY102v<$Xob1Jyb}d5 z5ySqjH4jN)b#ROaYZ@P2EUP3H#Q2671hy&*2Xfz>W0*Qp;$CL{;%mV0@Zd?sis`2V z(GlX{Y+&z{?+X`XZRpvyMzgT^<8*~4v~Le183d+BZbzR0C8vcSJyF%t;(lR7FVCv{ z2r@B2nha*4YTys__>sL*>Zn^2(snsJJUE%Rn>zCH1#KU;ht>wNfUXlyapop|7#YlDAWtxVQFdQX zKS#1|S?KVPW^uCK(0+WZ|8t|Gqa(!b^1GSuq_a0Rj>RTrp!p zIYe>}`P($55M{FyA9oPE+s=I_$1{0%#Gbw#tR#BU2p%ZOOtAyE!o^NkGe%IPd?# z+V%mV#f6TTjT;TAxwUumQ7SA=g>Ya1QD4c?;?XSNgQ0jdKe8im-rqHz58uMme0UBe z_+y)nB8W`_#G5upsW(pYb?3PtmxS;?%awKBWjW=vp5GRG@INt;>^T5mi9od1Y;Z`( zDBq4t|K&UQx*oGJCyvk2SsRbL`|PeS8!+ipZl~$;B*KLD?fjZ^@6wwb>*Rq7g9kU= z{QUh2%HE;#LQfW+TA3|Y7mvR)FU6NBvyo_88%v{O15AzZIxI{ZSG6Jdp8ujEjDMM+ z6x_w$F`!u~&)Y68QL01>SL8B8ZMOKHI)4v&^{cUYNbM??Jz;Q-5wRE+w!P znv^37q(@c02jIV5zrG_mM3I1g$k6{;lT^-)Mf?L$-~#cZ6l%ZgH$J^U-U>akt_h-x z*c;|r$iaM}BjP29Q48sG7*b&P)n$ocYGKv9tNE*Fk9B4ZQXF?wl_~RoYaFCHh}qP# z+>3+Ogk45j*FiRr7m5}S20P3%u(Pk#x}3Y2+wydvV$KG?-nLhT@MZK}qyy)ck1pmX z>>?h#&_P1{HE&)U;teB4{Jy16cpiGGZ$L=6J758hytzgOGNNd-SX$LQ_`GnNI&@q? zqL+AyJsU=xX z!Z)8kxZ-&uTj34Rndf{6iiT ztjF_|jP?zLtsFd2wuG9kC3Rg#q-BCe@_{&(1R6GU`->Em9u?FeL{6Tj#Y1LF4?(2! z8d?gs3^L$dzN@v&+rbV*?Xt~Y)M64Y31{1ons2~18kUY$`0F( zYzD*7jq8F7N%`l}2FN2u+9Yg)V*LGzO`y6$Uj;rIRgVAqo^FowSYf82PrUL>=S%XD zd;V8%?=R`&&wG?MCYF4UgINlV)_^IIDuHHX@{}YVznh`5)6MjoZ)cKq>PykjUm`ka zG8y?FHF+5i(z+UHgNiJ+^P^Zh+WVLjPUGKxKwd#fUyh%`y)Lp<~s4rqjX1{ z)G0xx0=o)%4wJDFT-z6hWNRzRpDeGvG$pE`?Y7HEao)!^1(hr;9Myt{{QgOL<)*#O z&j%d_2@ckW8BcIu%`ohgq-T=1ZDO4*%}UCXzP2`MKHh`ty#vy1cJ9ABuB zwSF2!LYY=STqp)^@Z`;_xlK1O*Pe+QkJEi6gB}kU3FLffP@G0@5V^Lw*+q;v(Yct+ zZzty>tRbDoca&5ni=P_jb80v&R98L8V~71HXGg0q#yp-m2BpK(sy>4j@ADwGxDZ-S z4WvG&tU86DVCwytq9;xLo!SZ!;Fljz*Z9yleP4QXkEaF%cbqYYW|ZIt(`!E%;O7R> z->!MU868OuI(Il5eT)m;`-!K69Q|o}g4w8Sw0+5qGn-17dBCui(2*`!L#(!CIPpPVJ{hN?bkQcGkk=tK%^ z=M3V-8Z}_7TIdGdn~jd-28&Hya&$pz;6t{~pQ-#Gj4|N{Z$lXhitj$!t87~2TE|O> zR zc8{V&acdi+=4~M|$`=c%^Y1eaR0Z<(8ld>8@`(V@R0D}Ss8@jw>!0qd3=x{5pSOa& zFWLRf1X46P8E@UVt9TaQf=e6>10yf?M&I}pjvN7DTV}+t5?myUG~bZw0ZOt5HU)jC z3X8pfHhHC`eq%!^UPregDL<`n zTu?^Jlf$wT2NYMnkSmzLkK&@Eq1A$LSM0Zh&sU-&1V%L8Nhj{Nmp^WS%3ao(;Ccqb z*^1wW(Kmg;>@Ir~`&fbN%2oPx&3-@EFSZK?{t8VH=y?cq&~r96-!4#p=wADAz3cif zx%1YfU%w{ffbkp^0}y!yiV6Jmt&5GoK*z2>o+YMb3oe^{)J6#~LUSlvfzXJZE@TLy z*k|U#R4|?TIhT6N9rUSGx->TGv0>>rH_4gRx9K$SHUs!#<*U&67Jr3*l(WSf7_HJ* zkyk3P1wg?6{rfcE_X84`-bA~hTZmt166=Umz}^WPhg3i0J7WAax-n7ZM%f-ZDuJt^ zv`t2SIsCx7wY$;|9tiqHGSRku+anl2;*H;;W*aLm1jIv^uI>GoV;enCA#TnbwW2`I zSPr?{5cjBjz!2_}OFjKr6EY;N!Df4T{YnGLL_`1PuhGdk@38d){IF~rn5%Ws37Ey_ zZgl*OZX}68NK}qFprYVs9$%25$J@QR_*NwZYs?}on41Xt3F#P&w}98x{JV2e2`s}B zp!1!JK)%rhBSG*(9-x4IbfV8Cq&+nIUc0wbY%pimS;W(Bz;hfodeiSw9(iErcA~R zW3)KC=~OJj+q2Z^DjSmf-Yeah$I^joS@uGylwHDO%q@p@UnLFxQObQo{4_{T=YB6d z_}Mrc>9B#!=y2QabD(% zJFM3*49y@DT=K1-|98j;-y7@nZr;1&VU7WNhn`PKNlPzt9k}TBl6>^|ad5?`d`}E4 z4jjWuLai9so)4AVd7SFy{P>#&%lyK*>HKg$k*ED=hHHPx>eH~g+wQ~VGZxh-*?{WR#}xhY6GD1|j%$&exczxi;IDNuJ<(1$va*V}X?WELYQE~2YH`_Pkg zV6w)3zq!w@U<5aJA0qV5AL66j0>tBX&q~6NaCvpq8S$a&n#R$l)?JB#lghNvddn+@ z<#P!D3JV(LXPN&m$u8PMAZG8A8|{xy%E8F14N5J{EsaWKi_k6?S>+_d$c;?=e7th9 ziGdQ+D?d_ZZbY;OsFAc})acXLyu5fW4_z901ML0XTSDj;o1WzM#Z4fTa!yxd_#Y&$ z85zMedtMlcJ?2mdR=D4LTwt7wa=^Jxyi%N3_|5S8sTE0r=T}sOH4h4OjDWo`qCJj? zbEp9PK?5p?sK!CNP#sX&CyK)!A5uJT9@H{d{w5EajX1#jtBBjTgh4qw! zUergCA0~b0_+e!v+{*hD>#FSyUdZSFG6UBVAI z7F_nY&9lNN<^{w0VTA|0gO-ix_JozY5=JDI)@lUwVCy zS)BL1DNH)TM@lgtZMUJ3;Nt3o9kFn2JE& z9WzbNHYJ-0S;eQ~Ecivju8AV4kuZ&aT-{@&>*g=v zAsRZ8+|brV2=*4kvf#x3#0y<`z~<~9Dzm>ceGb{WzBP+X9w+|d589(N zP!o1`a%_gzxL%i+53OEb*ED{^cGAKHFu`-N&#&e8OwAq#h_bV({zfhi)`)&XqP{m6 ze;RFyL5(AC7&Y>ve>Z4SOmM!!wm;vgFu0hXvg^ukJs!p5G?6L4eo2i<3eoJUH%rD% zV;v{f-`Ht*&(f7c^roOZfTii$xu>8PW!f7U#omV|6pEs*o*$d!a!iSpAv4+-xK2L5 zqVs?rbobAo1iAfpk#u!x6KyzJo!ag;JvNdGRr&l{{apUf(Nc`L*JUZu1C4}(t;wD* zvVK2rJatf+4s1Jk9Jck0h9`3%gp(lVeH8il5gV@)!)z&L^D7zgdyAl|oYj#a!pE8= z^mwb&J0e)=Ywy=qNxSQoRd}IR9RKWI#Hk0V(o9~Tb8Qg5y1vPI<#M7v5SiOAz!Q~7 zeIbH~xs(Buh~d0HT(B~h(+1gZYYjPyfCgFhs+sjYprS>Ff|k%Vy<`0cpd@$c16j0H z`;A-qeDozr{%%U917YsiD5j&@d#PZmMdMS;@xTH|n3^K>vcG!tM85RNrJ|a1+IRlg z+6YnG`0t)RrX}u(yl%u{9YM)b>)mAc7)Oimkwj!tzg6JkQDrlX^88%#)@_m`+BauK zl+{iLq+2uXS6_rkZoj&64fn|~g5K=na?a^=e?{wDu+IFuHrT@*Rd1>G>v}wJD07cr zCq&=9_Tp|+_O=BS?i@M1X_rK4`&fK7vIn_%68M?wyX{-mcZzW-h0a<`%`vxcx=M4! z)(B91tq|ftcV=}(;V6)-u1w|Ni(OR~Go4~Ep*ym{kn`mw1a_6SNRD~=D0e|BN}e9& z`XfLajd1(NAL#u%lZq?B5MufQ&}Yh8kkC5D4c7tFO6xW%M>NBfz2Cv-2d8L#*zVuE z6HsKFOVtS$wU$hfh+MeYgzr26(|W1?b|vK`D5Z&&FjC<2zm+1nVf7(b20hGE?TGs< zDso`aA7A%}2RnTQ^Z!(yu?&q5$LZ8R&7bj8;IusW+n3XqNLCOu(L}kj*gLh02vWUH zjE$5&ToLBU1R)USURi*vLNt0zc^pOb={NR)lI}goE|tMAk_5aL*MIc4#8>K zAIy0`UVfHh*!XEdnKEMGrjcdr4yCNxr6ojOScNucC<*HLo9|FH_T@xlTwQ5T%4YM+ zm${wak&4Mm=TG;tkzW`!#n?K79#NR|(5F~Lu*rv>Rr_}_xZc`$<9hyky#3h^;=Y9M zZ15^DEvJjebp9H)5ng37JBHTz@XYZGj~tm_8!zNG{^Xg{d2px|R@C-GVO&hpLN3>W zrkP!QB%!<5SU4xxOlW)V*9j&HxrxcyYacGK4LoWjONn(VB7IB3xdiYJQxh_)#&v@S1PZvvQF zSYNZatH71qWA6Ix^H`tjqH`Ijy2X%jh1rxGyT?+q2T`f^qr9nS{-lpgx?JylG%^no z-O}R(2M;(XF4BXkd^Ei%LCa1=ggLb7CnaVPF;vG761#vPgfeBbJ`rGuULf1~Kkg1t zdbE}kG6Om=*K=HPmE`$QoZg`4-?tBfqKo($8km)p0^6$T=ycy1lR*3T7kPj$hEH{?`cTY zM3x1McoG%0T#tecZpeUT_imR@ef#0KlZbw`%$Em2WNBu;u8>IB^ACRt4q98Px4dLA zyYMd~W^jSC8y}Y^O^N?SL3APXmKI3b%HQmO7#H2o#*yIJi8Si|-%w{2DrYz$t1I!g%-73zsYQ!B&%^J3>R( z4n#)To~_(yg!z2hw1T`pZF+RBj$%N22J=Z}F6D5<0P;PUc$DQmpJdlUpRyEGK3Y=P z#|{fP45o(MwmjLG%7EK zXA9E69mJ+$g8n3Vl|TEBQ10`HADPQSh#ofVk!{D{W^eSk3g7#=?K!3T#kz;^%lL)J zeYq3`C*0s1B;D*X(YeFzR+ZBV6wSIl+gSX%Sg`6d&)1ZTm#6c2&t1FFDMtC^SL z*?UP=ruIiBo5sRseD*+5NJxc&6`m@ahZ3YlX{cx&pqb?PypiPgYG2}WMZDftJ!o2& zw?gqLSUHOvx}f}FqYZuoCCKC83$HvgK^*q8ioI}j5zdrb5QO+9pwTeejQ$VZcx4SP z(5DwY!`dM0oK(7Q_cIH1MVXXDA=)lA=l_m;ukW&kTlVWREhxE@D8ru{XCf8Y zZ^dsmPDv1H7ZAzC-UiQmr80Us-+kD7ubtaajDP4GdNF7HRtCM@_)bG?BD=pVQ)d!? z5=juUjri6RbaIZ2&T9!c--h0M8i@UroxW`a6Uj=Ca$}?eQM=zB%1H#ly*pOKXiCtt z_E!*Jc|VGQDPFEtifyq=Zp5MyUML7|pR<$?ji~+%qSs!Q%=vq`ap|l&KB7I!)Ogvi zw_na9sVY$0&57g8meNt_^!?}j z2M*fRYVIPSJqyu16h2|Q%anCRTC{>QtZ&pU1|b*gY(O4G3t9$?o~%7)=WF|&>`vYY zsv7a;#nYirOtYCBBNq#hkdfMR)w7aO;*b(C|4ZrsU7=vK6tS{SKRz=s?YxG|F8SIQ zCak2uJ$D(!dIyF(f*)~b$dKy;%1eyzO|I)16>ZFiraBv)BYOoKN>rudvjWrK{_h`)tN1`*9;1;P z3?{rwIUNoH^kK#dlf;f_e*rO@am5Gm=|UOn+l z)HY<{6cmM_c<|2D+x~$c)o>4eE4Ds5Eryp3Sj9g+0dtnjva>;m6npv+RpKs4Mno+QCU`94|d-NR865ZARp!fLcM z+QATySkKGB^uAaOIbUpl(mM@ljjaD9aj2L%>zI2ejH~MBo2M+_pcM6$#$c1R^S#ez z$4nXrr{l!#-J-V6pSe^)NU_?6XTKN?olVsr^jydfcMei`^N9RQ zdr#GWR|~h}lH}AuUEQB&@NQr>chLXQbl&k){_h{Z&v9_yn{O&&A$M5m*U;oH`-`D%PUa#ltdXKem?>EB! zTta&Ss6|SgjvbkaHGWy80ytt}0VH1nhtGefYv@bDl0)6JJq11?pyH6o@%mpk*W2;Y zcZCQw7MGJZq#!8Nfmdd!RO>cd&9Rdevl_N7XqBHkxS(+(BiJ5qH~kg!M?^@t)YSVt z8L!ZETtbDZl06ewjzvx@L;%j#kXc%6}y!R39tWTJ6QRceZiuEXYSW z%s-aTpReT%{Jri#ag)*!87~<{gdj2Ic0*M^m|S$nKZ1p8*wCwz@qBe^WS!B8VFKFU zX=p6Jq*UmSP2*Z|m6lBneZO~^tzG)O;o8OPG>9iHgwzbnVjO+P!6nq z(oo6BEaYd~PJZLc?ms;O3%FMnjYEU&z@& z14?22J&}}ulBQdB{BkUeJdE@J>Rx_bK#yAJpA8!KlJ)zLoo|%sBoA&NWsca|SmiJl*z1j8qKTyOi;+p{5 zC!dn976)&SDm`H2j1#winPWN+mpamqdObUt3#4U#wEw@Ri zDNk%<;fv)iQ$VO=@8(YX(`u9aSNk_V*1h}oCM-Ct-_w~#^h%P@4X@ecvWO50u8@1G zBN>U`qLh+s8w`8i@z?YyM(%hbF&Ib-7g| zuH2F@xIkqo+D_?oHOF(j^O81Sfzq|pO>`TJ)0yt%W3x-lE&|0lt7E^j*xc915lZjp z{m-<)Ww8?Zl{2;85K5)RTC8w#U?dG@G*tMpq>jI)t9XgwHBGf0OpJW?;^Z2-dSqP! zQIYZb$&@&CpwU!2gz(t>Y2!s=tNp9G?_s=NpYhhVVavphWuXn8PWK*O`Es(W1OA79 z$nAi=8h&=p)DWMrUV)qbct@rAoX(a|=b>I+NS!y|s<4W)DDw7!bH;KoADtG}@u$q~ z+Qk+uwm_9nsk?nSmx;zi7T!%NF|dtNV@W?D)jhsTG!&5Fbe+iK?-ODNMJI0&G52if zr1Cp;Ffp%gZP8ubCyQjufZXJB+!gei1+8;xBP3*tB<<5WNkB(iN!Ii8@K*<($KkbV zoX^DHTAWwRlp4h3|7*D9X5Uz-OeTMXL z)H8NTfR~I8gM%wkASdz8O$Lamzl+pJU5G8l-^nUs!KuhW-#h0*lY*SiU*-CPmY_o3 z(~Z|KsZA$bCGM8&w9dfmKhF{bWK#YUs~!nn2UjV0^EaLPNzq`J$v&>bWZae<7>t7| zDsgo(Te}{aq!|N<+eRvAj`DL-@~GNoUQxNIgRV?+{ju^FroZaxjz7@p(P7IPFWDmS z8QhLzMZB~toFg#(8k7s=1$aq##bnst_bZqYNhXY>=#|bd7KZq%8YZGypu8Nk+F*kk zTD6QR^mZ3D3LO|4ot=!`{SIZOKI-)4v<>>f+4Q$9PFhXzs_5ktG`l^otTj|*iD!HV zaShATq0S@bPD!LorX_Obq5jMa<@qX=6`5WAtW1!CJ|UGzmxL9)XG<{|W~1a3uIg$N zF-y6mvZZXEaE%OT_*jO^tKGg^M)`V0jEI`CZ{%M2oS6O#h8R|V{IRH>z{i6eB=VHHK;|SkMOxxSd9>fl(b+?>~!AD%@TvBjH`h;oUOdY56=jP1xvWnwq;*xx=L+VI2v zD#cTIM|2kem=l_x4N2A&$;&m;nYWm(+x1OL&cO&>?97I-FRc(YEsctbijho>1TK$) zC;B{aIP+CyG95_-=j!uRvlTd@+AIZqGDqk`Vf`Ij>-vn>dcWqAwH zs}Ot`j#anCXB$QUVjfPBwEV)e`!9*n*NE?2q-DlM3eZ;0$r0qMKy}oM*ULQ=$@qrl zVdC9AzCS~S*I9E#sm`$QOA?LnjIJdbbbKg56!=k9!W31`mD%pw4yemxR!+|D?M2L!qmvU}R~x(n4dym9euF0!8v%K?{;Yk_ z__H%oUv#_>FvF8Um>oZ(J*4rkv%j=gakn?0=wNZ#?ch%1pIJVf-jrUM??%hLkQ*xu zP8&)vNrL^Qm5s?sWx~c$N~eQ}}40KG*~Z{MWl@JeKpj9Y*%{ z7UWF;?++AJ;aa;h8YNft8A{;wM`Vq zeDwqAUlTFW-r-cGd49DHk46%H1k}Wg?UPMB3{;TrY#*RBff0Hv9wn?RrtkqLdy8?o z5trg%uls`^29I=|RrsALTjRJ{(|=#~&)#kq(t&2m^JkRJT{Vz(Jn5vf_+fz5D4jW! zlE-pFsR7sf-|7GY?-I8~8l8GN!Co-6B8r5Gw)*sqnDayK6&JwNi$WNtyO}dS-Hf}M z0yXdaPRG9@PisihBMiMSTzh3PA0!_x9-9cLD!viB;5|eclG~x^2U<*2{%*BD93@;iRF_$a6n|Br%W^N}w5RTmn1zRrD3uYJ4-p@_ zfR-l}h%qT}IT-Y?x`Dqez(Y3j{ckKBcZy3%OD|7$`bxDPvIR&eaczFLS92TGLSyb6 zkQ^@%k^T_yq1O$g-D?#m&x=NO{U+JZ1OS{19grKEc^+hrgrC8aFFgXnq_2vPM3fWWt+(7fb z(;}q?n}RhO$&% zZr%~e9{MHLVN_DHbHq{{)XBHzZ$)|ZxVW^8;j}7(UVIk?D`v>R&8WA-S~w`-F?X?4 z?cH~wl^h6aEDOp*U4s?dCw=zYQ~v{@*(L)}4|5QuFd>rUH{B(6r94Rbaq7nB?7<=R#(nS1~{qEc18J#!8A#=-0cwNq#&GKYxc1*8JqbhMuc z4+KxI>reV)byRNwC-yBC%XzfGL&y!s&ZzAtOVb6%04;8xyA^th$KS-ADK91-kEm>0 zBo=)-Ra_%^!80cdN@XjnNz+q1dGY>ixX-ieds-w5oqCYoRp_M@dC2jivKVcoE1=!4 zj}(I7rop!e(lnh4h=p{jC57CCe#(5jDhxJrLjP(%wRnQ-xwpABSe+?V>aJhGNJ1Ak zSa3u6_*qpA2`Vg23w`J*i27Z|(PK}UB;d<9dE6)9^%JI&){)o_LIGhj*LRo@#&Q{c zSshP`=j`iTST=obWKd-4?SmP4E%RZiAPuU78CiHn4mNU;gm*uBrml`G$1Pr56XU?y z^n>@|?(ZayesQD&2|0i=vi2q+ZBcD$HfMfnaoB3&X_qMlB(L7v!>~s9+Tcj}DI&BqcGg^R5D|6#L@ zdBflU3{e}wXIerS+77a+?p-we_4zyIfiXqwN=@-*jN8 z9Ko0qXU$A*H~;UA7@M3+`L4m0NOIvw7v+H8_4;*)S$@z|GQ z({r0h6xAPUj>|Lhwh8+yKEfjSWhUzNGZK29PX$(wNcY=L*!+IIc#FKH7=zquVg86? z(4gj_TdL~b>ZTl_JOc_Nj2?1NqVMBXZ;ec#cbEgG((k?69^Gokst|{5ccPjchQe(u zdU>AHLH*9GQ-OOI@7JC_eJ|xzH#(6`n5ySQCwzGD%XhIGyx!pw?BH0h>}cwMoqK)+ z}Y8NlQEQcDN{$qQ(t^T1sXS{!@Yu{nTmZ+gc zG8F65jY|$E@7PIkb=YxL;kcH70dkM~5I6)>Hb*3E6bmCMG1ZHF4B1%LfWC(f8~nWI zMGjS^llo#?{PYP~>CIG)M;yAPkGPaOF#1ZIsVTr2{mkuw54vVNSbVVs;Q{tyiq=gm zo|*{7yZ2)8xd!YLAH={prPgjhC7H~VFUyA0czr*^j%A1m=X9LWgl`Oj0#8XU#wJaX zZFQuYLnB&B7C>$ySn^ofFd^kOU#OFwbT`7_$>iU_UjE-GuR>o~T#Pm!>ybL^1Qcjf&aCAR= z+5b2odPE**JD;pt8W1ix(go(C{$>E6=K9j$%I8NU;GM0UXB;4>zg9QfL0`DT$zWMA zsYtej?SskCqYth^Am9|&xov-`W9fS+>3cLT*m6D7%wTT@ebW~TXcuzF3$!R@llVfr z?0L3Uy~swd!7N{kNM!&De+1CUqof7`z}j`Q9NuKT#^-PRzl%kH!YlN@CM}dK5;gCr z!jGw1n`Q>R2hkpu)<2>0F&9@m+TlL~mmHkV>z5o%1z2<96lTRooL$omh+@I5hax9k zwxy9jXSgy?yhw=fJRL(0Pw2c_c7+voXPl8sd9wzhU;F>C_Vx;!R>^%@Dj1^dXm>yG zwqpL6Mb2e^%o7oMm}Hw!D-nhN+IMgNKsIgo9eC~~e5D}4{7Rn3&R!L-37NZgJvW(T zl<3W*gm#+OXDS|z`t$n$q4^F$>Q5;h!BQqLP{sh7Qx3Q!nCxyKt)V^LSum*q zbzT^sZlPkhL5mw~QSj|v+QW9$td7z8+ldW7(xFS2Q5)q?H&-^}p&z`rI}mRb#=>p9 zgkS!;eNoe?p(j$>5Oz`R@ZaH={r0aRYe{7AW_%h>vGcqNM#BGP-k)YPiOg5^0n|M zHFmn>ZnrDO`~FMAv-dBEcx4(B~c_qIqsi-R#}Z@Gd^5a zldni}dcrO;S$UVY^o>#v#LJ1V!vN|IG$l~dc4&#%5}TVTldq=$uChPHd<6O-f-q`> z(8k6s?w&@^uJ+KH%E9-1DCdQw(N^6<6vD!;-QDBZK_~yi<>08K%M$lwV|NVl`e&9_ zL%ol2`eq`5rUOJZ^BQXpD8vB(r1NK5JXsbP$)Q-e>Heb$yFddNt-Ehw^} zBbU4FFmG>ZInLtE-3nhBh4l;Keyk1jAj$y^s%Z7rc{W5+x6n^oBX1Tv2|=-oO~Gc6h@Yx z?Yi(lj+z}p1&|8ABx?TQmM?YEIf!!l--!Q}`B>2(#k_{5!yPKW($me!0Uw&tnmaK* zR^>hf|HfbjXJw74GWb0%EAb{-sZMKtZFq}R;rI%uYt6(_?m;$vSDA?H||k-+@btZb~fi~pUNeJhRL;T-w`|UnyojaL@1!At83L* zo3P@XHgbP#aW1yA%}b@}_k;2%)v8F`tvUrTT8gawa7Wo5 zng|Th^($1iKAo}s8;58?A{A&?J2&=F7nF$yDs;8cg71`&dzwQz}u>je~vmMtx3 zw$v7cr8(>oOWSiv)FEO2Mw#JG^xS*Cb|1E#0A^f2;tgHM?eh@R>d!p~-Iqc994xxH zVuFbBxv`4aXf4tf!Qth@!IQGxNKCb2c4Ho@g4&`vjcI-Ic-WzmmV_{aFjU#gs-xI^ zcY3qOhoH=#Gq8`2{6ucCN0&VZpb&dvm|KW$z<#$Ye*3k_=Oqf>89bRH5Tw1mKzLOng zwpGw=AazIL-lKcti+jeyOAa~apoQ|nbAQ|KLyWS;uSgvW#EvIfH5}ysx){DA7e`G+ z)?`?Bw$;6Zgm*)*dcQ6(3^}i_J>fOhOQHL;20d;3oXs zwOU6)V?JhzpXRJ^LDw_ITmUMQsG=C+Fm(lc#t@!t;j{)2nX;D`pDDPdOMiFrf6>(sz@#^saeCk`ih9~3&1qHK;``<1;SSHEhS}Fe6 zSs~;s0Xqs3y4Lf`%+;p(QFWkha?Ofb*#`dGE)u?k&VPa~KwWAyQC5a`cw4EFEisUm z&xX~aJI2A;c>wITUQ1yPg?(CszV5Q=0(*8=Kp@eQp{@WK?b6u|U4U@;u#Y>I2VkT} z3jd8d2aRu+{Qtrb?)ntOpE!S@_^~XzaX@pbjsVu;$43`{Vmfj|VX0v9F?DCV*BAB7 z0fcz*X`ka)BwQpA9H^x0ojKqCSUcX^-0dZVU3mOEY$BulGA{NLME~Wz7u-J);{)G? z8>l-wg}FM|o=Gy-tenhYW?oI=KO!Ps=UA2YB?4%uL44t!6H2mK>7Z$qrfh%dRejF2 ztaTYJv8jhSFX2)z#|Q7%ORw-!;%zD^Uu_kZWsFX}4qiU(7C<-Y_oYRr8#m30kWzE- z^ZsHH~Zg+31FZHeGYHDx5g}O>x3*&PV1_+u?n)+RZdxp6x~EAj7ZN?PgZ4+>VMM zMEsND1n_zeVjdX(YDUM(s=5Sw$#PzKQPb~N9!qA=vfFoDMHrQq=q+BcSoy=|2H=D1 zno~%8n z=J;#)QrRV+`-=()+{r(N=93*a#%3qaN`|b%Mw1uP(}dQbwxlNmKK}ZV3OtX2gAaW! zH9qe%4@3bt&95ZI%Bb_u)Axp?o@OxL1@v(saBuz}rE>Jvj<~S`Yr5nxAW4FyIpEb- zbU|}M2{^W^9Vm)86o`5D^5bFE-eOc~@6K0{myIS9^bnn9r`uQx4QzLs&cSelnAiOU~-w8h-L=RczQRiDwD@_sA#I#$bf!zW?%p{7Fj3<@IUmXfN4HN)!HKPnxGk_h= zErZKB0SGKX`(MtR_djZ-h2g>R;#*c-M>}q2Y8GS|D2KcnxV2o-(N6O%`aq>%2}E-U z@pn+h5MNWtWU@Y7h~L(L@bbq!hlJSZ=t4{wU^4x+9}9a{B6Ee53}B`+{&0&WQY)pP(+X^Y_hIQfcXLcGIPtQhFfF5yBq?K$Lb z7<9C2DZ#0m4aB3ZeP}Hr-;5U^H(mDBO?OKIBBOd4%Pi-BfRaKy`En#|?H+gcp`pq* zli$uS-FU_~BqBWE?ea8l&%$-!kDSzk@W;Ad^673Gq$Xv%MbXujY^ zK3O8|4m)Sumn9K2E#s-zdIi|$jtgL4L@7>PSkUVNQ}{xkGk_R$6DENT zf-MsOgte&|$#}|tCC-t=cxPn*Q89YxCH53ekiCDP3uKwQYeRd$&r@&hEOU(!)Hts` zc+>LKfWUts^$LIJ4yK;J-6h3OZq$?F>&r0q9qPoO%ssNF`MiwdLO6;r@NWhd|0LO| zy-^Uy9&wJ~z=1K>KHqB8KW=Os6vbbliXuHj+*JHA1Z5f=12=B&!*%9sh&dv{nF{mO zKVZaU^<5UtQcWPcX~kr0W2MMKdOxt}vb#r2F4X_bzg>}-ka;s2rGI(-%98WB@T7c` za5Vdm$D|@5J&a6C?pC8tvU2w zP6F%1+Xs5s24#oVFB}xa3b1_`rQo<@+n!b+&bvP~t<4|C%5sgmue!NrJo8 z5l*sHfbBc2Cd&hRRf6mCPQHR(9j032&4*~$$Y$!TjBb(LS%FXdoi^7(IV;cc@?&GB z06ewUb7Gt7UyA!5Y~V{xi#@ft^fV3;XDao*@NDn?S(<-P0ad{unsAR8pPYl5Pe*zz zk?t(Bm-QKtA9g=+Bb6+b(U`wF#l$2KY1ziCiv|(5SAPAjnVrPS^io>|Tq1u!vsIdA zhB^7mlpXT zSV`tmUvSytvM6c<497fHipDd1*Jvxtjz&S3db4Qm&A+R7Kh3Vs<`Qex-hS8Q(Myf3 zo0c%$!B+5cU?P0CRurSqCG`Qz5SQy1urTP?dd8`NlY#9C=o+^mHZUyz&jM`FDW)i_ zyv!rNh|;8cj}IZ$uug*}a0Da};a*}UQTv>=#y6lY=QJ{E;sFi})9(1azPL(_3=&jrPcYx@~6rWH}Kj`qf@v{el?+h;`2e|F91ouCJD$$hP$(JNVoZ z^tNDKbOEOukI#8GlYCBo9Y;vS^xSR^Qd;-Z@ z{#$6o@EI>yZN?@^WsN1FO*uTw6cFS8FpD!&m* zFtd)OlnNP;k3zxs3v@8XYX@u=mk@N;T%c**OyYQ3g~k^E++KXKpVl5qV?loP-W&5u z$AEj#dTY+)Z7vgx_uRrm!_VejcH$OG`*I#QXFR;z{7QIVEA82Lu7IGm8kc1NDH`Fw z5j|5K!VW4S0pf;Ewb{=}@D2^%(az)hQqvbJH zi5948!Ds{MR{mAMijurgsU=B%(zpsQ3NDSf)`HPk^H=Pse|}Q?=o*w(f#mw9AabBy zPsglaBVl`2^#G<%eLRque()b(q^E)*r>K9b zqY7dC8a4&M-u!{$^85|5dzql5kxH~R_?faf`g$BFS`}#V*j>2#&I^5X4mDY5=X|sx z7_+pf_LvytPbK4SeF%ba^MV-&Fs_&Iq}3PMiI^*UV8bkyC9~V+Pka|~Pz}R}X1CIQ zuH*^`T&oGL=B``?H_CAL$l3%Ij=75sUN02;{xPJAyw_E`;A=(-7e&R^mt{|&McZ~7 zju)hL{JAF?Nm}!5x%q)MC4Z;(pLusipS>6FpC_L3<;#0?Eb_JfJWX=ic|mnJM`B6LIB`q>A4fWGP15l)*z5p4Y- z6OC#cH4m(+Wr+jeB12vdfdrHULNeVhTrDgv$!eBvu)k0Ks}T}h z+L22ecEZ5jw~oT!ZSn%}rSG1x7JwNjU!M-tzpSje525wcaq?rFBg2Xn$&Ba`$3;}f z4oV#%A_5+sJo&TD48u30RbL_;NPep41bt9^Y;4+F@)x)coYVJjEO&{u0r(Ou$YonD z+)!6%j89*=&~KpTh{=3RRLEi&SuZ23g?>l{}(h!B2Ns>P_!OJ{DT9{%EfxkYD^Q3R>4?C@GJY|L)-d@W4l+pFH3Q zNQq9??(6>kTfOzE^AN4$6!5KB?Gz(<&k^1e37t}ht3)6hs4;$xzn{ZWjfmp)pt?MW zXD}%}MzW=B+nww*8^}aC_zg=R=nAAoizYC1XyrRRAnsZ%Z<0=ZKXl6sMir8vk09OD zSD@<(vA^Od`IaT`msaj9#YmnUmW6}B*3rJTV=Tl4^8g4hV=R60NW}P+1;I*sqYd}j zc=@0`SX?9w<4tE^WaJ#?w^bNLc+#4Dhej2BvG-+~l)x;Z9J}lM9ohDUCXX{j!cGAg z;%hpqyu*d{zH#P1Sqp3L9(??16EXSrFtQDf*Iv)7IJuZM3**F=2HanA;1y~?eUrAv zI`n7W@g$11q+NYFr}?Apjf@6&m0gM6kCD%T$>dn7{jb#u;-_jm*+1psuh~l^r!4>U zO%QSk^fk%X$mXCt?aG6Pa5s+qB=QHXB0@f#_!mi9Xi+4#?PH|mw?$R z_lqY|Q}L@Q5#MCJ!=Kevi2ghmb=N%e&PkQ~DtQO2zBAUp&PJX8>}__9A|=T`bI61z zI-UkcKxRr0|9Yd?jaAPWw~|QUkVivLT|*Cz#9aCF^m(&~`Tn=IAa#T{d#K2)qR93` zk!?lM-T(aC1xy~161DAg?5a}47@IF^i^IuZ`}5lDl@|`SN%*#i>WE+O4c;`lF}!|~ zMT8od<<8xR{R)1p2)!W3xe`A4*nxBweE>d2{Bb^+Zh!i@>I-ftIR) z-6yBBk9?W8+Blu_;SU*;8R$T*G2i$c-;a9{*J5Z(jC=S+f>o(yH97=}Xn@?mXDl5|g;7Cw z?)7-+F~dW0+KA|A>r|2o9Tpc2mJkztvC?|y!Y|AOp_BpuT2Tlx+GVC+o*2@?yj^5p z)g<-pCkB2eS03 zz&bwpkO~}s0tqodpKp=?dV5fyyV3*lQ^5|;0ftS34wTQ4L++Bpb76y}du;RfiPkUYOxYK^=XmqJ zFMV0W(%Tb$S`bm<7##2UU17Mb9f9BP1PI`gxJ}`Lo{Gj_-?AbSEkz_$iDxSz0gQf@ zwLZYC!IghH5qrZ9ru9->--$8xPL}aIA2EAetA|C|(ZiGrhLi!bd5fYTw2R*LF9SJCFNE*-5WAXjs$|!c8GeZ0_oy88A~i8JCyNYz z+p&BL9^VI8|9Y)*{>4*!yoV1O;5!l89KoBe{c2yxmW1m4WRz=6FL3P8G*afYeB1E8 zArv6*uxQXoSf|r7b5&uSMcr_9>*Hcq!PiG*+!d3cx;gX15&) zKKj{2X4nTlu$KX^GJvy3H?*MU59KCs{7^Qs(d(&zeZ4Ea;~81sYBD=2(m7dauu4Ai zws>)qKhdk>XSDL8s^+acz-sNJ1N=3&IX!Tn9zX|}r3KMVOcs{a3qUgW?Tn#399+(} zhG5+ArR0BI5n}uv?Q`$lk75_gk=D@tihOY+O8w?kK{Qi-{Dj^IPmH8dgmfo@P(e)S zdVz)?s`;+`URr!mB-6rKpU~REd2q%Nag17C21;4yOIr6sTY3^D_Fe zNq~ru1#jHkE{f3@@rCL5re>Me(@ZbDgqXKsPc!ZM^=n+FB*p5)ObcmYf6*wf1<9w0 zLWJ~{y@LQ>2&C+`?t{3W_l1x}JxLKJ+X|-PzphiiAG9v>*>C%~m{r5;PEE4=fiPbe z-nw&98pe(+Z-`G<9A$C4N%GA&tr3WSXcRWCNBG`#s?qZTYs0aZIf)x>9X-7MHqysI zkR$-+^j_i}s!P_zPeTxrDeXrh0FWLJo|KMazxFD-8c=k!+`B6HDJ`KzuKqaSL)67x zM6BHQ4X1%F2<1s2KX^LIRZ|Kqa`xorcb&Eq!guDr&|E7?0}E=dwwnB@K*!jv?4lE@fbc+`pHsb+(N@+c5rzc#HdSALc5T|P z{Ptnmt|qroY-1C+Z}orj5UImYHjz0ffu#3EY(ho~2`*!F?XB976l62`f+5E)o)(137{XP+%jCba4c?l)x*)B; zY!;KLpSL2`dwgxaTBfXWC((#t>w5eMjG0Q5zWvouN6$)35>Ti~3ZGEuOzQW!WTDgi zXH9`w)2O74%N)qa_;ceiE$tr-W0 z2eYv4#IBfz>@>2anzVU3uUI-&#G^&Vg()>Yz#La!sE0RD;!Ccp{K6RjEE0gamt1S! zud$;CAi*q=l}ft_t~6=FgAXLk=3;vNVZI?Yu|tZWc9ef7Wp&f7@!sYr4@u~kwBh^6 z^K8gV=!k1y^53Sdj|Gk{!7#?rbYL@p96Uc1Z$hy~P&Z9zwPJ?ZGi^-@-wW@Er!4ut zVwT*2;q+jtyCq8hNp!6svbaoF0I(6EB4gR5%73T zJo_uHuZw02B$yEc+$tJ%mur%jwg#Ce^s)Gh3FrLqc7f!Y@8oG^4|rY+it;+IW{5D~ z`nAkWM5qLA2nJ5RZEA#oVG}8p7Mf|>O9nDrX(%&qBSwK5&vJCSv@mJBx__Jt2G^(x ztx1|H?xqNoSenUXg%dssd%$9laGVD^+yhfZPrO9l;x*|&fh+DnGaBna!9_(sxRf3c zx7_F9%`mvVXtCm+rQ&OAvO+xKv>zTtkx3L@x*3eh12;IeBMt zax!-!{m~8Qd`LHDr^br%`LeUD3NGKtQO%JHj|p>r`nQJlcO;0^Js<9HV?UHyz&Hxn z^yaoWlFc3P&DJuPeVI&ep1f$AeC$0hn0=~qUn^h1mrr)D!e)NbkL$zv0y`TW+so76 z35#c66@~d=PWn$jxJ9B*1MO=})?T8zkE~z8n|!s_fu-p?ufqH;f7`iMMtq30X+YdU zyzC9mPe$(6*$aFtOu3yRe7~g%T;Q=~`9vytc)x7k^!-B8H-Xsk@LDpyi~Ix&?mkQF z2g{4QD0p1HQi7^-qx0h@6yP$U>dU)@YVWqW6nuc7g)=pYtJl~B&>NxeC&R991zyih z0_{^xs8C-Y1AXBf=QEgzv-#oP$!DuD>`BmaZu=(tk76>i>aYXpnEA(MT0z~ZT~N_v zN3zIy%OVak9A*Ojj*>kbE1nJWiE)K`(W4#Pcfx2>*!l$X1_qz@)n%F2?wip8 zS&!@oOsm)J2#HM9H7h!EA^8_(f)O1FxF1?#t-- z_uxUfol=Q+Cl=)Q&wHm=Ll*I#NRIB)FfHHb;4ou`Q6~<1wpYwO14V z$0_B+*7<~L79F%`zY2LHm5wa7w_WiDyt4Y^;_`Ed*UW9Hq@AB%-|+`r%J&?r)E%g3 zP67ThWR49RJkoToxIR#DgPzhF9r6w>IkhN+w?Bd#f5fk7~}O z?;p+V?~I2Ko*(sR`L?*bWYd`qt<9gJzO-X_j9!06w<>Q)E33xV?CS;3c@sUPn(y0C zJ5>zZapur?N9qJw9SC^?P;nbEX45K(+v_4VB`M6(Iuvm9!e$IA@KE z!$JY{)nsQuuz#?cwl&cc+|GCgykGmN7g@V1?o)XZ{TbhFaxlJykmK4(AQ3S*&z?#f zJbaGwO+O0TuESdQV&yHvb)vWeTYY1`XVqDL3D#Il1Q)G0;)l2Q^F|1Z45@1&@hhwr z*)OVpS`Xb-D(;#2<-Upv3?v4nN*$ly-yV44E>>+!b5TOQxrUDlUiRk4{td<~IfX4R zYg*db{MZPpq9t=Bp>w1sHfvQ#PMQ?U-{(fxzmij0EwD@Unz0c5TKf}P#l ztZN?Rb~m|{ z=GLaKGLrJt+8(T1@4UR-F55}_yEzg;IJ$$_$Zy*-WqiXOL*_`Mu_~z#30q;~cVM0j zDUL)7_M_FG3<*LjCEb%a+ePmfWdK{wJ*g`dB;07dCcOgU=$UfC*WK6g zNzSin-@3R;)Mw}d55IlU1Bww1!yi1pm|s;9ne7G^{i{f%b2`ZVzK3 zoPU-qp59yiZKo`yDi_&{W!93tc<#12zZW6T6^2niYF0Ibx*S@pkQD}z>iR>Tr=+~G zFB23%%JV{=wC1ZrWAx+x#58Yl-FG%`-~a1hhsAL2b@}J##SjH^(Vi$-s$ME|Em*(v zu+&9cxc>srkW@8x0U%RN_~s2^h(z~d&%L5X;qH6AzRw76L)3$K(||7D531tqT#I+j z272|h0dqf37h25AViQuo%b-cQ^A#;L|L!-bqv6SjZV?utkw^4IvUpd&j@K^X&Xlpe z2(0C=0em`B41B&M(LGP~wS9ivli@yg`-_LTIF@h=s0_}fWO-{v=I-rAf`~zS{?`w_ zx2SGWm5^M=Pr8)Ti%puXBH&Mgmu{V|wvC|FWbxaE6G0KGy+Xax@~uqre_!|2{9wUs zN~%69$+~+IUU!F^LS)Og_a6JeF`~i+YAL?ya3ANfY!CQSwng1>!F|~p_lVw|zK)}M zQ&<3TInNtA-1IwXrFKP9iFX}d-Gqsk>jeK!!m~Dga*#E(!3mZT1|k+NBT{3!W1J4M zuMl(-pyUd1HkTHw+;7{EB$RrvwIop#<+M(i!_yn@#_W#1*lq0PUdgLeQ=sEfDO-{4 z%MVIG`-ejG1fbFl1D|E)2O1#~LJ+K23s^!q$vcE@-3b-tMwiUZzX8sb4*MA&bDA=) zuFWQ5XIdSiHXxxv-<==&LGeA;yEa>I{*Z4!GYnoy5T+$@l8KY1|1zeli{7ufpU%J| z2ze;ykO6q)U3=2X_2e=J_D7ta=bJDj^V{(ErDy_yuKSQOXv6*r*UH{wS`TN#P7JTnq3$&t`RuV<<9)Q`Uvq&v6BxasPf^~H)Eny z;Iquc>;JFsE~_QT&msRu(^ZEx`M=#~qdP?Dl9uj}m_}Hncohs*Q?@DxpnZL;q^8;$0X_~~buT;3VIPVvMQi%YaI4D_NdH)5c1JMWw zTUO%;=b{MMh^A05Un6SM27D9+WU0c?P0|?q$OFN)tX%$&w~mELADv!@6Yo5r&9Crl z*F+=<#-HYX*b>eMu2=ZsXm87!{J-?kWs7tsS zCbkfz%b=;=I>)NX4^EbUtY4N*7+oeeWGVE_M%o@Z_QCPA(M&AVU-F$q$EfiJ-m*K4 zIR#}u-7FDR97AUNlKOW#QNbDVX3z$;+M5#n=l!8EFQhCz3BcEI``3bP7iKGTOMx6p z3mi(#)-2SCiNMEalz&EeL8tzdF7qdI8;75vVI+B%@VWfF{vXvJC#0k3h^+{m92)ex z=!wfm9KvBb&NhyCd$D^cUSL71x6LkMm$Hp9K;ePGJHnAlU>72AI?lhMo&J@J)7q^y)z80UaEQTW*V{V_TJ#GbeW7G3+5k~!*# zrbEH=hRGc|94v)Go-FTOu*mQiRl2>Qmp{nTV2Z4}Zi(_d>ign&ID1qD$mdbL9WYJ4 zNQX8-Cu%`v=3USRUt|y*YAw$%hHDt!W$CW~wkgIiuQGZ_2}`hDT6z6yHf8cV(^1fnL1Ehd3v27&?%TF*bb6V>18mVWjfg{A|2_{=C)5y4%! znf3C_GQ;J5AF?!imp%r_FhrbN($Ocg)ck}8udF78CtF9)*i2?Puz9zuj@l(ZKL@7wS zYPJ?<_v99_XSK^Kov~Vsd0S-ou_$=~H1-x&St$umh_ee(p0UcG(@h5BEA`yYXQY06 ztRNX}QZQbA*yty=RDO=-abNJiHD1m1Gh;;Qn&C?exv}OE%%i*^IPXUfm)ot)rzyp?ulq_rUqdacK`2Y~#V~ zeQ2cJO?LTt^0D3yRr0C0N28k176%`p2nwMW;HM0IjY4>w6m54({yDps9

_T4;*t zv$-0+s1U~mzN{nY7cMcc!HxeAvcIvwpSdVcWEKkxqH00BI@OmJ#0R)PLu`5BAV@$G ztI{DYUm&L#Tiolp>-Ija>;Jg`R+*2g4Z8(e4<+<+8&m6E@X#<-O>k2`M)eRT-c1~` zyk46S1hxIK+oYJe_Kt(T$RM~hifk3ypXg(whrG#{8m7G)L`c?EF+LV>wk53@{$)H_ z1xYXT4Xc}s<2%ANTdNUltukx11yu>FPjXg;Q7$|W(Vw<`(jL0-7*cGEWP+LWfdClB zL>~L%@f2=sIQII|Qzha<9^}Q8WODe8`C|wfJw#^HTN5a@-amu6igbAji+_B&WW?^C zM6}Cd?`PE<#(B-D_EB8|0%o>>d1BTxiVCJI8L{{wdC(!Eh=o zmOtJ87RAX;mbgHYj_i2=1|-m8Q=KB_`G)cWLix+Tg_a+NKQ?%of)`jmQTTNX{^oG& zf3<$W!KwuJ<;dm>pW)(orhGgzL@79p*-_3gM$5-m&+AE-n(XS7-A!;0KYHLoe+8VO zze|E44m&Hd{)og*nDTS|(J6PVpXfS%!-_AV4Km$@aX5wabCp^+G=T*xJHDee4|T!! z?>8CuNB8`sQBW_A=>}Nuk>qX`qO+!0Yu+1Y`u3v3oY2lWKAd@upEiv$6y)&6;9j^^ zCL}A|;x)PtTnso{hZ{2C*6Un(U=^op4d9J5b4cLZqYH0mwo`bPxhJ)RbRS`x`ft8a ztU|ACxS}!geG)lH)6!=G@%l!<4v4k~TlTYT5=7(6xjG?f=GH2RB+0m1qncH?Y*{a#TmsXXR$VR6 z^^d_^Rg-(m;TZj;QGxj7^@aNqYWL$}DkV>gJk%{+wu2D3n+?xl75{<-_o79&J_@c+ z8{23R0Z8?y_XIN8x^UU-%_y?sZ^_`ZtI$1189}nQbE5Jno`X=v^^J`&dYXmK6SKw; z?G%6^!mR7&2QQ2uHZxO`3k0B)i6@sE%(;AHQ@}C_y;rBz!~D9kTjVKQ`CV$7 zpX9K?E@q0pq=rnJ_b*otpmf;Na~mQe0p;QLHzjdvY0pouLwSnLUy6`-snPXcOr^NI z$_WtaU78AUyO}bY!iCkwLK`>S*;ImLq_N#Kcc=ZN`Ma{rGPApe>Y3-SmmVnltrA{6 zNX!j})EZRh{qTBEDPzQyn{hfUh25&J_;7R}ag%hevE%k58u$h=H7k)n_10>i*z684 z**eki2@k9IE^tsVPQXRUL)F(VBlPOkjli%vTlW<8KGhRKQZE1MWPspC&gEAYM}Y?% z{el+Qe#US9ip>jNFfzwq1TC^ojBc85EycO$fJx^Fl&Ua0C?=DQZa)>JJAMb_*Aspu zh~P~CKV?UUHu~GT&zZ<{@sH##MostEkTjhP-9K6rSA)6Nx+DYlI?D1^37qA2m|W;R zV3qtq7}bV_JUa4`J@nILL%Jg(-nJ=alw1>T0SDW1v-nF-liOc3+8lJplgXj(k6Db3 z0GR6aX_>Rm=+D5yHAf`F|1P0Exd3Q&&=F&tYH#Uze%Ud$(1HX0L>oyS+Lb1?yU-jEulNBTn@Wp?ahZR!@Xx zUa>aRP$z2=y-2^=a^hYfgO&HZMyWL;QXxy0B>36 zr!3%}iWORuHeH?tG#N(-=DI*AFSpL=;gP1J+bMRc3+69ZM}rPEd9jGeXK&Wr#EGGSu}?+L?LO3$uBW!aGb-Fj=v>X zbP$y%8|pAcf2p1G3PP@=9AHg_nQ{6eDHp#dZBglQPR*tk3_6Fd(ayTC%fe2P$HEWN z?L6vIyJ%}~QdY3sfHqOjikSo!HPEKPj6(d{0Bn%Z>Up<|?%f2=MN)BCh=c>1Kht?< zD0yUyb4PZG6L5o;;UR?goS91Gi*-(p~ROlpUP+<;4l z1mE%gVH2Q}yYbDuD)cEpvpa2w`G=W)OPH_t<>j6Tq-GNG(%U93fTU=IgM%TSPJox5 zlB$*d*v>W+#a7iisS-pgzqA|$2$~OD$C4R<^72-8e6aL=iK*C z-vsBcPgU)Kc7E|PK=_EC@j|50gq!FQV{2d`uM$OybeB_~N}LqLeYbd0iDer8j>R-`c*rE5{YT9E=|d zRMRs|M|RLDW{+wXI3Ykq1DX#GeeTYJYq7pG-EY_!&g;C7Jdz8rUSVGP{Yb)F7{AG$ zuJNV6_B&{M6HJ8&TmsT9TxO=!2!XF|f$$bG>~0-y{wp+(}6HE zi^iR%7CH5*jlWjiT)>TMF6u?X?IEWz!}UYbp1-e+f=5ML59cM;r&gJ#NQ~GsRQ){( z+xk_Dg6@t|YpHp%@p+rFm8_2>d@>QXR#HVlGK4n8}8UKQQ(}Zo*+MoYn3wi)sdwV~~j&Tr64=jxp z>eOM*=8h;@4=FM~ebPPBqC}pAvjF49xuYXmk5H+Wa1_(Rc>5qP&u3&w;O!(Dr2an5 zOL6v=;)t-#PGnT=%>)9qhTD@zv;7L%_PnSaAI;2q^54PDYEZL6{gk9npcewhq^hj; zsajbdvwd@#Y0!OM-OxfKuD#O<*$r&)08BpZQ}miWv)Ot}*G}?GMP>5z>bceTsj-8R z6Xi#y!pZ6?oE%N3VgIdZIT~+}U5#$WsyPu|`D`}eU*Y>_9Qbr&T)E&LNYr~#yF;^b z%{%}mq{zK9&FueJ{WdeT5rRt!8iz548X)KC#VJ+4f5v*;~ zj`!HXF6&lw59Lxo$lqMy|3z!JeWH)V9dAhbSaCOvM)s?fiNCTECb!A4Yc~7uHynFG z*T#)>`a`yFUQ+%W@Cw#Z#x}DRwbuptb#Ku&UZBC46Zx7O?=-^%@W#i~t#oocT{x*e6wH(hbu_1-)_&SC(F7*6!b`p7ap4L+>twx*msBm)@}E zq2s25PgF%jc4go=!H+Wel9W#Ee4DDu1*MWes%Kya*PF!)KuVA<55xT!gQqQNdbn5iPj^m{Y1sU>v)E?E8d`&jg#E*_*hdNy9_t4 zhABha%R~e&b*=FMJ?<%7USNxl_3e3;`AVghDT zrg^|*=NWk0Wx<`rLcy#HI_3Wb&gnK@vWGQ7**Ibj&Kv8_r4e1dx4M@Lr)c4BkD&c} zPvaBp&f^tbku|sfB@?}z=1kWzewMkj?bgZ_52lp?rj2d};CYu?kBi}$8r8eNr}u)@ zN{=e$)&cXE7mP8Q;MED?N3^8FFJ8m=CQy-KMuMtHW~RY-v_(G-<)55sZ7aC<0R0E$#%qXH^W1&5JtM2lQiG_r)13of?zisfH`x0V* zsvVT8ck3|9G_+MbOcz5+yYmIyAhxTazNkO5e{(^7>jXX76q$N!Q*A0OaMjH^+JY&X z!_8Y7mAGEibgl3VbH1WnLEz^bRF5GNfmy-)CUF{t-qSaH`r^e8 zfqTrk4B;JgW!S$QR6IFCKBH)451|XktxqqhljC9{^;8`weUiT*F8!bmFQwveD|^5b z6!MT7c=zkM2xstkoj>$6xb*|>@XLWZL(x7yB^IXL_L)>tN(r>yBPo^=5ivX0c;iKk;XLmG_I_pR_{96lX1D zg@EN}voWW<91ZNy#CdP5ii(MBP55l1`r58j=v}l{9P3uVI>+8;>+`+HEzF#<5rmMJ zXk9W^a4E9!vT-$Zm8N_0_I#Y`Uz*A*BsQmJ_zx&Kz>l!EcRc$=R>kFu@i($yCED)oiW0yz8HP-D&*_+A^n{|^V{giO1{03HKu5JP(@w?cc{<~{elv(c z$G!B>2|Bcg&0MAqo3CWI{d{zAO?u5P>jldFXiRly-Au zZ?ETodv@1AO<6Rz8YjO3r|fS#YXOyn5V1?F)*gFW$JIV}+*wc*AA|chTG(CYC63ia zactAZjnhx=hL@pvz<2g@LffFEEv4@XojJna%kMh;b%~I@6T@)lw3?;lL6$@4OgF4E z?Rm&mIEJ*H_S$dQKIjd-v-=Yl*C@|nB)Z&x`FKr7=yT#gf)YdiI;$4wmjL8SmGt51 zUkMl?$z7>?iSkAlF7N+BN> zT{YC4(3EhV)n`%?$sg7T;Uo@?M5IcCzb=e!t1U(#^Y{xB3tvB_C|{ii-!grjAtD-fxrYg3cclgkqWg=;4gDpT>nLZXxavuU}wRyVM3R^lPt6u2t_aG9C>dT-qFB zC?A))%@BBmP}I2Pc8KD~>(_-J#6#9Rf6lsmu@f)DdMCr2PUW|mmh>fdMMun1PltE= z9dDdMtKhQ)tT_Iy&j%m@t*>gwq3%s@2{@}fJpe`beEOGhVBN9S2Q5ibt&8uGPglIu zj*b$RvEqvfT%>L&qz=m4xJvtACKo&5;@e>ePcxwqZKil~ZyY$*e%MeI^!GI)`}|ib z_kjX#Qxj%q_qH;Xk8r>ZkX~55D=KgF@_VrQnBAwa>20;w_Dq-5%}b>b=tN*Qv*nJ4 zN}KMTr(DS3t!ks#DgCsm)BA@boJ5^y zOO`rB^8?!H^ixEjPOt2Uaassk>o(Y+Hav1>(L(T?-dUGqvq0!?5Pr(N_f;i6G1<%)_km)7-90jM2of?<*`3cVM|Hx+h; z3zL%XJ=rSmZy`LRnpcC1m~j(+P(1fwVTffPJEd>?+Ea32e^|pKgnGHd@2P&gJ#r`z zF3VbX9c%M@qVu*aF!w_j$tryQ2L5tIt!8!@^cfs7k4A)dg`f~1NBpu_g@_HkS;yYh z>Ui;Y>TV2bHP)!&HLlm9dOo0)y3+LOGlFg_vw2K>hjc^od1uA%3i;(gj(B#JkNp|q zs6QW0E{-y86d244Yfg8BVY&OAZm!L1)5qfHS;bev-*$E*{L+gA?ANp2pzo%ZAc4fc zXDphF2mKPZAEe|QkorEw}|EwKFNp z1|Mb)*e{(T0~fe`h`Z@KNuc8pBp%7w9UZFh2Q+57@~)zFWLl>`Y4O}aY-9%WtG`v_ zA$9V>Gu)Xn&8yAuBCY1tYom=Z0-ZU>`=pyIKlO+EAA(@h7pmw3jfqZQYNBsnlj(HU z@DSCNV-)tAWcxdq2&lz3Ln2Xr=1k|Ay?0uVo$ZZnB?%RvV5lxo+BAt9UpaP_~u#j*PBaHdOQ|5&zf9 zMiOwpZOd(qc(w-&A0k_hL&Z;& zjI==6aUzPg1>so-x00(o0tk2?J36l(8QRN4<%R}ymDMgG7O(j6AT!Wg5r*EiJ2feH zh?Lj=vvKXm9O|frdpxY}aG`->74oO&i=vwE93DLUq$*x|$tA?IPBWUFZ_m?x?C|U} zKqSB%ibxB2{%Xv}o~!%LNX5p~^f*wZQf%%x#x506Wy)NcO7m2O=rZh|tvhj@od8tYAon?6EVjk?iVA|`Az zjKocq!U;|>D=!sIz$F;+pHqF9x@*IAisXs?%>+}U=U(YR zrv7{Tt!tCU2yxXb!g8^Sm&pCV0oUC3Q#l<*e+Nho&uUxQ8O5!iu0L~F^vXNl zD0BJ^&+r*_%^%h5fhokxl8qb`K8E#?(0+dlgOlbf=_YSr8aGySE1+)cx5;cTJAOL^ zLo&^xS+AO&Lf3f#`70~Mw9-A0N}%0`NODaIbz*)Q&-~r}gAF!gg(!Mb!be7Qr%p2l zu!mm9#3O@g^9ui<$5MUu{KWEKJFSx3T75Z^ZLbEHrBI6!$DizM?xECl!t9?u^MdC% z-?TrPwrKAw?yfot=CH;eNhA>uS@eh0yQmw!#~0RIpT<@LK1^)Er~t;88He}vdZYRV z{hrXw+`23GAXt3d51O}O7Z@UcbH!BSw(u^ral`X$<+kzN1pXl|3n|k5G+k+;5=R^Ghxf;O4IW3d8#+s}l^WXC-_cm1s}< zrU9uy1b`^(RF?X&37qW*H?zXhYy`Gz9CLd?6LLixE_Cns#!fM@t8v!Pq0+|--_ocv3c>AvVnViZ9d`0eo}ay zEJb(h3U;vN!&fNr%u+R3Qq|%N;d)=POZ`ycEjxzO5hWbM7i*0KbP@Ep`zRK-RrHJQ zR(D(98&;PEj&~AL=hSzSiC#-WI4)JAk1G0Z2P|vh#w*q z59{B|EVgc43hzT@8bt5~ZTbs0f)FiXQTiW$5nFk~ci#HcVNXQHo_OLSliUR`I@Aiu zp!mLv;dlomHy<&R!n)g6`vR+8ImG??NGBDV8EI))(m{~e=fxu5F=QS&QKIsTk6(9H zSc;Q`iVZ;dRiIUPL8)GPmOG^;`}2zR^DOj>i!v+Wl?YrIVeTt=A*RsLlYZX^$B{Q= z2#p8e5y{T^LK`lSriyhp^~Srxj9*xp^{6HTKwXOIT%6z9Qex+%KD_4R-JF)U%;%wN zp8uAS`|RGCY%VX0>j^?Digy-5&lds?f0K+J2wZ}e3biy<8tnB%kHFuY?EbMb;$Bc; zxVU&BcZd_4B7^d13MA@fudWRq$#-ME+d%oOuaY?@?PG%2e-5!fU^qL`0^%dS*@@d_ zf(Pt>qU=(FmOt!0wB1ySq!5L7#|40Hc`cYf+*tbnPDO(SJ(G`pg^PJL{%zrx3rWW_ zobS(0KuJ^Rgykv8l$JBgaW@kmuZw)C&O=P+a`v!b(C;vf2y=REO0de_1@ z9C%iJII9-$yy{B=@9~dclj<&RRG2VCDP>3D3f8I%dgd!6#l>8bdMX~z!xps5wT~Gn zGM<8R+PP7d+-j6iTnG~dPV?ie{#-&17VndyU*Nr?LEKkp0wObC3CidA0XN)aG* zAdI+=f;z;962w7^=YrY;hn_) za{+87%m|H4a|8&D%(9>tOqO;4KugF?t>Q~gl91E(Z?3o=Fp*)UvUJ~l{51dEV)6J+ zj&dNqR#p2`|4aOGeNdy>THXsR!$QV9;yjM`&mGax0?<=<==}Tv_6#;-ni-03d^~RY zrPq!HfY3>3Xf zvNY-~F=@$+iypOTem7aqa~1T;>DAGse2c2q<}HDvEBv?lVvqVAm**v?%s%o)Y@qQw zq=xR?M#n@vL=7Y^i|qbzvT?NU->j3ubQo&MJQsnlmF)kkm4R%^UiA98N(qS_(Bm{V zildVW_7n~>$-td-snef`WuEr887Ca|5*aMWwo3r`MmUl!%fMwSmmT(fH8K^?ZgyCen*Yc^ z@bd||9{BpHIb#F1vF7G4nu%4#U|!8W553x*fFH)(R9I`m&0lf+aEn%fGa_Hx7K>un3T*9>x7bjUdbus0* z&bW@PZnbQ5g$NxlRazcVgvV|b+XLF4OP@JIl>XZtx1MCLLRNAdydp8BrsqhKzp@kH=Z$bX$(+RP>btg6U5xR<-p=18smc+G z)LTV;Zm`fM*W6Y-sb@M5XU0BDI8o$r+F%Of99Lj8eQ`1WD8a6Dv<+VuGFd!c{!)#r zkuQ$A+AK&|SqwgSQacAqOa?gmNeqmSaK5>0Kazq-9(%e5fkqNxVO7!)dTLwxxpG7= zp4)QRip9n`%du#MZ`h&nWwNZ$fuf6^7nXU6l&(x^I-x7>e#npZ%%g$T+S}`h|LL$Z z`2?dAJq8MWx&B(pyMmq33z7C;iFD|)NE3I$mR@Zs%K$tK-R1SJmdL|-!| zV-4-C^G*rR!-QynPrG08qt0g9yF#x9acATq!xV^w@iPqub-eCiR0{=aAAh@eSO@(T zXV@Gs2tOQ&u<1f2sFhQd{hF0g8Z>{Ziyv>x1MwSy!w(u9-DBE1mW8ACE0LujUaO@z zmg85sSfd%^LP!*slIdu{Q@WPJ zMGz&2fDvixKzhx&(qw|W-de!IJe5K0j=R{XKE);G9=L6M?`MsuJj+siY@QRXRgz5N zb6>2I7a~$bjpWeE;JE*cwb*mY`L#Z>driYyv zecRzbY<@$-wl7O#bg;?~$9+!bJX+bKsM#Mfe89(GE7#{unEJQB1^^2^En)Z>p=LC2 zn>_KRxTCc^7j)sV9EjVm55TzCnr&aNyI-Z$z?wAa&atL*N2--b1vx$%u_%_Ae1pJZslhQr3 z)YI!-=Qa$k@tFJgq9B~2rCxUFKJrq}vhFPi;yP3&YqLS%JYF>cO=B~lBfv;JRR-R* zO*7{s_(|A&oM4FSE!-_}+$Ey71(TmJSzknZ9_&uvc9`s-9@=ZEd8*K9CL_ev?O6VS zmG7k>FnX&!5?uF{p*JfcDdmp*(9N^nIDvm<&9;gI!pnjq!lZN4J(l9qsHfS!@_72D zgBAD$az%SM{`pmne3g>Qe)5WAxQmWQ9g4p9Vk2SOWwFtT5ql+$RRG=9Ove7Y&tB?V zwTJyPj`1i!VJEhs&DP!9+xM_*82|s!p#gx{r2pqhw)WkBv#?46Ptg!+q|%u53Pj)l z&aVPoT+7MB0VZPd+;SW>qoI9TF3a}M_+L^E$zUI48MZd2ji5N_f(Ek$!rrXZnD{PX zBrmOY3b=_q^uIBB@-pRvF3^ifg{cSN(u9usmh=9t=Eslgu~TnkjWZ}I=VR9zg0&8v zf;xr+nCaUTY9k0o_5z_#cp2@VCc}=%8epd_)kK zujz7rtu=)16m&D9@L-l!*7j}HWDv9`k?Jqq1hr~fNILCJ+U*JEUTVwTIRguhX#_T$1?}W&yF35yBjW#1f{Qn~qto9X^EEpqt zWX>M6P0qkKx|iLU#$@bTATd*yT1$JE4K!M2Tej&EUC~*y_4=`=mrX;n z>g*o%6-E`Ddn#^+xecj=L+?)ZCFX5Pq12d@+0QFp;v(`Bt`DxkdI;6Dc}5zu?}J}# zkngs}(XD^?mUXTXj~i25!(|S))ufZlI-u!xVs+S(maXj;3PJM6VD?)AM5|_|qnup^(y6=jZO6QLXFT2aEK13tHJU)1-hWv?CELM0 zeaa_`V;f7K0Y&eRTSsYDwF-=y-t_fO+tU+;&qIzz1tip}ZwE83ODL*FcFu}4^wbdF zbO@-1W3JD6C<%a(lcIy-z?#Sxg942pnPf{q=#qnHCLF?yZML?VXNClW$+bYm_ztw` z!~;i;r)Hm4FRDTrnkR%I3^Yq*ZInT=go4w|ZD|Y!A_5)YY0$N*W72)J4Nb|~#A*2c<7-o?#%MIe2z)>ks!2Y3<$7<$&Jw4{oPVt=z-~I)xSa^I&(prdXi6DV=V|89)d&)ayR|0A`;k#aXKYb%Xs6{>&jyBRjJBLrw5aoW_XN2gY`OkYKqdug3aC*CI1SVm#wnSYrXOMNr|q;xF{z4OP~iXYOvKDbi?iLf za2^5Am3hAR^J}WiiJ(6NX)J%8O;HJCnFUKjW@U!zO`BJo8{L>9p31f#AQmkfy!erd zp9C-IN}5~B=$DUYGOMsq^srgo#<%`Ss@Ja*;BWChqeH4wo@7%GH@yW@Gx$Mus(hl6 z-~HowE!GAZp8$Aq>1^F;;74eG_I1<>dCCt`ld(V8>K(igVo6;MGjLp};7>fVk-ARg zW&Ltq+c!WER`>mYH-n-HaJI4%P_N)z8tqO%jZHYtS2=O~HNHiP;TP*L7i=3FqgTb- z6BkUp;kzQwtCY2^nzi}M4cz0!2ecqPl913YH4vPb3reO97vZ*@`3ghg4egg{!mg*1 zX|}3ImAskkMx?1iV+bWEJ=cY_;uVkRd8h>WtKr@sv!@@%(l;vEX zufz7czgmC4A+w|+H^ZEQn3-f@R6e!PF;h9=O$AkZ+i^fo7@=Pz<2M4$c6>&+PRBx_ zDQ2w-R+rP!qPS=Ctq0di#FC`okR$B1=l=Z6S5=rWR_=7?R_3BqxP{-Kec`W24TN&M zb;U4=ZMbpZ+<%l$Z}VZRAsnD@GkuAy3LirgpYumBL=&A)y4c=iB+Uo0{mi&?Qh%#I zYV)tm_7?Zar4U8X)7;AV&u;w8x5*?{j$FU;CaC{DNM)0M2=r~aEk9DA|Md4XMx*!YZm@pz-}b%&vI3eeZHt{%+HgZNo%f5Chwj3(;w~Q0<=nZh_PN4*-SrXW=jVG#GBULE{hTv zJ2Bpm7QHSvm~k__J^Vj^Ab)Qccjv>Q!zYLG(4(Tv?Cb|{raTg#V3nWuJJ2>BmyE0y z*qBPh*ZFw22r<*8c6(3Uo8Y^{1bVs3;R#`g-L_pEM0+tQ_xUqMmw%V@&^5f_}2LE~)OKqBb<| zhf_DPy15GZ?)<_h$iNR4 znacBo5F@@N=r2$@2;+r~Mvf=JLm9)h(f2((23a3_7)Ky-|7tTi|MK6$!3q76Y5tgP zhAQ|6($R1#MTR!6S4zmoRjRW)eKCK$IukrMx5ys_zOZ%|gfyo&b-}DDN4i>hgls>B z0C^kBgV0Ns-Nx4y9QxNclK4deuUUtg4E|VXeUi9njsXfW&ML?W3)1bj{3*Ni<1^qG zcmCygKCG{gs=WJN{nN<^w|rNW^0%PJXtMjM-8%+ z*MCvl@@HVgpsRJGF!)vx1mEW4$@a^5cB=u{K$+_-BqwIWutK05SGzwGPN1Q;y!$~| zowA5%V61Yj(W$H0KO*sB7zkL+G(_YWhqs60kufctLEQpU5DqmIk@~=S2e|$rMY>e^ zoo>nG%96SOd3Pt#{-RMcg7r745Ac|gjO*+Nb>bE;`L0qy`dxx4U(2{(Gd&N1$P*u- z#CJO!mwgMGF^vzdUXYMM(Ak<`(r)|=B$dn5y>tnX*AmNYCwip`wAGh!a@zYX+^MEU;D+BwY#R6Y`!X(BUV@xk7m_^;OLB(5Lt+QN92Lx9cVa4GXWER2Yf#P^Qb{zG;&!mW811S;yT}oSCqMy+O)ix?lKU$L_!DbEN zo3nSNMwIqvx+e=*%WJKRS0j`0JtVJ<7lZc91az_QrEOq+7DSV?#_OlK#jt>u6)#>s za*z&km*{o{SDLx~ZQC%vF4KzjNO;s|_4v`a#lNR>Wz^N(eN^iaAi5o=w4&gNIq+#T z+wn_bQfo)6NdeI=X(GdD8)jUu<0lL3Wgl9Nh{*|0IL`HN5wG_HLM!5RGCNnzZZ-N3 z*!u0<3E66+EB!e&aB?!?O_ak{f_u$(YrOE_NybxRRlX@G`b8$!y_do|4IDh+Qpq`o zwjMa{uAT2ByIh;2S%D#-6RAN}w&QHWAlG&s^1_ZMMn>oXCFMGiL~^TD2lSCHfFtR9JBVfj}Jw?F(>iQaI{&;U!Qm_!ohyS*-j9>0t-apbTO;e;$s z!r~2JO^Q)LIioJ96L^yw*Pac(fS9#aS9?_awgFy$ORN{=tuEN6hDE8Z;8l7v7^9A+ z+1p%knBf`%-UAm|0FwU@^voJqBcmlG{llx##&rpVt=-1Shb>*Vuxjg{nurwyqb+AmA1EzC(0d$u*pmNj^@#J z&YQD}Wfz2JwjYM(-9ORrRp=ZV;eIJ!x}%0sg^S`s5WKA43#uo(y4B7MztuqlIP{*( z8G1OB;}Y0aK6q!`5zQFbO)J|Z?Y64K&|f@lWAnrmagdP1Z#Q6XCH4Vtj%%Kdsc{h7 zvhY1(#!0d!oOswfj@-7Ndef?;tt5x=F#V+bZC6=eI94r1nMRO~&Fc$a(GdFW5mM7| zI8N%FQGaC5tA_t}?x!m!PpirW(R000njA^FnkaN4O3oajBf`t2tFvhE%ivj0eyQ2H z^YB5*l{$K|2-*aMLWFk);}N|1zGSs8y=N$;Q@aSmQeT?z#dwkG2fd<{Z*nREPGtWm z{&co0WQhUm6RAac)I^$^_y8rYf;V0CVGm9~O>0!pNR`Gr`C*MEPBc8uq9x=V7q84O zJzBSZ{;NOXHkyFB4va&+&N zUW_%tv6rnjZF#9ns6E)3|>gOYetvjLaO@ajuZ4qJK8cdL3l%jsKyr$Z96u_ ztnmHL%xSVp(3{BVUozX?d*+Ty}4 zijSbOc@JylVz%%(vB8NW*PSK-zX8FFe;5TU{`5uH(YOERm0W+~1pxKa%XNx-KC^}Udf`#_D7V*m|N9OTBxB8*m*PN1gHR(~j{a6lUhp7bT zULoc^@98NB<0o82>MM!^>LMxEqt-hs_yR1UI*A8|=Opnq4~5PYFARP(S<5q+D^L(rQRggY+d!`g%_*^`C|kD{-v=;k!@62F)hzAsjeFC#U~pFQbhj$q*8ecurA=slRpy5zOWqpz3o!{+LN zT7g-Ec4?N-|IKIOckYwFU2_r|{h8~HwlTu$nTlqTo9dD#Uo-hK@`z!(0>1qgmm2k& zhq{lcW!~ZprBZTRxjL|$J2h!q9=3La<^9rQ%%$?en6C96j)~$@uUoa1Qo;Y@9wCq? z9HF}0Zxk4Z?Yu%L8*7Jc?c7;tRQ(u)_u|R!5gon)O6~&cYSm$)D{Vm7*=3wP8}Ikv zGy)T8aVpg?J!{gE7x6o5$ds8^9qI#`yutB>PSUlGWbYsYYHg< zgfM*C;JLEl&5u*!YX$_59&~kIH`Ud>kD_7k)V;s)4+OD~Q_?#vqDw)p2P3boMMOpE zf@Ln_N>-b+m;fG7YAs&xM$2ps?DUcxs)&cEVt4T5$Sz^K+PJgMThZ+!GEG9%sJw*q zN^w3SAKsU*D1^xSw-hy{w&i&l+9u_1=Cy|@_wW<*J#m=!q%c0$#fT`9JJe0!avJI> z?-^%OF3owi|0kTjbtNtsd{s151P`1_hvs~igF|BqYpj-Cjkp5iB7ib){o)d0;HDRf z6Wx7bHgd~DjdWzoXN2Yt6+T<#(M9e+%hJoGc*`R()-;IA(<0jUpIbf@6)29gPz~sM z{FXi!!(*!_3Zcs%$yyk==;5y36spYgo-i#_8~E9u@9~>g`mn;IH+At{Z#yv-=O%Yq z*t%Mqx1V)ga6V>x-)<1fm#ne7CX?KMd>VyzZM+(ke0zDs%E5FScyhcutJ|MO#WKs? zC)+ZdY^PsQuzr0eE%CA5rC_$Kx;cB3cDq4St2)^Vkt5m~UnUS2hS!9h3M=L@pD`b4 zKPsox2lbZ34v{3AGT9DN{1o4rg-eoJ15aDMo6CooBkA&#J*hM9n7-Y~WB(`T!OSuZ zky!Yk+oNbuE!X>xYUgyvd5*w`7!fwe-oW2)j`zVAcyFMr1cmtOGEme2N!!{)#g(t} z#?0^-Z`=RT^p#;zwq4iP(A`K1NGnK5N;e3SN=TQ0bT>0fcY{cmfG8kHcSx7i(B0iN z%*;FY^Bv#c`7y`Db)I|ewbxpEp(JJRm#GGk&Qj4C^)nE6wvzsJ&V5?w))0lQ>Pj{X z4yG1Vo;I<0;DBn>>7DQ!Y<(To&;Q+hMU-mK(CG8&hLULyEB%>i%+UfJuJia>o55C? z4EHHvxlF#uY}uW4fDE^DV>L7uc_zUWKVkAZVP(=UC`kHhN=A>b1XOv$&7#?>kKUpnmFUg!H*69sWKzoBHEibv9!*M}fJsB2wTg_0;uy;hOpYZP_sEB3Ra#%w$X8l zmI8rCn2Rv&9jwFeDSKbP5N@^m22-~)U0_mA?^~UCHdJyx{YP^?tuN+Ze}PoNC2}D3 zqXRt5fl*AE9pQLQwL`5p1}H?5_ER3!ACnnf$RNs43&i{jyNJoBJxWF>o1{3nHo4BD zX+C0nQD(=Ev1Ur4%uB3kpO>na@QYKFVy#4SaS$K;9vdCq06+daefCEGCCUu^p)|s| zq4d>*sTveXtNIB2VDcAR`VQo4e`H2L%u!?*D|BG+bunC0{NveLftA4r=W=q}DuTOI zLwE)%?AnfE;cq;v#z9&O;!+<)U{2lX_s7D_X73t0SZ+q=*`l{Bz%~oX8cY3uC?s0Y zRM%M1MSTY`Wk14ndLftU_Fszt0M+O#$i8d5MNL|O$cMTC{LZUn*V|e{XL=FZdzT!> zjDe&rx3(v&onBEg}8sTe^nx%9fMvgM&{3`lbHw{6Mao zW)YahgMh?0dpdFO*Mf@bD>|v{QnZOKl~~i1uL9Zwp`pVGOdAd&q-c zlv`u`*GR`|a4X^rFiE}K#cG(wwl&-j=wV760BMlTg-gx(IzqvV$Bw88rMPt`)3ZQE z?FnVrqi$bY;4&lJXT)Wdh$$SKxXqMt*;yp#XUco<@dG1Q2nohou_c7^ws_MMemnIm z9OdH{B{)B0Azt4q*DZ$vt~^WO6E2pE(-_Xnk_oSGraf%No7?(Pi;cv=LiDz;VFAZ^7?tDy14WEw%^F+eK;~ zW{|bz%=COZNP{rwwf=;^U(3HpT+p!xbtU4rnEw8u6|3UN32`1BhzUoI{K*UDT!6(-ngKHx$yo+r`0(A`GBgZFrj%_fmxv;uzlmoD^fgqM1eJ zfof6My?)BcPXIQNA6b9 zECLUcPm0g1m@`c{1PlDUk{o|9)6^s3F=-CHT?vlxhM)ElW+#;L3-O0%QSDUQ zv_>iCipFbH5#uFxg2)7{=1t+d6)({SSfHH0$~dhUpL`7=9K$m~mb`!3PXr{B^3os; zG4EkC-FM?@No43fv|pV=j0I*DyZI!kW|aHh5L~bPerS^gC4Ck;c5qGhw`l{En2Yu+ z2CBbzAY1bU2|;$#4nGv#<3WAjla>K4P zZjyVK^{qjY#aJ@}RJPS-ZAx4;aDk@Pf`(x)1>qya#6hXDUPg|pJ=^eOSh;JK?i#6g z`lMnY)y`<)GAcY0 zwAd|aE-165#p?WzXN=@{UQ1?fYN_%xsNz;B)?gv8fU~JfW6Zv3&7%g0Z_g|^{XIS# zAe?l5C;0jtb6NO5MaXV;R!)}#0_I{v<10ywYQ~z|a=nMuYOcO3fdyL+r8`DdM>}oP`@^(B$lA1rB`v@rc+Dd{h$moiUceOS%kDdseW2~<*U0IJwX)^e zpg}QMwO;tlRq<2s=gV71^R;84klYM5jGxd?ub-L6Axg$0+%NT;08c51pltqvkPI93 zSRZFlL+5`okliYTi59^Oiu%~7cA?$ENZIDV^yICl7S)7$xDeW{Ys7&ry)g%drmqd= zlCJF6jNgxW$o?BF%fYPJ))wSK+g0Ve3YWI5&3RX{xrjBV5H3wkPl;iwdw&HjY-l>q6idh|-A6oa__-(JI_&daq=k2R*h@e8Mm|bc>}*^JUlrPNcG^-EvO6 zy!sJl@kYT)qs=P?u!IWy{*(-$Wo9=B<#SPVek&SjQWe}9Y)jgGp2fsBKopZG%)`(Y z3{fU#R4y{@e=BbLzt+qZe?ePbKVUpyC1k2p)AqKyJ#H09 zIMXE#jxICAg^&~6(5cyR#dep(cqhfg#?~A|HDS_;fAD#}AslXtoCoU#O9$7gFfN^KWF^avRCK7aZ>9OnmI2NE`+Y z$F z29GAp$k=)PA4kG}GNX}kjh@S(>^&P()T)~E1Tg(CJudCK(BAQjTWh0R;RCOy4Eb%3 z)0KdBnFlKN5kyW5;iiB%6MnrFh0o-{pY1e^%O(M+#4ct72b%Eu)>i=kG%hZaMP=)8 zX47zoA_WeXV^l`=FN>8}xtjR0Vg6-ta2KA+z(< z)QzyiC%&pcvS-JCxH1Z^Fx_PivNUMp1+18@R`5?eV3Gc)bQw391PkwvbcjddV3ADY zBI}RGp3QqV4}(9zi5i_>4m;QgQYk-s5$7h|jYFf5WM?G({0!hnlH9-x)iSf*dso`F z#`w&awB~@aw^=L5iMyg8n#N& zha8Bd=fQ9k&2?G~>7Pjp9BFgc%zJy=_*2-7va=sydPK{@OoT-}eEsAby1DQ3_6CtJ zD$Tx}0$cvcz_j^J5b!Nu=!&1s{ZbCp>&N;;eu%*Rb8K38e5MCI9e8BNNnZ@|KUWXt z&w6o`N{7fX>y5;Tom}U5@J+4n<9R;{a0snxCL{I(flLlaUijV2Cn=Kt*Az_ADxv@i zc{X6Z+Z=Vy5xWVyKlbf$Krq2mW6Qk|&wFK8*+E}-OJZjt&z+raGd7dT-3bZk@XTp$ zF!J2x^V)YkiXV*qK<{c)iZdvzDJ6wW6-!1PMR-mfZ%6 z+ecxP15I>3OG(9Z9=38T#m&P*#+in=3F6HfKfE5H%TH&+cy}30-><|eqmqL5eH~Es zvkpUR%>A43I1zI`nekXnOX07Ey5icu28v7%l$vHvt7OE2pD{wV5H2t2X^Owl<0USO zPaT`ZnSCQ?`yv;p`S9YZnO4CzvH8DoWypU%{bVkA)VX0N+BS5*UiBTH)2DkR7kTNf zp*H_2-0+)9V?mxW!B!s}Ulob+mCsb5vT}9IPGj0HG4IOr?zBTKK63iZHovCP%-=+a z!Ay@HPAwBq?0K3frw857XL#}wj}!8Z?)S+jo1UU^0~HpiaOnT=yF5xrHZ=JIGw|+B z1ZZq-NcG=AhsUC{Lz)s0cK+HJ`La6vi2mvg4Yg1#SSKM^q)$}Y{?SagyYm+nfjMTX z|EWN(o!AVcrP!;RJj8@8&YC`&C{YIX+QRa2>wCx5alOlfx^FzC=aVdHbfo6HOC4Vy zMO0e0szWeH4sn#Erq?Bb;Gpx1lso;%BxfB)=t{=GeR{Tn#)J2vq(8Nshlx&{lq3 z6~-UM!2yIAB(~z-1-#ICI%)PFY^eL6@YgqNL-oxt*J_^fp}_WwnkFW!=1=1$_3xg3 z{91Y~X3yk@MX>X5y4??_+f^~`F~#O8WrXhLWPj~FMBLp@rXj64b2O;hf~EN%dpL(5 z8T((;RYi8qy@>tee)umyv2V}M{su|GIemyL)9Aj9w*uaUy>t4r$!{FT{?Bguw~GZ4 z;Ci>!BzVr)DN9N{Ag8B>m8=xhlJgr+VVG5?v#zxE9Pd){*bJ@QuNQ((eR;k>X>g4y zK_LUpofz00KY2g94t;P>#QaWd7ep1sbV%Dk_c*0|q4yO^iKP_`96CrBTZe!6JwXEb z+y-zrDM5|;A{&Wxtha0^Gi8VU-41KBtxkzGxUjubn&K-o~xI{0?6?$kRx)obbyo z9wwYXGwB_XDQR#Oi+H|8N~Q^L0V!U-9BHkQt!WR6*?s)Wh^RadaLxncX;V`_OYY0- zGhUK^#mgwu#XQPafSO%e8@;Kp`T*5RC?Ycj{4SwP;~k<6J5W^o1!~aM`<$-*VH_7@ zpFX!-;d+2m*MZYx-FOM7lw5YbSEu_rFO9|;WK}?_yk{&HS3NZey)f#yz+3ubOZ5(| zD3~OF>Tv(1FU2N9X(m#6`yr3uxygN1CKob}f?h#8avXf(5n0H2+}%^|N_*yD@HMCJ zWlO_mXOgaglMfT^R(^P}BZwbGeA#LUcV=2Gb_hfvIn6`RS!>dsHh-|1r5u{Mw+tQ~ z=qquF0|3x{qnc>f#!un=-@0enMtvn`O^F25y>>ov{RLdv+aj&^(!F;P{Os6{wH9vY zKg~Wt(uI^zft9nOV|7U7H_54~Z&Qqz#ya}-3_o|}wo)F5CcGkh^2KzN%^pWihX9H@?6+5DZ%D)=mi$b-yyK?sd;Qa(RN$?eRhctYv zAmExFrBx(R=2t7`rk*2X3;k;rw~$hEGaAf^5Jx@%-GS^_|9vyD;$;KcSgQ@ z4H>`vcdDh39=UMt$H{Rdcjlp$r}#4KzDA;BM@kcd+#IdJEu-PVB@pwu%vsx3RXRJy zkCdmtSgu%zX7GjCwQt4-?oXvnlqY+mUQ&GGlaJd$x6NB6*CInfE!+WjV+fWHKe}vj zGA^0DINk;)e_}nkeh8KqJVT1u=J8T(T>3=t4qND|DkHLE&~hzBD8nnZ@!apAxi zF|}f8h!s`FUHOzu1#u%hYL2_d-+>eLkf3@7`3Ah}+GP z%vXJ)v8Z!2+iuSQ`5-BTm~sNaJrzw~ik4|Xm|`dJ(XK)e69qsOa%#2z=t%uxuxBVL z1Si1Bz&9>TlQvvf1R-Y1bun9fmtd*%$$)Ewef`Z!Jog*zFEWA;URmn@(eag~|IxaI z#uYQ*f`apv{fBYbGxE?qhT%B>W86e(Hv-fYBo?MQ_=Rt;z-vcU^81Hh;UcX&w*}SZ zyP#!L;$_o3)+Oys#k@4t|3SnOK%0h1jV#jJ0> zYb4Ay>*-z+^d5KVL6m9~F7GF$@S__G^b!_Aej#?7K79g|Am0wMXwPElBdw&c3?Tmu zKavoz4tx4@i=3FDh0NXxaY9z83&vqG6(@e%-G;L>yMWiW!Ln7$JA?cY2C+^w^_8Kc_M9Nani~th?``Wmnxw6ZK;rVNV zZX4yiyi5%sDhd_5AHi`7YQHjY_!Uzn;fEIBJz^gGk!uYmIzQYB0BgAcCtV8*9|ZbK zegA4o(${5}JwUarrMrOk3_s9>38NqC&1@faKSg>emkw{RiqW1s_R@+9dYFD(&-<|>~}vp~C!vuYrZp7F)es59WC2^$r}GF%NvNJ2Ss z0h+<8Wb{cC6PRaS!5NQ==7yW2PEa0VFk=nYu^aY~`2pqol6ByxDa}YII0^)=zGCMR zcSbEIr_58wugUkoWR?}>o)}OI|4P}%3y?~7d!>%*W3h=j-$g7>IQplh1ILqq8m*L0nM&kjaq?`GzY}+!MA_+Zd)Dom2>70IT9!0NL&W4h zAv+4GV3G1u(9PGrNx5&g6k14*B!wb1N<)x&Z6e4T)}|p0X%8^3slt|CrlH|`!}mX4 zyjSIB`DjNZ$P_x!9+F5>2#R{5;)o_&>nXBKV7vEmY<+|#IFoUQ@!vYrLzyfenH-L6 zT4>qJ+M1dl?r|dn19KU-ftid;qmL^N&?UHHYh>(Smz*e$d-VL#xj(W}izl15gkid0`#7%q6B?EZ^htUKMb6d@KQGyn^H)DdX8d&sLP^@IKs^g0J#W8$gaB{jQ?ju3H?4;mMmQqy(gd8bk4x;1X+MO9pOA zU`1fs?uk1tjWnJQ?TXtHC7bGrvU=rvvF_0rcr5%RUH?U=Tqp>@jr|a|hSiFU_UV1~ zr$m+)>b0<2Y~w)`h6sRsl-TSTgb7ui=fxns)f#=Q7UN?5B+ndPT)y3O$BYBSJ$-Fs z>5?yH-kO{mFNd^55Wl~C9JcbL0@BgVyD=c8_!Z;@c#Ca1S!0g1$LA&2OH)^^hn@z6 zxcU1Gu$-5e0|S#Uo#H=wbjV3)SsHQ^=0lz6F!Ps-0@Jgp&#osQH}Fu)w>xzcq#&EM zuc$Mnc9d!>5wFH2LSm?RncwOHuG&EQS%PKDQo`w-d;_LnAJceDnS3(^Q<55JGWI2A z^{uX?Qm{*cP+k^(uQHgqYP1F+MEea+AX+i@80cvHvh9?ET4T-_(=1_7jE; zvA%XLSbO7#Y*~%JZNGHV*tRu{{((X-q*h@#M$9d0hp?J`iTe>YLrON$iUrt zQH1EN>3G2*Q^x{%{u=}l!2A7CAIPXG8+!k)0vi-~GnLnS8$6z6+%fCi9{ca0W(FWa>YaAJ|3~R#D9H@-V;z!3eG?9DK zlzlGcdm;_t)I{XTXS@|}A9st#YBzEt;6rUly)M+dNK&I42kxWsm<7+5_Z{xzTC?{> z&D%@d4~VtiExhHf`Wb_dS42-n@^%1LMS@9DtX&wI0=n{xdi{)L6~;|)v)0CGuK(Pq zA=t2DYG}eGuw6(%R)$1Cbb$xEOvnI(#Jyio{;uqEwvzkWS`6J6!p+Z0z{IVyCT{Jl zyKCfErFkCQe0`l=AB>%?of5#>v~&>p$Lfn#`ZFXVfK|oy^oFucDfcbU!;3sRCzf#! z?#iDivAmJ*L6V24SKyP(D7PTbk+e3?eKHgX5i7R;pq^kuA!9vc1GIe_HdDhenB;!p zgDubp_(jRrEE(Y?vR~71*<&Y zYCnaLjmI-F%_ZjYN}s(Bhq{r`=Fxhyy{?Qw+p}&cW&z?0kI1yIi$jkKNBREn9 z4b>iZZ4#FYYRa^kxZe?q37@Vg)cn?&1qGjqfN2t>E~<57i&+0wtCzicqjJ%a!-~Lv zcR|8L#ooqS?>r6e2 zoK(Y9sSROj-sizL&y)DZI3pveYF876u@({&ugUQ4S5=Fz}A34SGa+4!XVI~xW??`Prh41cvav@_<#PlZ4$4EIp@ht(u^kD9)-rT;`fYWWtS z0>3j`e|2X6iJlble%#8u(})KQpkd1G*mf%wZr`rPt=^4vM9k3iq+vR~Tz>IlLJ0XR@Nf6kVfO2n8E7g?DjoQ(`-(YV_Bv_^ z{zJ6%7EuaD9B!n-wqPAu>$sgDV7xNuR)`QMg5q4r2MPU zj`U&Gf4F1Apr$E2jcdGz7P)#KUV3(zhhY7QHh$R+lctRu@GgI+6Uupptvd`>Ks!;&tpeVH4>O#4I{@acG;ST(jdh@+;$Ldf>AOEE1Hn#uG%6_ zNN4NxQpYz3Mg@DpiNm~_{QWcz__+|QdK6;|z#O7(Irj(3u0YbR#3K)}B=sC^-yg?Q6L%kCdx4OPL z`ac-6t!Y!8dF#rN^Et{tECM7}xs>e#PnjIUdEb5bd;rf+g`%2rOib%qv+}Tb+lGc{ z<&zvT>m)Iqw6}B4={U?{^^*opn!QNgH0`#~?zhFVa(yeor=RSZv1!{yQqXS^e*S)< zslSVNfwTV2TwEdAgMpj2R9usQpMFDGJ{5WgmHD(ivhuB;s)C;bcl4uI^6+{{s=`gw zmXi`F5_YEI?ndmFyIGgzlV~eudb>u0TJI)aWbbJG-VVMijr3b;3uyQR6+?^lz?fD9 z8I;Nry~70!jsZM)olf{)na8h7fD4hl%*;L{d=<&Hmt7MKdv9&OQT;>>PlYcdmzXK^ zbV1Q)poBhHE04*ncLEvvHK?4cY(H{aaluQZ*~B3MFmHr)OG#R@$HX|7i}5^E*@(xf_UBiD`J8AO^l`T^oM0 za1iw*@c)*0jr3cGkJCWT6(vtnap><}I!jtE0{^^_ZpNVmrj2LJ&P$E!-xpsPgU~)CMDL%nh1@P^Puu(i_>D~SOYWw zc-a21xdgAGD4+VKu=lJjCxF{4=vkk9B=t9g)R9K(a-FJc9pJ3VB+r&I#7qgqhu-!{ zckzjq5~zBh;ah;qqzC8VCvOcF#y5s0tG%etyMDcU+CR8i%cmV$!HTzbbG+Ea2^si0 zs|^fzGzk9V(fzYX$zfwD(-Nbd{6q~T8dVAZ-if^e_YOR3JB0-CitJP|8yaytYr8eR z!)o|){e?6a6Oq#Y&OM(<`3Ej&{fuo!@dE|qw&`x`K$P?@BZE=?W~z01u>HS-^9FTr zx)fTGmB#PWNwK^OE9Y+#>iE+wIcaPZ`QJHBJKl2)gbC7ETt9@>NVz(CKLKCCI>Ng3 zMnBWf(G#_8iTyQ`JkQh3#H+T`AxMhC3uAnriCmrq+Ymvnue~0}d4vBU^>5OhMNR42i%iftbm)B8s}8coa7#x5;kxKzPQynftGg< zuw9Rvh4*jU;?efDRQ@X}I;U`-h#sJ&ezX&VBaXmpl;YJa8;QVYC!}xL*LM`x1s0nT zh}xIPSlQg|xewVrc24Dgkc22FUNC8bMBobPf@(6wAwsQQqHfUR!uY6&OAZ-TR)Ey- zqv(%&o*AI)jI?r`WX!s&GKaBxtD+(4!SW#^Syf2Nlu*eH>PT(vu`Ic zgt9}I0nm|6+5p*aQkGxf4E!8fT)j!iQ1&tfr5;Ib^M9y+UHIr8ELry};26Fd|68{2 zywbE`jOlfuk}FqIs4RLxHLo>x&_xEY^*3?4ZsfnNhVFb$PoveQroizJ5@> zK)N=TBYuZUZF`@E51~O6a002r00na=EpnzFVyzDuv7~iJDwy65^xTc-!RjuuWNVtf zjE2z-T>k8~V&2t(&qAbDJg8k-a6u*i%x-3SlJZ$U_tw2>s>!*Kxz@rU+S%sdhFMhZ zS&#pRiOVx4dh_3!)8ap8Z_M#U?wjq*Cj}L!G>YsmRQr-WXjUmNQmJA5;o~m{Cf8r< zRZ5*c+&uJ~MVP^-$1{BNI7dgauKMCFLa76rj&tuht-VnE_g%w zgDD&Okr;9I(Cf0wzs(gXSPQ=coF5y~e#`XS#CqW-9<);b>ilQXDdwa?WPjw~u{8&s z=h%qTHL=5xq1V^ypIvyBKphZ2+AC{RW5O~_oGQ5gO02_SmlL;hXqLP&wwQDPkRwsBfm3-NDFyU?E0lo~8hLyw5}W1yRV* zi|n95_+@fiLLtI5=II}K$e2`hVke8=IA%X@PDcor1fJ-FNmt=dU0hfHYw|rE;;a-c zLmloaX)f;@M;*+}-zYIB?)LFn__aQ+ts4gYy!3B*f+=&loj*#NbM(U#qf5kP^IN29vi#mMKiMBMtJ5@}Yy3keRjae{uZEbDX(D-NV zWb=29lX4hu^$nruFz_cllhS#KdD>#F$$O^*$^?>;70rlW@J9x~^ z(e6vvqje6E|LW4>I+eb@Q9EOkd0%Y;l@ht|p?&Ds^gAnHZtHD`vX3Su>+E*(UzV6-0L!E@v3bI`l#`#=o5jI;n+MD13sxMh;{i^b7)8K4 zGA6!p?Ls}4&&zJ6;WVXw@n`iA#DzfIS7$Z<-R()BNg*Fqrvn&@M|NBzsZ5(b_cOfS zbO#x;Xakp*mv!Q33c><>@pC$|FY%bLf8<2hEd7EpmXw_5r6$D*qF#zYOB9$n-5f`3 z5nB`vRhx8NzqsHAy_zmh;&G*xR%(MUO%N;j(CX%qXt968`f(#ur~{hBj&fnP&b#$j8#oX>MDz18>*kr#7)OdKrkT=ypE43H(6CPaS&P=p;LFHA67X!#F=h@cErL2WWIhkqO$ z2yok9c}Y*!@A5nUfxg7FGwoyZ!gNxGGNNiPf8^=I;#3h}2V>ACG(Q<56RubCeSCz= zO!w%#{#ytjHh2+eF)=YSUO#I)PjEV!0ZSilf$s~Xo$nUWP@|#03&>DM+^?y)Xiw|i zieuW|BItv!B9JeoZZ;V?BR+TaJ-(0Cdm@Wk%H{0PKmnoMKO6WQUILJr`Ll+EOZxdq zyMUhCE@Jc#{GAuJT28FOBcfXU?|=CD-}9gNl=I#x;29b@twRX)r4y=hOXb`>r*nw& z_yMR$Rsw+~=4o^&6kFh;@T{@fCWrf}1$<{%QI~J;+W&4-`i>Zt{;BbqI3nzJHN2l~ z-?{<*3eti-1JkT|d{PjERn>lhXX=aayKPzGh9Yhs&?T-1(0%vo#2g(7k7vAOCRxQe zu-Nxyd{P zjaGkuZNH%nd|3T<^7eVku2_9IOY7YMp@bWPAbwQ6M}f35g%i@$Bqjkns#Tey0E{Uh zmlsC6kRH6h8lW)rf=IxX6S z`g1Ind9lCPQSZP3OrbNr4Oyrz%Kh^#&ex8oOjbcobNZZD9gpJ1CY?LWVm`=@yG!Y~ zQd6Yp&xYr!0tCuMlb3mE4x4?8H&rLMi4kSDtL#_L>ya@_v*0YFth>dI`{asOLsm#1_o)@NNN%pS5Nhot54>1l!1SfJ88)dU|_8L7mL%xHiEfj!rbn#LN>V{zzP_{9hwQnN zzx}8n`Xt~}oy@$R)$ku`ajT_2O3c${LAKVi$1V%5@wE3s+Q5p>X?7vi#nLvQRRjpi z`HO1nHU7am^jPu;FdKQ8d5t$-=S(Fr0H zcfd6_(p-k;^@|86C`|MAAP zA0VWoi%Ix0f1$7OdYZ5vLtBwjq9Jz`09$|t|I&K_ne(HvLddX*2!c5Bh&y#@fc*Gy zc2pAExK-Ru4hV)V_k!7wb z+s``aP<@m5sCSj`6TkoTgWkybRS@nzmVN$I%|+0ZCuaVEq7pksygh59zk0pd&@5+H z7?+3d#=6JX+}v<}ENH~5lgF6~{qv0&UgqIwHdg_>d{>G&PDnBdCpoBw6T<0kHNM05 zf*BBK=t){+m|(|H_hZ0}!{F;%6Op=9mALP?V#m94(c^!<= zwYIMR#(1%QUwB4{dNw#$g+c~Dq$5Q`a32TK!?OqqS_z#ld@1nk&4gs`tywlpiipTW z*Er@^^Mq^4@K%xa;g`0Bu3u@is@Hn{ip2`2FBjb{n;`|qvfGKD$grwLYwyDw0=7P! zO6%@$b~)ZX7m0qq)pxgo46Yh@U{oYkQvHGof zSgun7<-wG9Kbqrz%md%SY*stTxdYS$jkqy!e%)j9uSs&-r4~=FJAq18=1;YO^^ZjL zrhCP0|5fp{9KPGwaz|!j)(S%g`~ak)Z~6|LDy6N0>H;xE0(Q%J2!)LH%DrCb9Gan8 zz6|Wqt?K7ME-U{#yjIJ}u@a@%b3h!|gY9Xr5aQac478j=)k@&DTj}T@+#L-r%ia1N z4?ZXNV{Ekp7Uuqv64z&9t$}diS&;}+X^Fwh7x#IX{LjWCFqKTnUw2xV|LB5M)!D$P zt`IT1#tx6{T^z)mY>+%Tr|A%TsE-T3*?o!MKuZ^8YW2vl74cc zd;#UypH?gQ3xVFC8AXuFmo8HW2hr~Tj>*M3>|Y*j=hsL@(0}P)89XKzxmN3foGd^g zo=7h%UMF=mC$NZ}PQo{AEGN?-Y2KvJ$xi$;m@%NDmG?AYH(_1U1*skJYu4Gc&(5ku zbe^nq#-iaMPl+fLS74k}FlG*DA2zG0#{DIz-xd9y$Key7sqMZX4_ z2k)1*7#D65o};zTKXU!{Jo-1k=j8sm@L2V&1TY>Dr@fS{)T%=b` zTVj?CB3GGFf{^^Lfr>5PNQE)A*~4T;b$z|wqdFg-c9fSoCCJ=|FnW`^&k0k7*JT5kD8Y8QeyeySPasr~dKCRDMWy*4pS$2@RMb!Q0=V)vGddg$EpFfk{q%53@-7+vJ)` z#OjZlk;%9|QOKWYf1-7xH;(Nt5R04KmtgLOo2cqPjgcLQ$&97TwiI<1SpxFgvxkV& z{tA)Z-}S$@{X`dhncTaN^luCNB<4o-j(t1rQ4}Royop_Gr*5VXrny+K`+@o-?%ntt zYp)c!4MP&E1@)TeT9N9Nn6cRR(cPC_Io@$_xw1cghx=r}2kl$Fh}iQRte~P30^_24 zF_^#S&l0pk$72D=1Z?ughvT)kzQVtlZ4qI!T25eQZ`Vmx^5d|$`+OReQpdDc-Q{mh zDXL>@|2E@f%qDmB3cc(_`gm7VG0c?!OBb$CxKl4NX#?XDmjsojZ9^vo?o1T%=nXh$JcJts3Y>q4{I)MDAr& zGSN(kM}I3PaN#&_z<$^GmICPMFl~9HP60H0oV?ww|7+CGt#?->P;$MHmEaKW1> zZRs$;%G}q7my&>#syhR?8pwPa&+9}lD2XH~&!2U$--{9MkCK|uY~W-4hIp&8faqKN zq?ei>v5gt8Yc*jSrm*NIP|Cf{oTo1oxPYxycwnq6r6iUUK?|e zr=dv1pOZ>7P`(iV^H1*hGimGBWJl^_uqv;_h~PmK9x&|_s7EmTPFDSX%udHO*LeNo za8CTGZQAWX9SUpFTu#$?cGNDE(dye(GSH!e!(CQKc`H(F zpF;RjN}Xc!ns_zgzJ<%ca1r24{0&5)5m$B4QWxBIO47XOoN7gq?ftn%P$>`kxMg1% znZT-4IAh;Q_rLgY{8VqA*K|Yvxp-jxg3Htb{-5z+C_BqPz94z7=l~*`UH_s3FSIcD zYw~A!-&8&WvPuWDN}wa7^WC{)CD7ieLvfWsF1wdy<(|MX^}dz!wLv5R#fhf9$d8XS zTV3kjK5RJOV%a768)VJiy=1qLgPhE04>f9VejjHjq3wTXwV_hR4E*4PeBmoA1eV+Z z)bBsc=bi-Er;$|0QV)1cD}k~lJ+P4H9vwQK#8^ewHjc|V^0~Y1zfY=*jqynOJl@O6 zuvyAD7{#EG6o)iCPT!a&VyuYS-$4~YcFbd#xS_{$*g5pCQJ9N`eKYJ)FvH1lJW^HD zM)fc2Hv0sB8?qSw>0)Qy;L6vxhHBjcjdgn;$H60G`5H@C_ilMS7z-ZEs3)5c9%Xc? z)PS&BLAF|tc`R?y_v3HO!63J*HMbdN?V%O=Rn5wh8T27hmc6=D|IHE4hDPr#eZG8m z*rmjAcVHJ{VxGMljs)n?472W3K?c-|u&ThDg<|s`&G8?Cv-*&2H;B{bP?-?hSe1P8 zA60o7*R+dbmge7CEK=EkXi{o+v_N~jVd&7OUZ;wiFpB~P-m238Qp&Z}i=erc=FJe6 zAG>Dok!wtrhG*BHe_+ohTDD3_cUsdR4V9RS;y8)TBrhQme4x?$kVoTbR#!QBSY;j^ z(bp&b5BsJ3v~kh;zj{ggD2&jQh@=f{<=%xM$Rk36*qh*4i;hUtelry8P3~pGP_K2z z1*V3td|niQ-TET{&GZ#Hc9KopoQMtAVnAzvRnt=_Q{u&*lV9{mT}p zdcU;I#uottb>0H2KEptK<$rB^8X!XivY&xfeWBpD|B;cNazfOKjOCt)^~YfMoaR7~ zt6FE@GIrW|ks9HP7*hqW+e$_EGX`L^HDYhg!lW$?k+nMOh9w!#=g&Z8c#>Q2hTWgt z^>CjRWTXP1Kq?G{o+E?qhbwQCW_xsmF%={wZYF3P9f{n0Y~rrjwxYB^gfCgzuB-t1 z9UIb>Csiggf0SjUK#xt2+>4(ad`~-NR;&7utbok2@2NGFO=92aN_ClQmx0eQ7} z5|ADrjWOaE&Mu$h2UBI1R>JTV%Uf$uJueX5;g!rECd`j@!PL|g#LNF1IP)>^bXY7u zMO9T9pjW~rSWtZxR3jND!M9@l=92@Uk|lGDQQ?P_d@@rr^}bO`7lZXTeon7p3-h~? zw`JcAU>(A@HHU}gDI90>nqV?rU0uHK5S*fa1B>_~EF(eZRhC0J3;18YbzXAdeGWg$ z6u^U2uEuQOKwXUcI|2`lPEZLgA1%~F%cMI~Q1{p{)P+S=htKLmGJt{M)+yU?y)F~# z1kd1ddeQr(UO2Ii?h1h|A-ZuN9UddyvIqa~KhjPdqa&hMbpL*4`GkZc8sjSu-dV?b z_+G~Mits9y2fftE*ibDI3UkIIquPIK2{8a}HPxnVL#3=&x;Vvz(~50@ydYes?t_WL zPfkEK5}LG>OrPWNR4C<>BLsIC`%BcDx%kY$rN3Fxx|gKzm5`Tpb@jx_M(WWPP%=rLPKnfZBF35)`SPWX`KfPM{oh zi72%{Xho(|x}elvPT`-6uMkD96%Hvr*_r`gUDgUX%x=x8PI6^q?pd;)(lwE6+ZBWw6y5!QG@XT4 zl;79IXNVyrq@+U{rMnrV1qr1jhZ2wm=^E+oRJub_Dd{dr=}wXEW|;T!`>x+w`~^I7 z&pl_K&)#=dgaRgyVJFsdjYVPFjQv83A<7?^-FnwX0 z%lWP@-THYcJ}P3n8|}?14WcbPkq4i=`rOp^O=iE@K1KTaF4{d9bfihU-!qV$GxiR+S*q+83IWR4oW8GnK<<-nvAr9 ztgGoQ&dzjI^*|2Wx7U!rgbX@Z;P2laC4rpT$Nl36NFMK(ezL&J#j59HZ%s>H-e%ag z{}ql13eDP33r7r{6N{Z~7Za$VDLU?M<$*dD(sYTT+k?}v|FHlp3VOiQQa$Jf_aq`C zgtpX2L0B1oi(no5cPP^?waJCtci%(=#Dn}^b$;USS%^+GXrL8$$IE_5kJSWj65V^X zR%G(Jl*n=WyB{UQ(&or`Zi!TcRE*>G5lY+HHdnKP@5^*)dwSVc$(0j;4|3kbtCz=W z_Nz#3+pEBU9XPFi|NO^IfX-rH(JVX3<`98Tjt3ss-C1||ns2h|g}kO9<|p5yR-C7v z-*vImN76j{Enqqi=Ye)|(VWTj^!C4h$eAS{uv0=QH;&+17o8Ng+AAI}eqOz*IDnbo zSx;g>lZ&8KsDHy8v}4}t0koPoR8_us3g8>j*xi~1RuG3d&>hzKK`u<4rXkK?=$FDq zA72_Z@lOyZe~?+8>2>y7PUE&H;E616G(D5!GY+sf`|}(_6!mp(4(tw5>4YR%lme}Q zEpe_q=Dm9KgX{a7)s+jwo4=te`zv2B^{eRSbxrzOFJ|tsz)XHPEHQ4narTskEW|R} z7|DX@e>k!mzF7`e^BD0NM^U3!Q+wwo$}j-qiEM$=ZNu54PB4iBmC(tyrKt4p9VWj{jS>D&8b<~rV+tiHX|8R;`!sS zWhHg3iPy}c1qmN6LLqCjX(tQdAyL#jvKI5L|JxQuCiWLOnfb*Fal%!{BXi+j?&_jV zsvt>bII>NZw`l0Q!nc(k$Yml>6LXJoCgb>BPJsGrw*#F`|F5;wYF(|Dl4NK8IVKe1 zbG)N2k~ujs@kJaxoZzs0%-$OTQGN9YyxPThv^zeMZHg$PX)<-Fw|;(SbJ6J-Akya` zK2l%)zFH01UXcgicuk1uSe8US4p@nJjxwNs96;CiH?bz^)(B7lNFkzYMu0 zZT?o9IqNCx<&LH?C4^B6pEzdcd8lG7GeG=@fF}ZXHy?n(#xiz^@(!~3XYs>2^g;&UE=`Xe>mka3bvH$o#>o`*XU%4 zwf|KHEPNs9N!Ps`pdCwj)r4X0b3%Ague&C5uNV%8{_(%^A$OuXDpl>{nZ!?%_CF~w zc@)hFIrOM?zi!NyHlcjcK?pkBBRdt+R7rUkWu|tFo>ll7ho1mV06~O^LtqEv-HRHu zhy0e0^brH{aZX67vy<(xT82p zoLaTo_bxU=X6kDIfj){KV&Awwno`Tz>>h8?(VxVN>>SC>WgQ?rVkrTy4m;oSp~A}8&WQhrup%* zZnko*PRH2A)gihl(g%zH(}=j!R{r9EuKpHYn`RZ=8)X=7*(6B=msbUlBc!QRj-|?Z zq)pf1gE6=YCgQGi7S7JF*+9W)(rurumZanujed*r>t8~9GTTe56yqG>V67b`YPKls zvcNZM-<#X8A8ZuEomxVP7}4F{Uau&CPdM(Jx3p*|Dff;fZH`^MCzpQb25?)V$*?sX zRl>?hH{0IzgNe-i_@Q5P#_rQCv!oMAkD=W z;fEgOaqruOW>?)BSjHz>3JiXKdvqFU2CzP3;O0D$F;e-^yn(>4t?#<8vc2DF`D>d{ zgoue_(${VEn^@kY1Txua{gBN(WH|6wV~3U3tKeR2tNBgsU2PoS-pT6?GV3pEwC#`h zM?3SsOxZ2paXUqY9!W)CRy;7NYFRt^|dzp(coe!tCB z$=w*-)MHpp0a$j8a!_qAE5p0_HP<8T`I6e|&{%_toUM{R8aYmtql6ihbr? zGO^j!u31*`%v^m;Rx|lHuE2E!W{pC&UOX=Dn5b+cQp3FtYQ)anPwBT454$`oZ{cnnlQ*J64GgfS=s z=PlficARi$1^9S9{NYsFmjVZJGc|@Frtw8_2!FG?)1g?o;w$~V za$m(=VdjktUq80^B-d<*T$0d63?)9-u4>PqFlSxU|j3W`Oq0lDxm1w&m;ju%w#HMgeH_LvM z)3Jd|x@bTLq9VM=#Y=+>Ezj{rDDJ1h)teNorFIH}zjYEKuV8Ay3Bw7jpzO^CYV@34 zj67wn<5t4T<9L)jiP$Ke%EG$ldXb)o$rm)fdQ-^W$gO`Vch}HncM( zq@}%&YqOeB32&q(k9*IqS#z##Nt%a6@hyDQn&`$L8UGhs9_^E3?3+1*x?-&3M>?90HQf*l?I$I&aPC{fz!(vuyZB zND85JaqoNK)l2h}0bmag{2GX^9x2aS4qE3bkT`>2bqi!{O-)-&JMzBW-Htt~D2_g4 z_wsbB`+D>4fj(q=#=n38&Cv>8$o8xKqXIfBaYkHyAORQ!&GQzs7@Aj~m%gs%_*N$6`M*OL-BLrdW&>c;x+yyn2-aajU*eCk zfB9rCv#mlyaVgs+5BZ3x*)9t|2>;+A40_&k5)h;Ux(NL)l;n{vm zssHSu_1EBAc#9$=E%j!=4ofkEbrZmRnqz%1fxab7tlkYlKRKa&8xs@%G)^S7>@O(7 zdinI(1p0^u$cL(i$G$zZkFIQ|e1we(bv8_|Au*p3xSTZ$oE(MJp5bL+o-oLyc?h8Y zh*L^>Q$&n25kB=b$8P?^aXTB!_D54sc z%DG>Xua?X+3z7ZPF}}Ktl)*H^cVK0jQfOs&2boBf91a?;_hgKNCTmZJ>J}>*vYCw< zdTK6CXdYE7<~fu2n2E9(qK12EHhlgEG8~HIh4jIMVWc)_p$C!jjzgv+EhPMKCug*PC;4oQjO1&-)uf^)O6COTnZazu+E;|LKkN*Srvo!#lKZ8-E+E0?zL%ksW7FY(x^V! zNvz2$Mv$B4vuUoaH>1+W?R*bd1TY3LJwdHpx)JZhf+D=4@OJXv0fg#v^-d}lc#x~K z6dXsof}{_$)AK}9drJVjtw?jY)4IEsbJlB~V(Wl^zq%tQdkdbF-;zLunE%aEQ{NO^ z7yV`xS}D2>Ci+wOR9@8ZTsKADk<08WZWFqCEe*lZ$kXj9%el$>Dy6>}ZW)r zG9n%(*BBM;nTq70QNu2h_*=cw?!WdFSD!M!E#9Yd&2=EY*Kop}g~^ApGvh!QqOh!| zf^fp*3E|i6$wDvdGzc6ztQ^w_)Qv0uM%B=0(}*P_)V*YBG200E$|c-xX3ytne+S$s{U%SaYn zvN<2YeP^?iaL0?G=HOmS`LBpczk-=X-2t3W9aKT3Z-w#W*zwf8S_h8tZ**sg+Dhg0 z127%6z3E|}oX+8YN9DZ2q3_}sf0Q(NTVMCg+va54cPk{At{-hMvS9CC%&yJ&JFO#( zjg0!F{90c>x_k3$iB~m-ve1Y|zI1t_$W-EpU^c>856_Wrgm5?RplCJa>;!0U_q@u9 z6XsIFpv5`-a_vvG>5tLw$&wkxqJXiq?KWz~ikhRiuqPhTRF-d!mO=m(mHpzKV<0lt zh1eDN>*U$S+5^0P$5FXBCot_7?`_*idP^fh_!HO9N)B>xiTi)Yf!ayHSssWmg0i`cu(dAAgrLVZZY&F9F*ZSVi z8wdDiPmT!Sq&kqqDt1OB{VJ(HOAHb13|X0b2jroel&U+!sh@2M^JfKWfHrs+$<@T_ za79JNfe#a^*@uTa4e^6HW1@terDe>$GC2emuRq>YN%+16OfuEk;hNPe-YpzD)Dm-6XP>~z>-C6*o{;YtI z6a}b{ZclCV<`>94Wo9kXz96&^HD<6p9#+o$@8+}tmsL-q#HY=;Ik?6U^%#ZKo8mmrq1`v0D{_b8Tb^!UdE4?G ziNGKdnC~?fb}q}j#2q7C;Y4})uj^Q~e;pwss_m*C#^(uOQNj*85vryP zkjCH4>ea#X8Vyjd6eU)iY0|UCAyYO=wzSk9!^?qk?~JUhKJV4X{F|)fM?Ck|>3y!} z%Jpk@6{Nf~%N`tws!uG5sP}XKf&`0f03eI#qk;x#h-w->f)IJZE={=+_jl^wVts8` z5W_4^ZmL5SMxR61b^Z9nY{t<+0+qXEVxz_ELphdD^NPQ_gg_qL7UNxtnu5M=yVIaV zh>-6N<>^(!gZer`A$~$oi70h&rt+p~t~#W7T`IKRkJjv4HXry%_nDEJi-dL^arp=*GQC-dGuX4x}5_$yL=Y2iC$~ zGqI?AQ~>UvgrMqlQ%{Y*JN zwA>kVil&OQ8#k+zk{79(`W=NKHH4q%bAyp7PCkBd#=4W7YF4WO`qFlCnepwnpK=Gc zQzdPvLcw>x5=Jo7IG;hf{y)xJdg?2RN{|R4`pGZ8F_^u5Wtr8%-D8+ZoDtP`Loj`4 z^8-&xw`tzq?Kvx`?IjdgHtwgf0bZ)gRQn1un_WTYBrGYpSI`mNVzcoXr<+O2SNp2N2AbDx%vvN=9&ROOU)Q8NvyF-8CSU{aCB)=tU3E!ahPcvkAK!aW2FQQ1V= zTh>IX^r-i=J!s!Nk?*Cf+GTykeDQRiaqAhoA#Q%LNFKc!ao$0Um5uxVyjo?hv_9b{ zrY#@KWySIu`23C4c?D@iMQY+Nwt2T>(xa=2wFwm_%d-=XZ>*zFUx&4D(So>hBkd?pSUhN0PQ62RD1)*H30Ig za2oh5S~>w%!4F7!hvU;Rt1$_~H;g3vqqjwAV=UW#y7_*-xy;Xs9A5lR`MrUmLe`G3 z--ECU@%mB8SOQq`KY%f5n$7l4m>q@{13s`n5tdmy|gc9 z#$GdY@a0>%Sat~Vl>%@BS;+;I9x|6>W}X`fcHL2uXw_mUG04#9X#@(akuNVE`=o{s zi7t#+FNKZx{IQS$O_U7~t?+WuWZVyKL2PT}vvn3_n1(Fw7tTW`3%*%!}@2Eu&MV+IQ^VQ~vO`IngBFtHlDe zwo`ga`IAO~_=g}#=EtZ!F2k>`J04Pv8fZozD9xeyQ-ol##N{xQHS?M(q1!t2i4h!^ zDu_8R)KB$!sYUy)gy*)$E&qt)_KczU>G=D!#!wuHyZpPOhuO9(fp3+Sgn=}@UjAlJ z35o-I>7RXV$^@wdlOL|O9KRZwJ3Hoo=7It^4eV%cTB|*zZq>X&2!c)E@LTIsYpqu<*U1JU3DClY3|r)2fa z;JLcFZh~#x+hUSzP0bF*0wYoq|ANstSwXg9!mWp@qR2DxYqy?t1f7v@>6juddrc+5 z(YFi_NWH{Y9PT}QSRQ6Ws1^-e$H)_1r_!LbY<_iuQ;xkxAs(O3O&K*pr<}Lo&3m0l z6jmCUqZY(sG)h`}dS|oWfx?ghsQ3Q6my9f!mB!oVK?maEnX!dmY7r}fr%L8ipg&pfN#mi=MZA*v}Ml_MW_ z5j(RRM3okP-vO3n$zpa#VN@y%zh&Q!3z%R@%6LU zkEHzs_A4!)0e}6^yYqYi(U4!FUCaH>!rf4fg8h2SOMWZ(IxCdOJts!8vyod4Io zlSRve)&Re4FI^v9jA_G_RQ(`mIR+$|Riic|`r6rYX{R?~h*2(~fE}A|WatoNLxm-X zz2=hrXnuQ_PLB<{#mfjBxXh*M$5ZQyrnZ^VL7Ni>ORl z3Y>GY;rF!65l&}YO18Gq)olXi@=b@7m;8;Kvq8wvL=p=lu^;w^H&R@x(n)A?uMM5K zTKp-h&pG>!#WV#;$BGhFMdxP$rbko$O-u%=J=voU$mK{Y@lI``yk4NDJ{9bpat%o~ z`q4jq{u&4;fFU9jH9;?rv+?6WS4~lJkVc!3=xFa|@f>+%(5FaY=4k68A>v88M#*fN zm-l~CCc^6l5EOb4y4c-e?1;PBoz#=5?(5V+5N;&O&E0H!3?MOH5zVrE`XS zx=kUqz@?>~OovI_xha5}Uv{u6#WN~3{o>`Q$F+@rvUccj``l;D-8ac;+Jf`V<2`(|#acefS*)Xe3Y)t|9 zpAz1qwM8Y*L7#=Ot(KikE0`ct$yp21l-D(};^MKq8SU?izfKlUdEsdWlWzNES##C> zSXN)?D$>5;&^T+`JXUYxa;)|(j}w#84x$*l-1@9;=y&aI5hK|4OzKONrJXM>@?lJ^ z`Da7uyTXK{_0!PNwS|i2?FFAI1!|2sUBgSu~pmRP|ZFWK&t_tXS5Oql%cmH=5TkP0ND;f+*qf4P)RQJ-GS$Rde%@njb;@a7FbQ{ooSZA zy97K{+81bT?sn}5U1t;@EFodV0K89j&WPX9)rDf@ce}l(*SEn%7)_=Nf#sdO;VD%5 z=x-Aci!BvEiw<+wrC`B^0Y6xP!D&Am%w~%vi<(L0F?e5clJ9+8&a)ZQ>l=1z*#O$QRNN@y6#cSG`&`RMe-$54cMtyMO5c{q;g)|1fqa4(P=gBA!@yZ}#D~ zTrHFzH5iax#&y%}y;*PD~1h{zis&C26>a71qQqHWJqcbvVPPE#X9bN)x!2=+`IDp(Y?=~CDiZ=%x(Ksrgt>|6Pwn207ov!h8q@J z#`xQtFm2!D5%MCgp?^^x9OpNZ0)~%C;s& z7P?&5mr(tDey>r%-bNYiKtYZ)#A|!^m9t%RSX?vMTwF+v^RmFXLL&j@=R~qIwj9d3 zXOebZopE8%i>=dJ4f$DDFA7YrU1W=e>%)j zLo2$2$A;5&S;cBg5IgzVsZ2_uHrY#Ok12Q7PLqCZ4G{h5r^88*NVZ219j%O>{^c-8 z#V%c5K@;}N&AIyDWfaekJL&YwH|;G~tfn0+yeI3Nc^E{eF#rM5Qkcc}5XJK1_!Gd5 zBt+5_xAV{N)_DIVGqY1c>V^goFngS$s37DP`O5TkW6rNo9FP4K7f^KWR1PYdT;1X= z78&}xEZ>iIA%$u&_uu0KHE*K_i@nkwW|IaFpyB#u#Qp@BX~_wKyUC#sooI zB8*}6qOp{Bu%EsDZ73x+Kg0HT;=dPtl=ouk{8TKU`za7~Aeyya6$j$|saoGT6ek&! z6-YrsXMsbXQ^)_5*esl`JyNR2@%lnDT9pt@*d}mKMo*sVcj~;Byi200x#-uw9?#w= zRJv|n(Pw#_;HXs138u+|AAU# z%4kXM??>fSaE|dk+bH_%la@JG2ip>WG8k5?AE;Ry=sX$k@43BK1tR}xS@5&y(!

XPj%O%DHT=dqDJOogrl-m7MI9n`$1!_Ys@{@EVPTN|P2 zh0Od|1}>%PIHQejR+C9M(DXj;J38On!_M-%BiC^^nF{5BXjH`luJ_((u}BN|Pcp_{ z6v9svIvCG~_E+!-MoT=UovGujf>3qtL@`fVkY@`5{i48!Qjp_k*yr~04Ct6|M9v3* zWfDLxnmJ#`EsNyUn(s)-1MJLo~&#k zpHBctHR^`L>xA)1!ezz~n4CN+zdX2+BXw~HhHHLYOd-LV0+AjZ#J$HO$(gb%J%K z`@Y=lunWnDpR~nfy+(PuLS$-$N2?-0zPfZX`-;PT1L1H^={~8%;?0%oL@mfDkTVkF zIBv}UjQeA-d)6-Fs_wP;ZLOVN7CC;9Yz`xM;(O%?k0MBG^+ib7HM@1wA>dQ_!Q3p3 zGKJ05zWiMJ%kT3pzN$pjA5_m9N++ra2)1YZR(OT-_FoNyG~Y_)AP-OZhaJyHd5!!Z z*`vba|Mc>{dZ{Lb;1?7U0w=XsNQW!nD9PLQ=|kdT3DCLaIpIVss{byY_6rxhy54-|EDmY_2FFJhDx*b}p%aU?KQY28nLuqMAU=AD>=j)uSb8l*5s)`$jAF+A>d z>a1NnL5g>OACuhQvo+@ttff&gFh?32Ey^ZnuXqR~X`m#qZ(1;xV1*!cEG`5dwpwu9 zH7l860`GF`5ZO?L+V@f>Wmy6a9;2U}{VBUqDY*h`0mgHAK*+^r@j zKo$8Q;^p2jyVy@DqHnjpgJ&&%d~4%}?}-`X&v2l|nWHj6G+T9O+C44FcgC`0r?}iu z8~MuIP;X}a5wqc(s3!yP4W;B0vz;ao@UxUW>vZ2-n&+!*plmRfODRmg&We6Q5KIw< zqF%%HqL`36@k@6k#o83spJ=x0`0QECpJg$oOR-{ZZp}U{_wxT>tw zFTpVox4D86I3CZbXQE+r?(rTG3w6#=YKc2wuC63w;%41QZeZ7_LoKk-ges_Hl=K z%aJir5ZN61j45zI-u)UHb@|xr$j38Zw&G9pTv=W>+q>8GHna`teVXauLHPUkZ)i+_ zuj-3UV|zp@k=&6dGB}Fp@z@XJ-3#q<^T8B?DM|&1_HD2q==dFW1;@DlroB4J+sKn$JWu6ns@BRFLde0ycH$-vrV{3amB-#P7qZEBQ2k9ASh11{rTRb#Vfr>DZ z{-YL1Azd{y+ie~d%^)OKr9BXf&@P4T7%%^w_6QTA$$Ekrg0!KB#^i++~0kt-s+3uvE=iEt82wYWR|JoJj#P#WJJ-gs~ zQjr=WJ`p^*c3sJ_2%2p&O9cHQLlLQ$p@%B{ zqa=Y2f^A*M;p54i3b7okP)6N!V?B;kunMY1P_RiI&f2_XcJJY0!)$b9p$%me*3ul$qj@4No*x;?RwO1DFI~v)7a2EWYOtaQRj;&x`t?*X zF8Lf%s9kAKUpu0hqrq2-1`RdSXLua)G*PdVko+vl)dth1R?N$y;cWsME6)_u&6)B_ zT3|=b?RRtEP6}*!K(7lEZ%i!T8&ygTw^kruIp#gHQiN$zJRUWD<;A9pS!x%q9|q$9 zq}}PEga6`mJKr9d`4#c?$&F00lZ%PcZsY|w9Sr_X?G@c8^~;bc4=Bny(x-wk=v5U9 z(U!zOTz{EE?Q+N}F#X4r@q>TLcQjnX)hUPEu;4rpCt}iUJ85g--^X80aVrDa<45v0 z`6Wn1TJsgK!xT}pLoXsdm`hgz|L)f-fuKCL&?tOWG!L>n4wn^2khGFv?EK6yd9&y_He8r@1KmBU#%24%&xQ!Q&)dVX86K>6fHeRjtwAcJwsI*pMfxdpP_yY-M zSqqXXY+{gi9+)?~T;0cL?@zDuRHe{iEJmZ2L3zbRZpEPB_U3B`Px*>2iwo z`R)X%&L{o4sErEUAoCjVBzG~MOAtzOg}ZFUHK29OA>&_l!BcY6PR%ifyT9#w zGGD-DDpKmAixu=-fn~=v!e0s)w^jwJGD8U@=It;?j zAWY1Rh>C<%4@Q9>jjV&96PX`9EmC#{bZLryEKqQl_oD#Oy50Hs+5Pt`r`kYOvHkJ+ z<5FkzE^y%-AWjNJX* zwjuU)V9Ck2$vX(@n78RFp#59jA;^FidM_tarYQFOSPBSmb+7z6oGt7}C3V~8o??4S z9H$e~9tE1)o$zR1F9+yd*@ zcXZI;Ke@0TxEnszxRnyPf%LHoL<>=+8`A0jnt%ktwgHWddY)R%wspXXGOJt|{4_ay zV5w!~lNNeO^puuLm3p8w#rY6VS#t#Hv}+6?#v zxw$?2#{~z+`jZKMl1{+oB@uKxd3$5MY}j|IBq{RShau_Kn1Ydk6`KO7*z1|A+KTKEpg((ak@clI?hyz%euzRa?8 zU1YMc$9aN?9Ukigef|0s=p-w;kfb3JX}k}}8Vq2^m;39n3J$tUUrxOEFn<4wx61x9 z-h=M1C$`?lZX{D9A?PKh9vU3W(-dVpP!`=zSzx3;AEH7dKqDbXDD5*3K}raZ zKICLlnM>`m0joJuGg zuRwmvgV#1Z=*poDoK&ozahO}9fWkJ&qzprlv|@fZkS65|%kN`F7WMPrR30p4Ml~~A zal6NJ?%sSOEJ^rF)>pFV>e?rp)-Dm7YUDLo=i)x~lI-S@Uo|_UcVj^wB;3f5vx3v) zmKDqtl7|s?oe8FY>)&$Xe+16)-yZ^!CEm=ctNu8$WXb&Gd>rKc*xTgX7V(N^fT}G9 z4w{-u(}Fe&%(S{V+ez`AumFNBduD!r#?cZD7A$OZTRtuUCr*;#6`CVL`SkM!`w0%2 zX$cx`#9$)GAgGf=@vpkP^z5)b^XFi;$cY*;o$^i=+2~a>$UE$D*`Iokg--Y=@&|<{P|xqcIVj- z7K)7c-f8A7<4$EJ_G-l6RASvHvBrVZq;O@rRy!C%n@SV#kr#!pMP$7CIc$>&xk(pU zxlRmMMxmP}jsFp>Qt)213rKui4!UPRUfnxBcDiuh8h;7j@^@o{l7r(kEO3W4_jylG z{PR>kQ*pIF@XF^0bkcl)*u2LNGrcIXtZ8cs<{z=LER%d+)xNFn`@x3OLM4X76yU(EbM^?@oQX{OO?*_4^<0mewTrSt8)y z``u(P6W}3aBad}-c6N4RDN5{Lgy|(d6_IsFLA{AT;1Zm}2+W-Jl4rZnd=PIf4&R%1 zwQ?>)8N5wB423ul)RtR}N8Bur2Mu>yvqyog_t@e35(cmPI0de5@89%4c@BX+oZ)p7 zK3^15et6N3@zwjFPEN`uc*E206BupuQ{Lhf= zZ_~+|j@~zL`&t}xsk+3%R8K7rB$&Gv0PnWG^AO0}M3Pmmxb{okeRc<)h}+y6OyuUa zt$5!nY?-{CO(eJ3l-b9P)BD}@bxlkA&lBW?RS>C>$I3L@{2$@t1ofLL>=~N zc=J-t2RMI!rCOWaM&*``6{+SN8n=O*g9j|oHse49LI;^KpLXC8Xmmfb$?Sh*XXQF% zXLsOw@k2pkKbXNj-)d|$Kv~xYvxw+nP|%}o9ZtvZ^ou(%y`h1=*R?=GS961S|BO`- z|HxCd5fF3NWJ%}`14wmCOO%eWZ(W(}N!rN6SPN2+JcmC7b%Wn0{QI}h4m{+`1a!)W zGruk;LReHY{>|r-SDn|yv!R_p>%>S|K9p9IZ9O2RCOXn@`sT_nLTg)mvXLo=I5_8G z?`5{#{7{g{+#_!kZ**E!#R9 zCq1qFSTr4~^jTcF#%ZUlc@Mmmo!Meosr%a}wcqmpjsMqLSxKL9ANH`PX+ z8IhT3ZggGE%ELY|f?)|MqhEgLm09!XU6MuM1FbTUsq=4z#hD@Ov~=ltK01B&g}7mo z2YON{Ay0@@GL2FIhb__3{E>4t6d5I}PnlhJJ+yRKAskCX9BvIL1E1k7xjw>@g82G5}`qPq79$ z4w_H$PW;jxL{fBgGj=1R!9e0dL~t-V2=X3}okb3%!-G4Jf0+CABnY099j@@X!sS=% z@kQ414*RCv7Irn=m}Tuca;b6l?xpD3W${%rbLQ#lpa~HVS1Cj%(napw*~1pRh<|he zPwoq9hc#|-SI}op951P)Y`9<1KIj8KDOQ)s7ZOKw7&Aa&phx3WPm`rO|tU}D4E95il^Le>fvjycJ_B- z>u8BcC-@pXoDSTgH2H!s7F=k<;ps6wGs)rJ9$3oeb0Xo;Jv9aDSEEwM0il`;_&K-l6;UjElI=jvk36_dUixq&gB@pDkOwAwnXYttS!E zM_|0^oGS^u#3#trtb>93RiIosPW-9$o+7cc{cQ(2Bm`~Mf7>{YLB_IF>p z5_UvBiz^6VCwk2&%!vhJogWBaSCdHT<0_U%O&Tj^lY$fBvH%KZ!H*v4W}4`{J%y*; zt5TzTAGd=8JDann=Gl4G2K!}(hwt9@D=(`o%u_I>MKJUPz9);vJXxr-X>>cJ*e|O= z#)tL3$aONGFx03&vV4*G5|1H=`>5hHd$9m+%Ldhx#|p{^#n4K{lmh>ehwftq%_HoD zLadPCXOxp7aKO%lmj1B3Q=rqc2%Qe0e0TJjAfucK^@o~P6zQW5<+}o3-VehwQ=a-n zmpAsYRjOAifD!;7(&dgMKYBb}7&G$JhZH!&g()I!(q1^Hc9*ZOM4H{& zrF_g?cMD$RkH%B2Vi6{JWJN;33Zq#)ncD&jl#8W%Rho}SK74FBU^0@P0WS_l;>W5w znNA!GRq$DWP9?I^y|PJ#C6kJIKKHp`Jm*wKexI}={f7d=O;i!^?$kJQUp@bLD@ThJ znIkF|6xS<$Yj~9$PKMAkef5PQ2Nw%w&Ip~xAKPSWZ^qCu!Sug3EbAA+S|dVp+@Vkc zoh`%bQBOTOxb&nV)O8Fx71KS|KJ}b$`zoOf(3Oj{u@4bm{DjG2; zACG5{Uq4c2-rg>2k|>}zF)yv`HnZui0yqAK{Sk7>7`_972!lD^YCdZ;nJgNY1X>SO=4r29PWq zb0wMRov^w?s&hIQSWIwP1ZV9E7(lIVYa1<_KmCx(L1ET_UZ6^?A$dX85#A;qx=2_Z z0b*5xPZ5IBUzW>(Geljnfz3ZHqN92Fp3k5)a$idc3iAIpM#EX&(i&59oqGLlE&{gIVrH4f6qRwoCqq7^u#1#KO#^lM~< zM2aZt-e&fG@emX}@&wu!z=-m#aW#AI&*W{uQpio}F!=3H^WU5ptj;3AK<nTv`lO#ZT>{CsdKDf=kT7Z z(&ku4@}WlYyRYb~J8u>sj)9Zt_KU`fwzDbZ)n3@U8KJ7I5hYzXb63Brl%7*vWXa?R zMtw=B&iyRqBD21C0X+_9wuZ;Q*L7Rw*z4tnup97wzA19bbPq%TRjUR^W7O!Z-KqCY z2b^Fm^M$HeR3xZ+9R`66va-!0NiS36oxmq~WIJOkp^K5_a^9~zC&%jckrtT-aQt=a z9P_TM5F|!t)NE~w`o830i7N1kp2b6S4Mjv^)u4?Sjx9BcSRmyb6gb-sx<9TY&+F1$ zyu8&Cjnx3OHKwFb<^N*=cIu^3=JsdfK{ErSjPU(@I-w<8<~f(g*Rrgv_&aq2v*KZpZo{opX`mK;tN7?A@#$O|a`2T(t$6>!pJ!fy z@6$>`FWLLFwOeSF64oXQm9-?!C~X$O3!77*OHA4YmQyr#0(C|k&J6yUzYXTl^+vWc zA+75H8V1!2;m?2(CDx}p0!6nSK`~h&07M4(3DU$c9rKfW^CpBmo~N!vCE}>38Se{d}aZQkF68te;vPaDreKr$b1x#Ji=Ps@lIGY1q~ApdV`v0@j9vG|7f}jx2U?WduN7jX{5VDR2mr&1W^eo zkya3pmhM3*X=$WE0qJfSLK+05k?tP4nfdPfd!CPf0G@j|XRp2X+G~|tVOxABlJr1O z_ObBdKjIx_ z{@NBBNhv0}6W(`?`QEjyU0I6*{e%7edMS$+cdhJ3;YtAIQZcP@4l9=c!X2aB=>e4Y zdz-e>`-Omgv@+w23t#)eXS|?SyR-ceV2G0i(%p#SyBWZS+*Wda22}gX+5l1yM>t^5 zK#iv{q#nw=JHw%BSR#%fggUMZQYDJuQCTepCtnmi7#9ZKI{OL;5@j{FoqR~5dDt(* zfF9iFcap~j+%IlG4@(=1QdZV-xtbGzCt4BSLa3Tp5e*y1hfLV?w$SWp^K^!%g#VS+ z^0eFNt(r?)P$U<7fkQSkJ>AydPk_D+K{9|_ACfqDFQX2u^}pRuRWJrhEBfZe_a1kZ zr59#fQv^+jdS}>@!gkTd={p(cRL%}=uOux_it`COn57EyNdOO}Z^Py#Hd+1kd~Ty2 zxE4R`BrK4nat?8i?mp3%wjyg!o0y>As#pmrXDD;iH_!GLF$eCZH#=ODlamlgZ%#i$ z(Yt;_Vc_er6-W{&ht=^z7)Gd$a#Z(30+nej76De```lO1~n8Ege+|r4!?yJnp*PIH zmG!g<#ypVTK(Aj0VC!ffFaG&oG_!=16cl(js3H2I2Iu)Z_|8>tfU|Bx&mx2(QNPcw zvYc3g&!=ixrLCssv8{tqSICpgpVxPi4L8`7SCm4@7A<2WF(2Z+8@a3x?)kqm*zMAq zH9JG;V_I6i4w_mq22O@~o7l9}=8CXPjVgf$Q{U^t_xsg!YJ}F*Gfdi(t?r)#>0a@g zP4tYNX+d@JQueAYPbvOPPdwXdpoY3sodpuHiqI2_&@*gZo1CHi0qgJYyuImx7@FAM zcd0S}A3F1C^iSS4L&{m(Y+6ffs3O*58mOir*VPxS*2AFTU9lehh#c}Z-O1AU84P{N zMXkt6H>T=LFn}vw4^d0_(CD$)@laLNqt5~d)7#F1@boieZWPp|PaZ~4+Wp%?56F6O z@T{P;8M*;L61}7lj{W#}@PK`-007#X&;IhJDf!f0M0%m~)Ps5EkhYTNQJGFyG)=hIA9P0gGgjp9l4pfSzmV1mkukR1gBM#!W?&{;F7pl+IDt7#o{wVmQQM$AGWeu?W{1^VeiZOpbaT-wL zCrgS$4Ia}>9Qj+Uq>18Z6=c{*rLR29yesyb%uOkbTbX>SSKidh6jbbif6JD#kFn{(c>&6oMU%f=z6Q{pyv)(eT&MVLbG>M+OAa zq%-2Nd}cvRS1i+3tOIHb!P^ z1o>ypD62Rc#6bS+=gI4`+${0xnuFaVm+dKQ+SDXmu#`sNzE<61ASti)!&Xq_0T?W6 zX@DVE)&d3SYD3=tCKb2M+s8faLj<3?mZr)8tWBCcCY$3qX!!HlGSg4c_~yIbc147n zF_!sqZ_Xb}W$P)M*T@sMP=415($dJCCS$!~CAqAvxU*G$^q>1RWz!dDTa?~DxMYSN zI{;!p)md1`{vqoW;K07Dp>#Iow#@b!5n>p7)c6?)i6UrxKD%E$lsLDDpr{Rje|z;{ z&R2fw?l7r^#`^om3;*29f2Ej8k*!Kyd(8*wZA3yVXb1I3)#TijwNPBRc1F6lqa#At z2Yu2wKUz$Ao3p@IE3W%M)5(M3y?YQut-@`mBGK<%Hj8-0#@ECqr|=y=TeZ(8E*SBa zs&z)!@q5|M)EkMe(q2R?>(9xxA+p4Hru=J`xX|Q!zk4aUkeTv801p7J%tN=2GFC1T zKz_MXn+kHs;WBmf0wRJ^T+Kv{uXu;9Y!+6Sk zhy6?VJh+eqAspW%yChv&y2Prpx0UDM4GeWuIR<<-9%iRQvzw0Akl-gv*ta#E&=lLD3kI1J>^ z%R~w1W(RG%?H*_=lU43W(AG>rE*JTk{rw%<3gxHNe}InX|6RQJjlW{CP{r>UeYhV*1}d z7-0T-iGx47M%Ak*dGM2e8f2M;663H#+a6R$G_Eh)0gWgdl)m_I1M@B^xxq9GrTtib zw=cD`m7wU_Kh5y=b}n%??0c=nx)%{({hC(*3jD~AKW0G`nM<<(I+ZD+>9^`ld-P@t zY75+hHE-1c?guP(tDk|6TNvLu5^0k`)8>A6=Fmfm-e>0FR$>{Ps$nptWSt;QpyDa$ z=pzpg07_XqH0Xs9K|J-Co3M(-cu1Cx!K~bRK1n9=!k6`JH*b&TZ^vE+?RtHuGLnee z5-ZVxa#sr~CkJA-FeizJJDvaK9qsM!%k!Q-tCe>RtVqXgn8L$3>avp9b-W%M+W8vz|;n5jE5 z;+oPYHOlg{-%Ps@B3f$C1#tnHRfbY;c0lB-%b}l%+C;263v_w*GWZM{Z66KpoMSPX zffEV_K?nhY2se}QPS1a-8SO*L%-uUXe6bv(rSBVdAz3ZZh$4N8n%AO_5s=*ms!k0j zC+c@hbPfnnG=@+E`r1EFK>NXDsjcaS6+&ubUld*WyB0eB_R)?ZNxI*rW=4(cm#S-L z>N_Pw@wpYGPK&ZT{Uaqxf0_8doh4o-vuS}rW7u; zI$Ny&o6g-S>b)H;ozC1+*1B*p zD#oHx-Ey8*2)Ztv{jkc~eN*Sk%#5xSR{EYdJw1&DkG@=;$52(-uA-4VbU&KYXyUHq z{=yLoqxoaJ8QetYR&NO+HDgyQcJ-Vd(QezE;R7%Q!i)6Xr&7@1O164kJY|m~%4@_X z!a$c>d&Y#WJS*Tc(h8T%WzN!Z2Nusw&8u1Rfm>(DE6DV?%!ZT7Ubcj{$Fq z=UfPHiEl|;ek81QwY6+l5QgQrqssd&GU|cs+~_a~>)|(ts}HwJq_>+qVNn0eU+M`L zVHBY}wFz!|p7=pnJnNx}-)?FkkU12gH>BVuBXJgiISGWc>CG9;hpZOu7z;(acnZMO z4znTlvTA;S8wu`oVkOT(0queSi5JKSE3lZUKkfjcwfF?Jv*j$|AZ^}A$ zrOXryTnn^2C<~FhSSH=67{@D9%vxD_%yt2vo@?*4f7Ehs3tS-f-mVI8(RRrd6=6Q-;f?Wy@jRcIG` zL_x%AS3euAU+VP8TFuq=&+;;>@eiP__+wJ(JLi%R{luz7X#ez;2b>8D4@?)=NAIge zF1^E-7xNh5VR-OfCgH|Ef6je;^xYc4S7OykC9=C>G6a|%Oc+Y87GNok&aA)m?r+uX z_T_J`bi00V^(cUun8pzTl|v_)W2Q3id>{&nF|XN}&mKrN8$5Y;Hn@0RvKSVPjzqQZ zsFL2`DqpT~`y(6GZO>4{kwr^QpMb2+V?#24#cs(Ew}B))8dn}r->#7QcxFG%(T9W+ zM{$dtTf36+fTopSU7s5bhoN|`-7;N$7T0%4qKRqmU30&m^V$07$&f{XbC@#hgVVV@ z;w8hXmWj)vs46z53@)?y4UB6dephJ?I1Qp|8ymwC5~!NbW-JeXm-M(?tu0x=sWoic z;!-B0YR^ND8^2XWS^_%fcOq||{V9zbvNn>^8*E%jeSm-y7Vb8EWp;5n`VZ+zI}yh6 zEgQ~%-!0{ClSvKZ+CigEwS22eu3b*_=($|?^HYnmT0G9{2q+;1~j0_9ksO3@;5B*d4QSj6N9u; zQ<ej4{lOq3MCYXdVOZIn!4 zyBL2$75ZuX%wdb|#UsyjDobG*rRFEXfac#{n+O>64FXaAub~Z*iZzG>DMbE=ipQ=r zV_xlS5>XXDWL!MIcRPf-Dix(W*x^I3BQG~C_S`7xvod&Y&~sRnK7?3!5ZDtu(}}4m zl=#FULm6M0qVqEtn2lU5cxn6ucz$U;faXy#GdO|412{Z^xlPxd7rYM!J{6bz02ds4 zj{y(#)ut0_LAGQhsVuet4#<%LMyY$KgT!B+Y$rt<&-$EWgJD)>YOzEk2dZP&*HV8U zb!A>Hd7rg}Gzqh0zG6&?>;FkY`*X7JS}hLpNmX{n@|2;zje16W>2%d|C2>(jiw1ru zFX{JZ)9?$;yCJt~JXfHNKj1!fLDA_A_$XR|k7C{rF@CLoi+JqHDV9&1dF1A?cnf!u zAXk@IW9;k4cs^Y>tys@NwaW<~qMtEh2yNnVfa#v!JLTxDvNqH3hLd%_d7zrT0koY6 zH)o|R9KC#yLwnTkMTJ4dbTu<-v{B%M{{8b-(h#Hw@KsD|`og#B>rplPJ2!^E@4zNW z=&=z?_6q~lssE<(E1;Mj%7XY5UQTHQRcY$mmB>!5t`I!dW_72$2<3umhkZ8SYDT{y zYa>)De~SAfJ~^Gi)WZY9CY0f8yV~L%v_)E&qDCC$nyo{k!3WyMS2#h7oAj zLJxWT=o~1icz6u$xw+wf|C@i8Ou_U!VZ`zA9c^@v^ExCn@b1sJo%NidCh03q?-2@M z<2jB82+Y8@iPU$-`}D^6Wlu8kdC}D1nTC!HOXZ@xYkIHShV0Md((PeUAAH&O3$qVU z5-=W-{?@t=b2ZPOI5)Z3(ZZEUvB0xZ;`qQ_Oi{F>>8#9JcfFa+#rUO4vwSdv2OZz; zjX(^X4n6xYhxr9O>rY$rcadQtC)5^-UO(HNsy&*t%zOq`vf0_c)P4yPc_V{4<&~JR zmsQk)qY8%a*w-)Fvjs3wMQOl?D!L4RwC8-OToJ8R?8@ZXD+bb@i4g??X}Ts(JPC_f z3Y^}DaShq)HKk#RN^&D|-0+5q$UhRrZbYsJU`JK0xDu%Bb(MzwyS6`$3QDG&@I-)- ztWC#iez*YE} zOx?{7`dqnZCbW)o#gAe%5~*g0a_|0KFED#tNUORlucJ*=Chw31$#bG}m{hUFPg@%^ z1?!7a(DFiepShkF!rv)~qbxbKLcNRXYa5~jgiQ?~#qx!ujw#YbgH!kvy8fn=o@~h~ z21gfj3}?yke$QhpW_O0=U>~PV^x`Q0_q3KPa!sqR!TmvG_kkr3d_rj8F}RJD*deE` zf&hC~FQ6VDpj!ve#Hs)UtDxBC1(;?ls2Rw7i$-I$qzl3^U*Xf%1sAxv+dhJ&OIC-oa+m+a7v}1-zsw>}$uXcZ5q)l;oyItM{=N z_?^2M)Ue+8$r{5TbaQ(1WC0mz>+=p~x^TlBV_+16IPr4@ef+i<8f`T8 zsS;&S#r!(>mHdp5{CG_xX#2D7^~1<+C3}NnzGX28WfGP19P?3T#h#eg zXMzAMcWQU}4&^63Ii>5mIfl--AHnWGuFfP*m-Tj&2-pa~N8Gi%b?<2w75pCCM+-iuX3a-u>e=A0-6D=xT{?wY}Loe!F`?5Z*sTQDpb<#Px zJOKV@?Alkgp~fLtjItUoUI7uR|aDl4@5 z8BhD6V2S~=MkVG@hRLl6J%ix^-X$ikZX+BM$G#yp=`rxPL1}rENzI~thf=@$rGIr z;x>KUyt1(n2%g*B;rp@%dlOsPyeJ_q@G5b#OqS$XyeK1ea1QAC-LjjFTG+?C|0{gU z{TUB{{8~w0ghP&{g+n<*v?{xb#2JjdMU%ZEQ`S1~|O-~;`3 zj|W7Xtr{?TpG{*|zLgN4s&~6+oG)&Klv8;)2kZ|(u^GBw+z@qPs#1a{TE1*Od2gZl z-quU3^wI^*!038v`nS2m(C*HeoXFt7`J-^8AYsk*7XMwMI6}7?TWg9$spt$x!!lE4Rlb)%0LQCC3OO|UWpwLC(Tf59?<~*B&Gkume?n5f z2GwdGPNbzlu}rCGZ^|A|?ObGys~$K~F_iYlE_OCvltk54gvn_=yFNSyB;ZZg(Z`dH zTTGpsyr>Hq$a2ImGs@3D^o(DRWrdb4Y=qnMf9gC+4twJ}9nmNPSQd&g!HM2qFQlOT z*^oNxzKnVU4m2Vln6zaxmdm)dO2NjS`q;Gf-)@lC-#5dG>t>r( zuAW4jHZ^C?7INAmXvr0A9 zfuFY&WLdp=wDaCfacH6Vb$^SWA(?l5$Y?o?4h9li?Q)~OLR%$JmEdnyT<)c2*o7Hq zLGW8j+%C4*2jCtIjIq%0>USnQE&iDA$tu~kAhb!TilpzhTU-hG%U5<*yn1O$hUFOV zuK~|ISL$y2OlOfkY95?QYNV7_3J)z9e4#x`DBO%Vnx^F{kkRUw>R=$`8FVc?BzS;yxmQ7tDzW3Fa>v#k$?THPm1wp!f({qp`>3n?^su_rtQA)tu``M}D*f2reht8x1` zK4C&yp3g)q*cvY6ZQ7=hb+|~Ti!UV2&7IFBC9AJV} zsXLo6Q(Z?jT$|#@hWGm}pB`bPrKP3NCOO9d89c2Nr~CH#Nh{D?*gBrq~86~CCZ12aC-=)ycN{Siv^#I`A8kvwoOao1wh-;A%(u} z32_?_v^@qWytT1dgg`iAEGg3Ft{C#Z_?8G2mz1q+%ALnuh6!Wf7FX`^m^bMH?>h$j zophYD^UeD}sxXoEr^#Y+tmDr1%Ke}XnNV;1U32U|g=NAGGSqwS^BD+iT}c>E;FW~W z3yk3>xPBQAfua6B>p=;Gt>ar9uBpF2vk;wRz87xL5mtdSCZ9$oB`6~4zN4y=iKiR6 z!?4U$H`6-ylG?@W?0v9X0wc52S}&|HVqpU8q6K&MWAAUbW`CX8{$|^BQ{r=krCXFFFU(J4m5lc&7`2XBW%8Ueb2qKm*{aO35{_|W09Aoh* zE8qQSq1w9$`Kah+IG_S-aow$cA{wdPWX3G67=vv1=!$mTV%-Y1<%6cQ}V(T+cX!lZs@OA{p?q;xS2R%BtmTzl@?(dT?doj&k9I z6QxKF{#gu4wCef2gufsg1+S|EaaMF_NK8H;?sQoYg=HHJJ412&5}dtIlEKGXi@s%l z43?9V%ErexW#;QquKO}s?VD4rFGt??Rz$GP$wq~|S8UM*>D);we@`zzF6F){Qzvh%MaWk^PNFreA%8%nd)c93}mk0l9t zk$ye92M)Wok`tT-XHw!Cu&ac&p1>`fxQN=m!`z2{`To{C-A9%RkmL=09_PJF`VQWZ z&tuI|8g}!Tf2Zv^C_jrAZ$>WO1>!o$5FcQ)HS_MSvjW;|T_R@svJWu6C?9F?7oEF- z7<(;YMSTUs?_PfF0ggdoRP5Gizq(ZLtn~cvW6FZ63APhnudGYEyEL`Gl=Y6NIdf&m zh+x2e@^YU7XjGLXg-$;Rz2+K-#!RXBS7kA8t+`A|?-a0SD)_AB;02l+DgXYI*D?ku zJGml&WxhMm_%)5_R>-Q23ua!7PF!Eap%hrpydAP+XFwiuCr3t|Jv2o65hKqD<-+S) z&W3)j`*SK$D$z!A^Bm{AtNG@HoP1xC{}PUX((JV2WEJ2-`qfl2u%|^~HdnuM;1|0?{3rfAfMQWVM2AU$o1Ukqx|6Iq zSPF_;!+SD7wQ$WrynAk}tF2OPp?6s3YlHKIcI6Q0^m2x4a5xzA17;C|J{I#@^=Dh` z*LN8V^VmPey#q<{W-YE&YCrmihY%53|V4_zh)aMkzr*m==gvNS8 z7*AtSXb`zpl4KB@!T9UvwzFgd%c+*`tC)f5mtW%5^C{+70T6B%rj{;M*rX=EwA_U>sV8;D&axDER*SHBz2a=3(9*qNKzgTo=1zw;lcf-3#T13 z``nXFy7e~b=z{JH^`2dukW3tEO~YLU<=(;FqD&@v3x$B;W1rx<;dDF=(F=&9XvWfH zWD%LuTP`Sv86ezx$(A=}eHC3dV6c}Q$idQloh8t)+Y#&_G72v0SBRLOFW%x>;Wq|Kl;d#@ENKm z?fz0ptaEKCiV2hS~mu= zpZBtwo$Nx_$)d(GIz?y2hF12(utq;{`@~tHUxuJIf6Lj924*G|?x)Ns_;vO;g_8$u z`J4byiK`bNTNl&ZY5Pq$^lETD5ZkKj%@NmbH6n2V2v9_nh5*+a6i&v&)C%buW>jGi1Y^NZY)iQDICU||Xu(iSh1M>wi;?*M*CC*jL(}fxMl0cLeSae>KG&ieq0GAAH!bPxjIZ zFZO~)k!8o5Pvnu;SN7rO^>|+=np{VTqLD73SRX?U|CY2>_6e6Ck3CCuPjnvh!n1#| zZQ$r%K7a?YOCeVP8CUP=nHdORjxF+Mz(%w2bKDWuP^~cH{f5k#`@eAnbjR5sT-K(2 z3H5K!w*nX`-#Uu|CoY;p8OUU%O&{!5F2~6|Prw{veUt*Cj`z1ED0@GIXA7iW5kcuu z&_Ti>LVxabiFyJ_vHULAd>)?B;ecK>>7a;SRHRgTv;8wB=r>xPd2D+ygRlg6W5W14 z=+r}u<_C*U1{a5OJb9B`p-;>(7SG}C)t3?&)SFqs>64S*Dq)#lo*ZTN64XAx36M_Pq1(; zPpaoJ&zlPSs~zGosnH89rB(A7e_UKl}?_nUK5oGsIdG0yJ z-AiIyc1O*R^=uP~c5uW}F)&0YKXC4CIbrzwD;L@HazW|#Ipd$9(Mq*6ty`o^Pp=k8 z0BI_dGS$4A+kvD^JmKW%A4=v}AcR4PM6wcAdr1gQ1+EfxGWjM%;I)4Uv!1;8I@1Rs z!OWxNQO*iW;ft3+`CM3)HNnI+lJd)W%S8 zVaZSAzc0K0cD>MEvDCRglwaJ#)zGsm$>7i1ZSjl%GlYzGcOQjiB5qr(iAM%wto08) zf0Dw3mMP{$Wr!|v)F}biR5WF2J;~&Q>r=0_2b4TnrTWKa^ZT8mK@H{|Kv?q#W}H`} z8%AkM+Xliq@SXEsJku?3cWm~j7tOo}3}E-{i4MT>ec&6Cj1Av;c3Zg-!tOT|d*f!4 zNz6D)5u}5U&vny}{ZoE{7*C{P(mQXm886M|%$=@GD0l0}%?vr74=ci+!EW?*BvebI zjgelE=3bZp|FBib!9{7EOgK+iMPn@vD}1iqlrvz|vg0jgXS1Z{#vc)QlE#OlmW~A< zb%L*ex2JL6RF}Y9GxptTzm!@q#bZ9%TCd;6a)G5%wXJ< zu74*tzav5xI#PcJP7`DoisJnr=A%6Rr5>sKoo!b5x)N$~#N^@URnZ+B?7f#teS2f- zsBVscJRD9VS2%`{F?~4l2~J9N9~3^Jib>RlaR}_D+pI?oix*>zy_q|b=*syX;fPn1 zC166LvhfADedbrsgfQH9r|Qq9XXg;11B!?q4#ClMY4?~-&nu-8{^YYyx?h1I8J?>$ znf*|jZ>Z4Zz2iK|p-1-Pn$osym;8Q}n(KLbe8tA8@{EflO0=)f z{Bt@1K$Zixu3`6n@_Ve!;vDA`Fvsvy)|c8RT6C16Cf?7EqFBYH{8iFK#yUDG3xG*Y zuq-9)1U6P_p#N#aeg2RMHC1Vv=U=EKBZE`jHkJc9OL6BT1P};S7{lrpX^GoG?!w*m z-o=Xy_vI=7Bg=B9b%GofkWqNar8PG*)9Iqycvp9Ed{SDd`fS-f!R2h`6@it#DZgwZ zvhjiqAQ`#NAlEu!usl5odUyO~YA=l1!AOD>z+T*K!_mD8=^9W^z>7KkwvNp-vjBE= z02?1M6;;da@c?aPM1Bswpk~hUyRX30^;j7iV%SK&EENt`Or<1|DJbm%PovClg*v18 zELkX%VP66Mkp(t;EW9VWd*?d!?XHzDZ*Yeu;x8(I`-5+}Dbp3P3b!-=xqasCS(Fg$ zzga}~Pr>_@(~^2@pOCdytn_c&vSUi$sndx)4>lL8?fuwk_kDbRL?&}YX{;S$o&h1N zZ}h}=@VV1c8KWeXyLAluz;9u~c&BH78zxzA@2Y!?$sw>9y0vEh8n(P0C=qxM+NOz& zmUchbaqFo%{*~*3UDWbBLLHx?6dOU_v$U*>k1qiU2jyGs4Ru<*@tLn~{r~sK4QUts zXt<$czfDiA$*=iq(Tg3)syGoXB4hm=j=&~(V+QG_Z!1whf%dX>f}LR0lbh!cb@6Uz zNHN}*Wqt?w<&}*DtXQ!e-BzOQ>FKf&!R)}XHZq_>H5R2R89JCYeVg1%qj*H~UGAUi zR~>4vMJzp})9H!q-s=LK`i#z0u=q^e*qvySyeT^)SThf9uweT7h&t5EhD<^GYuJlM z=S>pur+9Xq|5KwP0!`+#q^N(MFe=aKD-?Fs0gPJ%C@nKU!Ss_xI!;@_`_i1U3sPo0 zLa*+Rbab_82fVi|q8`MimLHJv!+3@^RbWEAFr$QH_J92YB>KvMNGYj@!mKKpLk!ccjJO|>m{+u7?bYQBpDb8Jxy3OL-TRf zeeU0%4i5p-jemF=VG!~2Ig$qvaGgyasMcazKR` znemU*t_K0N^^C;s5+-@W*<5?V4|BcPF91c4zY)NxT~-T$G>{3mgx3q7PWVZIn}q(&nWix4&Fav zGN`x?(~gEsp;D0ZLTI$Ag`4W*;Y15Y5ea1Xg`(r^Z_% zz*0k|bqH_aJTK)P__B|d8$G}%#2;Xs7~Ze;Q{k}^t?&;W`S09Leg2K8$sX&*q$)q? zZadUHjz(4|lH%&apQ?w=x`J#Eq^rxWxq0{sNEaNZg?ZtCOHCDY0%E3Fk zY;Mz%ujny+=!L~A1F7e>vA-qgNSqw}nRA`+vG}nIhfYIw zMF`|{7@%P-x*YXdkSq_G{H>cxLV6sL#is(g(IbD`*MfJm9VJKwMjq3$z}saZ>x)b; zh|5Y&hzj~1yG%1DaznI5XS4cYF&1VQ4js{FXJgqiZ?;a^3~aH6^789JEXUV8|XJz zaqwK-jp2AuYJx1iXY`c-!qtO$?)t3w5fQY2R(Y2$Ihsc+R~ci?WrgoZ9+I$|M#lM+ zN;8m0EvB^iy+p=m%Tw3MPfb3*@PV)5LF?G2I?KgphM#gdZ=n%X|M8$7pR+zO-S4uS zO)Dwia$vk|bPv+qHXQS=BE-@VK_JHNRBkxT<<%W`pq%z#;4RUSCVH_N9S2E#8 z@~l`-u8kIhk!MEC5J2%8oI!buRIR+qKeW%IP~KLJr)*5xcOYBDR+6m^OOt6@19Lt~2>y%Sv(>nOyeviyx1 zkmq~lX=g|5#IOpwl~aH8Rf|5z?iEEFxl{ROH;3GpF_Gzj) zfA>Bd^$y2F{B|iX>pAY8dJv|zzQRr(m&>CZR|nR zlM7xVlusT*F|fkZ9euZ?eDrGZ&=nDX?J=FZ3OT=s7D<0ubo-d);vuCf-;`p;fUwS~ z>w}5|t@Yo&q@Ph(7p;$KvUL;>XHzsn#e?aS-A*0GWM?NQ+$#jpg}xeB?(o}Vb}e1l zfj2jVtm`_vXjg{~o-GRiOW^h4y2qk#0xf^aJmETxGK;f)>_7|mgpT`|0eWS|psdYf z%3$%w0N0(-+L)%~>{uW~dw3sWTG z5R%fgl|_iPB_%YgBF4!^IpRH;ojSLXKWeslKj{wHD+t5aN-m+{&#^>SF} zuOtLvy-7er$PL(9EQ_z^Ur5GXf`Xo%(4P&(@ZuGusflwel5rdbaS?Db#9t&YHdPA% zCi%1eu)`q`1;hp}UOF@;8b{*t6!ot9MnO^yulUsK@+$Mz>~M;9Mr+VY-!WqBXA^{k5#vze9aG8RF* zHhw?k7e6?{W-=9%7_o5hKBwb&9=2a1STbI8Vp3A?Px})i;HoUY(J4}?`i+L~#O}v? zX=}VTH2R5~n;R>ZhKgx?0xa?`Q(jeC6C?0%K9VxgUjhP)64BU{ZL6-jF2$n1kJDD` zK8wS|ap`k1jsj~v?Z-}G>UCaoW@+`pe^4tD06-MDaYIU~4HBiNu2J#)(Sp=?WYF3s zb@YFE?Y$ZRg z8(l{U`{jB8FQX6Sse=Tk8ch?lS{-QteFwI3re8N;q}K(rgReLOC*zi>kcMY>Yefs} z@l_}d0~shv7l}SPblSq(hX$q4Wqi&W1BaUaX=IuN8dY&mRrCRXspW_aEK@Kr=x{lN zS!nmUGrH&rXym3AjggMN^gqFSmZhzX;SE+k0rn2|mJSce0Fgo9YizsX^RUi#4Y^F+ z>ZiJH&yLRD(;EF;tkH-813DjfyyAgmxymj%m5T%cq@PN_ssiO9eWT`1qlM>kVRSY} zF4Fdph}IN;|303Gu~lIjHncii?&_r|21Y)HesXZvj)}7M_|fxeHGB8c!GAsfh;z7w ziX2Ya1z??%kT`j`MCd0b_(Z@w|NVKoj}km(o{H2TVtw`Y4b`=(0v?YeB?Z#K8+%KaWj=j0p>H0C+q@iD>Bw z>;Rfuuoaz1N;#Qj9^MeMhfI0yB!>-B2#IV)F^!I{gPQDm#P5c&I_s_)2V@Ek0wR$b z8IJQdltZ2`RpV6+M7IrbHn^5qQ=#i>!TNx629t1u0mVLnp&C5yLP3|Y5oJN_G8L)l zSSqFKIj9apA-M`WK~%g8xZSW_Z7#sAuOt3n(Yux-O-19P;f5ez2M-uqUQL6gt{FWe~Ci*59+N68zSq6~eA-1)AsWq{Bp>bcD z>Mw3E3|+Qw&#+~jcDc|^CU^SHN83~Ksw`3c?Dp;#q>e5=p9O~de^?}}uxal9B=MI! zo5Q_Cx(Z4DvhjpyXBOLpM}*jDX}KMs=m!RNcEz;WCOkRi)-srncdBN~{TcaNaj!eQ z{)i1rrCY3TzjzL|IXEc|ZjO$oXYv-^pHdXNX>)e08iak+&;B{DYS{!5!T<{M#ZCidg2m_xwIW|Q5aNl^6@IPyFo6cw#y}A z`>0jOdw||JT0*V7q5+>(@#``5-zZGd_)xeyR`00H(a&4goAB@A{1BFVQsFt}v>O_k zK+MWcHVNLibpfj3n~wq@HE{S(0e(^d?@pgu@>!Gc(gO1>^G6K;A>NFxxn%a+w>&E3wukUI zQ?4lmq~F09^!kzKZ?%j+#tz?_NaIE#g9h?_(M+dM7XPP{K5vK7vR1zK5v=Q$SJllv zqGz`eLol*qgw6f9e}Ay|pZY(A<3MO`ua@8e#}1m5^%btznw8K{yr;2vj{g28^pEB) zvJAOd5N)5^?lH<~DRu&%sGh9`LXy1>I{+~;v60=g^4i8Q@#X{GJEF06KS|sgGvM)Z z$r_&K?svUs3QiI~P3liJ`!Dhq#k_Iv827v%SIe$Go*n)4-$C3cQfe zaO-K9(l5us(N?s1x_+7ziQC%^1K{6(cx=>^ffRLpZHryQr-ma8*A??A7gC!bK~+J+HPdZS8e@mi_CFCNK7%y8}!h) zzA2G&UA+T}t#jAV_z|hqqV}H&>jBj6@onHG_tDD&*mE!IhnUxfpjcL ze>MY{MmF{&y*@0(r)*Bz{Q1`Oi(7~g%kh|(ko--;bS;CCBC0HE=fBU+IrJs=lPk@f zhEXu8dR^e6__0aDopW0Nn(1n)$UCVI)1NaXcgCTs=cN)$`|saBjlnlPH*vYfE)8*t zJz*G=&pABsl(gAFO-}Sf=MGK)j1I4NcTo11)8qy?_*GV>6>d{0owsFd1dmbo*x!)J zx9K%+ssL}i|9x=G0tB7m7JjdJJA#Xag$*Bz zJ%BCs-QfzdYXONCw6bSGlwFS`txow}_c&VE5kr3-%cZMTR5e8}I|d32^VeZIJW3Nt zOK~iZQncbUa&wU-o^DegQGBFnhD&_t?#dYv%8iu7`#U3wf}WJSUac&d#~rK1-ej#W zoM}d-et&W}`+|^XIh0}5Ksd0MNO7<7DyBgJF3Fe#-tXn$6#4GXx5)GAn&&E{^zrdc ztb1rM?qR2yAK~kROdQjJ;BL5fspLUJU0vO`Jl+L#p5?d}2zEfob17PS-#`4acp=%|1^i}cBGH0- zujUhNC+$XFw)~pe%$dc9*~!1$kmLf#C$m*${sf@<8Qe($1h7qdUh=sM7q+e3Ms&pg z;_Wga>&pByw6MT*etr%BW6)%smyc9m6Fs9SLy5igKB55b3mj*(nMDs&lj5l+p5#W$a61sUq zbHh69yM}KnuQKRKOuaqp*K2QAF7{5e#CQDr}n1dHS|UcrCMmtGQ9p&-hfLt#)l2^5<=t){gMR+uee%U^kxg*O1Uo zjWr4awGI5ngWh>)HeLMU-u&U*ZihYp9Pwxqa*TPqDmkhe7hpNe%SYl_e_z>|q(-OFb;8LOmc zy{3Uhc%qrf<>c1hZl{vk-$N#|pZK z{{D;iaP3w@u6=5`Au)#|{rkv4+?d@!M79XP%bCN|v9t4$3giOrjm!AcYS`A zeM^p(Op(5^z*b=ItjlYJFDvk5?dQdr;kEBm6Gr?GgD$p$(q^;nE}H+f4YU=6KleY- znzk-0A%QrqEW|u=EaNFfdL)@?>q9HvmQCAnJO1YJrk^NfrpM+wBQmtlZ9wCFET^;Kb2bzQh?)1Wj0 zBGO$_(y{51mXdCe?uJb$DM*7fh;(;@bVzp#(%sEI>-*1ho^!z^H*?Q5=6J_=gIbLZ ziALUozqe94H3SDYw>GpS?ZDjj2Z<$X{0>qOiN!I~t{%MhL=z!gYkoZBkxuMDGVQ^2 zdV)D}bg_BkxVJ8-X`9(nfJTw*=YTDG(57m2)Qvt0BjqP?6Ytj07IL^H@lji0xrv|M ztBy;2ICA^;m_M2nvaDomr&vc!TQK#9Uy0|+iTGu;_X;1AYJb!7I>WgumjqjqDF@^63>i!C`oRgZ+7X>nnp%S`PH zyMU3}lpJ7Z82TyrOYO?t)u)ouXC@-pb$iwCcOP18=E^CfO@%I`D#U*z-CeMrp!*yC!hUhz6(z;B;%WDFlVbZ#2fP=p=c&Xz_nM07DX*i_w>WKC6e(c$= z6}~biCQcPCpIIL;-`{0SKDF?{@*bNB{vz5%#5jEbc-d(h3i0HvhR6A|NC#^L1%c~V zV5J^H+sMC${aa{>?e7v^#N;cq6jA_+4v@ZmyLYn4j3@t+Wv#466dn2r9wGjD4&FMD z;i&5A(%RMr>W3?vtAh%%yc1(rl(2-%mqQ?YXV0V*3-^3bG9z_o*8?x(PN3t&>)!ix z?kZUJEpSSKV_x6P&`Pn=NYS#qX7#0}$O{Hl_%|69TZHfWg!++i+E;+*_bZrXruVB2 zzWNP#qDj_{hB(na@;aKfTW!K^K%0|RS_6W>Zh)D+l9G}u0u&(rGsGAkSBpm~5!LY3 zy1`^0ViJNrre=sv^H&JKOu`%$G)|okLFu+B<~`G z{k=-;ANJN8><#9xo*?@GV1w1$yQK24U+iS?jAIq2QMncB^Zem9*S6)mRV3-~RvjM7+iTN-vF)X-(l75=6cqSl{N&J zImtf$1Fn+G-9HdUk>ao{|od*zdA3R!}U$ zEBqv-a&l_x2+JK(?0sFUotiY%>R3KEG}$iHu`C3PzJHd_PCxnyLif=`uqE+Vdn3Kz zel}7wux-8!#j$3A-=dl0V-!EQ_Dk>xyirWta$=sT1HTsVVvGN{c64)5w{&mhx`xtB&6ve30pmD*Hfz$PMfS#TnNO;iGA?rnt4#fc06F#etVjyV-j*Sor zKwzJcw575-3|VJpXf@-S@KD{sYQbuyO8E^jU3qG4gJ2PbDlWC9Sm#+#0}BZE75F`| zBl0Cf`N?oL@jqqR>DuFA%*Nt1A#CzI%bef+`g(#q-6&~GqgvGPZij4FPdr;sib`+d z?!X}9;wAt{2yULgpny*wDUA(lOTE8r8@(7sUKOUujOVcJH0Bw`%`d@GeTf#2R>^>I z`S7H699VU(EB#&e3z7<=dJ8{$jEZPLQo*;{c;J%^!oGK(4Rk^RTR4P9?sPi7!7(30 z^iKixh_v65tOet&2*Wz#mAxMpQue_#GU^YyNR3Ocbsl18Ck#I`C-}GM(FpL!5mfzh z)3-Src-PcU{BIs`?cZ2T;kX7V)U%%$8`Kf4|6F`*A9GMn4BR^KM4xr?=e zT8{l%d9$gX!5J!Pifn0TFLl=xM1vGny*7iDKxdUPRvnoWZ;xyG0=-2Rn9+mJt_*nC~ z7JM?Rd+c%d#uW4!h{XZl==ec`8}}Oy;^w>}174MFy+$PWnD0%Y5p>uc(5x>kj(!IixwWX2NMBQR3b?yCXeq-UI~uFFUQlM5s` zc@D2=dVJ;Gne*G_M)f6m_jYstf0(v${uedT3W}Mp0^dQ{xt;BW)F9Ax z@{A5!_E)7dV3o?CiPn&k9XWwem&_32S6sgzJLU2e} z9t{jxJ==G~Q9fxuD8_YmTo|M@ixqsxu4pY`MY|qd zz24^tm(AYL8g5oV!RBIEsa!nTJ49r6QT@tfKLxYz^MS3Vy>5%4bdi?ZUYlIg7LW2! z%>;1Q=o-^e-TpN#Mks_KqOz?GGkbYC@qlop=cu&ev6dwgDV@KH$Bp=B8b1UoAKqn@ zojT2j7!rn?FRa($Eu~TIKrFdOBypl&>}F?cPkLPPAGAjmco8^)d%2I)&DAK}5X0?7 z1CCV+YVMBp|D})}ZH#u@8*(gr86;PL%a3_%KZ3Pet!EQ2QCu-e+-Ow#`4!O~Poekr zeQM_9?>x5xAOhHq*=$PlMcVMEAT`zi0Zj6j9-kQ(>ISdGy)$5P_sBGoVI~WJ%In|jmtE#Zcr4o|+F;F?= zu$jMhPtGCCQQoer#d{Vba(#1}X!tAw6auSgGX4GYfOfk3LVCa!Y{R%U2!-MtII@j_G z3HAKVIika6=ti%_^I6OTmP+3&v71%HnQ^kYX(;a;jt1AL1)%^`_l0ZzzYst;rWI<4HmE?)lRKbYNA)|@2e!qFVrG>Rz(JO?? zLa^_X3{>VtC&{vq;{*o$btlBGyzN?uMesY~v`$ozJpx(1-}`W_m)VfAg|<&F8lME= zFKDbU{+0Egrgfa+d-kWT0hBPB2nZS}DVZ_6GG@W`t2p6e+-JL-<6u1`ynFbk>5Mfz zPbQd=oC`N^p<139>Vw^|Oxk{J*+Dr3#nrLqd5-Zpsl@kBo3;^Do-~FI$4M_pI`RPl2pt7AX%5F_jzf%k%i))Y)80Y2+3bVk{%olw&LewT7Q!4c9 z6Q^?-;cclU=U1v59sW~TY{_fdHusD#3HMU2VP5-R7WF7_?h?WN*>R$CYv7YGzz!-KP3ak(sSuz%Jd(4PPA1?kNWy zkl@f$6mrwiBwDhI5QSv7YR(?qJn#vzh(+tDk|8qWhlJs$N719{UfcAM-|FpPSPh}& z{oB`eIe3AufLkj*w~d=CuwR(BrS>N0h!j~+S;b?v-R7y_=tm*g%z5suZH)HAQ#GEq zdE3c4&R&QH&I#S|g@obAa9}W21vrL*3+!_i=ESg0)c`Y`E=x7nRk=E=Lh=BIUs3U| z3>bg=)u^aGqkp=U5b}(sY`pXO{L1av;Qf%_w~etY;j}FrCybBb(J~rToh-xSCpT^P z<(6hYm1OYfBq!Aqb}0MTC2r7JS7h^UZP;NVydbgi_4+}UH{NH(5hbj^Tor5-A|c^O zA)s_}tklq8)noW|o<5>u{}Wx#TG0hwv-W>1_Vn$=)5hkmYYXZk{ZiL>M={9gKK{MJ ziOrR1OmHN8j9$Vl&lJdKzuE66mmrV=#qrf%nbMB=&mVZ7E}V+QKm5JMZ@IZEIt{yG`!?9}6J3z4TE+@ZpPvE2fZG6Ft@e$llfHnbD)L^5xq4hF z1UXV_W(;t&kt@n4mbs&p+tHf{uc3M-ym)p$+RthlfA@NIruvVLnxjypCt8SSm0|2j zq`C$FX%4O}_Mf^t1KDs-b4=CAV4PUcdNY9-OW}1vLSP}D{6AVgl!Py?&-YEaHh6Jl zs0@EpVPE(aBkI*_>*~Opb$V%&IlY+)5dTkUYt zgXy`Sa9BHoqS**RPQVit(Kj1Cz9`2nd(aW)d|MINo!K0hw2!a;t{kM+YB|>rTy-#th0fB0-w;p$V|ujUt{BC~GOw3TJP$6}tjL&8bRq+JDkGg8m}Gs0 z7jCHk7}DU8AmA*f{gmVp>ichyeHd`>QKn#c^BztqaxFpLySRvv%OH+NpE6=Gza-k} z$W3M6<38CD`SbCjM+Y(W6R5TvjZtziZ%E5rIr&Jwt$D66>jHx;2m2upl`TUus{-Ga z`jwF^b?d$fnMR4MVvz0atP-VZQo?23#pz zdtq-xt=T!yzU=lVr{-O?EofC+vW)zKB++Xs+WVLUk&G1^hE!ZJ?yqDXfaSQmtM(rQ z2Fz$FY!Y~h#{RB)M`urQ?eN!;t-C#5D@YrrgxOjx_ZeLDn1YNnkk0w$%^P5ZPKno! zWG>%}Ow~8Jul)cZs#g8%!6TNn^pPA(S>1JsJWh6eRT+lBsoT$dZ1Bfk-p04%} z-aQISm|E$!Bkkh>B1Y5bggeS*o}F>`p9q_V{PSzA*c;Ee@u-3di>Gp`3}mZ2T`OZ+ zI^ge|KqAuaxh$IRNrOLi`-xyXI(UDhO+YosgjvwjlSEWs{5i|n&{hW_i!l9Gz~ASf zjy02xlI<3Sg@Prf{P%0Y`tRoLjjPMfA5Y8)&Q&Hw*=k`so4ya<6FcgK>6yQuXw7=( zqe5xeiI z(C}fuAChoaSUu56;sV+_`s;N#;M6RBDSfh=WnjLzXckXKJMH=f?g0*aw0Dx#8j6V` zSUC;fB29&BVb~iSZxcgB%vC|%&+bM+F%nFx+?MzkV>jrCn>fc_P$N%O!1B0d>Elnu zNyLo=o3!GdG<~xJlm}wf*e;gyu zkE`OlA#~-_M!&1A#qdfhcA+Z%kr326h@1z7Ab(Y8Gt^)uRrtx``~mBD{n`PpOibQd zI;^GXeTy3K;B%Vwyj8(g_AD307w*JK`gi>lZF8>{$vPihxX|s%Ba5=|ku@f$Ne^d{ zt;J2~-It4fcBoGyQH7{ThZ3gtiO$7QeU4Lo(l?T|naOV=@@lf^QOrO#1IFPAn6~k+ z$0kRdirSokgGf7gaQP#3d|@JGNgn?T9UNuAT8J=R1RO;FU*f&G^77=C`R~s~{mO}6 zPo*UPaN2DTr`5CcRbW@Y%i1Hot~b4|g1ipgU5)?iFZhZZ?z6z^c>5+5+(UdTLD>rd zEe5%BF#zRNUnEt6|8)Da!b>!OZLawXW0DCJranSzWq_GZBdN-%9u*qGu=jVd?+3}U zuPGKfH6`5%)7hw7va$1K)e0Ws+(9b_2~r^&4Tw8NQy6f3#J&hAQzE$4B-1^&S8t$q zo8TM>6U`d@S!jdbwNv(Ici^h}dP?1@2TdBxF&4A#gl?;5_a!z&bSR*vL51?8AP>95 zZLW@J2e$(-vr zgjq%D4E8A#Jg?zi(i}(;?Dwm7S9$2XGxmIOX?% zuGJw?OU_vsm2%=34@RYaWqJ;48gWVMAA03GQqoO(5ktvl+9$ zDP1$caejub*PR5~zI=PwX|-!Qsbw?u%v%>@XqZo>MYuekn2`FfHpsgEK%N@E_QeM@ z{RBWi&^LINM+ITOisNHY87$04=Hq$E#Ym;Xa?!x@Yqlv(i&Siy{If16tKowY{fDy{ z;NzQ`ACVJQX1#rk$^5wV1LvJOGo+;Y!2`*?#=`(O>aI!}RAa60?#kKZV0LP67Z-e^iWR4EPAER2Bd@0_;Uph9iyXog>4n{1iZ zlP`&6x+r$%>@491U*G-^MrPw38W8BqGf|*9vkh^K`b-2-)fm?LUpS`!q|xw zrzPSDS-%v)#%FB3sDcjhSn%!F(nC9QJI0FoZzv}7%?p#=mfx;mGa-9b!xf73JruN7 zTjdd$1B+hOyPs^t>-Ik(cVz8*nYCP7);2WUv5qSEkKb$(+%+Y5)lUHw)C&T(WE49tR>x+P zxCP8OP6(7#N09G3O(GcMw4Vw7n&~Lm|I4b({QQrC4I6fbWVBtD3r>43z1ujkJL7rX zym$oYOn4oZImf7czx+@gu`6j?!L}SPq1C+JS*%6x-Mzgw&j)WQzzuiTjLCL-(@P~E z7~1M=mH(d1=K{<7ts@L6*mp=shKFNhL!*K0e{P1^L!wS=COEph25pR#>iDcCPm^h_ z2*^X?Zn(i+P_AA%x<9p&9MV%PBVifUJmC*|HyY{0p`T#edmkD0&Pe|oQX|-2$rUND7cf$mbkHo;#oydZ*M0HHuy&q*}q4ZzAyn2C&K=4J90L9B1`TubNG$^vZ&w4K|FN4ZX&-3l>W|lWupl2P< z&1@+usEipi9-e4c(x9UlxoGBeyJ~w}`1s~M-QO|wx_7c@P|d7Chw}ENt^K$40wzNO z%_AVXy9pls0NW%`v)n{W62uU=Nd5MJo)ZX8enhqIv;r;$(H0toI4$hlkmnkBDD!*n z@0;t7ZL|VpuaN-LDr5Q&Q`RBxlXVu**rc3~#v=MmH#G$YhrVe`f=kpn_G5M&3iSB; z15~7X0c8J7#Q=lsoIKQEJ&MXaEno${rh5X{cb(BtCmYf_o@&WA z_Me_<7)k-{L8IHRj2<=<{Ef?XA{_O7iNqx2(tLe$@qtzEf0Qd@_la&LZY$_O=N(hd z_UoLi)IKjKet<5%ip+G70a-Eubd`Z7y06ZZ>&zFo&)eyuS!)Vbl(OL(1!o)Scs8Et z5Iu6ZO{=2vq%*(YPIkKO^ZNd3pLV#W-<&eGL>-7g0Ew$raE3C^D)yjqbL2>>Fh1#o zpWs(P9MeaPrF=QaV%O)q{qGS)EQTv2paRqc#soa#gZZ}){NT=1gHVw|e@(o)KHTgo zLZf4LYi$dilB|;ZUEm!o{N9Jv=7Y<3#Lv7GDT%8k*C}sHI&5wyDX}k`4cG1uF1u!_{pvvDG?{|Cw*u{c|C4-C{b`Zi-*-V{ zx)4t1g=$~5HPTLI5ta1VYIh;QjxA`BKwYHyv&DK zRS#7F#9JmU-oUeYkg?QS{H8$Gr=&S+mhD04!`t>>!%OJiSHBgs=Rbq~lH!hs&>#h| zn=$qES2VuUBWJA_V{;Wd{FY+%K5eSLwZrAyLjjpvpu-0}KSFVcK`p-hElo(yvFf6C za$UuAbYaj5lTtzh^dcp$Z<9mh`7CCW$p0@n-aF**j993{g@AY39LTfGWZ$&AF&gFd z_g@Oh*XgYN=Y>LU;#76>#6uBbyWYj>z-`#X6-{xvruoa!KP~=@KwL6W9P`7)IT_dh zf=L_($z6>BRNZXVb+vZ^g&gP(Jk^~{rpI>mfb1l2W8!_nV3W!RJ z`Wz4e^E~rGkJ%N%uP5U4voOy&8YA+ z!?xtCzkY9}Bp{u!I1ES>F8DjepoOZ;p!K2$(u0#+w?l(NonHW}%4-Bw0v#b#hD5ls z|M|_CLdWGW7y$t@Iimb|kml(v*nK_2tgXBE_io8!8Fy^wFLYZ+KwkJLezxL7Y4(D) z+*b}ZoO({osC#IGxB5nVDta4%-EF4dnQZtM?K-G)->i8^RGY0powVRig{bO98v^m9 zyS-ag{Uo4>mUI|Cw%UTK>zsaL+>yz@vwXAC)-sPQhl3qNg&aiCtx`=E%b<{?z_{RS zqVsXXIkz$HqisK9a(tZptAcbj(!?XaUwY=Ba*M|CG;&R(EheTTbEU-B5gmd$MPxCM zWN~O1@Oo^jI*REW9yu$i&Wj8X-VlC*Qj7aSs!q5*9}4uTAnN*e~T4*CuY zkI(oh?(ktGm<2hh{LAqK;W17#nTPK;@ZvYuAX)b#0@QdsQTnacl4$G}0JCH1TYeD!K@$nzWh`wfE1P+5#&XRNAHja`POH!$w~ zDU%o{F}$e|n7~Gbq8S^Mp{Vo;u~R!JgqG>|;YIR0kllIIR?LQ4S%34{cG**Klym)Z zlqU((8|t`q6wSOF*B0F&*u*Z`?&QktRx)h)#J?3;g$ z$>aRa%Ldr8nW;7zW+N^a-V2R+C*}JqA=P|3ET{JW&YYxPx#1or8#tN1xpFzKht)T`UL#-_Dna zyI+{+3p0IG{uiA>)=TMOE(7bea=Nziyp zwcSA8PN~3E{3xh3E`R2l8{oS5SgV_v>~j^kS5~pby-|w3j>W`|WD_{ln-iV$LykEx zPdC1swNww7cW?AcCrb+-al+dBnE>8?jc^in6jL-8*zifIxN&3oFeyfaZ^6*gOs0A5 zf#096p##z~0F0}^V?sgwpI3Ch0ZIxF%hUqN&}SkSN43ZJkmg4b zvTu%meB6wW7dw=UJ{tpELZNbrQh z=}(~mrpgZkKh!Wgo;7cO-kv|!F4WE};`)L`Lwqs1S1abb4x5h|q=2X=JaCQW!}s|c zYdk(V2TYbD#3;s{uX@*35lyygq|}=^tSi5}PhzI2okSu@ z|FRs<_s|mxGANAwgOo8o>cTCW5RviO&S<)t8xK!UdodH`i+6J{`B_ax1rSuOvEF9| zOO+DbbPw?N4ZKq!6$BTGU0slBmhLe2f8e&uipAk);j3mMQ?1ms67jXk@35^3I53MD7{oTn|E*%Dgy>dL z54tQvcRL!oFSUqz=|NIj7ML##jRyZ;TEqGX)yEWL=}5A&A@qBGMiqf!}GR-l^gHa8j}$G05M(Ar5Fj0ZP3F!hwVB( z|1s+!>>m@wr-@$|E-Rdu&F#&fie8Ud$BxYtwe5`L;CN$w3%mF153&(DvM;BU^EP7X zDy+0LLxSmKE=mvKV=Ynk|L5yHgBnqgBc#FE^DU?9nTT&;PHU;GU7tC~7zFcI_LnmR+bH1M5u| zBCm5QdmOJX?W+(wlRhD+C<*kuK$>EYYW>3~d2!kT6Q#ya-E5DEj{cZZL;(;JD|E(X zwwou$p`AJ?&AO3?XtwjKvOnF+n`pZtb)OGL!Mxsft{EWBV939aPELi|zv{U}deIg$ zX_ai_u8IelwAwb8;&XdLWWFVEPm>xG{_*N?OUTq4Zce_{0m6deWVVe4{{!CPAEfg_ z0lMhV$|oCrH3i7G@I%^G=O^HMFfIdwfex(EDwvb#ku&K z#mdYRJ*#L}{gTi2(Q>4Rk)zpHvnaweZ6cl7&cFvcd~o(oJywIT{$@Q(&e^6tmr9dn zK&C3a5DlKZmf_YUi!^_5C5Z&haj4GotHOs;x+9f#)6wnddF2IN*C3AbddIa71b(_= zP7lst(F2RcOb;RtGn3bnQ!-CNSZMfVodY8;(GvQ~>Ga|j>B25ft4cj@`s#o4pvA@6 z@;p3f&d1S@;fNoL#>Ti+@JWoT_MDiy|Ee4T?4uYGiL|obek;_Q_`!bIYx(`u>s(~5 za|I}&er(fYMxxuctr;vj8*&X_#l{&(){%%w>3^U>2ypUkJiH9zen*Ad72ut?Fu74M zcXFGC-}t2sPjZeqp`aw8Rfw9tw8p*8dbJKm?6}g+cIeqIF$h&}Xhl!sJcJ)w3%TAo z`R>;wzc|G%h(?__n{9T%ch&q}`zd2_BSlbLl~jR&L(YL&_}+_Ei=5 z+X{+YvlF<}jJ1ddQ~gdG@xd8XA7ZJpym9X$R>vTuU@60x;7mdY5klkQCb^XPJ){T7 z@5S!|>@Pzl1Q96Yy1avT{nIEtm-+d%xbEHGZl>>~3ScG=@E|7sE)cAS%EqH*n>R@- z;3Ac5G#S`A?H<9NvqHnz^@`ytlU=U<4EOYH+n*5KOZL^{Z;HzeA|UYThb)2#bWV9n z#i_}QfIB=9P}JFy?g7}g?Yr^$UA&zqzH~YsVH?fj|ALBn>M)A$biatAxX+gw5PSgV z_aM6{hc`rP{joNVGrC8s^O`A{tG^my9!Ra$j&%7vG5go?CC$rq(s&k`(ZDm$DDZT3 z1R=6H(Rj&IW`uZYXya6EVWkxn)MGA}lLX*7KtP5z+QR90V<^TF@xRP`gDd`-!awA{ zv1TpPUZQR9V94>p%S*x3MZAc&WdB&_f4iY^5ufr&-gK#0bkRa0RK`=sZC%4`X`LB&JQX3stZdF;I(OogApy{=W(O+Q=MU5#ohG9om+#kt`o%(tmVt-NDMqj_9Bk824 zJZU*ev9_IQEKl}CyDo{h?tQOBgdUw?5El07S)C0rKetX>zZq}xlFY*6Br-yXT_d!e z=H+Ly_4MFCYGXOo0;Cv4H~2_h66)iy7mXZ7MZn*?EVJJia6$6N1}Lr?CW>vxyPe_si1P7 zo5I?!uH0rizze(aIn#2WPsX1@`FIfI`XQc?j0*MZSqmE;-9LLxMt`)D*~z*stfT!7 zR$0cP96$);SM#UN5{blQ-p5d#q5h9n8U``8t~7Dra4+ZdnX9koK440n;?;XhWj#FH z<~W)vCp>^!3W(w~5NeMDP8DX%G{s08qvyQcuWK^*7v4>r%!Vs3rd77dMeZAnm4pgd zk8w?fIHtyb+OA;UdPaAe8~}gQd%TCV zcM2goHmVq}lyFX#^|ye+-C>&HuDFkwtxmW_{A4j1x)210WToPpCO#3Fl?`Pi*}TZ? z+;4yph&Mn3RuFP5r%qK7o78x#E)#M-hP_oxn{JHR{1IWUc= zXt}$L*nqSv(oLP9MN#-N=&zjjlK+-QeOAm6D=?NxC>CVKNmTirxW?@$Zp{QSQKNph-gdG zY+`ZT2#*C){s`#LqW^vEmnZ%*%q=ccZ;)>d4>p%q*+x%}HUbr5HdkN7gjWWrhw83+ zthhLo!3!=BdBZ{kLb%#Aokr6_RFb~=B~@`oHg%s@H_Rvhpz$*ePwl6sLaY`-Wd^_E zl*K)Uu?tRA!0)8!=^vz^MpNQ^Myp9OY)%yWJ1uyopf%2aA@Cx4shQ77UvV>@mkwlTAc=jSo8`5$ zE>N+s?btDd!3};eox=ZOKebR9=cHJ>8~UJL+xyhW-+Gh-@Ef7~f<{fVhXP=++SfYMB{0?c&RTalFdIYBUXSULNzDo_ zz5=0remo)ygraw==Ukw65g$wYgpI;2WY;D$Sq`%0lx*wZK&_~rF3g$?{4?RVQSJKR zeT3P;yDj?gdLB!l;HKkN&*pVSo?lCZ{pS7Bo>^)>H4t6J_bqByj09od{Iy@1kH(UH z{;!!$(gjbn%okt0e$68|T3VtS-9L&aa=h0Q$M7}~pHmzh``{ak4DO%mG1vJ}fv+@2 zImtsgI>rMZE6;M|mJCYBJ+16S$EDy<`i~}2Mb>fQC}Ms_8OG@altJuhxX~Hh-v zV2#0riO9O$nzlPyDc^pa3fL%gUq(n*f?*$!RA)B5>{Qw(QpWP^eewCo)b2Smv9s~4 z&i4wz#alf>{sD8>cqRIjb;prc2e!HjWkCeGt*DX&<(Fh4$oO^0(uy?ETk$_9iqba$ zd|HB$<4#a>8=DtV9Lp*+5G2^)F3z3VzpOXR+ic8uzwuvXQz4|}WzO1v@!YxpVfH~k z$RB>OW;L)wNvuMs8$HN4idsxYz!8J4SLqZW%8o)k76?-EIkAo zh5Mwpgtt@1(jMQj^|Y`>ACC@>cxQNEoI=sGdr`tfS1^CSyj;Ya7x6#ht=`ZPD$|*b z^EYkm$4JcNDBC@|o2%5%sR~`f%JfNG;6=i9)XAyF=eive%-}gk2DYgw`lW2R&}yfz zP>-2s_UPe}eXvV3h)T;yHGY#y1rheD5t-}RNG^RR?p1inuV0jG9@_mA7DxxO%Gg#FW=1JabaYm*i_7ARom`tWtDy4DpFEyaOa#DI+(E?Lp&6uMpVF@ zUW&Ud{H2zDBCYtuZ8xc2;;VQnN`~!pHi-;*#;d`6~zQTQR5G5lRdi zLN+RUEFv^oDjvwr47gi){rNbK@QSQ$Ej>~acK&vU^fP~~0vK^M&6gwy`L{`VKA~Ef zl_W8e$~C;{o3}IK#mVQOdDHDB?9qE$ox$=Ae07+@-_@e_yx3tN&nJBgHSADYX!mG~ zJ>&h6PH|OzredzRval-og9fBSwHY+g8F)Wi---&Cw~y%7TA^5F=_}Ak=i&a3==_=! z*HV+k&xkm>=CwyX_jS;Lh-v2L%PcqZ$u6Z|$+C`QHUuGY;rA6pr|u#5I~+oXG{2td z1d146NgwL{ELU>eTSwk~rR6Hma@*m1M&*C92KT{yJXyKc=W|)ot!!HDziWHDT-gx( z@J=`o{EN1kyclcBJRO%pP>ISW|cF5YR z`TpUj=5wBWb_@_5WH9Aq`4F9#SJj_&|vsX+_t=CKj$p;nNvoJw_bYj zAdJxguqnYMjP&b=%+lKgBnF`;*XkO&Uczr8){Ws~BKe<)U865H&$MYFq?SEU)0goh ziopEp<376fJ40jQ_kJQAt5u)ul&we7*^8p+oC9wn6 zvrcG~k`9^_x%T&NW$}J(hgUM$%8el{79qf`;}X{4)a0t2SsY*6=Gy9HZ|C}(rdk^R zUSb`$T!x%Jk|)?ayZKpvJ>o@!zZHMJ zc(#N_lwqsU$YBHBA^$eB(Z3gc#2fguaNRTNp&~?$XI%VzAym-TCTweO4>FJ<%YfI2 zov|@8*-G3u%e(wL$cNIYI19%q)O%_$C8b~g^*Z7FvUx&=qwznrOL^Nj?h^tpNtVgR zzH_AyTGcSbEBA?CaDH7m!esCJ{;TMdZa&1%K*>b$SD8*}jn?Y3c-L3DnnAPNS-3LB zSchk;T#eT}cfDR8RDq&3DJ1GmTS%&sW1#<+&&phsvFMAxI z)$-f7i*lx^PTp)4+?d_Uag)<>{{%Vu(SXsW&8IRHc>Ew5IMNvJ42WYtTzRhleIeS3 zS>! z0-`uTaYF*wRIWG4+A1>7yBI9%Ddwf5t9F=+-P6wh(xk@`9v?i52ODk9vo}Xmo<~tU z>6RNhTAM-MOSp&ma3RF8zVG{<9zHKX0|9p8Fn!>|W}x?DK4orVc*i##G(-YECWi*@ zYr6RGA3%-XtXxD?lbe}*jF_TCvG1t;SkS6(aQjSA%`W*JQdmCr=hw)T%58ol$rOL) zlEIO86Y++0z*{;>0^wX0 z@EE7-dfrG|ICzBJMRv;`XXrwXcj$*i>xSNJWe?o4kTYR==qeg~%*D}r^>N2r#X@)S z;_?sgr6(!wUl9vDlvwAHZQNm6HU6=OQAK6%e_m{HK#=K2NnikJAbzlisX`gjlgjzx zy}B6aWdBm+D&YM8aRE@Bc%%-Iz)Lg)f#T~ffpk*`-HYTCNWxCZ()s&|@r7OfIb75d zO7J~C$J?yq>Jq+McRv zu5qRdW3l)qey2gxORiTW2=o%0o!W8$_gS=$j(65h2AMOls|fX&MnQb<5DVSPcd?0P zRov50jpamQ?z1sLyFZgk!*b{$yejTG2)Y`-PYa#aupqG;Q&Al20YYRO8+k;hs2!Ft z_=%_BwLNPme3fT3bFojDD611O3yyJ(9lBBcue}jcY7+|gIqoBRc92F*+0oFgjo#X7 zXd7^+fi1-R;0*ODNo?Yn?jtyQxYy)0c619eG5E)20yN6Ir<=e2@6{v4dI76g3gQ&< z<4Ng2*^_~`H{rvSLHn0Z{{B?;rDFKPsmfM8)0Yv&k+YbDDliLnU$AHEPsI~=ffG-k zf${t8m`$d)5XTSs?<@3s-)|%nC&&-?!$4I60(9Vb_P@~L?d@LzePWoX9WusFG_Z%% z#>_D@PEA}OzO^u|vJnl&zh>weEA{23)2o;oi$tM2T=?JHF!By3yv5-8)Nw{A+BDV` zHnD6*mlJ2tH2m^OX}85>pAzL%NG6krvI7@aty~X*`*j%xoVO2(_9%KkK#g?@Uzu+K zkzV=-`ohZZ{|-*V&=>C^RAMXVDBLnqaob(1jG}wpnIh{r!cWKF zZ^qd*F@f7>dZPqH5(*^o866=}ta;5nOdec;7L$`SUB~tF?E>W3v5H^C3Q`nWhb>t3 z#h0jeOu}4mzLXsl6286KJJ!l5jRwo3TpV5S6#6M9t!W}ULojpzXRL`3QrXgm-bXw; z$6I>tZk1DBOT_v+l>kdW9v3VaAF6ZLMjDVhjVYuQ6uSqxTR-c${Gx;_oG-C`Tud?A z@^pikb-yUq=bCjq#U&6CA7N3(B+RCh!Ka|ri>d=*p5B%Oy*h3{7X#Su%YfWr- zwx2HsdQZp&A-efp(dkHEa%fFNbD~!(OcQeq?0Ib{d{%efdzy+hIl*Ccd z(0>t*7SGg*tNX@gJsq6Khg~E+Wiy-2j3PLic-nCy@p0fSfzwebz|0vPNRdrZNAyiw zutB8#6LDSjwVI`8xGG6oUzPs8;McQL$Ib}3lu;}uR!|oU`PPaSYN@~1!~Ec7H9}vm z0)EkV6X`YVjV|gFr}9ddU)PV(=-;jrbN-GnU9KTMlRqtY-{y(lB4R$Soo1|+bi%#% z?m8~bg)V#PogBF*f!0^g?*u-smQ3DBC;5$bUqEfJW%bs@JsP2|4Zs zOfs4M|I714HvJ$8u%kHsUB(mNrbb*&TVEqo{s*|!TKl{EdFXc?TwZ8~i8dfy^vlIX z11SZycjq#78dHrGZ`la;UcdC(3_}>9HwBwa&&-_UU&NO_0~e&$Kavif6OC0!FoqF? z6}DJABwqWl4Gw4q=r|dgyoUBxMp2-C_Bkevs{jt||TKataFLBgxgJMGx25YcTDqh=rMtHK{_g$Uf8m_xIp>LQP#aE21u|@Odmm4B z8s@G+h%nT50W9JoO!fk`a$W9Ocyit7Rj+3*O@#DX=Fg`KA=@s>95g z^#`#|>bT+LQbD>+dh~4o=dEmk0W(~}b+CNB(u0E7HG1$=CY&ps2%T!Wx5)`0M?Od> z4(dt&&>7CU?;#ms4%AQLPtVVHT8V+!3uyx($l~JfBf~E9%|@x?CYgdsFCIo^mUL9X zJHT*?$s(`yzwxb5eF(mGAxjm2=XE%H__oe~gA!eMK>rg2*!<;6T5+UI6oCJYw&gywWhlTK?NdY2TR zB{YaSd4CmkSKU!1rH+uez$nX0L*O{w9bcVSPiXK^+ft&&N4Wm=;0b0D zg5B7=2q<4i6vw(1)VzCTPknCg1I@Y}EqM1%T1et#CtHplqnpbhB&M4crVItGD3w~C zEC}k&6N#P5mV~%Y_#g_S&N$;xE$<&PJU26Rusn*tzx`}cCYfON)KQ+GnM~8?4M{II z;GOBH38dSe$+>$W`9|Dy;!m-G>J^~a(*J@^<^SE)1ket+$hho+Ibsa6HRZC}S4)me z{##r}g=lu}hD(oeFp~|nUe&ynIx-dCy_gWIpS(@(I&vb()CD@rs>}0%$Ebx`5moB4 z7a#2ge6Jo-D_kbk_e0S2#&lf_XyZF&7cUtk-!N*;4#VOYpAsB7KGnp3#s{(5oYskB zp5qOEAxTQ&G6qdw;Z2f4BZSvw{UvNOSz5T+&HOymxgzGe+ES%r%ej=>sJMtKyX_l& zPVc|kzEYhb8lAjRyfMK8t$E#Cu5`;hXTIWHC^mm=&d~O|T247Uuz`2A4pYdY6Ogmi zm_fHAi#X`s0b(KAkQZCoe&`{gT&UiRU1eO~cy@#`>E9-f)F5to(&7gBTCnBcAIJ6* zCP2k>pT{Yqt=?uGIGCx$>}zwq;*Y)3i4hz`RSC-5POh)NqJ$_>8Qa@fLmQlIvIs2b zOnEUTW1ihBW)>o)|DZ-RjRVsn!sM12RO5@Y-KdOK;>G#&*tPXZ zZxH`-Sq=W{M%+9xY-ew&&2BS9(O7#Cf4r>gkx_ve#a%bM3xuorzM?26p)H)dtj8@} znCg@er{Fwm7KM9$7kP)0L?mwCj1z8e8JmGqP)?iEwDn-y(D3I6uhd^Q z9~=r?q`Q-r1SLbe%sDS4BvZ+I{!OEwlli?z>6|`-N}co{Y979LbZJYHdF*4`^pf*B z7oX|ao4S7}@RphzEMuUyZ}4LU*h`n@<22ZI4~opmYnsc+I_be<(S_JiHO5i5n@@%Vh;|Ukee)G zZ@wZlxNgjLmTtC$)92^W_96jzEHuS2D37+anU|e#X8cMZq|xaWOQhgY+(_eAfD!4}JCq86=M z=^HwvNrVj*eDyt$vgGVMG$k!!hKdpX^q<}H$_s&UuK8XExa#O$`+RmBJ&ec%95S!5Cl^`ppkVVc|Jc-G{e1<~4|$lQcJ}0DD{{uRzoQe8Qt-Lf_!880PgXA_bz4yp;`0+1_gD$3ej2WKkS#m-1@YkpPZ>Ql)xX7rapA(!VB<%x2*meK< z9P*+TnI?>gg=f@nax0yo3nIb?Ipbf^GSY+o2I?VX?Co!v~J~sB0#!q!DlK71T@|{EXCHj_*PRw&y+dm_2C7#Hm$mcDW59kZnL6pB-uBrG)1Mle13!|RSZSModc9+J1UI?z*Vewr|R zqZQ3cUe9)|1tWTIL3$uO6fAlFr_Z?=!#!8aE(40Rj|&O(gJ2+x$%Oz^JdZJJI?&uD ziY)&{1<-pNQIyQdRU}4;>RaO|jOn*X-6@>*h zEMW&$5y|Qche9MlLFWA}VR2QePqVBdYViD4TayM2{z2oAfiDvxYL4W{*8$@Yg1-%# z(eA-#e``qq3K%ddshYqwHEk}sy|!3?=Trz2hhjN^^LwD1KK$V7HS?e7a>$fl2Pe#Z z9NGlh?X9eQOa_DdJ)ZP4&+(0RH8PkSRZ!o*)?zs!y1)DdiOoJ&^y_ze;I5@vM(32zN0$f;y*%l56q}Uso?jZS zJ&6tLmZp3Nvj{39a&5=~B3sO0%4M?6Gau`K#C?+_s?F8#N#20HX_mD7_CRR`X z<&~!>aGME7radY9>j6?U z7kV@+yVn2{zFF{7E7^qpwO5DF!Z0TftrM{_vOE6}&S@Ks^JmopGj572CKezda%96h zv#?ylna!Z)mc=0QvSj#Nzh&$9wHXi2iBv7PK(j0*=rm3vq%b#IXXGA;=qszPuGo#6 zv$(+Y{I?S3aBv*@^Wng!DaeqaLr}C6?MAkmrq|(!Q;rLcsH97+!t7}gbXM74velhm zQfqYcO`>2n!lHX@m|DjTg?oWWo#{jedF;T$RDYq9xiw*_nZ)KHpjMeo8t@f^WUpN9 zVG=MszLm(9xpSK=plqoQlrry)#fD@0-kH}wgae~zdl{iPys(_dSiB2_5)!*SEd)E* zuDzun;2Xr=)d6uK!=eak0(H*5Cndb>xiBEojf&|}B{r-bJ11o;!e2Hxv!RhyeBS3e zupNm}x!ve5xfoPebtxiQnl)6swW^gK8nNsBpfaWzkAqAxTN>s8$UHCnZ-I^I;mSc>tVt(T*GqB)dt^`EnE`^z*JM9Pvk+qOolhFQXs*^#sn}xKS z*f`db0|ZLCJJhX6Az%#rTqi$`PcD z+;YT@Uzwt$d(p>59D1TkQDN&PUmhx_8ajB#$US%4djpocOj198a(zj0c6ipev&!Jb zQ^8D*?+-AUj~Ug{e8x2!$HKcZL)M}S^5};>otk>&Bgs>ivKO!pX~fbrQ4O@3VF?v z7!pHlDxELi>^$J{TD5rxx_Y09g?SM?q;}qY47IX?SUJ~X{yxU_-`soNn#pTvgb($j zdpLgEBl>j*pIw$ToKMxK$7C0;N?7m9-x`36pOroPY~Q^<2Z$Zz9?Y;T*?Tne(f*XS z)%+6Hxtm08OWz{*F8gR1^I(16&>Tm+rNi+UJ8<_KsyZa=$oH*Kd7wDU|9*nFXshfT zR_XeMXOI7NdhS#TH{~@2{Q0GzB8+!3c51lwYW*X4Z0=C2Ps&qNja_bOY#(igc9e^% z@92{CIrU#Ci0-&xMu&9q&d)Gml*wW@o88xAeP8^rU0Qwp}Ae&u?(g z-qz!oskWgqq9F<%m;B~e+xMjzwVldJ=8Q^C+h7#WtegNx_yy|N`?)TP+{tXC8?GLL z+%f;IqCzQo2U}p5d~j>YL!^+!i2Ba9s6wNov#m`H5!?6JE>S_Uo0yqBN#GKIBHcui z>#eU^YCj{*s)svdUQ-gbKJ{oE?_tUV8`9@F_>ROlC9jO1|IivY<;~pq7~d|oc|PXq zMuZe_nUaX)!EtX|ZUCwC26{h#_cArn@oG=wW1r6>2o6FWl<2KyPM|b)dAGIYmAZS*mr>UG$8U)MoN?z?PXIqI4JNXsq{{A1g zG@ItyGAaKDK4C|!o^HJ!|L6JefOxr&;`vlRJGygVfI!>Dv93x>PpKhSXqPW_Nrl|t zrbHqy5GfE28RDyHiIPcX+K1S`hc2|5x!n5NbfjUoD#07tAr<_!(s`G)A zPFJ*V16R)*#e)*>oj)45-L}IIofD?6jN$D&lcUgsiX1W-BVbu>5YqY1-77qdrH-6@ z)-%?}Gg0!l_QHAMl<)4n^7`cEo1dgk#ixfonz~Cz`h&~wBzaI7eZjgW`0X<~5kTw) zoD)xD3`sk(e|(Zc&ao%zE&Jj6%435Hvk;-bT3IS@E8|J>xo%_cX^2pYa_GTMgCoc{Km7%Z2gx>ZPU+~66sWs_yLS6*>YP( zPMPUz7ae@>5}wOeHrh`81n{RYGpH`>r+voLLL>w(M+Rs)Me35zK3@pP<=O~qw<3x? zTMu&jY+lXKsN6qJCC#^q7M+`cpTWs@bgLY9-GZ?=ib0kD<7VwQtTEo}7oXj|xnT2_&m0+*^$@v07a=0M3 z1GyApL3jD&4~UvHCExITSXMpJ&MS%_P08}nDY_(pwB;AT&*DGD3K5RGQ4z8X?MLw; z4f373E_S$c7`@^O*eaU`T~zIAaKBzNr0x6VCKD$p3pvshM^~E5D0QxsYn-L`TFB-% zS@pHCX9gZ!XmUi$-Cyuc?)1%nnuELZlzhw z!#TT{uDUHQp*bof?dJ)eV1^oMR7_f+TRDam!2dW2rvTo@2)rVlXyX1*i>ri0*k8<4 z{6U6xeDwT~V|#Z|apKyg#xBW)3bSv9b(tfUv0U4#jeuIyq$y=_=dtEF@0ig0%e~bj z8rb~iv*Pi2LZ|DD^V=%*Pu~5{{6PZBnQp6T-NOlVEKlWEYXK;@3P@O5v|>G9@FZtx z!djjx@Hmjy-hiS!TV^fPGmieVUT>()cKm1kFL&y0#@y(i4x+XoyxHkKzxfwksxa`m zI(0O0#7Zr0FwGSp0j$RQI9(wn~8@3@E<#C#rt=32f+F zB1fpx?f#DJ;-Z%(0$-4azyENgsLzu~gjTh78~_hbxK_c*+49%xf&mYXe=#~Sv0x)g zrFrAyOYW6wjh>kCY{HAblOlfN`%|w%ToX76N1inr8u=M_(L6Z(sZg2_RQ!-i2P~^+ z(WtI#(bzO^;D`F$35FV3YB6eH>9fNhZoev>4fy`8P0*lleEjD_-yls>pVs!7JV7_^ z^^$iCt5h1ZGzHwq#k{gZLz4ev|D&h~sl0<&&b~^Hr-fo?#6szA$`o1^B$Fl0K?Hk^ z1myDXSXV1bxnQn4adm>BNd8F9DTI@k?^2 zOAhi9cT)digH@2A%X&TCr_D%mY;2NhOC!tjZ)q{CLcj7+df|}wfjO4~{u^rGzD1is z;)`*Za^n{+8IbRy9~r4Ksmg)=`TZMnfKy7Vhn^XT!^iEDC@$9P7o#7MG+=je_`Yy5Yx-ZVtnifs3T(6rANBP52da6RSsWh&G1Ew^bCCaxCr9zDkm zHG8islal$98YZJT9L_J%NwZj5=lKO~%2TucyJAr9=J?%s`L=|!DoVAg92aH8d-}Z( zQucU6K>CDq$`mJ!0r9m4=SOuai3W8&OFs`_sK)dX=m+#A29*=U!d{N|^!9>rvu~bv zzHpM+7{kDVAnn#?)7gjBDH~)NTNm9*DX52G9d~XbzR`ce9lCN+Y_MTJ9=Vq;TKx^2 zYi10EBxsfD2i(QlBs~*o@*>ewbpu^tQ{dhV=K)t>A=TafIP88X7%A6}FpN42C(L*k z3urZPCWN{;-2fNQtJBGz^SDPMR{JrXVnon$s=$ht#Km%sJCC!4@lTG?^+>Ht1zm0T ztRe5ZXi&V#^>1lCUigNf$9uuot`FYK#;>G1o=@$c8_f8_0OVWw?NkJVKB)xH#I++R z!~A~zrf+o`OW1|(@%!_L9c&nRwSvq->jb;W_307gQ9K*O2Pl8o!q>g!`tabr^fiTT%8}jFt!&|8~a`h_CL#n~zxPL0`coY_iCmI9f{+OW=`| zIO!fY{;4x8;ge@~s>jo16aNhgvt-SYr$E4Ez$=qb5FNdgsf(bZW4$$pt)5+ZSwJwg z6T}CKn@hSP{>)%};6-(+O_gp%lLva{#;Dz`>maGGZQA=_;dqPk*4Cx3`oKI{y=!{5 zL4Bt##l-fg#qgt~1~sH+8WXj^9cfD(6&rvm4ezQ}m?J{h*%Q!<2KrqX7jQ@qhi_NN+cQf~A{g$PvQ3i~w3~jUZLy}!%Rs~bQf9+EMAVHebE7U`mvQeBeE|RV z|5$+j0-6h5DozZ6tEha>YT_AfusicrCOfCZxKxq<5DY@{BwEm;8~) zo3w}h;)XYb&6c{tI22}P#E;{TnRG0+IiTj~X5oE*P0`4HkD;DzSPIT!s%CEW3vmyq zW!uz;*9(4*t%fg&ke5+Uc8XGTWPi`aRFPsHkk=91m~Cjk`^RS!0sP_qPnV^LO31SNIqis{oQSp*QCQb+=&)5zUh=EM_z}2+X~UWhu*!ZsX(qquwx2 z;Mw=0fCehyYG-N~ch*c-)M%%1gRzAf^4R~i|H-g@OCIM8&H1(E?OUPJ&6PKQi9q`R z1|Ae00%x$r-O}~s+To}ED_2zDrSq@v?fG*`X3?qoMs4^Ctze!+CQY@9?WBQK9Az>{UB7CkJ(^O*G`fJR( zi7Ing2}+j2qkHZW_e_M{$9t%H-7^tJZgQfutG_6Le0Q@FCN~qY3r`}eTd zu5vFDN(lY%Ui;}CWI*!m==8)fG|4~vIYcBDwW2VqYY|RBFPzx=3g#s3k;FSJveA6b z?ayNv)crW2N)qisg`QK>iyH(@zrYG4>n5@B-Bw$!z!H3#b@5d3=)Uyrmr4GEh5he! zJ4d4zBU12+R#ei^KJ8Jcn^f7^9-#E}$5l4Uo-K!sZJrq?`NV(IwkOX^mqGBDt(c2& z4YP~Q8`>PV{F0Pk5$1mK>G)D?#bxvZwCkRR{eDTZy9^NXQ}X#QVuKEq#C(SwlFz>s zgd-bFdSFGr2BSPeEi{rTZ}bnG(o1)5Jx^O-qj1+ElF60GhoyQxzBfT;{u_+p;Y*>| zZu@Sy#=)z;gNu$rxUoR4 zeuD7(M*I0FD11hvB-n-_Hp*% zVqo{yPla&u^3UNPcYK?%{d*~WZn`kYUzg;h!SDoVj5+js7wTVSb-GfuV;m%;?!ejo z`(tT4Y5SL(!*W31K56V$SSd-EPfU94Htm<%ADN@Rd`SF4j^JklPrNf%?q@aJ%R>1* z2WSBpg0vQU@W^%Bpw`N_863*oIY3-G$Q>4^G%YGR8Fz(_)I#zLh%QS#4wI+1Y+qG` zFQ^_yug#VT;NsId2Y`T@dRzdwYNi47-J*z38bJ#SrF$0pdH-$3hG4!D)j?F94YMry zHk=!5)yB&@fDq-ydDYGV($SgL&bk@fvWn;(wM6>T^m$aRB2KcJL{6`UxB{&nBw~lJ zVZ9$R&fh9R_4AZdHq1Yo&kT&Mu?o4Gm0b>$*2MQHX^1NA*3D_^zwR^6ljZ;tR8qGW z0@fMiuK(4>(|C-uGFqO;cv_!#el2enk;6LZkz#_sU9W}POI`F znL7d@3}*8k%PvsYjb=%Z6sJM|L{a#-x9*g#9c0Lok(0fcLb#O0m@OQRPRV0UnQ!1e zjPQU?987%%eNp^a1a4}VW&;h*x5olXa*6X(I>~y;b0v$&UYzV0S~ry*=M*K;tb%ZEAx{cLayBg}U&=xzD$R-{|K zfyrvimM7y41>Q5`X3ZxwVrq39`0vUyoJ=>(*vb6Onz}%SsGlT1HHLN(u`#PXWx2m% zP*97eZ|D85EWu0|L{+}x@}TKjy32L3Prjj4Fz zfv!NlP1|q(<(W`*2Og=|?vy~P07tvKDSaAjNw~NAZ{B-tV{M1VW@=7BA`CMNLJ6?h zmT}px3%N;EqMYkl4_x_k_fqTGg{uAI)%puBTo3l1sOYWPT<%rWnV$FQSR&i zcWLwBrPVJzm@;8q1PhBhH;A>g^+i;@(0cKsyDY~8Gj%5w{fe>wzH)sm4B4~#9QPwv zb>5cx-a&_|PbS-cfoP~#wE9Yr=O+nFxI!C;&uNG8(}%tDmM?=o0%`0Qo~TBBB;rn! zfjj|ac0BaM>z05y!hIB_1=~!XiV{Q4?$lMRc%i&kGgi9>BiK!F6_|83`)W>fi>xFU7vD=)dOjkt{NIH?+;9O~Q@-X2=L>=cw`OM;8`mqtZMi)d zv!-+PuXK7MYT2i}Jc3Oa-r@Oe+mipTtth=nU{gxLdR|3r?wg!fx_n@Gbjm%M>>G53muMx`T8#W`i$f)?4D0(tald)wzU-mN+BTwLtiF^%5l5LPor3(CmiTcr*|;P1jlN6JUlF{vqq_2%`J0`X zAL7aikm=|1SgN5Ev^f_v9Yp%gfz-wm%%J6zvK|bfW9B{G7>>3O%CEeT)0bj?PO-&$#(Sm2@MI zRn0oyuT_Mq*>?EZ{dCvCAv#lR%QR2wFn`25Y`a#$f0rq7PU4TwI{$x9&3i)eJsGK_ zfmZ=qRKm)3+HCt5v7xb)5*Qu2ItLOgLZfUtlEa8H(%MZK5v+3Rg2qDmcj8 zx%pFkEjN!nQV2g^sEkid{sdBJpio9AIi0_E;90{Paf(cF1ro`J+b;uMWu!B zMFX}VP46xf>Gx41gi2p*;FGMK*IV>qcJ=s=yRvgdE20>*DPNcUm3cMK>3(ZfZM*r4 zLBsB(_tzh|eyps#$Qvu~HP4tF2<|#*i7<(|z_%ifR z8fT;FpwsS`&=Y1(yGvEZoVB@kfJ_tqhjD-1Yjdr|zYQwLbyZA_8y@y8=K?W?-#CAP z{~{%nhVzYuW}bS@Q0_2r_qoy$paEzr!-mOWQwH8xZhng9vjyCRP&*2Z9#?nX37e&v{Q>Vz^rX4pM$Z7gV*pzfKX@+c|CU^KB zg>V0mKsyY4sr_bY#u8@6o6(^Oz8(_a$Bg`19{ixf1-(L&fOq51J(#;vENrQi7%KRv z64un-Hg74RJe@tiQXMx1+vT4+RkOJfU_Z>UT@*}C0LZ_0n|b7oGAEnPcowAsW%0%% zaIe=Id>Rx`!_$bz&{W&U3`C0u82z9i5ffmm7G_Dq(Pf%!59U-SHROgjQ7b;iBsp+& z7w|T5d7vflQuBDO`$5Yi(!aD4Z>!6&&>P+euapr<<+fB~D4QxbL@VxO5>)pIWAPz0 zNnRqr&dwZsJHI9VmoaVdo4iymc!TBACaToJK@A#$E|tlT_I*G8AO%`qvSLb>n^idR zasqBYOt04}PL6j)*JPM27rE*3H!{?%=qJh^XlZ_K)4E^T@Yb&Qz#(lV+>ONNgJg`M z)5km8P~*S5XQGDrE)M3a7W6&o zZ1zHMD!to*+>=upd-4_SOv7hT*68` zM*3hgEKg`D#`m8gnz_(#W;s76;9C726v5;>+({P8`)M;?aou9sr1PmYd1w#4kEUaUY{1FzrJD0lHO3(nWNH-BDRmy<;T-BGq4rQtNr91L zuygbLT7!y`N`XaJEHes(0CC*FOR!SSSmZr2(TQiLan#XY-VCXc)Qj=D{=rMSc$)Zv zRd?~OOq+4gZSWJn<&s9UHyQq7bnQaufws~+d*+X}ITLVNp zi1`AjS3}gIOn5zaIvO8idroPP38x7iugwUqc=)Y?h}CuykCRj2@gx!25)@QHES25F zfZV;6tJ+L-bpa~8XXycm#2(0a6bAB`t?WJNRt`JvU_p(K8#-?weI{OHgpD-tt&I_q zZyyouSQ5l8@*6i9HrQVerHC$$0cWZ9S+@@}{f-JXsLGudC%#%n{}+>9E4#JHYdoBO z#~AXJ&E8rL4v5p@&Isp2cFoQ*o0}8_4tn}qWco2T^Tzy)*kEJtj!#Dn4dJHzzDLxV z#qCkXal~-I$t=~Q4ZJ>83L;JG(HDxN(j1}NF#+OtX(5ZlrRmcdnt8s~C)xdioX0)c z0QRtE`~B>`z}Ah<_J0`GxT^B2Bu$)QsUMCE4K;@}MuS=xZPmhE73O=WKh@m8*s(53 z)Km+vhckMOi=P)qhVp%;@VH9tyR>naCfvmZUj;%;M1dJjdxg{EX^u?)=^8CSg9x%M zAFF+%-YLXQ`}7&SN;I$@_deGbWXWNHKR*%V+R|i^-ro{D-D#yMJmyA4nQ5Bq5fr({xYkrj{x9eP{E#Z4vv~cBku?8c`*sUs%^t^<)5P|ltrE=YWa30h3lczO(*(i$;y2}eQ++_x&PP+?IN{cnV$FXZuZFYk&J_7r zwjQq;Cw@~1UHygV4?5(pPH3+YFD|pGpFu{{6~kkG7+$gqaiwE z;{aBt`CZ6>2c;=I5qOQz#NnnMoD|omi9r5)mp39jQGXeDMzt38lbqS^Uq>6_-B7=K z27R*`TKme0E~}aZJGSz+{CGNe=v*|u2C6j1L&PtdL5HBXXJI?6gM;V(=yzc@`vzTZPW zX}{uABR$|SIAZYq%Hqv~HWJc>1(Sh7@U^|}+?I>fN!ABta3Z+X`1xX60-j-KR;St5ByhO<6J7u$$**zIUjL+i zgbe50BQNB7Pj23+^6Cv4O(PJ;1c;Pr#CFVkwr`A1v6)UR*r>KD3Y#%@bG5QUdbU$v zY0Ox@XRIM#$)df|g#?`p74B@u18X%1JO?ErlGC{;HjQ4CDK6m97iGw{s!C*zbn*%} z%4~=#g!@-<5hUWGF5Ixxn2A9Q$p_C5<&BNOTra`LH5B7!Nqn`6Afn>Cgicy3Pxl3q|jiMXZ55t~M%qcc%H)8YOx+dU! zDIuc733NNMw8;gS{7Z;!zxI27na>QX^2tc8`PKU(eS@OUwk{kB@=2_UWQnpz+9~DD zAEs&XKyPxjoGfH8zzgU#Pv0=(SlZK+t_chF#~afBg|xeaBhV1l%J}9H%-1R+m4*lW zMuhr=pi0mHLnJ~!$dP`-A@5NF`&^{VSt1E zrNeb$^}rn=4NvL1|}wUaxG7C?TkpcsAD zZGqx11OKzOF4tQ#xS9e3ge^NW%Eo94MO&d8tBfuDc>QSGsY}d*<`$ z-5A+lZsu^U|Aj%7`XJfsw(Qj!6Wn$CIx#6=?e(cw=<}kaU*Y|9iN_J;k_Kq&gf&Yj z`j>h)kfmoi_QLY?9t@NlN@!#ItOkgtH%pD4>%+af(x8-!eRmAmyS0eHW$;PP z+bdnzUz)>SAlh|rJ7NPjm|z@d!3&Dg9j#08c$j7wmZ`$)$r!@lW#Ms%(s(t8+t>al z={>DnM93gQK9c?P4Le*VN)y9}tC4I-HI5`MCCjEPCB#sBDP|NAjsiO)lS1sxTBGak zU`vRf91Ve_bu{5hlOUSy4LIDfK^N1*SME|cuR z^x!JusT7j9>pec?iYinxfq!GVCKHlk#&m4XC5Jzz2Ou)&o2!}7M;;%sfA8|>?uftjFjI1*!m#Eh+*L(e4g|{ z6F<^ONx`~Lv0bHH`qiR7Xt;HI z7l!;uiB~8o>c;R=o6&Z0SL_6&ICeHhv~` zAETZ(A`{Z};6$pB?>SEO$G}Z1>fonsOYHBHJ;gGD19ZK~_#teZfKzbC+lg8sD@#42 zz)!c`c4WvG_33pC3EK&5gc*>-VLe~{Q^Aqfg>rB27KWD`FlUKgq#*y2g3F+iJVXbw zpeq`&{vK#W>Q-DOlY7iTO=DOE+R^zYCcW|5;V0$EJw z?DPHxrH`uvNtx`C0r?q1hO*FXYCvDiGyYCT@#|ij+mHwqB*63Wd8QqMT5deFqix=* zBQs9zlR~-ZJ@GyL3UHIEjl8wgOI=m9{)JCPYKueuTEHdL?k3)lGazZA8`396`ofIi zz$IM@jUxT$G1!c|^NYn|RP%|yHWm7$*Ui*fNAG+Qt)nz@U=`MFSZWzBI?bsY;bjU$AyG4dBu zA=^HYgg-o7Fob2^cW&oY0E0A5?v1wV(geA?U1L-3am8{Qc+a0vsK~(XY9!+jQe`tG zDxP~{cmlTQFqsec;8#cObysVH?Dv>q(r`YK77s%p3!#ed_0`OA^fJy3Oljyi48yGBlw<4x~w?C&FWgtVMR zfIdr>0gBl_rewL~K1=KaDDYn7D;|WxOHAK;t@(LNVTD#nVjTE}yCxEn-;V8uLl2!* z?`Zk}^gJf@c#EyAfd~dAW&CIDHks5yw6%2nMZo05#0xTj62jJo&A5gQnlTLyOY#)7 zs64^pe(gTK38y~T59mt1ce4Y-M#UkXLZu&L{|H~6EaFkb+eH=|Rh`*og6L@R9$VbN zmf~!#AC*F)o#a600VraDLN_9|T37r+{vQj#%EtZek5N_wSl=s#_Y4Od3h0ZGNIdL4 zWYZCIPT#tU-i)wjN>Q;K7WhM8z1N`JYrLAtfM>N19nuI?xh~m~oi<9;K(1J7WL#-N zUQ>%uF!HTX6A+=J7K$H4e5p09vkbnz8zvBAP$k%DjgQPV`j`J7^X|Ps?lz$%_E(=f*=!3kLy(#!Q;}LsTQ8zU($*L zMvCg@mu1{d}tw4_RO@@t01+4NS_L>85#qmnGgR@R-?f=oHVuZpAS0ETUN zkeA($ua=l+o2U<2YGcaf0q@;+?_@R}xJHp%K99YuE^VP?_1kZJckL`im&p?{0o>QC9wd}nciWRiRtbD?119aPts%lZ?QqTD;=|Dyxk2Ck~UA9%jX?j}-8<>6+V z#`aD11Q|ucPjr{kB947ff|L<+in^lqT4=;j;@`HsIi8kcY5&}{N5_SnqA`avg332@ zLlOX^fj*U8nUc(C%h&7$E@HXI9-oJkL7l9A;_XI;Xr->252dfFaH{q}r2%yUqj=!k z#v-%@pK?*y$j$O=)^U!Xp>{gYIC?>0(7PVb3YC%+6Kkovm66b23G4spn{e-@#S~X5 zImIo_<}VJi_c~*pq5r)zrVa5`hY=jq3B^}Eh;-Nr4NLaOx%VPYu4Fg(vp z_SqgN;>y8-L<&NM13@g^!-+|Q#>p&iD$#(Y`}C~lf~7sZt^`WQBaVGQQjC~KjB>xj z)ki9l5c=#8q+9yVb6|QRBZQ(VH@x>KSx1scVcat#n@||bDf--z!jT=OrxJvFEv3niv|SxP`WVGf?%R zBTfv-eCMD3HPwt|!~*hEH}^u26G-6V=fMkS0!;Afevk(}dyaOUcE0G)pnk?`Q4rHQ zzD)jC;KIJ&YhfA>+kZHRhj}t{`&?8O?=H{Kqy}hp;vNWHF3%D;fveKd+d|pN`#rGf z8}!X5OqsW{te>AtM1e2dYz+1sjv|)IY=kgb7orZi+K<8exoTyvKyECIsF9)(`bUB< z{_L5^H_KIzIf08FML`L5A97e-0Ju}x^)$*#Ym4<3X}`W7rEU||MGYzyXnlHTc}dn& z1K~@6sG0!>bOD>!|2Kr)b1GC|k;6)6qHbVd(%$tTq8O{Z`PvXf;V$_&Y?JbfOEC0Q zuT+V3!SqPUqDagidSTI^y;IP{Sy(ij=|P&XI>vTy({22uKtF3R4fplmA+eP3v6fD) zD{5&&yOiwkD*n_7%P)^bAe)JN49|6TTbFjpqv?&4CL)F}L0zM*Fe1^;*BrU>fdUzO zTKN{5=f~4Nv!m}-;(za8b+-RYqsSM5ww~Og)W#mghBY^3XjDM-f%t8cM*j;a$Mc1&$X<=rjPYJxyTV&G&0Gap^Uq=;O{J>k9|{VCyN7@q+Et;VVjHuXv7}rSYQy*4Ks`HWm@RN>&IByRyG*nitMzT z6)-67w>9H+*2d}>dNZ?d#N)Rpk7csg*@pt4YKNCxYow87TWc%3$?^Wd{0M7YWAt|u zZ_LitFM5}lh14QPp2iOZ;b%g^Ps2Uo2>{haA0Kd;B)xec6!W8;FF6`SwC48Us^?Ow zt%$3wl(UdNb0RlB0Fa*~`8GqAp$q3{wacD}l{x7~&tLT0B<+QR%k{)rXfLb)KsINi z6Rs#z(}9GFQ1LCdjz|^TJ@KVHeU1=Nx!$adD=1iIp0AVij;n~&irbCq99jO zDoMn8CrKxv9eWx)$)s0ah(T>gWkqH^Nn*JOo9S8sHko7e*r-vf68#gv^ zHovT@0NueyJ;@l`Wr~X=3wh3{{2QWAOQ7tm84~#O*`J{Y=-U~PlKHb3n7s1uwp#t+ z3{VbZjXBsPF9}El8_7>K@S1P`ho-CWit>xL-vr&=(%m85NQxkeAYIZ(cg+w=cOxZ; zl!Qtu4Fb|3AYIbk0}RZY-&^nf1GCnwd%tt`*=OIqeM9k%ZH+-FsF?FFIdn&xBUvq+ z$)`nrcrW>Q{MCnc9~9J`jT|xb+!FWCr8detMoD|81Bz)7T{mL@KA~4PEa>v0I-V>z zCqlL~t=%6#l>MEXhce9|iPUXc-8Xp%36pS>-lkwDa=iBngGGsnNUPj_-jaEA74b`q zxcph$Kc9WUlqU5^)PhwVJ=gaKsyp|plmV&9b-&aJuow@=n5cFiS-iUS5eM z@cao_!#ZX!P!k_0RSVkBck5*gU6u16N!WhH*gtF0{XGeZ6>lD@cOazLNA-ug%%&e$ zwIheis>MhclEW*Wt}58=Cb#fo6!o@q@)Y?KY85s<1NRbx-p*0-&oSRF3P)U(5f?mz zo5nYU=Az^JQtljt#)oM1(tK6UXEg=d_*tLt`thXwhN2@XooG7QHi}ExSA8tq!u1z)WmS&_GPUUGZ4L}HPmQ7Z~mfEj5qAtFb*SCDr$%-4k@wNGuk4fZ#^N9 zh26LwwmkeLf+;Lt51}~GT@i?`E`8raQqXZmN=Qib_(V6YX@ndZ^=8mx+n~qew%=*s z%XVyVIoZ2LCgJ14y*Ct~=l%~}Qk}yl8IjH&b<~2MM>M(|)P(BPx*V$Holp3&sC7j) zPX$*5C*mn_o}2Cx)c&M^A;K(vy=_|jRFlDQxUo=p$E7xF4&ai)_g={$^W$X#v_~Sm z0}@zq6(L87!bdE4_;7(c{!8q(0%>(t|JWbxr9fc4A{<&YrqW2G0(R(tf2^v~0IIbK zav&!X+Z^{zm0nBZ=anl>&)=|&iEjRVy^r1|qJvV=nR1n%Tt)V9B*K0L)lBnJow}e6 z^J>g~aufq+^l9`?%k)$eK!$jzN*lfQJcDShk0Pp91I>IFL$MtG?wd~A4I8umWJE`L z=!cbA{IPr*1gU$XO;}>Rz}`Yp^z;oPLkE-k2>?(q3t?5zedA~Xn_AG3_q8lyJ||+I zF74Lvpr2yptOV8hqbA`QoAu6jogG6=nD{5pG5xi+mh!iee+UP$ZA&V73mGLwie8$~^~V%=?()s?7i|CS2xY*! zyIU{#hOaq~^)yIB*6369A!<(pV&h%u`7(CIYNyj;VJ?iecesepe}dX3mOjNCnTOv0 zr*+>ckfZ=Nt)6GW|8Zh<}fLqqm9vghN+HvX4JpyYo+ zdKvi1fwLoAfI4}i{LE8$wK@plt*AFjb5`iEq6)i+X7ng;wo}FiCrH*MRRls;Uv$@} zLfzrWmSiB%IV^zvTYD8+t?V=$^wm}t9n3wZw|4U+p*FOmj0Io=6)i+Q?|0cJF$j2R z*J9ckEb)o3Y@3=IZHf3F7)0B-Pe{JJw~x1y<BuJ%)h0Uty|m?v))y;wat8LzD3Hg_CWG#n63p&jO7hXlvE zg@iDmt=(*%MRuQ}2h)VZvuDvjkC$~o)dyNCl1bknwT(@6BAiv(qy03D@ypCF&bh1k z1zCM{O^4VgL_7OeaT~bQ(5{ZtB`E6sX^rjrHOIZE3X);};rHd!@#1a96So_6r7$SU zhFcG5aO6YGSbtp-S7&oo$P3QxgKSMd%=~s&(Dx0 z!BiFPB4ZW%D#;XM@^|z{KlTM=um0LJdv4;Y(Wt}r$pb(9)R=7om1MFnk_6~)-qc24 zeUm-XQSoV{SIqy+&dhRIM{7f`krs}#8gQD_&id=FFN|-S2W%-z!q({^Yw!s^ES%y+ zildmCzPV==?Y!cD#21Qc3dL|k)yO=~KRr~Jf4>$t1{kRUwep{bZAFKv&uh5gFHq^X z@I8F8oh;jm8WziCKIc@(nPBYp2tH{S6X;7YWRF_Q%pn;dZx*D$5uz9uyzNB$HfCHF z))C1^VT_5o4`9O!=E2Eo0MMIj>RGfCRC#uVb`VWWgnG#E_yPdH#@&}T zT*4;D2KQJlgfF~O#j85W!kgLu*Ni^#|BP9fDzX&F*BS98DupPgKhpMg{ugp<&S;6F zMyAIx=7oM|8*{_(Cx~N@O%t3cG_)c9lC+a`D;Gt5XUx%ML`QDYb3z|1f_bJb;rgi= zKNCBGgYA?A^ms@NLDCw6Q*R5doJTLe-bx^@3*5+%5K08r+aA1!-xdT&84ZxrLE4y| zi2TU@n0KA73OYkX$+-!La1iOC?e#R7PAc^7 zF3Nwcv8>(Ul~d!X!UuKYP=SYhh8QA@0AuB%I@M^u^!+-OG6V7WFa(FBu z3w)7fgN-EWTdU3>3E&zY)GuW(4`9u4xkm1;fIJypm#A4l4ra+;OLiAZ0f)%A_g4nb_7GA_2mx;GuVTaz5YQXzo zS?_I7`47SVfTpNca~XNTApJt)aw?m8|1j8&u@?mOIScRVnz9o%_ZbgKM*`qr09Ujy z0!iYrR{k@qO20M9A0 zu7-O^tN&%CvHkA+7Ev}oB5C3=?T+9Bdpyp1YQ`J8Ok2d3L`TeZ>$V{ZcC{=snpq-C z7Fv1xPm0WyGPN1|BkS8O-?be~oY;!$mw&`SJ6?Z(bV=H&QBeQrn^b@Q=-W05OAXoPz(n)A z$mio9$U-=D;JYei&PPH-K!O){kcYto?$h$a9i=80SiBs+*wg2dQ}hPQ85d?Vp+4bNhty3e=Mmog4He?mLO zv%JJ-E9wNQxmw+?fS~ z2qg+d5@bpoDiH&~^Q!db^Xy)01~>sFl~|PG@%xLp9UYY#GICFcK3BD_OBYH+Q=ZM? zaCh({{xU-(rprk!{pmzk$76em)i)mqgT`|N@<=T+rOGOG({ElC@<+IjCo#~#1{Gn3dlNe$Oo5(Ee& zzc(RfCmuG(9+zlNidy_$ZN7MVXC$7JIG^#1OrBhvkE{=*hd(^ZpFg;GP93}J;u7_o zSTob(eL4^knN)Of7sAKS|8e2a+VdOVeE0bWodyDbZAeE$s55aiHH!j7gIl%Xh1$;r ztfw|_G~>%D_x=zMFqz+f6!YjD>qiFStP&e6fVv19oby& zymescF!6bd4qiPxZYLGI@l*Jy=FZLj+Ogql{iL#NwA27D9ClnmJ*7medPZ*t#u6iD zC}cTic*T?uf!gR#+BkFz;+;PfccX)QhLBRpZ`kYQXDc<3TA|($ROQRN{#Zfs3?hm` z9Uj8{`ssgNC5COPujQ%y{`umAe|pY+1L^RcI@Ac#_s0|_+QF6|a1nSR#3(+^ScSiK|JUYF#GlToyLg^3QPIN!ZoN7jOiVQcubOHN zw9w)VxOE1o$ypF)XW<6Ce)%}YlIug!ndbncZ~Txz(E%#NWUH7e%#`@`+qZCos&~JC za|81+TZy@AUt;FvGz=}9qi8NKqeaYXQpKB!S)ChbwbyE5FVlO_qlj_r-WPTAL!v zh}@Mf-TMJA3Iu1QWkAEb&1uSYrEjIHFnwllI+vX4V?#MY41Gx9s0hTU zObc>H7%3#(J|RoH#3j_3ok)7Q=zr|U*AUb)+hFz0{Aayt;;M$-NZ?9d#Ao85tXPq= z8?8xvV0J9ES9m{TItvGNA%%fq1^ysP@S@Z_nk81E?aEL1@m%jh?M>0-blmkKoG)>r zb@hc({E%O?1z*In;cA{_FHox3r^tj2RV8+i>(MR}yd;J0WOe3)wSy~@;g}i#ON}0V z+3N0=hhiF_>?P9YLpMbJ-7*Cbv64vvTD7)HH|3w$Xb7b%Fj=MHZI5m7}Rk`#=?}(PtEYh)}raMf>fqXy1M6EYxH-6~B(*qYq6Y$x;9K z5A}c=zb=LM5irgtE70Su@(#TwsX;e&A!wq>W?22~ud@(|Vo^WsFqBq9xF7O{alO)B zei{?STlLztA*DBX)2FT)g6iq^!bGzM3A#tP{8^~o1BRTx)lW)UGO&wju`(;PO3q_B|E8i5b zi|}lz;9S}F1P|C`^MMx46MkGurQS-Xcd96gyyr3(Cp*!(Mm_>^M< zLQ<+>*p`GCe;*^pz-)l`A0Uz;b#)~kAI=7fU%_C5$5a2+VS^9L=qm@z5G>B>8FrnX zcHf6ANM6hj`*A$I>Fz^ z=ajuR9IwZbocW1cqoNqlP_S|^z{ZRKp~DBleMqv`>M>cLUU-D&KQTSuik3P4`{wI( zv3S_`*?k`h(0KVPTiXHgU;<#>MWuh3ZTB^fGIJ6>_OxBtWio`qw^EI#!~D!{s1vq| zh+b7lm&ZpA*=&TvI&=sgyr}NIdhT(!>n6=#t`^$T4F8&zJt;hochUOWakEGrz=oq)q>kj?e4?1w>%aPN zcUn`mf`d*xhTpcIpGKpvg;N9V=RFGgTvyAlOTV_=0)hT*gI`F`s5fHtQrn6rw90{8 z)ISu!R;FU?tERup-zGZ)8lISz$c}J(WfG~>c@DtpNi~iosqFL1y>E(|Qbr^Rl0xd) zPyoL2(2!;0Ssb>4`YsVi;`e@YFVSCv-J16xHjC#y`;j(zLPD02U8tO(0}ok%oovx&C$24h_F# zW8(EtP+`=}8Y9tOq@~=iUcln7Kag3iF%>5e8gAV zcqtM9Kk`YD9!?s8CIE#80P!CR$<1ox(V@MTj|AN$S#10SP@`#PV9S2Ih(`o=*0T|_ z$y&KG^rJfoGA{(123>L8-FWQ2$Ir4+{?*#F#2LK7w7>)&=(A(2P8p;V z^Wut&u7O^*v+mG@9h18#{imq0xUg`T*1M?Q>0f!0eXrM8;JE1v6?T|G`&&l#{r{d3 zJRh~wDXnaq-)A_D^j-cQE2K#1zYw;n;8u0@tgdF%5dR_007=Aui=~MV?_>qHlEADp zu;9%L-IGfz$}k^uv+X}`$YAH03O!_@s}sOKa8BpsB(A}Nb95TisIQR; z{m$$g(>BB9)-k$wVLh+L%FA<3xn80lkx1-*zy-dvk|IBRB7|U#EKA2GFJ*@l{Z zhJwT6-xSd_%s`S4MHen(QQPd<1-ZR$$Ytl0&)n45#{I`nGB1QfCN>m#A2Ut=2vh2? zNX55wvM}wCqEI9TNA3jN#S+86x>aK-9@-3uA;wri`s7M>xjpg#`=slZ;d zHG3>$BU}z=8~5MP_t}LIP2$+_fymL36 z2-)yXDO+#7B251t3Re=?73(>@fTOr{QjK5(6SUt=_2e7wo&%^qH*#QvUzk+hRnF=P zbxV`sj^Cs$jq|6KIiiuf`oIF{|7!utWL+c=>+9UNXGv=LRep5eU5&1`xdq8R3i0F-_F?L4Z6YrpK7^j@ug+ej8UT+sF-)}LI2(}YpYIr(hb%uQEj&Kxw((t11 z;t2&-*`DOr@xBHL#;)DX$BammPn9~n_&4-t=7~R|EsickmO&~*Zk6Q8@x4q%<#VHY zj08Szo8;g@!+YJA&$W`NeYx1!f#@O)pyd(Z*0@wAc)v?!S*+I&yRBB}WO@V_{tpBV zq*6~&DS%3~o+ZpgNS!~}mcy3y0UMCw+vlY^e(;B8HaKttNKO-V>Bee{7Xy< zj2@4$gV4bQ5!ZPGfwC!%nIUyaKONZwYd>(hFT%>s$3B=GV>>F@rx4%2V$J+$z>TMn z0K*(7CkQ228U+LX5L*XWZbv|I4)g08^yJ~_sQK=eC>5Uz#Kyz?`(j&ZOv|)GMsO?| z>aN6YQ*UeNn>)T{CTRj~5O2tU#mn1ONPMwz z^9Xny^WKMWV0y%N zG0ha>Ym>4$#`2B)S`O13Wn)Eo1E`SOJ+(T0sig~#-*GOKq`1pL@J zxn)aO{Wz&O0*^|YUT?Ox>L8F!e_OnPf#?+)Y_>DL8F-o@6Gd*rW8PEoCULznIvR{2 zIbF`eV+c~7*l;dK{~&tMWlppyP&Bn2R_FNVG$KGIPtWTbZ*}!Uh3$5@F~4KNp-7+S zqfu?l1-=pK5Uu!^{N7!Oe^MCxQe)Um+_n7g`upFO`5pTK2rPX2d2NZFYjp^UXT)p# zZIOi-J5#e;4TK4Vb#Mh`1@{VLGP&|w9c2nK@7BhA>s-SV?Cf8@w=?xdfPuV$p-Fta zr$Y`6vyu)XoeFjLT?*{vo((XXD@LN*=F^o2ib5o!zrIHU-bRIDB2?JKC^sDZE2{VF zV-9A!pA(Hm>kZcy+Miyq`Tf^gx9F)&5{#a~BXS&7e(L_SUJRYv<(Rvt*qsPY@c&wr zQtn7-!r3&vGyyz-#&c7&Fcx*+?q_KiNctk{B2&law8oA3sHPHI2xH5vu2uuIk)JL- z7*J>yJ~k;6@bbOs36XVSP@E?4>WB~hSdfKDf&VyQ2(r-v5a9<;&1=5TivlpHUoMGbLRu9@Kf&O2oIXHqBw(e?}kjrPORFct3xa zV6h@!1@o6FDg0d{W|-xxw?s7wY+(-z1e>s(K><)*+9x={bZqCCg6sWW*)OfVTe(c( ze)J1rkLXr%fd7>uwvxn_qX)f>m6cL81aMFh3>L0VzftNMq5`@I!1o`AumzIWQy|hG z4XVOk#Kyd50=|(OO&S)C(C{#`y3hvh>|ZlrO*Ow8wDGr~2y@}&zm|{pP-ykdg{c*o zo-hvVGf3>Mn4Y*nf`?K#uDf!XVVnnYU5WnJts4NTf3P00qQD#k;@B6Q!9n7`)!kd=5U~F(0cP!fZ&%LLq zOVd!%gGz( ze9wHlBkGxoYyB^;>~~Aw8raUrBx-QQbI>T$*4j!@3Hpf}GvaS7l)BeL00;P&2IvN? zZ=5DEHq&BV9luJTsi&-S@1ITaHu$Bo6Yj=|%SF6IhKZDN%p}B31~3t`fk{sHj(Zd@ zvC{HHJ`0FlJd`zzbK5xj#wB|<^|c5}>i%bA<7dpOz?j#yu`iNe z&}imvA)-pq?(F))}rTm%3;HC(*jWn3)X$nCg z3og@GvP|C(Y~(il)D%ZbY=5_ffZd2*#q_z~LwU#XmwbLi6IBcAUVs>k7fT%bp=Vd= zgc1AK2nLF|sCGUD@{ljBau=Ha(2he2yni_3vvX^w)M6wK=Y14HBafVQ>unDS0sxXy zG%WPOd%ENO6PFDQAn3VYd`mztNJ;fCAf@DJ*2MyqRlD}R@P-pjIuYmj{rc|FMI=vk ziHn80D|2ez9FT1fT<{=#DAgLCUTH57pl@STRl{j&*jqMFwD!;aK#4O0Vk%ArSz_~p zCAGys)%)7t@s0XGp)AS|OS?dXHaAA3*xM zfg9%snw|DV%WF#61r?arMd6rqRgEvC+$0aS*UjFQ{_%kk>>s_Tfc8-rM;Dt{!)>`I zm8gtFuw}3V`sPQdQUQR&AcUh6M-pNqDe4H`Z)#-YL(IsL0@KOw6@3Ig9yZ>-)|AgD2w`u8!w*6{aaO3H0 zsNOECGW@&{AuD@;Rq)=pC9*B;@xg~LYckg(>&||8om!kH2@WW*dV6My8Y(K^S;I*5 z)yb&&cD-SQVhVq~c!Edcc(AdfJwSl_k8w!kljD0dBCrROkvu5uckp_2me4Gw;{C@q9;CS2KcEZIVteY(B4W_T#nOsp|^{Bh!Q7!yCakw#wVP%jt`2s%lEZqofZOT)#tsJ zLuSRzJ4n{jyX~{{_ZJ5>E?EDuOWo^j?lx`kk^~N;(VKw@a43zDE{r%LRu@F7HBRyJ z^Xhvhp%8SbFrFpn}{L@FTVsCqxRkiH}lJL1QwDxE@XdlCc+dW-L0f>$1 z_*~>d5G#voTMg@G-W0~{k9fnJkap&3T8kOb!FOGlEPmnrz{={^EQ?~}?r->BO`$juGhoClbeK5c z+Klj1k}!d#K3WHMvK{0j0G#++<4(98PX_HAYq&gs+jxPp}}}&PP@;X+eSHl%$d1gC`oXGPqxRuSYDhB zx5&JDeE0z#_QkfYwSR_OuBX}>1tc1xzuO99X$uLDDd`2{{s9dfVMlXZ3=MY}rku2)j~#dIk$==i*rfIOnwr z6Gc;PHdNBzk`dhtu2+96T=2)C?YbX>i8~~eX6~br7cA@0hRuEMeyI0Ckv6# z=lKU@pqurDMxly=Cbt46y0x;Y7gpkhuD&GtZ9IiGOMI=ip{`%s1H628wqK&;hWst zDdJ(hR#`2atowcdhs_!_c6A*8Bl1Fy)F+>hEjW~Ym;laNjWUa6VEE`=&`UEx0C}K$ z&$ax37AcUc0+NVh-=J&@Q?=SzLpZmMjQwZ_-UANvYa^pRd-?mM=9|xS6iUPyTFpB~ z3K92Ia+nEDG+3YavcF`UPA?>FtQ^Tj=qL~&&q=H@OM@T1&BRrgR>X|Y7Ee7;+;&TM z-XsBnSN^1Es{zrhIRJZ3JitXq%D){3_Ejq z{`V@fFh4vvvpVH6cY!`XBTGEI?K?JPggP$*8YYMgL_P{ z9yVvL*{ADYmN81_6H-!Al7l*_zHt%Ia^nAJ`MFhJOOL}#+M_$ zwom^jN-+MgFOyA-l^)hP5zah18GyCrm{$j{Hu zcdmV2w_4jUyX4{bJf4cf-@*(Jt)hDa6KN|?nC^W?FK zah5&G9uX}j{d4%o$XQ}qxE;BPyo$eaKXJ>qXFn72LJMDk98Z3{%6p@?j5|e? zz5<*u-Yyo-6QzLF82Fw}$eja}$2W%ibBGKJ1WoH&l6h&MWGt6-z5o^~gz&+rPu;A6 zthudAA&lrDi;C*Bq61~oypg!@7$Iore(Gf&-$rE~9^-_A2Kwk3uleXF(fa2*`-w|= zJoXyyXF?AA)|Uf*!a-A19$S55Hm65);}){-_Rt%%REZ zg#&jk84~a-p_knNg=TVW14x@xF_h)`GpuNvUQJ^SFmUxnTuBsQ{mEK`@ zb?2`r`kj7a0%_+Lo%=hg{$mvOrV{pkuLO0)Bkdfm91-)4&(SR2b3^vJShH!sN zVZCK7;D5;$ZL!=~@wqKBt-!Db4#iF;tszQb7yhQCO9G4p62uGZKOxWNe%}ObVJZqT zWt6!tzJFHMk#IOTh)YRD1v9PVFVAA(hv9mK{R#3VuEE|H#0~v`7!$De=98K z^?1NrrV5np?OzAIwP!(@1`y_I8w(;N7{(JYP&H{L*bmRjg3-!isqvn!4v8|@KszQ1 zN4o5|XEH>>XbI&kh+=Qu@_UH;L8SKtJ>^-3I%3>+tulij!rt9Tp;Jj1f8Ad%Rc#@& zDt$~nr=JR+*Qpm7@ouboL#AIu3N8iWH$BQ%7rg2j0>Mj#rM>#y*Y^v1*BLC-w}&A+ zqYBX(tWB1u1$4xI1`(Ux83{t*^w}oX8i>uN6qe3f;IY)JV=$<69Ae9%HX(Z ziR%3-$Rp*lGVDF1R=IK;gQwM*xs?w)0Hp|r5GrGTdjl8Sf-1HdE0OC7^*!gw(D!|L zEQ)DU8rd6yh47XcqDvdPPReagyH+JxoKO!@D>OLDf%Rpkj^g!!vuE9ezGaL zGu3u-5=~opKU}8EJ^k7GSbwxegPUON8}GJ0_4f?NQ8&yjZr^r*IN6zA?JYRlEJB~K z1$PP-6 z)ly=FEG{BTr(wT0YEntk@@*mVkwMbZ$4eq+gj>f$72+}rmFgdP!{T54p9IEGn7Y^L z(u)ciq^q>r@;7=SN>AA#Dhvjk{dZ)jas2DR({A!b|MZqAiCy zVpoZr$!X7`bZpPEIvwTCPiAQys!&ii@>32%Sy6|9LyFJMksC}58sOr3CmEHf_K`$I&JnVR_YMl2Qp-QDN!uZTh2HgMl4koV4Gs>*#=bb@ zU|~#99HO|u`ufb>WT8&*Aoiz&uaerix>f$oruf$mKU1AY@1$CufuQV+nL57wT-uEj1i2SY#7KddwhcAEa0x!+v1`F?q9Xtl zrQU2SYl|-|Zxy0>NH{TzLF_vOxg`M$L2~TT+xpRZADpF8=#ZNu)+y361G;{h>7`AX} zaQmOI;`CF$0%dK;xy5;KOI(EYy|gR!DPNl0`W&a|SVO$i3vTxH4DWfy9Z@%^`v4AN zM`21!YIJHwC_`~4aeGbr*77q=8kn&supyUAgucc@L%am4yt#o#B_<<5a z%C2+Sd1sj`FP_8JZoJMhqOqHTS82oF(kffly@B&>+*Zz&v&OPqQUKGiK5?7CUYMy| z2eU7z&xi7f&H${Yeu2M1hk_G8PyxkS`DwH|CifG;4yeU@(es_y0}(AC4ILzgP>r~#feUvkA`D(r#?zJWK?%iPj3u|V|^dTlq;#W>gdNE{xb?z5a zt7-DmSPcJlJg*o%X^iGiYdr1qU;iG_e-&IQM7gDa`=WIlj4=Rhoj)z2sihis3~x^B zrn_Ek^q2_eQHU6DR4C>lrPcp}gq2*~)0Y?$+|P(-J*dAPtGB2xfRR5-E>%}o@L>d? z8v-y&bsr$-Kj~jMRs#W!9ZAzRO(h}guG3?BMi8+aFi5~nmY@Rda*aj8C$ zDwp&?Dw&=a_;H`;aw)xa5)=q|7#d&vPL$SwOZZHeNk=63s*e@1{9E>9ESd1f>wr}Q zB4o$Gwt4h*>y3}W%6K{X5!O@}{_fGSO8>|K7R5(Mdo{XjQk6KdA}LxW(D-(2JVTA)NLc1zh3#3s_bzMX zL1x7Y!Ou4d#WL{hfd_*7oPYzY{=2sYtSgNa3`1nPm^`gF*Ls<@XpFB{2pm-E0tR2*>_|Va z(1E9pa*f)lAH0C^yE%px<5b?3RM>En#0sqO-$$;WBmfaRjWl_&y7QMhb?Un(@ymF> zp8iXI&qF578SL)%Ij;JPi7IyXXqH}q@Owzm=kffiuwM{w>ze22=bGK!;7Kuz(iEXw zVmKiWUmWS9%<@TwlC5{CZgsYLMSVgpc7YmN>_>mHddmP4XNFG^k0zUmj4LpP{M9}X zH#4KwtOc0Hs?6eJvo9(B$T>-NOcVCCdRp_1NEIILfZNaMet=&^d5nI?KoyYDfKi=0 zs}_yF^9s>L!a3ZE??kusT)AgEO-KGf?57SB!^PLYi=R8g3@>M23uK*UD%?Ymh*x8z zKf(*01AHiWtKRl{go_RJYK)CSQR!#)mwzW%{Z}3ze?5C_N4P#&Wgf2Ph5MhpYV^<7 znYhz;AClI0Oz|{nF;SYe5u10ez3A`%wR-4=p~ZW&BAG%XmAp(R9}MW{iWafMK-JaB zivyye7kQ1g$fZwe-`lv|FxFKusefo4@viFnlLH_o%!!+9-`vxb`#<4ON(2cG zP}H6W!cY27WO4hS$l_a=VcQmg6M35tQs9ka_}06uh)kZ=YHhGDg7w15BEHWg1&}T7 zqOZRGjN$Tv4W6^528LrBvQp!$ZmppKZs^VW&D;6V z+QhtzR<8t0uMu59=P_L@ke!PR4RaPi^)iz!N`r>A|F{>Msw#8O z_bJbP|Nec)TiQXK^HpwXGPho0K}DVtHntaiz1|O>Xbt-?8N%Tm4w;J;(=~Cn3@uf& zokG2p+G^wA4GbxDeaV`*qe_Hv4KJKC>f6__K zn%PQ3l|(D$Sio%>!3hyx^%v{XX|->^Ru!&|gePNCW}&D^&lf3bu?I@enS{l%GtO!-Z{PimS2^iUL5sLFU_Zjl`xD``#aIDUE&%92o z@84Q~c&78CRmLbNU=w%?SdAKk=ybs+Ws4Z7$)>;3q(#p?!^G)jRFEQ4J^>THpPz{w zniRDs6V{iYJm=jGqxJ{V_!2VOvt9n^@nk%&ot?;Ysnm5bZtR?IVg-*j_`fNfTrV3!PHvBY?wBA zfN-5J+;MYrMrf3c_Lu6+xRf$O`_H0s2re@8hGGef+eQ;uOUb83Fm(XMOy;MU-2q|( zEZf$fHi{eFDGBNaQ@VA8K^-B>;pX1xNJGG$txz)wUkxTAMMV*Irg)k^>{qFVg$mm+ zA$-W+um?S`C;JVZir=kT9Evj0e6hM|r<<_IiSSPRKt_i6(1esKxQH->3(GU+2wQpt zP*hcmr?OF0-S1P3M64=o&&}(sqT{iS`qUMWN_a@!d_NL_fTJQ z*5PYto8Swm_OQn|Z!!}s=4wtKVsBj|g3$@yPHY#O@-ROW4ZcMoS<#B1;D0mNHVSmY zpgpx|&aPvF-_O$=;0!}s#)TkyC2cv?_;XS^M1-(#;Ugytk`3sNHr7+e3Z8@A3k*e$29@I)sJF|wip>x}s~dZ33cLltq4qRL-bNZ?qaX5b396bhO3o)^ePWyIn=e|dAqMz(jM$sR{ECM#A;cI|D+>lW z;{x@OzWq1eRe@!YUbqTzB+hbpI}UK4KzoF{l(y&)VTFdoL$)@pF=kRx-x9N&=+$)p z4cQZ&@12Y>$3UL`mO8}YA@8gEF$3YxP{PK5C>i=|#KpyBfB3KwOYMtI$=s(5N4u?t zrdB2IKGKWDPo>gguN{-@%l>$kkDQvCDxY>jzJ#Zd$?9fO1mlhik0*jgIWxdI(MIZt z=OUF;ALCM2#cS_Xj?n?>*R;|3SHzeon-D)4A|zE9veg^VtW7BW+3_|El~chTe6lC8 zrm5hM0YnoApzj3+`d+NF1vtP_lISNR%T{49;_zKO!C&l#?bK){af<9!UXwkTGi&Cg zg)V8e*P0qBnu%VNbfN>PM!~3rK!W3kq1jbc1z&cpQtS*Z8X{SDXn!KZCf@IN0=D@1 zk93x0%Upi81f`z^X(TdgF0m-VZ{Pl9d&$X?CMEfSqmlYfA6V zE}~06ARU-3{185y`@AKt6;urOJG&Z}k6zq0m45e{d=_N4=K`oYgI||i1;DmEF3Tfb z60ScP9SV=p1wMRn_B{N)jRieu_t06fUfxxI-o!P|FL-RMAogdO9fWQNKC*s4 zI)xY*nede#TFu^&)!zvyxsReL-@gLuV2zicf34$38sC=_2dEQ^sg<`I;4%t~UWpXE z*cL4} zet1O%x3;!+k*R>qXDQ|v0Z{m1IZ)v72-DN^Y%_&LH6&S`&;Mi0%#5RMN;V*eu6HD$ z(KZ9Z8_EcnABcA>g;4sh)k*FC67)o{h86qaCqLivB?11t6ALTh!9o;K$6YldY)BBJ zvkTToO_`ZF;pBBvXzS7+fns~KdbQxz!>MpZaz9EO9+KqGClGKo_R+k``v2rT`Dl5M zn{+H%-s3!N@AJ$kw(E>uXX(W8!m#1df{bXwb;seQ|J77MyeGGEg+7=WIva8$eQH#Z zF!gjpW5V=BzT=&wtLhkj5@|`_y5x}A9V1<=(EFwGQ%@8rjZgVB+V<4|C-oA&rYCjEqP+`Jk{QY7T;A$m(?0;?ULiEvw{-vm{ej z!^Q-(N{|SHW>$(a`EGBxJk!^+EfLL>kn2X(oP4J@m<`81(|J*FjVqO7s;vu z$bRI;&(#%kN0SJc8^%!rfEv{Yl)0(l{%_G;14f|PR9$o4eLmKszH)BxpGpJ}B7FFc zj~Dl!7>Jm&0*sA>HTOBHG#(f1bJcJ`+?kl^t z!Kaxv*(M`csJ34(B~KGj?>;qso*Yx~CT0xXraOt`eKgVqBS&jqT$|!DGHkQI+xXhv zcT)l0(w=-KTwArjbB-yRJK>EFrnz_Om*-l^er+cTiPFx&;9P0Richl8zZdKtMVrrIGH2p}QoN z1_?!^VSs_T^ZVa>XPr+oYt4sq_SyS+-zQ$_9BtymaFtC4BT4_+6-l27=dRWGq^Q(| zOI71xT$zFpejxW%MeeKZsMM5EEA7xXp=lOOV7A*WC9_J^Uu|QTPH?%-$*%zbHX4zL zh$xPT@dO88Q`&w&GN$zt;$GCXAM-aOG`!(4Gr`Gq_nt-Ddy$oM^##0ZFDsk>MU6R$Qpr)2A}suaR6A3W#Ez9F?Y} z2JOem!W=I?-sE{6m|DnDo7bmglk})ZL{nE;vBeM1$?4yuLC|+LUDSnC?BE_UgJH zF5piKkd%KH?L}`2|8!s=(dIjHMyFre(+9yDtnsm+MwKcgkZJ9ziT>!f&TU8_48Pka z)`yVsYL+JV70)}Jx=6^3$Fh$<`NHZoGqvH0;O>_JY?;>M!C+NsHOh3|j%=gH=G zRau2-v?_BFvpU7t#6(cd_{>X-QSlFV13s^w#%%?>iA0I((A-#k{SbVE$6Ay{hg_={ zfwq<(#NDvVr3gjgMuq$U5?Mm$RThH#74^^eHk0{uYC+YJPI zW4lKwm@jnz{YV866p>&-3+BoC@O|up(9xpgJ`oxFWKZ+I%kTHknWI*^O4Gw~Pu4az zbBCT_gr3qiuQg}i>r4f9039FT-WrneL<@{PYWsGkNY0knW>)-!lGqoM8Q8FX1w{=< zxdUyyp$twlEZ;l5blEGf2(0ojv63j{uCd%hVs#|JDP_!}3R3g2e})seYU=wGcp7_)HDK!1{HU`?VLf zj6463a5kMff0>#H0d)yX&vw4SghEakici6;jrxEPeWuC@;`jN*b~MT4hwUKEvdxJk z_XmuvdCF{FP&iKsQXrvQqB^EHY6!#xA$h!1Ftj?GE#b5{hvi0sFo{$)L!xnR+{kkD z^aQ7Jyy@f5e-}fHpn2R1Eyk~+0N#^lDAjb7Mzr0dFdeQHX`wY! zE3R3ZqOr@2s%IWMW97~Kj36v?;Fb&r4M6^a))|>`+AXvh{T>7@kFtn8Ht#=N@VGpc z9CaGACuwsNuhj(pTE3Z#dQuQAwORF@T+a-|@k_XANMeWlzPNlhZLdaKc!}}0wh-H1 z;c_z{AK&`f@0muYL`vI65UAIf~#Z1@g(0?VTRS?L92Z% zQ&}AYzH?WZJb7q$lNqE7AC!2~-6ioypc`Xm#fYs}oX=RgDVZ<^{(FC(SRAg>0dh(_ zo9x}oo5GSS*$?7Bbi>x8=^Pc0blAQj;Z+O$UB;OE#+Us9CH~A%n!Bk}myN9)?0Hfb z7LX{m?7hZU*|i0I)&4TO#nP4OfYNJg?3rox_nezEuB`y)JIcRV*(&TRcOWeI0HC^- zA!&7C7@N`=M#7%MC-*+|AMI+dLL4+5DG;;;BGK+|E@Pv0!0gnhC;1?D0_LG$zWb*o zKD2I(1TGs_yBi`*9k{QhFWhd81;ehEs#KRv)^Ui`5eP<+m|d)kc2gJ|9+3@o3Czg# zgQy_{$;td(UeLvpsh#FDNM~S23p!ommkCU870{ z%-P@9pV3dDe>!0{+(J>;g>N=?OLLdM;Rhhm%k9@-xhJ4BZ%^CO=(z@y38c;t@8`3Lm=+B&XOwXw2(bmm+hGP3bz zsi0T$lJ+ce*!GG!3zA*kWoL};ZO*&662YAv8{ldaVff~>T!PsD~r^nWY79Hi!r|kTjnED@zCZCBQ`#6bf^Y+l2jWgpJ0;H=X6k##; zm=CK=u|E=!9}~yHtVWP*tegJxl4S6|YIQhn*zfvwsuvlReL~s1j+Y(j+Yox2=<(NX z-lbQj_&;?@-rPNSDI5J+weOkuSit3@SJzR2e>K`~bxc2F$um73g%+wHE90u5A#%=d zJtG@2-0yQUAOC3CQZnW*>~rx{<>N(2lmDtk=ZC7sDD`N&>LCFel{a;jU)d1`RDz>t zG~i!U02ZD=3F55ixInaF2>{;ZVXuv>+r8}T0xknH>$@0ux0%O#Zi4j+kxj%!1s4ch zfG8cT(Dm|(Rp9`+MIewl_u3T?zc_n=NwdFMEZ*2B;9yaRN(1# zmBtcD%t13*TUK8C9KZ9L7iTcLT>OS-mVn2-uwKsY3vDoFe(3hPyNhA9YRNJLL)_6n zW6-*v@ygWnyu5hh3$}M+?;)Ei6v^$|0otLap8oAQN4O&eLXV>D`{n`6!7CzDG#a+G zw1zI?B+A2&^&g0G**oEKJA%CQ)F+Ha^jeJ1Vd{an}ki0!)m*Sqa`yH+2A9+~XI zho4{_jo2PrVMHvt*e>kpGbA#fmmNX%ClZtOlJsM%^$G*JjqHMBH52N66!v&nkhG{|sObCNc(qJqFo?IrzYufjv`e!Pt(xO1N|i2T<>z_;Qa;=yE! zvX~s4bM|L2ZJ~RZ>)96YKiT8{qobUUD$ZjWZP=hFu@jy1R0Vt%+ltEdI?Nf|W#;pm z?v-6>v}X3L`%{^y

3c7w_r|kcOvAbbzjW(j}OmLxuSUlt=MY`y`8EV@on|_ z&vyO*T8~hohZwF8g(W1jB*B5o5r(dB?EyHSd@f4E0S(7SJcE?hUC#2M&)@T8a1HUW z`);c!eU)kLpMjWuR$#j2JVsi*yp=P%ao0iR9-!y7Jfm6`I#NmX2TOi>Gl zA{dM;OXz%3`h3yp{m-Yw zWMLl+pAz*MOg?}yr=aZ^={@ox&aZFZpxL1{{QCkdzEEuHC&gsk4CFnv`Rl+pw5(k5 z|Bjhd@V`^Ob}Jr$+(2ue#)7L?$a%?|(9z25p{GRg`GPSzQ6Wg+r3;1&vBVf*piVigh~U?^c!Er&w_j z=313o5Z$gj3ijOg%v&c=X1_UR5&sR^sbghS+i~ED-IMZG`v)pz`@rvU(bo5fSAs-B z^^9m~5~Bh%ZqSWqvh9kBuh5CZepiruof_8;F;Yb)NuQ4{trm84Inel^>~gso`seKe zGh_N6jF9?UcJy-n6%zCu8PCKvu@;p7NtG3uI0-F{NNS9a{Bjcf8zVru90yNM0&-8M za@PW=0F+WJDN3A5{=^6R6i&BO z^%H%m#Up#?KWyy17|9FKx=Bik{7w8?59(%}bz387N(>p#?51G7B`Vc&i?q-QMuY4P zy~l&xp*9R6;STup33_p(L>Ce7A7)Fte)~leNKmA?_o$l(tg=&V%!GQ%#W**jlMIw$ zYTlKl$H~APQk*tMW%xnKr0|QH)%(7^pPA-ktS;mj#Vqd32-KM)8=nf= zQeN16V$E}`RYr=ekZeemhtP=zS)jHbRay(mPT{z(al_7MH)&dYu{|RkaKcR^?uox~ ztxP_G)s;WKQKNIU@Bj^uK5$B-qFg@@tSYpjDsI|h1xZ3{wH{adg5*{UX*KLB4J~+i zO)TCv_cCqFWNZ>Rh%3!h%ZiBXueQ9KEHL10Jl>Rd-!wLX0*WcaEW4^ZtB!b^F6y?a~sbp;tPu+Y*rk#J{wx4wpLpB?XC>! zgw9`tW?V-HPNZZ*QMBDK`V|k{Bf6RU?=FE8hx7X(70Qiqa}9kCiQA6Q%b)t<3Fjh*XVwD96#EPQ9+AO+4HBa7hM$EJ5`R=gs=gJC9HP}74lf5^3W0iYADe&xcS zkyhZbz9Rt!4eUjTZldX~dQx2MZm+EUlI*hl^^c~Qj->JhdW$Yj*dU^F%eNKL%cI|JhIwr5r_8O9b z5f{6lyDdC$WrxcX-yZz3GLyTMdZW2(jZ8{kpOu~N{8B5{VzuoOC!0;C!Inj$e))?H6JX(y~^`(>$qf4+I!buvu((uwn7 z$xNh^7zSvGpimdJ0vU<+NC`okoj#kf>cCr-mk(NT#GGxOX?)M1&^rQ15tyYoND-w={OO%Phaj1SF**J+$qdbwCSMDW*XAyaiX8Y>u@P~r{F$I4%#w?}nb z=ph|l9gu;Mc-QURjmzt_)Cue!MtW>$FQ_9k-bm<6c!^eXb7*{?x_n_U3ve1}R^F5_ zwA~hxKL7U{RnkLSGBjCx6m`|VqI|pC-TJ)-ecdB#hL@gc0C&1Bu4fVx z8yC2O5Gq_>F)+C$tA)z62_r{wma z5gJ6GaSH}P@VRo#%Ay_`^kL~I8qSB}5qUJaKghjIz zhi{R0EW{5!&{gmgz7xw5<5gs-u^x1>6)8mad-3Mh#RbZ4>TAJlz_uS3D8O2iJKmRq zNG*K=EJh9a)X~eJm(|%coTz0W?{V>64ut6Pcc;11JEj+D3`Hi+M=H;I@lS&qtqS`XNgZiAU=N3_ zy4m#Q)amYe&FVv}KWTDvDV^AFGkkt132<#hWUvF%$zAy{HTFJb&&HA{_|9591^QFn z+;MxXx{S>-p=V6or9V&PBQq$f;-#`idk{l6>Pp8MZ4KCZrt z5B*+ahnzbe5MA-|r30+jAUCQQ>CoZ*&P^YoW{GHCDrVxK1*M@+NK(1e`AqmtboQKk zxCn@h;%SK_&66o|<*hfyes=4n^0&6}!}ho!sUrQJv40z+d&8%dUPP>_tXqp-rShV}Db$55YNvV_@o z9#UFoM5ZHjTZR#(A{_ae(AGc9iBX};k=+3Rla(*T(yS4#Oc?)r^0(o*M&5cFNUnW+ zPrr(H+DH6{>2E*%X1~^YX``zPktE-U08uC*y6)0^7wT@9r}*JM@{#u~92d7Jy{K#a zkH`gI`u>NRB*vFaGt^|+M2Dz7%QEhqvP)_iNOCl$tG8hPuC`Hu{Ef3&DGtc~MyxWM zSnxSGx{0TOybIiZGE;mKP!{@O{?*C0bGU^l`oi*lC*KRqW>NJnFIRBkGf+%jo8JWK z8|jZaiWN=%E#OS1?gYPdW^GsL^w^WW?2kz3T}-nV?(^ihBA693*dxQXn-=6N68`H< z4%FO?H2x&oXB2Ikob=8!6(*X=(dITryng0OgcF0l5>;9eFB!2wNyj`f;rf!hM-A^L zda??;D2CuYdUyX4{imV?S$?|*|41e+`05Q(0BNdwgoe9GcHISTn}d^(Z%^(qliYt0 z4yTDF3uW$Iu=xY$mSd&|Co6zn1>JvzHJh97wiN@HJUH+l3bMmXdI zP;udL#1g9;9`V|rne_n5jGp&IATOGhPt{6)So|GJPehD^aWEv0(Q2GE+c~dSyoJh(;-@WuRn#n*W!kg zxJ6u^&jPwiXYCk!ln);tKpE1P!pfg3+ltSZO^JG0%=X#yG51XO>fp{iR{$4p1hr34 zwNL%?GE-F#CwawbgUWU4-24LFp$jY1TDa>AQ!%OgP4PA@5?)6{D}x1Mw&7LlGlmg8 z#ZsKUcoq?q3#DA$pm9?HyXO(zNeJ;81h9w_;hr`2xoDHgE&q*q!z}YpBtH^ChS%YP zUM8?_|5t*oj7YmHI$x_mt5fOxE+1(Dv>UKSE5N2qC=vJpZ+k2y=PXC`twLFb@B;HV zi^;(Ib7pP`k`>|hOr57`R~LAq4~3}%D=+ixdC*Jz^R2XE-4*fiklcCRH}B_jKUR>( zq!eS%-oAGqKb3Ur@4mJ&Q$m{VOjT1KzUz<`lK>v?*>H*7cJXF+@MIJ0cqUGhGmtq4 zKUCnhcddY%F|JOK=u4w4x_Dja-EX0HT|&!yoF_h6aMoHXwJLKStQ4(SYJxVO^-8U@ zC6&J7;uD44j*ztDlPf1nRhS5iy5qiVvo`jZH)NT;^u*UPa@XWGF%O<2E=5)t=Y)fO z!mjuBw#OrG&H=i0s>py_=aW+gZ+b}}t{nLLt#hI0ynTzXY5pS3!=%Rez zY&oBzjKSI!{kgn|(z><)o>p5#l)Ekprl_TY-`WIif!so2jvOb#d_(oYT+9yG*dQ>3 z&28{uIa2=~*H5mYCf!*^{F+oM$Q-_Bpd-jJ~%1Q7$Z;`$6hpJFxH!%!Q0xm0Md+ z{G!8O=42(w8Sq--VezXgt0EFtNFX1Byu-GSi1&=41Y}=NPN!f7eCWqI7i;^EBy#dX zyiR9uAJg>89V=*g+d{$VEEt%ZZw^HdY5z)w_9#2+^3 ze1Aptfz)*pInpOVerYJQB`suQjGTOF?Fqo*<1@7v2Av)&rIq*IZmMz6#s1u`0eJP9 zgZ=Z+VEN5!3Ae-Hu8x%*x_krs%e_-}dSXL*Vn5KjQ?k{_c11uR`)>P!nu7BtJjypy zUbL@IkGVGd<+ysDp=SV$8KK*S&U-BG^#>gPyo?Hda5Gk2K_8-WGXd+fRS)C3=%YLt zIS!0$&-SJJ2EtRrjpr&KwrL!9>FJG&CEe{I$5D#ByQgFp`1#ZjB zT-J{p(!YEjO(uhUtjRPXUn|4r$Ffr*U|;iQX$fYE-{5hctmUUs_8fE5&5|X)Af^f~ zcGBXfbNpfesv~z>E4oS@$GgD67}?-l+|fGAicbqH;0w`-Bv6;(3P=|U3ZKs+8!Pd+ zy#uX9s}X81pn>TwA2IJgwrTfz13yG~@%uYCpgJI{Ym^NK6aYaHalb_- zfUtG1j}N>1zO(fT0Zk6mqe{O6t`%m+an5n&3ezIjh^;tH5UY+FH?dB+JM0}ZM?EhT zF!-m=zJBDQX%Z~kHEsfk11HtnshYP_+wT@+hSPp*w;nwEIrhVbZW$g>qL8)ZDQDtQJfgTjx7WVbA&|?9x%_57UTT8s# zN)e(IA@NajJ_mKqRbT2)v~_aye>7cXSd;DBzc;$OyOBnakVaCFP!yy?1?iARHl({0 zP!Nz16p@mS(TH?+H%QljvAws?|9C&`+m2(quIr3noF{BG{+?6Y!!LG9MvpX`UW<*J zP{w@!LwE7wugQ^U1VN{A-KkP|LZg*D);djva|j$CieGp|*F5o|&w2Zo-s`e=mT;yJF7Mg>hUgK&OXm0}>H>LP;MnXh$3n=j z`Jk}5h^K$POnU$cb~j69(CvnVOvQ78`RlGBu4G-+r$J^I^A>m-_>%9+n$V2jV%Z7I zo7Kb*CXhB={L%5-D5MEF^FAlZkbg_7cYniZyCDKBtF9ZkZ5u+WnWXI&$6}8s(^&Ya zW81EIa;>s8pqAl?i4a73%zP|dcDy%dN(A!Ps}cRTnRwo7*~+JL$piNvuOsunn4IPt zjt$UvvSjPAL(JXH=LjGLUqkN_z_GrCD(f+|3hQta@!x56pmtY-zjMa`Posd893JRz ziM+=C7sqXIlWbyZ+Hul-l1D_yA{_Z6q-s->qwvoBA5z>i9rnyVE~{ZNo6&li zQEej`usZxY0B4F%u1uF zJc={Pn~P*_KM9H#BhyuvZ0Mo{e-XRVS*4VL4brF}?O(jP9w!KYzq#J#a11v<)g2$M z%M3zJY88zn&%`zRIPTib8U#8!TIxo^roNz&@1kR~p8{Idb(<;1ipY#u{XMx=)>aKXpArCH6m zVTHhI?Sd6~EpnN0f8V$is}Tb#ny_G#vi;le<62R@P!u#UA$T+%k$Lw(c1htTGa^8B5!rZaxIknwu!6TDDZP?gcYH)=tM4d&BbN z)j(SvfxY#@cjF4D8y|kc=i!2W7c=(d4kHqE*RxLUgY~I~#>Qk8UZ1fY8*rPQ175(L zFm9iCCvZV5Dq@9&!9*nAfd7lg2erElzWeDc%1@1g{&KOk<1NC3(e6t*N3lyNQVR)B8ds^Ys~H??}AL|Mo4X?2F3G-)u z{RJD9dW!XfI5$0H;d^Ti&UNL9RulDn;7*tYj8PQl^6BqTgWRDo54-Uv_Ar|6yWEf1 zE&k(Vb9q2@Vl=jltrpzcRGV?j8U?M}sAz)HZI(A8iQ$)MA`rZIphuYW8tZ7o{dk*) zLODW13s(LD*fvQf4C>wRG^zK&s&QTluNsmenX(M#&|_497Cwg72SFmf+D+o5=T#Rn zI6Z55hZT7F*ahGx-5kn{^iLe@@Sd_tlo*ny`qmIoy#5PFB#Ne~1FY{iVGhomz6x zx(lMM+*mhJklzVd)PFz$a{|5HZ%aP%1F95mONyI(q|J{tCALGnYU~%JI8Hne=Dx7! zzjLQ2D5GK-#OFat%+b}*TUzgL)SzPRd&4do^i>U%?t@gw_xo3Nb9WwsqOe7U#^e4m zeOqwDY6ud7g=aJSSC(EXh+Fc}15VZlZv}83O&xV#$7j^K6G*wvBm{l=y}rwU{{d=1 zQ7my>4TXsy3gkzUb26V+=Ck3hmn7je<6%|=FgA9obIPIrrP;%@e=tTexh$bJ0JQv( zqiE2=8PFV8BKr`kOuIZ5G_MW8FDNk~4FJs+vX1w_@peTUBO2{&#snP8xHm)PRgFwK zRzWm-ivdg$eERKA)3X!5gyQBJ2yvtjJz%>_jV01Z37VbTnaU6`2{p7y!VWm3tehJsZNd8&Fu4IDO8gh(~s=#LS2Vb`AO zM?u8RsdG%2BBf6MUkiZ$o{sV`6VjT<_2S3nZB-b+!`5^L8l?>=TbX2fYOHCz_}~0Z zPuPE%ZW$-%hPkhi$cnS7Yd9r2oe&SQcE7yed@&LkLr12TdWt`y8W_MUKfBs0zuJEk zBLA)7ewLgIZ}(>@)`p*4tPUKXZoX~(K6%e;Sb37&jOj|M) z@R2Gp=d=k4#=&LP5NyuYEzS&2(iHroImLhSr47NMeTNp_tdtWrjy1dUBq> zGd3>kz>(lv1NBY$uq9p)Vpu=%CuS2Td=MGmn&4tq?z7>fTV22+uBl@FQ`V3%(=gpJcO(3G%x~h6>8=aKS85 zc}$h-E#FVcw<v1Y{NN%vQ`M$#mcliSW#+MWSTD|pf6Kqq1 z%2rxK?B+mGFtuE!jhV{Ro8zLKgu_LDys!G1yYcyZAn5w;ja2OBq!0LO^%krM`e{z= zp>?f@=28;DG|>*G5@VcEhKLXe-p`>DLm%Tzgc35oZKz11yF5Z3{ zhstQ*r=IfQxWQppzXm}SuGsDeUrCm!Ahsv=sH5%2-+k1^_!7Pa*?=SH8BLTD+};EsmL7oIEs_vd0yX zb-S;L9Vff)wuk|KVnCcJxLvK_@g4dG(t&Z1 zaeOlbiugYL-Xa?IUf=^qlz#n|ZzRBF#qSquEv>}x5tOAaBVb?7k}PD-I&?h335`A2%V45jgv}*TNYW?Jj!I8u^xtFlRG&ALHa$qQ)F7EeJ*T zB#hhQ0zkyiWMYnG6$4C}M>?kb6GY7AbjwoPoJXuPrPp1h*g_z8dI4HugwM@({{=pJ zsMM<6`w%gSgNiv^Kp61n)t9m?ytZ6GJR2sfBSkmdmphs*DYNc6p@Y7D`n2m#QGCz( zYYD?81F{EG$-3MI=?~j~3CTD9eJOv1A_8GK(T6-Cb;UFem9N#8MNv{lp6L> z*uSQJ?UDV%hncX%b?Iw6z@uYV{I5L)O{HLVRO1B&5x~1y0Q`X0fvFOZ9_{1&`XLEN zZwLh)e*6NS6LDqTa@WsZpYW)U>U884iz6qT#duais~S2liO%~<$)LRUGWNmBRoX)y z=ec@3Sg)`jmwdt=zT#Lv6)Sqn|WV%EbQlv8sJUp@QIaT`I_|iCSh@zmv6_L0Y0ck zJacs5;T2B{dcy2@tPuw8=gHo3!sdrR{lhWWg!TOu`-m_8nGsfN2JR7{!TGn2LRGzH z%<8G?FT(E-ScD`#oHSr4GFHxaoyLo<7sdH&GyEmDX8aK^@Q$A_iVg66c6!i!W&D++ zb-y#!zYwajjCCfK%Nj@a3Bpc(;D$6FfgW{+tU)n9X{T9_ioodyA@kc=B~f6@kXe zbz-DEmf3x*?eHlERFgg>ZdkbR- zd0HY%ticgx@EZzmRO3H^ckF+eGOX8z7c$>Bn?OMPm4pv6KM!>;T+YTdXr($}H&7+@ zd)YQO;j7{^tqt*nh7d#av6Cv9MdMZJ*g?@KAdra%s!|GGz>&o-z$M)9jA@l`Chgq= zbLDoImO|H;v30wnL}GR)&q2>Wm_Wgzbanig%44){tlWPs(*)D~@Wtrs6SZX^L+%nH zk6ga3+x_n3zFAOZXk~SHaGfba0pdts_U`|AslnA+o}0-?yl|3*pO)0SZeX0Q`j&+Q zI=`jxs-J)Uve9a-rYwj-srhCK)RW3jCzO46GJCmh>Z@W%&3#Q4n(P?%ok`W+KUdi5 zuS6##U60~%cn}}Q%Rg|$wtJEjmrEp_(DRbn1d_b#zcNzHZeMg47aZ#S)(P9@s(IE6 zXT{+vH<;WbQiwJ~`wqY@Oq#=>To;y1Byv=vqyE0(lg)>dkQdQ@Q0d^m9mrK->3p{( zUVis|)V)Wc`!WuP+p0Q&c%XX6S&kXm*D=q6apnz`o+|4Z(^pXGn8Ca6jMM@#2c`!R zq~SkzK>8S@<3K{vd8UOZQSny(AEson^QOxqse1x?-MshE5p90e3`JYYet;`}>$!M@ zqdGRBN+0Dy+ZOO&HJgzJqJ!Ki58FkWzVj%&;D(!-x^M&9e}E^2l~w>kPLW_aLK{GE z$Kf5g$`PogQ$ck7e|aV{=h~c9I`TmIGw@UgupHQSW*?~H`mHEBtoImjW4HdwNF&Hi z61Cn3(fx+EblJhd3_n}`s_M!Ha_&C4^TNx2od_pODwwl7+fzWwEr4q8S(%ztst40y z-AhF@GD!YnTHf4qXCve8OF~Ab8&Ky@zo-oXIgnp|oVh@j6wHR8(EpsW_C88DY4b&j;qI;H$bz+6vhWJXG-3eacYHW)*<4-kNWj4GVm zZ1G-gpJ+c5O0E}0vuSTC^70(U=@rVua2KH!! zM&QKNTQ&#vO1psxyz*EBx*|byf9HxfhNj@K3rJ(AzO+|U6ZV_)aiQE-oUMD(@Z|~^ zq!joXTAc)GM_%WP!nz5m!4v&qe#85(5+Bo3q%gMdfqd2d6xCpq!T}v@?OoIB*^Fl@ zcO7s9L)A=jPt}l6XP$j_cmMM$aj!||v;8TuPqdM)4ZF2r_+pPX#{r8_*H0~9mA{4Q zO2u9q5uSVB+0GuQ!ZPMsHdeyiY4Prv@;GF}#3|jLW4`2vDs43mdjR2sSW)-RG@FK$ ziz~RP)$J@vTed!MTknZFQfm1i3twKuFaz_JjfW{Nat8+pyAB^_Q1IASGryp#N(zj$ zALCO)lS}xBVLs#7?5)HE?G(_IHDJafIGhhkO`gNQ@(Lj2(BnBJqO-!;4wJk~Og%#FI{g;P-|C2OD z7d(@t2WiHweFB2k_ajsY01$A%IubZxCQy!5cs~n7e#E!#mK>LFJ!Bb!@ruO}v%8SO zpRm8NS&e^kKeMaE?MFvMZSC@}RQ)&ipeCHTCY?J}L!EVFeAauLk4zc^c<#^6eQAwY z3rYM(sEP`iMO5)VYR93o3=0XxyI5Ot-U6pfx823sU|?YcIJF4^{nR&F?#=1`Bj(o6$PYHP^ZjrMWyQ1*CJz zILLb`1nwqr>Z~wO;>Cv1q?`fE0{TWkGotN{IC- zZj)l6g|;K7YILRIYZrs4h*)!m;-z~hhNtnibU#LT6zPMe%_xSJP=u~jq-J&yEm3+) zl)}v?LjgQ}Ui`C0N|W~mByhBH1EX&T86%R5{uvI^SV#vPfm9xBAb?3ZscWc{#4jMK z5mXDSV`X@yp6bJ$jQzip<{LEw1v8efZ1{Y0JB4Jz?}Ckwvhojbs6gLQA0LtSon^im zdG|#-7ohA@$3yI-;1myQjaN-!~1Z2^qnX$yUv^|P~ z>u6CBgVmuCr!3D3xLZj7-Nte2gP2-nu%m@ zmf1f(TuB=WCX{}=yOwb|O@$nQVIWSEZp#f0A9Q{nED_=mQr_x=1Ji)wfcCwXc1&q* ziYV2{N{+6eGAS65n>Y5na*{6>`AO$lU`#bG9cOUF>zQ()%S9YawiO&7$yWV%KbZom zT%-oi$d6b9dPNXi4%lKVAwe;|LhKy08It4rK+#Kf$PL6M3iolMT}QvY!S*!XoKWEY zN$TrQ5l&?dl>Z{Sj7Pr%eBs#GVhAnlvcIisZy=KSYX}5P)IEGr5;Me$v*m41&-rqM z$EG5>HL@gLGU~A?QAB*{8208~^(aUopw{6LGC$#@mA`azo~!OT|0}u|_`By0&N(Pf zP$RUiQ2_8|6C#1WLm&4E56)s6W;qwiri+rh0uTt>*=PXxqHUlAu-jWQx1)JB26S)w%G$I88u zHV%xE3u@23ZtYC`o1>J_8*YA{D^*#$ zq5#OH<_))yX;`pv-;jl7JHuCB(`xzd&2S{gKfy^(`%>PT!{+u-5q~LmO@{hRFop;z z+~?Vbc-dAXuL<`dSynQ&zR;Rh$H?7#V_`!%NzhZ!4#Gc?UY)raI+bc+Cz_;{I{`EN2V?F`^} zr@#WMy9q{jqrsMRrcdyAS|YZ>e@G3rTV za5I3meQx9Lv~W)LRlR(u85h&GMf*=q|~khLbW`*tPG66@?fI( z7eqA*z@1JF7t!ZT3U_k>2Q_T7$34jK2a0G~9f^}_rc`n9hhkaCcR1DAaicU^OG+kf zZ_P42{%GePvw?ut$0vi`@Zh(}qSVQK8{)R({8?hQ*rud^duFAd+1#WJxHD%`LSD^u zDq${RD>9^ufg2xWyhdjn930+!#tFa%#Hm1G&&InQM=WwS$k%Aqil_tKf4Cpx-X5sB zSAefv*bV+=kbzwg|6Ob(gQ4e?jxZpfU}|bwfAFEof`6;w3!p{98gH@&I8<=6vsUv$ zb~%d=oB7*L!X3?NV0bkzJ0u_R8}J|1>h?`wms_|1a~#3I{AIpo?2y(wa5NHQC(_if zCv(lo&u^S@*(BvXajUPP{BIQZ82PgE@dE&s8+6xRM>FqXQ=YO1v&k!hjW>9NEH?$! zoogQEmuM%CK6}M*kk1MnIQ2!vc2RyZn;V|^tkNsF6J$w(Om*+88JU<#m=H8xUDBbG z2#_Yc?c8HxbRS%QE#rbx12g*f-JFL!*3YFZ1NKS!t&sAIvrQy3t;xYHVNicU z2?GrraZ`k6-AoBTymMrKTDgx;LbN081vA;d?eYvIxSIR#p>w4ESE(=l4;I;%H{u3b z3%%VwSl^GpW?!!5#S5`)deFxci^awryKwDQN;gNj?s{fcg+xTK847QO>m zLS#pjkHJOUs$=Gq%2P%eU&C#`#ewzQ3(kb@h=76=Z3kAk@3QqY2=9M(Ta1uv@e$lq zI_5?r(-CVQri@3wu%|dJhM1p{qF@(`LemLrx@4%z?}PPQu0RC^03kP5CYRH4r;$$1 zq4-# z4cVjjZI_}xm>hOl3|h*PJ^y%a|LoQ0`@RqnIEsEq6GI+41#vD6bDcO}Ucy+?~nEAR}F=aIT$os4-K;*Gj|b6rZ6?I$fWv3l2Mf z1*Bu#vk9LwRHlya@4kgO8gt`kG_)|*^C7-WZUBtjE0LV2Nwp9ySf~XBgkc5Fn*Nsk z`QYe}FN#5|@gq7j6yg!}UR%qWFtk0A4};V+k%5J9qCM%t0-8BgZ_5($Ms%ZL*5ojz z9XvaSTC=*KD@w&HBv;VMv8Ju!>mN$+dN0?GP%@>MY9^^XBZ1dWs5y_gM4!LyqLwhG z8&Z}oq}tPgDjnVGb`A3ZJKP;QbqjK9ykpVTV^Lj{i?`g&p7P04f4-3pd0)ZjIbG{Z zR4}qc)gvf8vd75402@e($IYn32i_#$E^C~h@l=kbz~BF^JX7bAW^8?Y!2Q>=KkW$9 zO9-E`s*b-Y3}z(jXQdS8x`pz6F;{O1vk?y1zl(d zt;!MAMmU%MC?qY4y&0cjpN5zX!zZm z2A93o!Bx0`mm2Bxu1=>pIqF$Syhc@cltib;>Q#C&5UtE!i*Thj$*BFz@fSd{OccoS}X;897D{dp_+b<-XGH zA5`wbba60KNQBkv-)~h%PNr}|e_+)}YD3Q%!+CabR?vwV`|NjhUMv3QC`toW9lNc{ zx>D2=n-qMqb8=B)R~3z9+K-Ju(cQ<8t}i`8od--_|8#P?bGg3MVRyZP1CS+tv;EEq zSi9*byllSt)-}ip&u1O7qD-2lxM#$4FX8=<#yp5oedY5P&jAX`lw^H%{NIz0EOQ5n z0og5Wmg~_kEPSVS8h9_tlGUkmZ)FV1q}`Fz1VJ9V#KGsAjeZBcJxBXnIc+C}u_F#r z;)bPPjAD+4I}&ZiHif|x%~@#=7rn=^{O5xpvUdq} k2N7X-tn=?e+EmmGxjnJM zIPWTN5;)YD_UbfDYm|>T+uAn82rBTLU7p(~klPehH651Gb13N7{ z8cVn8T0-qFtyEbA-reH%!hwqu3pLXz)C$wu0?^2!rHY?R0$*kDmAL!?%1)PhG$LFh zKU#((|1KGv5RhfstxP+e~6C8PpT;_D0!kZvvE&7H?oEgA?i82 zUfb?aNab}txAQ&cqHwmZ37wbcp-V_%>+DgI(7pZANHk0BVZ0U#z%*Ifp@b>I&@bH% z>fm<(kkn2q=LK2Al9kmi!S=PKU0u|j9XuJvcwD_4`Dp1SKN5TWoRBzvtyg%~t*bmb z$G`Kf+7wEjao|6Auft;`ps;;d3htO7SjEhm`K-EydNj$bM1IPYAI+@rXNf{6c0;9H zI+vcg#(8^kVAh%Y(ahdIyib2t@nKk5r-&_qqoWK`U3Kj3@oeV3I&Sz&t9PX%fEqR+ zrZ57$CcE$qT_&QUEo;`kkY&&W(UWo54vOMtmiXko&|@e&sMCiS35oBH_@}3pzJtpS zkxDX>Fk@D!gFUZ>f}77R7?h4KGBfdbf}%e+%r69);8Z33|;~b;?VWGUc{uNtD3OmBBUF76_0)v24HqDw|J;qaFh=b zov8hw6Y4KTT#g)JIS|@+NN208&-SkM1i>9CV@-wiw-IZ&-ag7dD~eSd+*j5q+&1wE zBSQg|(Qm?VQ{)PwVBc4^q@^h#;e2x$B6c<>*s5j)2a63NL_D z+-!1BA79ZfBU&E#9&eb~S(Re?+Tfqjz zCFn1=clFUTu&6gq;M(g_z=~>fczTIsdpeQy3CxOd#=*xDk{i#0DuYj|noxru{E#DM z%Yz>TDZ)4c{_rGEAj;?lG^p5uP8ckM_e*t)VF8sENv-C#uQ|FaEm?Q?a%zq++ElPA z`LbY+RX15pQ>(PCNp&BQ`{b|zjmUtH4cVwbzkWtPNNa~(13QM#NEtuFkfN17^d2L) zJM9npeLiGdjF6ikjM?=XDm*BzU=jZ}m2M|b70xX2>m#o!h!{qfC)3d+Wf}aWSJrPx zVprzvztnbU{q|T;=`cSAx2AK_ zT@pKtE34hvcyL_yeSj95-n<3(gTD^N*;!#9_B!$Na9}zgx?XMg?g^o`{M>%c^enLu z$Mv}2Kx!$#vm&ajEH9K)z{P>_;QaM#%z=mp`$&>gxk~JjmvdvpS<9Vpj!%`auTvk* zS>f-0&z%7DSR9urK}j;R1B{HuqPDAjYo5FkkG2LshAQ2xDRnAcm$2Dx#B7iwifrdq z$l+cID<%1L?#FjEdb&pv?7Uf}R`r{2Q;><~3~dJ%Id*$Y2t%(2+DdkiXQeG{W~~0y zvFSqU^w|9A54ZRB)ZGg4ssmWemTt%qr~x?{zjYbj?-%RAECg1Xcb~_d*vsO-JpzS>?;Nn_qk(wIE2a!3;sY936=gor0`(;Y8_BnpkL|aP{0r}C6r4jrwN607oYhQX= z-gV%SSzrDfa!3Dteot>uM#kRn%3i5s2zLGC$5J`Pkm3!qt5qfT2hZnWzcqVJufl#z z?2$;)Ke!V^9`qRH9B`>>~MB5{-nOVevQ6c9i zlca$=lGfMW>g0&tpRNVjy#Jtt=Rc6@`3F0h1M&=eBFA~dTU{QuVij60sM()DOd zR;zkW8!l(Sf^C}>hdT-g^*T^3g`-|gECY!d2f%`TSzFHQxw7Mg$|w;5cX$YX+);94BUh2angg@R) z-;;8*_XQIWn3$L3#gNKOBXSK_MFY_*4x=x2@d(U0pgQ+rVG4R;(O&Nze5wqP*>Owz?miOLkPTuZmr z)eko2EqCJ_OVdzBuc8s!*IjO$2BisW$O=2Z+iGL+ppBUCeA-I%Vq#)Zcs0&#-2-HK zwY6l1)Okhb8ik{w5A_-7M9J1RrWV`X7H5Ye&Kz>lwj|9xDANHk(|DwZ>uz%6v6(No~0DuS0^!&~AAPq!l zjh~sMm3a<_cdb$#i{B|?%8Cx^Q2TTE?Um|7?EoKw5Hox&tE_t*fM@XzD(Pb{K55d{ zV>RMjzAZ}Ze*a$!Txm`Rlz8-5j03m{*)q{oMS5#=WiDM0GNqRMl(nQQ6idwGkfoXy+&}YB1i-?Yr0}g>`;)9})ipib(ZZG zO9}S+;++qiMwtWaGefTnD1x{+tSvK?a-(sXnfGU9c8v#Z{?3mG8FKqsk7=N;zzYj* z#Wka6W;Pmml7jRa6ju}vIZgj*y}rxO82|NJm6or|;;U&nZXi4) zTXzdQ84J4Ek3C-QNVGlwRL%e4VN{;Mk3+DGG#6MIpAr2RB91Qb*w*^%Pr((KpUWOV zDn-B3aG^Y1CC;7mTH~l-J>qo7wX@~@A*D@JSEBCdS-$~Ax$(a7{dY(wI{_%h?C*;B z%l|3~UU3?V+$T4xoIn!Cr4~lhLQ*BSeDn?@`@YV(v)^so-#(~O{VNUTDqcctUOsGY zs~`SQAw$T=Z7lyqDRKB9*=ILdeRXU|Rq14_FtHf!uQ?aHjPNW)DR*n_|^c zS-fZS9(d?3@Fu{H*VtB83;U4glfFlL(u>`4Y(a4v`N^_db%s5^ll8?t&m`dDMy_UY zAsbG^5|=(Jh)SRB-loq9 zclTCJ(lGp1;p0$Qs?@7~ha&kMaMks;#2%AgTE+5l-+x}CQ8DEDxBtK5;orkhc;xu-+2V&H8b@*%T14Cz1)Vb0V2b}J%}MyC)lHwP_L zUM5Psj^0Kk_vZb#9?n-d%Vq~3_%lz}(t*;w?)0s}5D_x`w&RtH{b_U?-g4GjIB z9~KBmXlSVN$JaX8tLuUJv($40e^{^`z2o8%^2`NdgCL=|+AVN{&rFf*3b13or5-DE z@1?kuVb`RuQfua+bH}91oCmsnqu(D(*##-T%e6J(o&HYwCHiq#+KYFUN-H~>B3Jq) zH|c}D$`R;VQ_hvVBUJ4~O{!;Omrvto*Ltm_n0s9|7Bx0pvF3b#*4fW;tfy*V{#yAF ze#~4y^>YI@gu3PHON`PL`f$Z*NHP8~x8(@EowW*_og5K3;rJ-* zip)wq-;%C9Ivk0oJAWgTWP>8k>Y;DG|L*p|1HbbRRswltWrujzxVYsWV_4IuW!nCa z5_l>p(`Ao$RNVB*7zcP27b~a`elCJOr29P+BOaX|^EQ^-+)O+cl)*NI>^stPb5TvP z8I8Mhe?E6w9d>Y|Uw?G%cx}eIr-ml#5A{(Tud&R{!Rzmsf}?JhtjQ8zhyP0%KXHWC z=bqoYVp~1i!Xbb5$Sgb^8%T}CWfv{l(IMy9Vej|?4GGQl1-E!fY+X|VS3G+Q`dey; zMBkMrMC_zBiP^m}>eEP7l$``u0th_&VfiDi(Wylqpi8~!q+8Ae5kS*&dv1TU&P8TB z^3Gr2wY9!J1DOJfpLPBOU&LG{@ry!ZIqc9Gf)Z;to|o70o;d@9O1-%T%uN7S%_d|1Ze9*pSO#61 zS@rlL&b>S3yAQsE`Z>+{G#y_^1=ZN&@7H{G9*;n%xvV#RlA{gVws^z0>O=IAZh=%Z zNAD1!$q{vPeiabV80k0;TdgO97DDfzSEDsp^lFROT~FX+_8q zS62%K=`)M-K0DhGr17F9nr|zGTSpx4c^v$eZ9?o@{9TeR=>Dz+yGy2%z8Hd6BOiA& z_4C0uY7XKDMgf1eOO1w~h}f*}(p&l;vNT<9{%a?~B=QkXKkr*kf#X{Q3Y6wB-rVR{ z7EEnZgCWz~YN&WG-@w~m*^jqA#p&PX2D}T`1fcq81^KTm|L}&ov~9KZ*H0xFb5o&0J-d7lugqaN}}%ar(7HTgVGUl z9qa>>h_2Z5_iT#HIM%lx9p6a;|(?rjcn&>J{Y zdm~%yJ~z|Ai#deMIf@U~qy1Qe;jK8sb|STLd(Kk>gCXu6VOwVe$={#$0RxOn~L)eRfs#JIdg zXHGpz<3BF}a9SF+)}K|G?%&%_|1LG+A%f3oY}mNJS)Ir|5&7VbnLYm(4}_ivMB<+& zKHM&SKQd>gLLGrzJ$sG{*bDT#xlQ!g?U$`+vC1mkFx7oGEjw#+7@1d~bTy~GdVbsx z1xsKbra6vm{u#e)_Sb$dR!U;?eCV4Kn>}gVnj(leu3i6^45k>LP(bciORGVBC4s*2 z>Zw|M+>^p?8j_^x_o7ehwV`9s2VvW)_y%topIE=w33M!IYCQo4em)>JIQ_tdJM14C zeEZ|n-qLQ3ag?rDRqkGr(}IJP2Wp)m$m5y@wR&D#;d(9*baPd7yq-^HyMmeud zy#>+Sg(jJ$Wdm7Ghu=zD0>?R=m|j!APrfQdm_ys_$BBq?K2IWUZCtyAj4u3-bvciR z>W|IowiA2AXV3q25pCPO9KV>J`Zk6oDOJ9tvJ6^r0)-eY2^)QB-Skj;AbEMVBV`e^3hEpo$cu{&YNckSdz>%{!ydi`*CFUE|PjvHmV zkWgSXKA3_o$ePX|J|6nz6-^}T^OgBPUrAj3#EnYV{QUGMV*heH6{I1aLqq{TKXbDF z0(@)coc-{=8I2n?{qfb76mq|N3c*9bZgJJVYlw5{y0HsBJ+^>U4AP z-yQk0K}oL~&o5H{mIJ+9=(bE|d5sGsL_3l+Mv|`j<{Wk(`s{aY1zxPR^CUm8?(0a* zE$SRznv3Ko1pnt`JmF-sbg>)-SLW38w6W{?xiB=iwY1Pb@WG>bxDX%MmYjM>$Z|m>Od#ewlMfb?Z<$Rc0Twgc zDr6;GoWFFZUkUv~g}TpzRycu%pm=(i7h*2t9LJ#33V zULB*tW067Iz`^r+uulQM8iX|9T~PxJ>%CSuzcDYcp%0NXy~`@!+Canb2 zxA#hOYe%sLWl33XpooA|izdu5X_kWT;&gb23Obfj^<|-4ds+2I${oI*lr;%G)FZRc zQK*6Cb6@8FnhKw`e@(>{)n~1y=go5tKnHp}ACht%7B?0gqlN|e_dzQ!ypP#gL>Q_s zUXH2)6(7H0E%@+>E9Y8zvsAC z2}ZMLT-IKj9Y|^A??6S{pBekAB;K?+0YobsLEE(8VFS?+>{LC-V-@@2a3MbQCeol( z??opZ>*mr9^f@g9&we%${lh8`%8c{ zB1geE8W1@^|U}x`z1v|Qi`9Ph<@!_y{%1=50GJc*_JB1;mOo)aK_e2>~dvB z%{`=$P5~iqT2S>myQ}ARgP}CzCE(I>O%fw6e>sL5wEvOssJ%+xrsLCuDR=VGa8WNV zSV(GU^tfOB5!2}58+MSKP{^IUzzZQKGD+gN72hh>(_KbZSEL-?{HIwLTW$a*~}v8dfPc zDr%bH?eao?Zc^p%qg8pD)v{Ur1f<#A8%}hM*Kqf2eRg$l`u`~F8G?Vgq91oX*{{m6 zmJ{v~G@B1`uvnC3WUnqF982ff*{Ph?@5yEJB7*QT_~Ju;RZwG@v`i^2SSe!OorP=fpi)H(>SxYyGa9oS=k6rKQ;L(=D66?rOi| zdcLFO>zfMqMHi5XESCNRLPsXvOKvghne|44)j!nm{%_ls>61i($wzUxdT$4$X{WmBiisr?&K++m})|3cr2$~dJMYvq=%58T%z`qLf&fnu_2JkX1xut8pW z9oFUe?7AK{q2PCY9CqS|iY-H?okgEA((ZTw~8)D-K&3}naBfl^; z7_gz1)mFkYD4TG<9>3FsS(K9rSl1dQ>wF9-C!^V;+z;Pg+N^Ej{rlt~;~qx6V_A>3Uv`@8vw1GF3X1E}sj`Qw}5}OZ*u69}Y>>Kn(#j{gBlOxMF*M=(q&1 zGcaC5ASwi3ri5m^d=B5I-{E>2@`nN{%^kbP~Y$U5c zwoaOmN?}oopL(kBT*`4doFe7J;?QX3ymQTa`==Tt*dfzY%@eNqBM#tR^Nz^06>EkZPK{T07Jn%FZOi8>)Uk#$l2#!%4_|>zB}{G<5;mn@m*mBLm8)5Bi7xYF0S1d`3wG~)p# z^(T5k`&VUl1Gi3M_6O!_hWHeEpUFAI_I;i#z7!!e>h{l$_|kW8(uN!;)Z*cM0mpx$ zN!$sU?Y-|&A=65UlT`0>m2`-FT#!4r(&ZtfI+5xX^E?iXh6tJd!Urp|z6mM6pj>yW zDJEucnB=Hj8U)zv|H$>HxBAN$%=ZOJa!B=i)xp>7DSBUr8noCMu*GRb%t8J@KCG=x zrRf@N55VW>L|W70oxp)SOvk^mm?~Z`+-~oe{-&a`es`oJDi27Sxq!J$T;7u=e{Bsc zr5$Q#A4VlDg5V-Kwl3H0HyMr-k1SblT(;mkmO!7w$BS=23K`t$-L+n9x-vm{P))kc z$KepsapFTkPS-P~7cu%owRxoT;BDklN$K3taZw{kckxJOJ{sO2Vf@IAJ*tlWysofy z{V4k=HTqEPI`w{d^X+$`$lpwcxKb+C_oETj@sIpI3LOu9+hg@2{l{3XUlm?{Q2D`St=K8z$JqTz@fUkLZ!5AY)j{iNW9x+fA5B*s6;=Cn?+i8c5E4=|gn)E6jFcc!1|c9IsWeE( zj7WDVf^-R}h%`tFNJ~q1hjiD>H~9X(wOB0vg5lohoU_l~`RDVVgVe_2fm+){>GohycR&uV9>~^-B`mY%;6lGoQ{RzSJ^EdY~TkPgPNtA7E#h<>!-sKNtbIvOf;;2?99g=t!Q{nV=2#&#r0;4je}0S_jq zhWM*WeASK)A!%`JUvulXwZ^o>wrH7Bgh!cn^bx^5*3W-jR!7wRYW!u$7{?2Oj|$ef zcXH8hKwk~3LD*%hEfKdoBh&%~m9@DQ^9!P|SqpGJ`1`@jZR-B`1=`8wDss4R^fULu zvaJ7X9?F&t^8`S>ZIgi*-*0iMt*WRjc3|GU+c^(_U4(a#kDy>rNd`yyOLJAp(XqRp?ziq-Yu!&zr&kN76mSiyNmP+I)W ztKt~zFTquml{J%p0x2d2^9l_80oF&0x*o-PM%gqj0c&jawYs+(A_4xWx5 zq^aKzzSWKF0IY4MUY8oWVH*0XdkZlpUfb#0s}!T$56CY)y`x{w9Cb4+ z53jx#|7M7<)uR3F$4k$$JcS~QQ)^R=#gfx8p=r~q^546b;YckLyHu??)rY9ro~LmnglmsbAyDx2XPn?qnErj7-O?31e3? zank&MFTg??4+T%muWQy0Iw+i#1l;BlRa&acDD4F}HSFWJcXSM0jvq`+O-25(8#SK^ ziLTk&c^dX$(fC0;>{>3|R#aa1myIv^e5GfVMaRxHRx=XDI;q}$P}rAu>w9B)9(jcR z!UfbGX9Zu`g!xm%RxC{#-Zhx=ynhkxgV%6vC?md@Ioz(Ya~NaT7NPEa?bdk}<#Wx{ zA$OC$_vdeXiVS$wilQjqYM)U))|Ri7VCg9H?iVNvzt8egddj$2SQfJGk_$L^nZ)x3 z1`z+6ye@pw(&Ft_dXDzptL%_i$gcb%=;WvXgs7HtpdBiy$m?Mt78beK2!+Nl$%if7 zC&M6CFV%r%sgVa=^!mu;vCtazF|0=!4`F3HbS>%VQvJ zPTi1NC0S%3_HyT0hz;|zSWfYh_Of5ZIz&qGMNJblmi0`zDPDR~1pFqFvALn-i{tT1 zXN%+JmBv|+)xHK&0ly_Y`^kzM{f2sCV~OtfC)jng^*0L+Y+MSX3cGFxLO&K zF|k!hl!%R1!BU_W+N$YrO`v(Ra?1ttgS5tN#YFKPBzfVI<|SP-2sNBGw}M?^HeJF$czbcHNP%Y1W!DZ|-UTy{lpkJnN5V4E~m3O|p&= z@XjR7g0VUI6UK+{uY4DG7lgL{ixCPF2xvGSrgJrM55mO`ULFzP!hQXoYha?Pb)Pk|5chR>AlExr`^G~7Uu}*ezWOb;o1g6 z@J$4N4;%a55B+Rd0mfPLGC_nkevhNv_60?H8cVV~0`%mt&=J-ca=H?Jn z0L~DQioGOZg`-^mY6UN`bIgh~5$Lm)uIt=Al1{tf!AA90uF8P=5nl#!>Jgw%jpF;; z6m~ktJKRVB$|($bgML0;ZZDKE?#GfbUPHw5fnPbFG5gOd7H(h}#GCIOj1KCoQXS`q zri;ria7Y?@5trZehgomNndxkzwtO%P`kY+1=;)3HFd2Bp3C7kAC@VrSWJ4HbK*2%H zTA;OC(Mt$Z`qPRqlKCb(4z(N&Ir7i+8kM3R)K>ojd+WM&j~nRpg9uCIJTRsWn!J6Y zHS0zjug8q+F(`y(hl3+tTW?RSj*Is{5F{iS>QB}ilP^#Xn!iXJ-EvP;IOV|F*Q3d2 zk=oImx4e?k5*F**+pP_!#qAAW#^%wLTZ0OMS;|?i)Er$`Z3nT>a^Jk|&@$f&%{0HX z@pak!>pk)+@aWJW!GB@baO%oT(5%U_Uk#iuJWli~g6bqBfwQi19AAud3wUC)QY>!ANQP7mMli9B_s7Fe|>~ zUk3jIe|#S%>n;#BE4JYyB3xvol_phEssD2yvOatbmPrLmvXY62s8T9n;9V z9mD)pK_YPcRVib3!4oVv!3xOcy9-oaTTA`>Q|Xu3+QBih<*r8F#5~I)(}E`U!f>4H zD?cT_mgs6yzgoFUH0+M6H*RsNOf>a;kT*w{8F@y_dXgTa9e5V`(b~wDWweyKaF-eR zUt_jGVX_PI^748JIzX1;1q0^_`@MDoYv#8&h zlzh&}+**|$x{uz;#To|Wb522&7Z|; z7<*e!7N$_;Haam=uX?IsX7k3D>*Oy|@)bCi?j`(8FZHWTOBw5v#&bQ9gyOhhzW^9% z^jcIn+V<>+CLq{_RD2-T(m!0hv1kBcpEr)bb}h;ikP>Vo*f`eDQ4yw5%^)A^52-x_ z$6Datqx2uJ4x?8}6#^V!WCPYhbT*4Wl$rz_4sFrsfjaHJ@|sZPT7ysh!H~FV*JW;8 zSX<&NcQE!E#`d*L|A_QV`_bK0|1{>C1*WR2hiJLwTrM*;{NIEvC@ zyna0>>zV!Jl;%B1XViVB^=FWQP029tR~ba0mnNDdg2}Zr_;Sbw?a6j-STmiGEAK5( z%|{|l-1($kOYBO0sIo}{|Fv;)8t0u3en=f9F8g4AoV072%b`{;DgvD5Ci>AKtyVHn z#h4s9eWD|yGtWoi7(xS@gH*m zC~Vj9^;v@|`<_u9S+&6P9NdIQbTA?-ucqWJ>$>P+)8{QG=>(+?9Z<3i$>=W@OSaX| zbe;$JHwT&h2roBo{Z?XC;E+wF^WY<=5?Z89Ix|`8n9MkiwYtJsTXf# zo!+(;6iBBO0z-xrLd~qWulc~=-!1d_9@K4TEE;?3JuY+FpHEe0ky6f#qg%O_*p3%= z&t$i)v@m9*@5uksQR=@=9AqBW_<%fVE`ULNu8tasnSD;eGK+OVSOxL;l$!kn_ohma zV^wJ&91K~$@D!>Jg!FL7O-!HX&AAPKI2e(MrbEEw>1cUGCS9go(tlLkAN$YnwnZ13eZc^wAdE(c@+e@nEO+_2o656w&tShGuY8-77~( z6N7YMIW2##-WMh8Ww_9Y-UkU<>i(`}!Sxu#WQjT@aRQRIR4dj>)ky~K>rYEjHChe* zo0IcXloDw(wQ&c{gym6RUzEDaYnWVhdSmh7|A2Mqd$rh z3lPKnUn!!_4+bltaqp-p!MyIm>=}*FXF1?ck4e5mK#McRNj==!D!0Vu4xY7@b`t>n zAHW7Vz#^S2JSfFZwJRXh3W&4J_)MX;qr}aRqQuC${G8S7m1?&mWt4QMAka2#A1}fw zG?5CeF>FO(6pxONvyJ%+%(rDp?QEdR2H)!XkDIkY32DNDd&xNJ87lOjXR(fsoxg^D zdq2goE{$!$gvLS*3dA(cMg!034~d3z*Wc2J`io^M9Z#o&;Hw9=9mTDWVy`o=C&>4) zyW3tkJL@RZ;ewv=O_b#;6A3Z3F{DQ|4VMv(?WR9X7Tt`Aj#;>N*xhJCc8vvB3$%CF z?f#NGoelNXD{f!R*GTlH3Q{1#!Q#UFM`4fXSc&LgMbl`dHH2-~ky~8$DM|WVXhcQp z4?d{B$_i3YT6S2Tg$zrCaqjA9UFyz}vOf5LXUqB~LQODSp-em?E`Uc}BKFp;TQ%1G z(&GA;b`P&qe(!W*#0XD4NA{m%{SQVs{|r*}LWC4Rva%>jckLtZ%}ZJQ^_m!@p8I!v z+Woa+#z|a8nbc@eB*+7fQpM4sfZ-cp=Ml~B#r0*fUosYvp3iXOtH=72#2~ycIDYo? z;~<8}wZoYOJ`w2RtEL=V zllY994S*ys^wT3Stp+Z*T^Wtj-YmJ55k?KFcv#&(7fz)HTs_Y^mm%A zv2Q=8rQAlOLf-7{-OpB=r^N&1#AQ#!xa_g^e*#i&|XIH!)f zF5e}1=k*i!zgvN8oQZ+%-Kwj{BneU9!PXyz%nB{y4bREm$?vBhlqzgM`~Bm5I&+hs zhUJzowhwN+M@esP6eCAH$#5erst1L2r4}P8Xe&@fkycJ5JJE>47o3ZpPc)9{+lh^q zwMhhAM)Y89)7vQlF|U{_?oIsyS~H~NKQVb?_x464oDU~~q1sK9_?Fbb+ECfWYadf? zDI3{s{gR?^u(z_pExd}DM=tkHz9{3U8gX7vnHq?k-ep_Zd3f=YlLD`~{4mi_I6jPT zv6~%ZMZ%^Z>T))4PdFgb`+!9qEwvW7t^t1=he51}0YjDnkAUy-0oGTV-Gd7S!Ai3R z<4sO1%>GBZf}^9W_wGPQ0)cz1xR7h}R~mc=u>Mpb7>OcwJBMg0Dal~~Bk4|C`%jsH zDG3z%fno7VY(hRIc5-2@Bx>QXwV>3$U-z$^&u!X}`!@p>922{&*jpJjr~&v^PK4H( zRI$cpAs>hooCz;5iNhE#?y~RYm2k%eG(1lVnoDb&n{AiMkTux!y2&qF|AZF_8D4hw zYM%pPK{s`304Sy z(MJ(nTE&q?y)fdWqm`$^Ibe)u4Oa3l_Qle=WtN0k=To@XU&;{qOS(0F(_aU{Z)-d^ zWJhlEr8PM_1VMGRq}2QkG5{+@1`UE^(nfu_BEa#BQ;)m)8p+@4Yqz2ePu3w&I z*JDJY>iKgX5#r#yrDI_D^-Dv4&y$6zBj>z&A^sOJH27y!tV0=HvH1Q}zxKlW*b@uV zHYqX^5|~j2_G_f@4>*m9Et=h;4Vw>7bU*0b1qzPjB6;4AjPf0v9VC^ z!_{oPFE18boJKI(LX13kH z8X5(OW4O@Xmh42HKKIOZED)dZx)iZ+J)L^0jL=`5`o{`pdW72(B@C%2Woc5(P%;P?XRlO}urs7{P} zu0n;dMEy*piYNie5Z@rZ7JwrZ=ILw#8otsYo(rbGK(Y6*tHT|3DM6M83LE8o<2M)W&djMds5(&$Jn!~F0aA49IWG#;o)Xt(K;V(nhTff^S_**Ii z`s*0WE@V=eR{GJFd--ym?Ynyvx-UMrnT~j*bv&d(8fBiSPULi5fqibIX_>9`ngAk;po}t^Q~m6FWaJv5+Dg%#D2t1hGcI8sUWXX5&LJlW44h1(2BeNpOhc zT>g{l#0zv33`d4j0k_=+a?@(96Cer2=}?&)%waU>bDh$$Fg^BOj2fmBFWR{jCkuF>cL<^=YQF@6*b? zKA&0($BuhxlHN!x)7{^pe`7R1N!>io~zLU&XQm#lTZ{Xp9(@7@d*u_Vc zEZnET1wG$iyYs@om_ur<=6Ge_e}j*n93EX!4Y5EEGKuh9uQAJBVZCgyu%={f^@~<6 zWp0vRSFSOxwP|5E2X7YUxqguRgq?{$N_+Vt!T-_o!X7ez^}2TmhHD)-A|v!O&sOr{ z8`ZG#rN+^`CR@3>YK3CA-{Htm@xH3`o!AXlEU|rnCAJrC)*)bZ1_Z=x6gvW#2n84V zhi_1V6WaRc&_Fx>rD7Z9Qgd~F|*$B>ss z=~GLBDzJJ$0#rJvl0vyrHf*4w^KQ0t81veL}Yl;ka=ww>ZuW2T{=Fm=`EN zDH~N$lnHLuVbUrNOaqjs7Dt5_m!Y;9t{wiP6g!@A9*&5UV$TKJ$DNc36rNwdf#z;u zT)$9^z!)<6C_yk1ES`p#vnvk2bqwFP5B9rba8bd%C~sn-wyU7ADiZz)J4O5C0U?qR zmrLaZA(mfRBpTg_B|5<9)(767==!9 zDPFj3nh-2HRhnjL?$jIznzS|9BC)kWg7k)rUC3@_?^gNvkmELDRHXhQ(U1l<6|vYw z2%7YM4Fv;i+CXK&$JY$E5L-Wfp`N@QkUR5c#qPVKQz&5J-j|R?NBFt1vp38){4C-! zld?YCp$fFB!~3cW+LZkp4h;KjDvXhQ@_Ysz#wvG#XQ2^=3ApYn5MAhpgAlk zxqZ0X3xjiKRs3NKn(Dwbff>VvOOB(Q4>5-l#Rn(&!Zc3m+LlK#Mtp|KphuY%Je${J zQ-+Zo6iC5Q%ws56^MnudPfW7&OdBhE#16QW+@=5Ys#nx9y4 z>D)ghur$v!mP3K|vb6;$_$XlHUU78aX`~9?`cfY)8MRAh5F~5!%Of{##BIE+aN)Es zU$1jG;1}ISnSJDm%w7-r@<}zGpe`IC5b1NyLHq+*lW>5L<;NZ8={3<26N-^GCBB9M zVRaMkyYP3}n-Uth&7${Awc^p54VcBpy)N&Rflg=4BW^{y5MV7V2f_>0rR6rZ?9&`^ zf3yQTq$%rXawiVP^!VKA;#{fNjXE{;4;??y$*6mKMazbET$Ht|zfKY#OFx^ssFEn7 z^~GlAg+aW3uW><@V$snqB+Uwx{`WTx97rAwdh@JgCg}Rhg~tMd!p~h=mPzOq2r^h; zDPKp8>LsiZ$|RIBgQZ;MJ7)>t0PwW~#^Gro#`V=O4D$oKd|D*FBA2zT5)}<(Hy`xkcU4z}Hc z{)@TwD0K*^&lY&;Gnhw^0|zbay6k+S^uqMvI>gJo5kmVjgy&7DWhuJ-g#kGCSR*-<#H*i`xGYHq8`=e zDUSQ&qVU?&^1#HJg=%3<`%ZCCWa$(b=Je>^yT~0d0`gro;m^-^Bc7}#p9B#B_oag| zcI3F<|2uYrS%G8kP|0ph=b`(095BulIq@Re)t4a$4|^aeL8#p@;W=%ls}!Qp z18>inO+?{UObX>QtSf~A1Y)Zbz@0Fm@k;Y7c^wZ3I+$1HCi>`mD$@x<>cq+1WFOJR z%_7Ht5k+5hTs*_HEYG=5?FuN#_D2mob+xPcG2>+C^yz`g8*y}bvOZYMIqHOs56$PCbtq_Fof8{c!#{x7GkGUGDAZ#Bfa^ocyEvt$IqIL=fi)Ad$Df!k zFEBeFXx6KEw`=6dzW7IrGPEdDlInz=X-6E{Y$J=fG z_rm_o;4mk)YVzU6RY@rV25*AiByrNy-ur(qKnA}Ej^w!3j zP*(TKf;~0r=-^9JZ6m%BKb4>x9#<@u-Bza7Sq#$SUwe~S`1U9`v$mTr9N4BHn9vY; zZ1#OFk#}E9L-7G&(-rfb*;lIQ{qL=57VTNMG%5D+{IzCkRS?U?6w<(ECe0UY`QjyI zs)aH$mg%DyHjS@EUWl$*YMyncP+dojs{$&&$H`m>v{WTwaj*LFaZ8`O+&*W+!-LQs z><|e#Il;daAtYwmY5LPTSuqEp(O`E6ccAL%S6$};u;o?x_L+><>SzjfPo_HhD=RAc zh%+c-QqMA785H;9_PIC&&jddXRQ*n4sD$=Y&Re}dWydUh{aa2n^|*GkFWcM1QNjd> zca+GDQoZF&&CS6dR%TkH={(#Of=MA)J+(HLFR&ME9JULiox?#Y^+#km8AXYlByld5 zVKvrMiqcFiiqhRO%_bd7Z7UPrhJVl%IUyx8dJcnugC537a0{#$BaDeg8z4D#JL5 znvD+y!hAepsD<>I^4VL{34jyV2Ay*Ct!GpqSNU4nb$Zlt8ZQOdk_`AEZxT|#LoQ~q zw~v|m`D06QafKZ0%A2C^5|vFI+ybltv3!_GzLgI=uq#T0@W?O1QKd$aK7h^VDUfY>pxW3{e&d*No_g#etHXiA z&S}wBiW30^D+B3ctAZ%uQd?0B#7%7JZ|l=HJ*)o zY@)*9rXNj#kJm?6l0=-~HtOf!3IHh<>~7XM!;kqHK1DCRq#bq#=~o$t!-y+!TWh#m z1V_-T&dSkozSE@Df>{}ctf(U9!>}JJ_59jPs}-=Fx3Hv+P^DQ$J3Yazx%k&g+NeABc$XC_&G) zzrVirMxd?OUow$upC)^E+DH*4h7psc|DA%!-HSH{`ou0O@Fg5{e*RSKc36T1qLSR2 zsc-e#NEaAaie2;>5zT+g%`Dfu@3d~e7LNRI?Slm=2LGkjlu*^xAGRL9gMmT2p{!hJ zT;*^!-*Ka+#uLOOxxR(E3LtjJQ2C?UZoo&FpeDpt6%^*|Pw8(4zkazWf0qo#an8%Z zt#SaY&mtf7+Zypwn4Rn$2g!19;}>eXmdzd_9bmg#D0u;wG{#hjuF-PL3sj zT>a@$jO9Y)Db7g6D54e6d{RCh4IEK!lVn;zyV^_Ro@5aPXM=bd%j_+q2U@o+_9V43 zaT@SyGiyAMDbJ5ce)f1xIC$`#ioLWU#&~jIhNo;g3S#GAXVa3}OLTnIEW`bpUlLQO zeCrlx1N?bYgjTA`tKBE}+ORcj=??0K?3De+=ZFt)9@6eu0f|6wWl>qoL}E?N34DMz z<6AtCa2Mz>2T10i&thM7rAH{T4ha*S>;A6m#DPs=snyAMM#{K`@(hTQ2F}ajh$136 za~P%PK@I74W3R`^8#>B_Vr4wVuYX+92W&chLZa5vG6z{IE`F>d9E?8D*)HW9fm*(& z-oGM_3$T;XzN#zTSioksfBGMG64We-2$a(~ngl&h3y>xTjl8qEmerBH3xls0aYsS` zxn2bm1#K_kVRYxnVVP)~D#0UC9HJms%H(vN&%|^Cu zNqw|y7_GlnD-1y#1T)GpoIZ`amsY71^w((8s^_KuT8D*r761(kwdep?Bc`N)TLhLlbc7_nhW_?PF(zjdV&DmW!C+iG3uQa(0L$uOkQ|< zBeGtTBugM9#THP)RSP50B(f#K4YW_z1@az}CDo%+dw?ThVXfMS02ZXpiGeIauPcxO4I=UAx`?q5~!eAcAi?H1nnb|5t;*l$B8P>)+-S%I)`rB+z0alyYYLsoJL$1n3%Wq>>Z3M*o-)=$u)%Whj zDmZdS&x8@)yzrHXE1UYmM``mub3rva{SBi3Isf#0M!9}?|8D_LJ%`(;}f1=paIOfE|Bmr zQuwJ+g_zv679HUgd%QCQXX7AnIr%ChF41qd3A^ULe`z!%I(cwSkO)WgW9j>|yTl`r zedX*%Rk^rhtF>bgse-E4l#V_F4hxuX%gATGTQ%w_vIK`|>C2fJ62*4s8GX-p_F3Cz zZmJP>$>D#Xr<|(X00LD>G-XCO-0Hq%HW`=q))2eKiUM|Q>3UEd&`X1dkjrwd$3D2t z<7$2!SUjMt6US+d{S4$N)y4b)*d^TI*d3EZd$Hrh6l+8x3dY`v;`D+nhK|I%3RE4Y zE>3}ZSBJ;-q1fL0`B~E|8~C31Zj;=EX(OH4KNKA|UgUE*EadrW%W=12=^r5DgZ%g0 z9D5bv2tLZyX_Kq-3!z4H+Y2W?mB-O$>V{#-M*)fgl{l7e-JWv}Eip_w$s4cvD zwa1bPF1mFp_C}kZ>|W0_6ku4Z1*-X8wA%N3pIA-#l~y$jFu?1@opR*jZ+j*(EE!8T z=1s{a9LW~1Syo$-n(8gLOFfJ=ViW~u87Ih7xUk%M0NC<)%C*KE^tx#W*a-LIH}rRv zJ87T`2qCNGpBlINW9TX7*)cJ5n#V?47bYw1Qj)6!=SIor{^e6y9@E=yah}_UXrwS+ z9kvN!9wU+mH)GRZd!V29M@418SuTknjG}Y4@}{z zC5UG#wX%Nw0{MkAgNP_(91$)jA^&pbp_c-D?^_%4LWej3V?30u^qH6n!>^9~92)+eFbw(Pkcz@-B+qe$;?o;?o#<1z*#^oubGU_lc!gPV|rT(E00UvP% z;Y{8=z_j^=VM|HNWzqL}O8j0aHg{27&_->To8a2`lC`qLGRr__2SSb$@u1seSyCfl zM)6I4+PKHcLRMSqx8nY=XL-EkqKFfxfZOid@c=6N%BTU2r*;|Tb6G6zN?JqyAF@jP zFKI~7{@~cMb~`xm^v}V5x@Cy*TH-Bg>c}w_;8BwSH6S8CT=mi*V9g2u#;UOEO4lk% z0$Wgw1Yt~U({n%4V2K2%hsB`;LlEGckuaSLKh}bnLMvR>^F5Vonjt3hs5#m~N6uyp zv!=>o>+v+Z%$)7aaPeUeW6M4B1BIuHbLR_bMS{q|I!-k9gjeHV@!#~@5(35oeJZJ~ zCxH&*{IBL7jiqdSjDlT{IVgQ`^1%qRE1hmyQN?U1t1vW;a>B*=ozi|Uy^Q1JToCG4 zml1f7badF27Ks!(MWqG}nE;CC>283KgQmS@CZV0w*sg9vbbjwD$g?uP-{iTep3E|R zh3s740MejSVPi^`^W0uW?wDr374J(iH~QqW(sHJ{c?2eQ|HdB7yhrix^C>J7Pd?-& zUmunCH%xo=1WR(*aVBgE9e}mdF{;$S2MzGwE?~G4Y|KaC%#SmmrGGkJpo=RjN4t@Z zYuMy8{>VRN0qtt9?*GxIc?W)6^Hj%D3OGg+fV^p_JH)y^3zN~R_fNYWpvA*#G$aKR zi5|uOP8wF!n7yxH0uGkKzY9x#5qMnxvet^1e_T0+v3F7sM~`1=Az3m`Ty$`MK5 z!Tm-8SJ+>!VMQvd{~Ncm;m+{ihNxb*toJs!e661j>76SF4}oM|a*u<|$$k#>a{Xb3 z+?RB2bjYhvxf?=pPiIf#-}7SjTfz&-&*VvL|3((ZH06Ps7Qo%>Jdo%+b^vk()pl=v;X1}t zW5+s@o}8xddUi;0mgB!qCIJ0rw~ok8ZZm_!>x!$MdCa*tJQE1mV|m?>WO_aR{EP2| zrf=n7gYEY?Axej!WFjsuF6+36druL%kF_{Y8p$bSUc^$!ET$!TA1t5d1`CV4*kx)B z54s9KDpf=tJ>w-<^#u>jjlLtKV%nv<1%C@?zOL4Mdv@Gh_w6La?{||sRl!+xl+8y4 zcuVLK4XXuM8Zd-R49G|xDetTLqd?8!6_A;ir zVAgAv-K+ZOvVM3rz*P{oHA5O+_)CFEnN5Rq97 zj7&0_ z@jO$8{8RQIJL-t>^4R`UVOf7`be{MebD7-BUR7><1B>Z>Yy9RRXEQ?YODTsl6X&Wr z)px1!i?P+>7fk}+25Ah&G%(~>JL|g^m6&69wvQJqv>5X{F(=hgPGUx!#+gt>8j9Q4 zl^{c^V`@)r!woI*U}j*isnk)?j!ESBDId=FS6OdaJJWXQ$lz|Q-}OeGIQNfDGDFQQ zJ93cZzwe+{<@4FE=2ETUyVs8QaT{Hud6#NWHO$OXjf(WgUKP@Jj9x}(ZeP!|VV>k( z^R+ZdJU;W3h6mZ}+X7HUHQG;m_m@U`QCWlojSVl63C?O^&wP%%eT-q6O}^x?$3G35FHMN@_X(nLw`|rtyFU^*)p-Y?cjFy=L{ofq40oHvjERj}oYVOVQTp6R=%Y(SaY7V0U+9 zY#8RDcpAvdO9Y2+TigbI>0eK)*;uN5Zw**gnlcIqJu;{!S2g%sV1BK&k(q0qdbo=- z7Kd0ry>lS*XGNAuMPc}g5N>%vQhkAo{qyF6n1R=u5i)!hSA#rIgZoAE7Z12gGA4{~ zeU=o!d-~PxTW*v719F^h3!eOl-8B7tvFEwmox$ZMxV=PnFY(|Nba(r!qv~0ypetT{ z3Ak5ckz$(`kH8foMfWI?Csi?3+Owj-=Q#?=RlU4RwxW&dB$o=~&Dx z?9Uh#9gEQIw~I|ZZo|SJcbkf+uds&@LJDBt5MH@BjxlJ5&{b(q;x^8TL0I#tkIBeX z1%xX%|Jgf;Zh*iO?tz}AmYL_o6bnhTVR6p-@8?TOH2#b+7?jI@``XtU`GX%YN*aWE zS4DD(S1s$&e$wknZoVGEM?t|jGvv*hm=fCWxb+-Kb$OVMs*arNPkZ`Rd*lU}v7Dv_ z>ygXHIhe#SWW>#J;kh}donHr$XCYJ=XB!=k_0`dF=_{s{47Zr`|1?`yyW<#PfohHA#pD=Nid>#Nq*{m@-%ZY zJ)o!5tZGim^EopKjm>1S?hK|M?Yx$ZzLSEMWVa|NL|FGKSLmXb#FdUX8AG9pVdOVY zXoB}s@-3(+=yn@R;U7f$I-FWN1@2|$+C)MXtJrSB$dV^{faLo_!0DxFo+l5^9!&+d zJ+F#enD2dj_uVa>NIKsin@{kw-UUJ5zDj-ciC*Ue0WMyzhjKP$!myzuXs0VESr>CJ z=?~cGwk9B#y>nYLgiB(hW+vb*-j!6h5LpCMe3+kC>e!XQ>ookF2~N^Ox^2#&xbwi9 zYGN-Y_Z!vD70~+iL>OrPdM;1~0vqCXt7FC{a8y}PucC!NvTTy;^xto2C?aX@qS^Z$ zizy^cWc=ZaM=E1-`Ksrhv0 zvk3kRf8d?-?Q)g2A5+JsvC&DOcP*XLF^>dO(cZrSUGc(H9P>#6D@)B@Wok_e&EcTQ zmMLQ~wujB1FH3M`&8(goSfk+Gq@^W!71j5LG3E>qYrQvOENGh`zQQRgIjzN~dsVeu~?k2Ui2j7l`hra!)XWLwA zQTYDbAU9$>Rndf=)s*<;fbnBD0OM#w7))iqo@pv=kd7KW>VJuEu%7I|&;Ql7%${Y= z`@Cy6_PQ!;0`}}7|A#7jpqy~tS+G!;?{jB8L-q$sYeUpjFZs~5{onI9BBC)1>GdC8 zLd9tm8wg)?xZySKSK1vl$@{#1&NFp=nt(m3@P9{Dh5{;I`Xt~BNwdSAevDWup{fY( zyD5S!8npXGzJ-3Hq<5-KN49Pbf!@MPlQwN>uW zQ2lUPwFAJQMjyaVv zzTp^eKS^xB5Zt>#AXN<9gW8@Cr_u({aT8g+)^94gw0CfHzHK#<4MloQyD?S|_;=gby`o59s=5z>4{DU0ZYA=W?6dYnMfM)3S_fv@^5Cl*6)0MBa z68HRHYgF=m&5tp{8153M(a^tK<5x$R;@SlhwxNF*Ba60Zr~FpF#IG7Fh}u*d$gh;8 zKC`hD+E^G@I{&RWYGLPD_H*2C@gob3`KlQ13v9vR|5xXTQ7PSX4lf9VObL(FSb*^q z;5iGx=M^=E`%&|dQ4*c|1Jz>rd#|YUj9~SfWTyzh7CFwE z>h`;!!rQ7BFQy~WM&P;I;W@iO7SuHxn05~g?#xn+5_k=JCF~EgVaD}z^c=1V7VY)Q z{d@88YBWb7on*a-te9+fO$yWS01MJ;a#StfUBRfZPe%Az{XNsWmbYqt16vn=LzEne zD>@U0DGWuZUUgrT(c_jsyBj|vJLX4>%Fy?FUpR}O6{UYg-y!fJa*sREtva{o0}^4)xP(%#~{X6t{v5TcELhdh3?1n^y@#P|-CF>MJt~ z<-#NsB8G9xy&Aw*R;mqoc{_*|O=@SfW~dEe%G*DC{B{wWnyN@|{`Vki<(#X^@GOax zXrS&LdGg@(t57Rk14RV`e6wWYmgh}(ah%7Dfp>>ZJ{?gd0`C6h;j`i`_CRv@B)}Eq zYtCO=f-c|7!DN5LCLET@SS_>QB`tRTTFGPtPOK&|Up0WE-M5A%EcR*o@}9qV(BR*g&)MxFHsPMbxG1KT-TgH2QA{W& zwJGH$CN~;~5L*lEZpt)7y&$6gejAegslq5h7T=@YPy5x@1T}_$+y!eNOO@n9t?N1V zpVoicWfb~l6vI9fAd+rbu@fPlo|cq@6uB>GRt&g{Yc+$0Fr1$;o_+a~j#k94^R{ZS zzd6PC9}e*N#CI@jMXFz@5B?!l<|GFGdw2)Tw#fA;xY3-|ARp&XL^}_t;E$wJF$jr_xqht%ETtX#E8WJHZ zk`S`pYs*$f$c|)>WV_e)vG?X0h3viV`o7)1zsK+EFYEoj@Ar9~bDrlsU+26|dS0tX zMd6D{8!8TQ*tSrbl`LFi?Lowst5=LbwBT5L~d>|$hs#;3`CJ^nx`5D+az(v;_TSdHA#+BB8a&qB+F zI8Odc(KalZcBy0+2OsAzbG-a)Y}7_3HY0n7li1CkAq$356LckR4=l<#7~bv);q63* zGrq#!#TqM_BxfD(c<&u4F@aLMO0vMl9~w26{SPiApFE90phNdzDP0UdzeKsL+k>yt zdr$Q)wMCNzELVooPm*ulxnb{)8IAi8jjW8C^X)eG+E%+U!vugXeaqfsAGOmluuq&l zAo{K)foD6tw;!4wwF>}|nD-2c)tXu|_n1DXPreIv71BXXh*NPuN@aj{p8iY~XKivk zjY8nNol&LR7)pZ=>07A&pS>L>)ik(1`;Tf=k@!-2Q@))I-|D=X}T_OTZxcZXcllVy6)0orv#oSa&V9BeJGrd|zLw)3fAglLgL&wj) zPSxS_z@9@fOP}fy@SKZ2-+g3?ZF&Xe4cMk}|=|e8hFz^$Ek@4hLe7Eipv2hUAd*t*6z|@7n7owT0@hM~D0a$+IsZZa8H-pA- z*K#j{7Fo7geIBo0Cfe-K>fZ9@Z!7_GBAeG9d`hW1&Z0&|O#->QS3|DH(v33_<5_*a zWuI2^O6pSR9$W~qfQ-jXZiEQrEh{Cfilv8o^zBL!_Hwj||5Yi7z2p;z0oVOiuMZ%$ z#0L)p4;A8=e#UV;X^uURr@r}tH|+xW)X5a2hv)t860|5+fxP<4V4<`oS%nx2zb*x% zErm4?x)=JKtlpfav-c8^>;h9iiRm4qx4)6RdKGB)O-M2cbDvO<`p2rOK_to~jdTjQh7?^ImDhK)%j(T%IDqB8f5@-YTs^I4%Se8XdWG7N1gZSsqmnb+S?zA>7Aa#KgdjFTdN*HrJ~HF zg##)e(bS8HaY4C9`l~;E#POIsqQWwTECW~O5q-N0Dy_XQ@XQaWk^Df2CKF!@>&J!Q zL!~=T7_vEeC|%0^)uhqb4i9Prz~#5{`wof#_zU5dZm~X;J_TAhgO$JX*K}r|_am(l zVtTi73^Pqx-LmCAhHd3XqFPNQ`fw|UXqXdQof=a(*!!&w3f?&7Uwrr|Hs<%ag;7ryc*WJ-a)I4K zR-f+%d;t#*T{{7?H#;VAkd~+m-O&EE+KSPuA-f12Y?%2+o$#jQF@E0wW@KRpV}Ibq zKh$qecXaj#@}p4mm9e!k=?q9u`0r&B+Os`9vQ5)Sm3_ z`DTNU^KiCucyOa+!#~cP} zB75uFZULLsT$W&+T6)M_^E(Rb25Ph%L%29n@Ysardzle>tHhX}AINySBT1(I>^Ed( zZ47Ie9iz`Hef0_cVS+F+Sc`EaS+BP8L9$%+IwU*(=nXL}>qgUr9A&ry zrJ|Lu<8H>4T^%~tukR!Ix^GFfwH_*{-admJ8j>GPvSF<#LfbRqG*3~?xm^HjK_vvu z`0AN~Z{n&w7wiEWQvZ!^YJ6UAF+ax$JJjHrWcqkg`ejp^_t>lFBa|*(RY|U0 z+J}K_Q}%~sc^cp4FWXTG#y)x?8>cczRnkGhIKtH$8wAEqFR$*#?W&hQy{yYc_RIvh z4W5Dy1gWOeL$Y<9-z#J;Gv!SZWj0i<2oVCQbrWDKa=h zxW&gs1wLO1NrgU{G6T}G>5uu4bJEkXE4s39krB)~IsYYfD`$ML)4DFb3)LeUq700m zCGntK^Z@maEadcVGThEAw@?Doekh;PuY0#={;92R^r z7tCV-@jCLTp!WM3PkYB@sp20$Ap8QL=8};dVBy8@mB|Aqx_n4DC%m+B`dquZR5{T7 z1X0e8bmX~YIZwMX23#8^>VH{iVD&eMe-&-nQC1)YEu+)Z0`nl{U_mEz6}{A~k?5-3 zY`s=SxLUppEm}thBV(3G<&>kE@A=v;A5Z%dJX5Dcj%%TN^@Vp@AWPhs6+Hb=Wq(zr zzT~_&g9Z6O(iqN7NA6%z}tE%zumD6iAr}uxeX?hZC02supTC|Rd=U0klr_1-ZaUruk=|TCuJ)X+Y=#{8f2+ayN{XDt6>9(K;`+PNW=&@`)(UMYC$5=DP_@)aUp70LF+-_vY6os>9DFj1E-eMR7?TBweCjw3fhQ zxWvT(8DoZA*4WSFrn8?v4zvXizg+Q@lsl<*yMLXN*O&_zdw0E}|A|U*Z11>er78-d z#?hC}n+(g_e44R^;{3zlLU7F@9?Zt$PdV~lAv%}YyLduoYKL7w6cQ&RxeQ7cubccy zT#%qFY{o4hP$@kbc3tq%os&XqgefYKe6F4;Jsj68D%9UDrv*`ie)p+2DGYP|j8csk zkjx_bH=fy^p4Q!Lsocn`{4oNbnd5jQb%0CR-jdN)&=wQ(Wlh5Jjy&>DwcY!Dj5pWJ z6i;#7odYl0mqbY5fT?b=QIh7nRaEjSh7DgVOBL><*YlS+sxM-TzW!jp`VAAl)Dy&J zi+NJccOzgacE6;=KGmf6hhUzS1?G4n$%G4<5f07G+<6h74c5aapYO>A;=b52D}!u} z_!VtrBY(3)v;ZHSlw1~iTlHKm`0ZXd|Q>DY&hoeBbKeCsE^ zun872t{!qtk}>LbK>EmZ_2Q2hp6#2Mc-D-|1X_w+_HX|6yzXi7AnY^=NJ-Tl(hjwN zJZ}am?9;u178Ouv8n{eiiMQIZKgCalE&naI4bB?xh z`RvzC-iK!inh7a?${YlHsrK@=D%^tiyob29+YEkS)mqAdyxe+$<9bm9SUPWa%UXKa ztMe%vAd{>8N)djQ;!a!DpeT~DV~>ZCSq-QL0-i)`L7AfstklyYD4eCp;`Dm2&40XV z$IqHMEdB7>$1eu2K5ps(?Q{vxehNH3H0w_gp<}sA}Yz(%fv|E;FBoSKU2%(PUgy@M`1X0E5-AT6jYVYv|$`JATr*^tS*ChZ+58qJf1ql2rNjBS&mi{9IJf9HkCcxgnDp0;nc+^Cztg!RcYY& zD$d33lqa*V*!~nHRd%I@M^>hh6@T4R?H;v3{bBJnvTvWFwc<4c*p@SD5SFfZ2CorH z1zB>CZVY-g-=La4%T|j!XBBp%xaJ<~3HbP*Nu=jDVOGC$hmgBcw9_G|YMo-1PAC-( z;yWw6(c=o31~ZI&S+JFM^)`oHxpGC(efJ{RjT$&$9Z(>Csh^69A10FsF&LnFzzt-+ zWqi&FF$mgm3m5N-S!PaT?8pv?X0GlKc<(E%n*=C*>*kO18*VC>A$Nw4ca%76W%q_h zJG}vbz>arJ*%kflhey}Tn?y?)mz)hZHL~ABvUeoTURwN*f}J8?O5f zeeW}Mu{^JFph_{rsH@0%(Pak3hHvXT<%yf(M!P%tbK|49o)l%6TJe!>7Ta=EnTwuT z5s6S*7u8G3j)P@+1J@HE){S~6lriGSyc53F#iu`ry&RADrnV?`lL0L;i)N;>c`6P% z$HR4+NIsRw#rCMhljXE_2E_4gujLzla)nS;<)2O8$YhKSL(NOn&dLMg(BV}EZGw%fbA?k zJk=2fq0*~Dgwh4y7KK=F@(%-gcSE%KKSO1@qAj5l{LTD*QoI%%zhQK3=5+6~l+jho zYuwx%3{G#uox~$9wz)@Uh#Si%Bt*c<#PeHhQpnPW+N8%Qka{yMi1;|+d&2x>1;=-^ zEE18QG}z!l1?%JX37Im>qRQpHk$CLJv?lq2oI`Ojlz3uuuBUNuf9}+%DG%(`G@-Q>Y1} z!TBTpuu7w-?CeWkiwm?46RqrX!wK!%hx20&`>uQ*3B;AGsD*($e64nsGeIiEJrw#( zy}-!@supOtWt^`-z-6+x#uhL-3V#_P{${BJ4u-aI4!USd?waijdiUPG4VUJMEWO2R zuE=Bhb@^!y+!0}s_{*4B+z|Y$hcXUvr2MAj$+=%Sak4qb#B+daweT3?*w!S8cC zNWDd$cwgCbJ6e*EpB7RWg4v8)+g8B+-`rDIO8L5>aK$D`(-E8}9_XZcH^VOV7RrNNxUcMmff%_S zoaczprh(OC9)ESD!^h^}t5N$czWVFDXxwfwb8C|}^4xvzSztW4ExN8B>-v{)N?*-s+W zT18hG#;hTXo}9cK$#)}&-3KdfjM&hPDSVW4S!;A@NI?PxrQED$P?+_)qM7yR6<4^E zk^96YMW+wsD4$LKhU@Ov`3W!`BGiTWZVb_NQHq}Ir#f-QamhPE0}nIz$OvB(1QAQ> zUt*hn`;y={TY+JGsS0#>6tWB7#7(5SJ^*>uotP z*B!1LZq7zjM9>!$6`IS{kbzUUZcby-l{=e;;Nc?qlsmx>Rd$N7TSUUv4u&v=SOs8!tB!sC(y$$rokO&NH#8O+1bccw zojYr2ukp1u0qDNIQS0Mvd@PR~rRD3S&kV(}51hP>7Wm95BM_E*3&|4*0>=!0sn>(c zLiYspnXiE39A{i-+fcZ5k>>^mKgz^pp4NTQ6*aYS4@kDJzd*TJ&j6mn$yugtD#v3s zw#)qCs-!>{S)|WkC`lCTkXUQo2ql_z&V$bMqYsJ>O}I5o*WU$&U!4@tb=_BJtshl-hDX#;JDheK z)NOaZsw0egRvmU;*%o1#3ER5q%plRQ?FHIfX<1FsNQKL^$JB+YzoSzQ>*amhr=U1{ zW12ba-#)2?Q_Us5PHjXHv9jZp_I!lZVge1;ek!VXYbsdvnyBDFUWmhMgCOlrwYg_H zo1vb9+3L4?OMm@(W=Z#?l9NX3yd^}#34Lk@nIs#JVySiAYBY_0h6_Y3Wj2wyOk(OUT)ia7FA zTy$R2#H^qino}PESRYDRsNe+DJKX>j=@b`9q@TBC$h)b0+`N9$rR%f7Q<5-GXn;j* z9v|TG1<+EpKxT>^dshnKetT$Kj+3tW<{W-NQvENERh<ByD_bI{uF{?$DZos)H5q4 z{ZVHOEB@h0cS^ValB3fu-5HbkgcN|>YwlzPYOEknA_(23BQ>oaIjVC9Fwt`6SS@Kt zxKnPVp#?{{bejl5F|wU_V1t{oH%1?f8GYPBEco>Dv;9hK&ycWi%o zH1`YUy124+t7%@}qz${(@H9ky*tiv(9|(PjTc9@bIk7w*i1GuvvucSmR zMoWerg~Vc(g+Rm&PiT8?h=B`t+CHLrFB;P&FnX=6!_v4xxP&z`XJz=vj#pZ5HbRFj zb3G-R`soOP;ZORZ5AZwFYs#;?q@gsD#l+{MzhnavfgclDb?MafJ9S%5_2k{G!tzeL zkJX>q0hmkP&l2oG9PP>ga~ljkQE4|1xRv)7t{ktAvp>f?FV5Of-6__%k-30k9?CgZ zXp_6PpC68FSwZpIPLJOkB(B|aI#oW~CAv(4;DMb?LT+HK!p{sk{<3F#j*t}cIZKKF zEr>dWtT~z)o82L~+WfT8*N7#(Te{dpnrg}`x^+@-Nzvt$?p(v6uzWYKF0w2=g7bpn0I{e&C9UG1tOyV!7LHBK!6bsE_lmv(0~p zUPmt7=)@663%DB|&B+|X+Tx({(6{;rz9g_{GVN`O_y8$iqp3JPC=q+lwRuf-R;*&e)A zAJ!af+;(RRwfr%kk9aJtd^m1iHQ&a)&5j@}SMBEIOY=l@CJ`Y){<~@OjQO@}AZm+h z0YSI#ij_8$`Z}hXe_d|%+=vJ%8-tk|2fREv$yQHu`E87%Pw#+o005Ycu$!cy8xxG1 zz_5xaQOq5FxcQR2jlKZ%9X>=5;^e@7Cm+MxGSC37i_!!R~^%GY_PcvTyECDXo6xc?0YM+jl8C5tFweB!Hs?&-DWyA8%Uj->4J zMufy8T)z>&E|$+=EbQ1&0Flp{&Wu}PEf-5Shw^vL#ldpbE{;youmFq?OprAf)7|#q z0-F}+zAC%Z^ffqBN!EWL(>Hq0#M=OltRZe-9sXD*s9iR=Mn8>qQJ4y{ldPus&N}=^<}A07y2weNCv$$#pU@ z!Jxr!y@8*m;>mOF#gP45-+uPJ&!aNbO~|Z&dM7>t$Y$lRFIa4jy4BQ&IF#j4c4I{5 zVTCxNdj9AeN8H$Ipd7@Cpk}dmqeQ>@K|44=X@Y@)0C9z2~B~XK&aqROp{u z7|KE&ZLVcS5rhak2m}Mh6IQcuVT)!js?C)4R^PNJ`YL zm{}yE2d$qBAA*Q$8a+Q`p0=1kTy|GJ=?**IUJ-fz@}+Fi)OkW=hk_m>!PJ|_TtziF zJ>1Uiqq!))8p;G?XUMM6vts7Doh5t~q0MmTWJhK002EfCf^qxgM=idVA2;eqm4Y0e`}WpBUB=$9cYx)7qw4X)-_a@V+0{-gxcs-N!4md#2sblGerG z(@)fV!P4n(0cV`8IE@apL1WrhfN#2}97r0y-vP~y%%FK>B6iD?XGR**y>m|($*A$< z*V|(e-9tvH`_MddHfWDLH1xgiLed*hbmOb5mm|UHd9&_BA>7czw3eC5nQ$Vm12&FW zRM@EihuW6?iX0h{r<24}oGtk@abt@lvftKEqZ)VkJZOG*l z^bLRCxfOM{O~bjsrnjF1+zGirN!khd_)`NrvyOcKpo){9u@BmxX)+OmsANS;)4Z`y z_mYK|QS0(fUS{b3fzMoF(v@c%HbcpsW91P7VhRA$uUEW2tUKXwKVEOIVHyH#i)(l= z#6!H>v7swyuDz{oZsFx%h6aW;Sl`-GVkGSN_sZ5zXCu4A@9njYE`93NyC?U-NQ2$P zjd%I0rv%~mLsXPEwpT2R=<=j8lHdLlB-&4eKU+j*&oL51B#5T^oQ}EScG|;i+Kjv- zOjMSQ)=`TR(`BfY&r&>A9Q1d_%k%H3DgX>04u1(p^!%=)E`_; z436GK%C(PR-!Q!mHDCGZA&^%s*j1o3atrT$QhrdMDkNi1|LB5{vSvuZEe3DnrH0+t z8O5qmEKSwD=)T#T@7olQ-r2}CX|R6{#xkt8Gw`|t3dWx2!Boi7h5ohv7#MZ=f|}uZ zNN4Q%$CAfuN6E_v=f?Cmp@MNl_`g7qsskf=hA5vPg;_k~gah^cWn;gAP46%I&rmp4 z?$;0C|M4L32qI^Ee0=n>InRv`bjTPE-6Um3=$O~u^)nF}xgS(?$UM@(x`MX2JILH{ z-G!#F&W%b1v8v#YLehV1e%hvMj;;+fM88nyN zmRBsq6oUd>j5Dz5)RsV%AEtZ7fvEmX=`4*PmEn}#b(RA{B_pZ(%j$L1u^1uoY1ou! zG627d(eg%U6)t2l50 z-31tP9br5vC2t<_MDn=9%DQQQb-HkKla#hv6qa?uG~kbuM3X}#J+gu&?bYJ?J<&@$ z&B0qge$_G&Z<aGBZk=Dr$n#u+V4 z9nE}H!EX9jovIj7hz6dSh=E~yTN_7p?D1+#g4^G~WykH-WyjOuA6j3j1sv9YU!EoY zRt)GU`MKpq7k^}GOdP8BS)~ove|S5Dj`-KGGT!j%`4beb^9pEWwGJCD3Z{x2rq&wR zJBqb6LCYpS7gW4gIeEaLkYANuXxukrm49lMa(4pz*B-AYOnH3A!OB^POOsaD8h>UI zM?M@82G4p_Gy+NPmRW}aZjAt&*{h2mvjMBt-V7}02jyEf&=p%7X{g$mxe20$-?~P> ztwEgS__U!ou9z7oH0^}#887!th&wOEyUY=#;PAUgVH=#JGGFgH>#Ij2(hjR5{-qYZ zBt2cvAjl0kw9I_vS9lgvTx=@!qD`pMm_pQaY;&e+e#!96Z76Qx_M|%~I3j|^U)DF- zBeT+Yn^Cw^1LcEm+T)eQzLH-J#^NjLg<(2kOdBODlA0n^h;->csHZJ!d#jfT5V;&I zr3{DKnEF{+&0RWDzI%6H3RKkO7;<2W@r#Bq5T5Jv_#XJ8ziS3JA10UTfn9npn&J{n zLhta_Q6f&aD;-X<*@gO?zP^0fygJEs?ONN}<2--ah`M=l@fPk_wvJFMxltl-u zUO^lal(2#es25|T^?LiST2YXRHKjzu&eZF@EZixAx(o>I*=V|DQ{WjcF#*7bskS!_ zyICDK^DB#IU*Q#b=p1IjG!%Tq`CtUjZrZ(z{`m{8S1xw+S`h5vX5-)>)fREnT={6% zmV`RHv%zkE`?*(I3tEyLUt+xHc+Ut?$0?n$`NmrN_LJol|Ht3^=DIsCAFjV>vzBY( z1K9|XG-4s)lW`U$e*U<>sE~G zw^i$pJ)emznJ}|7gPSVzE{^X=Zij)RW{3J3LO^7Lf;xadp1plEA8K#px7RxnJX0HA zYU@tzuWf4QLND2HdVOhC9*K0>05_VdHgfD2d~4q|SLnZtoOcNMGeD*1{ju2|6_tkD zwZR?E3GfgX$l9I`HHSnWje^BCZDYABW9CNl_HU0e2{ExmGcA50G_Lv)?oQi_F$)Dk z`QasXA|9LYKo_horZS-Va#rsj)@Bt4iFLw{ZE>nyKYjsUey!kw5@SJ6FBS03uy;NQ zv6NU@Odgwc?peaq%}Or%)GWg2C}BpZ&4AMBt&-2veaNPcE({Dx(y+)pAy zNM~v68!mDOARZ5^F#fGPOjM~1C0;Yn` zr~D^u;jR^uZ{kk5+fj>`{th4GvGG3Y^#)?7LDx#vTh6U}pd6&Dzp02r&Vn7J-+R6O zo|Mb{&(3$}R-71nxE3*I1EbJJp6_PaKyM$Aw@-Xya*(avoB*hMTQw=--}sb{88Q6X zVGWgmyaXL#x_UK6drPtyb)CUB&D*3v&)37YzE3^j9EXalSugn)k-5i3#i{|%l8qkO zhgWQR!uJiA|Aa30U$dhlYxTYTY%hYyg-a zJ;%cS;@@3VsR^nsw4}e0%>TZ3^Jb_e1;*gmDtRs~q zb|>Q%^;z7`)fh|osnqy{IOjpL!u(hMJ|w;KuZIu5{N=gy8@MYg5lcR?e+eUrv9`%J z#8L%vbk&2Izo^UfqGK|$$MxPLHy`~Gev}e*DYknT5Ma|+*V(H{${f~FQ&8R4$8rTA z>V57H^TDP5pzKo8k6nd`e-eLDe-LTfDo^j@2CEQfrOv!RTg)$UWIrK52Jl3*ivu@> zS!2f5TXm zi13@?VqqrqOh8(fbXAaFj$P@I0mH;`kI@RS;UmSa`wTu?NfjpIfQ{< zf@mgBiwLN6xqGrDLg>0;Eem{IK@8>-r#;Ogz8{~}^8#m)yn*^D2hjFwUmW=!fe}Y? zCIXEcI%`U{r{)o!pG6O|dbS1I?#CL07TXl02p%4MVJ+QyckUw|?IwBMIP&91f|;wz zJm#uDI`ziQ9R@@X`WEraxo`qlDHBQRxDpq9EDwYxZhrj{2mSd47&+wRg3QVXcLU3( zhV+mlPbVr2RCmDbrs}J;ZrX4gcKn~i_YYL&?ThPe7BDwOjyyayiTR5GBvOSIMta~U zzb@0J^Nfv=m5ilIaii-~HHFX%0GGTxBzAzQey}x86<*v6sQy~pyF(?=;!g@*E+;3E>uxew zLROT-gyGxA)C0IT#!lDZZ|M=9rrv9lEc6ijS&IRp#M@^%=$}O*;~jn6!~Dl7?i-ny zv@wn2u|>l&3c)qaRup(VzyNXF=*)_kNmi8mEho(tL?J7P+ggw|;F;oc36eYdKmod{ zH1FM;G`dtGHW#52ak%B|CpgPB7g64R`e-wKg<)gu^X670y$1gFl(`Fz6l1kPWHQHoi65Quzfqd{O$=|1g$dA%s>eQeil(YLh;!$~}(o5!Nwt zuO+^otpByCR<6^HHE&wv(s1(MF0Q=OCj1SjKlPoTP`{=#8#Q+=hX`s-FR7+jT*fet z+;r1^g;KZArHtYQ78;A4-pD9JzVTE8PqyGR4R>iLZ~ql8a=sASz!7`vmKB{`_STw< zSrg_0hAS@3?>MUPkI}MrCb1N(_)z=xucsg;(UJ`*D_PA7@4J5uf;-@%_j_&tmzR)U z;OlyCElq}VqU#Ze_<0BcYN&l)dlhK&KRwpBZOJ4Y?5Itd(-Xln0vA+DFx<^6V5blx zjI^2^-?#v9I-jpeL9`K#ZjpQ`wdvQ#`KtYI$T(~TRp&&wp}lqesbZYayp33V&D1bE0u zT>5&i73GTCzV?6b-CIx&aJ7@Qyzd~RDvC*^XHTsUoQ?>=qu&3>*S0n#ujHZ2|QD?=mrlBKHC)4=XhAGfoUCuk~h7PV@s# zR6S0SDN^xg<)Hr>T2dq^;6umOV(?NeTQOwqFXQ4n_u!qU|6zrKG}&*XxzjElf48LR zZbr0;RL2MGJv@)?eU7M;{Dzeuv1KRByB{hRFQII_T~mrc#?f4X)MCK)&k9+_{lo!; z5hV-1N8Mj;$mo}G7xy*A<<-<=1@Qrki672lFl$CEp{_;7_m?$7UYNfI_J^XeIs+`w z+=I+=*iOr35_Q(jc=J(GT9<;3EeAsFUt2?0HX19MmM43t?kZz~l8Dx0SPB+jX92d8 z4+=+&xY349zZ=51ti8{A1fg~tPVK`rW%lPN_LibLu44xgg&+Z&|I|7DmdO+P{N#E5Gn z+nj8!&{`{3Mq0sFaB5C^Nq}aQhW3j!ES|c@$&k)J_Vm=v`Q|5sXs&}O9?65cI!9I_ zxR%WSDC|J89i?jOAR^r(4!p)Z(MI;~Ook)d4i=rb z`V^dbBlZTDKS!zuxVfzaBtm{;0G-CMzP3N7-FKyzep!c4xQwF*f9Op=WIT%Y}Y<+4PJpxU%3@Upd*~#YaSmMV2)} z{a%>#Rv#M}4t)Gqs~T~O0zOrjDhyBC@eT*Dir)9RzB+}am~4Of#xTzM~5wIY{2{%Z^U z*^_LLRUa^n1>K9Q@p~P_=|Rx4tALz6=(=B+3|Wi~e3jt)I-sob^Fi`TRK#Dbrr(eK zDDSuplay?}DZ!*xDXSa5cIu(DOF=?ziRb`%V;PDyVD^&l(#98;$V>8KH z165h?zr7`!aMp9!!TL|v65VAWT%%ue?;}Dv8I#fmMKZ2F7KoDwLMzk$`cVf-cg!r; zj#~Oa@04@tl)KL^sY#_Q?d z9u?0!Yf?U+tPu-d_7Mi5#Mpzg0%@Kz#R|{{Px9#5n$kgVX~M^x){;jtLfL7S0D1i^ zUH^-Re2Jrm+wA3ww_lf>I}=$nC&@A0eGQqKAfsAOix1fv{;2ZjI`#`xXYKLIk&qbJ z)aS9%m)x6K^L-`F`6_9_Wl5SG?N==e3C(ggKuoU5N32=UIV+7m_@1S>acMtm@r4#e zj_9fX+QDBNfOO5@GqYjTE9Vr3n`*zfj{DhzL?= zqtq%Y7vXsE|6FEPZUA03Ew16|(Sv6lJf7;N<|1P&6#SL%5E1!MobQY8N>ouT=Og0q z;#ozU8)-v&Cozb+-!jEm6YluCp?!Tcz`kiMEUm?2ukyy{&_U`zpL%T-rdu%?{k7V@ zB+(=O719lTFUQmAt%}INuJfWyUK92!>7se%LdP}{P0k)`=${%0=brt4jz#!i!;s>T z45X&$e10J&GuNA_f2iZrLwir;(d1TN?2me52d)XS$D*%R#Bo?2u=%B=EqzTlM`_#jyki7S=btk@9Qhhj&IpP6TVVzV8M|JP@V)Z#5e7fF!qWC=tg)cc@QnOdK9O%H${ulH`|CO>C zs_VH16MpU_GP>S(BgKQJTTRjR`RArH+j>RGQH;fj!V%t zrY_MB)h-Q+Dw^@1A*9*3{m3{{DNUsbzfj_|1`FL=ZMZPM#_ zo9NrWVMzrT4tYhXq4*31JUn@w^2{(Vz92Hs_U0u>H+*|emaVB?$M+3{=HNnOK&FS4 z8Rj|_Q4VZ~l;I}5=Y-KU1M7!x>7IuTT>Rphb1_vxW5tm2cbYl4a#kdoRKT!{Ep+uq z5)7dC>oE;gb05-ZaE0Pn!oj!u*X-7TlM03=2{#H$!=&r}Krw-SXK&6%(wPn~*=0ZX zRSL*Gv&|N7Dw?xY*6Cj#;8c{70=bbjv$MHjh$jn;H~5z+GLp)$h1pr1i?$;RyakHJ z?%Wx!3f!ROBD+XIe)b#k;IsUIk=akP(G30w48H@OkStYA*jKZ0RMqk9H_jw`XOyu8 z@9*D~3JNZfnj{kNJMb14;J-#hK)(sT<=KxDdqh|#e1OwRCvg%0zwT)~P%lz5_4^;$ C#OO`{ literal 0 HcmV?d00001 From 4d0dfaf1cb9af979a827c0b0371aacf4fe9b2724 Mon Sep 17 00:00:00 2001 From: razor Date: Tue, 17 Oct 2023 00:20:55 +1100 Subject: [PATCH 756/801] remove old CI files (travis, appveyor) (#1180) --- .travis.yml | 49 ------------------------ appveyor.yml | 74 ------------------------------------- scripts/appveyor/deploy.bat | 20 ---------- scripts/travis/build.sh | 48 ------------------------ scripts/travis/install.sh | 52 -------------------------- 5 files changed, 243 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml delete mode 100644 scripts/appveyor/deploy.bat delete mode 100755 scripts/travis/build.sh delete mode 100755 scripts/travis/install.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4dbb097d33..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: cpp -sudo: required -dist: bionic - -addons: - homebrew: - update: true - packages: - - libpng - - sdl2 - -install: - - if [[ "${TRAVIS_OS_NAME}" != "osx" ]]; then ./scripts/travis/install.sh "${host:-native}" $opts; fi -script: ./scripts/travis/build.sh "${host:-native}" "${flavour:-Release}" $opts - -matrix: - include: - # Linux x64 Release - - os: linux - compiler: gcc - - # macOS - - os: osx - osx_image: xcode9.4 - compiler: clang - - # Linux x64 Debug - - os: linux - compiler: gcc - env: flavour=Debug - - # Linux i686 gcc - - os: linux - compiler: gcc - env: host=i686-linux-gnu - - # Linux x64 mingw32 - - os: linux - compiler: gcc - env: host=x86_64-w64-mingw32 - - # Linux i686 mingw32 - - os: linux - compiler: gcc - env: host=i686-w64-mingw32 - - # Linux clang - - os: linux - compiler: clang diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index e0b9601c6e..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,74 +0,0 @@ -version: 1.0.{build} - -branches: - except: - - release/1.0 - -clone_depth: 1 -shallow_clone: true - -#do not build on tags -skip_tags: true - -os: Visual Studio 2013 - -environment: - VisualStudioVersion: "12.0" - CMAKE_GENERATOR: "Visual Studio 12 2013" - -matrix: - fast_finish: false #finish build once one of the jobs fails - -platform: - - Win32 - - x64 - -configuration: - - Debug - - Release - -init: - - ps: $env:SHORT_COMMIT_HASH=$env:appveyor_repo_commit.substring(0,8) - - ps: Update-AppveyorBuild -Version "1.0-git-$env:SHORT_COMMIT_HASH" - - ps: $env:ARTIFACT_FILE="openjk-$(Get-Date -UFormat "%Y-%m-%d")-$env:SHORT_COMMIT_HASH-windows.zip" - - echo "Artifact file='%ARTIFACT_FILE%'" - - cmake --version - - msbuild /version - -clone_folder: C:\projects\OpenJK - -#scripts to run before build -before_build: - - cd %APPVEYOR_BUILD_FOLDER% - - if "%Platform%"=="x64" set "CMAKE_GENERATOR=%CMAKE_GENERATOR% Win64" - - echo "Generator='%CMAKE_GENERATOR%'" - - echo "Platform='%Platform%'" - - if exist build rmdir /q /s build #remove build dir - - mkdir build - - cd build - - cmake -DCMAKE_INSTALL_PREFIX=install -G "%CMAKE_GENERATOR%" "%APPVEYOR_BUILD_FOLDER%" - - ls - -build: - parallel: true - project: C:\projects\OpenJK\build\OpenJK.sln - verbosity: normal - -after_build: - - cmake --build . --target INSTALL --config %CONFIGURATION% - - cd %APPVEYOR_BUILD_FOLDER% - - 7z a %ARTIFACT_FILE% %APPVEYOR_BUILD_FOLDER%/build/install/JediAcademy/* - - 7z l %ARTIFACT_FILE% # list files in the zip file - -artifacts: - - path: openjk-*-windows.zip - name: OpenJK Jedi Academy ZIP - type: zip - -deploy_script: - - ps: $key = $env:DeploymentKey - - ps: $fileContent = "-----BEGIN RSA PRIVATE KEY-----" + "`n" - - ps: for ($i = 0; $i -lt $key.Length / 64; $i++) { $min = [math]::min(64, $key.Length - ($i * 64)); $fileContent += $key.substring($i*64, $min) + "`n"; } - - ps: $fileContent += "-----END RSA PRIVATE KEY-----" + "`n" - - ps: Set-Content C:\users\appveyor\.ssh\id_rsa $fileContent - - scripts/appveyor/deploy.bat %ARTIFACT_FILE% diff --git a/scripts/appveyor/deploy.bat b/scripts/appveyor/deploy.bat deleted file mode 100644 index 57d2d3a2b6..0000000000 --- a/scripts/appveyor/deploy.bat +++ /dev/null @@ -1,20 +0,0 @@ -setlocal -set CYGWIN_ROOT=C:\cygwin -set WIN32_ROOT=/cygdrive/c -set DEPLOY_LOCATION=ojkwinbuilder@upload.openjk.org:/home/ojkwinbuilder/builds/ -set ZIP_FILE=%1 - -echo Scheduled build: "%APPVEYOR_SCHEDULED_BUILD%" -echo Platform: "%PLATFORM%" -echo Configuration: "%CONFIGURATION%" - -if not "%APPVEYOR_SCHEDULED_BUILD%"=="True" goto end -if not "%PLATFORM%"=="Win32" goto end -if not "%CONFIGURATION%"=="Release" goto end - -echo Deploying %ZIP_FILE% -%CYGWIN_ROOT%\setup-x86.exe -qnNdO -R %CYGWIN_ROOT% -s http://cygwin.mirror.constant.com -l %CYGWIN_ROOT%/var/cache/setup -P rsync -%CYGWIN_ROOT%\bin\bash -lc 'rsync -avz --progress -e "ssh -p 29022 -o StrictHostKeyChecking=no -i %WIN32_ROOT%/users/appveyor/.ssh/id_rsa" -p --chmod=0644 --protocol=29 %WIN32_ROOT%/projects/openjk/%ZIP_FILE% "%DEPLOY_LOCATION%"' - -:end - diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh deleted file mode 100755 index a887e97f00..0000000000 --- a/scripts/travis/build.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -set -e -set -x - -host="$1" -flavour="$2" -shift 2 - -mkdir deps build - -case "${host}" in - (*-w64-mingw32) - export CC=${host}-gcc - export CXX=${host}-g++ - set -- \ - -D CMAKE_TOOLCHAIN_FILE=$(pwd)/cmake/Toolchains/${host}.cmake \ - "$@" - ;; - - (i?86-linux-gnu) - set -- \ - -D CMAKE_TOOLCHAIN_FILE=$(pwd)/cmake/Toolchains/linux-i686.cmake \ - "$@" - ;; - - (native) - ;; - - (*) - set +x - echo "Error: don't know how to cross-compile for ${host} host" - exit 1 - ;; -esac - -set -- -D CMAKE_BUILD_TYPE="$flavour" "$@" - -# Build JK2, so that the CI build is testing everything -( cd build && cmake \ - -D BuildJK2SPEngine=ON \ - -D BuildJK2SPGame=ON \ - -D BuildJK2SPRdVanilla=ON \ - -D CMAKE_INSTALL_PREFIX=/prefix \ - "$@" .. ) -make -C build -make -C build install DESTDIR=$(pwd)/build/DESTDIR -( cd $(pwd)/build/DESTDIR && find . -ls ) diff --git a/scripts/travis/install.sh b/scripts/travis/install.sh deleted file mode 100755 index 9bcabc73fd..0000000000 --- a/scripts/travis/install.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -set -e -set -x - -host="$1" -shift 1 - -sudo apt-get update -yq - -# This is what Travis does using the apt-addon. Didn't want to duplicate a load -# of packages in the .travis.yml file though so we have this script instead. -APT_INSTALL='sudo apt-get -yq --no-install-suggests --no-install-recommends --force-yes install' - -${APT_INSTALL} cmake - -case "${host}" in - (native) - ${APT_INSTALL} \ - libsdl2-dev \ - libjpeg-turbo8-dev \ - zlib1g-dev \ - libpng-dev - ;; - - (i686-w64-mingw32) - ${APT_INSTALL} g++-mingw-w64-i686 - ;; - - (x86_64-w64-mingw32) - ${APT_INSTALL} g++-mingw-w64-x86-64 - ;; - - (i?86-linux-gnu) - ${APT_INSTALL} \ - libglib2.0-dev:i386 \ - libgl1-mesa-dev:i386 \ - libpulse-dev:i386 \ - libglu1-mesa-dev:i386 \ - libsdl2-dev:i386 \ - libjpeg-turbo8-dev:i386 \ - zlib1g-dev:i386 \ - libc6-dev:i386 \ - libpng-dev:i386 \ - cpp \ - g++ \ - g++-multilib \ - gcc \ - gcc-multilib \ - ${NULL+} - ;; -esac From 14790679d8d879b95d5e0939a3f3abb9914cf507 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Fri, 3 Nov 2023 23:32:55 +0100 Subject: [PATCH 757/801] [Shared] Replace CARET shift check when using cl_consoleUseScanCode with a check for cl_consoleShiftRequirement. The cvar cl_consoleShiftRequirement matches the jk2mv mv_consoleShiftRequirement: - 0: no shift key required - 1: shift required to open the console - 2: shift required to open and close the console --- code/client/cl_main.cpp | 2 ++ code/client/client.h | 1 + codemp/client/cl_main.cpp | 2 ++ codemp/client/client.h | 1 + shared/sdl/sdl_input.cpp | 25 +++++++++++++++++++------ 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index b74008c31b..6527a23e6e 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -78,6 +78,7 @@ cvar_t *cl_inGameVideo; cvar_t *cl_consoleKeys; cvar_t *cl_consoleUseScanCode; +cvar_t *cl_consoleShiftRequirement; clientActive_t cl; clientConnection_t clc; @@ -1279,6 +1280,7 @@ void CL_Init( void ) { // ~ and `, as keys and characters cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60 0xb2", CVAR_ARCHIVE); cl_consoleUseScanCode = Cvar_Get( "cl_consoleUseScanCode", "1", CVAR_ARCHIVE ); + cl_consoleShiftRequirement = Cvar_Get( "cl_consoleShiftRequirement", "0", CVAR_ARCHIVE ); // userinfo #ifdef JK2_MODE diff --git a/code/client/client.h b/code/client/client.h index 178fe2a2b3..48517e9029 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -279,6 +279,7 @@ extern cvar_t *cl_activeAction; extern cvar_t *cl_consoleKeys; extern cvar_t *cl_consoleUseScanCode; +extern cvar_t *cl_consoleShiftRequirement; //================================================= diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index b5b07c6fa9..ee86a6ea97 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -100,6 +100,7 @@ cvar_t *cl_autolodscale; cvar_t *cl_consoleKeys; cvar_t *cl_consoleUseScanCode; +cvar_t *cl_consoleShiftRequirement; cvar_t *cl_lanForcePackets; @@ -2773,6 +2774,7 @@ void CL_Init( void ) { // ~ and `, as keys and characters cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60 0xb2", CVAR_ARCHIVE, "Which keys are used to toggle the console"); cl_consoleUseScanCode = Cvar_Get( "cl_consoleUseScanCode", "1", CVAR_ARCHIVE, "Use native console key detection" ); + cl_consoleShiftRequirement = Cvar_Get( "cl_consoleShiftRequirement", "0", CVAR_ARCHIVE, "Require shift key to be pressed for native console key detection" ); // userinfo Cvar_Get ("name", "Padawan", CVAR_USERINFO | CVAR_ARCHIVE_ND, "Player name" ); diff --git a/codemp/client/client.h b/codemp/client/client.h index 4584b2d18a..2ebcfdcece 100644 --- a/codemp/client/client.h +++ b/codemp/client/client.h @@ -410,6 +410,7 @@ extern cvar_t *cl_inGameVideo; extern cvar_t *cl_consoleKeys; extern cvar_t *cl_consoleUseScanCode; +extern cvar_t *cl_consoleShiftRequirement; extern cvar_t *cl_lanForcePackets; diff --git a/shared/sdl/sdl_input.cpp b/shared/sdl/sdl_input.cpp index 5eab5e458f..59e940613b 100644 --- a/shared/sdl/sdl_input.cpp +++ b/shared/sdl/sdl_input.cpp @@ -251,6 +251,23 @@ static void IN_TranslateNumpad( SDL_Keysym *keysym, fakeAscii_t *key ) } } +/* +=============== +IN_ModTogglesConsole +=============== +*/ +static qboolean IN_ModTogglesConsole( int mod ) { + switch (cl_consoleShiftRequirement->integer) { + case 0: + return qtrue; + case 2: + return (qboolean)!!(mod & KMOD_SHIFT); + case 1: + default: + return (qboolean)((mod & KMOD_SHIFT) || (Key_GetCatcher() & KEYCATCH_CONSOLE)); + } +} + /* =============== IN_TranslateSDLToJKKey @@ -376,11 +393,7 @@ static fakeAscii_t IN_TranslateSDLToJKKey( SDL_Keysym *keysym, qboolean down ) { { if ( keysym->scancode == SDL_SCANCODE_GRAVE ) { - SDL_Keycode translated = SDL_GetKeyFromScancode( SDL_SCANCODE_GRAVE ); - - if ( (translated != SDLK_CARET) || (translated == SDLK_CARET && (keysym->mod & KMOD_SHIFT)) ) - { - // Console keys can't be bound or generate characters + if ( IN_ModTogglesConsole(keysym->mod) ) { key = A_CONSOLE; } } @@ -842,7 +855,7 @@ static void IN_ProcessEvents( void ) uint32_t utf32 = ConvertUTF8ToUTF32( c, &c ); if( utf32 != 0 ) { - if( IN_IsConsoleKey( A_NULL, utf32 ) ) + if( IN_IsConsoleKey( A_NULL, utf32 ) && !cl_consoleUseScanCode->integer ) { Sys_QueEvent( 0, SE_KEY, A_CONSOLE, qtrue, 0, NULL ); Sys_QueEvent( 0, SE_KEY, A_CONSOLE, qfalse, 0, NULL ); From c007dfd5b82616dfd9bbffe50574c3734cc9fd1a Mon Sep 17 00:00:00 2001 From: Daggolin Date: Mon, 6 Nov 2023 17:27:20 +0100 Subject: [PATCH 758/801] [Shared] Add con_height cvar to set console height. --- code/client/cl_console.cpp | 4 +++- codemp/client/cl_console.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/client/cl_console.cpp b/code/client/cl_console.cpp index 19c50fd3e2..c948cb342a 100644 --- a/code/client/cl_console.cpp +++ b/code/client/cl_console.cpp @@ -38,6 +38,7 @@ cvar_t *con_conspeed; cvar_t *con_notifytime; cvar_t *con_opacity; // background alpha multiplier cvar_t *con_autoclear; +cvar_t *con_height; #define DEFAULT_CONSOLE_WIDTH 78 @@ -287,6 +288,7 @@ void Con_Init (void) { con_opacity = Cvar_Get ("con_opacity", "0.8", CVAR_ARCHIVE_ND); con_autoclear = Cvar_Get ("con_autoclear", "1", CVAR_ARCHIVE_ND); + con_height = Cvar_Get ("con_height", "0.5", CVAR_ARCHIVE_ND); Field_Clear( &g_consoleField ); g_consoleField.widthInChars = g_console_field_width; @@ -710,7 +712,7 @@ Scroll it up or down void Con_RunConsole (void) { // decide on the destination height of the console if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) - con.finalFrac = 0.5; // half screen + con.finalFrac = con_height->value; else con.finalFrac = 0; // none visible diff --git a/codemp/client/cl_console.cpp b/codemp/client/cl_console.cpp index fa9e170bec..62c95d7899 100644 --- a/codemp/client/cl_console.cpp +++ b/codemp/client/cl_console.cpp @@ -38,6 +38,7 @@ cvar_t *con_conspeed; cvar_t *con_notifytime; cvar_t *con_opacity; // background alpha multiplier cvar_t *con_autoclear; +cvar_t *con_height; #define DEFAULT_CONSOLE_WIDTH 78 @@ -364,6 +365,7 @@ void Con_Init (void) { con_opacity = Cvar_Get ("con_opacity", "1.0", CVAR_ARCHIVE_ND, "Opacity of console background"); con_autoclear = Cvar_Get ("con_autoclear", "1", CVAR_ARCHIVE_ND, "Automatically clear console input on close"); + con_height = Cvar_Get ("con_height", "0.5", CVAR_ARCHIVE_ND); Field_Clear( &g_consoleField ); g_consoleField.widthInChars = g_console_field_width; @@ -878,7 +880,7 @@ Scroll it up or down void Con_RunConsole (void) { // decide on the destination height of the console if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) - con.finalFrac = 0.5; // half screen + con.finalFrac = con_height->value; else con.finalFrac = 0; // none visible From c24eecec72b4cc94deeb65d2bba0a58f3344e1f2 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Mon, 6 Nov 2023 17:40:42 +0100 Subject: [PATCH 759/801] [MP] Add fs_forcegame cvar to override fs_game. --- codemp/qcommon/files.cpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/codemp/qcommon/files.cpp b/codemp/qcommon/files.cpp index 7077b2d4c3..cf9ed5b48b 100644 --- a/codemp/qcommon/files.cpp +++ b/codemp/qcommon/files.cpp @@ -243,6 +243,7 @@ static cvar_t *fs_cdpath; static cvar_t *fs_copyfiles; static cvar_t *fs_gamedirvar; static cvar_t *fs_dirbeforepak; //rww - when building search path, keep directories at top and insert pk3's under them +static cvar_t *fs_forcegame; static searchpath_t *fs_searchpaths; static int fs_readCount; // total bytes read static int fs_loadCount; // total files read @@ -3324,6 +3325,22 @@ void FS_UpdateGamedir(void) FS_AddGameDirectory(fs_homepath->string, fs_gamedirvar->string); } } + + // forcegame allows users to override any fs_game settings + if ( fs_forcegame->string[0] && Q_stricmp(fs_forcegame->string, fs_gamedir) ) { + if ( !fs_basegame->string[0] || Q_stricmp(fs_forcegame->string, fs_basegame->string) ) { + if (fs_cdpath->string[0]) { + FS_AddGameDirectory(fs_cdpath->string, fs_forcegame->string); + } + if (fs_basepath->string[0]) { + FS_AddGameDirectory(fs_basepath->string, fs_forcegame->string); + } + if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) { + FS_AddGameDirectory(fs_homepath->string, fs_forcegame->string); + } + } + Q_strncpyz( fs_gamedir, fs_forcegame->string, sizeof( fs_gamedir ) ); + } } /* @@ -3405,6 +3422,8 @@ void FS_Startup( const char *gameName ) { fs_dirbeforepak = Cvar_Get("fs_dirbeforepak", "0", CVAR_INIT|CVAR_PROTECTED, "Prioritize directories before paks if not pure" ); + fs_forcegame = Cvar_Get ("fs_forcegame", "", CVAR_INIT, "Folder to use for overriding of fs_game (can not be set by the server)." ); + // add search path elements in reverse priority order (lowest priority first) if (fs_cdpath->string[0]) { FS_AddGameDirectory( fs_cdpath->string, gameName ); @@ -3454,6 +3473,22 @@ void FS_Startup( const char *gameName ) { } } + // forcegame allows users to override any fs_game settings + if ( fs_forcegame->string[0] && Q_stricmp(fs_forcegame->string, fs_gamedir) ) { + if ( !fs_basegame->string[0] || Q_stricmp(fs_forcegame->string, fs_basegame->string) ) { + if (fs_cdpath->string[0]) { + FS_AddGameDirectory(fs_cdpath->string, fs_forcegame->string); + } + if (fs_basepath->string[0]) { + FS_AddGameDirectory(fs_basepath->string, fs_forcegame->string); + } + if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) { + FS_AddGameDirectory(fs_homepath->string, fs_forcegame->string); + } + } + Q_strncpyz( fs_gamedir, fs_forcegame->string, sizeof( fs_gamedir ) ); + } + // add our commands Cmd_AddCommand ("path", FS_Path_f, "Lists search paths" ); Cmd_AddCommand ("dir", FS_Dir_f, "Lists a folder" ); @@ -3827,6 +3862,7 @@ void FS_InitFilesystem( void ) { #ifdef MACOS_X Com_StartupVariable( "fs_apppath" ); #endif + Com_StartupVariable( "fs_forcegame" ); if(!FS_FilenameCompare(Cvar_VariableString("fs_game"), BASEGAME)) Cvar_Set("fs_game", ""); @@ -3890,7 +3926,7 @@ void FS_Restart( int checksumFeed ) { Com_Error( ERR_FATAL, "Couldn't load mpdefault.cfg" ); } - if ( Q_stricmp(fs_gamedirvar->string, lastValidGame) ) { + if ( Q_stricmp(fs_gamedirvar->string, lastValidGame) && !fs_forcegame->string[0] ) { // skip the jampconfig.cfg if "safe" is on the command line if ( !Com_SafeMode() ) { Cbuf_AddText ("exec " Q3CONFIG_CFG "\n"); From 4539be30dac6e5246b94a6c5c1b7ab60e58435fe Mon Sep 17 00:00:00 2001 From: Daggolin Date: Mon, 6 Nov 2023 18:22:48 +0100 Subject: [PATCH 760/801] [MP] Prefix downloaded pk3s with the string "dl_" and only load downloaded pk3s when referenced by the server. Ported from jk2mv. --- codemp/qcommon/files.cpp | 99 +++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 22 deletions(-) diff --git a/codemp/qcommon/files.cpp b/codemp/qcommon/files.cpp index cf9ed5b48b..e9ad7bcc55 100644 --- a/codemp/qcommon/files.cpp +++ b/codemp/qcommon/files.cpp @@ -313,6 +313,12 @@ FILE* missingFiles = NULL; # endif #endif +const char *get_filename(const char *path) { + const char *slash = strrchr(path, PATH_SEP); + if (!slash || slash == path) return ""; + return slash + 1; +} + /* ============== FS_Initialized @@ -2986,7 +2992,15 @@ static int QDECL paksort( const void *a, const void *b ) { aa = *(char **)a; bb = *(char **)b; - return FS_PathCmp( aa, bb ); + // downloaded files have priority + // this is needed because otherwise even if a clientside was downloaded, there is no gurantee it is actually used. + if (!Q_stricmpn(aa, "dl_", 3) && Q_stricmpn(bb, "dl_", 3)) { + return 1; + } else if (Q_stricmpn(aa, "dl_", 3) && !Q_stricmpn(bb, "dl_", 3)) { + return -1; + } else { + return FS_PathCmp(aa, bb); + } } /* @@ -3008,6 +3022,7 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { int numfiles; char **pakfiles; char *sorted[MAX_PAKFILES]; + const char *filename; // this fixes the case where fs_basepath is the same as fs_cdpath // which happens on full installs @@ -3052,8 +3067,33 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { for ( i = 0 ; i < numfiles ; i++ ) { pakfile = FS_BuildOSPath( path, dir, sorted[i] ); + filename = get_filename(pakfile); + if ( ( pak = FS_LoadZipFile( pakfile, sorted[i] ) ) == 0 ) continue; + + // files beginning with "dl_" are only loaded when referenced by the server + if (!Q_stricmpn(filename, "dl_", 3)) { + int j; + qboolean found = qfalse; + + for (j = 0; j < fs_numServerReferencedPaks; j++) { + if (pak->checksum == fs_serverReferencedPaks[j]) { + // server wants it! + found = qtrue; + break; + } + } + + if (!found) { + // server has no interest in the file + unzClose(pak->handle); + Z_Free(pak->buildBuffer); + Z_Free(pak); + continue; + } + } + Q_strncpyz(pak->pakPathname, curpath, sizeof(pak->pakPathname)); // store the game name for downloading Q_strncpyz(pak->pakGamename, dir, sizeof(pak->pakGamename)); @@ -3149,9 +3189,12 @@ we are not interested in a download string format, we want something human-reada qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ) { searchpath_t *sp; qboolean havepak; - char *origpos = neededpaks; int i; + char moddir[MAX_ZPATH], filename[MAX_ZPATH]; // If the sum of them exceed 255 characters the game won't accept them + qboolean badname = qfalse; + int read; + if ( !fs_numServerReferencedPaks ) { return qfalse; // Server didn't send any pack information along } @@ -3183,41 +3226,53 @@ qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ) { if ( !havepak && fs_serverReferencedPakNames[i] && *fs_serverReferencedPakNames[i] ) { // Don't got it + read = sscanf(fs_serverReferencedPakNames[i], "%255[^'/']/%255s", moddir, filename); + + if ( read != 2 ) { + Com_Printf( "WARNING: Unable to parse pak name: %s\n", fs_serverReferencedPakNames[i] ); + badname = qtrue; + continue; + } if (dlstring) { - // We need this to make sure we won't hit the end of the buffer or the server could - // overwrite non-pk3 files on clients by writing so much crap into neededpaks that - // Q_strcat cuts off the .pk3 extension. + // To make sure we don't cut anything off we build the string for the current pak in a separate buffer, + // which must be able to hold fs_serverReferencedPakNames[i], the result of st and 6 more characters. As + // st is at least 8 characters longer than fs_serverReferencedPakNames[i] the doubled size of st should + // be enough. + char currentPak[MAX_ZPATH*2]; + + // Don't allow '@' in file names, because the download code splits by them + if ( strchr(fs_serverReferencedPakNames[i], '@') ) { + badname = qtrue; + continue; + } - origpos += strlen(origpos); + *currentPak = 0; // Remote name - Q_strcat( neededpaks, len, "@"); - Q_strcat( neededpaks, len, fs_serverReferencedPakNames[i] ); - Q_strcat( neededpaks, len, ".pk3" ); + Q_strcat( currentPak, sizeof(currentPak), "@"); + Q_strcat( currentPak, sizeof(currentPak), fs_serverReferencedPakNames[i] ); + Q_strcat( currentPak, sizeof(currentPak), ".pk3" ); // Local name - Q_strcat( neededpaks, len, "@"); + Q_strcat( currentPak, sizeof(currentPak), "@"); // Do we have one with the same name? - if ( FS_SV_FileExists( va( "%s.pk3", fs_serverReferencedPakNames[i] ) ) ) { - char st[MAX_ZPATH]; + if (FS_SV_FileExists(va("%s/dl_%s.pk3", moddir, filename))) { // We already have one called this, we need to download it to another name // Make something up with the checksum in it - Com_sprintf( st, sizeof( st ), "%s.%08x.pk3", fs_serverReferencedPakNames[i], fs_serverReferencedPaks[i] ); - Q_strcat( neededpaks, len, st ); + Q_strcat( currentPak, sizeof(currentPak), va("%s/dl_%s.%08x.pk3", moddir, filename, fs_serverReferencedPaks[i]) ); } else { - Q_strcat( neededpaks, len, fs_serverReferencedPakNames[i] ); - Q_strcat( neededpaks, len, ".pk3" ); + Q_strcat( currentPak, sizeof(currentPak), va("%s/dl_%s.pk3", moddir, filename) ); } - // Find out whether it might have overflowed the buffer and don't add this file to the - // list if that is the case. - if(strlen(origpos) + (origpos - neededpaks) >= (unsigned)(len - 1)) - { - *origpos = '\0'; + // If the currentPak doesn't fit the neededpaks buffer we are likely running into issues + if ( strlen(neededpaks) + strlen(currentPak) >= (size_t)len ) { + Com_Printf( S_COLOR_YELLOW "WARNING (FS_ComparePaks): referenced pk3 files cut off due to too long total length\n" ); break; } + + Q_strcat( neededpaks, len, currentPak ); } else { @@ -3232,7 +3287,7 @@ qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ) { } } } - if ( *neededpaks ) { + if ( *neededpaks || badname ) { return qtrue; } From 7ff631688ca85f83110fb8de86b371f65ce7473c Mon Sep 17 00:00:00 2001 From: Daggolin Date: Mon, 6 Nov 2023 19:25:40 +0100 Subject: [PATCH 761/801] [MP] Add reflists and adjust reference conditions (ported from jk2mv). Add ref_whitelist.txt, ref_blacklist.txt and ref_forcelist.txt. Refactor reference handling to be more predictable (by making the reference conditions more explicit). --- codemp/qcommon/files.cpp | 188 ++++++++++++++++++++++++++++++------ codemp/qcommon/qcommon.h | 1 + codemp/server/sv_client.cpp | 61 +----------- 3 files changed, 164 insertions(+), 86 deletions(-) diff --git a/codemp/qcommon/files.cpp b/codemp/qcommon/files.cpp index e9ad7bcc55..13cf61ad36 100644 --- a/codemp/qcommon/files.cpp +++ b/codemp/qcommon/files.cpp @@ -210,6 +210,7 @@ typedef struct pack_s { int pure_checksum; // checksum for pure int numfiles; // number of files in pk3 int referenced; // referenced file flags + qboolean noref; // file is blacklisted for referencing int hashSize; // hash table size (power of 2) fileInPack_t* *hashTable; // hash table fileInPack_t* buildBuffer; // buffer with the filenames etc. @@ -319,6 +320,12 @@ const char *get_filename(const char *path) { return slash + 1; } +const char *get_filename_ext(const char *filename) { + const char *dot = strrchr(filename, '.'); + if (!dot || dot == filename) return ""; + return dot + 1; +} + /* ============== FS_Initialized @@ -1401,41 +1408,47 @@ long FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean unique // The x86.dll suffixes are needed in order for sv_pure to continue to // work on non-x86/windows systems... - l = strlen( filename ); - if ( !(pak->referenced & FS_GENERAL_REF)) { - if( !FS_IsExt(filename, ".shader", l) && - !FS_IsExt(filename, ".txt", l) && - !FS_IsExt(filename, ".str", l) && - !FS_IsExt(filename, ".cfg", l) && - !FS_IsExt(filename, ".config", l) && - !FS_IsExt(filename, ".bot", l) && - !FS_IsExt(filename, ".arena", l) && - !FS_IsExt(filename, ".menu", l) && - !FS_IsExt(filename, ".fcf", l) && - Q_stricmp(filename, "jampgamex86.dll") != 0 && - //Q_stricmp(filename, "vm/qagame.qvm") != 0 && - !strstr(filename, "levelshots")) - { + // reference lists + if ( !pak->noref ) { + // JK2MV automatically references pk3's in three cases: + // 1. A .bsp file is loaded from it (and thus it is expected to be a map) + // 2. cgame.qvm or ui.qvm is loaded from it (expected to be a clientside) + // 3. pk3 is located in fs_game != base (standard jk2 behavior) + // All others need to be referenced manually by the use of reflists. + + if (!Q_stricmp(get_filename_ext(filename), "bsp")) { pak->referenced |= FS_GENERAL_REF; } - } - if (!(pak->referenced & FS_CGAME_REF)) - { - if ( Q_stricmp( filename, "cgame.qvm" ) == 0 || - Q_stricmp( filename, "cgamex86.dll" ) == 0 ) - { + if (!Q_stricmp(filename, "vm/cgame.qvm") || !Q_stricmp( filename, "cgamex86.dll" )) { pak->referenced |= FS_CGAME_REF; } - } - if (!(pak->referenced & FS_UI_REF)) - { - if ( Q_stricmp( filename, "ui.qvm" ) == 0 || - Q_stricmp( filename, "uix86.dll" ) == 0 ) - { + if (!Q_stricmp(filename, "vm/ui.qvm") || !Q_stricmp( filename, "uix86.dll" )) { pak->referenced |= FS_UI_REF; } + + // OLD Ref: + /* + l = strlen( filename ); + if ( !(pak->referenced & FS_GENERAL_REF)) { + if( !FS_IsExt(filename, ".shader", l) && + !FS_IsExt(filename, ".txt", l) && + !FS_IsExt(filename, ".str", l) && + !FS_IsExt(filename, ".cfg", l) && + !FS_IsExt(filename, ".config", l) && + !FS_IsExt(filename, ".bot", l) && + !FS_IsExt(filename, ".arena", l) && + !FS_IsExt(filename, ".menu", l) && + !FS_IsExt(filename, ".fcf", l) && + Q_stricmp(filename, "jampgamex86.dll") != 0 && + //Q_stricmp(filename, "vm/qagame.qvm") != 0 && + !strstr(filename, "levelshots")) + { + pak->referenced |= FS_GENERAL_REF; + } + } + */ } if ( uniqueFILE ) { @@ -3098,6 +3111,11 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { // store the game name for downloading Q_strncpyz(pak->pakGamename, dir, sizeof(pak->pakGamename)); + // if the pk3 is not in base, always reference it (standard jk2 behaviour) + if (Q_stricmpn(pak->pakGamename, BASEGAME, (int)strlen(BASEGAME))) { + pak->referenced |= FS_GENERAL_REF; + } + fs_packFiles += pak->numfiles; search = (searchpath_s *)Z_Malloc (sizeof(searchpath_t), TAG_FILESYS, qtrue); @@ -3456,6 +3474,77 @@ static void FS_ReorderPurePaks() @param gameName Name of the default folder (i.e. always BASEGAME = "base" in OpenJK) */ +void FS_LoadReflists( void ) { + char *mv_whitelist = NULL, *mv_blacklist = NULL, *mv_forcelist = NULL; + fileHandle_t f_w, f_b, f_f; + int f_wl, f_bl, f_fl; + int s; + searchpath_t *search; + + char packstr[MAX_OSPATH]; + + // reference lists + f_wl = FS_FOpenFileRead("ref_whitelist.txt", &f_w, qfalse); + f_bl = FS_FOpenFileRead("ref_blacklist.txt", &f_b, qfalse); + f_fl = FS_FOpenFileRead("ref_forcelist.txt", &f_f, qfalse); + + if (f_w) { + Com_Printf("using whitelist for referenced files...\n"); + + mv_whitelist = (char *)Hunk_AllocateTempMemory(1 + f_wl + 1); + mv_whitelist[0] = '\n'; + s = FS_Read(mv_whitelist + 1, f_wl, f_w); + mv_whitelist[s + 1] = 0; + } + + if (f_b) { + Com_Printf("using blacklist for referenced files...\n"); + + mv_blacklist = (char *)Hunk_AllocateTempMemory(1 + f_bl + 1); + mv_blacklist[0] = '\n'; + s = FS_Read(mv_blacklist + 1, f_bl, f_b); + mv_blacklist[s + 1] = 0; + } + + if (f_f) { + Com_Printf("using forcelist for referenced files...\n"); + + mv_forcelist = (char *)Hunk_AllocateTempMemory(1 + f_fl + 1); + mv_forcelist[0] = '\n'; + s = FS_Read(mv_forcelist + 1, f_fl, f_f); + mv_forcelist[s + 1] = 0; + } + + for (search = fs_searchpaths; search; search = search->next) { + if (search->pack) { + Com_sprintf(packstr, sizeof(packstr), "\n%s/%s.pk3", search->pack->pakGamename, search->pack->pakBasename); + + if (f_w && !Q_stristr(mv_whitelist, packstr)) { + search->pack->noref = qtrue; + search->pack->referenced = 0; + } else if (f_b && Q_stristr(mv_blacklist, packstr)) { + search->pack->noref = qtrue; + search->pack->referenced = 0; + } else if (f_f && Q_stristr(mv_forcelist, packstr)) { + search->pack->referenced |= FS_GENERAL_REF; + } + } + } + + if (f_w) { + FS_FCloseFile(f_w); + Hunk_FreeTempMemory(mv_whitelist); + } + if (f_b) { + FS_FCloseFile(f_b); + Hunk_FreeTempMemory(mv_blacklist); + } + if (f_f) { + FS_FCloseFile(f_f); + Hunk_FreeTempMemory(mv_forcelist); + } +} + void FS_Startup( const char *gameName ) { const char *homePath; @@ -3560,6 +3649,8 @@ void FS_Startup( const char *gameName ) { fs_gamedirvar->modified = qfalse; // We just loaded, it's not modified + FS_LoadReflists(); + Com_Printf( "----------------------\n" ); #ifdef FS_MISSING @@ -3670,7 +3761,7 @@ const char *FS_ReferencedPakChecksums( void ) { for ( search = fs_searchpaths ; search ; search = search->next ) { // is the element a pak file? if ( search->pack ) { - if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, strlen(BASEGAME))) { + if (search->pack->referenced) { Q_strcat( info, sizeof( info ), va("%i ", search->pack->checksum ) ); } } @@ -3749,7 +3840,7 @@ const char *FS_ReferencedPakNames( void ) { for ( search = fs_searchpaths ; search ; search = search->next ) { // is the element a pak file? if ( search->pack ) { - if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, strlen(BASEGAME))) { + if (search->pack->referenced) { if (*info) { Q_strcat(info, sizeof( info ), " " ); } @@ -4324,3 +4415,42 @@ qboolean FS_WriteToTemporaryFile( const void *data, size_t dataLength, char **te return qfalse; } + +// only referenced pk3 files can be downloaded +// returns the path to the GameData directory of the requested file. +const char *FS_MV_VerifyDownloadPath(const char *pk3file) { + char path[MAX_OSPATH]; + searchpath_t *search; + + for (search = fs_searchpaths; search; search = search->next) { + if (!search->pack) + continue; + + Com_sprintf(path, sizeof(path), "%s/%s", search->pack->pakGamename, search->pack->pakBasename); + if (FS_idPak(path, BASEGAME)) + continue; + + Q_strcat(path, sizeof(path), ".pk3"); + + if (!Q_stricmp(path, pk3file)) { + if (search->pack->noref) + return NULL; + + if (search->pack->referenced) { + static char gameDataPath[MAX_OSPATH]; + Q_strncpyz(gameDataPath, search->pack->pakFilename, sizeof(gameDataPath)); + + char *sp = strrchr(gameDataPath, PATH_SEP); + if ( sp ) *sp = 0; + else return NULL; + sp = strrchr(gameDataPath, PATH_SEP); + if ( sp ) *sp = 0; + else return NULL; + + return gameDataPath; + } + } + } + + return NULL; +} diff --git a/codemp/qcommon/qcommon.h b/codemp/qcommon/qcommon.h index c4dbdacfb9..47d53681ab 100644 --- a/codemp/qcommon/qcommon.h +++ b/codemp/qcommon/qcommon.h @@ -706,6 +706,7 @@ qboolean FS_ComparePaks( char *neededpaks, int len, qboolean dlstring ); void FS_Rename( const char *from, const char *to ); qboolean FS_WriteToTemporaryFile( const void *data, size_t dataLength, char **tempFileName ); +const char *FS_MV_VerifyDownloadPath(const char *pk3file); /* diff --git a/codemp/server/sv_client.cpp b/codemp/server/sv_client.cpp index 073fbbe6a4..fb2d4418ca 100644 --- a/codemp/server/sv_client.cpp +++ b/codemp/server/sv_client.cpp @@ -716,80 +716,27 @@ void SV_WriteDownloadToClient(client_t *cl, msg_t *msg) int curindex; int rate; int blockspersnap; - int unreferenced = 1; char errorMessage[1024]; - char pakbuf[MAX_QPATH], *pakptr; - int numRefPaks; if (!*cl->downloadName) return; // Nothing being downloaded if(!cl->download) { - qboolean idPack = qfalse; - qboolean missionPack = qfalse; - - // Chop off filename extension. - Com_sprintf(pakbuf, sizeof(pakbuf), "%s", cl->downloadName); - pakptr = strrchr(pakbuf, '.'); - - if(pakptr) - { - *pakptr = '\0'; - - // Check for pk3 filename extension - if(!Q_stricmp(pakptr + 1, "pk3")) - { - const char *referencedPaks = FS_ReferencedPakNames(); - - // Check whether the file appears in the list of referenced - // paks to prevent downloading of arbitrary files. - Cmd_TokenizeStringIgnoreQuotes(referencedPaks); - numRefPaks = Cmd_Argc(); - - for(curindex = 0; curindex < numRefPaks; curindex++) - { - if(!FS_FilenameCompare(Cmd_Argv(curindex), pakbuf)) - { - unreferenced = 0; - - // now that we know the file is referenced, - // check whether it's legal to download it. - missionPack = FS_idPak(pakbuf, "missionpack"); - idPack = missionPack; - idPack = (qboolean)(idPack || FS_idPak(pakbuf, BASEGAME)); - - break; - } - } - } - } + qboolean allowDownload = FS_MV_VerifyDownloadPath( cl->downloadName ) ? qtrue : qfalse; cl->download = 0; // We open the file here if ( !sv_allowDownload->integer || - idPack || unreferenced || + !allowDownload || ( cl->downloadSize = FS_SV_FOpenFileRead( cl->downloadName, &cl->download ) ) < 0 ) { // cannot auto-download file - if(unreferenced) + if( !allowDownload ) { Com_Printf("clientDownload: %d : \"%s\" is not referenced and cannot be downloaded.\n", (int) (cl - svs.clients), cl->downloadName); Com_sprintf(errorMessage, sizeof(errorMessage), "File \"%s\" is not referenced and cannot be downloaded.", cl->downloadName); - } - else if (idPack) { - Com_Printf("clientDownload: %d : \"%s\" cannot download id pk3 files\n", (int) (cl - svs.clients), cl->downloadName); - if(missionPack) - { - Com_sprintf(errorMessage, sizeof(errorMessage), "Cannot autodownload Team Arena file \"%s\"\n" - "The Team Arena mission pack can be found in your local game store.", cl->downloadName); - } - else - { - Com_sprintf(errorMessage, sizeof(errorMessage), "Cannot autodownload id pk3 file \"%s\"", cl->downloadName); - } - } - else if ( !sv_allowDownload->integer ) { + } else if ( !sv_allowDownload->integer ) { Com_Printf("clientDownload: %d : \"%s\" download disabled\n", (int) (cl - svs.clients), cl->downloadName); if (sv_pure->integer) { Com_sprintf(errorMessage, sizeof(errorMessage), "Could not download \"%s\" because autodownloading is disabled on the server.\n\n" From e3930aba64380bdb833354a880abbe92b4571a16 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Mon, 6 Nov 2023 21:40:02 +0100 Subject: [PATCH 762/801] [Shared] Don't unpack/load native libraries from pk3s by default. As many users don't review the content of pk3s when installing mods and as cl_allowDownload can download pk3s from the server the pk3 files in the gamne folder should not be considered trustworthy enough to run native libraries from. In case a user really needs it the unpacking of native libraries can be reenabled with a protected init cvar: com_unpackLibraries. --- shared/sys/sys_main.cpp | 59 +++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/shared/sys/sys_main.cpp b/shared/sys/sys_main.cpp index fd103e713f..eae2c29d6c 100644 --- a/shared/sys/sys_main.cpp +++ b/shared/sys/sys_main.cpp @@ -40,6 +40,7 @@ cvar_t *com_unfocused; cvar_t *com_maxfps; cvar_t *com_maxfpsMinimized; cvar_t *com_maxfpsUnfocused; +cvar_t *com_unpackLibraries; /* ================= @@ -164,6 +165,8 @@ void Sys_Init( void ) { #endif com_maxfpsUnfocused = Cvar_Get( "com_maxfpsUnfocused", "0", CVAR_ARCHIVE_ND ); com_maxfpsMinimized = Cvar_Get( "com_maxfpsMinimized", "50", CVAR_ARCHIVE_ND ); + + com_unpackLibraries = Cvar_Get( "com_unpackLibraries", "0", CVAR_INIT|CVAR_PROTECTED ); } static void NORETURN Sys_Exit( int ex ) { @@ -473,22 +476,24 @@ void *Sys_LoadLegacyGameDll( const char *name, VMMainProc **vmMain, SystemCallPr if ( !libHandle ) #endif { - UnpackDLLResult unpackResult = Sys_UnpackDLL(filename); - if ( !unpackResult.succeeded ) - { - if ( Sys_DLLNeedsUnpacking() ) + if ( com_unpackLibraries->integer ) { + UnpackDLLResult unpackResult = Sys_UnpackDLL(filename); + if ( !unpackResult.succeeded ) { - FreeUnpackDLLResult(&unpackResult); - Com_DPrintf( "Sys_LoadLegacyGameDll: Failed to unpack %s from PK3.\n", filename ); - return NULL; + if ( Sys_DLLNeedsUnpacking() ) + { + FreeUnpackDLLResult(&unpackResult); + Com_DPrintf( "Sys_LoadLegacyGameDll: Failed to unpack %s from PK3.\n", filename ); + return NULL; + } + } + else + { + libHandle = Sys_LoadLibrary(unpackResult.tempDLLPath); } - } - else - { - libHandle = Sys_LoadLibrary(unpackResult.tempDLLPath); - } - FreeUnpackDLLResult(&unpackResult); + FreeUnpackDLLResult(&unpackResult); + } if ( !libHandle ) { @@ -604,22 +609,24 @@ void *Sys_LoadGameDll( const char *name, GetModuleAPIProc **moduleAPI ) if ( !libHandle ) #endif { - UnpackDLLResult unpackResult = Sys_UnpackDLL(filename); - if ( !unpackResult.succeeded ) - { - if ( Sys_DLLNeedsUnpacking() ) + if ( com_unpackLibraries->integer ) { + UnpackDLLResult unpackResult = Sys_UnpackDLL(filename); + if ( !unpackResult.succeeded ) { - FreeUnpackDLLResult(&unpackResult); - Com_DPrintf( "Sys_LoadLegacyGameDll: Failed to unpack %s from PK3.\n", filename ); - return NULL; + if ( Sys_DLLNeedsUnpacking() ) + { + FreeUnpackDLLResult(&unpackResult); + Com_DPrintf( "Sys_LoadLegacyGameDll: Failed to unpack %s from PK3.\n", filename ); + return NULL; + } + } + else + { + libHandle = Sys_LoadLibrary(unpackResult.tempDLLPath); } - } - else - { - libHandle = Sys_LoadLibrary(unpackResult.tempDLLPath); - } - FreeUnpackDLLResult(&unpackResult); + FreeUnpackDLLResult(&unpackResult); + } if ( !libHandle ) { From 8690f739691a39c5e9ee3469988e9c173c56006d Mon Sep 17 00:00:00 2001 From: Daggolin Date: Mon, 6 Nov 2023 21:51:08 +0100 Subject: [PATCH 763/801] [Shared] Workaround for high kernel load when using many pk3s. As the filesystem is initialized before the network socket the file descriptors of the ip_socket turns out to be very high if many pk3s are loaded. When calling NET_Sleep the select call is used to sleep unless something arrives on the network socket. Due to its high number the highestfd value given to the select call is very high and covers alls open files, leading to high load on some systems. As a workaround this commit calls NET_Init before initializing the filesystem. --- code/qcommon/common.cpp | 3 +++ codemp/qcommon/common.cpp | 3 +++ shared/sys/sys_main.cpp | 2 -- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/qcommon/common.cpp b/code/qcommon/common.cpp index cb4fe06de2..7087c82557 100644 --- a/code/qcommon/common.cpp +++ b/code/qcommon/common.cpp @@ -1075,6 +1075,9 @@ void Com_Init( char *commandLine ) { com_homepath = Cvar_Get("com_homepath", "", CVAR_INIT); + // Init network before filesystem + NET_Init(); + FS_InitFilesystem (); //uses z_malloc //re.R_InitWorldEffects(); // this doesn't do much but I want to be sure certain variables are intialized. diff --git a/codemp/qcommon/common.cpp b/codemp/qcommon/common.cpp index 8cceb640e9..0d0cca1ae2 100644 --- a/codemp/qcommon/common.cpp +++ b/codemp/qcommon/common.cpp @@ -1166,6 +1166,9 @@ void Com_Init( char *commandLine ) { com_homepath = Cvar_Get("com_homepath", "", CVAR_INIT); + // Init network before filesystem + NET_Init(); + FS_InitFilesystem (); Com_InitJournaling(); diff --git a/shared/sys/sys_main.cpp b/shared/sys/sys_main.cpp index eae2c29d6c..541a83e082 100644 --- a/shared/sys/sys_main.cpp +++ b/shared/sys/sys_main.cpp @@ -788,8 +788,6 @@ int main ( int argc, char* argv[] ) Com_Printf( "SDL Version Linked: %d.%d.%d\n", linked.major, linked.minor, linked.patch ); #endif - NET_Init(); - // main game loop while (1) { From 19c162ca4a81630ae8272c34f10a4705f379d853 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Mon, 6 Nov 2023 22:38:23 +0100 Subject: [PATCH 764/801] [Shared] Add fs_restart command to restart filesystem if no module holds a handle for a file inside of a pk3. --- code/qcommon/files.cpp | 34 ++++++++++++++++++++++++++++++---- code/qcommon/qcommon.h | 4 +++- code/ui/ui_main.cpp | 2 +- codemp/qcommon/files.cpp | 34 ++++++++++++++++++++++++++++++---- codemp/qcommon/qcommon.h | 4 ++-- 5 files changed, 66 insertions(+), 12 deletions(-) diff --git a/code/qcommon/files.cpp b/code/qcommon/files.cpp index c35d0e00f5..ab1ebbbd22 100644 --- a/code/qcommon/files.cpp +++ b/code/qcommon/files.cpp @@ -2685,6 +2685,29 @@ void FS_Which_f( void ) { Com_Printf( "File not found: \"%s\"\n", filename ); } +/* +============ +FS_Restart_f +============ +*/ +static qboolean FS_CanRestartInPlace( void ) { + int i; + for ( i = 1; i < MAX_FILE_HANDLES; i++ ) { + // If we have an active filehandle for a module that references a zip file we cannot restart. + if ( fsh[i].fileSize ) { + if ( fsh[i].zipFile ) return qfalse; + } + } + return qtrue; +} +static void FS_Restart_f( void ) { + if ( !FS_CanRestartInPlace() ) { + Com_Printf( "^3WARNING: Cannot restart file system due to active file handles for pk3 files inside of modules.\n" ); + return; + } + FS_Restart( qtrue ); +} + //=========================================================================== static int QDECL paksort( const void *a, const void *b ) { @@ -2819,13 +2842,14 @@ FS_Shutdown Frees all resources and closes all files ================ */ -void FS_Shutdown( void ) { +void FS_Shutdown( qboolean keepModuleFiles ) { searchpath_t *p, *next; int i; for(i = 0; i < MAX_FILE_HANDLES; i++) { if (fsh[i].fileSize) { - FS_FCloseFile(i); + if ( !keepModuleFiles ) FS_FCloseFile(i); + else if ( fsh[i].zipFile ) Com_Error(ERR_FATAL, "FS_Shutdown: tried to keep module files when at least one module file is inside of a pak"); } } @@ -2850,6 +2874,7 @@ void FS_Shutdown( void ) { Cmd_RemoveCommand( "fdir" ); Cmd_RemoveCommand( "touchFile" ); Cmd_RemoveCommand( "which" ); + Cmd_RemoveCommand( "fs_restart" ); } /* @@ -2935,6 +2960,7 @@ void FS_Startup( const char *gameName ) { Cmd_AddCommand ("fdir", FS_NewDir_f ); Cmd_AddCommand ("touchFile", FS_TouchFile_f ); Cmd_AddCommand ("which", FS_Which_f ); + Cmd_AddCommand ("fs_restart", FS_Restart_f ); // print the current search paths FS_Path_f(); @@ -2998,10 +3024,10 @@ void FS_InitFilesystem( void ) { FS_Restart ================ */ -void FS_Restart( void ) { +void FS_Restart( qboolean inPlace ) { // free anything we currently have loaded - FS_Shutdown(); + FS_Shutdown( inPlace ); // try to start up normally FS_Startup( BASEGAME ); diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 70580daf9d..cc71c86a0a 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -445,7 +445,9 @@ issues. qboolean FS_Initialized(); void FS_InitFilesystem (void); -void FS_Shutdown( void ); +void FS_Shutdown( qboolean inPlace = qfalse ); + +void FS_Restart( qboolean inPlace = qfalse ); qboolean FS_ConditionalRestart( void ); diff --git a/code/ui/ui_main.cpp b/code/ui/ui_main.cpp index b6d4fed156..30f22ec16d 100644 --- a/code/ui/ui_main.cpp +++ b/code/ui/ui_main.cpp @@ -994,7 +994,7 @@ static qboolean UI_RunMenuScript ( const char **args ) if (uiInfo.modList[uiInfo.modIndex].modName) { Cvar_Set( "fs_game", uiInfo.modList[uiInfo.modIndex].modName); - extern void FS_Restart( void ); + extern void FS_Restart( qboolean inPlace = qfalse ); FS_Restart(); Cbuf_ExecuteText( EXEC_APPEND, "vid_restart;" ); } diff --git a/codemp/qcommon/files.cpp b/codemp/qcommon/files.cpp index 13cf61ad36..6892aca854 100644 --- a/codemp/qcommon/files.cpp +++ b/codemp/qcommon/files.cpp @@ -2997,6 +2997,29 @@ void FS_Which_f( void ) { Com_Printf( "File not found: \"%s\"\n", filename ); } +/* +============ +FS_Restart_f +============ +*/ +static qboolean FS_CanRestartInPlace( void ) { + int i; + for ( i = 1; i < MAX_FILE_HANDLES; i++ ) { + // If we have an active filehandle for a module that references a zip file we cannot restart. + if ( fsh[i].fileSize ) { + if ( fsh[i].zipFile ) return qfalse; + } + } + return qtrue; +} +static void FS_Restart_f( void ) { + if ( !FS_CanRestartInPlace() ) { + Com_Printf( "^3WARNING: Cannot restart file system due to active file handles for pk3 files inside of modules.\n" ); + return; + } + FS_Restart( fs_checksumFeed, qtrue ); +} + //=========================================================================== static int QDECL paksort( const void *a, const void *b ) { @@ -3319,7 +3342,7 @@ FS_Shutdown Frees all resources and closes all files ================ */ -void FS_Shutdown( qboolean closemfp ) { +void FS_Shutdown( qboolean closemfp, qboolean keepModuleFiles ) { searchpath_t *p, *next; int i; @@ -3346,7 +3369,8 @@ void FS_Shutdown( qboolean closemfp ) { for(i = 0; i < MAX_FILE_HANDLES; i++) { if (fsh[i].fileSize) { - FS_FCloseFile(i); + if ( !keepModuleFiles ) FS_FCloseFile(i); + else if ( fsh[i].zipFile ) Com_Error(ERR_FATAL, "FS_Shutdown: tried to keep module files when at least one module file is inside of a pak"); } } @@ -3371,6 +3395,7 @@ void FS_Shutdown( qboolean closemfp ) { Cmd_RemoveCommand( "fdir" ); Cmd_RemoveCommand( "touchFile" ); Cmd_RemoveCommand( "which" ); + Cmd_RemoveCommand( "fs_restart" ); #ifdef FS_MISSING if (closemfp) { @@ -3639,6 +3664,7 @@ void FS_Startup( const char *gameName ) { Cmd_AddCommand ("fdir", FS_NewDir_f, "Lists a folder with filters" ); Cmd_AddCommand ("touchFile", FS_TouchFile_f, "Touches a file" ); Cmd_AddCommand ("which", FS_Which_f, "Determines which search path a file was loaded from" ); + Cmd_AddCommand ("fs_restart", FS_Restart_f, "Restarts the filesystem if no module is currently using files from a pk3" ); // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=506 // reorder the pure pk3 files according to server order @@ -4039,10 +4065,10 @@ void FS_InitFilesystem( void ) { FS_Restart ================ */ -void FS_Restart( int checksumFeed ) { +void FS_Restart( int checksumFeed, qboolean inPlace ) { // free anything we currently have loaded - FS_Shutdown(qfalse); + FS_Shutdown(qfalse, inPlace); // set the checksum feed fs_checksumFeed = checksumFeed; diff --git a/codemp/qcommon/qcommon.h b/codemp/qcommon/qcommon.h index 47d53681ab..1b5c0324c9 100644 --- a/codemp/qcommon/qcommon.h +++ b/codemp/qcommon/qcommon.h @@ -577,10 +577,10 @@ issues. qboolean FS_Initialized(); void FS_InitFilesystem (void); -void FS_Shutdown( qboolean closemfp ); +void FS_Shutdown( qboolean closemfp, qboolean keepModuleFiles = qfalse ); qboolean FS_ConditionalRestart( int checksumFeed ); -void FS_Restart( int checksumFeed ); +void FS_Restart( int checksumFeed, qboolean inPlace = qfalse ); // shutdown and restart the filesystem so changes to fs_gamedir can take effect char **FS_ListFiles( const char *directory, const char *extension, int *numfiles ); From fb888be098aaaadd2db3c304d8eb857ab3697537 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Mon, 6 Nov 2023 22:52:52 +0100 Subject: [PATCH 765/801] [Shared] Remove hardcoded limit of 1024 pk3s. Try to increase the maximum allowed file descriptors to 4096 on start (can be overriden with "-maxfds" on launch). Ported from jk2mv. --- code/qcommon/files.cpp | 17 ++++------------- codemp/qcommon/files.cpp | 17 ++++------------- shared/sys/sys_local.h | 2 +- shared/sys/sys_main.cpp | 2 +- shared/sys/sys_unix.cpp | 26 +++++++++++++++++++++++++- shared/sys/sys_win32.cpp | 22 +++++++++++++++++++++- 6 files changed, 56 insertions(+), 30 deletions(-) diff --git a/code/qcommon/files.cpp b/code/qcommon/files.cpp index ab1ebbbd22..d105742d2f 100644 --- a/code/qcommon/files.cpp +++ b/code/qcommon/files.cpp @@ -2727,7 +2727,6 @@ Sets fs_gamedir, adds the directory to the head of the path, then loads the zip headers ================ */ -#define MAX_PAKFILES 1024 static void FS_AddGameDirectory( const char *path, const char *dir ) { searchpath_t *sp; int i; @@ -2737,7 +2736,6 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { char curpath[MAX_OSPATH + 1], *pakfile; int numfiles; char **pakfiles; - char *sorted[MAX_PAKFILES]; // this fixes the case where fs_basepath is the same as fs_cdpath // which happens on full installs @@ -2771,20 +2769,13 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { pakfiles = Sys_ListFiles( curpath, ".pk3", NULL, &numfiles, qfalse ); - // sort them so that later alphabetic matches override - // earlier ones. This makes pak1.pk3 override pak0.pk3 - if ( numfiles > MAX_PAKFILES ) { - numfiles = MAX_PAKFILES; + if ( numfiles > 1 ) { + qsort( pakfiles, numfiles, sizeof(char*), paksort ); } - for ( i = 0 ; i < numfiles ; i++ ) { - sorted[i] = pakfiles[i]; - } - - qsort( sorted, numfiles, sizeof(char*), paksort ); for ( i = 0 ; i < numfiles ; i++ ) { - pakfile = FS_BuildOSPath( path, dir, sorted[i] ); - if ( ( pak = FS_LoadZipFile( pakfile, sorted[i] ) ) == 0 ) + pakfile = FS_BuildOSPath( path, dir, pakfiles[i] ); + if ( ( pak = FS_LoadZipFile( pakfile, pakfiles[i] ) ) == 0 ) continue; Q_strncpyz(pak->pakPathname, curpath, sizeof(pak->pakPathname)); // store the game name for downloading diff --git a/codemp/qcommon/files.cpp b/codemp/qcommon/files.cpp index 6892aca854..9529217d75 100644 --- a/codemp/qcommon/files.cpp +++ b/codemp/qcommon/files.cpp @@ -3047,7 +3047,6 @@ Sets fs_gamedir, adds the directory to the head of the path, then loads the zip headers ================ */ -#define MAX_PAKFILES 1024 static void FS_AddGameDirectory( const char *path, const char *dir ) { searchpath_t *sp; int i; @@ -3057,7 +3056,6 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { char curpath[MAX_OSPATH + 1], *pakfile; int numfiles; char **pakfiles; - char *sorted[MAX_PAKFILES]; const char *filename; // this fixes the case where fs_basepath is the same as fs_cdpath @@ -3090,22 +3088,15 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { pakfiles = Sys_ListFiles( curpath, ".pk3", NULL, &numfiles, qfalse ); - // sort them so that later alphabetic matches override - // earlier ones. This makes pak1.pk3 override pak0.pk3 - if ( numfiles > MAX_PAKFILES ) { - numfiles = MAX_PAKFILES; + if ( numfiles > 1 ) { + qsort( pakfiles, numfiles, sizeof(char*), paksort ); } - for ( i = 0 ; i < numfiles ; i++ ) { - sorted[i] = pakfiles[i]; - } - - qsort( sorted, numfiles, sizeof(char*), paksort ); for ( i = 0 ; i < numfiles ; i++ ) { - pakfile = FS_BuildOSPath( path, dir, sorted[i] ); + pakfile = FS_BuildOSPath( path, dir, pakfiles[i] ); filename = get_filename(pakfile); - if ( ( pak = FS_LoadZipFile( pakfile, sorted[i] ) ) == 0 ) + if ( ( pak = FS_LoadZipFile( pakfile, pakfiles[i] ) ) == 0 ) continue; // files beginning with "dl_" are only loaded when referenced by the server diff --git a/shared/sys/sys_local.h b/shared/sys/sys_local.h index 815adc5eff..2a404f4c05 100644 --- a/shared/sys/sys_local.h +++ b/shared/sys/sys_local.h @@ -28,7 +28,7 @@ void IN_Frame( void ); void IN_Shutdown( void ); void IN_Restart( void ); -void Sys_PlatformInit( void ); +void Sys_PlatformInit( int argc, char *argv[] ); void Sys_PlatformExit( void ); qboolean Sys_GetPacket( netadr_t *net_from, msg_t *net_message ); char *Sys_ConsoleInput( void ); diff --git a/shared/sys/sys_main.cpp b/shared/sys/sys_main.cpp index 541a83e082..7c8dcf9127 100644 --- a/shared/sys/sys_main.cpp +++ b/shared/sys/sys_main.cpp @@ -745,7 +745,7 @@ int main ( int argc, char* argv[] ) int i; char commandLine[ MAX_STRING_CHARS ] = { 0 }; - Sys_PlatformInit(); + Sys_PlatformInit( argc, argv ); CON_Init(); // get the initial time base diff --git a/shared/sys/sys_unix.cpp b/shared/sys/sys_unix.cpp index 96f5b7aab3..aec3becab8 100644 --- a/shared/sys/sys_unix.cpp +++ b/shared/sys/sys_unix.cpp @@ -32,6 +32,7 @@ along with this program; if not, see . #include #include #include +#include #include "qcommon/qcommon.h" #include "qcommon/q_shared.h" @@ -42,7 +43,11 @@ qboolean stdinIsATTY = qfalse; // Used to determine where to store user-specific files static char homePath[ MAX_OSPATH ] = { 0 }; -void Sys_PlatformInit( void ) +// Max open file descriptors. Mostly used by pk3 files with +// MAX_SEARCH_PATHS limit. +#define MAX_OPEN_FILES 4096 + +void Sys_PlatformInit( int argc, char *argv[] ) { const char* term = getenv( "TERM" ); @@ -56,6 +61,25 @@ void Sys_PlatformInit( void ) stdinIsATTY = qtrue; else stdinIsATTY = qfalse; + + // raise open file limit to allow more pk3 files + int retval; + struct rlimit rlim; + rlim_t maxfds = MAX_OPEN_FILES; + + for (int i = 1; i + 1 < argc; i++) { + if (!Q_stricmp(argv[i], "-maxfds")) { + maxfds = atoi(argv[i + 1]); + } + } + + getrlimit(RLIMIT_NOFILE, &rlim); + rlim.rlim_cur = Q_min(maxfds, rlim.rlim_max); + retval = setrlimit(RLIMIT_NOFILE, &rlim); + + if (retval == -1) { + Com_Printf("Warning: Failed to raise open file limit. %s\n", strerror(errno)); + } } void Sys_PlatformExit( void ) diff --git a/shared/sys/sys_win32.cpp b/shared/sys/sys_win32.cpp index 5b6c234cf5..829b9b7467 100644 --- a/shared/sys/sys_win32.cpp +++ b/shared/sys/sys_win32.cpp @@ -542,7 +542,12 @@ Sys_PlatformInit Platform-specific initialization ================ */ -void Sys_PlatformInit( void ) { + +// Max open file descriptors. Mostly used by pk3 files with +// MAX_SEARCH_PATHS limit. +#define MAX_OPEN_FILES 4096 + +void Sys_PlatformInit( int argc, char *argv[] ) { TIMECAPS ptc; if ( timeGetDevCaps( &ptc, sizeof( ptc ) ) == MMSYSERR_NOERROR ) { @@ -558,6 +563,21 @@ void Sys_PlatformInit( void ) { } else timerResolution = 0; + + // raise open file limit to allow more pk3 files + int maxfds = MAX_OPEN_FILES; + + for (int i = 1; i + 1 < argc; i++) { + if (!Q_stricmp(argv[i], "-maxfds")) { + maxfds = atoi(argv[i + 1]); + } + } + + maxfds = _setmaxstdio(maxfds); + + if (maxfds == -1) { + Com_Printf("Warning: Failed to increase open file limit. %s\n", strerror(errno)); + } } /* From ec944bb8b3f56b348d9a5263a09b141363dbeec5 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Thu, 9 Nov 2023 17:35:05 +0100 Subject: [PATCH 766/801] [Shared] Draw console prompt even when renderer cmd queue overflows from too much text. mvdevs/jk2mv@634e5b2 --- code/client/cl_console.cpp | 6 +++--- codemp/client/cl_console.cpp | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/code/client/cl_console.cpp b/code/client/cl_console.cpp index c948cb342a..3022dc55f3 100644 --- a/code/client/cl_console.cpp +++ b/code/client/cl_console.cpp @@ -576,6 +576,9 @@ void Con_DrawSolidConsole( float frac ) (lines-(SMALLCHAR_HEIGHT+SMALLCHAR_HEIGHT/2)), Q3_VERSION[x] ); } + // draw the input prompt, user text, and cursor if desired + Con_DrawInput (); + // draw the text con.vislines = lines; rows = (lines-SMALLCHAR_WIDTH)/SMALLCHAR_WIDTH; // rows of text to draw @@ -665,9 +668,6 @@ void Con_DrawSolidConsole( float frac ) } } - // draw the input prompt, user text, and cursor if desired - Con_DrawInput (); - re.SetColor( NULL ); } diff --git a/codemp/client/cl_console.cpp b/codemp/client/cl_console.cpp index 62c95d7899..5fc61fe427 100644 --- a/codemp/client/cl_console.cpp +++ b/codemp/client/cl_console.cpp @@ -745,6 +745,8 @@ void Con_DrawSolidConsole( float frac ) { (lines-(SMALLCHAR_HEIGHT+SMALLCHAR_HEIGHT/2)), JK_VERSION[x] ); } + // draw the input prompt, user text, and cursor if desired + Con_DrawInput (); // draw the text con.vislines = lines; @@ -833,9 +835,6 @@ void Con_DrawSolidConsole( float frac ) { } } - // draw the input prompt, user text, and cursor if desired - Con_DrawInput (); - re->SetColor( NULL ); } From 80352dbdb92945908b6600e76a9d2cfbb0d22867 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Thu, 9 Nov 2023 20:40:52 +0100 Subject: [PATCH 767/801] [Shared] Port console features from jk2mv. This includes con_scale, con_timestamps, changes to line wrapping, condump, ... Most of these changes were originally written by fau and have more context within the jk2mv repository. --- code/client/cl_console.cpp | 493 +++++++++++++++++++++++------------ code/client/cl_keys.cpp | 15 +- code/client/cl_scrn.cpp | 8 +- code/client/client.h | 14 +- code/client/keys.h | 4 +- code/qcommon/qcommon.h | 2 +- codemp/client/cl_console.cpp | 493 +++++++++++++++++++++++------------ codemp/client/cl_keys.cpp | 15 +- codemp/client/cl_scrn.cpp | 6 +- codemp/client/client.h | 16 +- codemp/client/keys.h | 4 +- shared/qcommon/q_string.c | 21 ++ shared/qcommon/q_string.h | 1 + 13 files changed, 729 insertions(+), 363 deletions(-) diff --git a/code/client/cl_console.cpp b/code/client/cl_console.cpp index 3022dc55f3..d40832a538 100644 --- a/code/client/cl_console.cpp +++ b/code/client/cl_console.cpp @@ -39,9 +39,21 @@ cvar_t *con_notifytime; cvar_t *con_opacity; // background alpha multiplier cvar_t *con_autoclear; cvar_t *con_height; +cvar_t *con_scale; +cvar_t *con_timestamps; #define DEFAULT_CONSOLE_WIDTH 78 +#define CON_BLANK_CHAR ' ' +#define CON_SCROLL_L_CHAR '$' +#define CON_SCROLL_R_CHAR '$' +#define CON_TIMESTAMP_LEN 11 // "[13:37:00] " +#define CON_MIN_WIDTH 20 + + +static const conChar_t CON_WRAP = { { ColorIndex(COLOR_GREY), '\\' } }; +static const conChar_t CON_BLANK = { { ColorIndex(COLOR_WHITE), CON_BLANK_CHAR } }; + vec4_t console_color = {0.509f, 0.609f, 0.847f, 1.0f}; /* @@ -83,7 +95,7 @@ void Con_Clear_f (void) { int i; for ( i = 0 ; i < CON_TEXTSIZE ; i++ ) { - con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' '; + con.text[i] = CON_BLANK; } Con_Bottom(); // go to end @@ -98,12 +110,17 @@ Save the console contents out to a file */ void Con_Dump_f (void) { - int l, x, i; - short *line; + char filename[MAX_QPATH]; + qboolean empty; + int l, i, j; + int line; + int lineLen; fileHandle_t f; - int bufferlen; - char *buffer; - char filename[MAX_QPATH]; +#ifdef WIN32 + char buffer[CON_TIMESTAMP_LEN + MAXPRINTMSG + 2]; +#else + char buffer[CON_TIMESTAMP_LEN + MAXPRINTMSG + 1]; +#endif if (Cmd_Argc() != 2) { @@ -130,47 +147,59 @@ void Con_Dump_f (void) Com_Printf ("Dumped console text to %s.\n", filename ); // skip empty lines - for (l = con.current - con.totallines + 1 ; l <= con.current ; l++) + for (l = 1, empty = qtrue ; l < con.totallines && empty ; l++) { - line = con.text + (l%con.totallines)*con.linewidth; - for (x=0 ; xinteger) { + line = ((con.current + l) % con.totallines) * con.rowwidth; - // write the remaining lines - buffer[bufferlen-1] = 0; - for ( ; l <= con.current ; l++) - { - line = con.text + (l%con.totallines)*con.linewidth; - for(i=0; i=0 ; x--) + for (i = 0; i < CON_TIMESTAMP_LEN; i++) + buffer[i] = con.text[line + i].f.character; + + lineLen = CON_TIMESTAMP_LEN; + } + + // Concatenate wrapped lines + for ( ; l < con.totallines ; l++) { - if (buffer[x] == ' ') - buffer[x] = 0; - else + line = ((con.current + l) % con.totallines) * con.rowwidth; + + for (j = CON_TIMESTAMP_LEN; j < con.rowwidth - 1 && i < (int)sizeof(buffer) - 1; j++, i++) { + buffer[i] = con.text[line + j].f.character; + + if (con.text[line + j].f.character != CON_BLANK_CHAR) + lineLen = i + 1; + } + + if (i == sizeof(buffer) - 1) + break; + + if (con.text[line + j].compare != CON_WRAP.compare) break; } -#ifdef _WIN32 - Q_strcat(buffer, bufferlen, "\r\n"); + +#ifdef WIN32 // I really don't like this inconsistency, but OpenJK has been doing this since April 2013 + buffer[lineLen] = '\r'; + buffer[lineLen+1] = '\n'; + FS_Write(buffer, lineLen + 2, f); #else - Q_strcat(buffer, bufferlen, "\n"); + buffer[lineLen] = '\n'; + FS_Write(buffer, lineLen + 1, f); #endif - FS_Write(buffer, strlen(buffer), f); } - Z_Free( buffer ); FS_FCloseFile( f ); } @@ -188,81 +217,182 @@ void Con_ClearNotify( void ) { } } +/* +================ +Con_Initialize + +Initialize console for the first time. +================ +*/ +void Con_Initialize(void) +{ + int i; + + VectorCopy4(colorWhite, con.color); + con.charWidth = SMALLCHAR_WIDTH; + con.charHeight = SMALLCHAR_HEIGHT; + con.linewidth = DEFAULT_CONSOLE_WIDTH; + con.rowwidth = CON_TIMESTAMP_LEN + con.linewidth + 1; + con.totallines = CON_TEXTSIZE / con.rowwidth; + con.current = con.totallines - 1; + con.display = con.current; + con.xadjust = 1.0f; + con.yadjust = 1.0f; + for(i=0; i= SMALLCHAR_WIDTH); + + scale = ((con_scale->value > 0.0f) ? con_scale->value : 1.0f); + charWidth = scale * SMALLCHAR_WIDTH; + + if (charWidth < 1) { + charWidth = 1; + scale = (float)charWidth / SMALLCHAR_WIDTH; + } + + width = (cls.glconfig.vidWidth / charWidth) - 2; + + if (width < 20) { + width = 20; + charWidth = cls.glconfig.vidWidth / 22; + scale = (float)charWidth / SMALLCHAR_WIDTH; + } + + if (charWidth < 1) { + Com_Error(ERR_FATAL, "Con_CheckResize: Window too small to draw a console"); + } + + rowwidth = width + 1 + (con_timestamps->integer ? 0 : CON_TIMESTAMP_LEN); + + con.charWidth = charWidth; + con.charHeight = scale * SMALLCHAR_HEIGHT; + con.linewidth = width; + con.xadjust = ((float)SCREEN_WIDTH) / cls.glconfig.vidWidth; + con.yadjust = ((float)SCREEN_HEIGHT) / cls.glconfig.vidHeight; + g_consoleField.widthInChars = width - 1; // Command prompt + + if (con.rowwidth != rowwidth) + { + Con_Resize(rowwidth); + } +} + /* ================== @@ -290,6 +420,9 @@ void Con_Init (void) { con_autoclear = Cvar_Get ("con_autoclear", "1", CVAR_ARCHIVE_ND); con_height = Cvar_Get ("con_height", "0.5", CVAR_ARCHIVE_ND); + con_scale = Cvar_Get ("con_scale", "1", CVAR_ARCHIVE_ND); + con_timestamps = Cvar_Get ("con_timestamps", "0", CVAR_ARCHIVE_ND); + Field_Clear( &g_consoleField ); g_consoleField.widthInChars = g_console_field_width; for ( i = 0 ; i < COMMAND_HISTORY ; i++ ) { @@ -302,6 +435,9 @@ void Con_Init (void) { Cmd_AddCommand ("clear", Con_Clear_f); Cmd_AddCommand ("condump", Con_Dump_f); Cmd_SetCommandCompletionFunc( "condump", Cmd_CompleteTxtName ); + + //Initialize values on first print + con.initialized = qfalse; } @@ -313,17 +449,37 @@ Con_Linefeed void Con_Linefeed (void) { int i; + int line = (con.current % con.totallines) * con.rowwidth; + + // print timestamp on the PREVIOUS line + { + time_t t = time( NULL ); + struct tm *tms = localtime( &t ); + char timestamp[CON_TIMESTAMP_LEN + 1]; + const unsigned char color = ColorIndex(COLOR_GREY); + + Com_sprintf(timestamp, sizeof(timestamp), "[%02d:%02d:%02d] ", + tms->tm_hour, tms->tm_min, tms->tm_sec); + + for ( i = 0; i < CON_TIMESTAMP_LEN; i++ ) { + con.text[line + i].f = { color, timestamp[i] }; + } + } // mark time for transparent overlay if (con.current >= 0) con.times[con.current % NUM_CON_TIMES] = cls.realtime; con.x = 0; + if (con.display == con.current) con.display++; con.current++; - for(i=0; iinteger ) { @@ -346,38 +502,18 @@ void CL_ConsolePrint( char *txt ) { } if (!con.initialized) { - con.color[0] = - con.color[1] = - con.color[2] = - con.color[3] = 1.0f; - con.linewidth = -1; - Con_CheckResize (); - con.initialized = qtrue; + Con_Initialize(); } color = ColorIndex(COLOR_WHITE); - while ( (c = (unsigned char )*txt) != 0 ) { + while ( (c = (unsigned char) *txt) != 0 ) { if ( Q_IsColorString( (unsigned char*) txt ) ) { color = ColorIndex( *(txt+1) ); txt += 2; continue; } - // count word length - for (l=0 ; l< con.linewidth ; l++) { - if ( txt[l] <= ' ') { - break; - } - - } - - // word wrap - if (l != con.linewidth && (con.x + l >= con.linewidth) ) { - Con_Linefeed(); - - } - txt++; switch (c) @@ -390,13 +526,15 @@ void CL_ConsolePrint( char *txt ) { break; default: // display character and advance y = con.current % con.totallines; - con.text[y*con.linewidth+con.x] = (color << 8) | c; - con.x++; - if (con.x >= con.linewidth) { + if (con.x == con.rowwidth - CON_TIMESTAMP_LEN - 1) { + con.text[y * con.rowwidth + CON_TIMESTAMP_LEN + con.x] = CON_WRAP; Con_Linefeed(); - con.x = 0; + y = con.current % con.totallines; } + + con.text[y * con.rowwidth + CON_TIMESTAMP_LEN + con.x].f = { color, c }; + con.x++; break; } } @@ -432,14 +570,23 @@ void Con_DrawInput (void) { return; } - y = con.vislines - ( SMALLCHAR_HEIGHT * (re.Language_IsAsian() ? 1.5 : 2) ); + y = con.vislines - ( con.charHeight * (re.Language_IsAsian() ? 1.5 : 2) ); re.SetColor( con.color ); - SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, CONSOLE_PROMPT_CHAR ); + Field_Draw( &g_consoleField, 2 * con.charWidth, y, qtrue, qtrue ); + + SCR_DrawSmallChar( con.charWidth, y, CONSOLE_PROMPT_CHAR ); + + re.SetColor( g_color_table[ColorIndex(COLOR_GREY)] ); + + if ( g_consoleField.scroll > 0 ) + SCR_DrawSmallChar( 0, y, CON_SCROLL_L_CHAR ); - Field_Draw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH, y, - SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue, qtrue ); + int len = Q_PrintStrlen( g_consoleField.buffer ); + int pos = Q_PrintStrLenTo( g_consoleField.buffer, g_consoleField.scroll, NULL ); + if ( pos + g_consoleField.widthInChars < len ) + SCR_DrawSmallChar( cls.glconfig.vidWidth - con.charWidth, y, CON_SCROLL_R_CHAR ); } @@ -453,7 +600,7 @@ Draws the last few lines of output transparently over the game top void Con_DrawNotify (void) { int x, v; - short *text; + conChar_t *text; int i; int time; int currentColor; @@ -461,6 +608,17 @@ void Con_DrawNotify (void) currentColor = 7; re.SetColor( g_color_table[currentColor] ); + static int iFontIndex = re.RegisterFont("ocr_a"); + float fFontScale = 1.0f; + int iPixelHeightToAdvance = 0; + if (re.Language_IsAsian()) + { + fFontScale = con.charWidth * 10.0f / + re.Font_StrLenPixels("aaaaaaaaaa", iFontIndex, 1.0f); + fFontScale *= con.yadjust; + iPixelHeightToAdvance = 2+(1.3/con.yadjust) * re.Font_HeightPixels(iFontIndex, fFontScale); + } + v = 0; for (i= con.current-NUM_CON_TIMES+1 ; i<=con.current ; i++) { @@ -472,7 +630,9 @@ void Con_DrawNotify (void) time = cls.realtime - time; if (time > con_notifytime->value*1000) continue; - text = con.text + (i % con.totallines)*con.linewidth; + text = con.text + (i % con.totallines)*con.rowwidth; + if (!con_timestamps->integer) + text += CON_TIMESTAMP_LEN; // asian language needs to use the new font system to print glyphs... // @@ -480,41 +640,40 @@ void Con_DrawNotify (void) // if (re.Language_IsAsian()) { - int iFontIndex = re.RegisterFont("ocr_a"); // this seems naughty - const float fFontScale = 0.75f*con.yadjust; - const int iPixelHeightToAdvance = 2+(1.3/con.yadjust) * re.Font_HeightPixels(iFontIndex, fFontScale); // for asian spacing, since we don't want glyphs to touch. - // concat the text to be printed... // - char sTemp[4096]={0}; // ott + char sTemp[4096]; // ott + sTemp[0] = '\0'; for (x = 0 ; x < con.linewidth ; x++) { - if ( ( (text[x]>>8)&Q_COLOR_BITS ) != currentColor ) { - currentColor = (text[x]>>8)&Q_COLOR_BITS; - strcat(sTemp,va("^%i", (text[x]>>8)&Q_COLOR_BITS) ); + if ( text[x].f.color != currentColor ) { + currentColor = text[x].f.color; + strcat(sTemp,va("^%i", currentColor )); } - strcat(sTemp,va("%c",text[x] & 0xFF)); + strcat(sTemp,va("%c",text[x].f.character)); } // // and print... // - re.Font_DrawString(con.xadjust*(con.xadjust + (1*SMALLCHAR_WIDTH/*aesthetics*/)), con.yadjust*(v), sTemp, g_color_table[currentColor], iFontIndex, -1, fFontScale); + re.Font_DrawString(con.xadjust * (con.xadjust + con.charWidth), con.yadjust * v, sTemp, + g_color_table[currentColor], iFontIndex, -1, fFontScale); v += iPixelHeightToAdvance; } else { for (x = 0 ; x < con.linewidth ; x++) { - if ( ( text[x] & 0xff ) == ' ' ) { + if ( text[x].f.character == ' ' ) { continue; } - if ( ( (text[x]>>8)&Q_COLOR_BITS ) != currentColor ) { - currentColor = (text[x]>>8)&Q_COLOR_BITS; + if ( text[x].f.color != currentColor ) { + currentColor = text[x].f.color; re.SetColor( g_color_table[currentColor] ); } - SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, v, text[x] & 0xff ); + SCR_DrawSmallChar( (x+1)*con.charWidth, v, text[x].f.character ); } - v += SMALLCHAR_HEIGHT; + + v += con.charHeight; } } @@ -532,9 +691,10 @@ void Con_DrawSolidConsole( float frac ) { int i, x, y; int rows; - short *text; + conChar_t *text; int row; int lines; +// qhandle_t conShader; int currentColor; lines = cls.glconfig.vidHeight * frac; @@ -561,7 +721,7 @@ void Con_DrawSolidConsole( float frac ) { re.SetColor(NULL); } - SCR_DrawPic( 0, 0, SCREEN_WIDTH, y, cls.consoleShader); + SCR_DrawPic( 0, 0, SCREEN_WIDTH, y, cls.consoleShader ); } // draw the bottom bar and version number @@ -572,8 +732,8 @@ void Con_DrawSolidConsole( float frac ) i = strlen( Q3_VERSION ); for (x=0 ; xinteger) + text += CON_TIMESTAMP_LEN; // asian language needs to use the new font system to print glyphs... // @@ -638,32 +797,34 @@ void Con_DrawSolidConsole( float frac ) { // concat the text to be printed... // - char sTemp[4096]={0}; // ott - for (x = 0 ; x < con.linewidth ; x++) + char sTemp[4096]; // ott + sTemp[0] = '\0'; + for (x = 0 ; x < con.linewidth + 1 ; x++) { - if ( ( (text[x]>>8)&Q_COLOR_BITS ) != currentColor ) { - currentColor = (text[x]>>8)&Q_COLOR_BITS; - strcat(sTemp,va("^%i", (text[x]>>8)&Q_COLOR_BITS) ); + if ( text[x].f.color != currentColor ) { + currentColor = text[x].f.color; + strcat(sTemp,va("^%i", currentColor )); } - strcat(sTemp,va("%c",text[x] & 0xFF)); + strcat(sTemp,va("%c",text[x].f.character)); } // // and print... // - re.Font_DrawString(con.xadjust*(con.xadjust + (1*SMALLCHAR_WIDTH/*(aesthetics)*/)), con.yadjust*(y), sTemp, g_color_table[currentColor], iFontIndexForAsian, -1, fFontScaleForAsian); + re.Font_DrawString(con.xadjust*(con.xadjust + con.charWidth), con.yadjust * y, sTemp, g_color_table[currentColor], + iFontIndex, -1, fFontScale); } else { - for (x=0 ; x>8)&Q_COLOR_BITS ) != currentColor ) { - currentColor = (text[x]>>8)&Q_COLOR_BITS; + if ( text[x].f.color != currentColor ) { + currentColor = text[x].f.color; re.SetColor( g_color_table[currentColor] ); } - SCR_DrawSmallChar( con.xadjust + (x+1)*SMALLCHAR_WIDTH, y, text[x] & 0xff ); + SCR_DrawSmallChar( (x+1)*con.charWidth, y, text[x].f.character ); } } } diff --git a/code/client/cl_keys.cpp b/code/client/cl_keys.cpp index b9b36739e2..768c135937 100644 --- a/code/client/cl_keys.cpp +++ b/code/client/cl_keys.cpp @@ -398,7 +398,8 @@ Handles horizontal scrolling and cursor blinking x, y, amd width are in pixels =================== */ -void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, qboolean showCursor, qboolean noColorEscape ) { +extern console_t con; +void Field_VariableSizeDraw( field_t *edit, int x, int y, int size, qboolean showCursor, qboolean noColorEscape ) { int len; int drawLen; int prestep; @@ -434,7 +435,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q str[ drawLen ] = 0; // draw it - if ( size == SMALLCHAR_WIDTH ) { + if ( size == con.charWidth ) { float color[4]; color[0] = color[1] = color[2] = color[3] = 1.0; @@ -458,7 +459,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q i = drawLen - strlen( str ); - if ( size == SMALLCHAR_WIDTH ) { + if ( size == con.charWidth ) { SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar ); } else { str[0] = cursorChar; @@ -468,14 +469,14 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q } } -void Field_Draw( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ) +void Field_Draw( field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape ) { - Field_VariableSizeDraw( edit, x, y, width, SMALLCHAR_WIDTH, showCursor, noColorEscape ); + Field_VariableSizeDraw( edit, x, y, con.charWidth, showCursor, noColorEscape ); } -void Field_BigDraw( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ) +void Field_BigDraw( field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape ) { - Field_VariableSizeDraw( edit, x, y, width, BIGCHAR_WIDTH, showCursor, noColorEscape ); + Field_VariableSizeDraw( edit, x, y, BIGCHAR_WIDTH, showCursor, noColorEscape ); } /* diff --git a/code/client/cl_scrn.cpp b/code/client/cl_scrn.cpp index 6a797181c6..730ee7d466 100644 --- a/code/client/cl_scrn.cpp +++ b/code/client/cl_scrn.cpp @@ -151,7 +151,7 @@ void SCR_DrawSmallChar( int x, int y, int ch ) { return; } - if ( y < -SMALLCHAR_HEIGHT ) { + if ( y < -con.charHeight ) { return; } @@ -162,7 +162,7 @@ void SCR_DrawSmallChar( int x, int y, int ch ) { fcol = col*0.0625; size = 0.0625; - re.DrawStretchPic( x, y, SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, + re.DrawStretchPic( x, y, con.charWidth, con.charHeight, fcol, frow, fcol + size, frow + size, cls.charSetShader ); @@ -176,7 +176,7 @@ void SCR_DrawSmallChar( int x, int y, int ch ) { size2 = 0.0625; re.DrawStretchPic( x * con.xadjust, y * con.yadjust, - SMALLCHAR_WIDTH * con.xadjust, SMALLCHAR_HEIGHT * con.yadjust, + con.charWidth * con.xadjust, con.charHeight * con.yadjust, fcol, frow, fcol + size, frow + size2, cls.charSetShader ); @@ -284,7 +284,7 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, } } SCR_DrawSmallChar( xx, y, *s ); - xx += SMALLCHAR_WIDTH; + xx += con.charWidth; s++; } re.SetColor( NULL ); diff --git a/code/client/client.h b/code/client/client.h index 48517e9029..a1410bd48a 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -211,17 +211,29 @@ typedef struct { #define CON_TEXTSIZE 0x30000 //was 32768 #define NUM_CON_TIMES 4 +typedef union { + struct { + unsigned char color; + char character; + } f; + unsigned short compare; +} conChar_t; + typedef struct { qboolean initialized; - short text[CON_TEXTSIZE]; + conChar_t text[CON_TEXTSIZE]; int current; // line where next message will be printed int x; // offset in current line for next print int display; // bottom of console displays this line int linewidth; // characters across screen + int rowwidth; // timestamp, text and line wrap character int totallines; // total lines in console scrollback + int charWidth; // Scaled console character width + int charHeight; // Scaled console character height + float xadjust; // for wide aspect screens float yadjust; diff --git a/code/client/keys.h b/code/client/keys.h index 5f3580dcbf..8a503b3c2f 100644 --- a/code/client/keys.h +++ b/code/client/keys.h @@ -55,8 +55,8 @@ extern field_t historyEditLines[COMMAND_HISTORY]; void Field_KeyDownEvent ( field_t *edit, int key ); void Field_CharEvent ( field_t *edit, int ch ); -void Field_Draw ( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ); -void Field_BigDraw ( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ); +void Field_Draw ( field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape ); +void Field_BigDraw ( field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape ); void Key_SetBinding ( int keynum, const char *binding ); const char *Key_GetBinding ( int keynum ); diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 70580daf9d..17d75dc9bd 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -739,7 +739,7 @@ void CL_JoystickEvent( int axis, int value, int time ); void CL_PacketEvent( netadr_t from, msg_t *msg ); -void CL_ConsolePrint( char *text ); +void CL_ConsolePrint( const char *text ); void CL_MapLoading( void ); // do a screen update before starting to load a map diff --git a/codemp/client/cl_console.cpp b/codemp/client/cl_console.cpp index 5fc61fe427..ec6e1777d1 100644 --- a/codemp/client/cl_console.cpp +++ b/codemp/client/cl_console.cpp @@ -39,9 +39,21 @@ cvar_t *con_notifytime; cvar_t *con_opacity; // background alpha multiplier cvar_t *con_autoclear; cvar_t *con_height; +cvar_t *con_scale; +cvar_t *con_timestamps; #define DEFAULT_CONSOLE_WIDTH 78 +#define CON_BLANK_CHAR ' ' +#define CON_SCROLL_L_CHAR '$' +#define CON_SCROLL_R_CHAR '$' +#define CON_TIMESTAMP_LEN 11 // "[13:37:00] " +#define CON_MIN_WIDTH 20 + + +static const conChar_t CON_WRAP = { { ColorIndex(COLOR_GREY), '\\' } }; +static const conChar_t CON_BLANK = { { ColorIndex(COLOR_WHITE), CON_BLANK_CHAR } }; + vec4_t console_color = {0.509f, 0.609f, 0.847f, 1.0f}; /* @@ -158,7 +170,7 @@ void Con_Clear_f (void) { int i; for ( i = 0 ; i < CON_TEXTSIZE ; i++ ) { - con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' '; + con.text[i] = CON_BLANK; } Con_Bottom(); // go to end @@ -174,12 +186,17 @@ Save the console contents out to a file */ void Con_Dump_f (void) { - int l, x, i; - short *line; + char filename[MAX_QPATH]; + qboolean empty; + int l, i, j; + int line; + int lineLen; fileHandle_t f; - int bufferlen; - char *buffer; - char filename[MAX_QPATH]; +#ifdef WIN32 + char buffer[CON_TIMESTAMP_LEN + MAXPRINTMSG + 2]; +#else + char buffer[CON_TIMESTAMP_LEN + MAXPRINTMSG + 1]; +#endif if (Cmd_Argc() != 2) { @@ -206,47 +223,59 @@ void Con_Dump_f (void) Com_Printf ("Dumped console text to %s.\n", filename ); // skip empty lines - for (l = con.current - con.totallines + 1 ; l <= con.current ; l++) + for (l = 1, empty = qtrue ; l < con.totallines && empty ; l++) { - line = con.text + (l%con.totallines)*con.linewidth; - for (x=0 ; xinteger) { + line = ((con.current + l) % con.totallines) * con.rowwidth; - // write the remaining lines - buffer[bufferlen-1] = 0; - for ( ; l <= con.current ; l++) - { - line = con.text + (l%con.totallines)*con.linewidth; - for(i=0; i=0 ; x--) + for (i = 0; i < CON_TIMESTAMP_LEN; i++) + buffer[i] = con.text[line + i].f.character; + + lineLen = CON_TIMESTAMP_LEN; + } + + // Concatenate wrapped lines + for ( ; l < con.totallines ; l++) { - if (buffer[x] == ' ') - buffer[x] = 0; - else + line = ((con.current + l) % con.totallines) * con.rowwidth; + + for (j = CON_TIMESTAMP_LEN; j < con.rowwidth - 1 && i < (int)sizeof(buffer) - 1; j++, i++) { + buffer[i] = con.text[line + j].f.character; + + if (con.text[line + j].f.character != CON_BLANK_CHAR) + lineLen = i + 1; + } + + if (i == sizeof(buffer) - 1) + break; + + if (con.text[line + j].compare != CON_WRAP.compare) break; } -#ifdef _WIN32 - Q_strcat(buffer, bufferlen, "\r\n"); + +#ifdef WIN32 // I really don't like this inconsistency, but OpenJK has been doing this since April 2013 + buffer[lineLen] = '\r'; + buffer[lineLen+1] = '\n'; + FS_Write(buffer, lineLen + 2, f); #else - Q_strcat(buffer, bufferlen, "\n"); + buffer[lineLen] = '\n'; + FS_Write(buffer, lineLen + 1, f); #endif - FS_Write(buffer, strlen(buffer), f); } - Hunk_FreeTempMemory( buffer ); FS_FCloseFile( f ); } @@ -264,82 +293,182 @@ void Con_ClearNotify( void ) { } } +/* +================ +Con_Initialize + +Initialize console for the first time. +================ +*/ +void Con_Initialize(void) +{ + int i; + + VectorCopy4(colorWhite, con.color); + con.charWidth = SMALLCHAR_WIDTH; + con.charHeight = SMALLCHAR_HEIGHT; + con.linewidth = DEFAULT_CONSOLE_WIDTH; + con.rowwidth = CON_TIMESTAMP_LEN + con.linewidth + 1; + con.totallines = CON_TEXTSIZE / con.rowwidth; + con.current = con.totallines - 1; + con.display = con.current; + con.xadjust = 1.0f; + con.yadjust = 1.0f; + for(i=0; i= SMALLCHAR_WIDTH); + + scale = ((con_scale->value > 0.0f) ? con_scale->value : 1.0f); + charWidth = scale * SMALLCHAR_WIDTH; + + if (charWidth < 1) { + charWidth = 1; + scale = (float)charWidth / SMALLCHAR_WIDTH; + } + + width = (cls.glconfig.vidWidth / charWidth) - 2; + + if (width < 20) { + width = 20; + charWidth = cls.glconfig.vidWidth / 22; + scale = (float)charWidth / SMALLCHAR_WIDTH; + } + + if (charWidth < 1) { + Com_Error(ERR_FATAL, "Con_CheckResize: Window too small to draw a console"); + } + + rowwidth = width + 1 + (con_timestamps->integer ? 0 : CON_TIMESTAMP_LEN); + + con.charWidth = charWidth; + con.charHeight = scale * SMALLCHAR_HEIGHT; + con.linewidth = width; + con.xadjust = ((float)SCREEN_WIDTH) / cls.glconfig.vidWidth; + con.yadjust = ((float)SCREEN_HEIGHT) / cls.glconfig.vidHeight; + g_consoleField.widthInChars = width - 1; // Command prompt + + if (con.rowwidth != rowwidth) + { + Con_Resize(rowwidth); + } +} + /* ================== @@ -367,6 +496,9 @@ void Con_Init (void) { con_autoclear = Cvar_Get ("con_autoclear", "1", CVAR_ARCHIVE_ND, "Automatically clear console input on close"); con_height = Cvar_Get ("con_height", "0.5", CVAR_ARCHIVE_ND); + con_scale = Cvar_Get ("con_scale", "1", CVAR_ARCHIVE_ND, "Scale console font"); + con_timestamps = Cvar_Get ("con_timestamps", "0", CVAR_ARCHIVE_ND, "Display timestamps infront of console lines"); + Field_Clear( &g_consoleField ); g_consoleField.widthInChars = g_console_field_width; for ( i = 0 ; i < COMMAND_HISTORY ; i++ ) { @@ -383,6 +515,9 @@ void Con_Init (void) { Cmd_AddCommand( "clear", Con_Clear_f, "Clear console text" ); Cmd_AddCommand( "condump", Con_Dump_f, "Dump console text to file" ); Cmd_SetCommandCompletionFunc( "condump", Cmd_CompleteTxtName ); + + //Initialize values on first print + con.initialized = qfalse; } /* @@ -410,22 +545,37 @@ Con_Linefeed static void Con_Linefeed (qboolean skipnotify) { int i; + int line = (con.current % con.totallines) * con.rowwidth; - // mark time for transparent overlay - if (con.current >= 0) + // print timestamp on the PREVIOUS line { - if (skipnotify) - con.times[con.current % NUM_CON_TIMES] = 0; - else - con.times[con.current % NUM_CON_TIMES] = cls.realtime; + time_t t = time( NULL ); + struct tm *tms = localtime( &t ); + char timestamp[CON_TIMESTAMP_LEN + 1]; + const unsigned char color = ColorIndex(COLOR_GREY); + + Com_sprintf(timestamp, sizeof(timestamp), "[%02d:%02d:%02d] ", + tms->tm_hour, tms->tm_min, tms->tm_sec); + + for ( i = 0; i < CON_TIMESTAMP_LEN; i++ ) { + con.text[line + i].f = { color, timestamp[i] }; + } } + // mark time for transparent overlay + if (con.current >= 0) + con.times[con.current % NUM_CON_TIMES] = skipnotify ? 0 : cls.realtime; + con.x = 0; + if (con.display == con.current) con.display++; con.current++; - for(i=0; i= con.linewidth) ) { - Con_Linefeed(skipnotify); - - } - txt++; switch (c) @@ -504,11 +635,15 @@ void CL_ConsolePrint( const char *txt) { break; default: // display character and advance y = con.current % con.totallines; - con.text[y*con.linewidth+con.x] = (short) ((color << 8) | c); - con.x++; - if (con.x >= con.linewidth) { - Con_Linefeed(skipnotify); + + if (con.x == con.rowwidth - CON_TIMESTAMP_LEN - 1) { + con.text[y * con.rowwidth + CON_TIMESTAMP_LEN + con.x] = CON_WRAP; + Con_Linefeed( skipnotify ); + y = con.current % con.totallines; } + + con.text[y * con.rowwidth + CON_TIMESTAMP_LEN + con.x].f = { color, c }; + con.x++; break; } } @@ -555,14 +690,23 @@ void Con_DrawInput (void) { return; } - y = con.vislines - ( SMALLCHAR_HEIGHT * (re->Language_IsAsian() ? 1.5 : 2) ); + y = con.vislines - ( con.charHeight * (re->Language_IsAsian() ? 1.5 : 2) ); re->SetColor( con.color ); - SCR_DrawSmallChar( (int)(con.xadjust + 1 * SMALLCHAR_WIDTH), y, CONSOLE_PROMPT_CHAR ); + Field_Draw( &g_consoleField, 2 * con.charWidth, y, qtrue, qtrue ); + + SCR_DrawSmallChar( con.charWidth, y, CONSOLE_PROMPT_CHAR ); - Field_Draw( &g_consoleField, (int)(con.xadjust + 2 * SMALLCHAR_WIDTH), y, - SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, qtrue, qtrue ); + re->SetColor( g_color_table[ColorIndex(COLOR_GREY)] ); + + if ( g_consoleField.scroll > 0 ) + SCR_DrawSmallChar( 0, y, CON_SCROLL_L_CHAR ); + + int len = Q_PrintStrlen( g_consoleField.buffer ); + int pos = Q_PrintStrLenTo( g_consoleField.buffer, g_consoleField.scroll, NULL ); + if ( pos + g_consoleField.widthInChars < len ) + SCR_DrawSmallChar( cls.glconfig.vidWidth - con.charWidth, y, CON_SCROLL_R_CHAR ); } @@ -578,7 +722,7 @@ Draws the last few lines of output transparently over the game top void Con_DrawNotify (void) { int x, v; - short *text; + conChar_t *text; int i; int time; int skip; @@ -588,6 +732,17 @@ void Con_DrawNotify (void) currentColor = 7; re->SetColor( g_color_table[currentColor] ); + static int iFontIndex = re->RegisterFont("ocr_a"); + float fFontScale = 1.0f; + int iPixelHeightToAdvance = 0; + if (re->Language_IsAsian()) + { + fFontScale = con.charWidth * 10.0f / + re->Font_StrLenPixels("aaaaaaaaaa", iFontIndex, 1.0f); + fFontScale *= con.yadjust; + iPixelHeightToAdvance = 2+(1.3/con.yadjust) * re->Font_HeightPixels(iFontIndex, fFontScale); + } + v = 0; for (i= con.current-NUM_CON_TIMES+1 ; i<=con.current ; i++) { @@ -599,7 +754,9 @@ void Con_DrawNotify (void) time = cls.realtime - time; if (time > con_notifytime->value*1000) continue; - text = con.text + (i % con.totallines)*con.linewidth; + text = con.text + (i % con.totallines)*con.rowwidth; + if (!con_timestamps->integer) + text += CON_TIMESTAMP_LEN; if (cl.snap.ps.pm_type != PM_INTERMISSION && Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME) ) { continue; @@ -617,46 +774,44 @@ void Con_DrawNotify (void) // if (re->Language_IsAsian()) { - static int iFontIndex = re->RegisterFont("ocr_a"); // this seems naughty - const float fFontScale = 0.75f*con.yadjust; - const int iPixelHeightToAdvance = 2+(1.3/con.yadjust) * re->Font_HeightPixels(iFontIndex, fFontScale); // for asian spacing, since we don't want glyphs to touch. - // concat the text to be printed... // - char sTemp[4096]={0}; // ott + char sTemp[4096]; // ott + sTemp[0] = '\0'; for (x = 0 ; x < con.linewidth ; x++) { - if ( ( (text[x]>>8)&Q_COLOR_BITS ) != currentColor ) { - currentColor = (text[x]>>8)&Q_COLOR_BITS; - strcat(sTemp,va("^%i", (text[x]>>8)&Q_COLOR_BITS) ); + if ( text[x].f.color != currentColor ) { + currentColor = text[x].f.color; + strcat(sTemp,va("^%i", currentColor )); } - strcat(sTemp,va("%c",text[x] & 0xFF)); + strcat(sTemp,va("%c",text[x].f.character)); } // // and print... // - re->Font_DrawString(cl_conXOffset->integer + con.xadjust*(con.xadjust + (1*SMALLCHAR_WIDTH/*aesthetics*/)), con.yadjust*(v), sTemp, g_color_table[currentColor], iFontIndex, -1, fFontScale); + re->Font_DrawString(cl_conXOffset->integer + con.xadjust * (con.xadjust + con.charWidth), con.yadjust * v, sTemp, + g_color_table[currentColor], iFontIndex, -1, fFontScale); v += iPixelHeightToAdvance; } else { for (x = 0 ; x < con.linewidth ; x++) { - if ( ( text[x] & 0xff ) == ' ' ) { + if ( text[x].f.character == ' ' ) { continue; } - if ( ( (text[x]>>8)&Q_COLOR_BITS ) != currentColor ) { - currentColor = (text[x]>>8)&Q_COLOR_BITS; + if ( text[x].f.color != currentColor ) { + currentColor = text[x].f.color; re->SetColor( g_color_table[currentColor] ); } if (!cl_conXOffset) { cl_conXOffset = Cvar_Get ("cl_conXOffset", "0", 0); } - SCR_DrawSmallChar( (int)(cl_conXOffset->integer + con.xadjust + (x+1)*SMALLCHAR_WIDTH), v, text[x] & 0xff ); + SCR_DrawSmallChar( (int)(cl_conXOffset->integer + (x+1)*con.charWidth), v, text[x].f.character ); } - v += SMALLCHAR_HEIGHT; + v += con.charHeight; } } @@ -682,8 +837,7 @@ void Con_DrawNotify (void) skip = strlen(chattext)+1; } - Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, v, - SCREEN_WIDTH - ( skip + 1 ) * BIGCHAR_WIDTH, qtrue, qtrue ); + Field_BigDraw( &chatField, skip * BIGCHAR_WIDTH, v, qtrue, qtrue ); v += BIGCHAR_HEIGHT; } @@ -700,7 +854,7 @@ Draws the console with the solid background void Con_DrawSolidConsole( float frac ) { int i, x, y; int rows; - short *text; + conChar_t *text; int row; int lines; // qhandle_t conShader; @@ -741,8 +895,8 @@ void Con_DrawSolidConsole( float frac ) { i = strlen( JK_VERSION ); for (x=0 ; xSetColor( console_color ); for (x=0 ; xSetColor( g_color_table[currentColor] ); - static int iFontIndexForAsian = 0; - const float fFontScaleForAsian = 0.75f*con.yadjust; - int iPixelHeightToAdvance = SMALLCHAR_HEIGHT; + static int iFontIndex = re->RegisterFont("ocr_a"); + float fFontScale = 1.0f; + int iPixelHeightToAdvance = con.charHeight; if (re->Language_IsAsian()) { - if (!iFontIndexForAsian) - { - iFontIndexForAsian = re->RegisterFont("ocr_a"); - } - iPixelHeightToAdvance = (1.3/con.yadjust) * re->Font_HeightPixels(iFontIndexForAsian, fFontScaleForAsian); // for asian spacing, since we don't want glyphs to touch. + fFontScale = con.charWidth * 10.0f / + re->Font_StrLenPixels("aaaaaaaaaa", iFontIndex, 1.0f); + fFontScale *= con.yadjust; + iPixelHeightToAdvance = 2+(1.3/con.yadjust) * re->Font_HeightPixels(iFontIndex, fFontScale); } for (i=0 ; iinteger) + text += CON_TIMESTAMP_LEN; // asian language needs to use the new font system to print glyphs... // @@ -805,32 +960,34 @@ void Con_DrawSolidConsole( float frac ) { { // concat the text to be printed... // - char sTemp[4096]={0}; // ott - for (x = 0 ; x < con.linewidth ; x++) + char sTemp[4096]; // ott + sTemp[0] = '\0'; + for (x = 0 ; x < con.linewidth + 1 ; x++) { - if ( ( (text[x]>>8)&Q_COLOR_BITS ) != currentColor ) { - currentColor = (text[x]>>8)&Q_COLOR_BITS; - strcat(sTemp,va("^%i", (text[x]>>8)&Q_COLOR_BITS) ); + if ( text[x].f.color != currentColor ) { + currentColor = text[x].f.color; + strcat(sTemp,va("^%i", currentColor )); } - strcat(sTemp,va("%c",text[x] & 0xFF)); + strcat(sTemp,va("%c",text[x].f.character)); } // // and print... // - re->Font_DrawString(con.xadjust*(con.xadjust + (1*SMALLCHAR_WIDTH/*(aesthetics)*/)), con.yadjust*(y), sTemp, g_color_table[currentColor], iFontIndexForAsian, -1, fFontScaleForAsian); + re->Font_DrawString(con.xadjust*(con.xadjust + con.charWidth), con.yadjust * y, sTemp, g_color_table[currentColor], + iFontIndex, -1, fFontScale); } else { - for (x=0 ; x>8)&Q_COLOR_BITS ) != currentColor ) { - currentColor = (text[x]>>8)&Q_COLOR_BITS; + if ( text[x].f.color != currentColor ) { + currentColor = text[x].f.color; re->SetColor( g_color_table[currentColor] ); } - SCR_DrawSmallChar( (int) (con.xadjust + (x+1)*SMALLCHAR_WIDTH), y, text[x] & 0xff ); + SCR_DrawSmallChar( (x+1)*con.charWidth, y, text[x].f.character ); } } } diff --git a/codemp/client/cl_keys.cpp b/codemp/client/cl_keys.cpp index 02966bdf28..294b9c3053 100644 --- a/codemp/client/cl_keys.cpp +++ b/codemp/client/cl_keys.cpp @@ -401,7 +401,8 @@ Handles horizontal scrolling and cursor blinking x, y, amd width are in pixels =================== */ -void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, qboolean showCursor, qboolean noColorEscape ) { +extern console_t con; +void Field_VariableSizeDraw( field_t *edit, int x, int y, int size, qboolean showCursor, qboolean noColorEscape ) { int len; int drawLen; int prestep; @@ -441,7 +442,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q str[ drawLen ] = 0; // draw it - if ( size == SMALLCHAR_WIDTH ) { + if ( size == con.charWidth ) { float color[4]; color[0] = color[1] = color[2] = color[3] = 1.0; @@ -465,7 +466,7 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q i = drawLen - strlen( str ); - if ( size == SMALLCHAR_WIDTH ) { + if ( size == con.charWidth ) { SCR_DrawSmallChar( x + ( edit->cursor - prestep - i ) * size, y, cursorChar ); } else { str[0] = cursorChar; @@ -475,14 +476,14 @@ void Field_VariableSizeDraw( field_t *edit, int x, int y, int width, int size, q } } -void Field_Draw( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ) +void Field_Draw( field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape ) { - Field_VariableSizeDraw( edit, x, y, width, SMALLCHAR_WIDTH, showCursor, noColorEscape ); + Field_VariableSizeDraw( edit, x, y, con.charWidth, showCursor, noColorEscape ); } -void Field_BigDraw( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ) +void Field_BigDraw( field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape ) { - Field_VariableSizeDraw( edit, x, y, width, BIGCHAR_WIDTH, showCursor, noColorEscape ); + Field_VariableSizeDraw( edit, x, y, BIGCHAR_WIDTH, showCursor, noColorEscape ); } /* diff --git a/codemp/client/cl_scrn.cpp b/codemp/client/cl_scrn.cpp index d82d6c7c8a..fb1c18b884 100644 --- a/codemp/client/cl_scrn.cpp +++ b/codemp/client/cl_scrn.cpp @@ -137,7 +137,7 @@ void SCR_DrawSmallChar( int x, int y, int ch ) { return; } - if ( y < -SMALLCHAR_HEIGHT ) { + if ( y < -con.charHeight ) { return; } @@ -155,7 +155,7 @@ void SCR_DrawSmallChar( int x, int y, int ch ) { size2 = 0.0625; re->DrawStretchPic( x * con.xadjust, y * con.yadjust, - SMALLCHAR_WIDTH * con.xadjust, SMALLCHAR_HEIGHT * con.yadjust, + con.charWidth * con.xadjust, con.charHeight * con.yadjust, fcol, frow, fcol + size, frow + size2, cls.charSetShader ); @@ -263,7 +263,7 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, } } SCR_DrawSmallChar( xx, y, *s ); - xx += SMALLCHAR_WIDTH; + xx += con.charWidth; s++; } re->SetColor( NULL ); diff --git a/codemp/client/client.h b/codemp/client/client.h index 2ebcfdcece..2a38d6014c 100644 --- a/codemp/client/client.h +++ b/codemp/client/client.h @@ -331,17 +331,29 @@ typedef struct clientStatic_s { #define CON_TEXTSIZE 0x30000 //was 32768 #define NUM_CON_TIMES 4 -typedef struct console_s { +typedef union { + struct { + unsigned char color; + char character; + } f; + unsigned short compare; +} conChar_t; + +typedef struct { qboolean initialized; - short text[CON_TEXTSIZE]; + conChar_t text[CON_TEXTSIZE]; int current; // line where next message will be printed int x; // offset in current line for next print int display; // bottom of console displays this line int linewidth; // characters across screen + int rowwidth; // timestamp, text and line wrap character int totallines; // total lines in console scrollback + int charWidth; // Scaled console character width + int charHeight; // Scaled console character height + float xadjust; // for wide aspect screens float yadjust; // for wide aspect screens diff --git a/codemp/client/keys.h b/codemp/client/keys.h index b7066d6c19..6ecf701893 100644 --- a/codemp/client/keys.h +++ b/codemp/client/keys.h @@ -62,8 +62,8 @@ extern int chat_playerNum; void Field_KeyDownEvent ( field_t *edit, int key ); void Field_CharEvent ( field_t *edit, int ch ); -void Field_Draw ( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ); -void Field_BigDraw ( field_t *edit, int x, int y, int width, qboolean showCursor, qboolean noColorEscape ); +void Field_Draw ( field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape ); +void Field_BigDraw ( field_t *edit, int x, int y, qboolean showCursor, qboolean noColorEscape ); void Key_SetBinding ( int keynum, const char *binding ); char * Key_GetBinding ( int keynum ); diff --git a/shared/qcommon/q_string.c b/shared/qcommon/q_string.c index a936fe2864..280de852ff 100644 --- a/shared/qcommon/q_string.c +++ b/shared/qcommon/q_string.c @@ -266,6 +266,27 @@ int Q_PrintStrlen( const char *string ) { return len; } +int Q_PrintStrLenTo(const char *str, int chars, char *color) { + int offset = 0; + char lastColor = 0; + int i; + + for (i = 0; i < chars && str[i]; i++) { + if (Q_IsColorString(&str[i])) { + i++; + lastColor = str[i]; + } else { + offset++; + } + } + + if (color) { + *color = lastColor; + } + + return offset; +} + char *Q_CleanStr( char *string ) { char* d; diff --git a/shared/qcommon/q_string.h b/shared/qcommon/q_string.h index 5228e80299..d81754a57f 100644 --- a/shared/qcommon/q_string.h +++ b/shared/qcommon/q_string.h @@ -31,6 +31,7 @@ const char *Q_stristr( const char *s, const char *find); // strlen that discounts Quake color sequences int Q_PrintStrlen( const char *string ); +int Q_PrintStrLenTo(const char *str, int chars, char *color); // removes color sequences from string char *Q_CleanStr( char *string ); From e8454e389568ffd7e1911df2b8e3f5bf62c275ad Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 11 Nov 2023 12:48:54 +0000 Subject: [PATCH 768/801] Fix memory leak --- codemp/rd-rend2/tr_ghoul2.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 716191a08a..aea553066e 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4373,6 +4373,8 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & surf_indices ); + ri.Hunk_FreeTempMemory(surf_indices); + surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); } From f536ef9da5b7fa622af43e33e7b9a1425b0f4ae5 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sat, 11 Nov 2023 06:24:52 +0100 Subject: [PATCH 769/801] [MP] Add download overlay. If cl_downloadPrompt is enabled users have to confirm each pk3 download now. If cl_downloadOverlay is enabled the window used for the confirmation prompt is used to display a progress bar and details on the current download. --- code/client/client.h | 9 + codemp/client/cl_input.cpp | 4 +- codemp/client/cl_keys.cpp | 11 +- codemp/client/cl_main.cpp | 355 ++++++++++++++++++++++++++++++++++++- codemp/client/cl_scrn.cpp | 3 + codemp/client/client.h | 17 ++ shared/sdl/sdl_input.cpp | 2 +- 7 files changed, 388 insertions(+), 13 deletions(-) diff --git a/code/client/client.h b/code/client/client.h index 178fe2a2b3..3e143cbbd5 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -206,6 +206,15 @@ typedef struct { qhandle_t charSetShader; qhandle_t whiteShader; qhandle_t consoleShader; + + // Cursor + qboolean cursorActive; + qhandle_t cursorShader; + int cursorX; + int cursorY; + + // Engine menu + int menuFont; } clientStatic_t; #define CON_TEXTSIZE 0x30000 //was 32768 diff --git a/codemp/client/cl_input.cpp b/codemp/client/cl_input.cpp index fbbf624281..647efee0f8 100644 --- a/codemp/client/cl_input.cpp +++ b/codemp/client/cl_input.cpp @@ -922,7 +922,9 @@ CL_MouseEvent ================= */ void CL_MouseEvent( int dx, int dy, int time ) { - if (g_clAutoMapMode && cls.cgameStarted) + if (cls.cursorActive) { + CL_UpdateCursorPosition( dx, dy ); + } else if (g_clAutoMapMode && cls.cgameStarted) { //automap input autoMapInput_t *data = (autoMapInput_t *)cl.mSharedMemory; diff --git a/codemp/client/cl_keys.cpp b/codemp/client/cl_keys.cpp index 02966bdf28..1bd9831a3a 100644 --- a/codemp/client/cl_keys.cpp +++ b/codemp/client/cl_keys.cpp @@ -1360,25 +1360,28 @@ void CL_KeyDownEvent( int key, unsigned time ) return; } - UIVM_KeyEvent( key, qtrue ); + if ( !cls.cursorActive ) UIVM_KeyEvent( key, qtrue ); return; } // send the bound action - CL_ParseBinding( key, qtrue, time ); + if ( !cls.cursorActive ) CL_ParseBinding( key, qtrue, time ); // distribute the key down event to the appropriate handler // console if ( Key_GetCatcher() & KEYCATCH_CONSOLE ) Console_Key( key ); + else if ( cls.cursorActive ) { + CL_CursorButton( key ); + } // ui else if ( Key_GetCatcher() & KEYCATCH_UI ) { - if ( cls.uiStarted ) + if ( cls.uiStarted && !cls.cursorActive ) UIVM_KeyEvent( key, qtrue ); } // cgame else if ( Key_GetCatcher() & KEYCATCH_CGAME ) { - if ( cls.cgameStarted ) + if ( cls.cgameStarted && !cls.cursorActive ) CGVM_KeyEvent( key, qtrue ); } // chatbox diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index b5b07c6fa9..4a0b59394f 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -105,6 +105,10 @@ cvar_t *cl_lanForcePackets; cvar_t *cl_drawRecording; +cvar_t *cl_downloadName; +cvar_t *cl_downloadPrompt; +cvar_t *cl_downloadOverlay; + vec3_t cl_windVec; @@ -1328,6 +1332,7 @@ Called when all downloading has been completed ================= */ void CL_DownloadsComplete( void ) { + clc.downloadMenuActive = qfalse; // if we downloaded files we need to restart the file system if (clc.downloadRestart) { @@ -1337,6 +1342,7 @@ void CL_DownloadsComplete( void ) { // inform the server so we get new gamestate info CL_AddReliableCommand( "donedl", qfalse ); + clc.downloadFinished = qtrue; // by sending the donedl command we request a new gamestate // so we don't want to load stuff yet @@ -1385,13 +1391,29 @@ game directory. ================= */ -void CL_BeginDownload( const char *localName, const char *remoteName ) { +void CL_BeginDownloadConfirm( void ) { + clc.downloadWaitingOnUser = qfalse; + + if ( !cl_downloadOverlay->integer ) { + clc.downloadMenuActive = qfalse; + } Com_DPrintf("***** CL_BeginDownload *****\n" "Localname: %s\n" "Remotename: %s\n" - "****************************\n", localName, remoteName); + "****************************\n", clc.downloadName, cl_downloadName->string); + + clc.downloadBlock = 0; // Starting new file + clc.downloadCount = 0; + clc.downloadTime = cls.realtime; + // Set current time to make sure the module knows the real start time after the delay + Cvar_SetValue( "cl_downloadTime", (float) cls.realtime ); + + CL_AddReliableCommand( va("download %s", cl_downloadName->string), qfalse ); +} + +void CL_BeginDownload( const char *localName, const char *remoteName ) { Q_strncpyz ( clc.downloadName, localName, sizeof(clc.downloadName) ); Com_sprintf( clc.downloadTempName, sizeof(clc.downloadTempName), "%s.tmp", localName ); @@ -1401,10 +1423,13 @@ void CL_BeginDownload( const char *localName, const char *remoteName ) { Cvar_Set( "cl_downloadCount", "0" ); Cvar_SetValue( "cl_downloadTime", (float) cls.realtime ); - clc.downloadBlock = 0; // Starting new file - clc.downloadCount = 0; - - CL_AddReliableCommand( va("download %s", remoteName), qfalse ); + // Prompt the user (unless they disabled it) + if ( cl_downloadPrompt->integer ) { + clc.downloadMenuActive = qtrue; + clc.downloadWaitingOnUser = qtrue; + } else { + CL_BeginDownloadConfirm(); + } } /* @@ -1418,8 +1443,10 @@ void CL_NextDownload(void) { char *s; char *remoteName, *localName; + clc.downloadWaitingOnUser = qfalse; + // A download has finished, check whether this matches a referenced checksum - if(*clc.downloadName) + if(*clc.downloadName && clc.downloadSize) { char *zippath = FS_BuildOSPath(Cvar_VariableString("fs_homepath"), clc.downloadName, ""); zippath[strlen(zippath)-1] = '\0'; @@ -1484,6 +1511,18 @@ and determine if we need to download them void CL_InitDownloads(void) { char missingfiles[1024]; + if ( clc.downloadFinished ) { + // If we just finished a download with a "donedl" we are getting another gamestate and we would be asked to + // download skipped files again. To avoid this we just skip this one... + clc.downloadFinished = qfalse; + CL_DownloadsComplete(); + return; + } + + if ( cl_downloadOverlay->integer ) { + clc.downloadMenuActive = qtrue; + } + if ( !cl_allowDownload->integer ) { // autodownload is disabled on the client @@ -2294,6 +2333,9 @@ void CL_InitRenderer( void ) { cls.consoleShader = re->RegisterShader( "console" ); g_console_field_width = cls.glconfig.vidWidth / SMALLCHAR_WIDTH - 2; g_consoleField.widthInChars = g_console_field_width; + + cls.cursorShader = re->RegisterShaderNoMip("cursor"); + cls.menuFont = re->RegisterFont( "ocr_a" ); } /* @@ -2774,6 +2816,10 @@ void CL_Init( void ) { cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60 0xb2", CVAR_ARCHIVE, "Which keys are used to toggle the console"); cl_consoleUseScanCode = Cvar_Get( "cl_consoleUseScanCode", "1", CVAR_ARCHIVE, "Use native console key detection" ); + cl_downloadName = Cvar_Get( "cl_downloadName", "", CVAR_INTERNAL ); + cl_downloadPrompt = Cvar_Get( "cl_downloadPrompt", "1", CVAR_ARCHIVE, "Confirm pk3 downloads from the server" ); + cl_downloadOverlay = Cvar_Get( "cl_downloadOverlay", "1", CVAR_ARCHIVE, "Draw download info overlay" ); + // userinfo Cvar_Get ("name", "Padawan", CVAR_USERINFO | CVAR_ARCHIVE_ND, "Player name" ); Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE, "Data rate" ); @@ -3718,3 +3764,298 @@ void CL_ShowIP_f(void) { Sys_ShowIP(); } +/* +================== + Internal Menu +================== +*/ + +void CL_DrawMenuRect( float x, float y, float width, float height, float borderSize, vec4_t elementBackgroundColor, vec4_t elementBorderColor ) { + // Draw the background + if ( elementBackgroundColor ) { + re->SetColor( elementBackgroundColor ); + re->DrawStretchPic( x, y, width, height, 0, 0, 0, 0, cls.whiteShader ); + } + + // Draw the borders + if ( elementBorderColor ) { + re->SetColor( elementBorderColor ); + re->DrawStretchPic( x, y, width, borderSize, 0, 0, 0, 0, cls.whiteShader ); + re->DrawStretchPic( x, y + height - borderSize, width, borderSize, 0, 0, 0, 0, cls.whiteShader ); + re->DrawStretchPic( x, y, borderSize, height, 0, 0, 0, 0, cls.whiteShader ); + re->DrawStretchPic( x + width - borderSize, y, borderSize, height, 0, 0, 0, 0, cls.whiteShader ); + } + + // Prevent color from leaking + re->SetColor( NULL ); +} + +void CL_DrawCenterStringAt( int x, int y, const char *str, int font, float scale ) { + int lenX = re->Font_StrLenPixels( str, font, scale ); + int lenY = re->Font_HeightPixels( font, scale ); + re->Font_DrawString( x - (lenX/2), y - (lenY/2), str, colorWhite, font, -1, scale ); +} + +typedef struct menuButton_s { + int x; + int y; + float width; + float height; + const char *text; + int font; + float scale; + void (*action)( void ); +} menuButton_t; +static menuButton_t menuButtons[16]; // No need for dynamic lists. We currently got exactly one menu with max. 3 buttons +static int menuButtonsActive = 0; + +static menuButton_t *CL_RegisterMenuButtonArea( int x, int y, float width, float height, const char *text, int font, float scale, void (*action)(void) ) { + // Too many buttons? Silently discard it to avoid console spam + if ( menuButtonsActive >= (int)ARRAY_LEN(menuButtons) ) return NULL; + + // Set the values + menuButtons[menuButtonsActive].x = x; + menuButtons[menuButtonsActive].y = y; + menuButtons[menuButtonsActive].width = width; + menuButtons[menuButtonsActive].height = height; + menuButtons[menuButtonsActive].text = text; + menuButtons[menuButtonsActive].font = font; + menuButtons[menuButtonsActive].scale = scale; + menuButtons[menuButtonsActive].action = action; + + // Increment counter + return &menuButtons[menuButtonsActive++]; +} + +static qboolean CL_IsCursorOnMenuButton( menuButton_t *button ) { + if ( cls.cursorX >= button->x && cls.cursorX <= button->x+button->width && cls.cursorY >= button->y && cls.cursorY <= button->y+button->height ) + return qtrue; + return qfalse; +} + +static void CL_DrawMenuButton( menuButton_t *button, vec4_t buttonBackgroundColor, vec4_t buttonBorderColor ) { + if ( !button ) return; + CL_DrawMenuRect( button->x, button->y, button->width, button->height, 3, buttonBackgroundColor, buttonBorderColor ); + CL_DrawCenterStringAt( button->x + (button->width/2), button->y + 5, button->text, button->font, button->scale ); +} + +static const char *CL_ByteCountToHumanString( int byteCount ) +{ + #define GB_BYTES (1024 * 1024 * 1024) + #define MB_BYTES (1024 * 1024) + #define KB_BYTES (1024) + + if ( byteCount > GB_BYTES ) return va( "%.02f GB", (float)byteCount / GB_BYTES ); + else if ( byteCount > MB_BYTES ) return va( "%.02f MB", (float)byteCount / MB_BYTES ); + else if ( byteCount > KB_BYTES ) return va( "%.1f KB", (float)byteCount / KB_BYTES ); + else return va( "%i B", byteCount ); +} + +static const char *CL_DurationSecToString( int duration ) +{ // SkyMod: Duration seconds to string + #define TIME_YEAR (60 * 60 * 24 * 365) + #define TIME_WEEK (60 * 60 * 24 * 7) + #define TIME_DAY (60 * 60 * 24) + #define TIME_HOUR (60 * 60) + #define TIME_MINUTE (60) + + static int call; + static char bufs[2][128]; + char *durationStr = bufs[call&1]; + int years = 0, weeks = 0, days = 0, hours = 0, minutes = 0, seconds = 0; + call++; + + while ( duration ) + { + if ( duration >= TIME_YEAR ) + { + duration -= TIME_YEAR; + years++; + } + else if ( duration >= TIME_WEEK ) + { + duration -= TIME_WEEK; + weeks++; + } + else if ( duration >= TIME_DAY ) + { + duration -= TIME_DAY; + days++; + } + else if ( duration >= TIME_HOUR ) + { + duration -= TIME_HOUR; + hours++; + } + else if ( duration >= TIME_MINUTE ) + { + duration -= TIME_MINUTE; + minutes++; + } + else + { + seconds = duration; + duration = 0; + } + } + + *durationStr = 0; + if ( years ) Q_strcat( durationStr, sizeof(bufs[0]), va("%iy ", years) ); + if ( weeks ) Q_strcat( durationStr, sizeof(bufs[0]), va("%iw ", weeks) ); + if ( days ) Q_strcat( durationStr, sizeof(bufs[0]), va("%id ", days) ); + if ( hours ) Q_strcat( durationStr, sizeof(bufs[0]), va("%ih ", hours) ); + if ( minutes ) Q_strcat( durationStr, sizeof(bufs[0]), va("%im ", minutes) ); + if ( seconds ) Q_strcat( durationStr, sizeof(bufs[0]), va("%is ", seconds) ); + + if ( *durationStr ) + { // Strip tailing space + char *ptr = durationStr; + while ( *ptr ) ptr++; + if ( *(ptr-1) == ' ' ) *(ptr-1) = 0; + } + + return durationStr; +} + +void CL_DrawDownloadRequest( void ) { + // Menu values + static vec4_t backgroundColor = { 0.1f, 0.2f, 0.45f, 0.9f }; + static vec4_t borderColor = { 0.05f, 0.1f, 0.35f, 1.0f }; + static float width = SCREEN_WIDTH / 6; + static float height = SCREEN_HEIGHT / 4; + + static float centerX = SCREEN_WIDTH / 2; + static float centerY = SCREEN_HEIGHT / 2; + + static float scale = 1.0f; + + // Button values + static vec4_t buttonBackgroundColor = { 0.1f, 0.1f, 0.4f, 0.9f }; + static vec4_t buttonBorderColor = { 0.05f, 0.05f, 0.2f, 1.0f }; + menuButton_t *button; + + // Draw frame + CL_DrawMenuRect( width, height, width*4, height*2, 6, backgroundColor, borderColor ); + + // Header + CL_DrawCenterStringAt( centerX, height + 10, "^1[ ^7File Download ^1]", cls.menuFont, scale ); + + // File name + CL_DrawCenterStringAt( centerX, centerY - (height/2), cl_downloadName->string, cls.menuFont, scale ); + + if ( clc.downloadWaitingOnUser ) { + // Tell user that we're waiting on their decision + CL_DrawCenterStringAt( centerX, centerY-10, "Do you want to download this file?", cls.menuFont, scale ); + CL_DrawCenterStringAt( centerX, centerY+10, "Please select an option", cls.menuFont, scale ); + } else { + // Draw Progress Bar + static vec4_t barBackgroundColor = { 0.1f, 0.8f, 0.4f, 0.9f }; + static vec4_t barBorderColor = { 0.05f, 0.6f, 0.2f, 1.0f }; + float dlFrac = clc.downloadSize ? (float)clc.downloadCount / clc.downloadSize : 0.0f; + + // Download speed + int dlTime = (float)(cls.realtime - clc.downloadTime) / 1000.0f; + static int dlRate; + static int dlLastTime; + static int dlLastCount; + + // Bar with percentage + CL_DrawCenterStringAt( centerX, centerY - 10, "Progress:", cls.menuFont, scale ); + CL_DrawMenuRect( centerX - width*2 + 10, centerY+5, (width * 4 - 20 - 3) * dlFrac, 20, 3, barBackgroundColor, NULL ); + CL_DrawMenuRect( centerX - width*2 + 10, centerY+5, width * 4 - 20 - 3, 20, 3, NULL, barBorderColor ); + CL_DrawCenterStringAt( centerX, centerY+10, va("%.02f%%", dlFrac * 100), cls.menuFont, scale ); + + // Draw size info + re->Font_DrawString( width + 10, centerY+30, va("File Size: %s", CL_ByteCountToHumanString(clc.downloadSize)) , colorWhite, cls.menuFont, -1, scale ); + re->Font_DrawString( width + 10, centerY+50, va("Downloaded: %s", CL_ByteCountToHumanString(clc.downloadCount)) , colorWhite, cls.menuFont, -1, scale ); + + // Download Speed + if ( dlTime >= 1 ) { + if ( dlTime != dlLastTime ) { + // Second passed, update measured values + dlRate = clc.downloadCount - dlLastCount; + dlLastTime = dlTime; + dlLastCount = clc.downloadCount; + } + + // Draw info texts + re->Font_DrawString( width + 10, centerY+70, va("Transfer Rate: %s/sec", CL_ByteCountToHumanString(dlRate)) , colorWhite, cls.menuFont, -1, scale ); + re->Font_DrawString( width + 10, centerY+90, va("Estimated Time Left: %s", dlRate ? CL_DurationSecToString(clc.downloadSize/dlRate - dlLastCount/dlRate) : "unknown" ) , colorWhite, cls.menuFont, -1, scale ); + } else { + // Set defaults - if we somehow don't get here and start with dlTime >= 1 we get incorrect values for one second, but that's okay + dlLastCount = clc.downloadCount; + dlLastTime = 0; + dlRate = 0; + + re->Font_DrawString( width + 10, centerY+70, "Transfer Rate: estimating" , colorWhite, cls.menuFont, -1, scale ); + re->Font_DrawString( width + 10, centerY+90, "Estimated Time Left: estimating" , colorWhite, cls.menuFont, -1, scale ); + } + } + + // Draw Buttons + if ( clc.downloadWaitingOnUser ) { + // Only show yes/no if we're waiting on a user decision + button = CL_RegisterMenuButtonArea( width + 10, (height * 3) - 30, 40, 20, "Yes", cls.menuFont, scale, CL_BeginDownloadConfirm ); + CL_DrawMenuButton( button, buttonBackgroundColor, buttonBorderColor ); + + button = CL_RegisterMenuButtonArea( width + 60, (height * 3) - 30, 40, 20, "No", cls.menuFont, scale, CL_NextDownload ); + CL_DrawMenuButton( button, buttonBackgroundColor, buttonBorderColor ); + } + + // The user can always abort if they change their mind + button = CL_RegisterMenuButtonArea( SCREEN_WIDTH - width - 13 - 80, (height * 3) - 30, 80, 20, "Abort", cls.menuFont, scale, CL_Disconnect_f ); + CL_DrawMenuButton( button, buttonBackgroundColor, buttonBorderColor ); +} + +void CL_DrawEngineMenus( void ) { + if ( clc.downloadMenuActive ) { + // Accept cursor movement + cls.cursorActive = qtrue; + } else { + // Disable movement + cls.cursorActive = qfalse; + } + + // Reset all menu buttons, the menu set them if required + menuButtonsActive = 0; + + // Draw menus + if ( clc.downloadMenuActive ) { + CL_DrawDownloadRequest(); + } + + // Draw cursor + if ( cls.cursorActive ) { + int i; + + // Re-draw the buttons the user is hovering over, but use a different color + static vec4_t buttonHoverBackground = { 0.75f, 0.5f, 0.0f, 1.0f }; + static vec4_t buttonHoverFrame = { 0.50f, 0.25f, 0.0f, 1.0f }; + for ( i = 0; i < menuButtonsActive; i++ ) { + if ( CL_IsCursorOnMenuButton(&menuButtons[i]) ) { + CL_DrawMenuButton( &menuButtons[i], buttonHoverBackground, buttonHoverFrame ); + } + } + + // Draw the actual cursor + re->DrawStretchPic( cls.cursorX, cls.cursorY, 48, 48, 0, 0, 1, 1, cls.cursorShader ); + } +} + +void CL_UpdateCursorPosition( int dx, int dy ) { + if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) return; + + cls.cursorX = Com_Clampi( 0, SCREEN_WIDTH, cls.cursorX + dx ); + cls.cursorY = Com_Clampi( 0, SCREEN_HEIGHT, cls.cursorY + dy ); +} + +void CL_CursorButton( int key ) { + int i; + if ( key == A_MOUSE1 ) { + for ( i = 0; i < menuButtonsActive; i++ ) { + if ( CL_IsCursorOnMenuButton(&menuButtons[i]) ) { + menuButtons[i].action(); + } + } + } +} diff --git a/codemp/client/cl_scrn.cpp b/codemp/client/cl_scrn.cpp index d82d6c7c8a..0ad8bca3bc 100644 --- a/codemp/client/cl_scrn.cpp +++ b/codemp/client/cl_scrn.cpp @@ -472,6 +472,9 @@ void SCR_DrawScreenField( stereoFrame_t stereoFrame ) { UIVM_Refresh( cls.realtime ); } + // Engine internal menu + CL_DrawEngineMenus(); + // console draws next Con_DrawConsole (); diff --git a/codemp/client/client.h b/codemp/client/client.h index 4584b2d18a..98c441ecc3 100644 --- a/codemp/client/client.h +++ b/codemp/client/client.h @@ -223,6 +223,10 @@ typedef struct clientConnection_s { int downloadSize; // how many bytes we got char downloadList[MAX_INFO_STRING]; // list of paks we need to download qboolean downloadRestart; // if true, we need to do another FS_Restart because we downloaded a pak + qboolean downloadMenuActive; + qboolean downloadWaitingOnUser; + qboolean downloadFinished; + int downloadTime; // demo information char demoName[MAX_QPATH]; @@ -326,6 +330,15 @@ typedef struct clientStatic_s { qhandle_t charSetShader; qhandle_t whiteShader; qhandle_t consoleShader; + + // Cursor + qboolean cursorActive; + qhandle_t cursorShader; + int cursorX; + int cursorY; + + // Engine menu + int menuFont; } clientStatic_t; #define CON_TEXTSIZE 0x30000 //was 32768 @@ -456,6 +469,10 @@ int CL_ServerStatus( const char *serverAddress, char *serverStatusString, int ma qboolean CL_CheckPaused(void); +void CL_DrawEngineMenus( void ); +void CL_UpdateCursorPosition( int dx, int dy ); +void CL_CursorButton( int key ); + // // cl_input // diff --git a/shared/sdl/sdl_input.cpp b/shared/sdl/sdl_input.cpp index 5eab5e458f..389c623f29 100644 --- a/shared/sdl/sdl_input.cpp +++ b/shared/sdl/sdl_input.cpp @@ -1147,7 +1147,7 @@ void IN_Frame (void) { // Console is down in windowed mode IN_DeactivateMouse( ); } - else if( !cls.glconfig.isFullscreen && loading ) + else if( !cls.glconfig.isFullscreen && loading && !cls.cursorActive ) { // Loading in windowed mode IN_DeactivateMouse( ); From f0b68d1e6edb092647b8170fe1ee3e3d79e2afcf Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sat, 11 Nov 2023 16:23:44 +0100 Subject: [PATCH 770/801] [MP] Default cl_allowDownload to 1, because cl_downloadPrompt is enabled by default and requires user confirmation. --- codemp/client/cl_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index 4a0b59394f..a1c7e47a9a 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -2774,7 +2774,7 @@ void CL_Init( void ) { cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0); cl_framerate = Cvar_Get ("cl_framerate", "0", CVAR_TEMP); - cl_allowDownload = Cvar_Get ("cl_allowDownload", "0", CVAR_ARCHIVE_ND, "Allow downloading custom paks from server"); + cl_allowDownload = Cvar_Get ("cl_allowDownload", "1", CVAR_ARCHIVE_ND, "Allow downloading custom paks from server"); cl_allowAltEnter = Cvar_Get ("cl_allowAltEnter", "1", CVAR_ARCHIVE_ND, "Enables use of ALT+ENTER keyboard combo to toggle fullscreen" ); cl_autolodscale = Cvar_Get( "cl_autolodscale", "1", CVAR_ARCHIVE_ND ); From 371b8d6a5da9b0a15305227df9b7ba457e06feae Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sat, 11 Nov 2023 18:48:39 +0100 Subject: [PATCH 771/801] [Shared] Add com_timestamps cvar to enable timestamps in system terminal and qconsole.log Originally written by fau for jk2mv. --- code/qcommon/common.cpp | 60 +++++++++++++++++++++------- codemp/qcommon/common.cpp | 84 +++++++++++++++++++++++++++------------ 2 files changed, 104 insertions(+), 40 deletions(-) diff --git a/code/qcommon/common.cpp b/code/qcommon/common.cpp index cb4fe06de2..41f2da9e55 100644 --- a/code/qcommon/common.cpp +++ b/code/qcommon/common.cpp @@ -73,6 +73,8 @@ cvar_t *com_G2Report; cvar_t *com_affinity; +cvar_t *com_timestamps; + // com_speeds times int time_game; int time_frontend; // renderer frontend time @@ -137,6 +139,7 @@ A raw string should NEVER be passed as fmt, because of "%f" type crashers. void QDECL Com_Printf( const char *fmt, ... ) { va_list argptr; char msg[MAXPRINTMSG]; + const char *p; va_start (argptr,fmt); Q_vsnprintf (msg, sizeof(msg), fmt, argptr); @@ -153,26 +156,53 @@ void QDECL Com_Printf( const char *fmt, ... ) { CL_ConsolePrint( msg ); - // echo to dedicated console and early console - Sys_Print( msg ); + p = msg; + while (*p) { + static qboolean newLine = qtrue; + char line[MAXPRINTMSG]; + size_t lineLen; + + if (newLine && com_timestamps && com_timestamps->integer) { + time_t t = time( NULL ); + struct tm *tms = localtime( &t ); + Com_sprintf(line, sizeof(line), "%04i-%02i-%02i %02i:%02i:%02i ", + 1900 + tms->tm_year, 1 + tms->tm_mon, tms->tm_mday, tms->tm_hour, tms->tm_min, tms->tm_sec); + lineLen = strlen(line); + newLine = qfalse; + } else { + if (const char *s = strchr(p, '\n')) { + lineLen = (size_t)(s - p + 1); + newLine = qtrue; + } else { + lineLen = strlen(p); + } + + Com_Memcpy(line, p, lineLen); + line[lineLen] = '\0'; + p += lineLen; + } + + // echo to dedicated console and early console + Sys_Print( line ); #ifdef OUTPUT_TO_BUILD_WINDOW - OutputDebugString(msg); + OutputDebugString(line); #endif - // logfile - if ( com_logfile && com_logfile->integer ) { - if ( !logfile && FS_Initialized() ) { - logfile = FS_FOpenFileWrite( "qconsole.log" ); - if ( com_logfile->integer > 1 ) { - // force it to not buffer so we get valid - // data even if we are crashing - FS_ForceFlush(logfile); + // logfile + if ( com_logfile && com_logfile->integer ) { + if ( !logfile && FS_Initialized() ) { + logfile = FS_FOpenFileWrite( "qconsole.log" ); + if ( com_logfile->integer > 1 ) { + // force it to not buffer so we get valid + // data even if we are crashing + FS_ForceFlush(logfile); + } + } + if ( logfile ) { + FS_Write(line, strlen(line), logfile); } - } - if ( logfile ) { - FS_Write(msg, strlen(msg), logfile); } } } @@ -1121,6 +1151,8 @@ void Com_Init( char *commandLine ) { com_bootlogo = Cvar_Get( "com_bootlogo", "1", CVAR_ARCHIVE_ND ); + com_timestamps = Cvar_Get( "com_timestamps", "1", CVAR_ARCHIVE_ND ); + if ( com_developer && com_developer->integer ) { Cmd_AddCommand ("error", Com_Error_f); Cmd_AddCommand ("crash", Com_Crash_f ); diff --git a/codemp/qcommon/common.cpp b/codemp/qcommon/common.cpp index 8cceb640e9..69061d16de 100644 --- a/codemp/qcommon/common.cpp +++ b/codemp/qcommon/common.cpp @@ -72,6 +72,8 @@ cvar_t *com_busyWait; cvar_t *com_affinity; +cvar_t *com_timestamps; + // com_speeds times int time_game; int time_frontend; // renderer frontend time @@ -129,6 +131,7 @@ void QDECL Com_Printf( const char *fmt, ... ) { va_list argptr; char msg[MAXPRINTMSG]; static qboolean opening_qconsole = qfalse; + const char *p; va_start (argptr,fmt); Q_vsnprintf (msg, sizeof(msg), fmt, argptr); @@ -150,41 +153,68 @@ void QDECL Com_Printf( const char *fmt, ... ) { CL_ConsolePrint( msg ); #endif - // echo to dedicated console and early console - Sys_Print( msg ); + p = msg; + while (*p) { + static qboolean newLine = qtrue; + char line[MAXPRINTMSG]; + size_t lineLen; + + if (newLine && com_timestamps && com_timestamps->integer) { + time_t t = time( NULL ); + struct tm *tms = localtime( &t ); + Com_sprintf(line, sizeof(line), "%04i-%02i-%02i %02i:%02i:%02i ", + 1900 + tms->tm_year, 1 + tms->tm_mon, tms->tm_mday, tms->tm_hour, tms->tm_min, tms->tm_sec); + lineLen = strlen(line); + newLine = qfalse; + } else { + if (const char *s = strchr(p, '\n')) { + lineLen = (size_t)(s - p + 1); + newLine = qtrue; + } else { + lineLen = strlen(p); + } + + Com_Memcpy(line, p, lineLen); + line[lineLen] = '\0'; + p += lineLen; + } + + // echo to dedicated console and early console + Sys_Print( line ); - // logfile - if ( com_logfile && com_logfile->integer ) { - // TTimo: only open the qconsole.log if the filesystem is in an initialized state - // also, avoid recursing in the qconsole.log opening (i.e. if fs_debug is on) - if ( !logfile && FS_Initialized() && !opening_qconsole ) { - struct tm *newtime; - time_t aclock; + // logfile + if ( com_logfile && com_logfile->integer ) { + // TTimo: only open the qconsole.log if the filesystem is in an initialized state + // also, avoid recursing in the qconsole.log opening (i.e. if fs_debug is on) + if ( !logfile && FS_Initialized() && !opening_qconsole ) { + struct tm *newtime; + time_t aclock; - opening_qconsole = qtrue; + opening_qconsole = qtrue; - time( &aclock ); - newtime = localtime( &aclock ); + time( &aclock ); + newtime = localtime( &aclock ); - logfile = FS_FOpenFileWrite( "qconsole.log" ); + logfile = FS_FOpenFileWrite( "qconsole.log" ); - if ( logfile ) { - Com_Printf( "logfile opened on %s\n", asctime( newtime ) ); - if ( com_logfile->integer > 1 ) { - // force it to not buffer so we get valid - // data even if we are crashing - FS_ForceFlush(logfile); + if ( logfile ) { + Com_Printf( "logfile opened on %s\n", asctime( newtime ) ); + if ( com_logfile->integer > 1 ) { + // force it to not buffer so we get valid + // data even if we are crashing + FS_ForceFlush(logfile); + } + } + else { + Com_Printf( "Opening qconsole.log failed!\n" ); + Cvar_SetValue( "logfile", 0 ); } } - else { - Com_Printf( "Opening qconsole.log failed!\n" ); - Cvar_SetValue( "logfile", 0 ); + opening_qconsole = qfalse; + if ( logfile && FS_Initialized()) { + FS_Write(line, strlen(line), logfile); } } - opening_qconsole = qfalse; - if ( logfile && FS_Initialized()) { - FS_Write(msg, strlen(msg), logfile); - } } @@ -1242,6 +1272,8 @@ void Com_Init( char *commandLine ) { com_bootlogo = Cvar_Get( "com_bootlogo", "1", CVAR_ARCHIVE_ND, "Show intro movies" ); + com_timestamps = Cvar_Get( "com_timestamps", "1", CVAR_ARCHIVE_ND, "Show timestamps in terminal and qconsole.log" ); + s = va("%s %s %s", JK_VERSION_OLD, PLATFORM_STRING, SOURCE_DATE ); com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO ); From c54bc586ef795c888fe99f760196aa9c8ad67c5c Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sat, 11 Nov 2023 18:59:33 +0100 Subject: [PATCH 772/801] [Shared] Fix ocr_a font not working in console anymore after renderer restart. --- code/client/cl_console.cpp | 4 ++-- code/client/cl_main.cpp | 1 + code/client/client.h | 1 + codemp/client/cl_console.cpp | 4 ++-- codemp/client/cl_main.cpp | 1 + codemp/client/client.h | 1 + 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/code/client/cl_console.cpp b/code/client/cl_console.cpp index d40832a538..f175cbcaf5 100644 --- a/code/client/cl_console.cpp +++ b/code/client/cl_console.cpp @@ -608,7 +608,7 @@ void Con_DrawNotify (void) currentColor = 7; re.SetColor( g_color_table[currentColor] ); - static int iFontIndex = re.RegisterFont("ocr_a"); + int iFontIndex = cls.consoleFont; float fFontScale = 1.0f; int iPixelHeightToAdvance = 0; if (re.Language_IsAsian()) @@ -765,7 +765,7 @@ void Con_DrawSolidConsole( float frac ) currentColor = 7; re.SetColor( g_color_table[currentColor] ); - static int iFontIndex = re.RegisterFont("ocr_a"); + int iFontIndex = cls.consoleFont; float fFontScale = 1.0f; int iPixelHeightToAdvance = con.charHeight; if (re.Language_IsAsian()) diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index 6527a23e6e..1a5c244665 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -935,6 +935,7 @@ void CL_InitRenderer( void ) { // load character sets cls.charSetShader = re.RegisterShaderNoMip("gfx/2d/charsgrid_med"); + cls.consoleFont = re.RegisterFont( "ocr_a" ); cls.whiteShader = re.RegisterShader( "white" ); cls.consoleShader = re.RegisterShader( "console" ); g_console_field_width = cls.glconfig.vidWidth / SMALLCHAR_WIDTH - 2; diff --git a/code/client/client.h b/code/client/client.h index a1410bd48a..131842a95d 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -206,6 +206,7 @@ typedef struct { qhandle_t charSetShader; qhandle_t whiteShader; qhandle_t consoleShader; + int consoleFont; } clientStatic_t; #define CON_TEXTSIZE 0x30000 //was 32768 diff --git a/codemp/client/cl_console.cpp b/codemp/client/cl_console.cpp index ec6e1777d1..68968dd941 100644 --- a/codemp/client/cl_console.cpp +++ b/codemp/client/cl_console.cpp @@ -732,7 +732,7 @@ void Con_DrawNotify (void) currentColor = 7; re->SetColor( g_color_table[currentColor] ); - static int iFontIndex = re->RegisterFont("ocr_a"); + int iFontIndex = cls.consoleFont; float fFontScale = 1.0f; int iPixelHeightToAdvance = 0; if (re->Language_IsAsian()) @@ -928,7 +928,7 @@ void Con_DrawSolidConsole( float frac ) { currentColor = 7; re->SetColor( g_color_table[currentColor] ); - static int iFontIndex = re->RegisterFont("ocr_a"); + int iFontIndex = cls.consoleFont; float fFontScale = 1.0f; int iPixelHeightToAdvance = con.charHeight; if (re->Language_IsAsian()) diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index ee86a6ea97..48e79a793d 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -2290,6 +2290,7 @@ void CL_InitRenderer( void ) { // load character sets cls.charSetShader = re->RegisterShaderNoMip("gfx/2d/charsgrid_med"); + cls.consoleFont = re->RegisterFont( "ocr_a" ); cls.whiteShader = re->RegisterShader( "white" ); cls.consoleShader = re->RegisterShader( "console" ); diff --git a/codemp/client/client.h b/codemp/client/client.h index 2a38d6014c..59ac0c6c4e 100644 --- a/codemp/client/client.h +++ b/codemp/client/client.h @@ -326,6 +326,7 @@ typedef struct clientStatic_s { qhandle_t charSetShader; qhandle_t whiteShader; qhandle_t consoleShader; + int consoleFont; } clientStatic_t; #define CON_TEXTSIZE 0x30000 //was 32768 From d786f197d1ebb967707f0570c7d5c0f45205c0a5 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sat, 11 Nov 2023 23:27:34 +0100 Subject: [PATCH 773/801] [SP] Map the UI module internal font numbers 1 to 4 to the names of default fonts and dynamically register them to avoid undesired font changes when registering other fonts too early. --- code/ui/ui_shared.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/code/ui/ui_shared.cpp b/code/ui/ui_shared.cpp index 885d0e9019..0306ba6c72 100644 --- a/code/ui/ui_shared.cpp +++ b/code/ui/ui_shared.cpp @@ -3072,7 +3072,19 @@ qboolean ItemParse_name( itemDef_t *item) return qtrue; } +int MenuFontToReal( int menuFontIndex ) +{ + // Default fonts from a clean installation + switch ( menuFontIndex ) { + case 1: return UI_RegisterFont( "aurabesh" ); + case 2: return UI_RegisterFont( "ergoec" ); + case 3: return UI_RegisterFont( "anewhope" ); + case 4: return UI_RegisterFont( "arialnb" ); + default: + return DC->Assets.qhMediumFont; + } +} qboolean ItemParse_font( itemDef_t *item ) { @@ -3080,6 +3092,10 @@ qboolean ItemParse_font( itemDef_t *item ) { return qfalse; } + + // Translate to real font + item->font = MenuFontToReal( item->font ); + return qtrue; } @@ -8261,7 +8277,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw) while (1) { // FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu. - textWidth = DC->textWidth(textPtr, fDescScale, 4); // item->font); + textWidth = DC->textWidth(textPtr, fDescScale, MenuFontToReal(4)); // item->font); if (parent->descAlignment == ITEM_ALIGN_RIGHT) { @@ -8297,7 +8313,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw) } // FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu. - DC->drawText(xPos, parent->descY + iYadj, fDescScale, parent->descColor, textPtr, 0, parent->descTextStyle, 4); //item->font); + DC->drawText(xPos, parent->descY + iYadj, fDescScale, parent->descColor, textPtr, 0, parent->descTextStyle, MenuFontToReal(4)); //item->font); break; } } From 97c7291fb5267abdac412385469146fd3fe1542e Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sun, 12 Nov 2023 01:15:33 +0100 Subject: [PATCH 774/801] [Shared] Add support for sharper fonts (requires new assets; cvar: r_fontSharpness). Originally written by fau for jk2mv. --- code/rd-common/tr_font.cpp | 122 +++++++++++++++++++++++++++++++++-- codemp/rd-common/tr_font.cpp | 119 ++++++++++++++++++++++++++++++++-- 2 files changed, 227 insertions(+), 14 deletions(-) diff --git a/code/rd-common/tr_font.cpp b/code/rd-common/tr_font.cpp index de2382448e..8724a18311 100644 --- a/code/rd-common/tr_font.cpp +++ b/code/rd-common/tr_font.cpp @@ -34,6 +34,8 @@ along with this program; if not, see . #include "../qcommon/strippublic.h" #endif +cvar_t *r_fontSharpness; + ///////////////////////////////////////////////////////////////////////////////////////////////////////// // // This file is shared in the single and multiplayer codebases, so be CAREFUL WHAT YOU ADD/CHANGE!!!!! @@ -218,6 +220,8 @@ struct ThaiCodes_t #define GLYPH_MAX_THAI_SHADERS 3 #define GLYPH_MAX_ASIAN_SHADERS 4 // this MUST equal the larger of the above defines +#define MAX_FONT_VARIANTS 8 + class CFontInfo { private: @@ -260,6 +264,11 @@ class CFontInfo #endif bool m_bIsFakeAlienLanguage; // ... if true, don't process as MBCS or override as SBCS etc + CFontInfo *m_variants[MAX_FONT_VARIANTS]; + int m_numVariants; + int m_handle; + qboolean m_isVariant; + CFontInfo(const char *fontName); // CFontInfo(int fill) { memset(this, fill, sizeof(*this)); } // wtf? ~CFontInfo(void) {} @@ -284,6 +293,12 @@ class CFontInfo bool AsianGlyphsAvailable(void) const { return !!(m_hAsianShaders[0]); } void UpdateAsianIfNeeded( bool bForceReEval = false); + + int GetHandle(); + + void AddVariant(CFontInfo *variant); + int GetNumVariants(); + CFontInfo *GetVariant(int index); }; //================================================ @@ -979,6 +994,11 @@ qboolean Language_UsesSpaces(void) // If path present, it's a special language hack for SBCS override languages, eg: "lcd/russian", which means // just treat the file as "russian", but with the "lcd" part ensuring we don't find a different registered russian font // +static const char *FontDatPath( const char *_fontName ) { + static char fontName[MAX_QPATH]; + sprintf( fontName,"fonts/%s.fontdat",COM_SkipPath(const_cast(_fontName)) ); // COM_SkipPath should take a const char *, but it's just possible people use it as a char * I guess, so I have to hack around like this + return fontName; +} CFontInfo::CFontInfo(const char *_fontName) { int len, i; @@ -987,8 +1007,7 @@ CFontInfo::CFontInfo(const char *_fontName) // remove any special hack name insertions... // - char fontName[MAX_QPATH]; - sprintf(fontName,"fonts/%s.fontdat",COM_SkipPath(const_cast(_fontName))); // COM_SkipPath should take a const char *, but it's just possible people use it as a char * I guess, so I have to hack around like this + const char *fontName = FontDatPath( _fontName ); // clear some general things... // @@ -1056,6 +1075,7 @@ CFontInfo::CFontInfo(const char *_fontName) // finished... g_vFontArray.resize(g_iCurrentFontIndex + 1); + m_handle = g_iCurrentFontIndex; g_vFontArray[g_iCurrentFontIndex++] = this; @@ -1137,6 +1157,24 @@ CFontInfo::CFontInfo(const char *_fontName) } } } + + m_numVariants = 0; +} + +int CFontInfo::GetHandle() { + return m_handle; +} + +void CFontInfo::AddVariant(CFontInfo * replacer) { + m_variants[m_numVariants++] = replacer; +} + +int CFontInfo::GetNumVariants() { + return m_numVariants; +} + +CFontInfo *CFontInfo::GetVariant(int index) { + return m_variants[index]; } void CFontInfo::UpdateAsianIfNeeded( bool bForceReEval /* = false */ ) @@ -1287,6 +1325,30 @@ static CFontInfo *GetFont_Actual(int index) return(NULL); } +static CFontInfo *RE_Font_GetVariant(CFontInfo *font, float *scale) { + int variants = font->GetNumVariants(); + + if (variants > 0) { + CFontInfo *variant; + int requestedSize = font->GetPointSize() * *scale * + r_fontSharpness->value * (glConfig.vidHeight / SCREEN_HEIGHT); + + if (requestedSize <= font->GetPointSize()) + return font; + + for (int i = 0; i < variants; i++) { + variant = font->GetVariant(i); + + if (requestedSize <= variant->GetPointSize()) + break; + } + + *scale *= (float)font->GetPointSize() / variant->GetPointSize(); + return variant; + } + + return font; +} // needed to add *piShader param because of multiple TPs, // if not passed in, then I also skip S,T calculations for re-usable static asian glyphinfo struct... @@ -1534,8 +1596,9 @@ CFontInfo *GetFont(int index) } -int RE_Font_StrLenPixels(const char *psText, const int iFontHandle, const float fScale) +int RE_Font_StrLenPixels(const char *psText, const int iFontHandle, const float fScaleIn) { + float fScale = fScaleIn; #ifdef JK2_MODE // Yes..even this func is a little different, to the point where it doesn't work. --eez float fMaxWidth = 0.0f; @@ -1547,6 +1610,7 @@ int RE_Font_StrLenPixels(const char *psText, const int iFontHandle, const float { return(0); } + curfont = RE_Font_GetVariant(curfont, &fScale); float fScaleAsian = fScale; if (Language_IsAsian() && fScale > 0.7f ) @@ -1586,6 +1650,7 @@ int RE_Font_StrLenPixels(const char *psText, const int iFontHandle, const float { return(0); } + curfont = RE_Font_GetVariant(curfont, &fScale); float fScaleAsian = fScale; if (Language_IsAsian() && fScale > 0.7f ) @@ -1673,14 +1738,17 @@ int RE_Font_StrLenChars(const char *psText) return iCharCount; } -int RE_Font_HeightPixels(const int iFontHandle, const float fScale) +int RE_Font_HeightPixels(const int iFontHandle, const float fScaleIn) { + float fScale = fScaleIn; CFontInfo *curfont; curfont = GetFont(iFontHandle); if(curfont) { - float fValue = curfont->GetPointSize() * fScale; + float fValue; + curfont = RE_Font_GetVariant(curfont, &fScale); + fValue = curfont->GetPointSize() * fScale; return curfont->mbRoundCalcs ? Round(fValue) : fValue; } return(0); @@ -1688,8 +1756,10 @@ int RE_Font_HeightPixels(const int iFontHandle, const float fScale) // iMaxPixelWidth is -1 for "all of string", else pixel display count... // -void RE_Font_DrawString(int ox, int oy, const char *psText, const float *rgba, const int iFontHandle, int iMaxPixelWidth, const float fScale) +void RE_Font_DrawString(int ox, int oy, const char *psText, const float *rgba, const int iFontHandleIn, int iMaxPixelWidth, const float fScaleIn) { + int iFontHandle = iFontHandleIn; + float fScale = fScaleIn; // HAAAAAAAAAAAAAAAX..fix me please --eez #ifdef JK2_MODE static qboolean gbInShadow = qfalse; // MUST default to this @@ -1732,6 +1802,8 @@ void RE_Font_DrawString(int ox, int oy, const char *psText, const float *rgba, c { return; } + curfont = RE_Font_GetVariant(curfont, &fScale); + iFontHandle = curfont->GetHandle() | (iFontHandle & ~SET_MASK); float fScaleAsian = fScale; float fAsianYAdjust = 0.0f; @@ -1904,6 +1976,8 @@ void RE_Font_DrawString(int ox, int oy, const char *psText, const float *rgba, c { return; } + curfont = RE_Font_GetVariant(curfont, &fScale); + iFontHandle = curfont->GetHandle() | (iFontHandle & ~SET_MASK); float fScaleAsian = fScale; float fAsianYAdjust = 0.0f; @@ -2032,7 +2106,7 @@ void RE_Font_DrawString(int ox, int oy, const char *psText, const float *rgba, c #endif } -int RE_RegisterFont(const char *psName) +int RE_RegisterFont_Real(const char *psName) { FontIndexMap_t::iterator it = g_mapFontIndexes.find(psName); if (it != g_mapFontIndexes.end() ) @@ -2063,10 +2137,42 @@ int RE_RegisterFont(const char *psName) return 0; } +int RE_RegisterFont(const char *psName) { + int oriFontHandle = RE_RegisterFont_Real(psName); + if (oriFontHandle) { + CFontInfo *oriFont = GetFont_Actual(oriFontHandle); + + if (oriFont->GetNumVariants() == 0) { + for (int i = 0; i < MAX_FONT_VARIANTS; i++) { + const char *variantName = va( "%s_sharp%i", psName, i + 1 ); + const char *fontDatPath = FontDatPath( variantName ); + if ( ri.FS_ReadFile(fontDatPath, NULL) > 0 ) { + int replacerFontHandle = RE_RegisterFont_Real(variantName); + if (replacerFontHandle) { + CFontInfo *replacerFont = GetFont_Actual(replacerFontHandle); + replacerFont->m_isVariant = qtrue; + oriFont->AddVariant(replacerFont); + } else { + break; + } + } else { + break; + } + } + } + } else { + ri.Printf( PRINT_WARNING, "RE_RegisterFont: Couldn't find font %s\n", psName ); + } + + return oriFontHandle; +} + void R_InitFonts(void) { g_iCurrentFontIndex = 1; // entry 0 is reserved for "missing/invalid" g_iNonScaledCharRange = INT_MAX; // default all chars to have no special scaling (other than user supplied) + + r_fontSharpness = ri.Cvar_Get( "r_fontSharpness", "1", CVAR_ARCHIVE_ND ); } /* @@ -2119,6 +2225,8 @@ void R_ReloadFonts_f(void) for (; iFontToFind < g_iCurrentFontIndex; iFontToFind++) { FontIndexMap_t::iterator it = g_mapFontIndexes.begin(); + CFontInfo *font = GetFont( iFontToFind ); + if ( font && font->m_isVariant ) continue; for (; it != g_mapFontIndexes.end(); ++it) { if (iFontToFind == (*it).second) diff --git a/codemp/rd-common/tr_font.cpp b/codemp/rd-common/tr_font.cpp index 0e80477085..956e182f75 100644 --- a/codemp/rd-common/tr_font.cpp +++ b/codemp/rd-common/tr_font.cpp @@ -26,6 +26,8 @@ along with this program; if not, see . #include "qcommon/stringed_ingame.h" +cvar_t *r_fontSharpness; + ///////////////////////////////////////////////////////////////////////////////////////////////////////// // // This file is shared in the single and multiplayer codebases, so be CAREFUL WHAT YOU ADD/CHANGE!!!!! @@ -192,6 +194,8 @@ struct ThaiCodes_t #define GLYPH_MAX_THAI_SHADERS 3 #define GLYPH_MAX_ASIAN_SHADERS 4 // this MUST equal the larger of the above defines +#define MAX_FONT_VARIANTS 8 + class CFontInfo { private: @@ -226,6 +230,11 @@ class CFontInfo float m_fAltSBCSFontScaleFactor; // -1, else amount to adjust returned values by to make them fit the master western font they're substituting for bool m_bIsFakeAlienLanguage; // ... if true, don't process as MBCS or override as SBCS etc + CFontInfo *m_variants[MAX_FONT_VARIANTS]; + int m_numVariants; + int m_handle; + qboolean m_isVariant; + CFontInfo(const char *fontName); // CFontInfo(int fill) { memset(this, fill, sizeof(*this)); } // wtf? ~CFontInfo(void) {} @@ -246,6 +255,12 @@ class CFontInfo bool AsianGlyphsAvailable(void) const { return !!(m_hAsianShaders[0]); } void UpdateAsianIfNeeded( bool bForceReEval = false); + + int GetHandle(); + + void AddVariant(CFontInfo *variant); + int GetNumVariants(); + CFontInfo *GetVariant(int index); }; //================================================ @@ -844,6 +859,11 @@ qboolean Language_UsesSpaces(void) // If path present, it's a special language hack for SBCS override languages, eg: "lcd/russian", which means // just treat the file as "russian", but with the "lcd" part ensuring we don't find a different registered russian font // +static const char *FontDatPath( const char *_fontName ) { + static char fontName[MAX_QPATH]; + sprintf( fontName,"fonts/%s.fontdat",COM_SkipPath(const_cast(_fontName)) ); // COM_SkipPath should take a const char *, but it's just possible people use it as a char * I guess, so I have to hack around like this + return fontName; +} CFontInfo::CFontInfo(const char *_fontName) { int len, i; @@ -852,8 +872,7 @@ CFontInfo::CFontInfo(const char *_fontName) // remove any special hack name insertions... // - char fontName[MAX_QPATH]; - sprintf(fontName,"fonts/%s.fontdat",COM_SkipPath(const_cast(_fontName))); // COM_SkipPath should take a const char *, but it's just possible people use it as a char * I guess, so I have to hack around like this + const char *fontName = FontDatPath( _fontName ); // clear some general things... // @@ -919,6 +938,7 @@ CFontInfo::CFontInfo(const char *_fontName) // finished... g_vFontArray.resize(g_iCurrentFontIndex + 1); + m_handle = g_iCurrentFontIndex; g_vFontArray[g_iCurrentFontIndex++] = this; @@ -990,6 +1010,24 @@ CFontInfo::CFontInfo(const char *_fontName) } } } + + m_numVariants = 0; +} + +int CFontInfo::GetHandle() { + return m_handle; +} + +void CFontInfo::AddVariant(CFontInfo * replacer) { + m_variants[m_numVariants++] = replacer; +} + +int CFontInfo::GetNumVariants() { + return m_numVariants; +} + +CFontInfo *CFontInfo::GetVariant(int index) { + return m_variants[index]; } void CFontInfo::UpdateAsianIfNeeded( bool bForceReEval /* = false */ ) @@ -1123,6 +1161,30 @@ static CFontInfo *GetFont_Actual(int index) return(NULL); } +static CFontInfo *RE_Font_GetVariant(CFontInfo *font, float *scale) { + int variants = font->GetNumVariants(); + + if (variants > 0) { + CFontInfo *variant; + int requestedSize = font->GetPointSize() * *scale * + r_fontSharpness->value * (glConfig.vidHeight / SCREEN_HEIGHT); + + if (requestedSize <= font->GetPointSize()) + return font; + + for (int i = 0; i < variants; i++) { + variant = font->GetVariant(i); + + if (requestedSize <= variant->GetPointSize()) + break; + } + + *scale *= (float)font->GetPointSize() / variant->GetPointSize(); + return variant; + } + + return font; +} // needed to add *piShader param because of multiple TPs, // if not passed in, then I also skip S,T calculations for re-usable static asian glyphinfo struct... @@ -1355,11 +1417,13 @@ CFontInfo *GetFont(int index) return pFont; } -float RE_Font_StrLenPixelsNew( const char *psText, const int iFontHandle, const float fScale ) { +float RE_Font_StrLenPixelsNew( const char *psText, const int iFontHandle, const float fScaleIn ) { + float fScale = fScaleIn; CFontInfo *curfont = GetFont(iFontHandle); if ( !curfont ) { return 0.0f; } + curfont = RE_Font_GetVariant(curfont, &fScale); float fScaleAsian = fScale; if (Language_IsAsian() && fScale > 0.7f ) @@ -1454,14 +1518,17 @@ int RE_Font_StrLenChars(const char *psText) return iCharCount; } -int RE_Font_HeightPixels(const int iFontHandle, const float fScale) +int RE_Font_HeightPixels(const int iFontHandle, const float fScaleIn) { + float fScale = fScaleIn; CFontInfo *curfont; curfont = GetFont(iFontHandle); if(curfont) { - float fValue = curfont->GetPointSize() * fScale; + float fValue; + curfont = RE_Font_GetVariant(curfont, &fScale); + fValue = curfont->GetPointSize() * fScale; return curfont->mbRoundCalcs ? Round(fValue) : fValue; } return(0); @@ -1469,13 +1536,15 @@ int RE_Font_HeightPixels(const int iFontHandle, const float fScale) // iMaxPixelWidth is -1 for "all of string", else pixel display count... // -void RE_Font_DrawString(int ox, int oy, const char *psText, const float *rgba, const int iFontHandle, int iMaxPixelWidth, const float fScale) +void RE_Font_DrawString(int ox, int oy, const char *psText, const float *rgba, const int iFontHandleIn, int iMaxPixelWidth, const float fScaleIn) { static qboolean gbInShadow = qfalse; // MUST default to this float fox, foy, fx, fy; int colour, offset; const glyphInfo_t *pLetter; qhandle_t hShader; + float fScale = fScaleIn; + int iFontHandle = iFontHandleIn; assert (psText); @@ -1537,6 +1606,8 @@ void RE_Font_DrawString(int ox, int oy, const char *psText, const float *rgba, c { return; } + curfont = RE_Font_GetVariant(curfont, &fScale); + iFontHandle = curfont->GetHandle() | (iFontHandle & ~SET_MASK); float fScaleAsian = fScale; float fAsianYAdjust = 0.0f; @@ -1673,7 +1744,7 @@ void RE_Font_DrawString(int ox, int oy, const char *psText, const float *rgba, c //let it remember the old color //RE_SetColor(NULL); } -int RE_RegisterFont(const char *psName) +static int RE_RegisterFont_Real(const char *psName) { FontIndexMap_t::iterator it = g_mapFontIndexes.find(psName); if (it != g_mapFontIndexes.end() ) @@ -1702,10 +1773,42 @@ int RE_RegisterFont(const char *psName) return 0; } +int RE_RegisterFont(const char *psName) { + int oriFontHandle = RE_RegisterFont_Real(psName); + if (oriFontHandle) { + CFontInfo *oriFont = GetFont_Actual(oriFontHandle); + + if (oriFont->GetNumVariants() == 0) { + for (int i = 0; i < MAX_FONT_VARIANTS; i++) { + const char *variantName = va( "%s_sharp%i", psName, i + 1 ); + const char *fontDatPath = FontDatPath( variantName ); + if ( ri.FS_ReadFile(fontDatPath, NULL) > 0 ) { + int replacerFontHandle = RE_RegisterFont_Real(variantName); + if (replacerFontHandle) { + CFontInfo *replacerFont = GetFont_Actual(replacerFontHandle); + replacerFont->m_isVariant = qtrue; + oriFont->AddVariant(replacerFont); + } else { + break; + } + } else { + break; + } + } + } + } else { + ri.Printf( PRINT_WARNING, "RE_RegisterFont: Couldn't find font %s\n", psName ); + } + + return oriFontHandle; +} + void R_InitFonts(void) { g_iCurrentFontIndex = 1; // entry 0 is reserved for "missing/invalid" g_iNonScaledCharRange = INT_MAX; // default all chars to have no special scaling (other than user supplied) + + r_fontSharpness = ri.Cvar_Get( "r_fontSharpness", "1", CVAR_ARCHIVE_ND, "" ); } /* @@ -1754,6 +1857,8 @@ void R_ReloadFonts_f(void) for (iFontToFind = 1; iFontToFind < g_iCurrentFontIndex; iFontToFind++) { FontIndexMap_t::iterator it; + CFontInfo *font = GetFont( iFontToFind ); + if ( font && font->m_isVariant ) continue; for (it = g_mapFontIndexes.begin(); it != g_mapFontIndexes.end(); ++it) { if (iFontToFind == (*it).second) From 247fe8b8b4db0057e0f5f460a9dcfa6414995aae Mon Sep 17 00:00:00 2001 From: veosar <46798136+veosar@users.noreply.github.com> Date: Thu, 23 Nov 2023 00:31:28 +0100 Subject: [PATCH 775/801] Update Dockerfile (#1191) Fix dockerfile by not building Rend2 engine --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a63a4c6199..37614696e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ RUN mkdir /usr/src/openjk/build.i386 &&\ cmake -DCMAKE_TOOLCHAIN_FILE=/usr/src/openjk/cmake/Toolchains/linux-i686.cmake \ -DCMAKE_INSTALL_PREFIX=/opt \ -DBuildMPCGame=OFF -DBuildMPEngine=OFF -DBuildMPRdVanilla=OFF -DBuildMPUI=OFF \ - -DBuildSPEngine=OFF -DBuildSPGame=OFF -DBuildSPRdVanilla=OFF \ + -DBuildSPEngine=OFF -DBuildSPGame=OFF -DBuildSPRdVanilla=OFF -DBuildMPRend2=OFF \ .. &&\ make &&\ make install @@ -26,7 +26,7 @@ RUN mkdir /usr/src/openjk/build.x86_64 &&\ cd /usr/src/openjk/build.x86_64 &&\ cmake -DCMAKE_INSTALL_PREFIX=/opt \ -DBuildMPCGame=OFF -DBuildMPEngine=OFF -DBuildMPRdVanilla=OFF -DBuildMPUI=OFF \ - -DBuildSPEngine=OFF -DBuildSPGame=OFF -DBuildSPRdVanilla=OFF \ + -DBuildSPEngine=OFF -DBuildSPGame=OFF -DBuildSPRdVanilla=OFF -DBuildMPRend2=OFF \ .. &&\ make &&\ make install From 2ed26b3f638787f8c64b19e813f39fa65c66ad66 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Thu, 23 Nov 2023 00:32:10 +0100 Subject: [PATCH 776/801] Unix: copy path into a static variable to work on in Sys_Basename and Sys_Dirname. This prevents overwriting argv[0]. (#1183) --- shared/sys/sys_public.h | 4 ++-- shared/sys/sys_unix.cpp | 12 ++++++++---- shared/sys/sys_win32.cpp | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/shared/sys/sys_public.h b/shared/sys/sys_public.h index bad8218531..c93006a698 100644 --- a/shared/sys/sys_public.h +++ b/shared/sys/sys_public.h @@ -141,8 +141,8 @@ char *Sys_DefaultAppPath(void); #endif char *Sys_DefaultHomePath(void); -const char *Sys_Dirname( char *path ); -const char *Sys_Basename( char *path ); +const char *Sys_Dirname( const char *path ); +const char *Sys_Basename( const char *path ); bool Sys_PathCmp( const char *path1, const char *path2 ); diff --git a/shared/sys/sys_unix.cpp b/shared/sys/sys_unix.cpp index 96f5b7aab3..e3149819fc 100644 --- a/shared/sys/sys_unix.cpp +++ b/shared/sys/sys_unix.cpp @@ -164,9 +164,11 @@ qboolean Sys_LowPhysicalMemory( void ) Sys_Basename ================== */ -const char *Sys_Basename( char *path ) +const char *Sys_Basename( const char *path ) { - return basename( path ); + static char buf[ MAX_OSPATH ]; + Q_strncpyz( buf, path, sizeof(buf) ); + return basename( buf ); } /* @@ -174,9 +176,11 @@ const char *Sys_Basename( char *path ) Sys_Dirname ================== */ -const char *Sys_Dirname( char *path ) +const char *Sys_Dirname( const char *path ) { - return dirname( path ); + static char buf[ MAX_OSPATH ]; + Q_strncpyz( buf, path, sizeof(buf) ); + return dirname( buf ); } /* diff --git a/shared/sys/sys_win32.cpp b/shared/sys/sys_win32.cpp index 5b6c234cf5..4a8768130f 100644 --- a/shared/sys/sys_win32.cpp +++ b/shared/sys/sys_win32.cpp @@ -38,7 +38,7 @@ static UINT timerResolution = 0; Sys_Basename ============== */ -const char *Sys_Basename( char *path ) +const char *Sys_Basename( const char *path ) { static char base[ MAX_OSPATH ] = { 0 }; int length; @@ -68,7 +68,7 @@ const char *Sys_Basename( char *path ) Sys_Dirname ============== */ -const char *Sys_Dirname( char *path ) +const char *Sys_Dirname( const char *path ) { static char dir[ MAX_OSPATH ] = { 0 }; int length; From 718c31c241854e10d0cacbf0eb93aba282a8c418 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Tue, 28 Nov 2023 20:05:32 +0100 Subject: [PATCH 777/801] [MP] Skip downloads if the server has disabled sv_allowDownload. --- codemp/client/cl_main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index a1c7e47a9a..9908e7f71a 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -1537,10 +1537,15 @@ void CL_InitDownloads(void) { } } else if ( FS_ComparePaks( clc.downloadList, sizeof( clc.downloadList ) , qtrue ) ) { + const char *serverInfo = cl.gameState.stringData + cl.gameState.stringOffsets[ CS_SERVERINFO ]; + const char *serverAllowDownloads = Info_ValueForKey( serverInfo, "sv_allowDownload" ); Com_Printf("Need paks: %s\n", clc.downloadList ); - if ( *clc.downloadList ) { + if ( serverAllowDownloads[0] && !atoi(serverAllowDownloads) ) { + // The server has an "sv_allowDownload" value set, but it's 0 + Com_Printf("Skipping downloads, because the server does not allow downloads\n"); + } else if ( *clc.downloadList ) { // if autodownloading is not enabled on the server cls.state = CA_CONNECTED; From 4fabac9f2b194cc926c920a7724e5e3552b52bcd Mon Sep 17 00:00:00 2001 From: Daggolin Date: Tue, 28 Nov 2023 20:23:03 +0100 Subject: [PATCH 778/801] [MP] Install OpenJK modules to base for win32. Since com_unpackLibraries defaults to 0 the game is not going to unpack the default libraries from the assets anymore, thus the OpenJK ones should now be used as default. --- codemp/cgame/CMakeLists.txt | 14 ++++++-------- codemp/game/CMakeLists.txt | 14 ++++++-------- codemp/ui/CMakeLists.txt | 14 ++++++-------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/codemp/cgame/CMakeLists.txt b/codemp/cgame/CMakeLists.txt index 3bb751c74a..22d61b3643 100644 --- a/codemp/cgame/CMakeLists.txt +++ b/codemp/cgame/CMakeLists.txt @@ -160,14 +160,12 @@ elseif(WIN32) RUNTIME DESTINATION "${JKAInstallDir}/OpenJK" COMPONENT ${JKAMPCoreComponent}) - if (WIN64) - # Don't do this on 32-bit Windows to avoid overwriting - # vanilla JKA's DLLs - install(TARGETS ${MPCGame} - RUNTIME - DESTINATION "${JKAInstallDir}/base" - COMPONENT ${JKAMPCoreComponent}) - endif() + + # Use OpenJK modules as default + install(TARGETS ${MPCGame} + RUNTIME + DESTINATION "${JKAInstallDir}/base" + COMPONENT ${JKAMPCoreComponent}) else() install(TARGETS ${MPCGame} LIBRARY diff --git a/codemp/game/CMakeLists.txt b/codemp/game/CMakeLists.txt index c1d4ae39ba..a550f7243d 100644 --- a/codemp/game/CMakeLists.txt +++ b/codemp/game/CMakeLists.txt @@ -229,14 +229,12 @@ elseif(WIN32) RUNTIME DESTINATION "${JKAInstallDir}/OpenJK" COMPONENT ${JKAMPCoreComponent}) - if (WIN64) - # Don't do this on 32-bit Windows to avoid overwriting - # vanilla JKA's DLLs - install(TARGETS ${MPGame} - RUNTIME - DESTINATION "${JKAInstallDir}/base" - COMPONENT ${JKAMPCoreComponent}) - endif() + + # Use OpenJK modules as default + install(TARGETS ${MPGame} + RUNTIME + DESTINATION "${JKAInstallDir}/base" + COMPONENT ${JKAMPCoreComponent}) else() install(TARGETS ${MPGame} LIBRARY diff --git a/codemp/ui/CMakeLists.txt b/codemp/ui/CMakeLists.txt index f44d4fcf4e..224a6be34c 100644 --- a/codemp/ui/CMakeLists.txt +++ b/codemp/ui/CMakeLists.txt @@ -113,14 +113,12 @@ elseif(WIN32) RUNTIME DESTINATION "${JKAInstallDir}/OpenJK" COMPONENT ${JKAMPCoreComponent}) - if (WIN64) - # Don't do this on 32-bit Windows to avoid overwriting - # vanilla JKA's DLLs - install(TARGETS ${MPUI} - RUNTIME - DESTINATION "${JKAInstallDir}/base" - COMPONENT ${JKAMPCoreComponent}) - endif() + + # Use OpenJK modules as default + install(TARGETS ${MPUI} + RUNTIME + DESTINATION "${JKAInstallDir}/base" + COMPONENT ${JKAMPCoreComponent}) else() install(TARGETS ${MPUI} LIBRARY From 58ad339799e46a1ba2ee7b3218d6937f6582f29a Mon Sep 17 00:00:00 2001 From: Daggolin Date: Thu, 8 Feb 2024 11:41:29 +0100 Subject: [PATCH 779/801] A few small changes (cl_filterGames + MAX_PATCH_PLANES increase) (#1188) * [MP] Add cl_filterGames cvar to discard servers that use an fs_game matching one listed in the cvar (separated by spaces). * [MP] Use known MB2 (incompatible mod using the default serverlist) fs_game values as default for cl_filterGames to filter them out. * [Shared] Increase MAX_PATCH_PLANES from 2048 to 4096. Due to precision/rounding differences the vanilla engine on Windows, Linux and Mac effectively treated this limit different and the behavior for never consistent. For that reason jk2mv doubled the value back in 2015 and by now some maps require the limit to be increased. * [MP] Improve cl_filterGames. Skip cl_filterGames entry if it matches the current fs_game. Add support for filtering servers without fs_game set (BASEGAME). --- code/qcommon/cm_patch.h | 2 +- codemp/client/cl_main.cpp | 21 +++++++++++++++++++++ codemp/qcommon/cm_patch.h | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/code/qcommon/cm_patch.h b/code/qcommon/cm_patch.h index edef27597c..54ec6eda6a 100644 --- a/code/qcommon/cm_patch.h +++ b/code/qcommon/cm_patch.h @@ -62,7 +62,7 @@ properly. #define MAX_FACETS 1024 -#define MAX_PATCH_PLANES 2048 +#define MAX_PATCH_PLANES 4096 // Was 2048 on vanilla jka typedef struct { float plane[4]; diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index b5b07c6fa9..807783f8ec 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -105,6 +105,8 @@ cvar_t *cl_lanForcePackets; cvar_t *cl_drawRecording; +cvar_t *cl_filterGames; + vec3_t cl_windVec; @@ -2774,6 +2776,8 @@ void CL_Init( void ) { cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60 0xb2", CVAR_ARCHIVE, "Which keys are used to toggle the console"); cl_consoleUseScanCode = Cvar_Get( "cl_consoleUseScanCode", "1", CVAR_ARCHIVE, "Use native console key detection" ); + cl_filterGames = Cvar_Get( "cl_filterGames", "MBII MBIIOpenBeta", CVAR_ARCHIVE_ND, "List of fs_game to filter (space separated)" ); + // userinfo Cvar_Get ("name", "Padawan", CVAR_USERINFO | CVAR_ARCHIVE_ND, "Player name" ); Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE, "Data rate" ); @@ -2991,6 +2995,23 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { return; } + if ( cl_filterGames && cl_filterGames->string && cl_filterGames->string[0] ) { + const char *gameFolder = Info_ValueForKey( infoString, "game" ); + + // If no game folder was specified the server is using base. Use the BASEGAME string so we can filter for it. + if ( !gameFolder[0] ) gameFolder = BASEGAME; + + // NOTE: As the command tokenization doesn't support nested quotes we can't filter fs_game with spaces using + // this approach, but fs_game with spaces cause other issues as well, like downloads not working and at + // the time of writing this no public servers actually use an fs_game with spaces... + Cmd_TokenizeString( cl_filterGames->string ); + for ( i = 0; i < Cmd_Argc(); i++ ) { + if ( !Q_stricmp(Cmd_Argv(i), gameFolder) && Q_stricmp(Cmd_Argv(i), FS_GetCurrentGameDir(false)) ) { + return; + } + } + } + // iterate servers waiting for ping response for (i=0; i Date: Fri, 9 Feb 2024 11:55:51 +1100 Subject: [PATCH 780/801] replace PATCH_STITCHING preprocessor define with r_patchStitching cvar (#1199) --- codemp/rd-dedicated/tr_init.cpp | 5 ++ codemp/rd-dedicated/tr_local.h | 7 +-- codemp/rd-rend2/tr_bsp.cpp | 86 ++++++++++++++++---------------- codemp/rd-rend2/tr_curve.cpp | 22 +-------- codemp/rd-rend2/tr_init.cpp | 88 +++++++++++++++++---------------- codemp/rd-rend2/tr_local.h | 44 ++++++++--------- codemp/rd-vanilla/tr_bsp.cpp | 12 ++--- codemp/rd-vanilla/tr_curve.cpp | 11 ----- codemp/rd-vanilla/tr_init.cpp | 4 ++ codemp/rd-vanilla/tr_local.h | 5 +- 10 files changed, 135 insertions(+), 149 deletions(-) diff --git a/codemp/rd-dedicated/tr_init.cpp b/codemp/rd-dedicated/tr_init.cpp index fe48457a87..794c307989 100644 --- a/codemp/rd-dedicated/tr_init.cpp +++ b/codemp/rd-dedicated/tr_init.cpp @@ -212,6 +212,8 @@ Ghoul2 Insert End cvar_t *r_aviMotionJpegQuality; cvar_t *r_screenshotJpegQuality; +cvar_t *r_patchStitching; + /* ** R_GetModeInfo */ @@ -453,6 +455,9 @@ Ghoul2 Insert Start /* Ghoul2 Insert End */ + + r_patchStitching = ri.Cvar_Get("r_patchStitching", "1", CVAR_ARCHIVE, "Enable stitching of neighbouring patch surfaces" ); + r_modelpoolmegs = ri.Cvar_Get("r_modelpoolmegs", "20", CVAR_ARCHIVE, "" ); if (ri.Sys_LowPhysicalMemory() ) ri.Cvar_Set("r_modelpoolmegs", "0"); diff --git a/codemp/rd-dedicated/tr_local.h b/codemp/rd-dedicated/tr_local.h index aa558b35da..8915ac5b57 100644 --- a/codemp/rd-dedicated/tr_local.h +++ b/codemp/rd-dedicated/tr_local.h @@ -860,7 +860,7 @@ 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 @@ -1265,6 +1265,9 @@ extern cvar_t *r_noServerGhoul2; /* Ghoul2 Insert End */ + +extern cvar_t *r_patchStitching; + //==================================================================== float R_NoiseGet4f( float x, float y, float z, float t ); @@ -1572,8 +1575,6 @@ CURVE TESSELATION ============================================================ */ -#define PATCH_STITCHING - srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, drawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a573fe316c..172174d318 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -114,7 +114,7 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) { 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; @@ -242,7 +242,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { // we are about to upload textures R_IssuePendingRenderCommands(); - + // check for deluxe mapping if (numLightmaps <= 1) { @@ -376,7 +376,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { R_LoadImage(filename, &externalLightmap, &lightmapWidth, &lightmapHeight); } } - + if (externalLightmap) { int newImageSize = lightmapWidth * lightmapHeight * 4 * 2; @@ -451,7 +451,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { else if (buf_p && hdr_capable) { 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); @@ -734,7 +734,7 @@ static int FatLightmap(int lightmapnum) if (tr.lightmapAtlasSize[0] > 0) return 0; - + return lightmapnum; } @@ -2174,8 +2174,8 @@ static void R_CreateWorldVBOs( world_t *worldData ) 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; @@ -2319,7 +2319,7 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu if ( indexLump->filelen % sizeof(*indexes)) 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; @@ -2427,17 +2427,17 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu ri.FS_FreeFile(hdrVertColors); } -#ifdef PATCH_STITCHING - R_StitchAllPatches(worldData); -#endif + if ( r_patchStitching->integer ) { + R_StitchAllPatches(worldData); + } R_FixSharedVertexLodError(worldData); -#ifdef PATCH_STITCHING - R_MovePatchSurfacesToHunk(worldData); -#endif + if ( r_patchStitching->integer ) { + R_MovePatchSurfacesToHunk(worldData); + } - 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 ); } @@ -2538,7 +2538,7 @@ static void R_LoadNodesAndLeafs (world_t *worldData, lump_t *nodeLump, lump_t *l 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; @@ -2552,7 +2552,7 @@ static void R_LoadNodesAndLeafs (world_t *worldData, lump_t *nodeLump, lump_t *l out->mins[j] = LittleLong (in->mins[j]); out->maxs[j] = LittleLong (in->maxs[j]); } - + p = LittleLong(in->planeNum); out->plane = worldData->planes + p; @@ -2567,7 +2567,7 @@ static void R_LoadNodesAndLeafs (world_t *worldData, lump_t *nodeLump, lump_t *l out->children[j] = worldData->nodes + numNodes + (-1 - p); } } - + // load leafs inLeaf = (dleaf_t *)(fileBase + leafLump->fileofs); for ( i=0 ; ifirstmarksurface = LittleLong(inLeaf->firstLeafSurface); out->nummarksurfaces = LittleLong(inLeaf->numLeafSurfaces); - } + } // chain decendants R_SetParent (worldData->nodes, NULL); @@ -2600,10 +2600,10 @@ static void R_LoadNodesAndLeafs (world_t *worldData, lump_t *nodeLump, lump_t *l R_LoadShaders ================= */ -static void R_LoadShaders( world_t *worldData, 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",worldData->name); @@ -2628,16 +2628,16 @@ R_LoadMarksurfaces ================= */ static void R_LoadMarksurfaces (world_t *worldData, lump_t *l) -{ +{ int i, j, count; int *in; int *out; - + in = (int *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) 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; @@ -2661,13 +2661,13 @@ static void R_LoadPlanes( world_t *worldData, lump_t *l ) { dplane_t *in; int count; int bits; - + in = (dplane_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) 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; @@ -2797,8 +2797,8 @@ static void R_LoadFogs( world_t *worldData, lump_t *l, lump_t *brushesLump, lump out->parms = shader->fogParms; VectorSet4(out->color, - shader->fogParms.color[0] * tr.identityLight, - shader->fogParms.color[1] * tr.identityLight, + shader->fogParms.color[0] * tr.identityLight, + shader->fogParms.color[1] * tr.identityLight, shader->fogParms.color[2] * tr.identityLight, 1.0); @@ -2851,7 +2851,7 @@ void R_LoadLightGrid( world_t *worldData, lump_t *l ) { Com_Memcpy( worldData->lightGridData, (void *)(fileBase + l->fileofs), l->filelen ); // deal with overbright bits - for ( i = 0 ; i < numGridDataElements ; i++ ) + for ( i = 0 ; i < numGridDataElements ; i++ ) { for(int j = 0; j < MAXLIGHTMAPS; j++) { @@ -2954,7 +2954,7 @@ void R_LoadEntities( world_t *worldData, lump_t *l ) { } // only parse the world spawn - while ( 1 ) { + while ( 1 ) { // parse key token = COM_ParseExt( &p, qtrue ); @@ -3064,7 +3064,7 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int } // go through all the key / value pairs - while ( 1 ) { + while ( 1 ) { int keyLength, tokenLength; // parse key @@ -3077,7 +3077,7 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int break; } - // parse value + // parse value if ( !R_GetEntityToken( com_token, sizeof( com_token ) ) ) { ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); return qfalse; @@ -3301,7 +3301,7 @@ static void R_RenderAllCubemaps() { cubemapFormat = GL_RGBA16F; } - + for (int k = 0; k <= r_cubeMappingBounces->integer; k++) { bool bounce = k != 0; @@ -3462,7 +3462,7 @@ static void R_MergeLeafSurfaces(world_t *worldData) if (worldData->surfacesViewCount[surfNum2] != -1) continue; - + surf2 = worldData->surfaces + surfNum2; if ((*surf2->data != SF_GRID) && @@ -3512,7 +3512,7 @@ static void R_MergeLeafSurfaces(world_t *worldData) if (!merges) worldData->surfacesViewCount[i] = -1; - } + } // count merged/unmerged surfaces numMergedSurfaces = 0; @@ -3543,7 +3543,7 @@ static void R_MergeLeafSurfaces(world_t *worldData) (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 = @@ -3707,7 +3707,7 @@ static void R_MergeLeafSurfaces(world_t *worldData) 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 @@ -4147,8 +4147,8 @@ static void R_GenerateSurfaceSprites( const world_t *world, int worldIndex ) { VBO_t *vbo = R_CreateVBO((byte *)sprites_data.data(), sizeof(sprite_t) * sprites_data.size(), VBO_USAGE_STATIC); - - for (srfSprites_t *sp : currentBatch) + + for (srfSprites_t *sp : currentBatch) { sp->vbo = vbo; sp->ibo = ibo; @@ -4249,7 +4249,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) { ri.Error( ERR_DROP, - "R_LoadBSP: %s has wrong version number (%i should be %i)", + "R_LoadBSP: %s has wrong version number (%i should be %i)", name, bspVersion, BSP_VERSION); @@ -4296,7 +4296,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) &header->lumps[LUMP_BRUSHSIDES]); R_GenerateSurfaceSprites(worldData, worldIndex + 1); - + // load cubemaps if (r_cubeMapping->integer && bspIndex == nullptr) { @@ -4321,7 +4321,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) if (tr.numCubemaps) break; } - + } if (tr.numCubemaps) diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index bdb8494242..90c24c4950 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -347,7 +347,7 @@ static void InvertErrorTable( float errorTable[2][MAX_GRID_SIZE], int width, int PutPointsOnCurve ================== */ -static void PutPointsOnCurve( srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], +static void PutPointsOnCurve( srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], int width, int height ) { int i, j; srfVert_t prev, next; @@ -386,7 +386,6 @@ srfBspSurface_t *R_CreateSurfaceGridMesh(int width, int height, // copy the results out to a grid size = (width * height - 1) * sizeof( srfVert_t ) + sizeof( *grid ); -#ifdef PATCH_STITCHING grid = /*ri.Hunk_Alloc*/ (srfBspSurface_t *)Z_Malloc( size, TAG_GRIDMESH ); Com_Memset(grid, 0, size); @@ -402,23 +401,6 @@ 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 ); - 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->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); -#endif grid->width = width; grid->height = height; @@ -476,7 +458,7 @@ 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)); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 490eda6664..183fbcae90 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -273,6 +273,8 @@ cvar_t *r_debugWeather; cvar_t *r_aspectCorrectFonts; +cvar_t *r_patchStitching; + extern void RB_SetGL2D (void); static void R_Splash() { @@ -624,8 +626,8 @@ we use statics to store a count and start writing the first screenshot/screensho (with FS_FileExists / FS_FOpenFileWrite calls) FIXME: the statics don't get a reinit between fs_game changes -============================================================================== -*/ +============================================================================== +*/ /* ================== @@ -682,10 +684,10 @@ static void ConvertRGBtoBGR( *dst++ = pixelRGB[2]; *dst++ = pixelRGB[1]; *dst++ = temp; - + pixelRGB += 3; } - + row += stride; } } @@ -718,11 +720,11 @@ static void R_SaveTGA( ri.Hunk_FreeTempMemory(buffer); } -/* -================== +/* +================== R_SaveScreenshotTGA -================== -*/ +================== +*/ static void R_SaveScreenshotTGA( const screenshotReadback_t *screenshotReadback, byte *pixels) { @@ -735,9 +737,9 @@ static void R_SaveScreenshotTGA( } /* -================== +================== R_SaveScreenshotPNG -================== +================== */ static void R_SaveScreenshotPNG( const screenshotReadback_t *screenshotReadback, byte *pixels) @@ -822,7 +824,7 @@ R_TakeScreenshotCmd */ const void *RB_TakeScreenshotCmd( const void *data ) { const screenshotCommand_t *cmd; - + cmd = (const screenshotCommand_t *)data; // finish any 2D drawing if needed @@ -832,13 +834,13 @@ const void *RB_TakeScreenshotCmd( const void *data ) { 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( @@ -856,8 +858,8 @@ const void *RB_TakeScreenshotCmd( const void *data ) { screenshot->format = cmd->format; Q_strncpyz( screenshot->filename, cmd->fileName, sizeof(screenshot->filename)); - - return (const void *)(cmd + 1); + + return (const void *)(cmd + 1); } /* @@ -884,11 +886,11 @@ void R_TakeScreenshot( int x, int y, int width, int height, char *name, screensh cmd->format = format; } -/* -================== +/* +================== R_ScreenshotFilename -================== -*/ +================== +*/ void R_ScreenshotFilename( char *buf, int bufSize, const char *ext ) { time_t rawtime; char timeStr[32] = {0}; // should really only reach ~19 chars @@ -968,8 +970,8 @@ static void R_LevelShot( void ) { ri.Printf( PRINT_ALL, "Wrote %s\n", checkname ); } -/* -================== +/* +================== R_ScreenShotTGA_f screenshot @@ -978,8 +980,8 @@ screenshot [levelshot] screenshot [filename] Doesn't print the pacifier message if there is a second arg -================== -*/ +================== +*/ void R_ScreenShotTGA_f (void) { char checkname[MAX_OSPATH] = {0}; qboolean silent = qfalse; @@ -1001,7 +1003,7 @@ void R_ScreenShotTGA_f (void) { R_ScreenshotFilename( checkname, sizeof( checkname ), ".tga" ); if ( ri.FS_FileExists( checkname ) ) { - Com_Printf( "ScreenShot: Couldn't create a file\n"); + Com_Printf( "ScreenShot: Couldn't create a file\n"); return; } } @@ -1033,7 +1035,7 @@ void R_ScreenShotPNG_f (void) { R_ScreenshotFilename( checkname, sizeof( checkname ), ".png" ); if ( ri.FS_FileExists( checkname ) ) { - Com_Printf( "ScreenShot: Couldn't create a file\n"); + Com_Printf( "ScreenShot: Couldn't create a file\n"); return; } } @@ -1065,7 +1067,7 @@ void R_ScreenShotJPEG_f (void) { R_ScreenshotFilename( checkname, sizeof( checkname ), ".jpg" ); if ( ri.FS_FileExists( checkname ) ) { - Com_Printf( "ScreenShot: Couldn't create a file\n"); + Com_Printf( "ScreenShot: Couldn't create a file\n"); return; } } @@ -1096,7 +1098,7 @@ const void *RB_TakeVideoFrameCmd( const void *data ) RB_EndSurface(); cmd = (const videoFrameCommand_t *)data; - + qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); linelen = cmd->width * 3; @@ -1109,7 +1111,7 @@ const void *RB_TakeVideoFrameCmd( const void *data ) avipadlen = avipadwidth - linelen; cBuf = (byte*)(PADP(cmd->captureBuffer, packAlign)); - + qglReadPixels(0, 0, cmd->width, cmd->height, GL_RGB, GL_UNSIGNED_BYTE, cBuf); @@ -1130,11 +1132,11 @@ const void *RB_TakeVideoFrameCmd( const void *data ) { 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) { @@ -1146,17 +1148,17 @@ const void *RB_TakeVideoFrameCmd( const void *data ) *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); + return (const void *)(cmd + 1); } //============================================================================ @@ -1240,7 +1242,7 @@ void R_PrintLongString(const char *string) { GfxInfo_f ================ */ -static void GfxInfo_f( void ) +static void GfxInfo_f( void ) { const char *enablestrings[] = { @@ -1316,7 +1318,7 @@ static void GfxInfo_f( void ) GfxMemInfo_f ================ */ -void GfxMemInfo_f( void ) +void GfxMemInfo_f( void ) { switch (glRefConfig.memInfo) { @@ -1418,7 +1420,7 @@ static const size_t numCommands = ARRAY_LEN( commands ); R_Register =============== */ -void R_Register( void ) +void R_Register( void ) { // // latched and archived variables @@ -1499,7 +1501,7 @@ void R_Register( void ) 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_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_imageUpsample = ri.Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); @@ -1643,6 +1645,8 @@ Ghoul2 Insert Start Ghoul2 Insert End */ + r_patchStitching = ri.Cvar_Get("r_patchStitching", "1", CVAR_ARCHIVE, "Enable stitching of neighbouring patch surfaces" ); + se_language = ri.Cvar_Get ( "se_language", "english", CVAR_ARCHIVE | CVAR_NORESTART, "" ); for ( size_t i = 0; i < numCommands; i++ ) @@ -1905,14 +1909,14 @@ R_Init void R_Init( void ) { byte *ptr; int i; - + 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 ) ); - + // // init function tables @@ -2181,7 +2185,7 @@ Q_EXPORT refexport_t* QDECL 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_local.h b/codemp/rd-rend2/tr_local.h index 52e53503c1..f03215cd0f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -286,6 +286,8 @@ extern cvar_t *broadsword_dircap; Ghoul2 Insert End */ +extern cvar_t *r_patchStitching; + /* End Cvars */ @@ -497,8 +499,8 @@ typedef enum { GF_SIN, GF_SQUARE, GF_TRIANGLE, - GF_SAWTOOTH, - GF_INVERSE_SAWTOOTH, + GF_SAWTOOTH, + GF_INVERSE_SAWTOOTH, GF_NOISE, GF_RAND @@ -853,7 +855,7 @@ typedef enum ST_GLSL } stageType_t; -typedef enum +typedef enum { SPEC_NONE, // no specular found SPEC_SPECGLOSS, // Specular Gloss @@ -889,7 +891,7 @@ typedef struct { qboolean cloth; AlphaTestType alphaTestType; - + textureBundle_t bundle[NUM_TEXTURE_BUNDLES]; waveForm_t rgbWave; @@ -975,7 +977,7 @@ typedef struct shader_s { qboolean isPortal; 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 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) @@ -991,8 +993,8 @@ typedef struct shader_s { int numSurfaceSpriteStages; GLuint spriteUbo; int ShaderInstanceUboOffset; - - shaderStage_t *stages[MAX_SHADER_STAGES]; + + shaderStage_t *stages[MAX_SHADER_STAGES]; void (*optimalStageIteratorFunc)( void ); qboolean isHDRLit; @@ -1159,7 +1161,7 @@ enum ATTR_BONE_WEIGHTS | ATTR_POSITION2 #ifdef REND2_SP - | + | ATTR_TANGENT2 | ATTR_NORMAL2 #endif // REND2_SP @@ -1180,7 +1182,7 @@ enum #else GENERICDEF_ALL = 0x007F, #endif // REND2_SP - + GENERICDEF_COUNT = GENERICDEF_ALL + 1, }; @@ -1242,7 +1244,7 @@ enum #else LIGHTDEF_ALL = 0x01FF, #endif // REND2_SP - + LIGHTDEF_COUNT = LIGHTDEF_ALL + 1 }; @@ -1757,7 +1759,7 @@ typedef struct srfBspSurface_s // static render data VBO_t *vbo; IBO_t *ibo; - + // SF_GRID specific variables after here // lod information, which may be different @@ -1850,7 +1852,7 @@ SHADOWS typedef struct pshadow_s { float sort; - + int numEntities; int entityNums[8]; vec3_t entityOrigins[8]; @@ -1919,7 +1921,7 @@ typedef struct mnode_s { // node specific cplane_t *plane; - struct mnode_s *children[2]; + struct mnode_s *children[2]; // leaf specific int cluster; @@ -1936,7 +1938,7 @@ typedef struct { int numSurfaces; } bmodel_t; -typedef struct +typedef struct { byte ambientLight[MAXLIGHTMAPS][3]; byte directLight[MAXLIGHTMAPS][3]; @@ -2161,7 +2163,7 @@ typedef struct model_s { void R_ModelInit (void); model_t *R_GetModelByHandle( qhandle_t hModel ); -int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, +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 ); @@ -2315,7 +2317,7 @@ 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; @@ -2369,7 +2371,7 @@ typedef struct { } backEndState_t; /* -** trGlobals_t +** trGlobals_t ** ** Most renderer globals are defined here. ** backend functions should never modify any of these fields, @@ -2539,7 +2541,7 @@ typedef struct trGlobals_s { 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; @@ -2846,7 +2848,7 @@ void R_AddPolygonSurfaces( const trRefdef_t *refdef ); 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, +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 ); @@ -3006,7 +3008,7 @@ typedef struct stageVars #define MAX_MULTIDRAW_PRIMITIVES 16384 const int NUM_TESS_TEXCOORDS = 1 + MAXLIGHTMAPS; -struct shaderCommands_s +struct shaderCommands_s { glIndex_t indexes[SHADER_MAX_INDEXES] QALIGN(16); vec4_t xyz[SHADER_MAX_VERTEXES] QALIGN(16); @@ -3151,8 +3153,6 @@ CURVE TESSELATION ============================================================ */ -#define PATCH_STITCHING - srfBspSurface_t *R_SubdividePatchToGrid( int width, int height, srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ); srfBspSurface_t *R_GridInsertColumn( srfBspSurface_t *grid, int column, int row, vec3_t point, float loderror ); diff --git a/codemp/rd-vanilla/tr_bsp.cpp b/codemp/rd-vanilla/tr_bsp.cpp index 7ce2e82eec..ecc3df602f 100644 --- a/codemp/rd-vanilla/tr_bsp.cpp +++ b/codemp/rd-vanilla/tr_bsp.cpp @@ -1391,15 +1391,15 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump, wor } } -#ifdef PATCH_STITCHING - R_StitchAllPatches(worldData); -#endif + if ( r_patchStitching->integer ) { + R_StitchAllPatches(worldData); + } R_FixSharedVertexLodError(worldData); -#ifdef PATCH_STITCHING - R_MovePatchSurfacesToHunk(worldData); -#endif + if ( r_patchStitching->integer ) { + R_MovePatchSurfacesToHunk(worldData); + } ri.Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", numFaces, numMeshes, numTriSurfs, numFlares ); } diff --git a/codemp/rd-vanilla/tr_curve.cpp b/codemp/rd-vanilla/tr_curve.cpp index bc67911d0d..e3d75834f1 100644 --- a/codemp/rd-vanilla/tr_curve.cpp +++ b/codemp/rd-vanilla/tr_curve.cpp @@ -306,7 +306,6 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, // copy the results out to a grid size = (width * height - 1) * sizeof( drawVert_t ) + sizeof( *grid ); -#ifdef PATCH_STITCHING grid = (struct srfGridMesh_s *)/*Hunk_Alloc*/ Z_Malloc( size, TAG_GRIDMESH, qfalse ); memset(grid, 0, size); @@ -315,16 +314,6 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, grid->heightLodError = (float *)/*Hunk_Alloc*/ Z_Malloc( height * 4, TAG_GRIDMESH, qfalse ); memcpy( grid->heightLodError, errorTable[1], height * 4 ); -#else - grid = Hunk_Alloc( size ); - memset(grid, 0, size); - - grid->widthLodError = Hunk_Alloc( width * 4 ); - memcpy( grid->widthLodError, errorTable[0], width * 4 ); - - grid->heightLodError = Hunk_Alloc( height * 4 ); - memcpy( grid->heightLodError, errorTable[1], height * 4 ); -#endif grid->width = width; grid->height = height; diff --git a/codemp/rd-vanilla/tr_init.cpp b/codemp/rd-vanilla/tr_init.cpp index 847bae6257..ef4944ab0c 100644 --- a/codemp/rd-vanilla/tr_init.cpp +++ b/codemp/rd-vanilla/tr_init.cpp @@ -216,6 +216,8 @@ cvar_t *se_language; cvar_t *r_aviMotionJpegQuality; cvar_t *r_screenshotJpegQuality; +cvar_t *r_patchStitching; + #if !defined(__APPLE__) PFNGLSTENCILOPSEPARATEPROC qglStencilOpSeparate; #endif @@ -1705,6 +1707,8 @@ Ghoul2 Insert End ri.Cvar_CheckRange( r_aviMotionJpegQuality, 10, 100, qtrue ); ri.Cvar_CheckRange( r_screenshotJpegQuality, 10, 100, qtrue ); + r_patchStitching = ri.Cvar_Get("r_patchStitching", "1", CVAR_ARCHIVE, "Enable stitching of neighbouring patch surfaces" ); + for ( size_t i = 0; i < numCommands; i++ ) ri.Cmd_AddCommand( commands[i].cmd, commands[i].func, "" ); } diff --git a/codemp/rd-vanilla/tr_local.h b/codemp/rd-vanilla/tr_local.h index 6f9504d682..dcef60d901 100644 --- a/codemp/rd-vanilla/tr_local.h +++ b/codemp/rd-vanilla/tr_local.h @@ -1273,6 +1273,9 @@ extern cvar_t *r_noServerGhoul2; /* Ghoul2 Insert End */ + +extern cvar_t *r_patchStitching; + //==================================================================== void R_SwapBuffers( int ); @@ -1596,8 +1599,6 @@ CURVE TESSELATION ============================================================ */ -#define PATCH_STITCHING - srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, drawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ); From 2d618a5ca6dbe7c88ffaa29523665fb18cb23bf5 Mon Sep 17 00:00:00 2001 From: razor Date: Mon, 19 Feb 2024 14:49:43 +1100 Subject: [PATCH 781/801] render local entities as late as possible (#1200) this should defer an overflow of refents occurring that would result in e.g. map models disappearing (light poles on mp/ffa5) localents are a lower priority, we can afford to miss out on force push/grip effects in these cases --- code/cgame/cg_view.cpp | 5 +- codeJK2/cgame/cg_view.cpp | 143 +++++++++++++++++++------------------- codemp/cgame/cg_view.c | 6 +- 3 files changed, 82 insertions(+), 72 deletions(-) diff --git a/code/cgame/cg_view.cpp b/code/cgame/cg_view.cpp index 01cb293e07..7b8b2a9d4f 100644 --- a/code/cgame/cg_view.cpp +++ b/code/cgame/cg_view.cpp @@ -2141,7 +2141,6 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) { if ( !cg.hyperspace ) { CG_AddPacketEntities(qfalse); // adter calcViewValues, so predicted player state is correct CG_AddMarks(); - CG_AddLocalEntities(); CG_DrawMiscEnts(); } @@ -2211,6 +2210,10 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) { CG_AddTestModel(); } + if ( !cg.hyperspace ) { + CG_AddLocalEntities(); + } + memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) ); // update audio positions diff --git a/codeJK2/cgame/cg_view.cpp b/codeJK2/cgame/cg_view.cpp index e3dcdd650d..ec09ba7f98 100644 --- a/codeJK2/cgame/cg_view.cpp +++ b/codeJK2/cgame/cg_view.cpp @@ -49,7 +49,7 @@ enhanced into a single model testing facility. Model viewing can begin with either "testmodel " or "testgun ". -The names must be the full pathname after the basedir, like +The names must be the full pathname after the basedir, like "models/weapons/v_launch/tris.md3" or "players/male/tris.md3" Testmodel will create a fake entity 100 units in front of the current view @@ -134,7 +134,7 @@ void CG_ListModelSurfaces_f (void) void CG_ListModelBones_f (void) { // test to see if we got enough args - if ( cgi_Argc() < 2 ) + if ( cgi_Argc() < 2 ) { return; } @@ -146,7 +146,7 @@ void CG_ListModelBones_f (void) void CG_TestModelSurfaceOnOff_f(void) { // test to see if we got enough args - if ( cgi_Argc() < 3 ) + if ( cgi_Argc() < 3 ) { return; } @@ -159,14 +159,14 @@ void CG_TestModelSetAnglespre_f(void) { vec3_t angles; - if ( cgi_Argc() < 3 ) + if ( cgi_Argc() < 3 ) { return; } CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2); - angles[0] = atof(CG_Argv(2)); - angles[1] = atof(CG_Argv(3)); + angles[0] = atof(CG_Argv(2)); + angles[1] = atof(CG_Argv(3)); angles[2] = atof(CG_Argv(4)); gi.G2API_SetBoneAngles(&ghoul2[cg.testModel], CG_Argv(1), angles, BONE_ANGLES_PREMULT, POSITIVE_X, POSITIVE_Z, POSITIVE_Y, NULL, 0, 0); } @@ -175,14 +175,14 @@ void CG_TestModelSetAnglespost_f(void) { vec3_t angles; - if ( cgi_Argc() < 3 ) + if ( cgi_Argc() < 3 ) { return; } CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)cg.testModelEntity.ghoul2); - angles[0] = atof(CG_Argv(2)); - angles[1] = atof(CG_Argv(3)); + angles[0] = atof(CG_Argv(2)); + angles[1] = atof(CG_Argv(3)); angles[2] = atof(CG_Argv(4)); gi.G2API_SetBoneAngles(&ghoul2[cg.testModel], CG_Argv(1), angles, BONE_ANGLES_POSTMULT, POSITIVE_X, POSITIVE_Z, POSITIVE_Y, NULL, 0, 0); } @@ -284,7 +284,7 @@ void CG_TestModelPrevSkin_f (void) { static void CG_AddTestModel (void) { int i; - // re-register the model, because the level may have changed + // re-register the model, because the level may have changed /* cg.testModelEntity.hModel = cgi_R_RegisterModel( cg.testModelName ); if (! cg.testModelEntity.hModel ) { CG_Printf ("Can't register model\n"); @@ -366,7 +366,7 @@ cg.refdefViewAngles =============== */ - + /* =============== CG_CalcIdealThirdPersonViewTarget @@ -438,7 +438,7 @@ static void CG_CalcIdealThirdPersonViewTarget(void) } } - + /* =============== @@ -544,7 +544,7 @@ static void CG_UpdateThirdPersonTargetDamp(void) VectorCopy(cameraIdealTarget, cameraCurTarget); } else if (cg_thirdPersonTargetDamp.value>=0.0) - { + { // Calculate the difference from the current position to the new one. VectorSubtract(cameraIdealTarget, cameraCurTarget, targetdiff); @@ -553,10 +553,10 @@ static void CG_UpdateThirdPersonTargetDamp(void) dampfactor = 1.0-cg_thirdPersonTargetDamp.value; // We must exponent the amount LEFT rather than the amount bled off dtime = (float)(cg.time-cameraLastFrame) * (1.0/cg_timescale.value) * (1.0/(float)CAMERA_DAMP_INTERVAL); // Our dampfactor is geared towards a time interval equal to "1". - // Note that since there are a finite number of "practical" delta millisecond values possible, + // Note that since there are a finite number of "practical" delta millisecond values possible, // the ratio should be initialized into a chart ultimately. ratio = pow(dampfactor, dtime); - + // This value is how much distance is "left" from the ideal. VectorMA(cameraIdealTarget, -ratio, targetdiff, cameraCurTarget); ///////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -587,8 +587,8 @@ static void CG_UpdateThirdPersonCameraDamp(void) // Set the cameraIdealLoc CG_CalcIdealThirdPersonViewLocation(); - - + + // First thing we do is calculate the appropriate damping factor for the camera. dampfactor=0.0f; if ( CG_OnMovingPlat( &cg.snap->ps ) ) @@ -605,7 +605,7 @@ static void CG_UpdateThirdPersonCameraDamp(void) pitch = Q_fabs(cameraFocusAngles[PITCH]); // The higher the pitch, the larger the factor, so as you look up, it damps a lot less. - pitch /= 89.0; + pitch /= 89.0; dampfactor = (1.0-cg.overrides.thirdPersonCameraDamp)*(pitch*pitch); dampfactor += cg.overrides.thirdPersonCameraDamp; @@ -619,7 +619,7 @@ static void CG_UpdateThirdPersonCameraDamp(void) pitch = Q_fabs(cameraFocusAngles[PITCH]); // The higher the pitch, the larger the factor, so as you look up, it damps a lot less. - pitch /= 89.0; + pitch /= 89.0; dampfactor = (1.0-cg_thirdPersonCameraDamp.value)*(pitch*pitch); dampfactor += cg_thirdPersonCameraDamp.value; @@ -636,7 +636,7 @@ static void CG_UpdateThirdPersonCameraDamp(void) VectorCopy(cameraIdealLoc, cameraCurLoc); } else if (dampfactor>=0.0) - { + { // Calculate the difference from the current position to the new one. VectorSubtract(cameraIdealLoc, cameraCurLoc, locdiff); @@ -645,10 +645,10 @@ static void CG_UpdateThirdPersonCameraDamp(void) dampfactor = 1.0-dampfactor; // We must exponent the amount LEFT rather than the amount bled off dtime = (float)(cg.time-cameraLastFrame) * (1.0/cg_timescale.value) * (1.0/(float)CAMERA_DAMP_INTERVAL); // Our dampfactor is geared towards a time interval equal to "1". - // Note that since there are a finite number of "practical" delta millisecond values possible, + // Note that since there are a finite number of "practical" delta millisecond values possible, // the ratio should be initialized into a chart ultimately. ratio = pow(dampfactor, dtime); - + // This value is how much distance is "left" from the ideal. VectorMA(cameraIdealLoc, -ratio, locdiff, cameraCurLoc); ///////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -702,7 +702,7 @@ CG_OffsetThirdPersonView =============== */ extern qboolean MatrixMode; -static void CG_OffsetThirdPersonView( void ) +static void CG_OffsetThirdPersonView( void ) { vec3_t diff; float deltayaw; @@ -714,7 +714,7 @@ static void CG_OffsetThirdPersonView( void ) VectorCopy( cg.refdefViewAngles, cameraFocusAngles ); // if dead, look at killer - if ( cg.predicted_player_state.stats[STAT_HEALTH] <= 0 ) + if ( cg.predicted_player_state.stats[STAT_HEALTH] <= 0 ) { if ( MatrixMode ) { @@ -937,7 +937,7 @@ static void CG_OffsetThirdPersonOverheadView( void ) { VectorCopy( cg.refdef.vieworg, view ); - // Move straight up from the player, making sure to always go at least the min camera height, + // Move straight up from the player, making sure to always go at least the min camera height, // otherwise, the camera will clip into the head of the player. float tpRange = cg.overrides.thirdPersonRange ? cg.overrides.thirdPersonRange : cg_thirdPersonRange.value; if ( tpRange < MIN_CAMERA_HEIGHT ) @@ -963,17 +963,17 @@ static void CG_OffsetThirdPersonOverheadView( void ) { angs[PITCH] = MAX_CAMERA_PITCH; } - // Convert our new desired camera angles and store them where they will get used by the engine + // Convert our new desired camera angles and store them where they will get used by the engine // when setting up the actual camera view. AnglesToAxis( angs, cg.refdef.viewaxis ); cg.refdefViewAngles[PITCH] = 0; g_entities[0].client->ps.delta_angles[PITCH] = 0; - + // Trace a ray from the origin to the viewpoint to make sure the view isn't // in a solid block. CG_Trace( &trace, cg.refdef.vieworg, mins, maxs, view, cg.predicted_player_state.clientNum, MASK_CAMERACLIP); - if ( trace.fraction != 1.0 ) + if ( trace.fraction != 1.0 ) { VectorCopy( trace.endpos, cg.refdef.vieworg ); } @@ -986,11 +986,11 @@ static void CG_OffsetThirdPersonOverheadView( void ) { // this causes a compiler bug on mac MrC compiler static void CG_StepOffset( void ) { int timeDelta; - + // smooth out stair climbing timeDelta = cg.time - cg.stepTime; if ( timeDelta < STEP_TIME ) { - cg.refdef.vieworg[2] -= cg.stepChange + cg.refdef.vieworg[2] -= cg.stepChange * (STEP_TIME - timeDelta) / STEP_TIME; } } @@ -1015,7 +1015,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { float f; vec3_t predictedVelocity; int timeDelta; - + if ( cg.snap->ps.pm_type == PM_INTERMISSION ) { return; } @@ -1024,7 +1024,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { angles = cg.refdefViewAngles; // if dead, fix the angle and don't add any kick - if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) + if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) { angles[ROLL] = 40; angles[PITCH] = -15; @@ -1084,7 +1084,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { delta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[0]); angles[PITCH] += delta * cg_runpitch.value; - + delta = DotProduct ( predictedVelocity, cg.refdef.viewaxis[1]); angles[ROLL] -= delta * cg_runroll.value; @@ -1172,7 +1172,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { { #define NECK_LENGTH 8 vec3_t forward, up; - + cg.refdef.vieworg[2] -= NECK_LENGTH; AngleVectors( cg.refdefViewAngles, forward, NULL, up ); VectorMA( cg.refdef.vieworg, 3, forward, cg.refdef.vieworg ); @@ -1184,7 +1184,7 @@ static void CG_OffsetFirstPersonView( qboolean firstPersonSaber ) { //====================================================================== /* void CG_ZoomDown_f( void ) - { + { // Ignore zoom requests when yer paused if ( cg_paused.integer || in_camera ) { @@ -1218,9 +1218,9 @@ void CG_ZoomDown_f( void ) cgi_S_StartSound( cg.refdef.vieworg, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.zoomEnd ); } } - + void CG_ZoomUp_f( void ) - { + { // Ignore zoom requests when yer paused if ( cg_paused.integer || in_camera ) { @@ -1244,7 +1244,7 @@ Calcs Y FOV from given X FOV #define WAVE_AMPLITUDE 1 #define WAVE_FREQUENCY 0.4 -qboolean CG_CalcFOVFromX( float fov_x ) +qboolean CG_CalcFOVFromX( float fov_x ) { float x; float fov_y; @@ -1265,7 +1265,7 @@ qboolean CG_CalcFOVFromX( float fov_x ) fov_y = fov_y * 360 / M_PI; // there's a problem with this, it only takes the leafbrushes into account, not the entity brushes, - // so if you give slime/water etc properties to a func_door area brush in order to move the whole water + // so if you give slime/water etc properties to a func_door area brush in order to move the whole water // level up/down this doesn't take into account the door position, so warps the view the whole time // whether the water is up or not. Fortunately there's only one slime area in Trek that you can be under, // so lose it... @@ -1344,9 +1344,9 @@ static qboolean CG_CalcFov( void ) { // if in intermission, use a fixed value fov_x = 80; } - else if ( cg.snap - && cg.snap->ps.viewEntity > 0 - && cg.snap->ps.viewEntity < ENTITYNUM_WORLD + else if ( cg.snap + && cg.snap->ps.viewEntity > 0 + && cg.snap->ps.viewEntity < ENTITYNUM_WORLD && (!cg.renderingThirdPerson || g_entities[cg.snap->ps.viewEntity].e_DieFunc == dieF_camera_die) ) { // if in entity camera view, use a special FOV @@ -1375,8 +1375,8 @@ static qboolean CG_CalcFov( void ) { fov_x = 120;//FIXME: read from the NPC's fov stats? } } - } - else if ( (!cg.zoomMode || cg.zoomMode > 2) && (cg.snap->ps.forcePowersActive&(1<client->ps.forcePowerDuration[FP_SPEED] )//cg.renderingThirdPerson && + } + else if ( (!cg.zoomMode || cg.zoomMode > 2) && (cg.snap->ps.forcePowersActive&(1<client->ps.forcePowerDuration[FP_SPEED] )//cg.renderingThirdPerson && { fov_x = CG_ForceSpeedFOV(); } else { @@ -1428,7 +1428,7 @@ static qboolean CG_CalcFov( void ) { if ( zoomSoundTime < cg.time ) { sfxHandle_t snd; - + if ( cg.zoomMode == 1 ) { snd = cgs.media.zoomLoop; @@ -1440,7 +1440,7 @@ static qboolean CG_CalcFov( void ) { // huh? This could probably just be added as a looping sound?? cgi_S_StartSound( cg.refdef.vieworg, ENTITYNUM_WORLD, CHAN_LOCAL, snd ); - zoomSoundTime = cg.time + 150; + zoomSoundTime = cg.time + 150; } } } @@ -1466,7 +1466,7 @@ CG_DamageBlendBlob =============== */ -static void CG_DamageBlendBlob( void ) +static void CG_DamageBlendBlob( void ) { int t; int maxTime; @@ -1508,13 +1508,13 @@ CG_SaberClashFlare extern int g_saberFlashTime; extern vec3_t g_saberFlashPos; extern qboolean CG_WorldCoordToScreenCoord(vec3_t worldCoord, int *x, int *y); -void CG_SaberClashFlare( void ) +void CG_SaberClashFlare( void ) { int t, maxTime = 150; t = cg.time - g_saberFlashTime; - if ( t <= 0 || t >= maxTime ) + if ( t <= 0 || t >= maxTime ) { return; } @@ -1653,8 +1653,8 @@ static qboolean CG_CalcViewValues( void ) { } } - if ( (cg.renderingThirdPerson||cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE) - && !cg.zoomMode + if ( (cg.renderingThirdPerson||cg.snap->ps.weapon == WP_SABER||cg.snap->ps.weapon == WP_MELEE) + && !cg.zoomMode && !viewEntIsCam ) { // back away from character @@ -1678,8 +1678,8 @@ static qboolean CG_CalcViewValues( void ) { } CG_OffsetThirdPersonView(); // } - } - else + } + else { // offset for local bobbing and kicks CG_OffsetFirstPersonView( qfalse ); @@ -1717,7 +1717,7 @@ static qboolean CG_CalcViewValues( void ) { /* if ( in_camera ) { - Com_Printf( "%s %s\n", vtos(client_camera.origin), vtos(cg.refdef.vieworg) ); + Com_Printf( "%s %s\n", vtos(client_camera.origin), vtos(cg.refdef.vieworg) ); } */ @@ -1732,7 +1732,7 @@ static qboolean CG_CalcViewValues( void ) { AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis ); - if ( cg.hyperspace ) + if ( cg.hyperspace ) { cg.refdef.rdflags |= RDF_NOWORLDMODEL | RDF_HYPERSPACE; } @@ -1747,16 +1747,16 @@ static qboolean CG_CalcViewValues( void ) { CG_PowerupTimerSounds ===================== */ -static void CG_PowerupTimerSounds( void ) +static void CG_PowerupTimerSounds( void ) { int i, time; - + // powerup timers going away - for ( i = 0 ; i < MAX_POWERUPS ; i++ ) + for ( i = 0 ; i < MAX_POWERUPS ; i++ ) { time = cg.snap->ps.powerups[i]; - if ( time > 0 && time < cg.time ) + if ( time > 0 && time < cg.time ) { // add any special powerup expiration sounds here // switch( i ) @@ -1879,11 +1879,11 @@ wasForceSpeed=isForceSpeed; float mYawOverride = 0.0f; if ( cg.snap->ps.clientNum == 0 ) {//pointless check, but.. - if ( cg_entities[0].gent->s.eFlags & EF_LOCKED_TO_WEAPON ) + if ( cg_entities[0].gent->s.eFlags & EF_LOCKED_TO_WEAPON ) { speed *= 0.25f; } - if ( cg_entities[0].gent->s.eFlags & EF_IN_ATST ) + if ( cg_entities[0].gent->s.eFlags & EF_IN_ATST ) { mPitchOverride = 0.01f; mYawOverride = 0.0075f; @@ -1913,10 +1913,10 @@ wasForceSpeed=isForceSpeed; if ( in_camera ) { // The camera takes over the view - CGCam_RenderScene(); + CGCam_RenderScene(); } else - { + { //Finish any fading that was happening CGCam_UpdateFade(); // build cg.refdef @@ -1928,14 +1928,13 @@ wasForceSpeed=isForceSpeed; // first person blend blobs, done after AnglesToAxis if ( !cg.renderingThirdPerson ) { - CG_DamageBlendBlob(); + CG_DamageBlendBlob(); } // build the render lists if ( !cg.hyperspace ) { CG_AddPacketEntities(); // adter calcViewValues, so predicted player state is correct CG_AddMarks(); - CG_AddLocalEntities(); } //check for opaque water @@ -1977,8 +1976,8 @@ wasForceSpeed=isForceSpeed; } // Don't draw the in-view weapon when in camera mode - if ( !in_camera - && !cg_pano.integer + if ( !in_camera + && !cg_pano.integer && cg.snap->ps.weapon != WP_SABER && ( cg.snap->ps.viewEntity == 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD ) ) { @@ -1990,7 +1989,7 @@ wasForceSpeed=isForceSpeed; CG_AddViewWeapon( &g_entities[cg.snap->ps.viewEntity ].client->ps ); // HAX - because I wanted to --eez } - if ( !cg.hyperspace ) + if ( !cg.hyperspace ) { //Add all effects theFxScheduler.AddScheduledEffects( ); @@ -2000,7 +1999,11 @@ wasForceSpeed=isForceSpeed; if ( cg.testModelEntity.hModel ) { CG_AddTestModel(); } - + + if ( !cg.hyperspace ) { + CG_AddLocalEntities(); + } + cg.refdef.time = cg.time; memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) ); @@ -2015,7 +2018,7 @@ wasForceSpeed=isForceSpeed; if ( cg_pano.integer ) { // let's grab a panorama! cg.levelShot = qtrue; //hide the 2d - VectorClear(cg.refdefViewAngles); + VectorClear(cg.refdefViewAngles); cg.refdefViewAngles[YAW] = -360 * cg_pano.integer/cg_panoNumShots.integer; //choose angle AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis ); CG_DrawActive( stereoView ); diff --git a/codemp/cgame/cg_view.c b/codemp/cgame/cg_view.c index 228024c2c5..022976026c 100644 --- a/codemp/cgame/cg_view.c +++ b/codemp/cgame/cg_view.c @@ -2648,7 +2648,6 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo if ( !cg.hyperspace ) { CG_AddPacketEntities(qfalse); // adter calcViewValues, so predicted player state is correct CG_AddMarks(); - CG_AddLocalEntities(); } CG_AddViewWeapon( &cg.predictedPlayerState ); @@ -2664,6 +2663,11 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo if ( cg.testModelEntity.hModel ) { CG_AddTestModel(); } + + if ( !cg.hyperspace ) { + CG_AddLocalEntities(); + } + cg.refdef.time = cg.time; memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) ); From 1c3056e7786171e950700bd8ee4df1fbcfcb1533 Mon Sep 17 00:00:00 2001 From: razor Date: Mon, 19 Feb 2024 14:50:12 +1100 Subject: [PATCH 782/801] Fix endless loop in Z_Malloc due to imageDeleted always being qtrue, even if no images were deleted. (#1209) Co-authored-by: Tom --- code/rd-vanilla/tr_image.cpp | 2 +- codemp/rd-vanilla/tr_image.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/rd-vanilla/tr_image.cpp b/code/rd-vanilla/tr_image.cpp index 276698ec0b..a13badd43d 100644 --- a/code/rd-vanilla/tr_image.cpp +++ b/code/rd-vanilla/tr_image.cpp @@ -890,7 +890,7 @@ qboolean RE_RegisterImages_LevelLoadEnd(void) { //ri.Printf( PRINT_DEVELOPER, "RE_RegisterImages_LevelLoadEnd():\n"); - qboolean imageDeleted = qtrue; + qboolean imageDeleted = qfalse; for (AllocatedImages_t::iterator itImage = AllocatedImages.begin(); itImage != AllocatedImages.end(); /* blank */) { qboolean bEraseOccured = qfalse; diff --git a/codemp/rd-vanilla/tr_image.cpp b/codemp/rd-vanilla/tr_image.cpp index 23de173e30..4665ae25d5 100644 --- a/codemp/rd-vanilla/tr_image.cpp +++ b/codemp/rd-vanilla/tr_image.cpp @@ -874,7 +874,7 @@ qboolean RE_RegisterImages_LevelLoadEnd(void) // int iNumImages = AllocatedImages.size(); // more for curiosity, really. - qboolean imageDeleted = qtrue; + qboolean imageDeleted = qfalse; for (AllocatedImages_t::iterator itImage = AllocatedImages.begin(); itImage != AllocatedImages.end(); /* blank */) { qboolean bEraseOccured = qfalse; From 8e56d3caee5d4913fad58681bc8f4bd5e8b55185 Mon Sep 17 00:00:00 2001 From: razor Date: Mon, 19 Feb 2024 14:50:26 +1100 Subject: [PATCH 783/801] ignore numBones assert if we're mixing jk2/jka models (#1210) --- code/rd-vanilla/tr_ghoul2.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/rd-vanilla/tr_ghoul2.cpp b/code/rd-vanilla/tr_ghoul2.cpp index b1f6d43a6b..1710799542 100644 --- a/code/rd-vanilla/tr_ghoul2.cpp +++ b/code/rd-vanilla/tr_ghoul2.cpp @@ -3611,7 +3611,11 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean #ifndef JK2_MODE else { - assert (tr.models[mdxm->animIndex]->mdxa->numBones == mdxm->numBones); + // let us mix JK2/JKA models and animations + if (tr.models[mdxm->animIndex]->mdxa->numBones != 53 && tr.models[mdxm->animIndex]->mdxa->numBones != 72 && mdxm->numBones != 53 && + mdxm->numBones != 72) { + assert(tr.models[mdxm->animIndex]->mdxa->numBones == mdxm->numBones); + } if (tr.models[mdxm->animIndex]->mdxa->numBones != mdxm->numBones) { if ( isAnOldModelFile ) From 4547d40efd629e9adaa248e3803712d4f091c553 Mon Sep 17 00:00:00 2001 From: razor Date: Mon, 19 Feb 2024 18:31:27 +1100 Subject: [PATCH 784/801] [Meta] trim EOL whitespace (#1202) * trim EOL whitespace * draw the rest of the owl * fix encoding issue with JK2 cg_effects.cpp --- cmake/Modules/InstallZIP.cmake | 14 +- code/CMakeLists.txt | 2 +- code/cgame/cg_credits.cpp | 2 +- code/game/g_roff.cpp | 4 +- code/game/g_svcmds.cpp | 22 +- code/qcommon/cvar.cpp | 14 +- code/qcommon/ojk_saved_game_helper_fwd.h | 2 +- code/qcommon/safe/memory.h | 2 +- code/rd-common/tr_font.cpp | 2 +- code/rd-vanilla/tr_ghoul2.cpp | 4 +- code/rd-vanilla/tr_shader.cpp | 2 +- code/ui/ui_main.cpp | 2 +- code/ui/ui_shared.cpp | 4 +- code/win32/game.rc | 6 +- code/win32/winquake.rc | 6 +- codeJK2/cgame/FX_DEMP2.cpp | 4 +- codeJK2/cgame/FX_Disruptor.cpp | 14 +- codeJK2/cgame/FxPrimitives.h | 20 +- codeJK2/cgame/FxScheduler.h | 28 +- codeJK2/cgame/FxSystem.cpp | 4 +- codeJK2/cgame/FxSystem.h | 2 +- codeJK2/cgame/FxUtil.cpp | 92 +-- codeJK2/cgame/FxUtil.h | 70 +- codeJK2/cgame/animtable.h | 178 ++--- codeJK2/cgame/cg_camera.cpp | 56 +- codeJK2/cgame/cg_camera.h | 8 +- codeJK2/cgame/cg_consolecmds.cpp | 8 +- codeJK2/cgame/cg_credits.cpp | 30 +- codeJK2/cgame/cg_draw.cpp | 198 +++--- codeJK2/cgame/cg_drawtools.cpp | 18 +- codeJK2/cgame/cg_effects.cpp | 62 +- codeJK2/cgame/cg_ents.cpp | 184 +++--- codeJK2/cgame/cg_info.cpp | 30 +- codeJK2/cgame/cg_local.h | 70 +- codeJK2/cgame/cg_localents.cpp | 40 +- codeJK2/cgame/cg_playerstate.cpp | 18 +- codeJK2/cgame/cg_predict.cpp | 54 +- codeJK2/cgame/cg_scoreboard.cpp | 62 +- codeJK2/cgame/cg_servercmds.cpp | 12 +- codeJK2/cgame/cg_snapshot.cpp | 12 +- codeJK2/cgame/cg_syscalls.cpp | 24 +- codeJK2/game/AI_Atst.cpp | 16 +- codeJK2/game/AI_Default.cpp | 64 +- codeJK2/game/AI_Droid.cpp | 30 +- codeJK2/game/AI_GalakMech.cpp | 52 +- codeJK2/game/AI_Grenadier.cpp | 30 +- codeJK2/game/AI_Howler.cpp | 8 +- codeJK2/game/AI_ImperialProbe.cpp | 26 +- codeJK2/game/AI_Interrogator.cpp | 24 +- codeJK2/game/AI_Mark1.cpp | 40 +- codeJK2/game/AI_Mark2.cpp | 14 +- codeJK2/game/AI_MineMonster.cpp | 10 +- codeJK2/game/AI_Remote.cpp | 12 +- codeJK2/game/AI_Seeker.cpp | 14 +- codeJK2/game/AI_Sentry.cpp | 22 +- codeJK2/game/AI_Sniper.cpp | 30 +- codeJK2/game/AI_Utils.cpp | 24 +- codeJK2/game/CMakeLists.txt | 10 +- codeJK2/game/G_Timer.cpp | 16 +- codeJK2/game/NPC_combat.cpp | 256 ++++---- codeJK2/game/NPC_goal.cpp | 50 +- codeJK2/game/NPC_misc.cpp | 2 +- codeJK2/game/NPC_move.cpp | 24 +- codeJK2/game/NPC_reactions.cpp | 54 +- codeJK2/game/NPC_senses.cpp | 82 +-- codeJK2/game/NPC_sounds.cpp | 6 +- codeJK2/game/NPC_spawn.cpp | 138 ++-- codeJK2/game/NPC_utils.cpp | 176 ++--- codeJK2/game/Q3_Interface.cpp | 752 +++++++++++----------- codeJK2/game/Q3_Interface.h | 10 +- codeJK2/game/Q3_Registers.cpp | 12 +- codeJK2/game/anims.h | 178 ++--- codeJK2/game/b_local.h | 2 +- codeJK2/game/b_public.h | 8 +- codeJK2/game/bg_pangles.cpp | 42 +- codeJK2/game/bg_public.h | 18 +- codeJK2/game/channels.h | 4 +- codeJK2/game/events.h | 2 +- codeJK2/game/fields.h | 8 +- codeJK2/game/g_ICARUS.cpp | 50 +- codeJK2/game/g_active.cpp | 238 +++---- codeJK2/game/g_breakable.cpp | 62 +- codeJK2/game/g_camera.cpp | 6 +- codeJK2/game/g_cmds.cpp | 38 +- codeJK2/game/g_functions.cpp | 76 +-- codeJK2/game/g_functions.h | 32 +- codeJK2/game/g_items.h | 6 +- codeJK2/game/g_local.h | 6 +- codeJK2/game/g_mem.cpp | 2 +- codeJK2/game/g_missile.cpp | 188 +++--- codeJK2/game/g_object.cpp | 20 +- codeJK2/game/g_objectives.cpp | 2 +- codeJK2/game/g_public.h | 14 +- codeJK2/game/g_roff.cpp | 8 +- codeJK2/game/g_roff.h | 4 +- codeJK2/game/g_shared.h | 24 +- codeJK2/game/g_spawn.cpp | 34 +- codeJK2/game/g_svcmds.cpp | 26 +- codeJK2/game/g_target.cpp | 56 +- codeJK2/game/g_trigger.cpp | 114 ++-- codeJK2/game/g_usable.cpp | 8 +- codeJK2/game/ghoul2_shared.h | 14 +- codeJK2/game/objectives.h | 36 +- codeJK2/game/statindex.h | 4 +- codeJK2/game/teams.h | 22 +- codeJK2/game/w_local.h | 2 +- codeJK2/game/weapons.h | 8 +- codeJK2/game/wp_blaster_rifle.cpp | 2 +- codeJK2/game/wp_bowcaster.cpp | 2 +- codeJK2/game/wp_demp2.cpp | 22 +- codeJK2/game/wp_disruptor.cpp | 28 +- codeJK2/game/wp_emplaced_gun.cpp | 2 +- codeJK2/game/wp_flechette.cpp | 10 +- codeJK2/game/wp_rocket_launcher.cpp | 20 +- codeJK2/icarus/BlockStream.cpp | 18 +- codeJK2/icarus/Instance.cpp | 18 +- codeJK2/icarus/Interface.cpp | 2 +- codeJK2/icarus/Interpreter.cpp | 76 +-- codeJK2/icarus/Sequence.cpp | 34 +- codeJK2/icarus/Sequencer.cpp | 218 +++---- codeJK2/icarus/TaskManager.cpp | 118 ++-- codeJK2/icarus/Tokenizer.cpp | 22 +- codeJK2/icarus/blockstream.h | 14 +- codeJK2/icarus/instance.h | 2 +- codeJK2/icarus/interface.h | 2 +- codeJK2/icarus/interpreter.h | 24 +- codeJK2/icarus/sequencer.h | 4 +- codeJK2/icarus/taskmanager.h | 8 +- codeJK2/icarus/tokenizer.h | 4 +- codeJK2/qcommon/safe/memory.h | 2 +- codeJK2/win32/game.rc | 6 +- codeJK2/win32/resource.h | 2 +- codemp/CMakeLists.txt | 4 +- codemp/cgame/CMakeLists.txt | 2 +- codemp/client/cl_uiapi.cpp | 2 +- codemp/game/CMakeLists.txt | 2 +- codemp/game/NPC_combat.c | 2 +- codemp/qcommon/cvar.cpp | 14 +- codemp/rd-rend2/G2_API.cpp | 32 +- codemp/rd-rend2/G2_bolts.cpp | 12 +- codemp/rd-rend2/G2_bones.cpp | 212 +++--- codemp/rd-rend2/G2_misc.cpp | 136 ++-- codemp/rd-rend2/G2_surfaces.cpp | 40 +- codemp/rd-rend2/MikkTSpace/mikktspace.c | 42 +- codemp/rd-rend2/glsl/bokeh.glsl | 4 +- codemp/rd-rend2/glsl/calclevels4x.glsl | 4 +- codemp/rd-rend2/glsl/depthblur.glsl | 12 +- codemp/rd-rend2/glsl/down4x.glsl | 6 +- codemp/rd-rend2/glsl/fogpass.glsl | 2 +- codemp/rd-rend2/glsl/generic.glsl | 18 +- codemp/rd-rend2/glsl/lightall.glsl | 66 +- codemp/rd-rend2/glsl/prefilterEnvMap.glsl | 10 +- codemp/rd-rend2/glsl/refraction.glsl | 28 +- codemp/rd-rend2/glsl/shadowvolume.glsl | 6 +- codemp/rd-rend2/glsl/ssao.glsl | 16 +- codemp/rd-rend2/glsl/surface_sprites.glsl | 8 +- codemp/rd-rend2/glsl/tonemap.glsl | 6 +- codemp/rd-rend2/stb_image.h | 26 +- codemp/rd-rend2/tr_animation.cpp | 54 +- codemp/rd-rend2/tr_backend.cpp | 40 +- codemp/rd-rend2/tr_cache.cpp | 14 +- codemp/rd-rend2/tr_cmds.cpp | 48 +- codemp/rd-rend2/tr_decals.cpp | 32 +- codemp/rd-rend2/tr_extensions.cpp | 8 +- codemp/rd-rend2/tr_extramath.cpp | 14 +- codemp/rd-rend2/tr_fbo.cpp | 6 +- codemp/rd-rend2/tr_flares.cpp | 8 +- codemp/rd-rend2/tr_ghoul2.cpp | 156 ++--- codemp/rd-rend2/tr_glsl.cpp | 34 +- codemp/rd-rend2/tr_image.cpp | 150 ++--- codemp/rd-rend2/tr_light.cpp | 20 +- codemp/rd-rend2/tr_main.cpp | 72 +-- codemp/rd-rend2/tr_marks.cpp | 8 +- codemp/rd-rend2/tr_mesh.cpp | 20 +- codemp/rd-rend2/tr_model.cpp | 172 ++--- codemp/rd-rend2/tr_model_iqm.cpp | 28 +- codemp/rd-rend2/tr_postprocess.cpp | 20 +- codemp/rd-rend2/tr_scene.cpp | 12 +- codemp/rd-rend2/tr_shade.cpp | 80 +-- codemp/rd-rend2/tr_shade_calc.cpp | 28 +- codemp/rd-rend2/tr_shader.cpp | 152 ++--- codemp/rd-rend2/tr_skin.cpp | 18 +- codemp/rd-rend2/tr_sky.cpp | 72 +-- codemp/rd-rend2/tr_surface.cpp | 96 +-- codemp/rd-rend2/tr_weather.cpp | 26 +- codemp/rd-rend2/tr_world.cpp | 28 +- codemp/rd-vanilla/CMakeLists.txt | 2 +- codemp/rd-vanilla/tr_shader.cpp | 2 +- codemp/rd-vanilla/tr_shadows.cpp | 2 +- codemp/ui/CMakeLists.txt | 2 +- codemp/ui/ui_shared.c | 2 +- rv-readme.txt | 2 +- scripts/docker/server.cfg | 4 +- shared/qcommon/q_string.c | 2 +- shared/qcommon/safe/files.h | 2 +- ui/menudef.h | 40 +- 196 files changed, 3800 insertions(+), 3800 deletions(-) diff --git a/cmake/Modules/InstallZIP.cmake b/cmake/Modules/InstallZIP.cmake index 090b946d03..70168942db 100644 --- a/cmake/Modules/InstallZIP.cmake +++ b/cmake/Modules/InstallZIP.cmake @@ -41,35 +41,35 @@ if(WIN32) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" -P "" ) endif() endif() - + if(NOT ZIP_EXECUTABLE) find_program(ZIP_EXECUTABLE wzzip PATHS "$ENV{ProgramW6432}/WinZip") if(ZIP_EXECUTABLE) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" -P "" ) endif() endif() - + if(NOT ZIP_EXECUTABLE) find_program(ZIP_EXECUTABLE 7z PATHS "$ENV{ProgramFiles}/7-Zip") if(ZIP_EXECUTABLE) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" a -tzip "" ) endif() endif() - + if(NOT ZIP_EXECUTABLE) find_program(ZIP_EXECUTABLE 7z PATHS "$ENV{ProgramW6432}/7-Zip") if(ZIP_EXECUTABLE) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" a -tzip "" ) endif() endif() - + if(NOT ZIP_EXECUTABLE) find_program(ZIP_EXECUTABLE winrar PATHS "$ENV{ProgramFiles}/WinRAR") if(ZIP_EXECUTABLE) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" a "" ) endif() endif() - + if(NOT ZIP_EXECUTABLE) find_program(ZIP_EXECUTABLE winrar PATHS "$ENV{ProgramW6432}/WinRAR") if(ZIP_EXECUTABLE) @@ -85,7 +85,7 @@ if(NOT ZIP_EXECUTABLE) else() find_program(ZIP_EXECUTABLE zip) endif() - + if(ZIP_EXECUTABLE) set(ZIP_COMMAND "${ZIP_EXECUTABLE}" -r "" . -i) endif() @@ -94,7 +94,7 @@ endif() function(add_zip_command output) set(MultiValueArgs FILES DEPENDS) cmake_parse_arguments(ARGS "" "" "${MultiValueArgs}" ${ARGN}) - + set(ZipCommand ${ZIP_COMMAND}) string(REPLACE "${output}" ZipCommand "${ZipCommand}") string(REPLACE "${ARGS_FILES}" ZipCommand "${ZipCommand}") diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 2c9e7f509f..f41d0f7a2c 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -190,7 +190,7 @@ if(BuildSPEngine OR BuildJK2SPEngine) ) source_group("common" FILES ${SPEngineCommonFiles}) set(SPEngineFiles ${SPEngineFiles} ${SPEngineCommonFiles}) - + set(SPEngineCommonSafeFiles "${SharedDir}/qcommon/safe/files.cpp" "${SharedDir}/qcommon/safe/files.h" diff --git a/code/cgame/cg_credits.cpp b/code/cgame/cg_credits.cpp index 68ff647634..27e1789f65 100644 --- a/code/cgame/cg_credits.cpp +++ b/code/cgame/cg_credits.cpp @@ -216,7 +216,7 @@ static bool SortBySurname(const StringAndSize_t &str1, const StringAndSize_t &st { std::string::const_reverse_iterator rstart1 = std::find_if(str1.str.rbegin(), str1.str.rend(), isspace); std::string::const_reverse_iterator rstart2 = std::find_if(str2.str.rbegin(), str2.str.rend(), isspace); - + return Q_stricmp(&*rstart1.base(), &*rstart2.base()) < 0; } diff --git a/code/game/g_roff.cpp b/code/game/g_roff.cpp index 5dd6381f42..d49649c26e 100644 --- a/code/game/g_roff.cpp +++ b/code/game/g_roff.cpp @@ -86,7 +86,7 @@ static void G_RoffNotetrackCallback( gentity_t *ent, const char *notetrack) // notetrack = "loop rof relative"; // notetrack = "loop sfx sound/vehicles/tie/loop.wav"; // notetrack = "loop sfx kill"; - //'loop rof' notes: + //'loop rof' notes: // (1) absolute ==> reset rof to original delta position/rotation world location before looping. // (2) relative ==> reset rof to original delta position/rotation at current location before looping. //'loop sfx' notes: @@ -742,7 +742,7 @@ void G_Roff( gentity_t *ent ) move_rotate2_t *data = &((move_rotate2_t *)roff->data)[ ent->roff_ctr ]; VectorCopy( data->origin_delta, org ); VectorCopy( data->rotate_delta, ang ); - + if ( data->mStartNote != -1 ) { for ( int n = 0; n < data->mNumNotes; n++ ) diff --git a/code/game/g_svcmds.cpp b/code/game/g_svcmds.cpp index f7d4faa344..0374e14091 100644 --- a/code/game/g_svcmds.cpp +++ b/code/game/g_svcmds.cpp @@ -907,7 +907,7 @@ static svcmd_t svcmds[] = { { "saberColor", Svcmd_SaberColor_f, CMD_CHEAT }, { "saber", Svcmd_Saber_f, CMD_CHEAT }, { "saberBlade", Svcmd_SaberBlade_f, CMD_CHEAT }, - + { "setForceJump", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setSaberThrow", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setForceHeal", Svcmd_ForceSetLevel_f, CMD_CHEAT }, @@ -926,29 +926,29 @@ static svcmd_t svcmds[] = { { "setForceSight", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setForceAll", Svcmd_SetForceAll_f, CMD_CHEAT }, { "setSaberAll", Svcmd_SetSaberAll_f, CMD_CHEAT }, - + { "saberAttackCycle", Svcmd_SaberAttackCycle_f, CMD_NONE }, - + { "runscript", Svcmd_RunScript_f, CMD_CHEAT }, - + { "playerTeam", Svcmd_PlayerTeam_f, CMD_CHEAT }, - + { "control", Svcmd_Control_f, CMD_CHEAT }, { "grab", Svcmd_Grab_f, CMD_CHEAT }, { "knockdown", Svcmd_Knockdown_f, CMD_CHEAT }, { "playerModel", Svcmd_PlayerModel_f, CMD_NONE }, { "playerTint", Svcmd_PlayerTint_f, CMD_NONE }, - + { "nexttestaxes", G_NextTestAxes, CMD_NONE }, - + { "exitview", Svcmd_ExitView_f, CMD_NONE }, - + { "iknowkungfu", Svcmd_IKnowKungfu_f, CMD_CHEAT }, - + { "secrets", Svcmd_Secrets_f, CMD_NONE }, { "difficulty", Svcmd_Difficulty_f, CMD_NONE }, - + //{ "say", Svcmd_Say_f, qtrue }, //{ "toggleallowvote", Svcmd_ToggleAllowVote_f, qfalse }, //{ "toggleuserinfovalidation", Svcmd_ToggleUserinfoValidation_f, qfalse }, @@ -966,7 +966,7 @@ qboolean ConsoleCommand( void ) { if ( !command ) return qfalse; - + if ( (command->flags & CMD_CHEAT) && !g_cheats->integer ) { diff --git a/code/qcommon/cvar.cpp b/code/qcommon/cvar.cpp index 77d8e4b4a7..a5cef1e158 100644 --- a/code/qcommon/cvar.cpp +++ b/code/qcommon/cvar.cpp @@ -481,11 +481,11 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, int flags ) { return var; } -static void Cvar_QSortByName( cvar_t **a, int n ) +static void Cvar_QSortByName( cvar_t **a, int n ) { cvar_t *temp; cvar_t *m; - int i, j; + int i, j; i = 0; j = n; @@ -497,10 +497,10 @@ static void Cvar_QSortByName( cvar_t **a, int n ) while ( strcmp( a[j]->name, m->name ) < 0 ) j--; if ( i <= j ) { - temp = a[i]; - a[i] = a[j]; + temp = a[i]; + a[i] = a[j]; a[j] = temp; - i++; + i++; j--; } } while ( i <= j ); @@ -510,7 +510,7 @@ static void Cvar_QSortByName( cvar_t **a, int n ) } -static void Cvar_Sort( void ) +static void Cvar_Sort( void ) { cvar_t *list[ MAX_CVARS ], *var; int count; @@ -529,7 +529,7 @@ static void Cvar_Sort( void ) } Cvar_QSortByName( &list[0], count-1 ); - + cvar_vars = NULL; // relink cvars diff --git a/code/qcommon/ojk_saved_game_helper_fwd.h b/code/qcommon/ojk_saved_game_helper_fwd.h index 60b360fcbc..b44ef99c6d 100644 --- a/code/qcommon/ojk_saved_game_helper_fwd.h +++ b/code/qcommon/ojk_saved_game_helper_fwd.h @@ -291,7 +291,7 @@ class SavedGameClassArchiver { public: enum { is_implemented = false }; - + static void sg_export( SavedGameHelper& saved_game, const T& instance) diff --git a/code/qcommon/safe/memory.h b/code/qcommon/safe/memory.h index 1299509102..5caec82d91 100644 --- a/code/qcommon/safe/memory.h +++ b/code/qcommon/safe/memory.h @@ -80,7 +80,7 @@ namespace Zone using other = Allocator< U, tag >; }; }; - + template< typename T > using UniquePtr = std::unique_ptr< T, Deleter >; diff --git a/code/rd-common/tr_font.cpp b/code/rd-common/tr_font.cpp index 8724a18311..f968fdb89d 100644 --- a/code/rd-common/tr_font.cpp +++ b/code/rd-common/tr_font.cpp @@ -1284,7 +1284,7 @@ void CFontInfo::UpdateAsianIfNeeded( bool bForceReEval /* = false */ ) case eTaiwanese: case eJapanese: #ifndef JK2_MODE - case eChinese: + case eChinese: #endif m_AsianGlyph.horizAdvance = iCappedHeight + 3; // need to force some spacing for these // case eThai: // this is done dynamically elsewhere, since Thai glyphs are variable width diff --git a/code/rd-vanilla/tr_ghoul2.cpp b/code/rd-vanilla/tr_ghoul2.cpp index 1710799542..4e25ddfca8 100644 --- a/code/rd-vanilla/tr_ghoul2.cpp +++ b/code/rd-vanilla/tr_ghoul2.cpp @@ -3569,7 +3569,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean // 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)); - + char animGLAName[MAX_QPATH]; char *strippedName; char *slash = NULL; @@ -3593,7 +3593,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean { RE_RegisterModel(va("models/players/%s_%s/%s_%s.gla", strippedName, mapname, strippedName, mapname)); } - } + } #ifndef JK2_MODE bool isAnOldModelFile = false; diff --git a/code/rd-vanilla/tr_shader.cpp b/code/rd-vanilla/tr_shader.cpp index 1fd3d40296..8991044919 100644 --- a/code/rd-vanilla/tr_shader.cpp +++ b/code/rd-vanilla/tr_shader.cpp @@ -2478,7 +2478,7 @@ Ghoul2 Insert End // functioned because rgbGen identity doesn't work with setcolor. // // We match against retail version of gfx/menus/radar/arrow_w by calculating - // the hash value of the shader text, and comparing it against a + // the hash value of the shader text, and comparing it against a // precalculated value. if ( shaderHash == RETAIL_ARROW_W_SHADER_HASH && Q_stricmp( shader.name, "gfx/menus/radar/arrow_w" ) == 0 ) diff --git a/code/ui/ui_main.cpp b/code/ui/ui_main.cpp index b6d4fed156..39a226900a 100644 --- a/code/ui/ui_main.cpp +++ b/code/ui/ui_main.cpp @@ -2432,7 +2432,7 @@ void UI_FreeAllSpecies( void ) UI_FreeSpecies(&uiInfo.playerSpecies[i]); } free(uiInfo.playerSpecies); - + uiInfo.playerSpeciesCount = 0; uiInfo.playerSpecies = NULL; } diff --git a/code/ui/ui_shared.cpp b/code/ui/ui_shared.cpp index 0306ba6c72..07461b8adf 100644 --- a/code/ui/ui_shared.cpp +++ b/code/ui/ui_shared.cpp @@ -1047,7 +1047,7 @@ static void Item_ApplyHacks( itemDef_t *item ) { Com_Printf( "Disabling eax field because current platform does not support EAX.\n"); } } - + if ( item->type == ITEM_TYPE_TEXT && item->window.name && !Q_stricmp( item->window.name, "eax_icon") && item->cvarTest && !Q_stricmp( item->cvarTest, "s_UseOpenAL" ) && item->enableCvar && (item->cvarFlags & CVAR_HIDE) ) { if( item->parent ) { @@ -1085,7 +1085,7 @@ static void Item_ApplyHacks( itemDef_t *item ) { Com_Printf( "Extended sound quality field to contain very high option.\n"); } } - + if ( item->type == ITEM_TYPE_MULTI && item->window.name && !Q_stricmp( item->window.name, "voice") && item->cvar && !Q_stricmp( item->cvar, "g_subtitles" ) ) { multiDef_t *multiPtr = (multiDef_t *)item->typeData; int i; diff --git a/code/win32/game.rc b/code/win32/game.rc index 7b9d377284..3632640c44 100644 --- a/code/win32/game.rc +++ b/code/win32/game.rc @@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" diff --git a/code/win32/winquake.rc b/code/win32/winquake.rc index 8be20e493c..751d5b49b3 100644 --- a/code/win32/winquake.rc +++ b/code/win32/winquake.rc @@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""winres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\0" END diff --git a/codeJK2/cgame/FX_DEMP2.cpp b/codeJK2/cgame/FX_DEMP2.cpp index d0c44789f5..e0a01527c2 100644 --- a/codeJK2/cgame/FX_DEMP2.cpp +++ b/codeJK2/cgame/FX_DEMP2.cpp @@ -100,12 +100,12 @@ void FX_DEMP2_AltDetonate( vec3_t org, float size ) ex->startTime = cg.time; ex->endTime = ex->startTime + 1300; - + ex->radius = size; ex->refEntity.customShader = cgi_R_RegisterShader( "gfx/effects/demp2shell" ); ex->refEntity.hModel = cgi_R_RegisterModel( "models/items/sphere.md3" ); VectorCopy( org, ex->refEntity.origin ); - + ex->color[0] = ex->color[1] = ex->color[2] = 255.0f; } diff --git a/codeJK2/cgame/FX_Disruptor.cpp b/codeJK2/cgame/FX_Disruptor.cpp index a141bcf025..899022ba25 100644 --- a/codeJK2/cgame/FX_Disruptor.cpp +++ b/codeJK2/cgame/FX_Disruptor.cpp @@ -36,10 +36,10 @@ static vec3_t WHITE ={1.0f,1.0f,1.0f}; void FX_DisruptorMainShot( vec3_t start, vec3_t end ) { - FX_AddLine( start, end, 0.1f, 4.0f, 0.0f, + FX_AddLine( start, end, 0.1f, 4.0f, 0.0f, 1.0f, 0.0f, 0.0f, WHITE, WHITE, 0.0f, - 120, cgi_R_RegisterShader( "gfx/effects/redLine" ), + 120, cgi_R_RegisterShader( "gfx/effects/redLine" ), FX_SIZE_LINEAR | FX_ALPHA_LINEAR ); } @@ -51,10 +51,10 @@ FX_DisruptorAltShot */ void FX_DisruptorAltShot( vec3_t start, vec3_t end, qboolean fullCharge ) { - FX_AddLine( start, end, 0.1f, 10.0f, 0.0f, + FX_AddLine( start, end, 0.1f, 10.0f, 0.0f, 1.0f, 0.0f, 0.0f, WHITE, WHITE, 0.0f, - 175, cgi_R_RegisterShader( "gfx/effects/redLine" ), + 175, cgi_R_RegisterShader( "gfx/effects/redLine" ), FX_SIZE_LINEAR | FX_ALPHA_LINEAR ); if ( fullCharge ) @@ -62,10 +62,10 @@ void FX_DisruptorAltShot( vec3_t start, vec3_t end, qboolean fullCharge ) vec3_t YELLER={0.8f,0.7f,0.0f}; // add some beef - FX_AddLine( start, end, 0.1f, 7.0f, 0.0f, + FX_AddLine( start, end, 0.1f, 7.0f, 0.0f, 1.0f, 0.0f, 0.0f, YELLER, YELLER, 0.0f, - 150, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), + 150, cgi_R_RegisterShader( "gfx/misc/whiteline2" ), FX_SIZE_LINEAR | FX_ALPHA_LINEAR ); } } @@ -85,7 +85,7 @@ void FX_DisruptorAltMiss( vec3_t origin, vec3_t normal ) VectorCopy( c1, c2 ); c1[2] += 4; c2[2] += 12; - + VectorAdd( origin, normal, pos ); pos[2] += 28; diff --git a/codeJK2/cgame/FxPrimitives.h b/codeJK2/cgame/FxPrimitives.h index b81fe3e9fb..14db076df9 100644 --- a/codeJK2/cgame/FxPrimitives.h +++ b/codeJK2/cgame/FxPrimitives.h @@ -85,7 +85,7 @@ along with this program; if not, see . #define FX_DEPTH_HACK 0x00100000 #define FX_RELATIVE 0x00200000 #define FX_SET_SHADER_TIME 0x00400000 // by having the effects system set the shader time, we can make animating textures start at the correct time -#define FX_EXPENSIVE_PHYSICS 0x00800000 +#define FX_EXPENSIVE_PHYSICS 0x00800000 #define FX_ATTACHED_MODEL 0x01000000 @@ -138,7 +138,7 @@ class CEffect { // Game pausing can cause dumb time things to happen, so kill the effect in this instance if ( mTimeStart > theFxHelper.mTime ) { return false; - } + } return true; } @@ -222,7 +222,7 @@ class CLight : public CEffect void Draw() { - theFxHelper.AddLightToScene( mOrigin1, mRefEnt.radius, + theFxHelper.AddLightToScene( mOrigin1, mRefEnt.radius, mRefEnt.lightingOrigin[0], mRefEnt.lightingOrigin[1], mRefEnt.lightingOrigin[2] ); } @@ -231,7 +231,7 @@ class CLight : public CEffect CLight() {} virtual ~CLight() {} virtual bool Update(); - + inline void SetSizeStart( float sz ) { mSizeStart = sz; } inline void SetSizeEnd( float sz ) { mSizeEnd = sz; } inline void SetSizeParm( float parm ) { mSizeParm = parm; } @@ -277,7 +277,7 @@ class CParticle : public CEffect vec3_t mRGBStart; vec3_t mRGBEnd; float mRGBParm; - + float mAlphaStart; float mAlphaEnd; float mAlphaParm; @@ -297,7 +297,7 @@ class CParticle : public CEffect bool Cull(); void Draw(); - + public: inline CParticle() { mRefEnt.reType = RT_SPRITE; mClientID = -1; } @@ -375,7 +375,7 @@ class CBezier : public CLine virtual void Die() {} virtual bool Update(); - + void DrawSegment( vec3_t start, vec3_t end, float texcoord1, float texcoord2 ); inline void SetControlPoints( const vec3_t ctrl1, const vec3_t ctrl2 ) { VectorCopy( ctrl1, mControl1 ); VectorCopy( ctrl2, mControl2 ); } @@ -496,10 +496,10 @@ class CEmitter : public CParticle vec3_t mOldOrigin; // we use these to do some nice vec3_t mLastOrigin; // tricks... - vec3_t mOldVelocity; // + vec3_t mOldVelocity; // int mOldTime; - vec3_t mAngles; // for a rotating thing, using a delta + vec3_t mAngles; // for a rotating thing, using a delta vec3_t mAngleDelta; // as opposed to an end angle is probably much easier int mEmitterFxID; // if we have emitter fx, this is our id @@ -514,7 +514,7 @@ class CEmitter : public CParticle public: CEmitter() { - // There may or may not be a model, but if there isn't one, + // There may or may not be a model, but if there isn't one, // we just won't bother adding the refEnt in our Draw func mRefEnt.reType = RT_MODEL; } diff --git a/codeJK2/cgame/FxScheduler.h b/codeJK2/cgame/FxScheduler.h index f40fe5fbbc..febfd65608 100644 --- a/codeJK2/cgame/FxScheduler.h +++ b/codeJK2/cgame/FxScheduler.h @@ -42,19 +42,19 @@ typedef sstring_t fxString_t; #define FX_MAX_EFFECTS 150 // how many effects the system can store #define FX_MAX_EFFECT_COMPONENTS 24 // how many primitives an effect can hold, this should be plenty #define FX_MAX_PRIM_NAME 32 - + //----------------------------------------------- // These are spawn flags for primitiveTemplates //----------------------------------------------- #define FX_ORG_ON_SPHERE 0x00001 // Pretty dang expensive, calculates a point on a sphere/ellipsoid -#define FX_AXIS_FROM_SPHERE 0x00002 // Can be used in conjunction with org_on_sphere to cause particles to move out +#define FX_AXIS_FROM_SPHERE 0x00002 // Can be used in conjunction with org_on_sphere to cause particles to move out // from the center of the sphere #define FX_ORG_ON_CYLINDER 0x00004 // calculate point on cylinder/disk #define FX_ORG2_FROM_TRACE 0x00010 #define FX_TRACE_IMPACT_FX 0x00020 // if trace impacts, we should play one of the specified impact fx files -#define FX_ORG2_IS_OFFSET 0x00040 // template specified org2 should be the offset from a trace endpos or +#define FX_ORG2_IS_OFFSET 0x00040 // template specified org2 should be the offset from a trace endpos or // passed in org2. You might use this to lend a random flair to the endpos. // Note: this is done pre-trace, so you may have to specify large numbers for this @@ -76,7 +76,7 @@ typedef sstring_t fxString_t; // // CMediaHandles // -// Primitive templates might want to use a list of sounds, shaders +// Primitive templates might want to use a list of sounds, shaders // or models to get a bit more variation in their effects. // //----------------------------------------------------------------- @@ -101,7 +101,7 @@ class CMediaHandles // CFxRange // // Primitive templates typically use this class to define each of -// its members. This is done to make it easier to create effects +// its members. This is done to make it easier to create effects // with a desired range of characteristics. // //----------------------------------------------------------------- @@ -166,11 +166,11 @@ enum EPrimType // // CPrimitiveTemplate // -// The primitive template is used to spawn 1 or more fx primitives +// The primitive template is used to spawn 1 or more fx primitives // with the range of characteristics defined by the template. // -// As such, I just made this one huge shared class knowing that -// there won't be many of them in memory at once, and we won't +// As such, I just made this one huge shared class knowing that +// there won't be many of them in memory at once, and we won't // be dynamically creating and deleting them mid-game. Also, // note that not every primitive type will use all of these fields. // @@ -182,8 +182,8 @@ class CPrimitiveTemplate // These kinds of things should not even be allowed to be accessed publicly bool mCopy; - int mRefCount; // For a copy of a primitive...when we figure out how many items we want to spawn, - // we'll store that here and then decrement us for each we actually spawn. When we + int mRefCount; // For a copy of a primitive...when we figure out how many items we want to spawn, + // we'll store that here and then decrement us for each we actually spawn. When we // hit zero, we are no longer used and so we can just free ourselves char mName[FX_MAX_PRIM_NAME]; @@ -563,8 +563,8 @@ class PagedPoolAllocator // // CFxScheduler // -// The scheduler not only handles requests to play an effect, it -// tracks the request throughout its life if necessary, creating +// The scheduler not only handles requests to play an effect, it +// tracks the request throughout its life if necessary, creating // any of the delayed components as needed. // //----------------------------------------------------------------- @@ -611,7 +611,7 @@ class CFxScheduler public: CFxScheduler(); - + int RegisterEffect( const char *file, bool bHasCorrectPath = false ); // handles pre-caching @@ -621,7 +621,7 @@ class CFxScheduler void PlayEffect( int id, vec3_t origin, vec3_t axis[3], const int boltInfo=-1, const int entNum=-1 ); void PlayEffect( const char *file, vec3_t org ); // uses a default up axis void PlayEffect( const char *file, vec3_t org, vec3_t fwd ); // builds arbitrary perp. right vector, does a cross product to define up - void PlayEffect( const char *file, vec3_t origin, + void PlayEffect( const char *file, vec3_t origin, vec3_t axis[3], const int boltInfo, const int entNum ); void PlayEffect( const char *file, int clientID ); diff --git a/codeJK2/cgame/FxSystem.cpp b/codeJK2/cgame/FxSystem.cpp index d4a47ffd0f..80c1cd443e 100644 --- a/codeJK2/cgame/FxSystem.cpp +++ b/codeJK2/cgame/FxSystem.cpp @@ -49,7 +49,7 @@ void SFxHelper::Print( const char *msg, ... ) va_start( argptr, msg ); Q_vsnprintf (text, sizeof(text), msg, argptr); va_end( argptr ); - + gi.Printf( text ); #endif @@ -108,7 +108,7 @@ void SFxHelper::PlaySound( vec3_t org, int entityNum, int entchannel, int sfxHan } //------------------------------------------------------ -void SFxHelper::Trace( trace_t *tr, vec3_t start, vec3_t min, vec3_t max, +void SFxHelper::Trace( trace_t *tr, vec3_t start, vec3_t min, vec3_t max, vec3_t end, int skipEntNum, int flags ) { CG_Trace( tr, start, min, max, end, skipEntNum, flags ); diff --git a/codeJK2/cgame/FxSystem.h b/codeJK2/cgame/FxSystem.h index fb83979ce0..1f91e255df 100644 --- a/codeJK2/cgame/FxSystem.h +++ b/codeJK2/cgame/FxSystem.h @@ -36,7 +36,7 @@ along with this program; if not, see . extern vmCvar_t fx_debug; extern vmCvar_t fx_freeze; -extern void CG_CalcEntityLerpPositions( centity_t * ); +extern void CG_CalcEntityLerpPositions( centity_t * ); struct SFxHelper { diff --git a/codeJK2/cgame/FxUtil.cpp b/codeJK2/cgame/FxUtil.cpp index 8df8097c86..d6b3f14879 100644 --- a/codeJK2/cgame/FxUtil.cpp +++ b/codeJK2/cgame/FxUtil.cpp @@ -47,7 +47,7 @@ int mParticles; int mOParticles; int mLines; int mTails; -qboolean fxInitialized = qfalse; +qboolean fxInitialized = qfalse; //------------------------- // FX_Free @@ -100,7 +100,7 @@ void FX_Stop( void ) // Preps system for use //------------------------- int FX_Init( void ) -{ +{ if ( fxInitialized == qfalse ) { fxInitialized = qtrue; @@ -210,13 +210,13 @@ void FX_Add( void ) for ( i = 0, ef = effectList; i < MAX_EFFECTS; i++, ef++ ) { if ( ef->mEffect != 0 ) - { + { // Effect is active if ( theFxHelper.mTime > ef->mKillTime ) - { + { // Clean up old effects, calling any death effects as needed // this flag just has to be cleared otherwise death effects might not happen correctly - ef->mEffect->ClearFlags( FX_KILL_ON_IMPACT ); + ef->mEffect->ClearFlags( FX_KILL_ON_IMPACT ); FX_FreeMember( ef ); } else @@ -385,8 +385,8 @@ void FX_AddPrimitive( CEffect **pEffect, int killTime ) //------------------------- // FX_AddParticle //------------------------- -CParticle *FX_AddParticle( const vec3_t org, const vec3_t vel, const vec3_t accel, float size1, float size2, float sizeParm, - float alpha1, float alpha2, float alphaParm, +CParticle *FX_AddParticle( const vec3_t org, const vec3_t vel, const vec3_t accel, float size1, float size2, float sizeParm, + float alpha1, float alpha2, float alphaParm, const vec3_t sRGB, const vec3_t eRGB, float rgbParm, float rotation, float rotationDelta, const vec3_t min, const vec3_t max, float elasticity, @@ -760,7 +760,7 @@ CElectricity *FX_AddElectricity( vec3_t start, vec3_t end, float size1, float si // in the editor, fx may now be NULL? if ( fx ) { - fx->Initialize(); + fx->Initialize(); } } @@ -771,12 +771,12 @@ CElectricity *FX_AddElectricity( vec3_t start, vec3_t end, float size1, float si //------------------------- // FX_AddTail //------------------------- -CTail *FX_AddTail( vec3_t org, vec3_t vel, vec3_t accel, - float size1, float size2, float sizeParm, +CTail *FX_AddTail( vec3_t org, vec3_t vel, vec3_t accel, + float size1, float size2, float sizeParm, float length1, float length2, float lengthParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags = 0 ) { @@ -865,12 +865,12 @@ CTail *FX_AddTail( vec3_t org, vec3_t vel, vec3_t accel, //------------------------- // FX_AddTail //------------------------- -CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel, - float size1, float size2, float sizeParm, +CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel, + float size1, float size2, float sizeParm, float length1, float length2, float lengthParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags = 0 ) { @@ -961,7 +961,7 @@ CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel, //------------------------- // FX_AddCylinder //------------------------- -CCylinder *FX_AddCylinder( vec3_t start, vec3_t normal, +CCylinder *FX_AddCylinder( vec3_t start, vec3_t normal, float size1s, float size1e, float sizeParm, float size2s, float size2e, float size2Parm, float length1, float length2, float lengthParm, @@ -1059,12 +1059,12 @@ CCylinder *FX_AddCylinder( vec3_t start, vec3_t normal, //------------------------- // FX_AddEmitter //------------------------- -CEmitter *FX_AddEmitter( vec3_t org, vec3_t vel, vec3_t accel, +CEmitter *FX_AddEmitter( vec3_t org, vec3_t vel, vec3_t accel, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, vec3_t angs, vec3_t deltaAngs, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int emitterID, float density, float variance, int killTime, qhandle_t model, int flags = 0 ) @@ -1289,7 +1289,7 @@ COrientedParticle *FX_AddOrientedParticle( vec3_t org, vec3_t norm, vec3_t vel, //------------------------- // FX_AddPoly //------------------------- -CPoly *FX_AddPoly( vec3_t *verts, vec2_t *st, int numVerts, +CPoly *FX_AddPoly( vec3_t *verts, vec2_t *st, int numVerts, vec3_t vel, vec3_t accel, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, @@ -1363,7 +1363,7 @@ CPoly *FX_AddPoly( vec3_t *verts, vec2_t *st, int numVerts, //------------------------- // FX_AddBezier //------------------------- -CBezier *FX_AddBezier( const vec3_t start, const vec3_t end, +CBezier *FX_AddBezier( const vec3_t start, const vec3_t end, const vec3_t control1, const vec3_t control1Vel, const vec3_t control2, const vec3_t control2Vel, float size1, float size2, float sizeParm, @@ -1498,7 +1498,7 @@ CFlash *FX_AddFlash( vec3_t origin, vec3_t sRGB, vec3_t eRGB, float rgbParm, fx->SetFlags( flags ); // fx->SetSTScale( 1.0f, 1.0f ); - + fx->Init(); FX_AddPrimitive( (CEffect**)&fx, killTime ); @@ -1509,7 +1509,7 @@ CFlash *FX_AddFlash( vec3_t origin, vec3_t sRGB, vec3_t eRGB, float rgbParm, //------------------------------------------------------- // Functions for limited backward compatibility with EF. -// These calls can be used for simple programmatic +// These calls can be used for simple programmatic // effects, temp effects or debug graphics. // Note that this is not an all-inclusive list of // fx add functions from EF, nor are the calls guaranteed @@ -1517,13 +1517,13 @@ CFlash *FX_AddFlash( vec3_t origin, vec3_t sRGB, vec3_t eRGB, float rgbParm, //------------------------------------------------------- //--------------------------------------------------- -void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, - float scale, float dscale, - float sAlpha, float eAlpha, - float rotation, float bounce, +void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, + float scale, float dscale, + float sAlpha, float eAlpha, + float rotation, float bounce, int life, qhandle_t shader, int flags ) { - FX_AddParticle( origin, vel, accel, scale, scale, 0, + FX_AddParticle( origin, vel, accel, scale, scale, 0, sAlpha, eAlpha, FX_ALPHA_LINEAR, WHITE, WHITE, 0, rotation, 0, @@ -1533,14 +1533,14 @@ void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, } //--------------------------------------------------- -void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, - float scale, float dscale, - float sAlpha, float eAlpha, - vec3_t sRGB, vec3_t eRGB, - float rotation, float bounce, +void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, + float scale, float dscale, + float sAlpha, float eAlpha, + vec3_t sRGB, vec3_t eRGB, + float rotation, float bounce, int life, qhandle_t shader, int flags ) { - FX_AddParticle( origin, vel, accel, scale, scale, 0, + FX_AddParticle( origin, vel, accel, scale, scale, 0, sAlpha, eAlpha, FX_ALPHA_LINEAR, sRGB, eRGB, 0, rotation, 0, @@ -1550,9 +1550,9 @@ void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, } //--------------------------------------------------- -void FX_AddLine( vec3_t start, vec3_t end, float stScale, - float width, float dwidth, - float sAlpha, float eAlpha, +void FX_AddLine( vec3_t start, vec3_t end, float stScale, + float width, float dwidth, + float sAlpha, float eAlpha, int life, qhandle_t shader, int flags ) { FX_AddLine( start, end, width, width, 0, @@ -1562,10 +1562,10 @@ void FX_AddLine( vec3_t start, vec3_t end, float stScale, } //--------------------------------------------------- -void FX_AddLine( vec3_t start, vec3_t end, float stScale, - float width, float dwidth, - float sAlpha, float eAlpha, - vec3_t sRGB, vec3_t eRGB, +void FX_AddLine( vec3_t start, vec3_t end, float stScale, + float width, float dwidth, + float sAlpha, float eAlpha, + vec3_t sRGB, vec3_t eRGB, int life, qhandle_t shader, int flags ) { FX_AddLine( start, end, width, width, 0, @@ -1575,18 +1575,18 @@ void FX_AddLine( vec3_t start, vec3_t end, float stScale, } //--------------------------------------------------- -void FX_AddQuad( vec3_t origin, vec3_t normal, - vec3_t vel, vec3_t accel, - float sradius, float eradius, - float salpha, float ealpha, - vec3_t sRGB, vec3_t eRGB, +void FX_AddQuad( vec3_t origin, vec3_t normal, + vec3_t vel, vec3_t accel, + float sradius, float eradius, + float salpha, float ealpha, + vec3_t sRGB, vec3_t eRGB, float rotation, int life, qhandle_t shader, int flags ) { - FX_AddOrientedParticle( origin, normal, vel, accel, + FX_AddOrientedParticle( origin, normal, vel, accel, sradius, eradius, 0.0f, salpha, ealpha, 0.0f, sRGB, eRGB, 0.0f, - rotation, 0.0f, + rotation, 0.0f, NULL, NULL, 0.0f, 0, 0, life, shader, 0 ); } diff --git a/codeJK2/cgame/FxUtil.h b/codeJK2/cgame/FxUtil.h index 7aed5d510e..4a708f7d37 100644 --- a/codeJK2/cgame/FxUtil.h +++ b/codeJK2/cgame/FxUtil.h @@ -36,12 +36,12 @@ void FX_Stop( void ); // ditches all active effects without touching the templat bool FX_ActiveFx(void); // returns whether there are any active or scheduled effects -CParticle *FX_AddParticle( const vec3_t org, const vec3_t vel, const vec3_t accel, - float size1, float size2, float sizeParm, - float alpha1, float alpha2, float alphaParm, +CParticle *FX_AddParticle( const vec3_t org, const vec3_t vel, const vec3_t accel, + float size1, float size2, float sizeParm, + float alpha1, float alpha2, float alphaParm, const vec3_t rgb1, const vec3_t rgb2, float rgbParm, float rotation, float rotationDelta, - const vec3_t min, const vec3_t max, float elasticity, + const vec3_t min, const vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags ); @@ -52,7 +52,7 @@ CParticle *FX_AddParticle( int clientID, const vec3_t org, const vec3_t vel, con float rotation, float rotationDelta, int killTime, qhandle_t shader, int flags ); -CLine *FX_AddLine( vec3_t start, vec3_t end, +CLine *FX_AddLine( vec3_t start, vec3_t end, float size1, float size2, float sizeParm, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, @@ -68,25 +68,25 @@ CElectricity *FX_AddElectricity( vec3_t start, vec3_t end, float size1, float si vec3_t sRGB, vec3_t eRGB, float rgbParm, float chaos, int killTime, qhandle_t shader, int flags ); -CTail *FX_AddTail( vec3_t org, vec3_t vel, vec3_t accel, - float size1, float size2, float sizeParm, +CTail *FX_AddTail( vec3_t org, vec3_t vel, vec3_t accel, + float size1, float size2, float sizeParm, float length1, float length2, float lengthParm, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags ); -CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel, - float size1, float size2, float sizeParm, +CTail *FX_AddTail( int clientID, vec3_t org, vec3_t vel, vec3_t accel, + float size1, float size2, float sizeParm, float length1, float length2, float lengthParm, float alpha1, float alpha2, float alphaParm, vec3_t sRGB, vec3_t eRGB, float rgbParm, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int killTime, qhandle_t shader, int flags ); -CCylinder *FX_AddCylinder( vec3_t start, vec3_t normal, +CCylinder *FX_AddCylinder( vec3_t start, vec3_t normal, float size1s, float size1e, float size1Parm, float size2s, float size2e, float size2Parm, float length1, float length2, float lengthParm, @@ -99,7 +99,7 @@ CEmitter *FX_AddEmitter( vec3_t org, vec3_t vel, vec3_t accel, float alpha1, float alpha2, float alphaParm, vec3_t rgb1, vec3_t rgb2, float rgbParm, vec3_t angs, vec3_t deltaAngs, - vec3_t min, vec3_t max, float elasticity, + vec3_t min, vec3_t max, float elasticity, int deathID, int impactID, int emitterID, float density, float variance, int killTime, qhandle_t model, int flags ); @@ -129,38 +129,38 @@ CFlash *FX_AddFlash( vec3_t origin, vec3_t sRGB, vec3_t eRGB, float rgbParm, // Included for backwards compatibility with CHC and for doing quick programmatic effects. -void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, - float scale, float dscale, - float sAlpha, float eAlpha, - float rotation, float bounce, +void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, + float scale, float dscale, + float sAlpha, float eAlpha, + float rotation, float bounce, int life, qhandle_t shader, int flags = 0 ); -void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, - float scale, float dscale, - float sAlpha, float eAlpha, - vec3_t sRGB, vec3_t eRGB, - float rotation, float bounce, +void FX_AddSprite( vec3_t origin, vec3_t vel, vec3_t accel, + float scale, float dscale, + float sAlpha, float eAlpha, + vec3_t sRGB, vec3_t eRGB, + float rotation, float bounce, int life, qhandle_t shader, int flags = 0 ); -void FX_AddLine( vec3_t start, vec3_t end, float stScale, - float width, float dwidth, - float sAlpha, float eAlpha, +void FX_AddLine( vec3_t start, vec3_t end, float stScale, + float width, float dwidth, + float sAlpha, float eAlpha, int life, qhandle_t shader, int flags = 0 ); -void FX_AddLine( vec3_t start, vec3_t end, float stScale, - float width, float dwidth, - float sAlpha, float eAlpha, - vec3_t sRGB, vec3_t eRGB, +void FX_AddLine( vec3_t start, vec3_t end, float stScale, + float width, float dwidth, + float sAlpha, float eAlpha, + vec3_t sRGB, vec3_t eRGB, int life, qhandle_t shader, int flags = 0 ); -void FX_AddQuad( vec3_t origin, vec3_t normal, - vec3_t vel, vec3_t accel, - float sradius, float eradius, - float salpha, float ealpha, - vec3_t sRGB, vec3_t eRGB, +void FX_AddQuad( vec3_t origin, vec3_t normal, + vec3_t vel, vec3_t accel, + float sradius, float eradius, + float salpha, float ealpha, + vec3_t sRGB, vec3_t eRGB, float rotation, int life, qhandle_t shader, int flags = 0 ); -CBezier *FX_AddBezier( const vec3_t start, const vec3_t end, +CBezier *FX_AddBezier( const vec3_t start, const vec3_t end, const vec3_t control1, const vec3_t control1Vel, const vec3_t control2, const vec3_t control2Vel, float size1, float size2, float sizeParm, diff --git a/codeJK2/cgame/animtable.h b/codeJK2/cgame/animtable.h index c7911b3e00..4c29d0cf5a 100644 --- a/codeJK2/cgame/animtable.h +++ b/codeJK2/cgame/animtable.h @@ -36,24 +36,24 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_DEATH5), //# Fifth Death anim ENUM2STRING(BOTH_DEATH6), //# Sixth Death anim ENUM2STRING(BOTH_DEATH7), //# Seventh Death anim - ENUM2STRING(BOTH_DEATH8), //# - ENUM2STRING(BOTH_DEATH9), //# - ENUM2STRING(BOTH_DEATH10), //# + ENUM2STRING(BOTH_DEATH8), //# + ENUM2STRING(BOTH_DEATH9), //# + ENUM2STRING(BOTH_DEATH10), //# ENUM2STRING(BOTH_DEATH11), //# - ENUM2STRING(BOTH_DEATH12), //# - ENUM2STRING(BOTH_DEATH13), //# - ENUM2STRING(BOTH_DEATH14), //# - ENUM2STRING(BOTH_DEATH15), //# - ENUM2STRING(BOTH_DEATH16), //# - ENUM2STRING(BOTH_DEATH17), //# - ENUM2STRING(BOTH_DEATH18), //# - ENUM2STRING(BOTH_DEATH19), //# - ENUM2STRING(BOTH_DEATH20), //# - ENUM2STRING(BOTH_DEATH21), //# - ENUM2STRING(BOTH_DEATH22), //# - ENUM2STRING(BOTH_DEATH23), //# - ENUM2STRING(BOTH_DEATH24), //# - ENUM2STRING(BOTH_DEATH25), //# + ENUM2STRING(BOTH_DEATH12), //# + ENUM2STRING(BOTH_DEATH13), //# + ENUM2STRING(BOTH_DEATH14), //# + ENUM2STRING(BOTH_DEATH15), //# + ENUM2STRING(BOTH_DEATH16), //# + ENUM2STRING(BOTH_DEATH17), //# + ENUM2STRING(BOTH_DEATH18), //# + ENUM2STRING(BOTH_DEATH19), //# + ENUM2STRING(BOTH_DEATH20), //# + ENUM2STRING(BOTH_DEATH21), //# + ENUM2STRING(BOTH_DEATH22), //# + ENUM2STRING(BOTH_DEATH23), //# + ENUM2STRING(BOTH_DEATH24), //# + ENUM2STRING(BOTH_DEATH25), //# ENUM2STRING(BOTH_DEATHFORWARD1), //# First Death in which they get thrown forward ENUM2STRING(BOTH_DEATHFORWARD2), //# Second Death in which they get thrown forward @@ -85,24 +85,24 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_DEAD5), //# Fifth Death finished pose ENUM2STRING(BOTH_DEAD6), //# Sixth Death finished pose ENUM2STRING(BOTH_DEAD7), //# Seventh Death finished pose - ENUM2STRING(BOTH_DEAD8), //# - ENUM2STRING(BOTH_DEAD9), //# - ENUM2STRING(BOTH_DEAD10), //# + ENUM2STRING(BOTH_DEAD8), //# + ENUM2STRING(BOTH_DEAD9), //# + ENUM2STRING(BOTH_DEAD10), //# ENUM2STRING(BOTH_DEAD11), //# - ENUM2STRING(BOTH_DEAD12), //# - ENUM2STRING(BOTH_DEAD13), //# - ENUM2STRING(BOTH_DEAD14), //# - ENUM2STRING(BOTH_DEAD15), //# - ENUM2STRING(BOTH_DEAD16), //# - ENUM2STRING(BOTH_DEAD17), //# - ENUM2STRING(BOTH_DEAD18), //# - ENUM2STRING(BOTH_DEAD19), //# - ENUM2STRING(BOTH_DEAD20), //# - ENUM2STRING(BOTH_DEAD21), //# - ENUM2STRING(BOTH_DEAD22), //# - ENUM2STRING(BOTH_DEAD23), //# - ENUM2STRING(BOTH_DEAD24), //# - ENUM2STRING(BOTH_DEAD25), //# + ENUM2STRING(BOTH_DEAD12), //# + ENUM2STRING(BOTH_DEAD13), //# + ENUM2STRING(BOTH_DEAD14), //# + ENUM2STRING(BOTH_DEAD15), //# + ENUM2STRING(BOTH_DEAD16), //# + ENUM2STRING(BOTH_DEAD17), //# + ENUM2STRING(BOTH_DEAD18), //# + ENUM2STRING(BOTH_DEAD19), //# + ENUM2STRING(BOTH_DEAD20), //# + ENUM2STRING(BOTH_DEAD21), //# + ENUM2STRING(BOTH_DEAD22), //# + ENUM2STRING(BOTH_DEAD23), //# + ENUM2STRING(BOTH_DEAD24), //# + ENUM2STRING(BOTH_DEAD25), //# ENUM2STRING(BOTH_DEADFORWARD1), //# First thrown forward death finished pose ENUM2STRING(BOTH_DEADFORWARD2), //# Second thrown forward death finished pose ENUM2STRING(BOTH_DEADBACKWARD1), //# First thrown backward death finished pose @@ -115,7 +115,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_DEADFLOP2), //# React to being shot from Second Death finished pose ENUM2STRING(BOTH_DEADFLOP3), //# React to being shot from Third Death finished pose ENUM2STRING(BOTH_DEADFLOP4), //# React to being shot from Fourth Death finished pose - ENUM2STRING(BOTH_DEADFLOP5), //# React to being shot from Fifth Death finished pose + ENUM2STRING(BOTH_DEADFLOP5), //# React to being shot from Fifth Death finished pose ENUM2STRING(BOTH_DEADFORWARD1_FLOP), //# React to being shot First thrown forward death finished pose ENUM2STRING(BOTH_DEADFORWARD2_FLOP), //# React to being shot Second thrown forward death finished pose ENUM2STRING(BOTH_DEADBACKWARD1_FLOP), //# React to being shot First thrown backward death finished pose @@ -138,17 +138,17 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_PAIN6), //# Sixth take pain anim - from behind ENUM2STRING(BOTH_PAIN7), //# Seventh take pain anim - from behind ENUM2STRING(BOTH_PAIN8), //# Eigth take pain anim - from behind - ENUM2STRING(BOTH_PAIN9), //# - ENUM2STRING(BOTH_PAIN10), //# - ENUM2STRING(BOTH_PAIN11), //# - ENUM2STRING(BOTH_PAIN12), //# - ENUM2STRING(BOTH_PAIN13), //# - ENUM2STRING(BOTH_PAIN14), //# - ENUM2STRING(BOTH_PAIN15), //# - ENUM2STRING(BOTH_PAIN16), //# - ENUM2STRING(BOTH_PAIN17), //# - ENUM2STRING(BOTH_PAIN18), //# - ENUM2STRING(BOTH_PAIN19), //# + ENUM2STRING(BOTH_PAIN9), //# + ENUM2STRING(BOTH_PAIN10), //# + ENUM2STRING(BOTH_PAIN11), //# + ENUM2STRING(BOTH_PAIN12), //# + ENUM2STRING(BOTH_PAIN13), //# + ENUM2STRING(BOTH_PAIN14), //# + ENUM2STRING(BOTH_PAIN15), //# + ENUM2STRING(BOTH_PAIN16), //# + ENUM2STRING(BOTH_PAIN17), //# + ENUM2STRING(BOTH_PAIN18), //# + ENUM2STRING(BOTH_PAIN19), //# ENUM2STRING(BOTH_PAIN20), //# GETTING SHOCKED //# #sep ENUM2STRING(BOTH_ ATTACKS @@ -679,9 +679,9 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_STAND5_REELO), //# Reelo in his stand5 position (cin #18) ENUM2STRING(BOTH_STAND1TOSTAND5), //# Transition from stand1 to stand5 ENUM2STRING(BOTH_STAND5TOSTAND1), //# Transition from stand5 to stand1 - ENUM2STRING(BOTH_STAND5TOAIM), //# Transition of Kye aiming his gun at Desann (cin #9) - ENUM2STRING(BOTH_STAND5STARTLEDLOOKLEFT), //# Kyle turning to watch the bridge drop (cin #9) - ENUM2STRING(BOTH_STARTLEDLOOKLEFTTOSTAND5), //# Kyle returning to stand 5 from watching the bridge drop (cin #9) + ENUM2STRING(BOTH_STAND5TOAIM), //# Transition of Kye aiming his gun at Desann (cin #9) + ENUM2STRING(BOTH_STAND5STARTLEDLOOKLEFT), //# Kyle turning to watch the bridge drop (cin #9) + ENUM2STRING(BOTH_STARTLEDLOOKLEFTTOSTAND5), //# Kyle returning to stand 5 from watching the bridge drop (cin #9) ENUM2STRING(BOTH_STAND5TOSTAND8), //# Transition from stand5 to stand8 ENUM2STRING(BOTH_STAND7TOSTAND8), //# Tavion putting hands on back of chair (cin #11) ENUM2STRING(BOTH_STAND8TOSTAND5), //# Transition from stand8 to stand5 @@ -698,11 +698,11 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_CONSOLE1START), //# typing at a console ENUM2STRING(BOTH_CONSOLE1), //# typing at a console ENUM2STRING(BOTH_CONSOLE1STOP), //# typing at a console - ENUM2STRING(BOTH_CONSOLE2START), //# typing at a console with comm link in hand (cin #5) - ENUM2STRING(BOTH_CONSOLE2), //# typing at a console with comm link in hand (cin #5) - ENUM2STRING(BOTH_CONSOLE2STOP), //# typing at a console with comm link in hand (cin #5) - ENUM2STRING(BOTH_CONSOLE2HOLDCOMSTART), //# lean in to type at console while holding comm link in hand (cin #5) - ENUM2STRING(BOTH_CONSOLE2HOLDCOMSTOP), //# lean away after typing at console while holding comm link in hand (cin #5) + ENUM2STRING(BOTH_CONSOLE2START), //# typing at a console with comm link in hand (cin #5) + ENUM2STRING(BOTH_CONSOLE2), //# typing at a console with comm link in hand (cin #5) + ENUM2STRING(BOTH_CONSOLE2STOP), //# typing at a console with comm link in hand (cin #5) + ENUM2STRING(BOTH_CONSOLE2HOLDCOMSTART), //# lean in to type at console while holding comm link in hand (cin #5) + ENUM2STRING(BOTH_CONSOLE2HOLDCOMSTOP), //# lean away after typing at console while holding comm link in hand (cin #5) ENUM2STRING(BOTH_GUARD_LOOKAROUND1), //# Cradling weapon and looking around ENUM2STRING(BOTH_GUARD_IDLE1), //# Cradling weapon and standing @@ -732,9 +732,9 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_TALKGESTURE7START), //# Start touches Kyle on shoulder ENUM2STRING(BOTH_TALKGESTURE7), //# Hold touches Kyle on shoulder ENUM2STRING(BOTH_TALKGESTURE7STOP), //# Ending touches Kyle on shoulder - ENUM2STRING(BOTH_TALKGESTURE8START), //# Lando's chin hold - ENUM2STRING(BOTH_TALKGESTURE8), //# Lando's chin hold - ENUM2STRING(BOTH_TALKGESTURE8STOP), //# Lando's chin hold + ENUM2STRING(BOTH_TALKGESTURE8START), //# Lando's chin hold + ENUM2STRING(BOTH_TALKGESTURE8), //# Lando's chin hold + ENUM2STRING(BOTH_TALKGESTURE8STOP), //# Lando's chin hold ENUM2STRING(BOTH_TALKGESTURE9), //# Same as gesture 2 but with the right hand ENUM2STRING(BOTH_TALKGESTURE10), //# Shoulder shrug ENUM2STRING(BOTH_TALKGESTURE11START), //# Arms folded across chest @@ -779,9 +779,9 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_REACH1START), //# Monmothma reaching for crystal ENUM2STRING(BOTH_REACH1STOP), //# Monmothma reaching for crystal - ENUM2STRING(BOTH_EXAMINE1START), //# Start Mon Mothma examining crystal - ENUM2STRING(BOTH_EXAMINE1), //# Mon Mothma examining crystal - ENUM2STRING(BOTH_EXAMINE1STOP), //# Stop Mon Mothma examining crystal + ENUM2STRING(BOTH_EXAMINE1START), //# Start Mon Mothma examining crystal + ENUM2STRING(BOTH_EXAMINE1), //# Mon Mothma examining crystal + ENUM2STRING(BOTH_EXAMINE1STOP), //# Stop Mon Mothma examining crystal ENUM2STRING(BOTH_EXAMINE2START), //# Start Kyle tossing crystal ENUM2STRING(BOTH_EXAMINE2), //# Hold Kyle tossing crystal ENUM2STRING(BOTH_EXAMINE2STOP), //# End Kyle tossing crystal @@ -960,7 +960,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_WALKBACK2), //# Walk2 backwards ENUM2STRING(BOTH_RUNBACK1), //# Run1 backwards ENUM2STRING(BOTH_RUNBACK2), //# Run1 backwards - + //# #sep BOTH_ JUMPING ENUM2STRING(BOTH_JUMP1), //# Jump - wind-up and leave ground ENUM2STRING(BOTH_INAIR1), //# In air loop (from jump) @@ -1024,24 +1024,24 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_DIVE1), //# Dive! ENUM2STRING(BOTH_ENGAGETAUNT), - ENUM2STRING(BOTH_ARIAL_LEFT), //# - ENUM2STRING(BOTH_ARIAL_RIGHT), //# - ENUM2STRING(BOTH_CARTWHEEL_LEFT), //# - ENUM2STRING(BOTH_CARTWHEEL_RIGHT), //# - ENUM2STRING(BOTH_FLIP_LEFT), //# - ENUM2STRING(BOTH_FLIP_BACK1), //# - ENUM2STRING(BOTH_FLIP_BACK2), //# - ENUM2STRING(BOTH_FLIP_BACK3), //# - ENUM2STRING(BOTH_BUTTERFLY_LEFT), //# - ENUM2STRING(BOTH_BUTTERFLY_RIGHT), //# - ENUM2STRING(BOTH_WALL_RUN_RIGHT), //# + ENUM2STRING(BOTH_ARIAL_LEFT), //# + ENUM2STRING(BOTH_ARIAL_RIGHT), //# + ENUM2STRING(BOTH_CARTWHEEL_LEFT), //# + ENUM2STRING(BOTH_CARTWHEEL_RIGHT), //# + ENUM2STRING(BOTH_FLIP_LEFT), //# + ENUM2STRING(BOTH_FLIP_BACK1), //# + ENUM2STRING(BOTH_FLIP_BACK2), //# + ENUM2STRING(BOTH_FLIP_BACK3), //# + ENUM2STRING(BOTH_BUTTERFLY_LEFT), //# + ENUM2STRING(BOTH_BUTTERFLY_RIGHT), //# + ENUM2STRING(BOTH_WALL_RUN_RIGHT), //# ENUM2STRING(BOTH_WALL_RUN_RIGHT_FLIP),//# - ENUM2STRING(BOTH_WALL_RUN_RIGHT_STOP),//# - ENUM2STRING(BOTH_WALL_RUN_LEFT), //# + ENUM2STRING(BOTH_WALL_RUN_RIGHT_STOP),//# + ENUM2STRING(BOTH_WALL_RUN_LEFT), //# ENUM2STRING(BOTH_WALL_RUN_LEFT_FLIP),//# - ENUM2STRING(BOTH_WALL_RUN_LEFT_STOP),//# - ENUM2STRING(BOTH_WALL_FLIP_RIGHT), //# - ENUM2STRING(BOTH_WALL_FLIP_LEFT), //# + ENUM2STRING(BOTH_WALL_RUN_LEFT_STOP),//# + ENUM2STRING(BOTH_WALL_FLIP_RIGHT), //# + ENUM2STRING(BOTH_WALL_FLIP_LEFT), //# ENUM2STRING(BOTH_WALL_FLIP_FWD), //# ENUM2STRING(BOTH_KNOCKDOWN1), //# knocked backwards ENUM2STRING(BOTH_KNOCKDOWN2), //# knocked backwards hard @@ -1112,7 +1112,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = //# #sep BOTH_ SWIMMING ENUM2STRING(BOTH_SWIM_IDLE1), //# Swimming Idle 1 ENUM2STRING(BOTH_SWIMFORWARD), //# Swim forward loop - + //# #sep ENUM2STRING(BOTH_ LYING ENUM2STRING(BOTH_LIE_DOWN1), //# From a stand position), get down on ground), face down ENUM2STRING(BOTH_LIE_DOWN2), //# From a stand position), get down on ground), face up @@ -1128,7 +1128,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_INJURED2), //# Injured pose 2 ENUM2STRING(BOTH_INJURED3), //# Injured pose 3 ENUM2STRING(BOTH_INJURED6), //# Injured pose 6 - ENUM2STRING(BOTH_INJURED6ATTACKSTART), //# Start attack while in injured 6 pose + ENUM2STRING(BOTH_INJURED6ATTACKSTART), //# Start attack while in injured 6 pose ENUM2STRING(BOTH_INJURED6ATTACKSTOP), //# End attack while in injured 6 pose ENUM2STRING(BOTH_INJURED6COMBADGE), //# Hit combadge while in injured 6 pose ENUM2STRING(BOTH_INJURED6POINT), //# Chang points to door while in injured state @@ -1145,7 +1145,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_SLEEP6START), //# Kyle leaning back to sleep (cin 20) ENUM2STRING(BOTH_SLEEP6STOP), //# Kyle waking up and shaking his head (cin 21) ENUM2STRING(BOTH_SLEEP1GETUP), //# alarmed and getting up out of sleep1 pose to stand - ENUM2STRING(BOTH_SLEEP1GETUP2), //# + ENUM2STRING(BOTH_SLEEP1GETUP2), //# ENUM2STRING(BOTH_SLEEP2GETUP), //# alarmed and getting up out of sleep2 pose to stand ENUM2STRING(BOTH_SLEEP3GETUP), //# alarmed and getting up out of sleep3 pose to stand ENUM2STRING(BOTH_SLEEP3DEATH), //# death in chair), from sleep3 idle @@ -1220,7 +1220,7 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_COCKPIT_CONSOLE1), //# type at controls ENUM2STRING(BOTH_COCKPIT_CONSOLE2), //# type at controls - ENUM2STRING(BOTH_COCKPIT_CONSOLE2_PARTIAL), //# last part of console2 anim (cin #1) used by Jan + ENUM2STRING(BOTH_COCKPIT_CONSOLE2_PARTIAL), //# last part of console2 anim (cin #1) used by Jan ENUM2STRING(BOTH_COCKPIT_HEADNOD), //# nod head yes while sitting ENUM2STRING(BOTH_COCKPIT_HEADSHAKE), //# shake head no while sitting @@ -1234,11 +1234,11 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(BOTH_COCKPIT_TALKGESTURE7STOP), //# Lando's supporting hand away from Kyle (cin #21) ENUM2STRING(BOTH_COCKPIT_TALKGESTURE8START), //# Hand to Lando's chin (cin #21) ENUM2STRING(BOTH_COCKPIT_TALKGESTURE8STOP), //# hand away from Lando's chin *cin #21) - ENUM2STRING(BOTH_COCKPIT_TALKGESTURE11START), //# - ENUM2STRING(BOTH_COCKPIT_TALKGESTURE11STOP), //# + ENUM2STRING(BOTH_COCKPIT_TALKGESTURE11START), //# + ENUM2STRING(BOTH_COCKPIT_TALKGESTURE11STOP), //# - ENUM2STRING(BOTH_COCKPIT_SLEEP6START), //# - ENUM2STRING(BOTH_COCKPIT_SLEEP6STOP), //# + ENUM2STRING(BOTH_COCKPIT_SLEEP6START), //# + ENUM2STRING(BOTH_COCKPIT_SLEEP6STOP), //# //================================================= //ANIMS IN WHICH ONLY THE UPPER OBJECTS ARE IN MD3 @@ -1377,10 +1377,10 @@ stringID_table_t animTable [MAX_ANIMATIONS+1] = ENUM2STRING(FACE_TALK2), //# semi-quiet ENUM2STRING(FACE_TALK3), //# semi-loud ENUM2STRING(FACE_TALK4), //# loud - ENUM2STRING(FACE_ALERT), //# - ENUM2STRING(FACE_SMILE), //# - ENUM2STRING(FACE_FROWN), //# - ENUM2STRING(FACE_DEAD), //# + ENUM2STRING(FACE_ALERT), //# + ENUM2STRING(FACE_SMILE), //# + ENUM2STRING(FACE_FROWN), //# + ENUM2STRING(FACE_DEAD), //# //must be terminated {NULL,-1} diff --git a/codeJK2/cgame/cg_camera.cpp b/codeJK2/cgame/cg_camera.cpp index 5abb11956a..a25020850d 100644 --- a/codeJK2/cgame/cg_camera.cpp +++ b/codeJK2/cgame/cg_camera.cpp @@ -81,7 +81,7 @@ void CGCam_Enable( void ) client_camera.bar_alpha_source = 0.0f; client_camera.bar_alpha_dest = 1.0f; - + client_camera.bar_height_source = 0.0f; client_camera.bar_height_dest = 480/10; client_camera.bar_height = 0.0f; @@ -142,7 +142,7 @@ void CGCam_Disable( void ) client_camera.bar_alpha_source = 1.0f; client_camera.bar_alpha_dest = 0.0f; - + client_camera.bar_height_source = 480/10; client_camera.bar_height_dest = 0.0f; @@ -200,7 +200,7 @@ void CGCam_Move( vec3_t dest, float duration ) client_camera.info_state |= CAMERA_MOVING; VectorCopy( dest, client_camera.origin2 ); - + client_camera.move_duration = duration; client_camera.move_time = cg.time; } @@ -242,7 +242,7 @@ void CGCam_Pan( vec3_t dest, vec3_t panDirection, float duration ) //FIXME: make the dest an absolute value, and pass in a //panDirection as well. If a panDirection's axis value is //zero, find the shortest difference for that axis. - //Store the delta in client_camera.angles2. + //Store the delta in client_camera.angles2. for( i = 0; i < 3; i++ ) { dest[i] = AngleNormalize360( dest[i] ); @@ -300,7 +300,7 @@ void CGCam_Pan( vec3_t dest, vec3_t panDirection, float duration ) //VectorCopy( dest, client_camera.angles2 ); client_camera.info_state |= CAMERA_PANNING; - + client_camera.pan_duration = duration; client_camera.pan_time = cg.time; } @@ -332,10 +332,10 @@ void CGCam_Roll( float dest, float duration ) //FIXME/NOTE: this will override current panning!!! client_camera.info_state |= CAMERA_PANNING; - + VectorCopy( client_camera.angles, client_camera.angles2 ); client_camera.angles2[2] = AngleDelta( dest, client_camera.angles[2] ); - + client_camera.pan_duration = duration; client_camera.pan_time = cg.time; } @@ -447,7 +447,7 @@ void CGCam_Follow( const char *cameraGroup, float speed, float initLerp ) {//Turn off all aiming return; } - + if ( Q_stricmp("NULL", (char *)cameraGroup) == 0 ) {//Turn off all aiming return; @@ -661,7 +661,7 @@ void CGCam_FollowUpdate ( void ) centity_t *fromCent = NULL; int num_subjects = 0, i; qboolean focused = qfalse; - + if ( client_camera.cameraGroup[0] ) { //Stay centered in my cameraGroup, if I have one @@ -718,11 +718,11 @@ void CGCam_FollowUpdate ( void ) else { VectorCopy(from->currentOrigin, focus[num_subjects]); - } + } //FIXME: make a list here of their s.numbers instead so we can do other stuff with the list below if ( from->client ) {//Track to their eyes - FIXME: maybe go off a tag? - //FIXME: + //FIXME: //Based on FOV and distance to subject from camera, pick the point that //keeps eyes 3/4 up from bottom of screen... what about bars? focus[num_subjects][2] += from->client->ps.viewheight; @@ -735,7 +735,7 @@ void CGCam_FollowUpdate ( void ) num_subjects++; } - if ( !num_subjects ) // Bad cameragroup + if ( !num_subjects ) // Bad cameragroup { #ifndef FINAL_BUILD gi.Printf(S_COLOR_RED"ERROR: Camera Focus unable to locate cameragroup: %s\n", client_camera.cameraGroup); @@ -774,7 +774,7 @@ void CGCam_FollowUpdate ( void ) //Get desired angle vectoangles(dir, cameraAngles); - + if ( client_camera.followInitLerp ) {//Lerping float frac = cg.frametime/100.0f * client_camera.followSpeed/100.f; @@ -830,10 +830,10 @@ void CGCam_TrackEntUpdate ( void ) reached = qtrue; } } - + if ( trackEnt && reached ) { - + if ( trackEnt->target && trackEnt->target[0] ) {//Find our next path_corner newTrackEnt = G_Find( NULL, FOFS(targetname), trackEnt->target ); @@ -867,8 +867,8 @@ void CGCam_TrackEntUpdate ( void ) if ( newTrackEnt ) {//Update will lerp this - client_camera.info_state |= CAMERA_TRACKING; - client_camera.trackEntNum = newTrackEnt->s.number; + client_camera.info_state |= CAMERA_TRACKING; + client_camera.trackEntNum = newTrackEnt->s.number; VectorCopy( newTrackEnt->currentOrigin, client_camera.trackToOrg ); } @@ -913,7 +913,7 @@ void CGCam_TrackUpdate ( void ) return; } else if ( client_camera.subjectSpeed > 0.05f ) - {//Don't start moving until subject moves + {//Don't start moving until subject moves VectorSubtract( client_camera.subjectPos, client_camera.origin, vec ); dist = VectorNormalize(vec); dot = DotProduct(goalVec, vec); @@ -940,13 +940,13 @@ void CGCam_TrackUpdate ( void ) adjust = (client_camera.distance - dist);//Speed up } } - + //Speed of the focus + our error //desiredSpeed = aimCent->gent->speed + (adjust * cg.frametime/100.0f);//cg.frameInterpolation); desiredSpeed = (adjust);// * cg.frametime/100.0f);//cg.frameInterpolation); - + //self->moveInfo.speed = desiredSpeed; - + //Don't change speeds faster than 10 every 10th of a second float max_allowed_accel = MAX_ACCEL_PER_FRAME * (cg.frametime/100.0f); @@ -974,7 +974,7 @@ void CGCam_TrackUpdate ( void ) { //slowDown = qtrue; } - + //FIXME: this probably isn't right, round it out more VectorScale( goalVec, cg.frametime/100.0f, goalVec ); @@ -1113,7 +1113,7 @@ void CGCam_Update( void ) } } } - else + else { checkFollow = qtrue; } @@ -1193,7 +1193,7 @@ void CGCam_DrawWideScreen( void ) modulate[0] = modulate[1] = modulate[2] = 0.0f; modulate[3] = client_camera.bar_alpha; - + CG_FillRect( cg.refdef.x, cg.refdef.y, 640, client_camera.bar_height, modulate ); CG_FillRect( cg.refdef.x, cg.refdef.y + 480 - client_camera.bar_height, 640, client_camera.bar_height, modulate ); } @@ -1336,7 +1336,7 @@ void CGCam_StartRoff( char *roff ) CGCam_FollowDisable(); CGCam_TrackDisable(); - // Set up the roff state info..we'll hijack the moving and panning code until told otherwise + // Set up the roff state info..we'll hijack the moving and panning code until told otherwise // ...CAMERA_FOLLOWING would be a case that could override this.. client_camera.info_state |= CAMERA_MOVING; client_camera.info_state |= CAMERA_PANNING; @@ -1374,7 +1374,7 @@ static void CGCam_StopRoff( void ) ------------------------------------------------------ CGCam_Roff -Applies the sampled roff data to the camera and does +Applies the sampled roff data to the camera and does the lerping itself...this is done because the current camera interpolation doesn't seem to work all that great when you are adjusting the camera org and angles @@ -1422,7 +1422,7 @@ static void CGCam_Roff( void ) #ifdef _DEBUG if ( cg_developer.integer ) { - Com_Printf( S_COLOR_GREEN"CamROFF : o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", + Com_Printf( S_COLOR_GREEN"CamROFF : o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", org[0], org[1], org[2], ang[0], ang[1], ang[2] ); } @@ -1454,7 +1454,7 @@ static void CGCam_Roff( void ) if ( ++client_camera.roff_frame >= roff->frames ) { - CGCam_StopRoff(); + CGCam_StopRoff(); return; } diff --git a/codeJK2/cgame/cg_camera.h b/codeJK2/cgame/cg_camera.h index 7f068458bb..d3772ab734 100644 --- a/codeJK2/cgame/cg_camera.h +++ b/codeJK2/cgame/cg_camera.h @@ -50,7 +50,7 @@ typedef struct camera_s //Position / Facing information vec3_t origin; vec3_t angles; - + vec3_t origin2; vec3_t angles2; @@ -95,7 +95,7 @@ typedef struct camera_s float bar_alpha_source; float bar_alpha_dest; float bar_time; - + float bar_height_source; float bar_height_dest; float bar_height; @@ -123,9 +123,9 @@ typedef struct camera_s // ROFF information - char sRoff[MAX_QPATH]; // name of a cached roff + char sRoff[MAX_QPATH]; // name of a cached roff int roff_frame; // current frame in the roff data - int next_roff_time; // time when it's ok to apply the next roff frame + int next_roff_time; // time when it's ok to apply the next roff frame } camera_t; diff --git a/codeJK2/cgame/cg_consolecmds.cpp b/codeJK2/cgame/cg_consolecmds.cpp index 6a67a67b55..7be6eb72f3 100644 --- a/codeJK2/cgame/cg_consolecmds.cpp +++ b/codeJK2/cgame/cg_consolecmds.cpp @@ -63,7 +63,7 @@ Debugging command to print the current position */ static void CG_Viewpos_f (void) { CG_Printf ("%s (%i %i %i) : %i\n", cgs.mapname, (int)cg.refdef.vieworg[0], - (int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2], + (int)cg.refdef.vieworg[1], (int)cg.refdef.vieworg[2], (int)cg.refdefViewAngles[YAW]); } @@ -74,7 +74,7 @@ void CG_WriteCam_f (void) static int numCams; numCams++; - + targetname = CG_Argv(1); if( !targetname || !targetname[0] ) @@ -184,10 +184,10 @@ void CG_ToggleLAGoggles( void ) } } -void CG_LoadHud_f( void) +void CG_LoadHud_f( void) { const char *hudSet = cg_hudFiles.string; - if ( hudSet[0] == '\0' ) + if ( hudSet[0] == '\0' ) hudSet = "ui/jk2hud.txt"; CG_LoadMenus(hudSet); diff --git a/codeJK2/cgame/cg_credits.cpp b/codeJK2/cgame/cg_credits.cpp index 4ffde22e99..7ce10c56f1 100644 --- a/codeJK2/cgame/cg_credits.cpp +++ b/codeJK2/cgame/cg_credits.cpp @@ -126,7 +126,7 @@ static const char *Capitalize( const char *psTest ) static char sTemp[MAX_LINE_BYTES]; Q_strncpyz(sTemp, psTest, sizeof(sTemp)); - + if (!cgi_Language_IsAsian()) { Q_strupr(sTemp); // capitalise titles (if not asian!!!!) @@ -136,7 +136,7 @@ static const char *Capitalize( const char *psTest ) } static bool CountsAsWhiteSpaceForCaps( char c ) -{ +{ return !!(isspace(c) || c == '-' || c == '.' || c == '(' || c == ')'); } static const char *UpperCaseFirstLettersOnly( const char *psTest ) @@ -144,7 +144,7 @@ static const char *UpperCaseFirstLettersOnly( const char *psTest ) static char sTemp[MAX_LINE_BYTES]; Q_strncpyz(sTemp, psTest, sizeof(sTemp)); - + if (!cgi_Language_IsAsian()) { Q_strlwr(sTemp); @@ -188,7 +188,7 @@ static const char *GetSubString(std::string &strResult) if (!strlen(strResult.c_str())) return NULL; - + Q_strncpyz(sTemp,strResult.c_str(),sizeof(sTemp)); char *psSemiColon = strchr(sTemp,';'); @@ -214,7 +214,7 @@ static bool SortBySurname(const StringAndSize_t &str1, const StringAndSize_t &st { std::string::const_reverse_iterator rstart1 = std::find_if(str1.str.rbegin(), str1.str.rend(), isspace); std::string::const_reverse_iterator rstart2 = std::find_if(str2.str.rbegin(), str2.str.rend(), isspace); - + return Q_stricmp(&*rstart1.base(), &*rstart2.base()) < 0; } @@ -231,14 +231,14 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) memcpy(gv4Color,pv4Color,sizeof(gv4Color)); // memcpy so we can poke into alpha channel // first, ask the strlen of the final string... - // + // int iStrLen = cgi_SP_GetStringTextString( psStripReference, NULL, 0 ); if (!iStrLen) { #ifndef FINAL_BUILD Com_Printf("WARNING: CG_Credits_Init(): invalid text key :'%s'\n", psStripReference); #endif - return; + return; } // // malloc space to hold it... @@ -246,7 +246,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) char *psMallocText = (char *) cgi_Z_Malloc( iStrLen+1, TAG_TEMP_WORKSPACE ); // // now get the string... - // + // iStrLen = cgi_SP_GetStringTextString( psStripReference, psMallocText, iStrLen+1 ); //ensure we found a match if (!iStrLen) @@ -256,7 +256,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) #ifndef FINAL_BUILD Com_Printf("WARNING: CG_Credits_Init(): invalid text key :'%s'\n", psStripReference); #endif - return; + return; } // read whole string in and process as cards, lines etc... @@ -278,7 +278,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) while (*psTextParse != '\0') { // read a line... - // + // char sLine[MAX_LINE_BYTES]; sLine[0]='\0'; qboolean bWasCommand = qtrue; @@ -383,17 +383,17 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) switch (eMode) { case eNothing: break; - case eLine: + case eLine: { CreditLine_t CreditLine; - CreditLine.iLine = iLineNumber++; + CreditLine.iLine = iLineNumber++; CreditLine.strText = sLine; CreditData.CreditLines.push_back( CreditLine ); } break; - case eDotEntry: + case eDotEntry: { CreditLine_t CreditLine; CreditLine.iLine = iLineNumber; @@ -425,7 +425,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) } break; - case eTitle: + case eTitle: { iLineNumber++; // leading blank line @@ -441,7 +441,7 @@ void CG_Credits_Init( const char *psStripReference, vec4_t *pv4Color ) case eCard: { CreditCard_t CreditCard; - + std::string strResult(sLine); const char *p; while ((p=GetSubString(strResult)) != NULL) diff --git a/codeJK2/cgame/cg_draw.cpp b/codeJK2/cgame/cg_draw.cpp index 35b02669eb..d0a0df6603 100644 --- a/codeJK2/cgame/cg_draw.cpp +++ b/codeJK2/cgame/cg_draw.cpp @@ -102,7 +102,7 @@ CG_DrawHead Used for both the status bar and the scoreboard ================ */ -void CG_DrawHead( float x, float y, float w, float h, int speaker_i, vec3_t headAngles ) +void CG_DrawHead( float x, float y, float w, float h, int speaker_i, vec3_t headAngles ) { qhandle_t hm = 0; qhandle_t hs = 0; @@ -130,7 +130,7 @@ void CG_DrawHead( float x, float y, float w, float h, int speaker_i, vec3_t head } if ( !hm ) - { + { return; } @@ -154,7 +154,7 @@ void CG_DrawHead( float x, float y, float w, float h, int speaker_i, vec3_t head // calculate distance so the head nearly fills the box // assume heads are taller than wide - len = 0.7 * ( maxs[2] - mins[2] ); + len = 0.7 * ( maxs[2] - mins[2] ); origin[0] = len / 0.268; // len / tan( fov/2 ) CG_Draw3DModel( x, y, w, h, hm, hs, origin, headAngles ); @@ -171,9 +171,9 @@ static void CG_DrawTalk(centity_t *cent) float size; vec3_t angles; // int totalLines,y,i; - vec4_t color; + vec4_t color; - if ( cg.gameNextTextTime > cg.time) + if ( cg.gameNextTextTime > cg.time) { color[0] = colorTable[CT_BLACK][0]; color[1] = colorTable[CT_BLACK][1]; @@ -228,7 +228,7 @@ static void CG_DrawHUDRightFrame1(int x,int y) { cgi_R_SetColor( colorTable[CT_WHITE] ); // Inner gray wire frame - CG_DrawPic( x, y, 80, 80, cgs.media.HUDInnerRight ); // + CG_DrawPic( x, y, 80, 80, cgs.media.HUDInnerRight ); // } /* @@ -326,10 +326,10 @@ static void CG_DrawForcePower(centity_t *cent,int x,int y) } cgi_R_SetColor( calcColor); - CG_DrawPic( x + forceTicPos[i].x, - y + forceTicPos[i].y, - forceTicPos[i].width, - forceTicPos[i].height, + CG_DrawPic( x + forceTicPos[i].x, + y + forceTicPos[i].y, + forceTicPos[i].width, + forceTicPos[i].height, forceTicPos[i].tic ); value -= inc; @@ -412,10 +412,10 @@ static void CG_DrawAmmo(centity_t *cent,int x,int y) && cg.predicted_player_state.weaponTime > 100 )) { numColor_i = CT_LTGREY; - } - else + } + else { - if ( value > 0 ) + if ( value > 0 ) { if (cg.oldAmmoTime > cg.time) { @@ -425,14 +425,14 @@ static void CG_DrawAmmo(centity_t *cent,int x,int y) { numColor_i = CT_HUD_ORANGE; } - } - else + } + else { numColor_i = CT_RED; } } - cgi_R_SetColor( colorTable[numColor_i] ); + cgi_R_SetColor( colorTable[numColor_i] ); CG_DrawNumField(x + 29, y + 26, 3, value, 6, 12, NUM_FONT_SMALL,qfalse); inc = (float) ammoData[weaponData[cent->currentState.weapon].ammoIndex].max / MAX_TICS; @@ -459,10 +459,10 @@ static void CG_DrawAmmo(centity_t *cent,int x,int y) } cgi_R_SetColor( calcColor); - CG_DrawPic( x + ammoTicPos[i].x, - y + ammoTicPos[i].y, - ammoTicPos[i].width, - ammoTicPos[i].height, + CG_DrawPic( x + ammoTicPos[i].x, + y + ammoTicPos[i].y, + ammoTicPos[i].width, + ammoTicPos[i].height, ammoTicPos[i].tic ); value -= inc; @@ -479,7 +479,7 @@ static void CG_DrawHUDLeftFrame1(int x,int y) { // Inner gray wire frame cgi_R_SetColor( colorTable[CT_WHITE] ); - CG_DrawPic( x, y, 80, 80, cgs.media.HUDInnerLeft ); + CG_DrawPic( x, y, 80, 80, cgs.media.HUDInnerLeft ); } /* @@ -511,18 +511,18 @@ static void CG_DrawHealth(int x,int y) calcColor[0] *= healthPercent; calcColor[1] *= healthPercent; calcColor[2] *= healthPercent; - cgi_R_SetColor( calcColor); + cgi_R_SetColor( calcColor); CG_DrawPic( x, y, 80, 80, cgs.media.HUDHealth ); // Draw the ticks if (cg.HUDHealthFlag) { - cgi_R_SetColor( colorTable[CT_HUD_RED] ); + cgi_R_SetColor( colorTable[CT_HUD_RED] ); CG_DrawPic( x, y, 80, 80, cgs.media.HUDHealthTic ); } - cgi_R_SetColor( colorTable[CT_HUD_RED] ); - CG_DrawNumField (x + 16, y + 40, 3, ps->stats[STAT_HEALTH], 6, 12, + cgi_R_SetColor( colorTable[CT_HUD_RED] ); + CG_DrawNumField (x + 16, y + 40, 3, ps->stats[STAT_HEALTH], 6, 12, NUM_FONT_SMALL,qtrue); } @@ -552,8 +552,8 @@ static void CG_DrawArmor(int x,int y) calcColor[0] *= armorPercent; calcColor[1] *= armorPercent; calcColor[2] *= armorPercent; - cgi_R_SetColor( calcColor); - CG_DrawPic( x, y, 80, 80, cgs.media.HUDArmor1 ); + cgi_R_SetColor( calcColor); + CG_DrawPic( x, y, 80, 80, cgs.media.HUDArmor1 ); // Inner Armor circular if (armorPercent>0) @@ -568,7 +568,7 @@ static void CG_DrawArmor(int x,int y) calcColor[0] *= armorPercent; calcColor[1] *= armorPercent; calcColor[2] *= armorPercent; - cgi_R_SetColor( calcColor); + cgi_R_SetColor( calcColor); CG_DrawPic( x, y, 80, 80, cgs.media.HUDArmor2 ); // Inner Armor circular /* if (ps->stats[STAT_ARMOR]) // Is there armor? Draw the HUD Armor TIC @@ -601,12 +601,12 @@ static void CG_DrawArmor(int x,int y) if (cg.HUDArmorFlag) { - cgi_R_SetColor( colorTable[CT_HUD_GREEN] ); - CG_DrawPic( x, y, 80, 80, cgs.media.HUDArmorTic ); + cgi_R_SetColor( colorTable[CT_HUD_GREEN] ); + CG_DrawPic( x, y, 80, 80, cgs.media.HUDArmorTic ); } */ - cgi_R_SetColor( colorTable[CT_HUD_GREEN] ); - CG_DrawNumField (x + 16 + 14, y + 40 + 14, 3, ps->stats[STAT_ARMOR], 6, 12, + cgi_R_SetColor( colorTable[CT_HUD_GREEN] ); + CG_DrawNumField (x + 16 + 14, y + 40 + 14, 3, ps->stats[STAT_ARMOR], 6, 12, NUM_FONT_SMALL,qfalse); } @@ -664,12 +664,12 @@ static qboolean CG_DrawCustomHealthHud( centity_t *cent ) // we just calc the display value from the sum of health and armor if ( g_entities[cg.snap->ps.viewEntity].activator ) // ensure we can look back to the atst_drivable to get the max health { - health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR] ) / + health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR] ) / (float)(g_entities[cg.snap->ps.viewEntity].max_health + g_entities[cg.snap->ps.viewEntity].activator->max_health ); } else { - health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR]) / + health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR]) / (float)(g_entities[cg.snap->ps.viewEntity].max_health + 800 ); // hacked max armor since we don't have an activator...should never happen } @@ -748,14 +748,14 @@ extern void cgi_UI_Menu_Paint( void *menu, qboolean force ); static void CG_DrawHUD( centity_t *cent ) { int x,y,value; - + if (cgi_UI_GetMenuInfo("lefthud",&x,&y)) { // Draw all the HUD elements --eez cgi_UI_Menu_Paint( cgi_UI_GetMenuByName( "lefthud" ), qtrue ); // Draw armor & health values - if ( cg_draw2D.integer == 2 ) + if ( cg_draw2D.integer == 2 ) { CG_DrawSmallStringColor(x+5, y - 60,va("Armor:%d",cg.snap->ps.stats[STAT_ARMOR]), colorTable[CT_HUD_GREEN] ); CG_DrawSmallStringColor(x+5, y - 40,va("Health:%d",cg.snap->ps.stats[STAT_HEALTH]), colorTable[CT_HUD_GREEN] ); @@ -773,7 +773,7 @@ static void CG_DrawHUD( centity_t *cent ) cgi_UI_Menu_Paint( cgi_UI_GetMenuByName( "righthud" ), qtrue ); // Draw armor & health values - if ( cg_draw2D.integer == 2 ) + if ( cg_draw2D.integer == 2 ) { if ( cent->currentState.weapon != WP_SABER && cent->currentState.weapon != WP_STUN_BATON && cent->gent ) { @@ -841,7 +841,7 @@ void CG_DrawDataPadHUD( centity_t *cent ) missionInfo_Updated = qfalse; // Set which force power to show. - // cg_updatedDataPadForcePower is set from Q3_Interface, because force powers would only be given + // cg_updatedDataPadForcePower is set from Q3_Interface, because force powers would only be given // from a script. if (cg_updatedDataPadForcePower1.integer) { @@ -967,7 +967,7 @@ static void CG_DrawZoomMask( void ) cgi_R_SetColor( colorTable[CT_WHITE] ); CG_DrawPic( 34, 48, 570, 362, cgs.media.binocularStatic ); } - + CG_DrawBinocularNumbers( power ); // Black out the area behind the battery display @@ -997,7 +997,7 @@ static void CG_DrawZoomMask( void ) color1[2] = 0.7f + Q_flrand(-1.0f, 1.0f) * 0.1f; color1[3] = 1.0f; cgi_R_SetColor( color1 ); - + CG_DrawPic( 4, 282 - level, 16, 16, cgs.media.binocularArrow ); } else @@ -1037,7 +1037,7 @@ static void CG_DrawZoomMask( void ) } } //------------ - // Disruptor + // Disruptor //-------------------------------- else if ( cg.zoomMode == 2 ) { @@ -1053,7 +1053,7 @@ static void CG_DrawZoomMask( void ) level = 1.0f; } - // Using a magic number to convert the zoom level to a rotation amount that correlates more or less with the zoom artwork. + // Using a magic number to convert the zoom level to a rotation amount that correlates more or less with the zoom artwork. level *= 103.0f; // Draw target mask @@ -1064,7 +1064,7 @@ static void CG_DrawZoomMask( void ) if ( level >= 99 ) { // Fully zoomed, so make the rotating insert pulse - color1[0] = 1.0f; + color1[0] = 1.0f; color1[1] = 1.0f; color1[2] = 1.0f; color1[3] = 0.7f + sin( cg.time * 0.01f ) * 0.3f; @@ -1085,7 +1085,7 @@ static void CG_DrawZoomMask( void ) max = 1.0f; } - color1[0] = (1.0f - max) * 2.0f; + color1[0] = (1.0f - max) * 2.0f; color1[1] = max * 1.5f; color1[2] = 0.0f; color1[3] = 1.0f; @@ -1147,7 +1147,7 @@ static void CG_DrawZoomMask( void ) CG_DrawPic( 34, 29, 580, 410, cgs.media.laGogglesStatic ); CG_DrawPic( 570, 140, 12, 160, cgs.media.laGogglesSideBit ); - + float light = (128-cent->gent->lightLevel) * 0.5f; if ( light < -81 ) // saber can really jack up local light levels....?magic number?? @@ -1195,7 +1195,7 @@ static void CG_DrawZoomMask( void ) CG_DrawPic( 65, 94, 16, 16, cgs.media.binocularCircle ); } - + CG_DrawPic( 0, 0, 640, 480, cgs.media.laGogglesMask ); } } @@ -1206,7 +1206,7 @@ CG_DrawStats ================ */ -static void CG_DrawStats( void ) +static void CG_DrawStats( void ) { centity_t *cent; @@ -1234,7 +1234,7 @@ static void CG_DrawStats( void ) if (( drawHud ) && ( cg_drawHUD.integer )) { - CG_DrawHUD( cent ); + CG_DrawHUD( cent ); } CG_DrawTalk(cent); @@ -1251,16 +1251,16 @@ static void CG_DrawPickupItem( void ) { float *fadeColor; value = cg.itemPickup; - if ( value && cg_items[ value ].icon != -1 ) + if ( value && cg_items[ value ].icon != -1 ) { fadeColor = CG_FadeColor( cg.itemPickupTime, 3000 ); - if ( fadeColor ) + if ( fadeColor ) { CG_RegisterItemVisuals( value ); cgi_R_SetColor( fadeColor ); CG_DrawPic( 573, 340, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon ); //CG_DrawBigString( ICON_SIZE + 16, 398, bg_itemlist[ value ].classname, fadeColor[0] ); - //CG_DrawProportionalString( ICON_SIZE + 16, 398, + //CG_DrawProportionalString( ICON_SIZE + 16, 398, // bg_itemlist[ value ].classname, CG_SMALLFONT,fadeColor ); cgi_R_SetColor( NULL ); } @@ -1292,7 +1292,7 @@ void CG_DrawCredits(void) if (cg.creditsStart) { - if ( !CG_Credits_Running() ) + if ( !CG_Credits_Running() ) { cgi_Cvar_Set( "cg_endcredits", "0" ); CMD_CGCam_Disable(); @@ -1315,7 +1315,7 @@ CROSSHAIR CG_DrawCrosshair ================= */ -static void CG_DrawCrosshair( vec3_t worldPoint ) +static void CG_DrawCrosshair( vec3_t worldPoint ) { float w, h; qhandle_t hShader; @@ -1324,7 +1324,7 @@ static void CG_DrawCrosshair( vec3_t worldPoint ) float f; float x, y; - if ( !cg_drawCrosshair.integer ) + if ( !cg_drawCrosshair.integer ) { return; } @@ -1440,7 +1440,7 @@ static void CG_DrawCrosshair( vec3_t worldPoint ) ecolor[3] = (cg.time - cg.forceCrosshairStartTime) / 300.0f; } - // clamp + // clamp if ( ecolor[3] < 0 ) { ecolor[3] = 0; @@ -1518,19 +1518,19 @@ static void CG_DrawCrosshair( vec3_t worldPoint ) if ( !Q_stricmp( "misc_panel_turret", g_entities[cg.snap->ps.viewEntity].classname )) { // draws a custom crosshair that is twice as large as normal - cgi_R_DrawStretchPic( x + cg.refdef.x + 320 - w, - y + cg.refdef.y + 240 - h, - w * 2, h * 2, 0, 0, 1, 1, cgs.media.turretCrossHairShader ); + cgi_R_DrawStretchPic( x + cg.refdef.x + 320 - w, + y + cg.refdef.y + 240 - h, + w * 2, h * 2, 0, 0, 1, 1, cgs.media.turretCrossHairShader ); } } - else + else { hShader = cgs.media.crosshairShader[ cg_drawCrosshair.integer % NUM_CROSSHAIRS ]; - cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5 * (640 - w), - y + cg.refdef.y + 0.5 * (480 - h), - w, h, 0, 0, 1, 1, hShader ); + cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5 * (640 - w), + y + cg.refdef.y + 0.5 * (480 - h), + w, h, 0, 0, 1, 1, hShader ); } if ( cg.forceCrosshairStartTime && cg_crosshairForceHint.integer ) // drawing extra bits @@ -1543,10 +1543,10 @@ static void CG_DrawCrosshair( vec3_t worldPoint ) w *= 2.0f; h *= 2.0f; - cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5f * ( 640 - w ), y + cg.refdef.y + 0.5f * ( 480 - h ), - w, h, - 0, 0, 1, 1, - cgs.media.forceCoronaShader ); + cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5f * ( 640 - w ), y + cg.refdef.y + 0.5f * ( 480 - h ), + w, h, + 0, 0, 1, 1, + cgs.media.forceCoronaShader ); } cgi_R_SetColor( NULL ); @@ -1605,13 +1605,13 @@ static void CG_ScanForRocketLock( void ) traceEnt = &g_entities[g_crosshairEntNum]; - if ( !traceEnt || g_crosshairEntNum <= 0 || g_crosshairEntNum >= ENTITYNUM_WORLD || (!traceEnt->client && traceEnt->s.weapon != WP_TURRET ) || !traceEnt->health + if ( !traceEnt || g_crosshairEntNum <= 0 || g_crosshairEntNum >= ENTITYNUM_WORLD || (!traceEnt->client && traceEnt->s.weapon != WP_TURRET ) || !traceEnt->health || ( traceEnt && traceEnt->client && traceEnt->client->ps.powerups[PW_CLOAKED] )) { // see how much locking we have int dif = ( cg.time - g_rocketLockTime ) / ( 1200.0f / 8.0f ); - // 8 is full locking....also if we just traced onto the world, + // 8 is full locking....also if we just traced onto the world, // give them 1/2 second of slop before dropping the lock if ( dif < 8 && g_rocketSlackTime + 500 < cg.time ) { @@ -1636,7 +1636,7 @@ static void CG_ScanForRocketLock( void ) { g_rocketLockTime = cg.time - 1200; // doh, hacking the time so the targetting still gets drawn full } - } + } // keep locking to this thing for one second after it gets out of view if ( g_rocketLockTime + 2000.0f < cg.time ) // since time was hacked above, I'm compensating so that 2000ms is really only 1000ms @@ -1681,7 +1681,7 @@ CG_ScanForCrosshairEntity ================= */ extern float forcePushPullRadius[]; -static void CG_ScanForCrosshairEntity( qboolean scanAll ) +static void CG_ScanForCrosshairEntity( qboolean scanAll ) { trace_t trace; gentity_t *traceEnt = NULL; @@ -1701,7 +1701,7 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) VectorMA( start, 2048, d_f, end );//4028 is max for mind trick //YES! This is very very bad... but it works! James made me do it. Really, he did. Blame James. - gi.trace( &trace, start, vec3_origin, vec3_origin, end, + gi.trace( &trace, start, vec3_origin, vec3_origin, end, ignoreEnt, MASK_OPAQUE|CONTENTS_SHOTCLIP|CONTENTS_BODY|CONTENTS_ITEM, G2_NOCOLLIDE, 10 );// ); took out CONTENTS_SOLID| so you can target people through glass.... took out CONTENTS_CORPSE so disintegrated guys aren't shown, could just remove their body earlier too... if ( trace.entityNum < ENTITYNUM_WORLD ) @@ -1785,7 +1785,7 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) if ( cg_dynamicCrosshair.integer ) {//100% accurate vec3_t d_f, d_rt, d_up; - if ( cg.snap->ps.weapon == WP_NONE || + if ( cg.snap->ps.weapon == WP_NONE || cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_STUN_BATON ) { if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD ) @@ -1824,17 +1824,17 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) VectorMA( start, 4096, cg.refdef.viewaxis[0], end );//was 8192 } //YES! This is very very bad... but it works! James made me do it. Really, he did. Blame James. - gi.trace( &trace, start, vec3_origin, vec3_origin, end, + gi.trace( &trace, start, vec3_origin, vec3_origin, end, ignoreEnt, MASK_OPAQUE|CONTENTS_SHOTCLIP|CONTENTS_BODY|CONTENTS_ITEM, G2_NOCOLLIDE, 10 );// ); took out CONTENTS_SOLID| so you can target people through glass.... took out CONTENTS_CORPSE so disintegrated guys aren't shown, could just remove their body earlier too... /* - CG_Trace( &trace, start, vec3_origin, vec3_origin, end, + CG_Trace( &trace, start, vec3_origin, vec3_origin, end, cg.snap->ps.clientNum, MASK_PLAYERSOLID|CONTENTS_CORPSE|CONTENTS_ITEM ); */ //FIXME: pick up corpses if ( trace.startsolid || trace.allsolid ) { - // trace should not be allowed to pick up anything if it started solid. I tried actually moving the trace start back, which also worked, + // trace should not be allowed to pick up anything if it started solid. I tried actually moving the trace start back, which also worked, // but the dynamic cursor drawing caused it to render around the clip of the gun when I pushed the blaster all the way into a wall. // It looked quite horrible...but, if this is bad for some reason that I don't know trace.entityNum = ENTITYNUM_NONE; @@ -1842,7 +1842,7 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) traceEnt = &g_entities[trace.entityNum]; } - + // if the object is "dead", don't show it /* if ( cg.crosshairClientNum && g_entities[cg.crosshairClientNum].health <= 0 ) @@ -1891,13 +1891,13 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) // if the player is in fog, don't show it content = cgi_CM_PointContents( trace.endpos, 0 ); - if ( content & CONTENTS_FOG ) + if ( content & CONTENTS_FOG ) { return; } // if the player is cloaked, don't show it - if ( cg_entities[ trace.entityNum ].currentState.powerups & ( 1 << PW_CLOAKED )) + if ( cg_entities[ trace.entityNum ].currentState.powerups & ( 1 << PW_CLOAKED )) { return; } @@ -1918,7 +1918,7 @@ static void CG_ScanForCrosshairEntity( qboolean scanAll ) CG_DrawCrosshairNames ===================== */ -static void CG_DrawCrosshairNames( void ) +static void CG_DrawCrosshairNames( void ) { qboolean scanAll = qfalse; centity_t *player = &cg_entities[0]; @@ -1966,8 +1966,8 @@ static void CG_DrawRocketLocking( int lockEntNum, int lockTime ) if ( CG_WorldCoordToScreenCoord( org, &cx, &cy )) { // we care about distance from enemy to eye, so this is good enough - float sz = Distance( gent->currentOrigin, cg.refdef.vieworg ) / 1024.0f; - + float sz = Distance( gent->currentOrigin, cg.refdef.vieworg ) / 1024.0f; + if ( cg.zoomMode > 0 ) { if ( cg.overrides.active & CG_OVERRIDE_FOV ) @@ -1994,7 +1994,7 @@ static void CG_DrawRocketLocking( int lockEntNum, int lockTime ) vec4_t color={0.0f,0.0f,0.0f,0.0f}; cy += sz * 0.5f; - + // well now, take our current lock time and divide that by 8 wedge slices to get the current lock amount int dif = ( cg.time - g_rocketLockTime ) / ( 1200.0f / 8.0f ); @@ -2095,10 +2095,10 @@ static float CG_DrawSnapshot( float y ) { char *s; int w; - s = va( "time:%i snap:%i cmd:%i", cg.snap->serverTime, + s = va( "time:%i snap:%i cmd:%i", cg.snap->serverTime, cg.latestSnapshotNum, cgs.serverCommandSequence ); - w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); + w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); cgi_R_Font_DrawString(635 - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f); return y + BIGCHAR_HEIGHT + 10; @@ -2141,7 +2141,7 @@ static float CG_DrawFPS( float y ) { fps = 1000 * FPS_FRAMES / total; s = va( "%ifps", fps ); - const int w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); + const int w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); cgi_R_Font_DrawString(635 - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f); return y + BIGCHAR_HEIGHT + 10; @@ -2165,7 +2165,7 @@ static float CG_DrawTimer( float y ) { s = va( "%i:%i%i", mins, tens, seconds ); - w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); + w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); cgi_R_Font_DrawString(635 - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f); return y + BIGCHAR_HEIGHT + 10; @@ -2201,7 +2201,7 @@ static void CG_DrawAmmoWarning( void ) { //s = "LOW AMMO WARNING"; } - w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f); + w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f); cgi_R_Font_DrawString(320 - w/2, 64, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 1.0f); } @@ -2253,24 +2253,24 @@ CG_Draw2D ================= */ extern void CG_SaberClashFlare( void ); -static void CG_Draw2D( void ) +static void CG_Draw2D( void ) { char text[1024]={0}; int w,y_pos; centity_t *cent = &cg_entities[cg.snap->ps.clientNum]; // if we are taking a levelshot for the menu, don't draw anything - if ( cg.levelShot ) + if ( cg.levelShot ) { return; } - if ( cg_draw2D.integer == 0 ) + if ( cg_draw2D.integer == 0 ) { return; } - if ( cg.snap->ps.pm_type == PM_INTERMISSION ) + if ( cg.snap->ps.pm_type == PM_INTERMISSION ) { CG_DrawIntermission(); return; @@ -2295,7 +2295,7 @@ static void CG_Draw2D( void ) } CG_DrawScrollText(); - CG_DrawCaptionText(); + CG_DrawCaptionText(); if ( in_camera ) {//still draw the saber clash flare, but nothing else @@ -2306,14 +2306,14 @@ static void CG_Draw2D( void ) if ( CG_RenderingFromMiscCamera()) { // purposely doing an early out when in a misc_camera, change it if needed. - + // allowing center print when in camera mode, probably just an alpha thing - dmv CG_DrawCenterString(); return; } // don't draw any status if dead - if ( cg.snap->ps.stats[STAT_HEALTH] > 0 ) + if ( cg.snap->ps.stats[STAT_HEALTH] > 0 ) { if ( !(cent->gent && cent->gent->s.eFlags & (EF_LOCKED_TO_WEAPON |EF_IN_ATST))) { @@ -2350,10 +2350,10 @@ static void CG_Draw2D( void ) float y = 0; if (cg_drawSnapshot.integer) { y=CG_DrawSnapshot(y); - } + } if (cg_drawFPS.integer) { y=CG_DrawFPS(y); - } + } if (cg_drawTimer.integer) { y=CG_DrawTimer(y); } @@ -2364,7 +2364,7 @@ static void CG_Draw2D( void ) } if (missionInfo_Updated) - { + { if (cg.predicted_player_state.pm_type != PM_DEAD) { // Was a objective given? @@ -2406,7 +2406,7 @@ static void CG_Draw2D( void ) } cgi_R_Font_DrawString(x_pos, y_pos, text, colorTable[CT_LTRED1], cgs.media.qhFontMedium, -1, 1.0f); - if (cg_updatedDataPadForcePower1.integer) + if (cg_updatedDataPadForcePower1.integer) { y_pos += 25; cgi_SP_GetStringTextString("INGAME_NEW_FORCE_POWER_INFO", text, sizeof(text) ); @@ -2418,7 +2418,7 @@ static void CG_Draw2D( void ) cgi_R_Font_DrawString(x_pos, y_pos, text, colorTable[CT_LTRED1], cgs.media.qhFontMedium, -1, 1.0f); } - if (cg_updatedDataPadObjective.integer) + if (cg_updatedDataPadObjective.integer) { y_pos += 25; cgi_SP_GetStringTextString( "INGAME_NEW_OBJECTIVE_INFO", text, sizeof(text) ); diff --git a/codeJK2/cgame/cg_drawtools.cpp b/codeJK2/cgame/cg_drawtools.cpp index badda5920b..0fd67f4e18 100644 --- a/codeJK2/cgame/cg_drawtools.cpp +++ b/codeJK2/cgame/cg_drawtools.cpp @@ -45,7 +45,7 @@ CG_Scissor Coordinates are 640*480 virtual values ================= */ -void CG_Scissor( float x, float y, float width, float height) +void CG_Scissor( float x, float y, float width, float height) { cgi_R_Scissor( x, y, width, height); @@ -74,7 +74,7 @@ A width of 0 will draw with the original image width Can also specify the exact texture coordinates ================= */ -void CG_DrawPic2( float x, float y, float width, float height, float s1, float t1, float s2, float t2, qhandle_t hShader ) +void CG_DrawPic2( float x, float y, float width, float height, float s1, float t1, float s2, float t2, qhandle_t hShader ) { cgi_R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, hShader ); } @@ -137,8 +137,8 @@ void CG_DrawChar( int x, int y, int width, int height, int ch ) { size = 0.0625; cgi_R_DrawStretchPic( ax, ay, aw, ah, - fcol, frow, - fcol + size, frow + size, + fcol, frow, + fcol + size, frow + size, cgs.media.charsetShader ); */ @@ -149,7 +149,7 @@ void CG_DrawChar( int x, int y, int width, int height, int ch ) { size = 0.03125; size2 = 0.0625; - cgi_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + size, frow + size2, + cgi_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + size, frow + size2, cgs.media.charsetShader ); } @@ -165,7 +165,7 @@ to a fixed color. Coordinates are at 640 by 480 virtual resolution ================== */ -void CG_DrawStringExt( int x, int y, const char *string, const float *setColor, +void CG_DrawStringExt( int x, int y, const char *string, const float *setColor, qboolean forceColor, qboolean shadow, int charWidth, int charHeight ) { vec4_t color; const char *s; @@ -272,7 +272,7 @@ void CG_TileClear( void ) { w = cgs.glconfig.vidWidth; h = cgs.glconfig.vidHeight; - if ( cg.refdef.x == 0 && cg.refdef.y == 0 && + if ( cg.refdef.x == 0 && cg.refdef.y == 0 && cg.refdef.width == w && cg.refdef.height == h ) { return; // full screen rendering } @@ -335,7 +335,7 @@ Take x,y positions as if 640 x 480 and scales them to the proper resolution ============== */ -void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charHeight,int style,qboolean zeroFill) +void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charHeight,int style,qboolean zeroFill) { char num[16], *ptr; int l; @@ -450,7 +450,7 @@ void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charH CG_DrawProportionalString ================= */ -void CG_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ) +void CG_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ) { //assert(!style);//call this directly if you need style (OR it into the font handle) cgi_R_Font_DrawString (x, y, str, color, cgs.media.qhFontMedium, -1, 1.0f); diff --git a/codeJK2/cgame/cg_effects.cpp b/codeJK2/cgame/cg_effects.cpp index eb2dd990d6..63add3c3ef 100644 --- a/codeJK2/cgame/cg_effects.cpp +++ b/codeJK2/cgame/cg_effects.cpp @@ -38,7 +38,7 @@ CG_MakeExplosion ==================== */ /* -localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, +localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, qhandle_t hModel, int numFrames, qhandle_t shader, int msec, qboolean isSprite, float scale, int flags ) { @@ -56,7 +56,7 @@ localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, ex = CG_AllocLocalEntity(); if ( isSprite ) { - ex->leType = LE_SPRITE_EXPLOSION; + ex->leType = LE_SPRITE_EXPLOSION; ex->refEntity.rotation = rand() % 360; ex->radius = scale; VectorScale( dir, 16, tmpVec ); @@ -81,7 +81,7 @@ localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, ex->startTime = cg.time - offset; ex->endTime = ex->startTime + msec; - + // bias the time so all shader effects start correctly ex->refEntity.shaderTime = ex->startTime / 1000.0f; @@ -108,7 +108,7 @@ localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, } */ // When calling this version, just pass in a zero for the flags -//localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, +//localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, // qhandle_t hModel, int numFrames, qhandle_t shader, // int msec, qboolean isSprite, float scale ) { // return CG_MakeExplosion( origin, dir, hModel, numFrames, shader, msec, isSprite, scale, 0 ); @@ -129,17 +129,17 @@ localEntity_t *CG_AddTempLight( vec3_t origin, float scale, vec3_t color, int ms ex = CG_AllocLocalEntity(); - ex->leType = LE_LIGHT; + ex->leType = LE_LIGHT; ex->startTime = cg.time; ex->endTime = ex->startTime + msec; - + // set origin VectorCopy ( origin, ex->refEntity.origin); VectorCopy ( origin, ex->refEntity.oldorigin ); VectorCopy( color, ex->lightColor ); - ex->light = scale; + ex->light = scale; return ex; } @@ -201,9 +201,9 @@ void CG_SurfaceExplosion( vec3_t origin, vec3_t normal, float radius, float shak //Sparks numSparks = 16 + (Q_flrand(0.0f, 1.0f) * 16.0f); - + for ( i = 0; i < numSparks; i++ ) - { + { scale = 0.25f + (Q_flrand(0.0f, 1.0f) * 2.0f); dscale = -scale*0.5; @@ -237,16 +237,16 @@ void CG_SurfaceExplosion( vec3_t origin, vec3_t normal, float radius, float shak VectorSet( temp_vel, velocity[0] + (Q_flrand(-1.0f, 1.0f) * 8.0f), velocity[1] + (Q_flrand(-1.0f, 1.0f) * 8.0f), velocity[2] + (Q_flrand(-1.0f, 1.0f) * 8.0f) ); FX_AddSprite( temp_org, - temp_vel, - NULL, - 64.0f + (Q_flrand(0.0f, 1.0f) * 32.0f), - 16.0f, - 1.0f, + temp_vel, + NULL, + 64.0f + (Q_flrand(0.0f, 1.0f) * 32.0f), + 16.0f, + 1.0f, 0.0f, 20.0f + (Q_flrand(-1.0f, 1.0f) * 90.0f), 0.5f, - 1500.0f, - cgs.media.smokeShader, FXF_USE_ALPHA_CHAN ); + 1500.0f, + cgs.media.smokeShader, FXF_USE_ALPHA_CHAN ); } //Core of the explosion @@ -399,7 +399,7 @@ Fun chunk spewer ------------------------- */ -void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins, const vec3_t maxs, +void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins, const vec3_t maxs, float speed, int numChunks, material_t chunkType, int customChunk, float baseScale ) { localEntity_t *le; @@ -565,7 +565,7 @@ void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins le->bounceFactor = 0.2f + Q_flrand(0.0f, 1.0f) * 0.2f; le->leFlags |= LEF_TUMBLE; le->ownerGentNum = owner; - le->leBounceSoundType = bounce; + le->leBounceSoundType = bounce; // Make sure that we have the desired start size set le->radius = Q_flrand( baseScale * 0.75f, baseScale * 1.25f ); @@ -579,7 +579,7 @@ void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t mins } } -void CG_TestLine( vec3_t start, vec3_t end, int time, unsigned int color, int radius ) +void CG_TestLine( vec3_t start, vec3_t end, int time, unsigned int color, int radius ) { localEntity_t *le; refEntity_t *re; @@ -626,7 +626,7 @@ void CG_TestLine( vec3_t start, vec3_t end, int time, unsigned int color, int ra // //---------------------------- -// Since we have shared verts when we tesselate the glass sheet, it helps to have a +// Since we have shared verts when we tesselate the glass sheet, it helps to have a // random offset table set up up front...so that we can have more random looking breaks. static float offX[20][20], @@ -664,7 +664,7 @@ static void CG_DoGlassQuad( vec3_t p[4], vec2_t uv[4], bool stick, int time, vec rgb1, rgb1, 0.0f, // rgb start, rgb end, rgb parm ( not used ) rotDelta, bounce, time, // rotation amount, bounce, and time to delay motion for ( zero if no delay ); 3500 + Q_flrand(0.0f, 1.0f) * 1000, // life - cgi_R_RegisterShader( "gfx/misc/test_crackle" ), + cgi_R_RegisterShader( "gfx/misc/test_crackle" ), FX_APPLY_PHYSICS | FX_ALPHA_NONLINEAR | FX_USE_ALPHA ); if ( Q_flrand(0.0f, 1.0f) > 0.95f && pol ) @@ -708,7 +708,7 @@ static void CG_CalcBiLerp( vec3_t verts[4], vec3_t subVerts[4], vec2_t uv[4] ) VectorMA( temp, uv[3][1], subVerts[3], subVerts[3] ); } // bilinear -//f(p',q') = (1 - y) × {[(1 - x) × f(p,q)] + [x × f(p,q+1)]} + y × {[(1 - x) × f(p+1,q)] + [x × f(p+1,q+1)]}. +//f(p',q') = (1 - y) × {[(1 - x) × f(p,q)] + [x × f(p,q+1)]} + y × {[(1 - x) × f(p+1,q)] + [x × f(p+1,q+1)]}. static void CG_CalcHeightWidth( vec3_t verts[4], float *height, float *width ) @@ -718,24 +718,24 @@ static void CG_CalcHeightWidth( vec3_t verts[4], float *height, float *width ) VectorSubtract( verts[3], verts[0], dir1 ); // v VectorSubtract( verts[1], verts[0], dir2 ); // p-a CrossProduct( dir1, dir2, cross ); - *width = VectorNormalize( cross ) / VectorNormalize( dir1 ); // v + *width = VectorNormalize( cross ) / VectorNormalize( dir1 ); // v VectorSubtract( verts[2], verts[0], dir2 ); // p-a CrossProduct( dir1, dir2, cross ); - *width += VectorNormalize( cross ) / VectorNormalize( dir1 ); // v + *width += VectorNormalize( cross ) / VectorNormalize( dir1 ); // v *width *= 0.5f; VectorSubtract( verts[1], verts[0], dir1 ); // v VectorSubtract( verts[2], verts[0], dir2 ); // p-a CrossProduct( dir1, dir2, cross ); - *height = VectorNormalize( cross ) / VectorNormalize( dir1 ); // v + *height = VectorNormalize( cross ) / VectorNormalize( dir1 ); // v VectorSubtract( verts[3], verts[0], dir2 ); // p-a CrossProduct( dir1, dir2, cross ); - *height += VectorNormalize( cross ) / VectorNormalize( dir1 ); // v + *height += VectorNormalize( cross ) / VectorNormalize( dir1 ); // v *height *= 0.5f; } -//Consider a line in 3D with position vector "a" and direction vector "v" and +//Consider a line in 3D with position vector "a" and direction vector "v" and // let "p" be the position vector of an arbitrary point in 3D -//dist = len( crossprod(p-a,v) ) / len(v); +//dist = len( crossprod(p-a,v) ) / len(v); void CG_InitGlass( void ) { @@ -905,9 +905,9 @@ void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, fl VectorSet2( biPoints[3], xx, zz + stepHeight ); CG_CalcBiLerp( verts, subVerts, biPoints ); - + float dif = DistanceSquared( subVerts[0], dmgPt ) * timeDecay - Q_flrand(0.0f, 1.0f) * 32; - + // If we decrease dif, we are increasing the impact area, making it more likely to blow out large holes dif -= dmgRadius * dmgRadius; @@ -974,7 +974,7 @@ void CG_DrawTargetBeam( vec3_t start, vec3_t end, vec3_t norm, const char *beamF SEffectTemplate *temp; // overriding the effect, so give us a copy first - temp = theFxScheduler.GetEffectCopy( beamFx, &handle ); + temp = theFxScheduler.GetEffectCopy( beamFx, &handle ); VectorSubtract( start, end, dir ); VectorNormalize( dir ); diff --git a/codeJK2/cgame/cg_ents.cpp b/codeJK2/cgame/cg_ents.cpp index 7fcb0c6f0d..bad8c736c9 100644 --- a/codeJK2/cgame/cg_ents.cpp +++ b/codeJK2/cgame/cg_ents.cpp @@ -42,18 +42,18 @@ Modifies the entities position and axis by the given tag location ====================== */ -void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, +void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName ) { int i; orientation_t lerped; - + // lerp the tag cgi_R_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame, 1.0f - parent->backlerp, tagName ); // FIXME: allow origin offsets along tag? VectorCopy( parent->origin, entity->origin ); - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin ); } @@ -71,7 +71,7 @@ Modifies the entities position and axis by the given tag location ====================== */ -void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, +void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName, orientation_t *tagOrient ) { int i; orientation_t lerped; @@ -84,7 +84,7 @@ void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *pare if ( tagOrient ) { VectorCopy( lerped.origin, tagOrient->origin ); - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { VectorCopy( lerped.axis[i], tagOrient->axis[i] ); } @@ -149,9 +149,9 @@ static void CG_EntityEffects( centity_t *cent ) { VectorCopy(*CG_SetEntitySoundPosition( cent ),v3Origin); // add loop sound - if ( cent->currentState.loopSound ) + if ( cent->currentState.loopSound ) { - + sfxHandle_t sfx = ( cent->currentState.eType == ET_MOVER ) ? cent->currentState.loopSound : cgs.sound_precache[ cent->currentState.loopSound ]; cgi_S_AddLoopingSound( cent->currentState.number, v3Origin/*cent->lerpOrigin*/, vec3_origin, sfx ); @@ -178,7 +178,7 @@ void CG_AddRefEntWithTransportEffect ( centity_t *cent, refEntity_t *ent ) if ( ent->renderfx & RF_PULSATE && cent->gent->owner && cent->gent->owner->health && !cent->gent->owner->s.number && cent->gent->owner->client && //only for player - cent->gent->owner->client->ps.saberEntityState == SES_RETURNING && + cent->gent->owner->client->ps.saberEntityState == SES_RETURNING && cent->currentState.saberActive == qfalse ) { // if we are the saber and we have been dropped, do a glow so it can be spotted easier @@ -351,7 +351,7 @@ CG_General ================== */ extern int CG_SaberHumSoundForEnt( gentity_t *gent ); -static void CG_General( centity_t *cent ) +static void CG_General( centity_t *cent ) { refEntity_t ent; entityState_t *s1; @@ -424,7 +424,7 @@ Ghoul2 Insert End } // player model - if (s1->number == cg.snap->ps.clientNum) + if (s1->number == cg.snap->ps.clientNum) { ent.renderfx |= RF_THIRD_PERSON; // only draw from mirrors } @@ -441,7 +441,7 @@ Ghoul2 Insert Start //------------------------------------------------------- // Start of chair //------------------------------------------------------- - if ( cent->gent->s.weapon == WP_EMPLACED_GUN || ( cent->gent->activator && cent->gent->activator->owner && + if ( cent->gent->s.weapon == WP_EMPLACED_GUN || ( cent->gent->activator && cent->gent->activator->owner && cent->gent->activator->s.eFlags & EF_LOCKED_TO_WEAPON )) { vec3_t temp; @@ -453,9 +453,9 @@ Ghoul2 Insert Start VectorSet( temp, 0, 0, 1 ); // add a big scorch mark under the gun - CG_ImpactMark( cgs.media.scavMarkShader, cent->lerpOrigin, temp, + CG_ImpactMark( cgs.media.scavMarkShader, cent->lerpOrigin, temp, 0, 1,1,1, 1.0f, qfalse, 92, qtrue ); - CG_ImpactMark( cgs.media.scavMarkShader, cent->lerpOrigin, temp, + CG_ImpactMark( cgs.media.scavMarkShader, cent->lerpOrigin, temp, 90, 1,1,1, 1.0f, qfalse, 48, qtrue ); } else @@ -468,13 +468,13 @@ Ghoul2 Insert Start } // shadow under the gun - CG_ImpactMark( cgs.media.shadowMarkShader, cent->lerpOrigin, temp, + CG_ImpactMark( cgs.media.shadowMarkShader, cent->lerpOrigin, temp, 0, 1,1,1, 1.0f, qfalse, 32, qtrue ); } } - if ( cent->gent->activator && cent->gent->activator->owner && - cent->gent->activator->s.eFlags & EF_LOCKED_TO_WEAPON && + if ( cent->gent->activator && cent->gent->activator->owner && + cent->gent->activator->s.eFlags & EF_LOCKED_TO_WEAPON && cent->gent->activator->owner->s.number == cent->currentState.number ) // gun number must be same as current entities number { centity_t *cc = &cg_entities[cent->gent->activator->s.number]; @@ -491,7 +491,7 @@ const weaponData_t *wData = NULL; // not animating..pausing was leaving the barrels in a bad state gi.G2API_PauseBoneAnim( ¢->gent->ghoul2[cent->gent->playerModel], "model_root", cg.time ); -// gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, +// gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, // 0, 0, BONE_ANIM_OVERRIDE, 1.0f, cg.time ); } @@ -504,7 +504,7 @@ const weaponData_t *wData = NULL; bolt = cent->gent->handLBolt; } - gi.G2API_GetBoltMatrix( cent->gent->ghoul2, 0, bolt, + gi.G2API_GetBoltMatrix( cent->gent->ghoul2, 0, bolt, &boltMatrix, cent->lerpAngles, cent->lerpOrigin, cg.time, cgs.model_draw, cent->currentState.modelScale ); @@ -536,13 +536,13 @@ const weaponData_t *wData = NULL; if ( cc->currentState.eFlags & EF_FIRING || cc->currentState.eFlags & EF_ALT_FIRING ) { - gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, + gi.G2API_SetBoneAnimIndex( ¢->gent->ghoul2[cent->gent->playerModel], cent->gent->rootBone, 0, 3, BONE_ANIM_OVERRIDE_FREEZE, 0.6f, cg.time, -1, -1 ); - + if ( effect ) { // We got an effect and we're firing, so let 'er rip. - theFxScheduler.PlayEffect( effect, cc->gent->client->renderInfo.muzzlePoint, + theFxScheduler.PlayEffect( effect, cc->gent->client->renderInfo.muzzlePoint, cc->gent->client->renderInfo.muzzleDir ); } } @@ -570,14 +570,14 @@ const weaponData_t *wData = NULL; { if ( cent->gent->owner->client->ps.saberLength > 0 ) { - CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], - &cg_entities[cent->gent->s.number], NULL, ent.renderfx, + CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], + &cg_entities[cent->gent->s.number], NULL, ent.renderfx, cent->gent->weaponModel, cent->lerpOrigin, cent->lerpAngles ); } else if ( cent->gent->owner->client->ps.saberEventFlags & SEF_INWATER ) { - CG_CheckSaberInWater( &cg_entities[cent->gent->owner->s.number], - &cg_entities[cent->gent->s.number], cent->gent->weaponModel, + CG_CheckSaberInWater( &cg_entities[cent->gent->owner->s.number], + &cg_entities[cent->gent->s.number], cent->gent->weaponModel, cent->lerpOrigin, cent->lerpAngles ); } } @@ -589,8 +589,8 @@ const weaponData_t *wData = NULL; {//saber is in-flight and active, play a sound on it if ( cent->gent->owner->client->ps.saberEntityState == SES_RETURNING ) { - cgi_S_AddLoopingSound( cent->currentState.number, - cent->lerpOrigin, vec3_origin, + cgi_S_AddLoopingSound( cent->currentState.number, + cent->lerpOrigin, vec3_origin, CG_SaberHumSoundForEnt( cent->gent->owner ) ); } else @@ -609,7 +609,7 @@ const weaponData_t *wData = NULL; spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin1.wav" ); break; } - cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, + cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, spinSound ); /* if ( cg_weapons[WP_SABER].missileSound ) @@ -623,14 +623,14 @@ const weaponData_t *wData = NULL; { if ( cent->gent->owner->client->ps.saberLength > 0 ) {//only add the blade if it's on - CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], - &cg_entities[cent->gent->s.number], NULL, ent.renderfx, + CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], + &cg_entities[cent->gent->s.number], NULL, ent.renderfx, 0, cent->lerpOrigin, cent->lerpAngles ); } else if ( cent->gent->owner->client->ps.saberEventFlags & SEF_INWATER ) { - CG_CheckSaberInWater( &cg_entities[cent->gent->owner->s.number], - &cg_entities[cent->gent->s.number], 0, cent->lerpOrigin, + CG_CheckSaberInWater( &cg_entities[cent->gent->owner->s.number], + &cg_entities[cent->gent->s.number], 0, cent->lerpOrigin, cent->lerpAngles ); } } @@ -653,7 +653,7 @@ const weaponData_t *wData = NULL; { if ( cg_weapons[WP_SABER].firingSound ) { - cgi_S_AddLoopingSound( cent->currentState.number, + cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cg_weapons[WP_SABER].firingSound ); } } @@ -673,7 +673,7 @@ const weaponData_t *wData = NULL; spinSound = cgi_S_RegisterSound( "sound/weapons/saber/saberspin1.wav" ); break; } - cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, + cgi_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, spinSound ); /* if ( cg_weapons[WP_SABER].missileSound ) @@ -683,7 +683,7 @@ const weaponData_t *wData = NULL; */ } } - CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], + CG_AddSaberBlade( &cg_entities[cent->gent->owner->s.number], NULL, &ent, ent.renderfx, 0, NULL, NULL ); if ( cent->gent->owner->health ) @@ -736,7 +736,7 @@ Ghoul2 Insert End VectorMA( ent.origin, 6.6f, ent.axis[0], beamOrg );// forward // overriding the effect, so give us a copy first - temp = theFxScheduler.GetEffectCopy( "tripMine/laser", &handle ); + temp = theFxScheduler.GetEffectCopy( "tripMine/laser", &handle ); if ( temp ) { @@ -808,7 +808,7 @@ Ghoul2 Insert End float t = (float)(cent->gent->painDebounceTime - cg.time ) / 1000.0f; // Only display when we have damage - if ( t >= 0.0f && t <= 1.0f ) + if ( t >= 0.0f && t <= 1.0f ) { t *= Q_flrand(0.0f, 1.0f); @@ -817,7 +817,7 @@ Ghoul2 Insert End ent.renderfx &= ~RF_ALPHA_FADE; ent.renderfx |= RF_RGB_TINT; ent.customShader = cgi_R_RegisterShader( "gfx/misc/ion_shield" ); - + cgi_R_AddRefEntityToScene( &ent ); } } @@ -853,7 +853,7 @@ static void CG_Speaker( centity_t *cent ) { CG_Item ================== */ -static void CG_Item( centity_t *cent ) +static void CG_Item( centity_t *cent ) { refEntity_t ent; entityState_t *es; @@ -863,7 +863,7 @@ static void CG_Item( centity_t *cent ) float scale; es = ¢->currentState; - if ( es->modelindex >= bg_numItems ) + if ( es->modelindex >= bg_numItems ) { CG_Error( "Bad item index %i on entity", es->modelindex ); } @@ -872,7 +872,7 @@ Ghoul2 Insert Start */ // if set to invisible, skip - if ( (!es->modelindex && !cent->gent->ghoul2.IsValid() ) || ( es->eFlags & EF_NODRAW ) ) + if ( (!es->modelindex && !cent->gent->ghoul2.IsValid() ) || ( es->eFlags & EF_NODRAW ) ) { return; } @@ -887,7 +887,7 @@ Ghoul2 Insert End item = &bg_itemlist[ es->modelindex ]; - if ( cg_simpleItems.integer ) + if ( cg_simpleItems.integer ) { memset( &ent, 0, sizeof( ent ) ); ent.reType = RT_SPRITE; @@ -932,15 +932,15 @@ Ghoul2 Insert End // weaponInfo_t *wi; // // wi = &cg_weapons[item->giTag]; -// cent->lerpOrigin[0] -= +// cent->lerpOrigin[0] -= // wi->weaponMidpoint[0] * ent.axis[0][0] + // wi->weaponMidpoint[1] * ent.axis[1][0] + // wi->weaponMidpoint[2] * ent.axis[2][0]; -// cent->lerpOrigin[1] -= +// cent->lerpOrigin[1] -= // wi->weaponMidpoint[0] * ent.axis[0][1] + // wi->weaponMidpoint[1] * ent.axis[1][1] + // wi->weaponMidpoint[2] * ent.axis[2][1]; -// cent->lerpOrigin[2] -= +// cent->lerpOrigin[2] -= // wi->weaponMidpoint[0] * ent.axis[0][2] + // wi->weaponMidpoint[1] * ent.axis[1][2] + // wi->weaponMidpoint[2] * ent.axis[2][2]; @@ -956,7 +956,7 @@ Ghoul2 Insert End /* Ghoul2 Insert Start */ - CG_SetGhoul2Info(&ent, cent); + CG_SetGhoul2Info(&ent, cent); /* Ghoul2 Insert End */ @@ -971,7 +971,7 @@ Ghoul2 Insert End { //VectorClear( spinAngles ); spinAngles[PITCH] -= 75; } - + if( item->giType != IT_HOLOCRON ) { AnglesToAxis( spinAngles, ent.axis ); @@ -979,7 +979,7 @@ Ghoul2 Insert End // items without glow textures need to keep a minimum light value // so they are always visible -/* if (( item->giType == IT_WEAPON ) || ( item->giType == IT_ARMOR )) +/* if (( item->giType == IT_WEAPON ) || ( item->giType == IT_ARMOR )) { ent.renderfx |= RF_MINLIGHT; } @@ -1052,12 +1052,12 @@ static void CG_Missile( centity_t *cent ) { if ( cent->gent->alt_fire ) { // add trails - if ( weapon->alt_missileTrailFunc ) + if ( weapon->alt_missileTrailFunc ) weapon->alt_missileTrailFunc( cent, weapon ); // add dynamic light if ( wData->alt_missileDlight ) - cgi_R_AddLightToScene(cent->lerpOrigin, wData->alt_missileDlight, + cgi_R_AddLightToScene(cent->lerpOrigin, wData->alt_missileDlight, wData->alt_missileDlightColor[0], wData->alt_missileDlightColor[1], wData->alt_missileDlightColor[2] ); // add missile sound @@ -1071,12 +1071,12 @@ static void CG_Missile( centity_t *cent ) { else { // add trails - if ( weapon->missileTrailFunc ) + if ( weapon->missileTrailFunc ) weapon->missileTrailFunc( cent, weapon ); // add dynamic light if ( wData->missileDlight ) - cgi_R_AddLightToScene(cent->lerpOrigin, wData->missileDlight, + cgi_R_AddLightToScene(cent->lerpOrigin, wData->missileDlight, wData->missileDlightColor[0], wData->missileDlightColor[1], wData->missileDlightColor[2] ); // add missile sound @@ -1095,7 +1095,7 @@ static void CG_Missile( centity_t *cent ) { /* Ghoul2 Insert Start */ - CG_SetGhoul2Info(&ent, cent); + CG_SetGhoul2Info(&ent, cent); /* Ghoul2 Insert End @@ -1168,7 +1168,7 @@ static void CG_Mover( centity_t *cent ) { Ghoul2 Insert Start */ - CG_SetGhoul2Info(&ent, cent); + CG_SetGhoul2Info(&ent, cent); /* Ghoul2 Insert End */ @@ -1198,7 +1198,7 @@ Ghoul2 Insert End } // add the secondary model - if ( s1->solid == SOLID_BMODEL && s1->modelindex2 ) + if ( s1->solid == SOLID_BMODEL && s1->modelindex2 ) { // vec3_t org; if ( !(s1->eFlags & EF_NODRAW) ) @@ -1277,7 +1277,7 @@ void CG_Beam( centity_t *cent, int color ) { /* Ghoul2 Insert Start */ - CG_SetGhoul2Info(&ent, cent); + CG_SetGhoul2Info(&ent, cent); /* Ghoul2 Insert End @@ -1287,12 +1287,12 @@ Ghoul2 Insert End cgi_R_AddRefEntityToScene(&ent); } -static vec2_t st[] = +static vec2_t st[] = { { 0.0f, 0.0f }, { 1.0f, 0.0f }, { 1.0f, 1.0f }, { 0.0f, 1.0f } }; -void CG_Cube( vec3_t mins, vec3_t maxs, vec3_t color, float alpha ) +void CG_Cube( vec3_t mins, vec3_t maxs, vec3_t color, float alpha ) { vec3_t point[4], rot={0,0,0}; int vec[3]; @@ -1316,22 +1316,22 @@ void CG_Cube( vec3_t mins, vec3_t maxs, vec3_t color, float alpha ) point[2][vec[1]] = maxs[vec[1]]; point[2][vec[2]] = maxs[vec[2]]; - + point[3][vec[1]] = maxs[vec[1]]; point[3][vec[2]] = mins[vec[2]]; //- face point[0][vec[0]] = point[1][vec[0]] = point[2][vec[0]] = point[3][vec[0]] = mins[vec[0]]; - FX_AddPoly( point, st, 4, NULL, NULL, alpha, alpha, 0.0f, - color, color, 0.0f, rot, 0.0f, 0.0f, + FX_AddPoly( point, st, 4, NULL, NULL, alpha, alpha, 0.0f, + color, color, 0.0f, rot, 0.0f, 0.0f, 100, cgs.media.solidWhiteShader, 0 ); //+ face point[0][vec[0]] = point[1][vec[0]] = point[2][vec[0]] = point[3][vec[0]] = maxs[vec[0]]; - FX_AddPoly( point, st, 4, NULL, NULL, alpha, alpha, 0.0f, - color, color, 0.0f, rot, 0.0f, 0.0f, + FX_AddPoly( point, st, 4, NULL, NULL, alpha, alpha, 0.0f, + color, color, 0.0f, rot, 0.0f, 0.0f, 100, cgs.media.solidWhiteShader, 0 ); } } @@ -1360,7 +1360,7 @@ void CG_CubeOutline( vec3_t mins, vec3_t maxs, int time, unsigned int color, flo point3[vec[1]] = maxs[vec[1]]; point3[vec[2]] = maxs[vec[2]]; - + point4[vec[1]] = maxs[vec[1]]; point4[vec[2]] = mins[vec[2]]; @@ -1382,7 +1382,7 @@ void CG_CubeOutline( vec3_t mins, vec3_t maxs, int time, unsigned int color, flo } } -void CG_Line( vec3_t start, vec3_t end, vec3_t color, float alpha ) +void CG_Line( vec3_t start, vec3_t end, vec3_t color, float alpha ) { /*FX_AddLine( start, end, @@ -1391,8 +1391,8 @@ void CG_Line( vec3_t start, vec3_t end, vec3_t color, float alpha ) 1.0f, alpha, alpha, - color, - color, + color, + color, 100.0f, cgs.media.whiteShader );*/ } @@ -1432,7 +1432,7 @@ static void CG_Portal( centity_t *cent ) { /* Ghoul2 Insert Start */ - CG_SetGhoul2Info(&ent, cent); + CG_SetGhoul2Info(&ent, cent); /* Ghoul2 Insert End */ @@ -1503,7 +1503,7 @@ Ghoul2 Insert End */ return; } - + //FIXME: prediction on clients in timescale results in jerky positional translation if ( cent->interpolate ) { @@ -1549,7 +1549,7 @@ Ghoul2 Insert End Ghoul2 Insert End */ } - if ( cent->currentState.pos.trType == TR_INTERPOLATE ) + if ( cent->currentState.pos.trType == TR_INTERPOLATE ) { // this will linearize a sine or parabolic curve, but it is important // to not extrapolate player positions if more recent data is available @@ -1575,7 +1575,7 @@ Ghoul2 Insert End { EvaluateTrajectory( ¢->currentState.apos, cg.snap->serverTime, cent->lerpAngles ); } - if ( cent->currentState.pos.trType == TR_INTERPOLATE ) + if ( cent->currentState.pos.trType == TR_INTERPOLATE ) { EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, cent->lerpOrigin ); /* @@ -1587,7 +1587,7 @@ Ghoul2 Insert End return; } } - + // FIXME: if it's blocked, it wigs out, draws it in a predicted spot, but never // makes it there - we need to predict it in the right place if this is happens... @@ -1637,7 +1637,7 @@ Ghoul2 Insert End // FIXME: perform general error decay? } #else -void CG_CalcEntityLerpPositions( centity_t *cent ) +void CG_CalcEntityLerpPositions( centity_t *cent ) { if ( cent->currentState.number == cg.snap->ps.clientNum) { @@ -1676,7 +1676,7 @@ OutputDebugString(va("[%3d] nonext %4.2f t=%6d st = %6d nst = %6d b=%6.2f } //FIXME: prediction on clients in timescale results in jerky positional translation - if (cent->interpolate && + if (cent->interpolate && (cent->currentState.number == cg.snap->ps.clientNum || cent->interpolate && cent->currentState.pos.trType == TR_INTERPOLATE ) ) { @@ -1685,7 +1685,7 @@ OutputDebugString(va("[%3d] nonext %4.2f t=%6d st = %6d nst = %6d b=%6.2f // it would be an internal error to find an entity that interpolates without // a snapshot ahead of the current one - if ( cg.nextSnap == NULL ) + if ( cg.nextSnap == NULL ) { CG_Error( "CG_AddCEntity: cg.nextSnap == NULL" ); } @@ -1769,7 +1769,7 @@ void CG_DLightThink ( centity_t *cent ) vec4_t currentRGBA; gentity_t *owner = NULL; int i; - + if ( percentage >= 1.0f ) {//We hit the end percentage = 1.0f; @@ -1810,7 +1810,7 @@ void CG_DLightThink ( centity_t *cent ) cent->gent->e_clThinkFunc = clThinkF_NULL; cent->gent->s.eType = ET_GENERAL; cent->gent->svFlags &= ~SVF_BROADCAST; - return; + return; break; default: break; @@ -1917,7 +1917,7 @@ extern cvar_t *g_saberRealisticCombat; owner->weaponModel = -1; } } - if ( owner->client->NPC_class == CLASS_PROTOCOL + if ( owner->client->NPC_class == CLASS_PROTOCOL || g_dismemberment->integer >= 11381138 || g_saberRealisticCombat->integer ) { @@ -1942,7 +1942,7 @@ void CG_MatrixEffect ( centity_t *cent ) float totalElapsedTime = (float)(cg.time - cent->currentState.time); float elapsedTime = totalElapsedTime; if ( totalElapsedTime > cent->currentState.eventParm //MATRIX_EFFECT_TIME - || (cent->currentState.weapon&&g_entities[cent->currentState.otherEntityNum].client&&g_entities[cent->currentState.otherEntityNum].client->ps.groundEntityNum!=ENTITYNUM_NONE) + || (cent->currentState.weapon&&g_entities[cent->currentState.otherEntityNum].client&&g_entities[cent->currentState.otherEntityNum].client->ps.groundEntityNum!=ENTITYNUM_NONE) || cg.missionStatusShow ) {//time is up or this is a falling spin and they hit the ground or mission end screen is up cg.overrides.active &= ~(/*CG_OVERRIDE_3RD_PERSON_ENT|*/CG_OVERRIDE_3RD_PERSON_RNG|CG_OVERRIDE_3RD_PERSON_ANG|CG_OVERRIDE_3RD_PERSON_POF); @@ -1955,14 +1955,14 @@ void CG_MatrixEffect ( centity_t *cent ) cent->gent->e_clThinkFunc = clThinkF_NULL; return; } - else + else { while ( elapsedTime > MATRIX_EFFECT_TIME ) { elapsedTime -= MATRIX_EFFECT_TIME; } } - + MatrixMode = qtrue; //FIXME: move the position towards them and back? @@ -1973,7 +1973,7 @@ void CG_MatrixEffect ( centity_t *cent ) cg.overrides.active |= CG_OVERRIDE_3RD_PERSON_ANG; cg.overrides.thirdPersonAngle = 360.0f*elapsedTime/MATRIX_EFFECT_TIME; - if ( !cent->currentState.weapon ) + if ( !cent->currentState.weapon ) {//go ahead and do all the slowdown and vert bob stuff //slowdown float timescale = (elapsedTime/MATRIX_EFFECT_TIME); @@ -2052,7 +2052,7 @@ static void CG_Clouds( centity_t *cent ) if ( cent->gent->spawnflags & 1 ) // TUBE type, the one with a hole in the middle { ent.rotation = cent->gent->random; - ent.renderfx = RF_GROW;// tube flag + ent.renderfx = RF_GROW;// tube flag } if ( cent->gent->spawnflags & 2 ) // ALT type, uses a different shader @@ -2063,7 +2063,7 @@ static void CG_Clouds( centity_t *cent ) { ent.customShader = cgi_R_RegisterShader( "gfx/world/haze" ); } - + cgi_R_AddRefEntityToScene( &ent ); } @@ -2073,7 +2073,7 @@ CG_AddCEntity =============== */ -static void CG_AddCEntity( centity_t *cent ) +static void CG_AddCEntity( centity_t *cent ) { // event-only entities will have been dealt with already if ( cent->currentState.eType >= ET_EVENTS ) { @@ -2168,24 +2168,24 @@ void CG_AddPacketEntities( void ) { playerState_t *ps; // set cg.frameInterpolation - if ( cg.nextSnap ) + if ( cg.nextSnap ) { int delta; delta = (cg.nextSnap->serverTime - cg.snap->serverTime); - if ( delta == 0 ) + if ( delta == 0 ) { cg.frameInterpolation = 0; - } - else + } + else { cg.frameInterpolation = (float)( cg.time - cg.snap->serverTime ) / delta; } //OutputDebugString(va("interp %4.2f ct=%6d nt=%6d st=%6d\n",cg.frameInterpolation,cg.time,cg.nextSnap->serverTime,cg.snap->serverTime)); - } - else + } + else { - cg.frameInterpolation = 0; // actually, it should never be used, because + cg.frameInterpolation = 0; // actually, it should never be used, because // no entities should be marked as interpolating //OutputDebugString(va("noterp %4.2f ct=%6d nt=%6d st=%6d\n",cg.frameInterpolation,cg.time,0,cg.snap->serverTime)); } diff --git a/codeJK2/cgame/cg_info.cpp b/codeJK2/cgame/cg_info.cpp index e8a6b5be5d..bdb726966a 100644 --- a/codeJK2/cgame/cg_info.cpp +++ b/codeJK2/cgame/cg_info.cpp @@ -28,7 +28,7 @@ along with this program; if not, see . static const int missionYpos = 79; -const char *showLoadPowersName[] = +const char *showLoadPowersName[] = { "INGAME_HEAL2", "INGAME_JUMP2", @@ -71,7 +71,7 @@ static void MissionPrint_Line(const int color, const int objectIndex, int &missi /* CG_DisplayBoxedText(70,50,500,300,finalText, cgs.media.qhFontSmall, 1.0f, - colorTable[color] + colorTable[color] ); */ if (pixelLen < 500) // One shot - small enough to print entirely on one line @@ -102,7 +102,7 @@ static void MissionPrint_Line(const int color, const int objectIndex, int &missi holdText2[1] = '\0'; strBegin = str; - while( *str ) + while( *str ) { holdText2[0] = *str; pixelLen += cgi_R_Font_StrLenPixels(holdText2, cgs.media.qhFontMedium, 1.0f); @@ -110,7 +110,7 @@ static void MissionPrint_Line(const int color, const int objectIndex, int &missi pixelLen += 2; // For kerning ++charLen; - if (pixelLen > 500 ) + if (pixelLen > 500 ) { //Reached max length of this line //step back until we find a space while ((charLen) && (*str != ' ' )) @@ -134,7 +134,7 @@ static void MissionPrint_Line(const int color, const int objectIndex, int &missi CG_DrawProportionalString(108, y, holdText, CG_SMALLFONT, colorTable[color] ); ++missionYcnt; - } + } else if (*(str+1) == '\0') { ++charLen; @@ -146,10 +146,10 @@ static void MissionPrint_Line(const int color, const int objectIndex, int &missi ++missionYcnt; break; } - ++str; + ++str; - } + } } // Special case hack @@ -272,7 +272,7 @@ static void CG_DrawForceCount( const int force, int x, float *y, const int pad,q sscanf( s, "%d",&val ); - if ((val<1) || (val> NUM_FORCE_POWERS)) + if ((val<1) || (val> NUM_FORCE_POWERS)) { return; } @@ -293,7 +293,7 @@ static void CG_DrawForceCount( const int force, int x, float *y, const int pad,q for ( int i = 0; i < val; i++ ) { - CG_DrawPic( x - iconSize - i * (iconSize + 10) , *y, iconSize, iconSize, force_icons[force] ); + CG_DrawPic( x - iconSize - i * (iconSize + 10) , *y, iconSize, iconSize, force_icons[force] ); } } @@ -333,9 +333,9 @@ static void CG_LoadScreen_PersonalInfo(void) CG_DrawForceCount( FP_SABERTHROW, x, &y, pad,&hasForcePowers ); CG_DrawForceCount( FP_SABER_OFFENSE, x, &y, pad,&hasForcePowers ); CG_DrawForceCount( FP_SABER_DEFENSE, x, &y, pad,&hasForcePowers ); - + if (hasForcePowers) - { + { cgi_SP_GetStringTextString( "INGAME_CURRENTFORCEPOWERS", text, sizeof(text) ); CG_DrawProportionalString( 200, 65, text, CG_CENTER | CG_BIGFONT, colorTable[CT_WHITE] ); } @@ -397,7 +397,7 @@ void CG_DrawInformation( void ) { levelshot = cgi_R_RegisterShaderNoMip( va( "levelshots/%s", s ) ); if (!levelshot) { - levelshot = cgi_R_RegisterShaderNoMip( "menu/art/unknownmap" ); + levelshot = cgi_R_RegisterShaderNoMip( "menu/art/unknownmap" ); } extern SavedGameJustLoaded_e g_eSavedGameJustLoaded; // hack! (hey, it's the last week of coding, ok? @@ -450,15 +450,15 @@ void CG_DrawInformation( void ) { // map-specific message (long map name) s = CG_ConfigString( CS_MESSAGE ); - if ( s[0] ) + if ( s[0] ) { if (s[0] == '@') - { + { char text[1024]={0}; cgi_SP_GetStringTextString( s+1, text, sizeof(text) ); cgi_R_Font_DrawString( 15, y, va("\"%s\"",text),colorTable[CT_WHITE],cgs.media.qhFontMedium, -1, 1.0f ); } - else + else { cgi_R_Font_DrawString( 15, y, va("\"%s\"",s),colorTable[CT_WHITE],cgs.media.qhFontMedium, -1, 1.0f ); } diff --git a/codeJK2/cgame/cg_local.h b/codeJK2/cgame/cg_local.h index fa696e1f6a..67946c5d66 100644 --- a/codeJK2/cgame/cg_local.h +++ b/codeJK2/cgame/cg_local.h @@ -55,9 +55,9 @@ along with this program; if not, see . // Zoom vars #define ZOOM_TIME 150 // not currently used? #define MAX_ZOOM_FOV 3.0f -#define ZOOM_IN_TIME 1500.0f +#define ZOOM_IN_TIME 1500.0f #define ZOOM_OUT_TIME 100.0f -#define ZOOM_START_PERCENT 0.3f +#define ZOOM_START_PERCENT 0.3f #define ITEM_BLOB_TIME 200 #define MUZZLE_FLASH_TIME 20 @@ -120,7 +120,7 @@ typedef struct { float pitchAngle; qboolean pitching; - int animationNumber; + int animationNumber; animation_t *animation; int animationTime; // time when the first frame of the animation will be exact } lerpFrame_t; @@ -143,7 +143,7 @@ typedef struct { // centity_t have a direct corespondence with gentity_t in the game, but // only the entityState_t is directly communicated to the cgame -struct centity_s +struct centity_s { entityState_t currentState; // from cg.frame entityState_t nextState; // from cg.nextFrame, if available @@ -164,7 +164,7 @@ struct centity_s int errorTime; // decay the error from this time vec3_t errorOrigin; vec3_t errorAngles; - + qboolean extrapolated; // false if origin / angles is an interpolation vec3_t rawOrigin; vec3_t rawAngles; @@ -174,7 +174,7 @@ struct centity_s // exact interpolated position of entity on this frame vec3_t lerpOrigin; vec3_t lerpAngles; - + //Pointer to corresponding gentity gentity_t *gent; }; @@ -218,7 +218,7 @@ typedef enum { LEF_NO_RANDOM_ROTATE= 0x0008 // MakeExplosion adds random rotate which could be bad in some cases } leFlag_t; -typedef enum +typedef enum { LEBS_NONE, LEBS_METAL, @@ -299,10 +299,10 @@ typedef struct { // all cg.stepTime, cg.duckTime, cg.landTime, etc are set to cg.time when the action // occurs, and they will have visible effects for #define STEP_TIME or whatever msec after - + typedef struct { int clientFrame; // incremented each frame - + qboolean levelShot; // taking a level menu screenshot // there are only one or two snapshot_t that are relevent at a time @@ -342,7 +342,7 @@ typedef struct { float landChange; // for landing hard int landTime; - + // input state sent to server int weaponSelect; int saberAnimLevelPending; @@ -380,8 +380,8 @@ typedef struct { int centerPrintLines; // Scrolling text, caption text and LCARS text use this - char printText[MAX_PRINTTEXT][128]; - int printTextY; + char printText[MAX_PRINTTEXT][128]; + int printTextY; char captionText[MAX_CAPTIONTEXT][256/*128*/]; // bosted for taiwanese squealy radio static speech in kejim post int captionTextY; @@ -504,7 +504,7 @@ Ghoul2 Insert End #define MAX_SHOWPOWERS 7 -extern int showPowers[MAX_SHOWPOWERS]; +extern int showPowers[MAX_SHOWPOWERS]; extern char *showPowersName[MAX_SHOWPOWERS]; extern int force_icons[NUM_FORCE_POWERS]; #define MAX_DPSHOWPOWERS 11 @@ -529,7 +529,7 @@ typedef struct char *file; // File name of graphic/ text if STRING int ingameEnum; // Index to ingame_text[] qhandle_t graphic; // Handle of graphic if GRAPHIC - int min; // + int min; // int max; int target; // Final value int inc; @@ -711,14 +711,14 @@ void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader void CG_DrawPic2( float x, float y, float width, float height, float s1, float t1, float s2, float t2, qhandle_t hShader ); void CG_DrawRotatePic( float x, float y, float width, float height,float angle, qhandle_t hShader ); void CG_DrawRotatePic2( float x, float y, float width, float height,float angle, qhandle_t hShader ); -void CG_DrawString( float x, float y, const char *string, +void CG_DrawString( float x, float y, const char *string, float charWidth, float charHeight, const float *modulate ); void CG_PrintInterfaceGraphics(int min,int max); void CG_DrawNumField (int x, int y, int width, int value,int charWidth,int charHeight,int style,qboolean zeroFill); void CG_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ); -void CG_DrawStringExt( int x, int y, const char *string, const float *setColor, +void CG_DrawStringExt( int x, int y, const char *string, const float *setColor, qboolean forceColor, qboolean shadow, int charWidth, int charHeight ); void CG_DrawSmallStringColor( int x, int y, const char *s, vec4_t color ); @@ -744,7 +744,7 @@ void CG_GameText(int y ); // void CG_DrawScrollText( void ); void CG_DrawCaptionText( void ); -void CG_DrawCenterString( void ); +void CG_DrawCenterString( void ); // @@ -759,7 +759,7 @@ void CG_GetTagWorldPosition( refEntity_t *model, char *tag, vec3_t pos, vec3_t a // cg_predict.c // int CG_PointContents( const vec3_t point, int passEntityNum ); -void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, +void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const int skipNumber, const int mask, const EG2_Collision eG2TraceType=G2_NOCOLLIDE, const int useLod=0 ); void CG_PredictPlayerState( void ); @@ -779,9 +779,9 @@ void CG_AddPacketEntities( void ); void CG_Beam( centity_t *cent, int color ); void CG_AdjustPositionForMover( const vec3_t in, int moverNum, int atTime, vec3_t out ); -void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, +void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName ); -void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, +void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName, orientation_t *tagOrient ); /* @@ -818,7 +818,7 @@ void CG_AddViewWeapon (playerState_t *ps); void CG_DrawWeaponSelect( void ); void CG_OutOfAmmoChange( void ); // should this be in pmove? -void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t min, const vec3_t maxs, +void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t min, const vec3_t maxs, float speed, int numChunks, material_t chunkType, int customChunk, float baseScale ); @@ -827,11 +827,11 @@ void CG_Chunks( int owner, vec3_t origin, const vec3_t normal, const vec3_t min, // void CG_InitMarkPolys( void ); void CG_AddMarks( void ); -void CG_ImpactMark( qhandle_t markShader, - const vec3_t origin, const vec3_t dir, - float orientation, - float r, float g, float b, float a, - qboolean alphaFade, +void CG_ImpactMark( qhandle_t markShader, + const vec3_t origin, const vec3_t dir, + float orientation, + float r, float g, float b, float a, + qboolean alphaFade, float radius, qboolean temporary ); // @@ -845,11 +845,11 @@ void CG_AddLocalEntities( void ); // cg_effects.c // -/*localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, +/*localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, qhandle_t hModel, int numframes, qhandle_t shader, int msec, qboolean isSprite, float scale = 1.0f );// Overloaded -localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, +localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir, qhandle_t hModel, int numframes, qhandle_t shader, int msec, qboolean isSprite, float scale, int flags );// Overloaded */ @@ -965,7 +965,7 @@ void cgi_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec const vec3_t origin, const vec3_t angles ); // Returns the projection of a polygon onto the solid brushes in the world -int cgi_CM_MarkFragments( int numPoints, const vec3_t *points, +int cgi_CM_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ); @@ -992,7 +992,7 @@ void cgi_R_LoadWorldMap( const char *mapname ); // all media should be registered during level startup to prevent // hitches during gameplay qhandle_t cgi_R_RegisterModel( const char *name ); // returns rgb axis if not found -qhandle_t cgi_R_RegisterSkin( const char *name ); +qhandle_t cgi_R_RegisterSkin( const char *name ); qhandle_t cgi_R_RegisterShader( const char *name ); // returns default shader if not found qhandle_t cgi_R_RegisterShaderNoMip( const char *name ); // returns all white if not found qhandle_t cgi_R_RegisterFont( const char *name ); @@ -1017,18 +1017,18 @@ void cgi_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *v void cgi_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); void cgi_R_RenderScene( const refdef_t *fd ); void cgi_R_SetColor( const float *rgba ); // NULL = 1,1,1,1 -void cgi_R_DrawStretchPic( float x, float y, float w, float h, +void cgi_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); void cgi_R_DrawScreenShot( float x, float y, float w, float h); void cgi_R_ModelBounds( qhandle_t model, vec3_t mins, vec3_t maxs ); -void cgi_R_LerpTag( orientation_t *tag, qhandle_t mod, int startFrame, int endFrame, +void cgi_R_LerpTag( orientation_t *tag, qhandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ); // Does weird, barely controllable rotation behaviour -void cgi_R_DrawRotatePic( float x, float y, float w, float h, +void cgi_R_DrawRotatePic( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader ); // rotates image around exact center point of passed in coords -void cgi_R_DrawRotatePic2( float x, float y, float w, float h, +void cgi_R_DrawRotatePic2( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader ); void cgi_R_LAGoggles( void ); void cgi_R_Scissor( float x, float y, float w, float h); @@ -1061,7 +1061,7 @@ qboolean cgi_GetServerCommand( int serverCommandNumber ); // this will always be at least one higher than the number in the current // snapshot, and it may be quite a few higher if it is a fast computer on // a lagged connection -int cgi_GetCurrentCmdNumber( void ); +int cgi_GetCurrentCmdNumber( void ); qboolean cgi_GetUserCmd( int cmdNumber, usercmd_t *ucmd ); // used for the weapon select and zoom diff --git a/codeJK2/cgame/cg_localents.cpp b/codeJK2/cgame/cg_localents.cpp index d25a8e1eca..dd1a72ec4e 100644 --- a/codeJK2/cgame/cg_localents.cpp +++ b/codeJK2/cgame/cg_localents.cpp @@ -119,10 +119,10 @@ or generates more localentities along a trail. CG_FragmentBounceSound ================ */ -void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) +void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) { // half the fragments will make a bounce sounds - if ( rand() & 1 ) + if ( rand() & 1 ) { sfxHandle_t s = 0; @@ -146,7 +146,7 @@ void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) // bouncers only make the sound once... // FIXME: arbitrary...change if it bugs you le->leBounceSoundType = LEBS_NONE; - } + } else if ( rand() & 1 ) { // we may end up bouncing again, but each bounce reduces the chance of playing the sound again or they may make a lot of noise when they settle @@ -161,7 +161,7 @@ void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) CG_ReflectVelocity ================ */ -void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) +void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) { vec3_t velocity; float dot; @@ -179,9 +179,9 @@ void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) le->pos.trTime = cg.time; // check for stop, making sure that even on low FPS systems it doesn't bobble - if ( trace->allsolid || - ( trace->plane.normal[2] > 0 && - ( le->pos.trDelta[2] < 40 || le->pos.trDelta[2] < -cg.frametime * le->pos.trDelta[2] ) ) ) + if ( trace->allsolid || + ( trace->plane.normal[2] > 0 && + ( le->pos.trDelta[2] < 40 || le->pos.trDelta[2] < -cg.frametime * le->pos.trDelta[2] ) ) ) { le->pos.trType = TR_STATIONARY; } @@ -192,25 +192,25 @@ void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) CG_AddFragment ================ */ -void CG_AddFragment( localEntity_t *le ) +void CG_AddFragment( localEntity_t *le ) { vec3_t newOrigin; trace_t trace; // used to sink into the ground, but it looks better to maybe just fade them out int t; - + t = le->endTime - cg.time; - if ( t < FRAG_FADE_TIME ) + if ( t < FRAG_FADE_TIME ) { le->refEntity.renderfx |= RF_ALPHA_FADE; le->refEntity.shaderRGBA[0] = le->refEntity.shaderRGBA[1] = le->refEntity.shaderRGBA[2] = 255; le->refEntity.shaderRGBA[3] = ((float)t / FRAG_FADE_TIME) * 255.0f; } - if ( le->pos.trType == TR_STATIONARY ) + if ( le->pos.trType == TR_STATIONARY ) { - if ( !(cgi_CM_PointContents( le->refEntity.origin, 0 ) & CONTENTS_SOLID )) + if ( !(cgi_CM_PointContents( le->refEntity.origin, 0 ) & CONTENTS_SOLID )) { // thing is no longer in solid, so let gravity take it back VectorCopy( le->refEntity.origin, le->pos.trBase ); @@ -229,7 +229,7 @@ void CG_AddFragment( localEntity_t *le ) le->refEntity.renderfx |= RF_LIGHTING_ORIGIN; VectorCopy( newOrigin, le->refEntity.lightingOrigin ); - + // trace a line from previous position to new position CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, le->ownerGentNum, CONTENTS_SOLID ); if ( trace.fraction == 1.0 ) { @@ -256,7 +256,7 @@ void CG_AddFragment( localEntity_t *le ) // if it is in a nodrop zone, remove it // this keeps gibs from waiting at the bottom of pits of death // and floating levels - if ( cgi_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) + if ( cgi_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) { CG_FreeLocalEntity( le ); return; @@ -363,20 +363,20 @@ static void CG_AddPuff( localEntity_t *le ) { CG_AddLocalLight ================ */ -static void CG_AddLocalLight( localEntity_t *le ) +static void CG_AddLocalLight( localEntity_t *le ) { // There should be a light if this is being used, but hey... - if ( le->light ) + if ( le->light ) { float light; light = (float)( cg.time - le->startTime ) / ( le->endTime - le->startTime ); - if ( light < 0.5 ) + if ( light < 0.5 ) { light = 1.0; - } - else + } + else { light = 1.0 - ( light - 0.5 ) * 2; } @@ -548,7 +548,7 @@ CG_AddLocalEntities =================== */ -void CG_AddLocalEntities( void ) +void CG_AddLocalEntities( void ) { localEntity_t *le, *next; diff --git a/codeJK2/cgame/cg_playerstate.cpp b/codeJK2/cgame/cg_playerstate.cpp index 3491570df2..62876256de 100644 --- a/codeJK2/cgame/cg_playerstate.cpp +++ b/codeJK2/cgame/cg_playerstate.cpp @@ -36,7 +36,7 @@ CG_CheckAmmo If the ammo has gone low enough to generate the warning, play a sound ============== */ -void CG_CheckAmmo( void ) +void CG_CheckAmmo( void ) { // int i; int total; @@ -44,18 +44,18 @@ void CG_CheckAmmo( void ) // int weapons; #if 0 - + // see about how many seconds of ammo we have remaining weapons = cg.snap->ps.stats[ STAT_WEAPONS ]; total = 0; - for ( i = WP_STUN_BATON; i < WP_NUM_WEAPONS i++ ) + for ( i = WP_STUN_BATON; i < WP_NUM_WEAPONS i++ ) { if ( ! ( weapons & ( 1 << i ) ) ) continue; /* - switch ( i ) + switch ( i ) { case WP_ROCKET_LAUNCHER: case WP_GRENADE_LAUNCHER: @@ -68,8 +68,8 @@ void CG_CheckAmmo( void ) break; } */ - - if ( total >= 5000 ) + + if ( total >= 5000 ) { cg.lowAmmoWarning = 0; return; @@ -97,7 +97,7 @@ void CG_CheckAmmo( void ) if (!total) // We're completely freak'in out! { cg.lowAmmoWarning = 2; - } + } else // Got a little left { cg.lowAmmoWarning = 1; @@ -172,7 +172,7 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) { } cg.v_dmg_roll = kick * left; - + cg.v_dmg_pitch = -kick * front; if ( front <= 0.1 ) { @@ -359,7 +359,7 @@ void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops ) { CG_CheckPlayerstateEvents( ps, ops ); // smooth the ducking viewheight change - if ( ps->viewheight != ops->viewheight ) + if ( ps->viewheight != ops->viewheight ) { if ( !cg.nextFrameTeleport ) {//when we crouch/uncrouch in mid-air, our viewhieght doesn't actually change in diff --git a/codeJK2/cgame/cg_predict.cpp b/codeJK2/cgame/cg_predict.cpp index 6c92ef4d85..8c73e52138 100644 --- a/codeJK2/cgame/cg_predict.cpp +++ b/codeJK2/cgame/cg_predict.cpp @@ -43,7 +43,7 @@ of the entities that are actually solid, to make for more efficient collision detection ==================== */ -void CG_BuildSolidList( void ) +void CG_BuildSolidList( void ) { int i; centity_t *cent; @@ -55,13 +55,13 @@ void CG_BuildSolidList( void ) return; } - for ( i = 0 ; i < cg.snap->numEntities ; i++ ) + for ( i = 0 ; i < cg.snap->numEntities ; i++ ) { if ( cg.snap->entities[ i ].number < ENTITYNUM_WORLD ) { cent = &cg_entities[ cg.snap->entities[ i ].number ]; - if ( cent->gent != NULL && cent->gent->s.solid ) + if ( cent->gent != NULL && cent->gent->s.solid ) { cg_solidEntities[cg_numSolidEntities] = cent; cg_numSolidEntities++; @@ -106,7 +106,7 @@ void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t cmodel = cgi_CM_InlineModel( ent->modelindex ); VectorCopy( cent->lerpAngles, angles ); - //Hmm... this would cause traces against brush movers to snap at 20fps (as with the third person camera)... + //Hmm... this would cause traces against brush movers to snap at 20fps (as with the third person camera)... //Let's use the lerpOrigin for now and see if it breaks anything... //EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, origin ); VectorCopy( cent->lerpOrigin, origin ); @@ -148,7 +148,7 @@ void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t CG_Trace ================ */ -void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, +void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const int skipNumber, const int mask, const EG2_Collision eG2TraceType/*=G2_NOCOLLIDE*/, const int useLod/*=0*/) { trace_t t; @@ -203,7 +203,7 @@ void CG_SetClientViewAngles( vec3_t angles, qboolean overrideViewEnt ) { if ( cg.snap->ps.viewEntity <= 0 || cg.snap->ps.viewEntity >= ENTITYNUM_WORLD || overrideViewEnt ) {//don't clamp angles when looking through a viewEntity - for( int i = 0; i < 3; i++ ) + for( int i = 0; i < 3; i++ ) { cg.predicted_player_state.viewangles[PITCH] = angles[i]; cg.predicted_player_state.delta_angles[i] = 0; @@ -355,7 +355,7 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { } // if the next frame is a teleport, we can't lerp to it - if ( cg.nextFrameTeleport ) + if ( cg.nextFrameTeleport ) { return; } @@ -364,23 +364,23 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { { f = (float)( cg.time - prev->serverTime ) / ( next->serverTime - prev->serverTime ); - + i = next->ps.bobCycle; - if ( i < prev->ps.bobCycle ) + if ( i < prev->ps.bobCycle ) { i += 256; // handle wraparound } out->bobCycle = prev->ps.bobCycle + f * ( i - prev->ps.bobCycle ); - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { out->origin[i] = prev->ps.origin[i] + f * (next->ps.origin[i] - prev->ps.origin[i] ); - if ( !grabAngles ) + if ( !grabAngles ) { - out->viewangles[i] = LerpAngle( + out->viewangles[i] = LerpAngle( prev->ps.viewangles[i], next->ps.viewangles[i], f ); } - out->velocity[i] = prev->ps.velocity[i] + + out->velocity[i] = prev->ps.velocity[i] + f * (next->ps.velocity[i] - prev->ps.velocity[i] ); } } @@ -390,7 +390,7 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { if (out->groundEntityNum>0) { pent=&cg_entities[out->groundEntityNum]; - if (pent->currentState.eType == ET_MOVER ) + if (pent->currentState.eType == ET_MOVER ) { onPlat=true; @@ -398,8 +398,8 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { } if ( - cg.validPPS && - cg_smoothPlayerPos.value>0.0f && + cg.validPPS && + cg_smoothPlayerPos.value>0.0f && cg_smoothPlayerPos.value<1.0f && !onPlat ) @@ -420,7 +420,7 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { EvaluateTrajectory( &pent->currentState.pos,cg.snap->serverTime, p1 ); - if ( cg.nextSnap &&cg.nextSnap->serverTime > cg.snap->serverTime) + if ( cg.nextSnap &&cg.nextSnap->serverTime > cg.snap->serverTime) { EvaluateTrajectory( &pent->nextState.pos,cg.nextSnap->serverTime, p2 ); lerpTime=float(cg.nextSnap->serverTime - cg.snap->serverTime); @@ -445,8 +445,8 @@ void CG_InterpolatePlayerState( qboolean grabAngles ) { VectorAdd(out->origin,vel,out->origin); - if (cg.validPPS && - cg_smoothPlayerPlat.value>0.0f && + if (cg.validPPS && + cg_smoothPlayerPlat.value>0.0f && cg_smoothPlayerPlat.value<1.0f ) { @@ -552,7 +552,7 @@ void CG_TouchTriggerPrediction( void ) { continue; } - cgi_CM_BoxTrace( &trace, cg.predicted_player_state.origin, cg.predicted_player_state.origin, + cgi_CM_BoxTrace( &trace, cg.predicted_player_state.origin, cg.predicted_player_state.origin, cg_pmove.mins, cg_pmove.maxs, cmodel, -1 ); if ( !trace.startsolid ) { @@ -643,7 +643,7 @@ void CG_PredictPlayerState( void ) { current = cgi_GetCurrentCmdNumber(); if ( current - cmdNum >= CMD_BACKUP ) { - return; + return; } // get the most recent information we have @@ -651,7 +651,7 @@ void CG_PredictPlayerState( void ) { // we should always be predicting at least one frame if ( cmdNum >= current ) { - return; + return; } // run cmds @@ -671,7 +671,7 @@ void CG_PredictPlayerState( void ) { cg.thisFrameTeleport = qfalse; } else { vec3_t adjusted; - CG_AdjustPositionForMover( cg.predicted_player_state.origin, + CG_AdjustPositionForMover( cg.predicted_player_state.origin, cg.predicted_player_state.groundEntityNum, cg.oldTime, adjusted ); VectorSubtract( oldPlayerState.origin, adjusted, delta ); @@ -709,7 +709,7 @@ void CG_PredictPlayerState( void ) { if ( player_locked || (ent && !ent->s.number&&ent->aimDebounceTime>level.time) || (ent && ent->client && ent->client->ps.pm_time && (ent->client->ps.pm_flags&PMF_TIME_KNOCKBACK)) || - (ent && ent->forcePushTime > level.time) ) + (ent && ent->forcePushTime > level.time) ) {//lock out player control unless dead //VectorClear( cg_pmove.cmd.angles ); cg_pmove.cmd.forwardmove = 0; @@ -720,15 +720,15 @@ void CG_PredictPlayerState( void ) { CG_CheckModifyUCmd( &cg_pmove.cmd, NULL ); //FIXME: prediction on clients in timescale results in jerky positional translation Pmove( &cg_pmove ); - + // add push trigger movement effects CG_TouchTriggerPrediction(); } while ( cmdNum < current ); // adjust for the movement of the groundentity - CG_AdjustPositionForMover( cg.predicted_player_state.origin, - cg.predicted_player_state.groundEntityNum, + CG_AdjustPositionForMover( cg.predicted_player_state.origin, + cg.predicted_player_state.groundEntityNum, cg.time, cg.predicted_player_state.origin ); // fire events and other transition triggered things diff --git a/codeJK2/cgame/cg_scoreboard.cpp b/codeJK2/cgame/cg_scoreboard.cpp index 27fb1acb30..d2d3c80a30 100644 --- a/codeJK2/cgame/cg_scoreboard.cpp +++ b/codeJK2/cgame/cg_scoreboard.cpp @@ -61,7 +61,7 @@ static void Scoreboard_Draw( void ) CG_DrawPic(120, 100, 18, 12, cgs.media.whiteShader); // Middle Top CG_DrawPic(120, 353, 18, 4, cgs.media.whiteShader); // Middle Bottom - + CG_DrawPic(130,357, 482, 18, cgs.media.whiteShader); // Bottom // Left side box @@ -97,7 +97,7 @@ void CG_MissionFailed(void) cgi_SP_GetStringTextString( "INGAME_MISSIONFAILED", text, sizeof(text) ); - w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); + w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); cgi_R_Font_DrawString(320 - w/2, y, text, colorTable[CT_HUD_RED], cgs.media.qhFontMedium, -1, 1.2f); switch (statusTextIndex) @@ -140,11 +140,11 @@ void CG_MissionFailed(void) break; } - w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); + w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); cgi_R_Font_DrawString(320 - w/2, y+30, text, colorTable[CT_HUD_RED], cgs.media.qhFontMedium, -1, 1.2f); cgi_SP_GetStringTextString( "INGAME_RELOADMISSION", text, sizeof(text) ); - w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f); + w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f); cgi_R_Font_DrawString(320 - w/2, 450, text, colorTable[CT_CYAN], cgs.media.qhFontSmall, -1, 1.0f); } @@ -162,17 +162,17 @@ void CG_MissionCompletion(void) const int pad = 18; cgi_SP_GetStringTextString( "INGAME_MISSIONCOMPLETION", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontMedium, 1.2f); cgi_R_Font_DrawString(320 - w/2, 53, text, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.2f); x = 75; y =86; cgi_SP_GetStringTextString( "INGAME_SECRETAREAS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_SP_GetStringTextString( "INGAME_SECRETAREAS_OF", text, sizeof(text) ); - cgi_R_Font_DrawString(x+w, y, va("%d %s %d", - cg_entities[0].gent->client->sess.missionStats.secretsFound, + cgi_R_Font_DrawString(x+w, y, va("%d %s %d", + cg_entities[0].gent->client->sess.missionStats.secretsFound, text, cg_entities[0].gent->client->sess.missionStats.totalSecrets ), @@ -180,7 +180,7 @@ w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_ENEMIESKILLED", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w,y, va("%d",cg_entities[0].gent->client->sess.missionStats.enemiesKilled), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); /* @@ -189,16 +189,16 @@ w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cg_entities[0].gent->client->sess.missionStats.enemiesKilled, text, cg_entities[0].gent->client->sess.missionStats.enemiesSpawned - ), + ), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); */ y +=pad; y +=pad; cgi_SP_GetStringTextString( "INGAME_FAVORITEWEAPON", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); - + int wpn=0,i; int max_wpn = cg_entities[0].gent->client->sess.missionStats.weaponUsed[0]; for (i = 1; iclient->sess.missionStats.shotsFired), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_HITS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.hits), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_ACCURACY", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); const float percent = cg_entities[0].gent->client->sess.missionStats.shotsFired? 100.0f * (float)cg_entities[0].gent->client->sess.missionStats.hits / cg_entities[0].gent->client->sess.missionStats.shotsFired : 0; cgi_R_Font_DrawString(x+w, y, va("%.2f%%",percent), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); @@ -251,43 +251,43 @@ w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_HEAL", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_HEAL]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_SPEED", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_SPEED]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_PULL", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_PULL]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_PUSH", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_PUSH]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString("INGAME_MINDTRICK", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_TELEPATHY]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_GRIP", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_GRIP]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_LIGHTNING", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.forceUsed[FP_LIGHTNING]), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); @@ -299,37 +299,37 @@ w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_THROWN", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.saberThrownCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_BLOCKS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.saberBlocksCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_LEGATTACKS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.legAttacksCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_ARMATTACKS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.armAttacksCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_BODYATTACKS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.torsoAttacksCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); y +=pad; cgi_SP_GetStringTextString( "INGAME_OTHERATTACKS", text, sizeof(text) ); -w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); +w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 0.8f); cgi_R_Font_DrawString(x, y, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 0.8f); cgi_R_Font_DrawString(x+w, y, va("%d",cg_entities[0].gent->client->sess.missionStats.otherAttacksCnt), colorTable[CT_WHITE], cgs.media.qhFontSmall, -1, 0.8f); } @@ -343,16 +343,16 @@ Draw the normal in-game scoreboard return value is bool to NOT draw centerstring ================= */ -qboolean CG_DrawScoreboard( void ) +qboolean CG_DrawScoreboard( void ) { // don't draw anything if the menu is up - if ( cg_paused.integer ) + if ( cg_paused.integer ) { return qfalse; } // Character is either dead, or a script has brought up the screen - if (((cg.predicted_player_state.pm_type == PM_DEAD) && (cg.missionStatusDeadTime < level.time)) + if (((cg.predicted_player_state.pm_type == PM_DEAD) && (cg.missionStatusDeadTime < level.time)) || (cg.missionStatusShow)) { CG_MissionFailed(); diff --git a/codeJK2/cgame/cg_servercmds.cpp b/codeJK2/cgame/cg_servercmds.cpp index b5c4d3226e..88df7f522f 100644 --- a/codeJK2/cgame/cg_servercmds.cpp +++ b/codeJK2/cgame/cg_servercmds.cpp @@ -139,7 +139,7 @@ void CG_ParseServerinfo( void ) { { // failed again, give up for now... // - } + } } if (!Q_stricmp(cgs.stripLevelName[0],"BESPIN_PLATFORM")) { @@ -148,7 +148,7 @@ void CG_ParseServerinfo( void ) { { // failed again, give up for now... // - } + } } } } @@ -179,7 +179,7 @@ static void CG_ConfigStringModified( void ) { if ( num == CS_ITEMS ) { int i; for ( i = 1 ; i < bg_numItems ; i++ ) { - if ( str[ i ] == '1' ) + if ( str[ i ] == '1' ) { if (bg_itemlist[i].classname) { @@ -204,11 +204,11 @@ static void CG_ConfigStringModified( void ) { if ( str[0] != '*' ) { cgs.sound_precache[ num-CS_SOUNDS] = cgi_S_RegisterSound( str ); } - } - else if ( num >= CS_EFFECTS && num < CS_EFFECTS + MAX_FX ) + } + else if ( num >= CS_EFFECTS && num < CS_EFFECTS + MAX_FX ) { theFxScheduler.RegisterEffect( str ); - } + } else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) { CG_NewClientinfo( num - CS_PLAYERS ); CG_RegisterClientModels( num - CS_PLAYERS ); diff --git a/codeJK2/cgame/cg_snapshot.cpp b/codeJK2/cgame/cg_snapshot.cpp index 586c25548f..fdfb9c40ab 100644 --- a/codeJK2/cgame/cg_snapshot.cpp +++ b/codeJK2/cgame/cg_snapshot.cpp @@ -73,7 +73,7 @@ void CG_TransitionEntity( centity_t *cent ) { CG_SetInitialSnapshot This will only happen on the very first snapshot, or -on tourney restarts. All other times will use +on tourney restarts. All other times will use CG_TransitionSnapshot instead. ================== */ @@ -144,7 +144,7 @@ void CG_TransitionSnapshot( void ) { // sort out solid entities //CG_BuildSolidList(); - for ( i = 0 ; i < cg.snap->numEntities ; i++ ) + for ( i = 0 ; i < cg.snap->numEntities ; i++ ) { if ( 1 )//cg.snap->entities[ i ].number != 0 ) // I guess the player adds his/her events elsewhere, so doing this also gives us double events for the player! { @@ -180,9 +180,9 @@ void CG_SetEntityNextState( centity_t *cent, entityState_t *state ) { cent->nextState = *state; // since we can't interpolate ghoul2 stuff from one frame to another, I'm just going to copy the ghoul2 info directly into the current state now -// CGhoul2Info *currentModel = &state->ghoul2[1]; +// CGhoul2Info *currentModel = &state->ghoul2[1]; // cent->gent->ghoul2 = state->ghoul2; -// CGhoul2Info *newModel = ¢->gent->ghoul2[1]; +// CGhoul2Info *newModel = ¢->gent->ghoul2[1]; // if this frame is a teleport, or the entity wasn't in the @@ -399,7 +399,7 @@ void CG_ProcessSnapshots( void ) { CG_TransitionSnapshot(); } while ( 1 ); - if ( cg.snap->serverTime > cg.time ) + if ( cg.snap->serverTime > cg.time ) { cg.time=cg.snap->serverTime; #if _DEBUG @@ -407,7 +407,7 @@ void CG_ProcessSnapshots( void ) { #endif } - if ( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time ) + if ( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time ) { cg.time=cg.nextSnap->serverTime-1; #if _DEBUG diff --git a/codeJK2/cgame/cg_syscalls.cpp b/codeJK2/cgame/cg_syscalls.cpp index d4e637c845..d1b2d1be7d 100644 --- a/codeJK2/cgame/cg_syscalls.cpp +++ b/codeJK2/cgame/cg_syscalls.cpp @@ -52,7 +52,7 @@ NORETURN void cgi_Error( const char *fmt ) { } int cgi_Milliseconds( void ) { - return Q_syscall( CG_MILLISECONDS ); + return Q_syscall( CG_MILLISECONDS ); } void cgi_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ) { @@ -148,7 +148,7 @@ void cgi_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec Q_syscall( CG_CM_TRANSFORMEDBOXTRACE, results, start, end, mins, maxs, model, brushmask, origin, angles ); } -int cgi_CM_MarkFragments( int numPoints, const vec3_t *points, +int cgi_CM_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ) { @@ -305,7 +305,7 @@ void cgi_R_SetColor( const float *rgba ) { Q_syscall( CG_R_SETCOLOR, rgba ); } -void cgi_R_DrawStretchPic( float x, float y, float w, float h, +void cgi_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) { Q_syscall( CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader ); } @@ -318,19 +318,19 @@ void cgi_R_ModelBounds( qhandle_t model, vec3_t mins, vec3_t maxs ) { Q_syscall( CG_R_MODELBOUNDS, model, mins, maxs ); } -void cgi_R_LerpTag( orientation_t *tag, qhandle_t mod, int startFrame, int endFrame, +void cgi_R_LerpTag( orientation_t *tag, qhandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ) { Q_syscall( CG_R_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName ); } -void cgi_R_DrawRotatePic( float x, float y, float w, float h, - float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) +void cgi_R_DrawRotatePic( float x, float y, float w, float h, + float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) { Q_syscall( CG_R_DRAWROTATEPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), PASSFLOAT(a), hShader ); } -void cgi_R_DrawRotatePic2( float x, float y, float w, float h, - float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) +void cgi_R_DrawRotatePic2( float x, float y, float w, float h, + float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) { Q_syscall( CG_R_DRAWROTATEPIC2, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), PASSFLOAT(a), hShader ); } @@ -340,7 +340,7 @@ void cgi_R_LAGoggles( void ) Q_syscall( CG_R_LA_GOGGLES ); } -void cgi_R_Scissor( float x, float y, float w, float h) +void cgi_R_Scissor( float x, float y, float w, float h) { Q_syscall( CG_R_SCISSOR, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h)); } @@ -421,7 +421,7 @@ void cgi_R_WorldEffectCommand( const char *command ) int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits, const char *psAudioFile /* = NULL */) { return Q_syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits, psAudioFile); } - + // stops playing the cinematic and ends it. should always return FMV_EOF // cinematics must be stopped in reverse order of when they are started e_status trap_CIN_StopCinematic(int handle) { @@ -433,13 +433,13 @@ e_status trap_CIN_StopCinematic(int handle) { e_status trap_CIN_RunCinematic (int handle) { return (e_status) Q_syscall(CG_CIN_RUNCINEMATIC, handle); } - + // draws the current frame void trap_CIN_DrawCinematic (int handle) { Q_syscall(CG_CIN_DRAWCINEMATIC, handle); } - + // allows you to resize the animation dynamically void trap_CIN_SetExtents (int handle, int x, int y, int w, int h) { diff --git a/codeJK2/game/AI_Atst.cpp b/codeJK2/game/AI_Atst.cpp index 952e8b4aa5..01da26ae4f 100644 --- a/codeJK2/game/AI_Atst.cpp +++ b/codeJK2/game/AI_Atst.cpp @@ -21,7 +21,7 @@ along with this program; if not, see . */ #include "g_headers.h" - + #include "b_local.h" @@ -65,7 +65,7 @@ static void ATST_PlayEffect( gentity_t *self, const int boltID, const char *fx ) mdxaBone_t boltMatrix; vec3_t org, dir; - gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, + gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, boltID, &boltMatrix, self->currentAngles, self->currentOrigin, (cg.time?cg.time:level.time), NULL, self->s.modelScale ); @@ -88,7 +88,7 @@ Called by NPC's and player in an ATST void G_ATSTCheckPain( gentity_t *self, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { int newBolt; - + if ( rand() & 1 ) { G_SoundOnEnt( self, CHAN_LESS_ATTEN, "sound/chars/atst/atst_damaged1" ); @@ -116,7 +116,7 @@ void G_ATSTCheckPain( gentity_t *self, gentity_t *other, vec3_t point, int damag else if ((hitLoc==HL_ARM_RT) && (self->locationDamage[HL_ARM_RT] > RIGHT_ARM_HEALTH)) // Blow it up? { if (self->locationDamage[hitLoc] >= RIGHT_ARM_HEALTH) - { + { newBolt = gi.G2API_AddBolt( &self->ghoul2[self->playerModel], "*flash4" ); if ( newBolt != -1 ) { @@ -134,7 +134,7 @@ void G_ATSTCheckPain( gentity_t *self, gentity_t *other, vec3_t point, int damag NPC_ATST_Pain ------------------------- */ -void NPC_ATST_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_ATST_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { G_ATSTCheckPain( self, other, point, damage, mod, hitLoc ); NPC_Pain( self, inflictor, other, point, damage, mod ); @@ -206,7 +206,7 @@ void ATST_Attack( void ) NPC_FaceEnemy( qtrue ); // Rate our distance to the target, and our visibilty - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); distance_e distRate = ( distance > MIN_MELEE_RANGE_SQR ) ? DIST_LONG : DIST_MELEE; qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); @@ -259,7 +259,7 @@ void ATST_Attack( void ) { altAttack = qtrue; } - else + else { NPC_ChangeWeapon( WP_NONE ); } @@ -328,7 +328,7 @@ void NPC_BSATST_Default( void ) else if ( NPCInfo->scriptFlags & SCF_LOOK_FOR_ENEMIES ) { ATST_Patrol(); - } + } else { ATST_Idle(); diff --git a/codeJK2/game/AI_Default.cpp b/codeJK2/game/AI_Default.cpp index 55ddda93c3..f0a8aed4fa 100644 --- a/codeJK2/game/AI_Default.cpp +++ b/codeJK2/game/AI_Default.cpp @@ -95,10 +95,10 @@ void NPC_StandIdle( void ) newIdle = Q_irand( 0, MAX_IDLE_ANIMS ); } - + //Start that animation going NPC_SetAnim( NPC, SETANIM_BOTH, baseSeq + newIdle, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); - + int newTime = PM_AnimLength( NPC->client->clientInfo.animFileIndex, (animNumber_t) (baseSeq + newIdle) ); //Don't do this again for a random amount of time @@ -174,7 +174,7 @@ qboolean NPC_StandTrackAndShoot (gentity_t *NPC, qboolean canDuck) } -void NPC_BSIdle( void ) +void NPC_BSIdle( void ) { //FIXME if there is no nav data, we need to do something else // if we're stuck, try to move around it @@ -233,7 +233,7 @@ void NPC_BSStandGuard (void) { NPCInfo->tempBehavior = BS_DEFAULT; } - + if( NPCInfo->behaviorState == BS_STAND_GUARD ) { NPCInfo->behaviorState = BS_STAND_AND_SHOOT; @@ -279,7 +279,7 @@ void NPC_BSHuntAndKill( void ) enemyDist = VectorLength(vec); if( enemyDist > 48 && ((enemyDist*1.5)*(enemyDist*1.5) >= NPC_MaxDistSquaredForWeapon() || oEVis != VIS_SHOOT || - //!(ucmd.buttons & BUTTON_ATTACK) || + //!(ucmd.buttons & BUTTON_ATTACK) || enemyDist > IdealDistance(NPC)*3 ) ) {//We should close in? NPCInfo->goalEntity = NPC->enemy; @@ -303,7 +303,7 @@ void NPC_BSHuntAndKill( void ) }//otherwise, stay where we are } } - else + else {//ok, stand guard until we find an enemy if( NPCInfo->tempBehavior == BS_HUNT_AND_KILL ) { @@ -331,7 +331,7 @@ void NPC_BSStandAndShoot (void) //FIXME: //When they're all dead, go to some script or wander off to sickbay? - + if(NPC->client->playerTeam && NPC->client->enemyTeam) { //FIXME: don't realize this right away- or else enemies show up and we're standing around @@ -382,7 +382,7 @@ void NPC_BSStandAndShoot (void) } NPC_CheckEnemy(qtrue, qfalse); - + if(NPCInfo->duckDebounceTime > level.time && NPC->client->ps.weapon != WP_SABER ) { ucmd.upmove = -127; @@ -390,7 +390,7 @@ void NPC_BSStandAndShoot (void) { NPC_CheckCanAttack(1.0, qtrue); } - return; + return; } if(NPC->enemy) @@ -432,7 +432,7 @@ void NPC_BSRunAndShoot (void) //NPCInfo->combatMove = qtrue; NPC_CheckEnemy( qtrue, qfalse ); - + if ( NPCInfo->duckDebounceTime > level.time ) // && NPCInfo->hidingGoal ) { ucmd.upmove = -127; @@ -440,7 +440,7 @@ void NPC_BSRunAndShoot (void) { NPC_CheckCanAttack( 1.0, qfalse ); } - return; + return; } if ( NPC->enemy ) @@ -457,13 +457,13 @@ void NPC_BSRunAndShoot (void) if ( VectorLength( vec ) > 128 || NPC->cantHitEnemyCounter >= 10 ) {//run at enemy if too far away //The cantHitEnemyCounter getting high has other repercussions - //100 (10 seconds) will make you try to pick a new enemy... + //100 (10 seconds) will make you try to pick a new enemy... //But we're chasing, so we clamp it at 50 here if ( NPC->cantHitEnemyCounter > 60 ) { NPC->cantHitEnemyCounter = 60; } - + if ( NPC->cantHitEnemyCounter >= (NPCInfo->stats.aggression+1) * 10 ) { NPC_LostEnemyDecideChase(); @@ -484,9 +484,9 @@ void NPC_BSRunAndShoot (void) //of a thin wall or something else blocking out shot. That //would make us just stand there and not go around it... //but maybe it's okay- might look like we're waiting for - //him to come out...? + //him to come out...? //Current solution: runs around if cantHitEnemyCounter gets - //to 10 (1 second). + //to 10 (1 second). } } else @@ -514,7 +514,7 @@ void NPC_BSFace (void) if( NPC_UpdateAngles ( qtrue, qtrue ) ) { Q3_TaskIDComplete( NPC, TID_BSTATE ); - + NPCInfo->desiredYaw = client->ps.viewangles[YAW]; NPCInfo->desiredPitch = client->ps.viewangles[PITCH]; @@ -566,7 +566,7 @@ void NPC_BSPointShoot (qboolean shoot) {//FIXME: needs to hold this down if using a weapon that requires it, like phaser... ucmd.buttons |= BUTTON_ATTACK; } - + if ( !shoot || !(NPC->svFlags & SVF_LOCKEDENEMY) ) {//If locked_enemy is on, dont complete until it is destroyed... Q3_TaskIDComplete( NPC, TID_BSTATE ); @@ -596,7 +596,7 @@ void NPC_BSPointShoot (qboolean shoot) float dist = VectorLength( dir ); float yawMiss, yawMissAllow = NPC->enemy->maxs[0]; float pitchMiss, pitchMissAllow = (NPC->enemy->maxs[2] - NPC->enemy->mins[2])/2; - + if ( yawMissAllow < 8.0f ) { yawMissAllow = 8.0f; @@ -616,9 +616,9 @@ void NPC_BSPointShoot (qboolean shoot) } } } - + return; - + finished: NPCInfo->desiredYaw = client->ps.viewangles[YAW]; NPCInfo->desiredPitch = client->ps.viewangles[PITCH]; @@ -664,7 +664,7 @@ void NPC_BSShoot(void) enemyVisibility = VIS_SHOOT; - if ( client->ps.weaponstate != WEAPON_READY && client->ps.weaponstate != WEAPON_FIRING ) + if ( client->ps.weaponstate != WEAPON_READY && client->ps.weaponstate != WEAPON_FIRING ) { client->ps.weaponstate = WEAPON_READY; } @@ -673,12 +673,12 @@ void NPC_BSShoot(void) } /* -void NPC_BSPatrol( void ) +void NPC_BSPatrol( void ) Same as idle, but you look for enemies every "vigilance" using your angles, HFOV, VFOV and visrange, and listen for sounds within earshot... */ -void NPC_BSPatrol( void ) +void NPC_BSPatrol( void ) { //int alertEventNum; @@ -726,7 +726,7 @@ void NPC_BSDefault(void) extern void NPC_CheckGetNewWeapon( void ); extern void NPC_BSST_Attack( void ); -void NPC_BSDefault( void ) +void NPC_BSDefault( void ) { // vec3_t enemyDir; // float enemyDist; @@ -741,7 +741,7 @@ void NPC_BSDefault( void ) qboolean move = qtrue; // qboolean shoot = qfalse; - + if( NPCInfo->scriptFlags & SCF_FIRE_WEAPON ) { WeaponThink( qtrue ); @@ -785,8 +785,8 @@ void NPC_BSDefault( void ) { // just use the stormtrooper attack AI... NPC_CheckGetNewWeapon(); - if ( NPC->client->leader - && NPCInfo->goalEntity == NPC->client->leader + if ( NPC->client->leader + && NPCInfo->goalEntity == NPC->client->leader && !Q3_TaskIDPending( NPC, TID_MOVE_NAV ) ) { NPC_ClearGoal(); @@ -822,7 +822,7 @@ void NPC_BSDefault( void ) enemyLOS = qfalse; enemyCS = qfalse; } - + if ( enemyCS && enemyShotFOV ) {//can hit enemy if we want NPC->cantHitEnemyCounter = 0; @@ -883,7 +883,7 @@ void NPC_BSDefault( void ) {//pick a new one NPC_CheckEnemy( qtrue, qfalse ); } - + if ( enemyPVS && enemyLOS )//&& !enemyShotFOV ) {//have a clear LOS to him//, but not looking at him //Find the desired angles @@ -899,9 +899,9 @@ void NPC_BSDefault( void ) if ( UpdateGoal() ) {//have a goal - if ( !NPC->enemy - && NPC->client->leader - && NPCInfo->goalEntity == NPC->client->leader + if ( !NPC->enemy + && NPC->client->leader + && NPCInfo->goalEntity == NPC->client->leader && !Q3_TaskIDPending( NPC, TID_MOVE_NAV ) ) { NPC_BSFollowLeader(); diff --git a/codeJK2/game/AI_Droid.cpp b/codeJK2/game/AI_Droid.cpp index f911137d4b..a21c45416d 100644 --- a/codeJK2/game/AI_Droid.cpp +++ b/codeJK2/game/AI_Droid.cpp @@ -20,7 +20,7 @@ along with this program; if not, see . =========================================================================== */ #include "g_headers.h" - + #include "b_local.h" //static void R5D2_LookAround( void ); @@ -51,13 +51,13 @@ void R2D2_PartsMove(void) { NPC->pos1[1] = AngleNormalize360( NPC->pos1[1]); - NPC->pos1[0]+=Q_irand( -20, 20 ); // Roll - NPC->pos1[1]=Q_irand( -20, 20 ); - NPC->pos1[2]=Q_irand( -20, 20 ); + NPC->pos1[0]+=Q_irand( -20, 20 ); // Roll + NPC->pos1[1]=Q_irand( -20, 20 ); + NPC->pos1[2]=Q_irand( -20, 20 ); if (NPC->genericBone1) { - gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); + gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); } TIMER_Set( NPC, "eyeDelay", Q_irand( 100, 1000 ) ); } @@ -194,11 +194,11 @@ void Droid_Run( void ) if ( NPCInfo->localState == LSTATE_BACKINGUP ) { ucmd.forwardmove = -127; - NPCInfo->desiredYaw += 5; + NPCInfo->desiredYaw += 5; NPCInfo->localState = LSTATE_NONE; // So he doesn't constantly backup. } - else + else { ucmd.forwardmove = 64; //If we have somewhere to go, then do that @@ -225,7 +225,7 @@ void Droid_Spin( void ) R2D2_TurnAnims(); - + // Head is gone, spin and spark if ( NPC->client->NPC_class == CLASS_R5D2 ) { @@ -247,7 +247,7 @@ void Droid_Spin( void ) ucmd.forwardmove = Q_irand( -64, 64); if (TIMER_Done(NPC,"roam")) - { + { TIMER_Set( NPC, "roam", Q_irand( 250, 1000 ) ); NPCInfo->desiredYaw = Q_irand( 0, 360 ); // Go in random directions } @@ -264,7 +264,7 @@ void Droid_Spin( void ) } } } - else + else { if (TIMER_Done(NPC,"roam")) { @@ -284,7 +284,7 @@ void Droid_Spin( void ) NPC_BSDroid_Pain ------------------------- */ -void NPC_Droid_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Droid_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { int anim; float pain_chance; @@ -303,7 +303,7 @@ void NPC_Droid_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve { if (!(self->spawnflags & 2)) // Doesn't have to ALWAYSDIE { - if ((self->NPC->localState != LSTATE_SPINNING) && + if ((self->NPC->localState != LSTATE_SPINNING) && (!gi.G2API_GetSurfaceRenderStatus( &self->ghoul2[self->playerModel], "head" ))) { gi.G2API_SetSurfaceOnOff( &self->ghoul2[self->playerModel], "head", TURN_OFF ); @@ -339,7 +339,7 @@ void NPC_Droid_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve // Spin around in pain self->NPC->localState = LSTATE_SPINNING; TIMER_Set( self, "roam", Q_irand(1000,2000)); - } + } } } else if (self->client->NPC_class == CLASS_MOUSE) @@ -380,7 +380,7 @@ void NPC_Droid_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve // Spin around in pain self->NPC->localState = LSTATE_SPINNING; TIMER_Set( self, "roam", Q_irand(1000,2000)); - } + } } else if ( self->client->NPC_class == CLASS_INTERROGATOR && ( mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT ) && other ) { @@ -500,7 +500,7 @@ static void R5D2_OffsetLook( float offset, vec3_t out ) angles[YAW] += offset; AngleVectors( angles, forward, NULL, NULL ); VectorMA( NPC->currentOrigin, 64, forward, out ); - + CalcEntitySpot( NPC, SPOT_HEAD, temp ); out[2] = temp[2]; } diff --git a/codeJK2/game/AI_GalakMech.cpp b/codeJK2/game/AI_GalakMech.cpp index 8d8738e6a9..b3ad869f87 100644 --- a/codeJK2/game/AI_GalakMech.cpp +++ b/codeJK2/game/AI_GalakMech.cpp @@ -30,7 +30,7 @@ extern qboolean G_StandardHumanoid( const char *modelName ); extern void G_AddVoiceEvent( gentity_t *self, int event, int speakDebounceTime ); extern qboolean Q3_TaskIDPending( gentity_t *ent, taskID_t taskType ); extern void NPC_AimAdjust( int change ); -extern qboolean WP_LobFire( gentity_t *self, vec3_t start, vec3_t target, vec3_t mins, vec3_t maxs, int clipmask, +extern qboolean WP_LobFire( gentity_t *self, vec3_t start, vec3_t target, vec3_t mins, vec3_t maxs, int clipmask, vec3_t velocity, qboolean tracePath, int ignoreEntNum, int enemyNum, float minSpeed, float maxSpeed, float idealSpeed, qboolean mustHit ); extern qboolean InFront( vec3_t spot, vec3_t from, vec3_t fromAngles, float threshHold = 0.0f ); @@ -126,7 +126,7 @@ static void GM_CreateExplosion( gentity_t *self, const int boltID, qboolean doSm mdxaBone_t boltMatrix; vec3_t org, dir; - gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, + gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, boltID, &boltMatrix, self->currentAngles, self->currentOrigin, (cg.time?cg.time:level.time), NULL, self->s.modelScale ); @@ -255,7 +255,7 @@ NPC_GM_Pain */ extern void NPC_SetPainEvent( gentity_t *self ); -void NPC_GM_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_GM_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, vec3_t point, int damage, int mod,int hitLoc ) { if ( self->client->ps.powerups[PW_GALAK_SHIELD] == 0 ) {//shield is currently down @@ -387,13 +387,13 @@ static qboolean GM_Move( void ) qboolean moved = NPC_MoveToGoal( qtrue ); navInfo_t info; - + //Get the move info NAV_GetLastMove( info ); //FIXME: if we bump into another one of our guys and can't get around him, just stop! //If we hit our target, then stop and fire! - if ( info.flags & NIF_COLLISION ) + if ( info.flags & NIF_COLLISION ) { if ( info.blocker == NPC->enemy ) { @@ -454,7 +454,7 @@ static void GM_CheckMoveState( void ) if ( ( NPCInfo->goalEntity != NPC->enemy ) && ( NPCInfo->goalEntity != NULL ) ) { //Did we make it? - if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, qfalse ) || + if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, qfalse ) || ( !Q3_TaskIDPending( NPC, TID_MOVE_NAV ) && enemyLOS && enemyDist <= 10000 ) ) {//either hit our navgoal or our navgoal was not a crucial (scripted) one (maybe a combat point) and we're scouting and found our enemy NPC_ReachedGoal(); @@ -602,7 +602,7 @@ void NPC_BSGM_Attack( void ) } //FIXME: if killed enemy, use victory anim - if ( NPC->enemy && NPC->enemy->health <= 0 + if ( NPC->enemy && NPC->enemy->health <= 0 && !NPC->enemy->s.number ) {//my enemy is dead if ( NPC->client->ps.torsoAnim == BOTH_STAND2TO1 ) @@ -693,7 +693,7 @@ void NPC_BSGM_Attack( void ) VectorNormalize( smackDir ); //hurt them G_Sound( NPC->enemy, G_SoundIndex( "sound/weapons/galak/skewerhit.wav" ) ); - G_Damage( NPC->enemy, NPC, NPC, smackDir, NPC->currentOrigin, (g_spskill->integer+1)*Q_irand( 5, 10), DAMAGE_NO_ARMOR|DAMAGE_NO_KNOCKBACK, MOD_CRUSH ); + G_Damage( NPC->enemy, NPC, NPC, smackDir, NPC->currentOrigin, (g_spskill->integer+1)*Q_irand( 5, 10), DAMAGE_NO_ARMOR|DAMAGE_NO_KNOCKBACK, MOD_CRUSH ); if ( NPC->client->ps.torsoAnim == BOTH_ATTACK4 ) {//smackdown int knockAnim = BOTH_KNOCKDOWN1; @@ -800,10 +800,10 @@ void NPC_BSGM_Attack( void ) } } } - else + else {//Okay, we're not in a special attack, see if we should switch weapons or start a special attack /* - if ( NPC->s.weapon == WP_REPEATER + if ( NPC->s.weapon == WP_REPEATER && !(NPCInfo->scriptFlags & SCF_ALT_FIRE)//using rapid-fire && NPC->enemy->s.weapon == WP_SABER //enemy using saber && NPC->client && (NPC->client->ps.saberEventFlags&SEF_DEFLECTED) @@ -818,9 +818,9 @@ void NPC_BSGM_Attack( void ) } } else*/ - if ( !NPC->client->ps.powerups[PW_GALAK_SHIELD] - && enemyDist < MELEE_DIST_SQUARED - && InFront( NPC->enemy->currentOrigin, NPC->currentOrigin, NPC->client->ps.viewangles, 0.3f ) + if ( !NPC->client->ps.powerups[PW_GALAK_SHIELD] + && enemyDist < MELEE_DIST_SQUARED + && InFront( NPC->enemy->currentOrigin, NPC->currentOrigin, NPC->client->ps.viewangles, 0.3f ) && G_StandardHumanoid( NPC->enemy->NPC_type ) )//within 80 and in front {//our shield is down, and enemy within 80, if very close, use melee attack to slap away if ( TIMER_Done( NPC, "attackDelay" ) ) @@ -848,13 +848,13 @@ void NPC_BSGM_Attack( void ) && TIMER_Done( NPC, "attackDelay" ) && InFront( NPC->enemy->currentOrigin, NPC->currentOrigin, NPC->client->ps.viewangles, 0.3f ) && ((!Q_irand( 0, 10*(2-g_spskill->integer))&& enemyDist > MIN_LOB_DIST_SQUARED&& enemyDist < MAX_LOB_DIST_SQUARED) - ||(!TIMER_Done( NPC, "noLob" )&&!TIMER_Done( NPC, "noRapid" ))) + ||(!TIMER_Done( NPC, "noLob" )&&!TIMER_Done( NPC, "noRapid" ))) && NPC->enemy->s.weapon != WP_TURRET ) {//sometimes use the laser beam attack, but only after he's taken down our generator shoot = qfalse; NPC_GM_StartLaser(); } - else if ( enemyDist < MIN_LOB_DIST_SQUARED + else if ( enemyDist < MIN_LOB_DIST_SQUARED && (NPC->enemy->s.weapon != WP_TURRET || Q_stricmp( "PAS", NPC->enemy->classname )) && TIMER_Done( NPC, "noRapid" ) )//256 {//enemy within 256 @@ -902,7 +902,7 @@ void NPC_BSGM_Attack( void ) { int hit = NPC_ShotEntity( NPC->enemy, impactPos ); gentity_t *hitEnt = &g_entities[hit]; - if ( hit == NPC->enemy->s.number + if ( hit == NPC->enemy->s.number || ( hitEnt && hitEnt->client && hitEnt->client->playerTeam == NPC->client->enemyTeam ) || ( hitEnt && hitEnt->takedamage ) ) {//can hit enemy or will hit glass or other breakable, so shoot anyway @@ -961,7 +961,7 @@ void NPC_BSGM_Attack( void ) int hit = NPC_ShotEntity( NPC->enemy, impactPos ); gentity_t *hitEnt = &g_entities[hit]; - if ( hit == NPC->enemy->s.number + if ( hit == NPC->enemy->s.number || ( hitEnt && hitEnt->client && hitEnt->client->playerTeam == NPC->client->enemyTeam ) || ( hitEnt && hitEnt->takedamage ) ) {//can hit enemy or will hit glass or other breakable, so shoot anyway @@ -1021,7 +1021,7 @@ void NPC_BSGM_Attack( void ) vec3_t mins = {-REPEATER_ALT_SIZE,-REPEATER_ALT_SIZE,-REPEATER_ALT_SIZE}, maxs = {REPEATER_ALT_SIZE,REPEATER_ALT_SIZE,REPEATER_ALT_SIZE}; CalcEntitySpot( NPC, SPOT_WEAPON, muzzle ); - + VectorCopy( NPC->enemy->currentOrigin, target ); target[0] += Q_flrand( -5, 5 )+(Q_flrand(-1.0f, 1.0f)*(6-NPCInfo->currentAim)*2); @@ -1029,7 +1029,7 @@ void NPC_BSGM_Attack( void ) target[2] += Q_flrand( -5, 5 )+(Q_flrand(-1.0f, 1.0f)*(6-NPCInfo->currentAim)*2); //Find the desired angles - qboolean clearshot = WP_LobFire( NPC, muzzle, target, mins, maxs, MASK_SHOT|CONTENTS_LIGHTSABER, + qboolean clearshot = WP_LobFire( NPC, muzzle, target, mins, maxs, MASK_SHOT|CONTENTS_LIGHTSABER, velocity, qtrue, NPC->s.number, NPC->enemy->s.number, 300, 1100, 1500, qtrue ); if ( VectorCompare( vec3_origin, velocity ) || (!clearshot&&enemyLOS&&enemyCS) ) @@ -1077,11 +1077,11 @@ void NPC_BSGM_Attack( void ) if ( AImove && !NPC->lockCount ) {//move toward goal - if ( NPCInfo->goalEntity + if ( NPCInfo->goalEntity && NPC->client->ps.legsAnim != BOTH_ALERT1 - && NPC->client->ps.legsAnim != BOTH_ATTACK2 + && NPC->client->ps.legsAnim != BOTH_ATTACK2 && NPC->client->ps.legsAnim != BOTH_ATTACK4 - && NPC->client->ps.legsAnim != BOTH_ATTACK5 + && NPC->client->ps.legsAnim != BOTH_ATTACK5 && NPC->client->ps.legsAnim != BOTH_ATTACK7 ) { AImove = GM_Move(); @@ -1146,11 +1146,11 @@ void NPC_BSGM_Attack( void ) if ( NPC->client->ps.powerups[PW_GALAK_SHIELD] > 0 ) { NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME; - G_Damage( NPC->enemy, NPC, NPC, NULL, NPC->currentOrigin, 100, DAMAGE_NO_KNOCKBACK, MOD_ELECTROCUTE ); + G_Damage( NPC->enemy, NPC, NPC, NULL, NPC->currentOrigin, 100, DAMAGE_NO_KNOCKBACK, MOD_ELECTROCUTE ); } else { - G_Damage( NPC->enemy, NPC, NPC, NULL, NPC->currentOrigin, 100, DAMAGE_NO_KNOCKBACK, MOD_CRUSH ); + G_Damage( NPC->enemy, NPC, NPC, NULL, NPC->currentOrigin, 100, DAMAGE_NO_KNOCKBACK, MOD_CRUSH ); } } } @@ -1170,7 +1170,7 @@ void NPC_BSGM_Attack( void ) VectorSubtract( NPC->enemy->currentOrigin, NPC->currentOrigin, smackDir ); smackDir[2] += 30; VectorNormalize( smackDir ); - G_Damage( NPC->enemy, NPC, NPC, smackDir, NPC->currentOrigin, (g_spskill->integer+1)*Q_irand( 5, 10), DAMAGE_NO_KNOCKBACK, MOD_ELECTROCUTE ); + G_Damage( NPC->enemy, NPC, NPC, smackDir, NPC->currentOrigin, (g_spskill->integer+1)*Q_irand( 5, 10), DAMAGE_NO_KNOCKBACK, MOD_ELECTROCUTE ); //throw them G_Throw( NPC->enemy, smackDir, 100 ); NPC->enemy->s.powerups |= ( 1 << PW_SHOCKED ); @@ -1212,7 +1212,7 @@ void NPC_BSGM_Default( void ) { WeaponThink( qtrue ); } - + if ( NPC->client->ps.stats[STAT_ARMOR] <= 0 ) {//armor gone if ( !NPCInfo->investigateDebounceTime ) diff --git a/codeJK2/game/AI_Grenadier.cpp b/codeJK2/game/AI_Grenadier.cpp index 125eaf8ebd..0c1e1d8a0a 100644 --- a/codeJK2/game/AI_Grenadier.cpp +++ b/codeJK2/game/AI_Grenadier.cpp @@ -94,7 +94,7 @@ void NPC_Grenadier_PlayConfusionSound( gentity_t *self ) TIMER_Set( self, "flee", 0 ); self->NPC->squadState = SQUAD_IDLE; self->NPC->tempBehavior = BS_DEFAULT; - + //self->NPC->behaviorState = BS_PATROL; G_ClearEnemy( self );//FIXME: or just self->enemy = NULL;? @@ -108,7 +108,7 @@ NPC_ST_Pain ------------------------- */ -void NPC_Grenadier_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod ) +void NPC_Grenadier_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod ) { self->NPC->localState = LSTATE_UNDERFIRE; @@ -133,7 +133,7 @@ static void Grenadier_HoldPosition( void ) { NPC_FreeCombatPoint( NPCInfo->combatPoint, qtrue ); NPCInfo->goalEntity = NULL; - + /*if ( TIMER_Done( NPC, "stand" ) ) {//FIXME: what if can't shoot from this pos? TIMER_Set( NPC, "duck", Q_irand( 2000, 4000 ) ); @@ -153,13 +153,13 @@ static qboolean Grenadier_Move( void ) qboolean moved = NPC_MoveToGoal( qtrue ); navInfo_t info; - + //Get the move info NAV_GetLastMove( info ); //FIXME: if we bump into another one of our guys and can't get around him, just stop! //If we hit our target, then stop and fire! - if ( info.flags & NIF_COLLISION ) + if ( info.flags & NIF_COLLISION ) { if ( info.blocker == NPC->enemy ) { @@ -238,8 +238,8 @@ void NPC_BSGrenadier_Patrol( void ) NPCInfo->lastAlertID = level.alertEvents[alertEvent].ID; if ( level.alertEvents[alertEvent].level == AEL_DISCOVERED ) { - if ( level.alertEvents[alertEvent].owner && - level.alertEvents[alertEvent].owner->client && + if ( level.alertEvents[alertEvent].owner && + level.alertEvents[alertEvent].owner->client && level.alertEvents[alertEvent].owner->health >= 0 && level.alertEvents[alertEvent].owner->client->playerTeam == NPC->client->enemyTeam ) {//an enemy @@ -266,15 +266,15 @@ void NPC_BSGrenadier_Patrol( void ) //NOTE: stops walking or doing anything else below vec3_t dir, angles; float o_yaw, o_pitch; - + VectorSubtract( NPCInfo->investigateGoal, NPC->client->renderInfo.eyePoint, dir ); vectoangles( dir, angles ); - + o_yaw = NPCInfo->desiredYaw; o_pitch = NPCInfo->desiredPitch; NPCInfo->desiredYaw = angles[YAW]; NPCInfo->desiredPitch = angles[PITCH]; - + NPC_UpdateAngles( qtrue, qtrue ); NPCInfo->desiredYaw = o_yaw; @@ -361,7 +361,7 @@ static void Grenadier_CheckMoveState( void ) if ( ( NPCInfo->goalEntity != NPC->enemy ) && ( NPCInfo->goalEntity != NULL ) ) { //Did we make it? - if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, FlyingCreature( NPC ) ) || + if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, FlyingCreature( NPC ) ) || ( NPCInfo->squadState == SQUAD_SCOUT && enemyLOS && enemyDist <= 10000 ) ) { //int newSquadState = SQUAD_STAND_AND_SHOOT; @@ -554,12 +554,12 @@ void NPC_BSGrenadier_Attack( void ) } } else if ( InFOV( NPC->enemy->currentOrigin, NPC->currentOrigin, NPC->client->ps.viewangles, 45, 90 ) ) - {//in front of me + {//in front of me //can we shoot our target? //FIXME: how accurate/necessary is this check? int hit = NPC_ShotEntity( NPC->enemy ); gentity_t *hitEnt = &g_entities[hit]; - if ( hit == NPC->enemy->s.number + if ( hit == NPC->enemy->s.number || ( hitEnt && hitEnt->client && hitEnt->client->playerTeam == NPC->client->enemyTeam ) ) { VectorCopy( NPC->enemy->currentOrigin, NPCInfo->enemyLastSeenLocation ); @@ -661,13 +661,13 @@ void NPC_BSGrenadier_Attack( void ) if ( shoot ) {//try to shoot if it's time if ( TIMER_Done( NPC, "attackDelay" ) ) - { + { if( !(NPCInfo->scriptFlags & SCF_FIRE_WEAPON) ) // we've already fired, no need to do it again here { WeaponThink( qtrue ); TIMER_Set( NPC, "attackDelay", NPCInfo->shotTime-level.time ); } - + } } } diff --git a/codeJK2/game/AI_Howler.cpp b/codeJK2/game/AI_Howler.cpp index 3930b0d8b4..0332b8716f 100644 --- a/codeJK2/game/AI_Howler.cpp +++ b/codeJK2/game/AI_Howler.cpp @@ -20,7 +20,7 @@ along with this program; if not, see . =========================================================================== */ #include "g_headers.h" - + #include "b_local.h" // These define the working combat range for these suckers @@ -91,7 +91,7 @@ void Howler_Patrol( void ) return; } } - + /* ------------------------- Howler_Move @@ -169,7 +169,7 @@ void Howler_Combat( void ) // Sometimes I have problems with facing the enemy I'm attacking, so force the issue so I don't look dumb NPC_FaceEnemy( qtrue ); - float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean advance = (qboolean)( distance > MIN_DISTANCE_SQR ? qtrue : qfalse ); @@ -195,7 +195,7 @@ void Howler_Combat( void ) NPC_Howler_Pain ------------------------- */ -void NPC_Howler_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Howler_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { if ( damage >= 10 ) { diff --git a/codeJK2/game/AI_ImperialProbe.cpp b/codeJK2/game/AI_ImperialProbe.cpp index a7fb3aeb2d..fbb58c3925 100644 --- a/codeJK2/game/AI_ImperialProbe.cpp +++ b/codeJK2/game/AI_ImperialProbe.cpp @@ -67,7 +67,7 @@ Hunter_MaintainHeight #define VELOCITY_DECAY 0.85f void ImperialProbe_MaintainHeight( void ) -{ +{ float dif; // vec3_t endPos; // trace_t trace; @@ -79,7 +79,7 @@ void ImperialProbe_MaintainHeight( void ) if ( NPC->enemy ) { // Find the height difference - dif = NPC->enemy->currentOrigin[2] - NPC->currentOrigin[2]; + dif = NPC->enemy->currentOrigin[2] - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 8 ) @@ -153,7 +153,7 @@ void ImperialProbe_MaintainHeight( void ) ucmd.upmove = -32; } else - { + { if ( NPC->client->ps.velocity[2] ) { NPC->client->ps.velocity[2] *= VELOCITY_DECAY; @@ -293,7 +293,7 @@ void ImperialProbe_FireBlaster(void) mdxaBone_t boltMatrix; //FIXME: use {0, NPC->client->ps.legsYaw, 0} - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, NPC->genericBolt1, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -327,7 +327,7 @@ void ImperialProbe_FireBlaster(void) { missile->damage = 5; } - else + else { missile->damage = 10; } @@ -416,7 +416,7 @@ void ImperialProbe_AttackDecision( void ) NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_RUN1, SETANIM_FLAG_NORMAL); // Rate our distance to the target, and our visibilty - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); // distance_e distRate = ( distance > MIN_MELEE_RANGE_SQR ) ? DIST_LONG : DIST_MELEE; qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); @@ -443,10 +443,10 @@ void ImperialProbe_AttackDecision( void ) NPC_BSDroid_Pain ------------------------- */ -void NPC_Probe_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Probe_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { float pain_chance; - + VectorCopy( self->NPC->lastPathAngles, self->s.angles ); if ( self->health < 30 || mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT ) // demp2 always messes them up real good @@ -472,7 +472,7 @@ void NPC_Probe_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve self->NPC->stats.moveType = MT_RUNJUMP; self->client->ps.gravity = g_gravity->value*.1; } - + if ( (mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT) && other ) { vec3_t dir; @@ -490,7 +490,7 @@ void NPC_Probe_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve self->client->ps.powerups[PW_SHOCKED] = level.time + 3000; self->NPC->localState = LSTATE_DROP; - } + } } else { @@ -499,7 +499,7 @@ void NPC_Probe_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve if ( Q_flrand(0.0f, 1.0f) < pain_chance ) // Spin around in pain? { NPC_SetAnim( self, SETANIM_BOTH, BOTH_PAIN1, SETANIM_FLAG_OVERRIDE); - } + } } NPC_Pain( self, inflictor, other, point, damage, mod); @@ -582,8 +582,8 @@ void ImperialProbe_Wait(void) if ( trace.fraction != 1.0f ) { - G_Damage(NPC, NPC->enemy, NPC->enemy, NULL, NULL, 2000, 0,MOD_UNKNOWN); - } + G_Damage(NPC, NPC->enemy, NPC->enemy, NULL, NULL, 2000, 0,MOD_UNKNOWN); + } } NPC_UpdateAngles( qtrue, qtrue ); diff --git a/codeJK2/game/AI_Interrogator.cpp b/codeJK2/game/AI_Interrogator.cpp index c81111f08a..550d6796bb 100644 --- a/codeJK2/game/AI_Interrogator.cpp +++ b/codeJK2/game/AI_Interrogator.cpp @@ -93,18 +93,18 @@ void Interrogator_PartsMove(void) if ((NPC->pos1[1] < 60) || (NPC->pos1[1] > 300)) { - NPC->pos1[1]+=Q_irand( -20, 20 ); // Pitch + NPC->pos1[1]+=Q_irand( -20, 20 ); // Pitch } else if (NPC->pos1[1] > 180) { - NPC->pos1[1]=Q_irand( 300, 360 ); // Pitch + NPC->pos1[1]=Q_irand( 300, 360 ); // Pitch } - else + else { - NPC->pos1[1]=Q_irand( 0, 60 ); // Pitch + NPC->pos1[1]=Q_irand( 0, 60 ); // Pitch } - gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); + gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone1, NPC->pos1, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); TIMER_Set( NPC, "syringeDelay", Q_irand( 100, 1000 ) ); } @@ -133,13 +133,13 @@ void Interrogator_PartsMove(void) } NPC->pos2[0] = AngleNormalize360( NPC->pos2[0]); - gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone2, NPC->pos2, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); + gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone2, NPC->pos2, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); } // Claw NPC->pos3[1] += Q_irand( 10, 30 ); NPC->pos3[1] = AngleNormalize360( NPC->pos3[1]); - gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone3, NPC->pos3, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); + gi.G2API_SetBoneAnglesIndex( &NPC->ghoul2[NPC->playerModel], NPC->genericBone3, NPC->pos3, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, 0 ); } @@ -152,7 +152,7 @@ Interrogator_MaintainHeight ------------------------- */ void Interrogator_MaintainHeight( void ) -{ +{ float dif; // vec3_t endPos; // trace_t trace; @@ -165,7 +165,7 @@ void Interrogator_MaintainHeight( void ) if ( NPC->enemy ) { // Find the height difference - dif = (NPC->enemy->currentOrigin[2] + NPC->enemy->maxs[2]) - NPC->currentOrigin[2]; + dif = (NPC->enemy->currentOrigin[2] + NPC->enemy->maxs[2]) - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 2 ) @@ -277,7 +277,7 @@ void Interrogator_Strafe( void ) if ( NPC->enemy ) { // Find the height difference - dif = (NPC->enemy->currentOrigin[2] + 32) - NPC->currentOrigin[2]; + dif = (NPC->enemy->currentOrigin[2] + 32) - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 8 ) @@ -289,7 +289,7 @@ void Interrogator_Strafe( void ) } - // Set the strafe start time + // Set the strafe start time NPC->fx_time = level.time; NPCInfo->standTime = level.time + 3000 + Q_flrand(0.0f, 1.0f) * 500; } @@ -415,7 +415,7 @@ void Interrogator_Attack( void ) } // Rate our distance to the target, and our visibilty - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE*MIN_DISTANCE ); diff --git a/codeJK2/game/AI_Mark1.cpp b/codeJK2/game/AI_Mark1.cpp index 7c9bdaddb9..ff25e8dd9c 100644 --- a/codeJK2/game/AI_Mark1.cpp +++ b/codeJK2/game/AI_Mark1.cpp @@ -105,7 +105,7 @@ void NPC_Mark1_Part_Explode( gentity_t *self, int bolt ) mdxaBone_t boltMatrix; vec3_t org, dir; - gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, + gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, bolt, &boltMatrix, self->currentAngles, self->currentOrigin, (cg.time?cg.time:level.time), NULL, self->s.modelScale ); @@ -145,7 +145,7 @@ void Mark1Dead_FireRocket (void) int damage = 50; - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, NPC->genericBolt5, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -190,9 +190,9 @@ void Mark1Dead_FireBlaster (void) mdxaBone_t boltMatrix; int bolt; - bolt = NPC->genericBolt1; + bolt = NPC->genericBolt1; - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, bolt, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -228,7 +228,7 @@ void Mark1_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int // Is he dead already? anim = self->client->ps.legsAnim; - if (((anim==BOTH_DEATH1) || (anim==BOTH_DEATH2)) && (self->client->ps.torsoAnimTimer==0)) + if (((anim==BOTH_DEATH1) || (anim==BOTH_DEATH2)) && (self->client->ps.torsoAnimTimer==0)) { // This is because self->health keeps getting zeroed out. HL_NONE acts as health in this case. self->locationDamage[HL_NONE] += damage; if (self->locationDamage[HL_NONE] > 50) @@ -332,10 +332,10 @@ NPC_Mark1_Pain - look at what was hit and see if it should be removed from the model. ------------------------- */ -void NPC_Mark1_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Mark1_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { int newBolt,i,chance; - + NPC_Pain( self, inflictor, other, point, damage, mod ); G_Sound( self, G_SoundIndex("sound/chars/mark1/misc/mark1_pain")); @@ -344,7 +344,7 @@ void NPC_Mark1_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve if (hitLoc==HL_CHEST) { chance = Q_irand( 1, 4); - + if ((chance == 1) && (damage > 5)) { NPC_SetAnim( self, SETANIM_BOTH, BOTH_PAIN1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); @@ -368,7 +368,7 @@ void NPC_Mark1_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve else if ((hitLoc==HL_ARM_RT) && (self->locationDamage[HL_ARM_RT] > RIGHT_ARM_HEALTH)) // Blow it up? { if (self->locationDamage[hitLoc] >= RIGHT_ARM_HEALTH) - { + { newBolt = gi.G2API_AddBolt( &self->ghoul2[self->playerModel], "*flash4" ); if ( newBolt != -1 ) { @@ -387,7 +387,7 @@ void NPC_Mark1_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve if ((hitLoc==HL_GENERIC1+i) && (self->locationDamage[HL_GENERIC1+i] > AMMO_POD_HEALTH)) // Blow it up? { if (self->locationDamage[hitLoc] >= AMMO_POD_HEALTH) - { + { newBolt = gi.G2API_AddBolt( &self->ghoul2[self->playerModel], va("*torso_tube%d",(i+1)) ); if ( newBolt != -1 ) { @@ -445,28 +445,28 @@ void Mark1_FireBlaster(void) int bolt; // Which muzzle to fire from? - if ((NPCInfo->localState <= LSTATE_FIRED0) || (NPCInfo->localState == LSTATE_FIRED4)) + if ((NPCInfo->localState <= LSTATE_FIRED0) || (NPCInfo->localState == LSTATE_FIRED4)) { NPCInfo->localState = LSTATE_FIRED1; - bolt = NPC->genericBolt1; + bolt = NPC->genericBolt1; } else if (NPCInfo->localState == LSTATE_FIRED1) { NPCInfo->localState = LSTATE_FIRED2; - bolt = NPC->genericBolt2; + bolt = NPC->genericBolt2; } else if (NPCInfo->localState == LSTATE_FIRED2) { NPCInfo->localState = LSTATE_FIRED3; - bolt = NPC->genericBolt3; + bolt = NPC->genericBolt3; } else { NPCInfo->localState = LSTATE_FIRED4; - bolt = NPC->genericBolt4; + bolt = NPC->genericBolt4; } - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, bolt, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -513,7 +513,7 @@ void Mark1_BlasterAttack(qboolean advance ) if ( TIMER_Done( NPC, "attackDelay" ) ) // Attack? { chance = Q_irand( 1, 5); - + NPCInfo->burstCount++; if (NPCInfo->burstCount<3) // Too few shots this burst? @@ -574,7 +574,7 @@ void Mark1_FireRocket(void) int damage = 50; - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, NPC->genericBolt5, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -656,7 +656,7 @@ void Mark1_AttackDecision( void ) } // Rate our distance to the target and visibility - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); distance_e distRate = ( distance > MIN_MELEE_RANGE_SQR ) ? DIST_LONG : DIST_MELEE; qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); @@ -686,7 +686,7 @@ void Mark1_AttackDecision( void ) distRate = DIST_MELEE; } else // It should never get here, but just in case - { + { NPC->health = 0; NPC->client->ps.stats[STAT_HEALTH] = 0; GEntity_DieFunc(NPC, NPC, NPC, 100, MOD_UNKNOWN); diff --git a/codeJK2/game/AI_Mark2.cpp b/codeJK2/game/AI_Mark2.cpp index 8d37ddcccc..9ae2e0b37a 100644 --- a/codeJK2/game/AI_Mark2.cpp +++ b/codeJK2/game/AI_Mark2.cpp @@ -77,7 +77,7 @@ void NPC_Mark2_Part_Explode( gentity_t *self, int bolt ) mdxaBone_t boltMatrix; vec3_t org, dir; - gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, + gi.G2API_GetBoltMatrix( self->ghoul2, self->playerModel, bolt, &boltMatrix, self->currentAngles, self->currentOrigin, (cg.time?cg.time:level.time), NULL, self->s.modelScale ); @@ -99,10 +99,10 @@ NPC_Mark2_Pain - look at what was hit and see if it should be removed from the model. ------------------------- */ -void NPC_Mark2_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Mark2_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { int newBolt,i; - + NPC_Pain( self, inflictor, other, point, damage, mod ); for (i=0;i<3;i++) @@ -110,7 +110,7 @@ void NPC_Mark2_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, ve if ((hitLoc==HL_GENERIC1+i) && (self->locationDamage[HL_GENERIC1+i] > AMMO_POD_HEALTH)) // Blow it up? { if (self->locationDamage[hitLoc] >= AMMO_POD_HEALTH) - { + { newBolt = gi.G2API_AddBolt( &self->ghoul2[self->playerModel], va("torso_canister%d",(i+1)) ); if ( newBolt != -1 ) { @@ -162,7 +162,7 @@ void Mark2_FireBlaster(qboolean advance) gentity_t *missile; mdxaBone_t boltMatrix; - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, NPC->genericBolt1, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -232,7 +232,7 @@ void Mark2_AttackDecision( void ) { NPC_FaceEnemy( qtrue ); - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); @@ -241,7 +241,7 @@ void Mark2_AttackDecision( void ) { NPC->flags &= ~FL_SHIELDED; NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_RUN1START, SETANIM_FLAG_HOLD|SETANIM_FLAG_OVERRIDE ); - if ((NPC->client->ps.legsAnimTimer==0) && + if ((NPC->client->ps.legsAnimTimer==0) && NPC->client->ps.torsoAnim == BOTH_RUN1START ) { NPCInfo->localState = LSTATE_NONE; // He's up again. diff --git a/codeJK2/game/AI_MineMonster.cpp b/codeJK2/game/AI_MineMonster.cpp index eac149a7cb..2ef79be180 100644 --- a/codeJK2/game/AI_MineMonster.cpp +++ b/codeJK2/game/AI_MineMonster.cpp @@ -20,7 +20,7 @@ along with this program; if not, see . =========================================================================== */ #include "g_headers.h" - + #include "b_local.h" extern void G_SoundOnEnt( gentity_t *ent, soundChannel_t channel, const char *soundPath ); @@ -103,7 +103,7 @@ void MineMonster_Patrol( void ) return; } } - + /* ------------------------- MineMonster_Move @@ -153,7 +153,7 @@ void MineMonster_Attack( void ) if ( !TIMER_Exists( NPC, "attacking" )) { // usually try and play a jump attack if the player somehow got above them....or just really rarely - if ( NPC->enemy && ((NPC->enemy->currentOrigin[2] - NPC->currentOrigin[2] > 10 && Q_flrand(0.0f, 1.0f) > 0.1f ) + if ( NPC->enemy && ((NPC->enemy->currentOrigin[2] - NPC->currentOrigin[2] > 10 && Q_flrand(0.0f, 1.0f) > 0.1f ) || Q_flrand(0.0f, 1.0f) > 0.8f )) { // Going to do ATTACK4 @@ -224,7 +224,7 @@ void MineMonster_Combat( void ) // Sometimes I have problems with facing the enemy I'm attacking, so force the issue so I don't look dumb NPC_FaceEnemy( qtrue ); - float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean advance = (qboolean)( distance > MIN_DISTANCE_SQR ? qtrue : qfalse ); @@ -250,7 +250,7 @@ void MineMonster_Combat( void ) NPC_MineMonster_Pain ------------------------- */ -void NPC_MineMonster_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_MineMonster_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { G_AddEvent( self, EV_PAIN, floor((float)self->health/self->max_health*100.0f) ); diff --git a/codeJK2/game/AI_Remote.cpp b/codeJK2/game/AI_Remote.cpp index 520ffdb65e..09e388c325 100644 --- a/codeJK2/game/AI_Remote.cpp +++ b/codeJK2/game/AI_Remote.cpp @@ -50,7 +50,7 @@ void NPC_Remote_Precache(void) NPC_Remote_Pain ------------------------- */ -void NPC_Remote_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Remote_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { SaveNPCGlobals(); SetNPCGlobals( self ); @@ -66,7 +66,7 @@ Remote_MaintainHeight ------------------------- */ void Remote_MaintainHeight( void ) -{ +{ float dif; // Update our angles regardless @@ -89,7 +89,7 @@ void Remote_MaintainHeight( void ) TIMER_Set( NPC,"heightChange",Q_irand( 1000, 3000 )); // Find the height difference - dif = (NPC->enemy->currentOrigin[2] + Q_irand( 0, NPC->enemy->maxs[2]+8 )) - NPC->currentOrigin[2]; + dif = (NPC->enemy->currentOrigin[2] + Q_irand( 0, NPC->enemy->maxs[2]+8 )) - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 2 ) @@ -259,7 +259,7 @@ void Remote_Fire (void) CalcEntitySpot( NPC->enemy, SPOT_HEAD, enemy_org1 ); VectorCopy( NPC->currentOrigin, muzzle1 ); - + VectorSubtract (enemy_org1, muzzle1, delta1); vectoangles ( delta1, angleToEnemy1 ); @@ -315,7 +315,7 @@ void Remote_Attack( void ) if ( TIMER_Done(NPC,"spin") ) { TIMER_Set( NPC, "spin", Q_irand( 250, 1500 ) ); - NPCInfo->desiredYaw += Q_irand( -200, 200 ); + NPCInfo->desiredYaw += Q_irand( -200, 200 ); } // Always keep a good height off the ground Remote_MaintainHeight(); @@ -328,7 +328,7 @@ void Remote_Attack( void ) } // Rate our distance to the target, and our visibilty - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); // distance_e distRate = ( distance > MIN_MELEE_RANGE_SQR ) ? DIST_LONG : DIST_MELEE; qboolean visible = NPC_ClearLOS( NPC->enemy ); float idealDist = MIN_DISTANCE_SQR+(MIN_DISTANCE_SQR*Q_flrand( 0, 1 )); diff --git a/codeJK2/game/AI_Seeker.cpp b/codeJK2/game/AI_Seeker.cpp index e347a64234..69d20abda6 100644 --- a/codeJK2/game/AI_Seeker.cpp +++ b/codeJK2/game/AI_Seeker.cpp @@ -54,7 +54,7 @@ void NPC_Seeker_Precache(void) } //------------------------------------ -void NPC_Seeker_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +void NPC_Seeker_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) { if ( !(self->svFlags & SVF_CUSTOM_GRAVITY )) {//void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, vec3_t point, int damage, int dflags, int mod, int hitLoc=HL_NONE ); @@ -70,7 +70,7 @@ void NPC_Seeker_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, v //------------------------------------ void Seeker_MaintainHeight( void ) -{ +{ float dif; // Update our angles regardless @@ -84,7 +84,7 @@ void Seeker_MaintainHeight( void ) TIMER_Set( NPC,"heightChange",Q_irand( 1000, 3000 )); // Find the height difference - dif = (NPC->enemy->currentOrigin[2] + Q_flrand( NPC->enemy->maxs[2]/2, NPC->enemy->maxs[2]+8 )) - NPC->currentOrigin[2]; + dif = (NPC->enemy->currentOrigin[2] + Q_flrand( NPC->enemy->maxs[2]/2, NPC->enemy->maxs[2]+8 )) - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 2 ) @@ -320,7 +320,7 @@ void Seeker_Ranged( qboolean visible, qboolean advance ) { Seeker_Hunt( visible, advance ); } -} +} //------------------------------------ void Seeker_Attack( void ) @@ -329,7 +329,7 @@ void Seeker_Attack( void ) Seeker_MaintainHeight(); // Rate our distance to the target, and our visibilty - float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); @@ -359,7 +359,7 @@ void Seeker_FindEnemy( void ) numFound = gi.EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); - for ( int i = 0 ; i < numFound ; i++ ) + for ( int i = 0 ; i < numFound ; i++ ) { ent = entityList[i]; @@ -404,7 +404,7 @@ void Seeker_FollowPlayer( void ) float dis = DistanceHorizontalSquared( NPC->currentOrigin, g_entities[0].currentOrigin ); vec3_t pt, dir; - + if ( dis < MIN_DISTANCE_SQR ) { // generally circle the player closely till we take an enemy..this is our target point diff --git a/codeJK2/game/AI_Sentry.cpp b/codeJK2/game/AI_Sentry.cpp index 6d56d5163f..b96ebc9df7 100644 --- a/codeJK2/game/AI_Sentry.cpp +++ b/codeJK2/game/AI_Sentry.cpp @@ -96,8 +96,8 @@ void sentry_use( gentity_t *self, gentity_t *other, gentity_t *activator) NPC_Sentry_Pain ------------------------- */ -void NPC_Sentry_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) -{ +void NPC_Sentry_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod,int hitLoc ) +{ NPC_Pain( self, inflictor, other, point, damage, mod ); if ( mod == MOD_DEMP2 || mod == MOD_DEMP2_ALT ) @@ -106,7 +106,7 @@ void NPC_Sentry_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, v TIMER_Set( self, "attackDelay", Q_irand( 9000, 12000) ); self->flags |= FL_SHIELDED; NPC_SetAnim( self, SETANIM_BOTH, BOTH_FLY_SHIELDED, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); - G_SoundOnEnt( self, CHAN_AUTO, "sound/chars/sentry/misc/sentry_pain" ); + G_SoundOnEnt( self, CHAN_AUTO, "sound/chars/sentry/misc/sentry_pain" ); self->NPC->localState = LSTATE_ACTIVE; } @@ -154,7 +154,7 @@ void Sentry_Fire (void) { NPCInfo->localState = LSTATE_POWERING_UP; - G_SoundOnEnt( NPC, CHAN_AUTO, "sound/chars/sentry/misc/sentry_shield_open" ); + G_SoundOnEnt( NPC, CHAN_AUTO, "sound/chars/sentry/misc/sentry_shield_open" ); NPC_SetAnim( NPC, SETANIM_BOTH, BOTH_POWERUP1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD ); TIMER_Set( NPC, "powerup", 250 ); return; @@ -171,17 +171,17 @@ void Sentry_Fire (void) switch( which ) { case 0: - bolt = NPC->genericBolt1; + bolt = NPC->genericBolt1; break; case 1: - bolt = NPC->genericBolt2; + bolt = NPC->genericBolt2; break; case 2: default: - bolt = NPC->genericBolt3; + bolt = NPC->genericBolt3; } - gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, + gi.G2API_GetBoltMatrix( NPC->ghoul2, NPC->playerModel, bolt, &boltMatrix, NPC->currentAngles, NPC->currentOrigin, (cg.time?cg.time:level.time), NULL, NPC->s.modelScale ); @@ -225,7 +225,7 @@ Sentry_MaintainHeight ------------------------- */ void Sentry_MaintainHeight( void ) -{ +{ float dif; NPC->s.loopSound = G_SoundIndex( "sound/chars/sentry/misc/sentry_hover_1_lp" ); @@ -237,7 +237,7 @@ void Sentry_MaintainHeight( void ) if ( NPC->enemy ) { // Find the height difference - dif = (NPC->enemy->currentOrigin[2]+NPC->enemy->maxs[2]) - NPC->currentOrigin[2]; + dif = (NPC->enemy->currentOrigin[2]+NPC->enemy->maxs[2]) - NPC->currentOrigin[2]; // cap to prevent dramatic height shifts if ( fabs( dif ) > 8 ) @@ -503,7 +503,7 @@ void Sentry_AttackDecision( void ) } // Rate our distance to the target and visibilty - float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); + float distance = (int) DistanceHorizontalSquared( NPC->currentOrigin, NPC->enemy->currentOrigin ); qboolean visible = NPC_ClearLOS( NPC->enemy ); qboolean advance = (qboolean)(distance > MIN_DISTANCE_SQR); diff --git a/codeJK2/game/AI_Sniper.cpp b/codeJK2/game/AI_Sniper.cpp index c76231e067..361ef28ea9 100644 --- a/codeJK2/game/AI_Sniper.cpp +++ b/codeJK2/game/AI_Sniper.cpp @@ -109,7 +109,7 @@ NPC_ST_Pain ------------------------- */ -void NPC_Sniper_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod ) +void NPC_Sniper_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod ) { self->NPC->localState = LSTATE_UNDERFIRE; @@ -134,7 +134,7 @@ static void Sniper_HoldPosition( void ) { NPC_FreeCombatPoint( NPCInfo->combatPoint, qtrue ); NPCInfo->goalEntity = NULL; - + /*if ( TIMER_Done( NPC, "stand" ) ) {//FIXME: what if can't shoot from this pos? TIMER_Set( NPC, "duck", Q_irand( 2000, 4000 ) ); @@ -154,13 +154,13 @@ static qboolean Sniper_Move( void ) qboolean moved = NPC_MoveToGoal( qtrue ); navInfo_t info; - + //Get the move info NAV_GetLastMove( info ); //FIXME: if we bump into another one of our guys and can't get around him, just stop! //If we hit our target, then stop and fire! - if ( info.flags & NIF_COLLISION ) + if ( info.flags & NIF_COLLISION ) { if ( info.blocker == NPC->enemy ) { @@ -241,8 +241,8 @@ void NPC_BSSniper_Patrol( void ) NPCInfo->lastAlertID = level.alertEvents[alertEvent].ID; if ( level.alertEvents[alertEvent].level == AEL_DISCOVERED ) { - if ( level.alertEvents[alertEvent].owner && - level.alertEvents[alertEvent].owner->client && + if ( level.alertEvents[alertEvent].owner && + level.alertEvents[alertEvent].owner->client && level.alertEvents[alertEvent].owner->health >= 0 && level.alertEvents[alertEvent].owner->client->playerTeam == NPC->client->enemyTeam ) {//an enemy @@ -270,15 +270,15 @@ void NPC_BSSniper_Patrol( void ) //NOTE: stops walking or doing anything else below vec3_t dir, angles; float o_yaw, o_pitch; - + VectorSubtract( NPCInfo->investigateGoal, NPC->client->renderInfo.eyePoint, dir ); vectoangles( dir, angles ); - + o_yaw = NPCInfo->desiredYaw; o_pitch = NPCInfo->desiredPitch; NPCInfo->desiredYaw = angles[YAW]; NPCInfo->desiredPitch = angles[PITCH]; - + NPC_UpdateAngles( qtrue, qtrue ); NPCInfo->desiredYaw = o_yaw; @@ -365,7 +365,7 @@ static void Sniper_CheckMoveState( void ) if ( ( NPCInfo->goalEntity != NPC->enemy ) && ( NPCInfo->goalEntity != NULL ) ) { //Did we make it? - if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, FlyingCreature( NPC ) ) || + if ( NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, NPCInfo->goalEntity->currentOrigin, 16, FlyingCreature( NPC ) ) || ( NPCInfo->squadState == SQUAD_SCOUT && enemyLOS && enemyDist <= 10000 ) ) { //int newSquadState = SQUAD_STAND_AND_SHOOT; @@ -515,7 +515,7 @@ qboolean Sniper_EvaluateShot( int hit ) } gentity_t *hitEnt = &g_entities[hit]; - if ( hit == NPC->enemy->s.number + if ( hit == NPC->enemy->s.number || ( hitEnt && hitEnt->client && hitEnt->client->playerTeam == NPC->client->enemyTeam ) || ( hitEnt && hitEnt->takedamage && ((hitEnt->svFlags&SVF_GLASS_BRUSH)||hitEnt->health < 40||NPC->s.weapon == WP_EMPLACED_GUN) ) || ( hitEnt && (hitEnt->svFlags&SVF_GLASS_BRUSH)) ) @@ -649,7 +649,7 @@ NPC_BSSniper_Attack void Sniper_StartHide( void ) { int duckTime = Q_irand( 2000, 5000 ); - + TIMER_Set( NPC, "duck", duckTime ); TIMER_Set( NPC, "watch", 500 ); TIMER_Set( NPC, "attackDelay", duckTime + Q_irand( 500, 2000 ) ); @@ -806,9 +806,9 @@ void NPC_BSSniper_Attack( void ) TIMER_Set( NPC, "duck", -1 ); } - if ( TIMER_Done( NPC, "duck" ) - && TIMER_Done( NPC, "watch" ) - && (TIMER_Get( NPC, "attackDelay" )-level.time) > 1000 + if ( TIMER_Done( NPC, "duck" ) + && TIMER_Done( NPC, "watch" ) + && (TIMER_Get( NPC, "attackDelay" )-level.time) > 1000 && NPC->attackDebounceTime < level.time ) { if ( enemyLOS && (NPCInfo->scriptFlags&SCF_ALT_FIRE) ) diff --git a/codeJK2/game/AI_Utils.cpp b/codeJK2/game/AI_Utils.cpp index 0ff327ad92..62e0c45c09 100644 --- a/codeJK2/game/AI_Utils.cpp +++ b/codeJK2/game/AI_Utils.cpp @@ -20,7 +20,7 @@ along with this program; if not, see . =========================================================================== */ -// These utilities are meant for strictly non-player, non-team NPCs. +// These utilities are meant for strictly non-player, non-team NPCs. // These functions are in their own file because they are only intended // for use with NPCs who's logic has been overriden from the original // AI code, and who's code resides in files with the AI_ prefix. @@ -246,9 +246,9 @@ qboolean AI_TryJoinPreviousGroup( gentity_t *self ) int i; for ( i = 0; i < MAX_FRAME_GROUPS; i++ ) { - if ( level.groups[i].numGroup - && level.groups[i].numGroup < (MAX_GROUP_MEMBERS - 1) - //&& level.groups[i].enemy != NULL + if ( level.groups[i].numGroup + && level.groups[i].numGroup < (MAX_GROUP_MEMBERS - 1) + //&& level.groups[i].enemy != NULL && level.groups[i].enemy == self->enemy ) {//has members, not full and has my enemy if ( AI_ValidateGroupMember( &level.groups[i], self ) ) @@ -272,7 +272,7 @@ qboolean AI_GetNextEmptyGroup( gentity_t *self ) {//try to just put us in one that already exists return qfalse; } - + //okay, make a whole new one, then for ( int i = 0; i < MAX_FRAME_GROUPS; i++ ) { @@ -367,7 +367,7 @@ qboolean AI_ValidateGroupMember( AIGroupInfo_t *group, gentity_t *member ) member->client->ps.weapon == WP_EMPLACED_GUN || member->client->ps.weapon == WP_BOT_LASER || // Probe droid - Laser blast member->client->ps.weapon == WP_MELEE || - member->client->ps.weapon == WP_TURRET || // turret guns + member->client->ps.weapon == WP_TURRET || // turret guns member->client->ps.weapon == WP_ATST_MAIN || member->client->ps.weapon == WP_ATST_SIDE || member->client->ps.weapon == WP_TIE_FIGHTER ) @@ -489,7 +489,7 @@ void AI_GetGroup( gentity_t *self ) {//FIXME: keep track of those who aren't angry yet and see if we should wake them after we assemble the core group continue; } - + //store it AI_InsertGroupMember( self->NPC->group, member ); @@ -506,7 +506,7 @@ void AI_GetGroup( gentity_t *self ) for ( i = 0; i < numWaiters; i++ ) { waiter = &g_entities[waiters[i]]; - + for ( j = 0; j < self->NPC->group->numGroup; j++ ) { member = &g_entities[self->NPC->group->member[j]; @@ -712,7 +712,7 @@ qboolean AI_RefreshGroup( AIGroupInfo_t *group ) int i;//, j; //see if we should merge with another group - for ( i = 0; i < MAX_FRAME_GROUPS; i++ ) + for ( i = 0; i < MAX_FRAME_GROUPS; i++ ) { if ( &level.groups[i] == group ) { @@ -934,9 +934,9 @@ void AI_UpdateGroups( void ) return; } //Clear all Groups - for ( int i = 0; i < MAX_FRAME_GROUPS; i++ ) + for ( int i = 0; i < MAX_FRAME_GROUPS; i++ ) { - if ( !level.groups[i].numGroup || AI_RefreshGroup( &level.groups[i] ) == qfalse )//level.groups[i].enemy == NULL || + if ( !level.groups[i].numGroup || AI_RefreshGroup( &level.groups[i] ) == qfalse )//level.groups[i].enemy == NULL || { memset( &level.groups[i], 0, sizeof( level.groups[i] ) ); } @@ -958,7 +958,7 @@ qboolean AI_GroupContainsEntNum( AIGroupInfo_t *group, int entNum ) } return qfalse; } -//Overload +//Overload /* void AI_GetGroup( AIGroupInfo_t &group, gentity_t *ent, int radius ) diff --git a/codeJK2/game/CMakeLists.txt b/codeJK2/game/CMakeLists.txt index 00f898e0d5..2790dc81fe 100644 --- a/codeJK2/game/CMakeLists.txt +++ b/codeJK2/game/CMakeLists.txt @@ -1,17 +1,17 @@ #============================================================================ # Copyright (C) 2013 - 2018, 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 . #============================================================================ @@ -127,7 +127,7 @@ set(JK2SPGameGameFiles "${JK2SPDir}/game/wp_stun_baton.cpp" "${JK2SPDir}/game/wp_thermal.cpp" "${JK2SPDir}/game/wp_trip_mine.cpp" - "${JK2SPDir}/game/Q3_Interface.h" + "${JK2SPDir}/game/Q3_Interface.h" "${JK2SPDir}/game/Q3_Registers.h" "${JK2SPDir}/game/ai.h" "${JK2SPDir}/game/anims.h" diff --git a/codeJK2/game/G_Timer.cpp b/codeJK2/game/G_Timer.cpp index b074b6a35c..068db56a8d 100644 --- a/codeJK2/game/G_Timer.cpp +++ b/codeJK2/game/G_Timer.cpp @@ -49,9 +49,9 @@ static int TIMER_GetCount(int num) count++; p = p->next; } - + return count; -} +} /* @@ -184,7 +184,7 @@ void TIMER_Save( void ) saved_game.write_chunk( INT_ID('T', 'I', 'M', 'E'), numTimers); - + gtimer_t *p = g_timers[j]; assert ((numTimers && p) || (!numTimers && !p)); @@ -253,7 +253,7 @@ void TIMER_Load( void ) saved_game.read_chunk( INT_ID('T', 'S', 'L', 'N'), length); - + if ( length >= 1024 ) { assert( 0 ); continue; @@ -325,9 +325,9 @@ gtimer_t *TIMER_GetExisting(int num, const char *identifier) p = p->next; } - + return NULL; -} +} @@ -389,8 +389,8 @@ qboolean TIMER_Done( gentity_t *ent, const char *identifier ) ------------------------- TIMER_Done2 -Returns false if timer has been -started but is not done...or if +Returns false if timer has been +started but is not done...or if timer was never started ------------------------- */ diff --git a/codeJK2/game/NPC_combat.cpp b/codeJK2/game/NPC_combat.cpp index dbf7d67ec8..a0b3b23c85 100644 --- a/codeJK2/game/NPC_combat.cpp +++ b/codeJK2/game/NPC_combat.cpp @@ -85,7 +85,7 @@ void G_AngerAlert( gentity_t *self ) return; } //FIXME: hmm.... with all the other new alerts now, is this still neccesary or even a good idea...? - G_AlertTeam( self, self->enemy, ANGER_ALERT_RADIUS, ANGER_ALERT_SOUND_RADIUS ); + G_AlertTeam( self, self->enemy, ANGER_ALERT_RADIUS, ANGER_ALERT_SOUND_RADIUS ); } /* @@ -155,7 +155,7 @@ void G_AttackDelay( gentity_t *self, gentity_t *enemy ) VectorNormalize( dir ); AngleVectors( self->client->renderInfo.eyeAngles, fwd, NULL, NULL ); //dir[2] = fwd[2] = 0;//ignore z diff? - + attDelay = (4-g_spskill->integer)*500;//initial: from 1000ms delay on hard to 2000ms delay on easy if ( self->client->playerTeam == TEAM_PLAYER ) {//invert @@ -191,14 +191,14 @@ void G_AttackDelay( gentity_t *self, gentity_t *enemy ) case CLASS_TRANDOSHAN: attDelay -= Q_irand( 500, 1500 ); break; - case CLASS_JAN: - case CLASS_LANDO: + case CLASS_JAN: + case CLASS_LANDO: case CLASS_PRISONER: case CLASS_REBEL: attDelay -= Q_irand( 500, 1500 ); break; - case CLASS_GALAKMECH: - case CLASS_ATST: + case CLASS_GALAKMECH: + case CLASS_ATST: attDelay -= Q_irand( 1000, 2000 ); break; case CLASS_REELO: @@ -210,10 +210,10 @@ void G_AttackDelay( gentity_t *self, gentity_t *enemy ) return; break; case CLASS_INTERROGATOR: - case CLASS_PROBE: - case CLASS_MARK1: - case CLASS_MARK2: - case CLASS_SENTRY: + case CLASS_PROBE: + case CLASS_MARK1: + case CLASS_MARK2: + case CLASS_SENTRY: return; break; case CLASS_REMOTE: @@ -225,12 +225,12 @@ void G_AttackDelay( gentity_t *self, gentity_t *enemy ) case CLASS_RODIAN: case CLASS_WEEQUAY: break; - case CLASS_JEDI: + case CLASS_JEDI: case CLASS_SHADOWTROOPER: case CLASS_TAVION: case CLASS_REBORN: - case CLASS_LUKE: - case CLASS_DESANN: + case CLASS_LUKE: + case CLASS_DESANN: break; */ default: @@ -285,7 +285,7 @@ void G_AttackDelay( gentity_t *self, gentity_t *enemy ) case WP_EMPLACED_GUN: return; break; - case WP_TURRET: // turret guns + case WP_TURRET: // turret guns return; break; case WP_BOT_LASER: // Probe droid - Laser blast @@ -347,7 +347,7 @@ void G_AimSet( gentity_t *self, int aim ); void G_SetEnemy( gentity_t *self, gentity_t *enemy ) { int event = 0; - + //Must be valid if ( enemy == NULL ) return; @@ -379,12 +379,12 @@ void G_SetEnemy( gentity_t *self, gentity_t *enemy ) assert( enemy != self ); } #endif// _DEBUG - + // if ( enemy->client && enemy->client->playerTeam == TEAM_DISGUISE ) // {//unmask the player // enemy->client->playerTeam = TEAM_PLAYER; // } - + if ( self->client && self->NPC && enemy->client && enemy->client->playerTeam == self->client->playerTeam ) {//Probably a damn script! if ( self->NPC->charmedTime > level.time ) @@ -435,15 +435,15 @@ void G_SetEnemy( gentity_t *self, gentity_t *enemy ) event = Q_irand(EV_ANGER1, EV_ANGER3); } } - + if ( event ) {//yell G_AddVoiceEvent( self, event, 2000 ); } } - + if ( self->s.weapon == WP_BLASTER || self->s.weapon == WP_REPEATER || - self->s.weapon == WP_THERMAL || self->s.weapon == WP_BLASTER_PISTOL + self->s.weapon == WP_THERMAL || self->s.weapon == WP_BLASTER_PISTOL || self->s.weapon == WP_BOWCASTER ) {//Hmm, how about sniper and bowcaster? //When first get mad, aim is bad @@ -470,7 +470,7 @@ void G_SetEnemy( gentity_t *self, gentity_t *enemy ) G_AimSet( self, Q_irand( self->NPC->stats.aim - (maxErr*(3-g_spskill->integer)), self->NPC->stats.aim - (minErr*(3-g_spskill->integer)) ) ); } } - + //Alert anyone else in the area if ( Q_stricmp( "desperado", self->NPC_type ) != 0 && Q_stricmp( "paladin", self->NPC_type ) != 0 ) {//special holodeck enemies exception @@ -503,7 +503,7 @@ void G_SetEnemy( gentity_t *self, gentity_t *enemy ) } return; } - + //Otherwise, just picking up another enemy if ( event ) @@ -517,41 +517,41 @@ void G_SetEnemy( gentity_t *self, gentity_t *enemy ) } /* -int ChooseBestWeapon( void ) +int ChooseBestWeapon( void ) { int n; int weapon; // check weapons in the NPC's weapon preference order - for ( n = 0; n < MAX_WEAPONS; n++ ) + for ( n = 0; n < MAX_WEAPONS; n++ ) { weapon = NPCInfo->weaponOrder[n]; - if ( weapon == WP_NONE ) + if ( weapon == WP_NONE ) { break; } - if ( !HaveWeapon( weapon ) ) + if ( !HaveWeapon( weapon ) ) { continue; } - if ( client->ps.ammo[weaponData[weapon].ammoIndex] ) + if ( client->ps.ammo[weaponData[weapon].ammoIndex] ) { return weapon; } } // check weapons serially (mainly in case a weapon is not on the NPC's list) - for ( weapon = 1; weapon < WP_NUM_WEAPONS; weapon++ ) + for ( weapon = 1; weapon < WP_NUM_WEAPONS; weapon++ ) { - if ( !HaveWeapon( weapon ) ) + if ( !HaveWeapon( weapon ) ) { continue; } - if ( client->ps.ammo[weaponData[weapon].ammoIndex] ) + if ( client->ps.ammo[weaponData[weapon].ammoIndex] ) { return weapon; } @@ -561,7 +561,7 @@ int ChooseBestWeapon( void ) } */ -void ChangeWeapon( gentity_t *ent, int newWeapon ) +void ChangeWeapon( gentity_t *ent, int newWeapon ) { if ( !ent || !ent->client || !ent->NPC ) { @@ -574,7 +574,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->attackHold = 0; ent->NPC->currentAmmo = ent->client->ps.ammo[weaponData[newWeapon].ammoIndex]; - switch ( newWeapon ) + switch ( newWeapon ) { case WP_BRYAR_PISTOL://prifle ent->NPC->aiFlags &= ~NPCAI_BURST_WEAPON; @@ -588,7 +588,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1000;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 750;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce break; @@ -599,7 +599,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 600;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 400;//attack debounce - else + else ent->NPC->burstSpacing = 200;//attack debounce break; @@ -638,7 +638,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1000;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 750;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce break; @@ -657,7 +657,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1500;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 1000;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce } break; @@ -686,7 +686,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 2500;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 2000;//attack debounce - else + else ent->NPC->burstSpacing = 1500;//attack debounce break; @@ -697,7 +697,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 3000;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 2500;//attack debounce - else + else ent->NPC->burstSpacing = 2000;//attack debounce break; @@ -721,7 +721,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1500;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 1000;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce } else @@ -731,7 +731,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1000;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 750;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce // ent->NPC->burstSpacing = 1000;//attackdebounce } @@ -750,7 +750,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) ent->NPC->burstSpacing = 1000;//attack debounce else if ( g_spskill->integer == 1 ) ent->NPC->burstSpacing = 750;//attack debounce - else + else ent->NPC->burstSpacing = 500;//attack debounce break; @@ -764,7 +764,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) // ent->NPC->burstSpacing = 300;//attack debounce // else if ( g_spskill->integer == 1 ) // ent->NPC->burstSpacing = 200;//attack debounce - // else + // else // ent->NPC->burstSpacing = 100;//attack debounce } else @@ -784,7 +784,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) { ent->NPC->burstSpacing = ent->owner->wait + 200;//attack debounce } - else + else { ent->NPC->burstSpacing = ent->owner->wait;//attack debounce } @@ -800,7 +800,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) { ent->NPC->burstSpacing = 1000;//attack debounce } - else + else { ent->NPC->burstSpacing = 800;//attack debounce } @@ -814,7 +814,7 @@ void ChangeWeapon( gentity_t *ent, int newWeapon ) } } -void NPC_ChangeWeapon( int newWeapon ) +void NPC_ChangeWeapon( int newWeapon ) { qboolean changing = qfalse; if ( newWeapon != NPC->client->ps.weapon ) @@ -843,13 +843,13 @@ void NPC_ApplyWeaponFireDelay(void) How long, if at all, in msec the actual fire should delay from the time the attack was started */ void NPC_ApplyWeaponFireDelay(void) -{ +{ if ( NPC->attackDebounceTime > level.time ) {//Just fired, if attacking again, must be a burst fire, so don't add delay //NOTE: Borg AI uses attackDebounceTime "incorrectly", so this will always return for them! return; } - + switch(client->ps.weapon) { case WP_BOT_LASER: @@ -859,7 +859,7 @@ void NPC_ApplyWeaponFireDelay(void) case WP_THERMAL: if ( client->ps.clientNum ) - {//NPCs delay... + {//NPCs delay... //FIXME: player should, too, but would feel weird in 1st person, even though it // would look right in 3rd person. Really should have a wind-up anim // for player as he holds down the fire button to throw, then play @@ -886,11 +886,11 @@ void NPC_ApplyWeaponFireDelay(void) ShootThink ------------------------- */ -void ShootThink( void ) +void ShootThink( void ) { int delay; /* - if ( enemyVisibility != VIS_SHOOT) + if ( enemyVisibility != VIS_SHOOT) return; */ @@ -900,21 +900,21 @@ void ShootThink( void ) NPC_ApplyWeaponFireDelay(); - if ( NPCInfo->aiFlags & NPCAI_BURST_WEAPON ) + if ( NPCInfo->aiFlags & NPCAI_BURST_WEAPON ) { - if ( !NPCInfo->burstCount ) + if ( !NPCInfo->burstCount ) { NPCInfo->burstCount = Q_irand( NPCInfo->burstMin, NPCInfo->burstMax ); delay = 0; } - else + else { NPCInfo->burstCount--; - if ( NPCInfo->burstCount == 0 ) + if ( NPCInfo->burstCount == 0 ) { delay = NPCInfo->burstSpacing; } - else + else { delay = 0; } @@ -935,7 +935,7 @@ void ShootThink( void ) { delay = NPC->owner->random + 100; } - else + else { delay = NPC->owner->random; } @@ -950,7 +950,7 @@ void ShootThink( void ) { delay = 300; } - else + else { delay = 200; } @@ -958,7 +958,7 @@ void ShootThink( void ) } } } - else + else { delay = NPCInfo->burstSpacing; } @@ -968,16 +968,16 @@ void ShootThink( void ) } /* -static void WeaponThink( qboolean inCombat ) +static void WeaponThink( qboolean inCombat ) FIXME makes this so there's a delay from event that caused us to check to actually doing it Added: hacks for Borg */ -void WeaponThink( qboolean inCombat ) +void WeaponThink( qboolean inCombat ) { ucmd.buttons &= ~BUTTON_ATTACK; - if ( client->ps.weaponstate == WEAPON_RAISING || client->ps.weaponstate == WEAPON_DROPPING ) + if ( client->ps.weaponstate == WEAPON_RAISING || client->ps.weaponstate == WEAPON_DROPPING ) { ucmd.weapon = client->ps.weapon; return; @@ -988,19 +988,19 @@ void WeaponThink( qboolean inCombat ) return; } - if ( client->ps.weaponstate != WEAPON_READY && client->ps.weaponstate != WEAPON_FIRING && client->ps.weaponstate != WEAPON_IDLE) + if ( client->ps.weaponstate != WEAPON_READY && client->ps.weaponstate != WEAPON_FIRING && client->ps.weaponstate != WEAPON_IDLE) { return; } - if ( level.time < NPCInfo->shotTime ) + if ( level.time < NPCInfo->shotTime ) { return; } //MCG - Begin - //For now, no-one runs out of ammo - if(NPC->client->ps.ammo[ weaponData[client->ps.weapon].ammoIndex ] < 10) // checkme + //For now, no-one runs out of ammo + if(NPC->client->ps.ammo[ weaponData[client->ps.weapon].ammoIndex ] < 10) // checkme // if(NPC->client->ps.ammo[ client->ps.weapon ] < 10) { Add_Ammo (NPC, client->ps.weapon, 100); @@ -1014,7 +1014,7 @@ void WeaponThink( qboolean inCombat ) HaveWeapon */ -qboolean HaveWeapon( int weapon ) +qboolean HaveWeapon( int weapon ) { return (qboolean)(client->ps.stats[STAT_WEAPONS] & (1 << weapon)); } @@ -1055,7 +1055,7 @@ this function does not check teams, invulnerability, notarget, etc.... Added: If can't shoot center, try head, if not, see if it's close enough to try anyway. */ -qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) +qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) { trace_t tr; vec3_t muzzle; @@ -1069,18 +1069,18 @@ qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) traceEnt = &g_entities[ tr.entityNum ]; // point blank, baby! - if (tr.startsolid && (shooter->NPC) && (shooter->NPC->touchedByPlayer) ) + if (tr.startsolid && (shooter->NPC) && (shooter->NPC->touchedByPlayer) ) { traceEnt = shooter->NPC->touchedByPlayer; } - + if ( ShotThroughGlass( &tr, ent, spot, MASK_SHOT ) ) { traceEnt = &g_entities[ tr.entityNum ]; } // shot is dead on - if ( traceEnt == ent ) + if ( traceEnt == ent ) { return qtrue; } @@ -1090,7 +1090,7 @@ qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) CalcEntitySpot( ent, SPOT_HEAD, spot ); gi.trace ( &tr, muzzle, NULL, NULL, spot, shooter->s.number, MASK_SHOT, G2_NOCOLLIDE, 0 ); traceEnt = &g_entities[ tr.entityNum ]; - if ( traceEnt == ent) + if ( traceEnt == ent) { return qtrue; } @@ -1105,7 +1105,7 @@ qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) } //MCG - End // shot would hit a non-client - if ( !traceEnt->client ) + if ( !traceEnt->client ) { return qfalse; } @@ -1113,13 +1113,13 @@ qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) // shot is blocked by another player // he's already dead, so go ahead - if ( traceEnt->health <= 0 ) + if ( traceEnt->health <= 0 ) { return qtrue; } // don't deliberately shoot a teammate - if ( traceEnt->client && ( traceEnt->client->playerTeam == shooter->client->playerTeam ) ) + if ( traceEnt->client && ( traceEnt->client->playerTeam == shooter->client->playerTeam ) ) { return qfalse; } @@ -1130,31 +1130,31 @@ qboolean CanShoot ( gentity_t *ent, gentity_t *shooter ) /* -void NPC_CheckPossibleEnemy( gentity_t *other, visibility_t vis ) +void NPC_CheckPossibleEnemy( gentity_t *other, visibility_t vis ) Added: hacks for scripted NPCs */ -void NPC_CheckPossibleEnemy( gentity_t *other, visibility_t vis ) +void NPC_CheckPossibleEnemy( gentity_t *other, visibility_t vis ) { // is he is already our enemy? - if ( other == NPC->enemy ) + if ( other == NPC->enemy ) return; - if ( other->flags & FL_NOTARGET ) + if ( other->flags & FL_NOTARGET ) return; // we already have an enemy and this guy is in our FOV, see if this guy would be better - if ( NPC->enemy && vis == VIS_FOV ) + if ( NPC->enemy && vis == VIS_FOV ) { - if ( NPCInfo->enemyLastSeenTime - level.time < 2000 ) + if ( NPCInfo->enemyLastSeenTime - level.time < 2000 ) { return; } - if ( enemyVisibility == VIS_UNKNOWN ) + if ( enemyVisibility == VIS_UNKNOWN ) { enemyVisibility = NPC_CheckVisibility ( NPC->enemy, CHECK_360|CHECK_FOV ); } - if ( enemyVisibility == VIS_FOV ) + if ( enemyVisibility == VIS_FOV ) { return; } @@ -1165,14 +1165,14 @@ void NPC_CheckPossibleEnemy( gentity_t *other, visibility_t vis ) G_SetEnemy( NPC, other ); } - if ( vis == VIS_FOV ) + if ( vis == VIS_FOV ) { NPCInfo->enemyLastSeenTime = level.time; VectorCopy( other->currentOrigin, NPCInfo->enemyLastSeenLocation ); NPCInfo->enemyLastHeardTime = 0; VectorClear( NPCInfo->enemyLastHeardLocation ); - } - else + } + else { NPCInfo->enemyLastSeenTime = 0; VectorClear( NPCInfo->enemyLastSeenLocation ); @@ -1195,7 +1195,7 @@ Only makes you keep your weapon up after you fire */ int NPC_AttackDebounceForWeapon (void) { - switch ( NPC->client->ps.weapon ) + switch ( NPC->client->ps.weapon ) { /* case WP_BLASTER://scav rifle @@ -1215,7 +1215,7 @@ int NPC_AttackDebounceForWeapon (void) break; case WP_BOT_LASER: - + if ( g_spskill->integer == 0 ) return 2000; @@ -1239,7 +1239,7 @@ float NPC_MaxDistSquaredForWeapon (void) return NPCInfo->stats.shootDistance * NPCInfo->stats.shootDistance; } - switch ( NPC->s.weapon ) + switch ( NPC->s.weapon ) { case WP_BLASTER://scav rifle return 1024 * 1024;//should be shorter? @@ -1325,7 +1325,7 @@ qboolean NPC_EnemyTooFar(gentity_t *enemy, float dist, qboolean toShoot) { vec3_t vec; - + if ( !toShoot ) {//Not trying to actually press fire button with this check if ( NPC->client->ps.weapon == WP_SABER ) @@ -1333,7 +1333,7 @@ qboolean NPC_EnemyTooFar(gentity_t *enemy, float dist, qboolean toShoot) return qfalse; } } - + if(!dist) { @@ -1383,8 +1383,8 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis return NULL; } - if ( NPCInfo->behaviorState == BS_STAND_AND_SHOOT || - NPCInfo->behaviorState == BS_HUNT_AND_KILL ) + if ( NPCInfo->behaviorState == BS_STAND_AND_SHOOT || + NPCInfo->behaviorState == BS_HUNT_AND_KILL ) {//Formations guys don't require inFov to pick up a target //These other behavior states are active battle states and should not //use FOV. FOV checks are for enemies who are patrolling, guarding, etc. @@ -1399,7 +1399,7 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis { if( newenemy->health > 0 ) { - if( enemyTeam == TEAM_PLAYER || newenemy->client->playerTeam == enemyTeam || + if( enemyTeam == TEAM_PLAYER || newenemy->client->playerTeam == enemyTeam || ( enemyTeam == TEAM_PLAYER ) ) {//FIXME: check for range and FOV or vis? if( newenemy != NPC->lastEnemy ) @@ -1434,9 +1434,9 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis {//They're only hidden from a certain direction, check float dot; VectorNormalize( diff ); - dot = DotProduct( newenemy->client->hiddenDir, diff ); + dot = DotProduct( newenemy->client->hiddenDir, diff ); if ( dot > 0.5 ) - {//I'm not looking in the right dir toward them to see them + {//I'm not looking in the right dir toward them to see them failed = qtrue; } else @@ -1576,9 +1576,9 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis float dot; VectorNormalize( diff ); - dot = DotProduct( newenemy->client->hiddenDir, diff ); + dot = DotProduct( newenemy->client->hiddenDir, diff ); if ( dot > 0.5 ) - {//I'm not looking in the right dir toward them to see them + {//I'm not looking in the right dir toward them to see them continue; } else @@ -1643,7 +1643,7 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis } } - + if (findClosest) {//FIXME: you can pick up an enemy around a corner this way. return closestEnemy; @@ -1750,7 +1750,7 @@ gentity_t *NPC_PickAlly ( qboolean facingEachOther, float range, qboolean ignore } } - + return closestAlly; } @@ -1820,7 +1820,7 @@ gentity_t *NPC_CheckEnemy( qboolean findNew, qboolean tooFarOk, qboolean setEnem } else if ( !gi.inPVS(NPC->currentOrigin, NPC->enemy->currentOrigin ) ) {//FIXME: should this be a line-of site check? - //FIXME: a lot of things check PVS AGAIN when deciding whether + //FIXME: a lot of things check PVS AGAIN when deciding whether //or not to shoot, redundant! //Should we lose the enemy? //FIXME: if lose enemy, run lostenemyscript @@ -1869,7 +1869,7 @@ gentity_t *NPC_CheckEnemy( qboolean findNew, qboolean tooFarOk, qboolean setEnem } closestTo = NPC; - //FIXME: check your defendEnt, if you have one, see if their enemy is different + //FIXME: check your defendEnt, if you have one, see if their enemy is different //than yours, or, if they don't have one, pick the closest enemy to THEM? if ( NPCInfo->defendEnt ) {//Trying to protect someone @@ -1928,7 +1928,7 @@ gentity_t *NPC_CheckEnemy( qboolean findNew, qboolean tooFarOk, qboolean setEnem } } } - + if ( !forcefindNew ) { if ( !foundenemy ) @@ -1939,13 +1939,13 @@ gentity_t *NPC_CheckEnemy( qboolean findNew, qboolean tooFarOk, qboolean setEnem G_ClearEnemy(NPC); } } - + NPC->cantHitEnemyCounter = 0; } //FIXME: if we can't find any at all, go into INdependant NPC AI, pursue and kill } - if ( NPC->enemy && NPC->enemy->client ) + if ( NPC->enemy && NPC->enemy->client ) { if(NPC->enemy->client->playerTeam) { @@ -1989,15 +1989,15 @@ qboolean NPC_ClearShot( gentity_t *ent ) { gi.trace ( &tr, muzzle, NULL, NULL, ent->currentOrigin, NPC->s.number, MASK_SHOT, G2_NOCOLLIDE, 0 ); } - + if ( tr.startsolid || tr.allsolid ) { return qfalse; } - if ( tr.entityNum == ent->s.number ) + if ( tr.entityNum == ent->s.number ) return qtrue; - + return qfalse; } @@ -2034,7 +2034,7 @@ int NPC_ShotEntity( gentity_t *ent, vec3_t impactPos ) CalcEntitySpot( NPC, SPOT_WEAPON, muzzle ); } CalcEntitySpot( ent, SPOT_CHEST, targ ); - + // add aim error // use weapon instead of specific npc types, although you could add certain npc classes if you wanted // if ( NPC->client->playerTeam == TEAM_SCAVENGERS ) @@ -2148,7 +2148,7 @@ qboolean NPC_CheckCanAttack (float attack_scale, qboolean stationary) NPC_AimWiggle( enemy_org ); CalcEntitySpot( NPC, SPOT_WEAPON, muzzle ); - + VectorSubtract (enemy_org, muzzle, delta); vectoangles ( delta, angleToEnemy ); distanceToEnemy = VectorNormalize(delta); @@ -2179,7 +2179,7 @@ qboolean NPC_CheckCanAttack (float attack_scale, qboolean stationary) if(enemyVisibility >= VIS_FOV) {//He's in our FOV - + attack_ok = qtrue; //CalcEntitySpot( NPC->enemy, SPOT_HEAD, enemy_head); @@ -2273,7 +2273,7 @@ qboolean NPC_CheckCanAttack (float attack_scale, qboolean stationary) {//Too close to shoot! attack_ok = qfalse; } - else + else {//Hey, it might kill him, do it! attack_scale *= 2;// } @@ -2329,12 +2329,12 @@ IdealDistance determines what the NPC's ideal distance from it's enemy should be in the current situation */ -float IdealDistance ( gentity_t *self ) +float IdealDistance ( gentity_t *self ) { float ideal; ideal = 225 - 20 * NPCInfo->stats.aggression; - switch ( NPC->s.weapon ) + switch ( NPC->s.weapon ) { case WP_ROCKET_LAUNCHER: ideal += 200; @@ -2389,7 +2389,7 @@ void SP_point_combat( gentity_t *self ) } VectorCopy( self->currentOrigin, level.combatPoints[level.numCombatPoints].origin ); - + level.combatPoints[level.numCombatPoints].flags = self->spawnflags; level.combatPoints[level.numCombatPoints].occupied = qfalse; @@ -2444,7 +2444,7 @@ static int NPC_CollectCombatPoints( const vec3_t origin, const float radius, com ///Make sure this is an investigate combat point if ( ( flags & CP_INVESTIGATE ) && ( level.combatPoints[i].flags & CPF_INVESTIGATE ) ) continue; - + //Squad points are only valid if we're looking for them if ( ( level.combatPoints[i].flags & CPF_SQUAD ) && ( ( flags & CP_SQUAD ) == qfalse ) ) continue; @@ -2572,7 +2572,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 continue; } } - else + else { if ( (*cpi).first > DistanceSquared( position, enemyPosition ) ) { @@ -2603,7 +2603,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 if ( flags & CP_FLANK ) { vec3_t eDir2Me, eDir2CP; - + VectorSubtract( position, enemyPosition, eDir2Me ); VectorNormalize( eDir2Me ); @@ -2611,7 +2611,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 VectorNormalize( eDir2CP ); const float dot = DotProduct( eDir2Me, eDir2CP ); - + //Not far enough behind enemy from current pos if ( dot >= 0.4 ) continue; @@ -2623,7 +2623,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 { vec3_t eDir, gDir; vec3_t wpOrg; - + VectorSubtract( position, enemyPosition, eDir ); VectorNormalize( eDir ); @@ -2642,7 +2642,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 VectorNormalize( gDir ); float dot = DotProduct( gDir, eDir ); - + //Don't want to run at enemy if ( dot >= MIN_AVOID_DOT ) continue; @@ -2651,7 +2651,7 @@ int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3 if ( DistanceSquared( wpOrg, enemyPosition ) < avoidDist ) continue; } - + //Okay, now make sure it's not blocked gi.trace( &tr, level.combatPoints[i].origin, NPC->mins, NPC->maxs, level.combatPoints[i].origin, NPC->s.number, NPC->clipmask, G2_NOCOLLIDE, 0 ); if ( tr.allsolid || tr.startsolid ) @@ -2721,7 +2721,7 @@ int NPC_FindSquadPoint( vec3_t position ) //Must be vacant if ( level.combatPoints[i].occupied == qtrue ) continue; - + dist = DistanceSquared( position, level.combatPoints[i].origin ); //The point cannot take us past the player @@ -2783,7 +2783,7 @@ qboolean NPC_FreeCombatPoint( int combatPointID, qboolean failed ) //Free it level.combatPoints[combatPointID].occupied = qfalse; - + return qtrue; } @@ -2824,9 +2824,9 @@ gentity_t *NPC_SearchForWeapons( void ) // } if(!PInUse(i)) continue; - + found=&g_entities[i]; - + //FIXME: Also look for ammo_racks that have weapons on them? if ( found->s.eType != ET_ITEM ) { @@ -2847,7 +2847,7 @@ gentity_t *NPC_SearchForWeapons( void ) dist = DistanceSquared( found->currentOrigin, NPC->currentOrigin ); if ( dist < bestDist ) { - if ( !navigator.GetBestPathBetweenEnts( NPC, found, NF_CLEAR_PATH ) + if ( !navigator.GetBestPathBetweenEnts( NPC, found, NF_CLEAR_PATH ) || navigator.GetBestNodeAltRoute( NPC->waypoint, found->waypoint ) == WAYPOINT_NONE ) {//can't possibly have a route to any OR can't possibly have a route to this one OR don't have a route to this one if ( NAV_ClearPathToPoint( NPC, NPC->mins, NPC->maxs, found->currentOrigin, NPC->clipmask, ENTITYNUM_NONE ) ) @@ -2886,7 +2886,7 @@ void NPC_CheckGetNewWeapon( void ) { if ( NPC->s.weapon == WP_NONE && NPC->enemy ) {//if running away because dropped weapon... - if ( NPCInfo->goalEntity + if ( NPCInfo->goalEntity && NPCInfo->goalEntity == NPCInfo->tempGoal && NPCInfo->goalEntity->enemy && !NPCInfo->goalEntity->enemy->inuse ) @@ -2899,7 +2899,7 @@ void NPC_CheckGetNewWeapon( void ) if ( foundWeap ) {//try to nav to it /* - if ( !navigator.GetBestPathBetweenEnts( NPC, foundWeap, NF_CLEAR_PATH ) + if ( !navigator.GetBestPathBetweenEnts( NPC, foundWeap, NF_CLEAR_PATH ) || navigator.GetBestNodeAltRoute( NPC->waypoint, foundWeap->waypoint ) == WAYPOINT_NONE ) {//can't possibly have a route to any OR can't possibly have a route to this one OR don't have a route to this one if ( !NAV_ClearPathToPoint( NPC, NPC->mins, NPC->maxs, foundWeap->currentOrigin, NPC->clipmask, ENTITYNUM_NONE ) ) diff --git a/codeJK2/game/NPC_goal.cpp b/codeJK2/game/NPC_goal.cpp index 6b79122e91..b6eb757d09 100644 --- a/codeJK2/game/NPC_goal.cpp +++ b/codeJK2/game/NPC_goal.cpp @@ -30,17 +30,17 @@ extern qboolean FlyingCreature( gentity_t *ent ); SetGoal */ -void SetGoal( gentity_t *goal, float rating ) +void SetGoal( gentity_t *goal, float rating ) { NPCInfo->goalEntity = goal; // NPCInfo->goalEntityNeed = rating; NPCInfo->goalTime = level.time; // NAV_ClearLastRoute(NPC); - if ( goal ) + if ( goal ) { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_INFO, "NPC_SetGoal: %s @ %s (%f)\n", goal->classname, vtos( goal->currentOrigin), rating ); } - else + else { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_INFO, "NPC_SetGoal: NONE\n" ); } @@ -51,26 +51,26 @@ void SetGoal( gentity_t *goal, float rating ) NPC_SetGoal */ -void NPC_SetGoal( gentity_t *goal, float rating ) +void NPC_SetGoal( gentity_t *goal, float rating ) { - if ( goal == NPCInfo->goalEntity ) + if ( goal == NPCInfo->goalEntity ) { return; } - if ( !goal ) + if ( !goal ) { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_ERROR, "NPC_SetGoal: NULL goal\n" ); return; } - if ( goal->client ) + if ( goal->client ) { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_ERROR, "NPC_SetGoal: goal is a client\n" ); return; } - if ( NPCInfo->goalEntity ) + if ( NPCInfo->goalEntity ) { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_INFO, "NPC_SetGoal: push %s\n", NPCInfo->goalEntity->classname ); NPCInfo->lastGoalEntity = NPCInfo->goalEntity; @@ -85,11 +85,11 @@ void NPC_SetGoal( gentity_t *goal, float rating ) NPC_ClearGoal */ -void NPC_ClearGoal( void ) +void NPC_ClearGoal( void ) { gentity_t *goal; - if ( !NPCInfo->lastGoalEntity ) + if ( !NPCInfo->lastGoalEntity ) { SetGoal( NULL, 0.0 ); return; @@ -98,7 +98,7 @@ void NPC_ClearGoal( void ) goal = NPCInfo->lastGoalEntity; NPCInfo->lastGoalEntity = NULL; // NAV_ClearLastRoute(NPC); - if ( goal->inuse && !(goal->s.eFlags & EF_NODRAW) ) + if ( goal->inuse && !(goal->s.eFlags & EF_NODRAW) ) { // Debug_NPCPrintf( NPC, debugNPCAI, DEBUG_LEVEL_INFO, "NPC_ClearGoal: pop %s\n", goal->classname ); SetGoal( goal, 0 );//, NPCInfo->lastGoalEntityNeed @@ -156,7 +156,7 @@ ReachedGoal id removed checks against waypoints and is now checking surfaces */ //qboolean NAV_HitNavGoal( vec3_t point, vec3_t mins, vec3_t maxs, gentity_t *goal, qboolean flying ); -qboolean ReachedGoal( gentity_t *goal ) +qboolean ReachedGoal( gentity_t *goal ) { //FIXME: For script waypoints, need a special check /* @@ -170,18 +170,18 @@ qboolean ReachedGoal( gentity_t *goal ) return NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, goal, FlyingCreature( NPC ) ); } - if ( goal == NPCInfo->tempGoal && !(goal->svFlags & SVF_NAVGOAL)) + if ( goal == NPCInfo->tempGoal && !(goal->svFlags & SVF_NAVGOAL)) {//MUST touch waypoints, even if moving to it //This is odd, it just checks to see if they are on the same //surface and the tempGoal in in the FOV - does NOT check distance! // are we on same surface? - + //FIXME: NPC->waypoint reset every frame, need to find it first //Should we do that here? (Still will do it only once per frame) if ( NPC->waypoint >= 0 && NPC->waypoint < num_waypoints ) { goalWpNum = NAV_FindWaypointAt ( goal->currentOrigin ); - if ( NPC->waypoint != goalWpNum ) + if ( NPC->waypoint != goalWpNum ) { return qfalse; } @@ -193,7 +193,7 @@ qboolean ReachedGoal( gentity_t *goal ) // is it in our FOV vectoangles ( vec, angles ); delta = AngleDelta ( NPC->client->ps.viewangles[YAW], angles[YAW] ); - if ( fabs ( delta ) > NPCInfo->stats.hfov ) + if ( fabs ( delta ) > NPCInfo->stats.hfov ) { return qfalse; } @@ -219,16 +219,16 @@ qboolean ReachedGoal( gentity_t *goal ) return qfalse; } */ - if ( NPCInfo->aiFlags & NPCAI_TOUCHED_GOAL ) + if ( NPCInfo->aiFlags & NPCAI_TOUCHED_GOAL ) { NPCInfo->aiFlags &= ~NPCAI_TOUCHED_GOAL; return qtrue; } /* - if ( goal->s.eFlags & EF_NODRAW ) + if ( goal->s.eFlags & EF_NODRAW ) { goalWpNum = NAV_FindWaypointAt( goal->currentOrigin ); - if ( NPC->waypoint == goalWpNum ) + if ( NPC->waypoint == goalWpNum ) { return qtrue; } @@ -238,7 +238,7 @@ qboolean ReachedGoal( gentity_t *goal ) if(goal->client && goal->health <= 0) {//trying to get to dead guy goalWpNum = NAV_FindWaypointAt( goal->currentOrigin ); - if ( NPC->waypoint == goalWpNum ) + if ( NPC->waypoint == goalWpNum ) { VectorSubtract(NPC->currentOrigin, goal->currentOrigin, vec); vec[2] = 0; @@ -249,12 +249,12 @@ qboolean ReachedGoal( gentity_t *goal ) } } } -*/ +*/ return NAV_HitNavGoal( NPC->currentOrigin, NPC->mins, NPC->maxs, goal->currentOrigin, NPCInfo->goalRadius, FlyingCreature( NPC ) ); } /* -static gentity_t *UpdateGoal( void ) +static gentity_t *UpdateGoal( void ) Id removed a lot of shit here... doesn't seem to handle waypoints independantly of goalentity @@ -263,11 +263,11 @@ In fact, doesn't seem to be any waypoint info on entities at all any more? MCG - Since goal is ALWAYS goalEntity, took out a lot of sending goal entity pointers around for no reason */ -gentity_t *UpdateGoal( void ) +gentity_t *UpdateGoal( void ) { gentity_t *goal; - if ( !NPCInfo->goalEntity ) + if ( !NPCInfo->goalEntity ) { return NULL; } @@ -280,7 +280,7 @@ gentity_t *UpdateGoal( void ) goal = NPCInfo->goalEntity; - if ( ReachedGoal( goal ) ) + if ( ReachedGoal( goal ) ) { NPC_ReachedGoal(); goal = NULL;//so they don't keep trying to move to it diff --git a/codeJK2/game/NPC_misc.cpp b/codeJK2/game/NPC_misc.cpp index 8ee9116a10..859f6ada81 100644 --- a/codeJK2/game/NPC_misc.cpp +++ b/codeJK2/game/NPC_misc.cpp @@ -73,7 +73,7 @@ void Debug_NPCPrintf (gentity_t *printNPC, cvar_t *cv, int debugLevel, char *fmt return; } - if ( debugNPCName->string[0] && Q_stricmp( debugNPCName->string, printNPC->targetname) != 0 ) + if ( debugNPCName->string[0] && Q_stricmp( debugNPCName->string, printNPC->targetname) != 0 ) { return; } diff --git a/codeJK2/game/NPC_move.cpp b/codeJK2/game/NPC_move.cpp index 0ed5725780..aee1b3263e 100644 --- a/codeJK2/game/NPC_move.cpp +++ b/codeJK2/game/NPC_move.cpp @@ -127,7 +127,7 @@ static void NPC_LadderMove( vec3_t dir ) //ALSO: Need to be able to get off at top //ALSO: Need to play an anim //ALSO: Need transitionary anims? - + if ( ( dir[2] > 0 ) || ( dir[2] < 0 && NPC->client->ps.groundEntityNum == ENTITYNUM_NONE ) ) { //Set our movement direction @@ -155,7 +155,7 @@ inline qboolean NPC_GetMoveInformation( vec3_t dir, float *distance ) //Get our move info VectorSubtract( NPCInfo->goalEntity->currentOrigin, NPC->currentOrigin, dir ); *distance = VectorNormalize( dir ); - + VectorCopy( NPCInfo->goalEntity->currentOrigin, NPCInfo->blockedDest ); return qtrue; @@ -210,7 +210,7 @@ qboolean NPC_GetMoveDirection( vec3_t out, float *distance ) { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); - NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); + NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; @@ -224,7 +224,7 @@ qboolean NPC_GetMoveDirection( vec3_t out, float *distance ) { //FIXME: Emit a warning, this is a worst case scenario //FIXME: if we have a clear path to our goal (exluding bodies), but then this - // check (against bodies only) fails, shouldn't we fall back + // check (against bodies only) fails, shouldn't we fall back // to macro navigation? Like so: if ( !(frameNavInfo.flags&NIF_MACRO_NAV) ) {//we had a clear path to goal and didn't try macro nav, but can't avoid collision so try macro nav here @@ -233,7 +233,7 @@ qboolean NPC_GetMoveDirection( vec3_t out, float *distance ) { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); - NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); + NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; @@ -291,7 +291,7 @@ qboolean NPC_GetMoveDirectionAltRoute( vec3_t out, float *distance, qboolean try { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); - NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); + NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; @@ -313,7 +313,7 @@ qboolean NPC_GetMoveDirectionAltRoute( vec3_t out, float *distance, qboolean try { //Can't reach goal, just face vectoangles( frameNavInfo.direction, angles ); - NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); + NPCInfo->desiredYaw = AngleNormalize360( angles[YAW] ); VectorCopy( frameNavInfo.direction, out ); *distance = frameNavInfo.distance; return qfalse; @@ -377,7 +377,7 @@ void G_UcmdMoveForDir( gentity_t *self, usercmd_t *cmd, vec3_t dir ) /* vec3_t wishvel; - for ( int i = 0 ; i < 3 ; i++ ) + for ( int i = 0 ; i < 3 ; i++ ) { wishvel[i] = forward[i]*cmd->forwardmove + right[i]*cmd->rightmove; } @@ -399,7 +399,7 @@ NPC_MoveToGoal #if AI_TIMERS extern int navTime; #endif// AI_TIMERS -qboolean NPC_MoveToGoal( qboolean tryStraight ) +qboolean NPC_MoveToGoal( qboolean tryStraight ) { #if AI_TIMERS int startTime = GetTime(0); @@ -443,12 +443,12 @@ qboolean NPC_MoveToGoal( qboolean tryStraight ) //FIXME: strafe instead of turn if change in dir is small and temporary NPCInfo->desiredPitch = 0.0f; NPCInfo->desiredYaw = AngleNormalize360( NPCInfo->lastPathAngles[YAW] ); - + //Pitch towards the goal and also update if flying or swimming if ( NPCInfo->stats.moveType == MT_FLYSWIM ) { NPCInfo->desiredPitch = AngleNormalize360( NPCInfo->lastPathAngles[PITCH] ); - + if ( dir[2] ) { float scale = (dir[2] * distance); @@ -487,7 +487,7 @@ qboolean NPC_SlideMoveToGoal( void ) float saveYaw = NPC->client->ps.viewangles[YAW]; NPCInfo->combatMove = qtrue; - + qboolean ret = NPC_MoveToGoal( qtrue ); NPCInfo->desiredYaw = saveYaw; diff --git a/codeJK2/game/NPC_reactions.cpp b/codeJK2/game/NPC_reactions.cpp index 209f3e607d..187bb0d8e1 100644 --- a/codeJK2/game/NPC_reactions.cpp +++ b/codeJK2/game/NPC_reactions.cpp @@ -71,7 +71,7 @@ static void NPC_CheckAttacker( gentity_t *other, int mod ) //FIXME: I don't see anything in here that would stop teammates from taking a teammate // as an enemy. Ideally, there would be code before this to prevent that from // happening, but that is presumptuous. - + //valid ent - FIXME: a VALIDENT macro would be nice here if ( !other ) return; @@ -83,7 +83,7 @@ static void NPC_CheckAttacker( gentity_t *other, int mod ) return; //Don't take a target that doesn't want to be - if ( other->flags & FL_NOTARGET ) + if ( other->flags & FL_NOTARGET ) return; if ( NPC->svFlags & SVF_LOCKEDENEMY ) @@ -226,7 +226,7 @@ void NPC_ChoosePainAnimation( gentity_t *self, gentity_t *other, vec3_t point, i int pain_anim = -1; float pain_chance; - + if ( self->s.weapon == WP_THERMAL && self->client->fireDelay > 0 ) {//don't interrupt thermal throwing anim return; @@ -256,7 +256,7 @@ void NPC_ChoosePainAnimation( gentity_t *self, gentity_t *other, vec3_t point, i {//ally shot by player always complains pain_chance = 1.1f; } - else + else { if ( other && (other->s.weapon == WP_SABER || mod == MOD_ELECTROCUTE || mod == MOD_CRUSH/*FIXME:MOD_FORCE_GRIP*/) ) { @@ -341,7 +341,7 @@ void NPC_ChoosePainAnimation( gentity_t *self, gentity_t *other, vec3_t point, i { G_AddVoiceEvent( self, Q_irand(EV_CHOKE1, EV_CHOKE3), 0 ); } - + //Setup the timing for it if ( mod == MOD_ELECTROCUTE ) { @@ -357,22 +357,22 @@ void NPC_ChoosePainAnimation( gentity_t *self, gentity_t *other, vec3_t point, i NPC_Pain =============== */ -void NPC_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod, int hitLoc ) +void NPC_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t point, int damage, int mod, int hitLoc ) { team_t otherTeam = TEAM_FREE; int voiceEvent = -1; - if ( self->NPC == NULL ) + if ( self->NPC == NULL ) return; - if ( other == NULL ) + if ( other == NULL ) return; //or just remove ->pain in player_die? if ( self->client->ps.pm_type == PM_DEAD ) return; - if ( other == self ) + if ( other == self ) return; //MCG: Ignore damage from your own team for now @@ -385,15 +385,15 @@ void NPC_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t p // } } - if ( self->client->playerTeam - && other->client - && otherTeam == self->client->playerTeam - && (!player->client->ps.viewEntity || other->s.number != player->client->ps.viewEntity)) + if ( self->client->playerTeam + && other->client + && otherTeam == self->client->playerTeam + && (!player->client->ps.viewEntity || other->s.number != player->client->ps.viewEntity)) {//hit by a teammate if ( other != self->enemy && self != other->enemy ) {//we weren't already enemies - if ( self->enemy || other->enemy - || (other->s.number&&other->s.number!=player->client->ps.viewEntity) + if ( self->enemy || other->enemy + || (other->s.number&&other->s.number!=player->client->ps.viewEntity) /*|| (!other->s.number&&Q_irand( 0, 3 ))*/ ) {//if one of us actually has an enemy already, it's okay, just an accident OR wasn't hit by player or someone controlled by player OR player hit ally and didn't get 25% chance of getting mad (FIXME:accumulate anger+base on diff?) //FIXME: player should have to do a certain amount of damage to ally or hit them several times to make them mad @@ -402,7 +402,7 @@ void NPC_Pain( gentity_t *self, gentity_t *inflictor, gentity_t *other, vec3_t p {//Run any pain instructions if ( self->health <= (self->max_health/3) && G_ActivateBehavior(self, BSET_FLEE) ) { - + } else// if( VALIDSTRING( self->behaviorSet[BSET_PAIN] ) ) { @@ -519,7 +519,7 @@ NPC_Touch ------------------------- */ extern qboolean INV_SecurityKeyGive( gentity_t *target, const char *keyname ); -void NPC_Touch(gentity_t *self, gentity_t *other, trace_t *trace) +void NPC_Touch(gentity_t *self, gentity_t *other, trace_t *trace) { if(!self->NPC) return; @@ -570,15 +570,15 @@ void NPC_Touch(gentity_t *self, gentity_t *other, trace_t *trace) } } - if ( other->client ) + if ( other->client ) {//FIXME: if pushing against another bot, both ucmd.rightmove = 127??? //Except if not facing one another... - if ( other->health > 0 ) + if ( other->health > 0 ) { NPCInfo->touchedByPlayer = other; } - if ( other == NPCInfo->goalEntity ) + if ( other == NPCInfo->goalEntity ) { NPCInfo->aiFlags |= NPCAI_TOUCHED_GOAL; } @@ -610,9 +610,9 @@ void NPC_Touch(gentity_t *self, gentity_t *other, trace_t *trace) } */ } - else + else {//FIXME: check for SVF_NONNPC_ENEMY flag here? - if ( other->health > 0 ) + if ( other->health > 0 ) { if ( NPC->enemy == other && (other->svFlags&SVF_NONNPC_ENEMY) ) { @@ -620,7 +620,7 @@ void NPC_Touch(gentity_t *self, gentity_t *other, trace_t *trace) } } - if ( other == NPCInfo->goalEntity ) + if ( other == NPCInfo->goalEntity ) { NPCInfo->aiFlags |= NPCAI_TOUCHED_GOAL; } @@ -757,7 +757,7 @@ void NPC_Respond( gentity_t *self, int userNum ) case CLASS_JEDI: if ( !self->enemy ) { - if ( !(self->svFlags&SVF_IGNORE_ENEMIES) + if ( !(self->svFlags&SVF_IGNORE_ENEMIES) && (self->NPC->scriptFlags&SCF_LOOK_FOR_ENEMIES) && self->client->enemyTeam == TEAM_ENEMY ) { @@ -896,7 +896,7 @@ void NPC_Respond( gentity_t *self, int userNum ) default: break; } - + if ( event != -1 ) { //hack here because we reuse some "combat" and "extra" sounds @@ -973,7 +973,7 @@ NPC_Use */ extern void Add_Batteries( gentity_t *ent, int *count ); -void NPC_Use( gentity_t *self, gentity_t *other, gentity_t *activator ) +void NPC_Use( gentity_t *self, gentity_t *other, gentity_t *activator ) { if (self->client->ps.pm_type == PM_DEAD) {//or just remove ->pain in player_die? @@ -1040,7 +1040,7 @@ void NPC_CheckPlayerAim( void ) if ( player && player->client && player->client->ps.weapon > (int)(WP_NONE) && player->client->ps.weapon < (int)(WP_TRICORDER) ) {//player has a weapon ready - if ( g_crosshairEntNum == NPC->s.number && level.time - g_crosshairEntTime < 200 + if ( g_crosshairEntNum == NPC->s.number && level.time - g_crosshairEntTime < 200 && g_crosshairSameEntTime >= 3000 && g_crosshairEntDist < 256 ) {//if the player holds the crosshair on you for a few seconds //ask them what the fuck they're doing diff --git a/codeJK2/game/NPC_senses.cpp b/codeJK2/game/NPC_senses.cpp index bf7ee9dfdf..57e7febf03 100644 --- a/codeJK2/game/NPC_senses.cpp +++ b/codeJK2/game/NPC_senses.cpp @@ -40,7 +40,7 @@ qboolean G_ClearLineOfSight(const vec3_t point1, const vec3_t point2, int ignore trace_t tr; gi.trace ( &tr, point1, NULL, NULL, point2, ignore, clipmask, G2_NOCOLLIDE, 0 ); - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) { return qtrue; } @@ -52,7 +52,7 @@ qboolean G_ClearLineOfSight(const vec3_t point1, const vec3_t point2, int ignore VectorCopy(tr.endpos, newpoint1); gi.trace (&tr, newpoint1, NULL, NULL, point2, hit->s.number, clipmask, G2_NOCOLLIDE, 0 ); - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) { return qtrue; } @@ -70,7 +70,7 @@ or take any AI related factors (for example, the NPC's reaction time) into accou FIXME do we need fat and thin version of this? */ -qboolean CanSee ( gentity_t *ent ) +qboolean CanSee ( gentity_t *ent ) { trace_t tr; vec3_t eyes; @@ -81,7 +81,7 @@ qboolean CanSee ( gentity_t *ent ) CalcEntitySpot( ent, SPOT_ORIGIN, spot ); gi.trace ( &tr, eyes, NULL, NULL, spot, NPC->s.number, MASK_OPAQUE, G2_NOCOLLIDE, 0 ); ShotThroughGlass (&tr, ent, spot, MASK_OPAQUE); - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) { return qtrue; } @@ -89,7 +89,7 @@ qboolean CanSee ( gentity_t *ent ) CalcEntitySpot( ent, SPOT_HEAD, spot ); gi.trace ( &tr, eyes, NULL, NULL, spot, NPC->s.number, MASK_OPAQUE, G2_NOCOLLIDE, 0 ); ShotThroughGlass (&tr, ent, spot, MASK_OPAQUE); - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) { return qtrue; } @@ -97,7 +97,7 @@ qboolean CanSee ( gentity_t *ent ) CalcEntitySpot( ent, SPOT_LEGS, spot ); gi.trace ( &tr, eyes, NULL, NULL, spot, NPC->s.number, MASK_OPAQUE, G2_NOCOLLIDE, 0 ); ShotThroughGlass (&tr, ent, spot, MASK_OPAQUE); - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) { return qtrue; } @@ -138,11 +138,11 @@ qboolean InFOV( vec3_t spot, vec3_t from, vec3_t fromAngles, int hFOV, int vFOV VectorSubtract ( spot, from, deltaVector ); vectoangles ( deltaVector, angles ); - + deltaAngles[PITCH] = AngleDelta ( fromAngles[PITCH], angles[PITCH] ); deltaAngles[YAW] = AngleDelta ( fromAngles[YAW], angles[YAW] ); - if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) + if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) { return qtrue; } @@ -152,7 +152,7 @@ qboolean InFOV( vec3_t spot, vec3_t from, vec3_t fromAngles, int hFOV, int vFOV //NPC to position -qboolean InFOV( vec3_t origin, gentity_t *from, int hFOV, int vFOV ) +qboolean InFOV( vec3_t origin, gentity_t *from, int hFOV, int vFOV ) { vec3_t fromAngles, eyes; @@ -172,7 +172,7 @@ qboolean InFOV( vec3_t origin, gentity_t *from, int hFOV, int vFOV ) //Entity to entity -qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) +qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) { vec3_t eyes; vec3_t spot; @@ -205,7 +205,7 @@ qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) vectoangles ( deltaVector, angles ); deltaAngles[PITCH] = AngleDelta ( fromAngles[PITCH], angles[PITCH] ); deltaAngles[YAW] = AngleDelta ( fromAngles[YAW], angles[YAW] ); - if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) + if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) { return qtrue; } @@ -215,7 +215,7 @@ qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) vectoangles ( deltaVector, angles ); deltaAngles[PITCH] = AngleDelta ( fromAngles[PITCH], angles[PITCH] ); deltaAngles[YAW] = AngleDelta ( fromAngles[YAW], angles[YAW] ); - if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) + if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) { return qtrue; } @@ -225,7 +225,7 @@ qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) vectoangles ( deltaVector, angles ); deltaAngles[PITCH] = AngleDelta ( fromAngles[PITCH], angles[PITCH] ); deltaAngles[YAW] = AngleDelta ( fromAngles[YAW], angles[YAW] ); - if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) + if ( fabs ( deltaAngles[PITCH] ) <= vFOV && fabs ( deltaAngles[YAW] ) <= hFOV ) { return qtrue; } @@ -233,7 +233,7 @@ qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV ) return qfalse; } -qboolean InVisrange ( gentity_t *ent ) +qboolean InVisrange ( gentity_t *ent ) {//FIXME: make a calculate visibility for ents that takes into account //lighting, movement, turning, crouch/stand up, other anims, hide brushes, etc. vec3_t eyes; @@ -280,23 +280,23 @@ qboolean InVisrange ( gentity_t *ent ) NPC_CheckVisibility */ -visibility_t NPC_CheckVisibility ( gentity_t *ent, int flags ) +visibility_t NPC_CheckVisibility ( gentity_t *ent, int flags ) { // flags should never be 0 - if ( !flags ) + if ( !flags ) { return VIS_NOT; } // check PVS - if ( flags & CHECK_PVS ) + if ( flags & CHECK_PVS ) { - if ( !gi.inPVS ( ent->currentOrigin, NPC->currentOrigin ) ) + if ( !gi.inPVS ( ent->currentOrigin, NPC->currentOrigin ) ) { return VIS_NOT; } } - if ( !(flags & (CHECK_360|CHECK_FOV|CHECK_SHOOT)) ) + if ( !(flags & (CHECK_360|CHECK_FOV|CHECK_SHOOT)) ) { return VIS_PVS; } @@ -304,7 +304,7 @@ visibility_t NPC_CheckVisibility ( gentity_t *ent, int flags ) // check within visrange if (flags & CHECK_VISRANGE) { - if( !InVisrange ( ent ) ) + if( !InVisrange ( ent ) ) { return VIS_PVS; } @@ -312,36 +312,36 @@ visibility_t NPC_CheckVisibility ( gentity_t *ent, int flags ) // check 360 degree visibility //Meaning has to be a direct line of site - if ( flags & CHECK_360 ) + if ( flags & CHECK_360 ) { - if ( !CanSee ( ent ) ) + if ( !CanSee ( ent ) ) { return VIS_PVS; } } - if ( !(flags & (CHECK_FOV|CHECK_SHOOT)) ) + if ( !(flags & (CHECK_FOV|CHECK_SHOOT)) ) { return VIS_360; } // check FOV - if ( flags & CHECK_FOV ) + if ( flags & CHECK_FOV ) { - if ( !InFOV ( ent, NPC, NPCInfo->stats.hfov, NPCInfo->stats.vfov) ) + if ( !InFOV ( ent, NPC, NPCInfo->stats.hfov, NPCInfo->stats.vfov) ) { return VIS_360; } } - if ( !(flags & CHECK_SHOOT) ) + if ( !(flags & CHECK_SHOOT) ) { return VIS_FOV; } // check shootability - if ( flags & CHECK_SHOOT ) + if ( flags & CHECK_SHOOT ) { - if ( !CanShoot ( ent, NPC ) ) + if ( !CanShoot ( ent, NPC ) ) { return VIS_FOV; } @@ -467,7 +467,7 @@ static int G_CheckSightEvents( gentity_t *self, int hFOV, int vFOV, float maxSee if ( G_ClearLOS( self, level.alertEvents[i].position ) == qfalse ) continue; - //FIXME: possibly have the light level at this point affect the + //FIXME: possibly have the light level at this point affect the // visibility/alert level of this event? Would also // need to take into account how bright the event // itself is. A lightsaber would stand out more @@ -606,7 +606,7 @@ void AddSoundEvent( gentity_t *owner, vec3_t position, float radius, alertEventL return; } } - + if ( owner == NULL && alertLevel < AEL_DANGER ) //allows un-owned danger alerts return; @@ -669,7 +669,7 @@ void AddSightEvent( gentity_t *owner, vec3_t position, float radius, alertEventL level.alertEvents[ level.numAlertEvents ].radius = radius; level.alertEvents[ level.numAlertEvents ].level = alertLevel; level.alertEvents[ level.numAlertEvents ].type = AET_SIGHT; - level.alertEvents[ level.numAlertEvents ].owner = owner; + level.alertEvents[ level.numAlertEvents ].owner = owner; level.alertEvents[ level.numAlertEvents ].addLight = addLight; //will get added to actual light at that point when it's checked level.alertEvents[ level.numAlertEvents ].ID = level.curAlertID++; level.alertEvents[ level.numAlertEvents ].timestamp = level.time; @@ -764,7 +764,7 @@ qboolean G_ClearLOS( gentity_t *self, const vec3_t start, const vec3_t end ) { trace_t tr; int traceCount = 0; - + //FIXME: ENTITYNUM_NONE ok? gi.trace ( &tr, start, NULL, NULL, end, ENTITYNUM_NONE, CONTENTS_OPAQUE/*CONTENTS_SOLID*//*(CONTENTS_SOLID|CONTENTS_MONSTERCLIP)*/, G2_NOCOLLIDE, 0 ); while ( tr.fraction < 1.0 && traceCount < 3 ) @@ -781,7 +781,7 @@ qboolean G_ClearLOS( gentity_t *self, const vec3_t start, const vec3_t end ) return qfalse; } - if ( tr.fraction == 1.0 ) + if ( tr.fraction == 1.0 ) return qtrue; return qfalse; @@ -818,13 +818,13 @@ qboolean G_ClearLOS( gentity_t *self, const vec3_t start, gentity_t *ent ) } //NPC's eyes to entity -qboolean G_ClearLOS( gentity_t *self, gentity_t *ent ) +qboolean G_ClearLOS( gentity_t *self, gentity_t *ent ) { vec3_t eyes; //Calculate my position CalcEntitySpot( self, SPOT_HEAD_LEAN, eyes ); - + return G_ClearLOS( self, eyes, ent ); } @@ -835,7 +835,7 @@ qboolean G_ClearLOS( gentity_t *self, const vec3_t end ) //Calculate the my position CalcEntitySpot( self, SPOT_HEAD_LEAN, eyes ); - + return G_ClearLOS( self, eyes, end ); } @@ -853,11 +853,11 @@ float NPC_GetHFOVPercentage( vec3_t spot, vec3_t from, vec3_t facing, float hFOV VectorSubtract ( spot, from, deltaVector ); vectoangles ( deltaVector, angles ); - + delta = fabs( AngleDelta ( facing[YAW], angles[YAW] ) ); if ( delta > hFOV ) - return 0.0f; + return 0.0f; return ( ( hFOV - delta ) / hFOV ); } @@ -876,11 +876,11 @@ float NPC_GetVFOVPercentage( vec3_t spot, vec3_t from, vec3_t facing, float vFOV VectorSubtract ( spot, from, deltaVector ); vectoangles ( deltaVector, angles ); - + delta = fabs( AngleDelta ( facing[PITCH], angles[PITCH] ) ); if ( delta > vFOV ) - return 0.0f; + return 0.0f; return ( ( vFOV - delta ) / vFOV ); } @@ -888,7 +888,7 @@ float NPC_GetVFOVPercentage( vec3_t spot, vec3_t from, vec3_t facing, float vFOV #define MAX_INTEREST_DIST ( 256 * 256 ) /* ------------------------- -NPC_FindLocalInterestPoint +NPC_FindLocalInterestPoint ------------------------- */ diff --git a/codeJK2/game/NPC_sounds.cpp b/codeJK2/game/NPC_sounds.cpp index 21917661c5..aaec4a3360 100644 --- a/codeJK2/game/NPC_sounds.cpp +++ b/codeJK2/game/NPC_sounds.cpp @@ -67,12 +67,12 @@ void G_AddVoiceEvent( gentity_t *self, int event, int speakDebounceTime ) return; } - + if ( (self->NPC->scriptFlags&SCF_NO_COMBAT_TALK) && ( (event >= EV_ANGER1 && event <= EV_VICTORY3) || (event >= EV_CHASE1 && event <= EV_SUSPICIOUS5) ) )//(event < EV_FF_1A || event > EV_FF_3C) && (event < EV_RESPOND1 || event > EV_MISSION3) ) { return; } - + if ( (self->NPC->scriptFlags&SCF_NO_ALERT_TALK) && (event >= EV_GIVEUP1 && event <= EV_SUSPICIOUS5) ) { return; @@ -110,7 +110,7 @@ void NPC_PlayConfusionSound( gentity_t *self ) //reset him to be totally unaware again TIMER_Set( self, "enemyLastVisible", 0 ); self->NPC->tempBehavior = BS_DEFAULT; - + //self->NPC->behaviorState = BS_PATROL; G_ClearEnemy( self );//FIXME: or just self->enemy = NULL;? diff --git a/codeJK2/game/NPC_spawn.cpp b/codeJK2/game/NPC_spawn.cpp index f5343ef5c4..28cf40cff1 100644 --- a/codeJK2/game/NPC_spawn.cpp +++ b/codeJK2/game/NPC_spawn.cpp @@ -152,7 +152,7 @@ painFunc_t NPC_PainFunc( gentity_t *ent ) case CLASS_MARK2: func = painF_NPC_Mark2_Pain; break; - case CLASS_ATST: + case CLASS_ATST: func = painF_NPC_ATST_Pain; break; case CLASS_GALAKMECH: @@ -200,7 +200,7 @@ void NPC_SetMiscDefaultData( gentity_t *ent ) case TEAM_PLAYER: //ent->flags |= FL_NO_KNOCKBACK; if ( ent->client->NPC_class == CLASS_SEEKER ) - { + { ent->NPC->defaultBehavior = BS_DEFAULT; ent->client->ps.gravity = 0; ent->svFlags |= SVF_CUSTOM_GRAVITY; @@ -266,9 +266,9 @@ void NPC_SetMiscDefaultData( gentity_t *ent ) } break; - case TEAM_NEUTRAL: + case TEAM_NEUTRAL: - if ( Q_stricmp( ent->NPC_type, "gonk" ) == 0 ) + if ( Q_stricmp( ent->NPC_type, "gonk" ) == 0 ) { // I guess we generically make them player usable ent->svFlags |= SVF_PLAYER_USABLE; @@ -277,14 +277,14 @@ void NPC_SetMiscDefaultData( gentity_t *ent ) switch ( g_spskill->integer ) { case 0: // EASY - ent->client->ps.batteryCharge = MAX_BATTERIES * 0.8f; + ent->client->ps.batteryCharge = MAX_BATTERIES * 0.8f; break; case 1: // MEDIUM - ent->client->ps.batteryCharge = MAX_BATTERIES * 0.75f; + ent->client->ps.batteryCharge = MAX_BATTERIES * 0.75f; break; default : case 2: // HARD - ent->client->ps.batteryCharge = MAX_BATTERIES * 0.5f; + ent->client->ps.batteryCharge = MAX_BATTERIES * 0.5f; break; } } @@ -317,13 +317,13 @@ void NPC_SetMiscDefaultData( gentity_t *ent ) } else if( ent->client->NPC_class == CLASS_PROBE || ent->client->NPC_class == CLASS_REMOTE || ent->client->NPC_class == CLASS_INTERROGATOR || ent->client->NPC_class == CLASS_SENTRY) - { + { ent->NPC->defaultBehavior = BS_DEFAULT; ent->client->ps.gravity = 0; ent->svFlags |= SVF_CUSTOM_GRAVITY; ent->NPC->stats.moveType = MT_FLYSWIM; } - else + else { G_CreateG2AttachedWeaponModel( ent, weaponData[ent->client->ps.weapon].weaponMdl ); switch ( ent->client->ps.weapon ) @@ -406,9 +406,9 @@ int NPC_WeaponsForTeam( team_t team, int spawnflags, const char *NPC_type ) // case TEAM_IMPERIAL: case TEAM_ENEMY: - if ( Q_stricmp( "tavion", NPC_type ) == 0 || - Q_strncmp( "reborn", NPC_type, 6 ) == 0 || - Q_stricmp( "desann", NPC_type ) == 0 || + if ( Q_stricmp( "tavion", NPC_type ) == 0 || + Q_strncmp( "reborn", NPC_type, 6 ) == 0 || + Q_stricmp( "desann", NPC_type ) == 0 || Q_strncmp( "shadowtrooper", NPC_type, 13 ) == 0 ) return ( 1 << WP_SABER); // return ( 1 << WP_IMPERIAL_BLADE); @@ -504,11 +504,11 @@ int NPC_WeaponsForTeam( team_t team, int spawnflags, const char *NPC_type ) if (( Q_stricmp( "probe", NPC_type ) == 0 ) || ( Q_stricmp( "seeker", NPC_type ) == 0 )) { return ( 1 << WP_BOT_LASER); - } + } if ( Q_stricmp( "remote", NPC_type ) == 0 ) { return ( 1 << WP_BOT_LASER ); - } + } if ( Q_stricmp( "trandoshan", NPC_type ) == 0 ) { return (1<NPC->stats.health ) // Was health supplied in NPC.cfg? { - + if ( ent->client->NPC_class != CLASS_REBORN - && ent->client->NPC_class != CLASS_SHADOWTROOPER + && ent->client->NPC_class != CLASS_SHADOWTROOPER //&& ent->client->NPC_class != CLASS_TAVION - //&& ent->client->NPC_class != CLASS_DESANN + //&& ent->client->NPC_class != CLASS_DESANN && ent->client->NPC_class != CLASS_JEDI ) {// up everyone except jedi ent->NPC->stats.health += ent->NPC->stats.health/4 * g_spskill->integer; // 100% on easy, 125% on medium, 150% on hard } - + ent->max_health = client->pers.maxHealth = client->ps.stats[STAT_MAX_HEALTH] = ent->NPC->stats.health; } else @@ -928,7 +928,7 @@ void NPC_Begin (gentity_t *ent) ent->e_DieFunc = dieF_player_die; ent->waterlevel = 0; ent->watertype = 0; - + //visible to player and NPCs if ( ent->client->NPC_class != CLASS_R2D2 && ent->client->NPC_class != CLASS_R5D2 && @@ -941,7 +941,7 @@ void NPC_Begin (gentity_t *ent) ent->s.eFlags &= ~EF_NODRAW; NPC_SetFX_SpawnStates( ent ); - + client->ps.friction = 6; NPC_SetWeapons(ent); @@ -1046,7 +1046,7 @@ void NPC_Begin (gentity_t *ent) // initialize animations and other things memset( &ucmd, 0, sizeof( ucmd ) ); VectorCopyM( client->pers.cmd_angles, ucmd.angles ); - + ent->client->ps.groundEntityNum = ENTITYNUM_NONE; if ( ent->NPC->aiFlags & NPCAI_MATCHPLAYERWEAPON ) @@ -1089,14 +1089,14 @@ gNPC_t *New_NPC_t() NPC_StasisSpawn_Go ------------------------- */ -/* +/* qboolean NPC_StasisSpawn_Go( gentity_t *ent ) { //Setup an owner pointer if we need it if VALIDSTRING( ent->ownername ) { ent->owner = G_Find( NULL, FOFS( targetname ), ent->ownername ); - + if ( ( ent->owner ) && ( ent->owner->health <= 0 ) ) {//our spawner thing is broken if ( ent->target2 && ent->target2[0] ) @@ -1180,7 +1180,7 @@ void NPC_Spawn_Go( gentity_t *ent ) if( ent->count != -1 ) { ent->count--; - + if( ent->count <= 0 ) { ent->e_UseFunc = useF_NULL;//never again @@ -1190,28 +1190,28 @@ void NPC_Spawn_Go( gentity_t *ent ) newent = G_Spawn(); - if ( newent == NULL ) + if ( newent == NULL ) { gi.Printf ( S_COLOR_RED"ERROR: NPC G_Spawn failed\n" ); - + goto finish; return; } - + newent->svFlags |= SVF_NPC; newent->fullName = ent->fullName; - newent->NPC = New_NPC_t(); - if ( newent->NPC == NULL ) - { - gi.Printf ( S_COLOR_RED"ERROR: NPC G_Alloc NPC failed\n" ); + newent->NPC = New_NPC_t(); + if ( newent->NPC == NULL ) + { + gi.Printf ( S_COLOR_RED"ERROR: NPC G_Alloc NPC failed\n" ); goto finish; return; - } + } newent->NPC->tempGoal = G_Spawn(); - - if ( newent->NPC->tempGoal == NULL ) + + if ( newent->NPC->tempGoal == NULL ) { newent->NPC = NULL; goto finish; @@ -1223,19 +1223,19 @@ void NPC_Spawn_Go( gentity_t *ent ) newent->NPC->tempGoal->svFlags |= SVF_NOCLIENT; newent->client = (gclient_t *)G_Alloc (sizeof(gclient_t)); - - if ( newent->client == NULL ) + + if ( newent->client == NULL ) { gi.Printf ( S_COLOR_RED"ERROR: NPC G_Alloc client failed\n" ); goto finish; return; } - + memset ( newent->client, 0, sizeof(*newent->client) ); //==NPC_Connect( newent, net_name );=================================== - if ( ent->NPC_type == NULL ) + if ( ent->NPC_type == NULL ) { ent->NPC_type = "random"; } @@ -1256,7 +1256,7 @@ void NPC_Spawn_Go( gentity_t *ent ) { newent->svFlags |= SVF_NO_EXTRA_SOUNDS; } - + if ( ent->message ) {//has a key newent->message = ent->message;//transfer the key name @@ -1280,9 +1280,9 @@ void NPC_Spawn_Go( gentity_t *ent ) else if ( !Q_stricmp( ent->NPC_type, "test" ) ) { int n; - for ( n = 0; n < 1 ; n++) + for ( n = 0; n < 1 ; n++) { - if ( !(g_entities[n].svFlags & SVF_NPC) && g_entities[n].client) + if ( !(g_entities[n].svFlags & SVF_NPC) && g_entities[n].client) { VectorCopy(g_entities[n].s.origin, newent->s.origin); newent->client->playerTeam = g_entities[n].client->playerTeam; @@ -1304,7 +1304,7 @@ void NPC_Spawn_Go( gentity_t *ent ) newent->target3 = ent->target3;//??? newent->target4 = ent->target4;//ffire death newent->wait = ent->wait; - + for( index = BSET_FIRST; index < NUM_BSETS; index++) { if ( ent->behaviorSet[index] ) @@ -1316,7 +1316,7 @@ void NPC_Spawn_Go( gentity_t *ent ) newent->classname = "NPC"; newent->NPC_type = ent->NPC_type; gi.unlinkentity(newent); - + VectorCopy(ent->s.origin, newent->s.origin); VectorCopy(ent->s.origin, newent->client->ps.origin); VectorCopy(ent->s.origin, newent->currentOrigin); @@ -1326,7 +1326,7 @@ void NPC_Spawn_Go( gentity_t *ent ) VectorCopy(ent->s.angles, newent->currentAngles); VectorCopy(ent->s.angles, newent->client->ps.viewangles); newent->NPC->desiredYaw =ent->s.angles[YAW]; - + gi.linkentity(newent); newent->spawnflags = ent->spawnflags; @@ -1341,7 +1341,7 @@ void NPC_Spawn_Go( gentity_t *ent ) //==New stuff===================================================================== newent->s.eType = ET_PLAYER; - + //FIXME: Call CopyParms if ( ent->parms ) { @@ -1367,7 +1367,7 @@ void NPC_Spawn_Go( gentity_t *ent ) VectorCopy( newent->currentOrigin, newent->s.apos.trBase ); VectorClear( newent->s.apos.trDelta ); newent->s.apos.trDuration = 0; - + newent->NPC->combatPoint = -1; newent->flags |= FL_NOTARGET;//So he's ignored until he's fully spawned @@ -1418,9 +1418,9 @@ void NPC_StasisSpawnEffect( gentity_t *ent ) AngleVectors( ent->s.angles, forward, NULL, NULL ); VectorMA( ent->currentOrigin, 24, forward, end ); VectorMA( ent->currentOrigin, -20, forward, start ); - + start[2] += 64; - + taper = qtrue; } else @@ -1906,14 +1906,14 @@ void SP_NPC_Jedi( gentity_t *self) { self->NPC_type = "jeditrainer"; } - else + else { /* if ( !Q_irand( 0, 2 ) ) { self->NPC_type = "JediF"; } - else + else */if ( Q_irand( 0, 1 ) ) { self->NPC_type = "Jedi"; @@ -2076,7 +2076,7 @@ void SP_NPC_Ugnaught( gentity_t *self) /*QUAKED NPC_Gran(1 0 0) (-16 -16 -24) (16 16 40) SHOOTER BOXER x x DROPTOFLOOR CINEMATIC NOTSOLID STARTINSOLID SHY Uses grenade -SHOOTER - uses blaster instead of +SHOOTER - uses blaster instead of BOXER - uses fists only DROPTOFLOOR - NPC can be in air, but will spawn on the closest floor surface below it CINEMATIC - Will spawn with no default AI (BS_CINEMATIC) @@ -2353,7 +2353,7 @@ void SP_NPC_Reborn( gentity_t *self) self->NPC_type = "reborn"; } } - + WP_SetSaberModel( NULL, CLASS_REBORN ); SP_NPC_spawner( self ); } @@ -2378,7 +2378,7 @@ void SP_NPC_ShadowTrooper( gentity_t *self) self->NPC_type = "ShadowTrooper2"; } } - + NPC_ShadowTrooper_Precache(); WP_SetSaberModel( NULL, CLASS_SHADOWTROOPER ); @@ -2711,7 +2711,7 @@ NOTSOLID - Starts not solid STARTINSOLID - Don't try to fix if spawn in solid SHY - Spawner is shy -R2D2 Droid - you probably know this one already. +R2D2 Droid - you probably know this one already. NOTARGET by default */ @@ -2789,12 +2789,12 @@ void SP_NPC_Droid_Protocol( gentity_t *self) NPC_Spawn_f */ -static void NPC_Spawn_f(void) +static void NPC_Spawn_f(void) { gentity_t *NPCspawner = G_Spawn(); vec3_t forward, end; trace_t trace; - + if(!NPCspawner) { gi.Printf( S_COLOR_RED"NPC_Spawn Error: Out of entities!\n" ); @@ -2803,7 +2803,7 @@ static void NPC_Spawn_f(void) NPCspawner->e_ThinkFunc = thinkF_G_FreeEntity; NPCspawner->nextthink = level.time + FRAMETIME; - + const char *npc_type = gi.argv( 2 ); if (!*npc_type ) { @@ -2917,7 +2917,7 @@ static void NPC_Spawn_f(void) NPC_Kill_f */ -void NPC_Kill_f( void ) +void NPC_Kill_f( void ) { int n; gentity_t *player; @@ -2976,7 +2976,7 @@ void NPC_Kill_f( void ) } } - for ( n = 1; n < ENTITYNUM_MAX_NORMAL; n++) + for ( n = 1; n < ENTITYNUM_MAX_NORMAL; n++) { player = &g_entities[n]; if (!player->inuse) { @@ -3042,13 +3042,13 @@ Svcmd_NPC_f parse and dispatch bot commands */ qboolean showBBoxes = qfalse; -void Svcmd_NPC_f( void ) +void Svcmd_NPC_f( void ) { char *cmd; cmd = gi.argv( 1 ); - if ( !*cmd ) + if ( !*cmd ) { gi.Printf( "Valid NPC commands are:\n" ); gi.Printf( " spawn [NPC type (from NCPCs.cfg)]\n" ); @@ -3056,11 +3056,11 @@ void Svcmd_NPC_f( void ) gi.Printf( " showbounds (draws exact bounding boxes of NPCs)\n" ); gi.Printf( " score [NPC targetname] (prints number of kills per NPC)\n" ); } - else if ( Q_stricmp( cmd, "spawn" ) == 0 ) + else if ( Q_stricmp( cmd, "spawn" ) == 0 ) { NPC_Spawn_f(); } - else if ( Q_stricmp( cmd, "kill" ) == 0 ) + else if ( Q_stricmp( cmd, "kill" ) == 0 ) { NPC_Kill_f(); } diff --git a/codeJK2/game/NPC_utils.cpp b/codeJK2/game/NPC_utils.cpp index da44b88c8b..c2c8d4c2c7 100644 --- a/codeJK2/game/NPC_utils.cpp +++ b/codeJK2/game/NPC_utils.cpp @@ -38,7 +38,7 @@ void GetAnglesForDirection( const vec3_t p1, const vec3_t p2, vec3_t out ); extern void Q3_DebugPrint( int level, const char *format, ... ); /* -void CalcEntitySpot ( gentity_t *ent, spot_t spot, vec3_t point ) +void CalcEntitySpot ( gentity_t *ent, spot_t spot, vec3_t point ) Added: Uses shootAngles if a NPC has them @@ -46,7 +46,7 @@ Added: Uses shootAngles if a NPC has them extern void ViewHeightFix(const gentity_t *const ent); extern void AddLeanOfs(const gentity_t *const ent, vec3_t point); extern void SubtractLeanOfs(const gentity_t *const ent, vec3_t point); -void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) +void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) { vec3_t forward, up, right; vec3_t start, end; @@ -57,7 +57,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) return; } ViewHeightFix(ent); - switch ( spot ) + switch ( spot ) { case SPOT_ORIGIN: if(VectorCompare(ent->currentOrigin, vec3_origin)) @@ -94,7 +94,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) else { VectorCopy ( ent->currentOrigin, point ); - if ( ent->client ) + if ( ent->client ) { point[2] += ent->client->ps.viewheight; } @@ -131,7 +131,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) else { VectorCopy ( ent->currentOrigin, point ); - if ( ent->client ) + if ( ent->client ) { point[2] += ent->client->ps.viewheight; } @@ -164,7 +164,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) case SPOT_GROUND: // if entity is on the ground, just use it's absmin - if ( ent->s.groundEntityNum != -1 ) + if ( ent->s.groundEntityNum != -1 ) { VectorCopy( ent->currentOrigin, point ); point[2] = ent->absmin[2]; @@ -177,7 +177,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) VectorCopy( start, end ); end[2] -= 64; gi.trace( &tr, start, ent->mins, ent->maxs, end, ent->s.number, MASK_PLAYERSOLID, G2_NOCOLLIDE, 0 ); - if ( tr.fraction < 1.0 ) + if ( tr.fraction < 1.0 ) { VectorCopy( tr.endpos, point); break; @@ -197,7 +197,7 @@ void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point ) //=================================================================================== /* -qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) +qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) Added: option to do just pitch or just yaw @@ -206,7 +206,7 @@ Does not include "aim" in it's calculations FIXME: stop compressing angles into shorts!!!! */ extern cvar_t *g_timescale; -qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) +qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) { #if 1 @@ -219,7 +219,7 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) // if angle changes are locked; just keep the current angles // aimTime isn't even set anymore... so this code was never reached, but I need a way to lock NPC's yaw, so instead of making a new SCF_ flag, just use the existing render flag... - dmv - if ( !NPC->enemy && ( (level.time < NPCInfo->aimTime) || NPC->client->renderInfo.renderFlags & RF_LOCKEDANGLE) ) + if ( !NPC->enemy && ( (level.time < NPCInfo->aimTime) || NPC->client->renderInfo.renderFlags & RF_LOCKEDANGLE) ) { if(doPitch) targetPitch = NPCInfo->lockedDesiredPitch; @@ -227,7 +227,7 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) if(doYaw) targetYaw = NPCInfo->lockedDesiredYaw; } - else + else { // we're changing the lockedDesired Pitch/Yaw below so it's lost it's original meaning, get rid of the lock flag NPC->client->renderInfo.renderFlags &= ~RF_LOCKEDANGLE; @@ -242,7 +242,7 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) { targetYaw = NPCInfo->desiredYaw; NPCInfo->lockedDesiredYaw = NPCInfo->desiredYaw; - } + } } if ( NPC->s.weapon == WP_EMPLACED_GUN ) @@ -259,39 +259,39 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) { yawSpeed *= 1.0f/g_timescale->value; } - + if( doYaw ) { // decay yaw error error = AngleDelta ( NPC->client->ps.viewangles[YAW], targetYaw ); if( fabs(error) > MIN_ANGLE_ERROR ) { - if ( error ) + if ( error ) { exact = qfalse; decay = 60.0 + yawSpeed * 3; decay *= 50.0f / 1000.0f;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } } } } - + ucmd.angles[YAW] = ANGLE2SHORT( targetYaw + error ) - client->ps.delta_angles[YAW]; } @@ -302,25 +302,25 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) error = AngleDelta ( NPC->client->ps.viewangles[PITCH], targetPitch ); if ( fabs(error) > MIN_ANGLE_ERROR ) { - if ( error ) + if ( error ) { exact = qfalse; decay = 60.0 + yawSpeed * 3; decay *= 50.0f / 1000.0f;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -351,14 +351,14 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) qboolean doSound = qfalse; // if angle changes are locked; just keep the current angles - if ( level.time < NPCInfo->aimTime ) + if ( level.time < NPCInfo->aimTime ) { if(doPitch) targetPitch = NPCInfo->lockedDesiredPitch; if(doYaw) targetYaw = NPCInfo->lockedDesiredYaw; } - else + else { if(doPitch) targetPitch = NPCInfo->desiredPitch; @@ -384,7 +384,7 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) if(NPC->client->playerTeam == TEAM_BORG&& NPCInfo->behaviorState != BS_FACE&&NPCInfo->tempBehavior!= BS_FACE) {//HACK - borg turn more jittery - if ( error ) + if ( error ) { exact = qfalse; @@ -399,18 +399,18 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) } } - if ( error < 0.0)//-10.0 ) + if ( error < 0.0)//-10.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else if ( error > 0.0)//10.0 ) + else if ( error > 0.0)//10.0 ) { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -418,26 +418,26 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) } } else*/ - - if ( error ) + + if ( error ) { exact = qfalse; decay = 60.0 + yawSpeed * 3; decay *= 50.0 / 1000.0;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -458,7 +458,7 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) if(NPC->client->playerTeam == TEAM_BORG&& NPCInfo->behaviorState != BS_FACE&&NPCInfo->tempBehavior!= BS_FACE) {//HACK - borg turn more jittery - if ( error ) + if ( error ) { exact = qfalse; @@ -473,18 +473,18 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) } } - if ( error < 0.0)//-10.0 ) + if ( error < 0.0)//-10.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else if ( error > 0.0)//10.0 ) + else if ( error > 0.0)//10.0 ) { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -492,26 +492,26 @@ qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw ) } } else*/ - - if ( error ) + + if ( error ) { exact = qfalse; decay = 60.0 + yawSpeed * 3; decay *= 50.0 / 1000.0;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -553,11 +553,11 @@ void NPC_AimWiggle( vec3_t enemy_org ) } /* -qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) +qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) Includes aim when determining angles - so they don't always hit... */ -qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) +qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) { #if 0 @@ -568,7 +568,7 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) float targetYaw = 0; qboolean exact = qtrue; - if ( level.time < NPCInfo->aimTime ) + if ( level.time < NPCInfo->aimTime ) { if( doPitch ) targetPitch = NPCInfo->lockedDesiredPitch; @@ -576,7 +576,7 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) if( doYaw ) targetYaw = NPCInfo->lockedDesiredYaw; } - else + else { if( doPitch ) { @@ -588,7 +588,7 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) { targetYaw = NPCInfo->desiredYaw; NPCInfo->lockedDesiredYaw = NPCInfo->desiredYaw; - } + } } if( doYaw ) @@ -603,7 +603,7 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) if ( diff ) exact = qfalse; - + ucmd.angles[YAW] = ANGLE2SHORT( targetYaw + diff + error ) - client->ps.delta_angles[YAW]; } @@ -616,14 +616,14 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) if ( diff ) exact = qfalse; - + ucmd.angles[PITCH] = ANGLE2SHORT( targetPitch + diff + error ) - client->ps.delta_angles[PITCH]; } ucmd.angles[ROLL] = ANGLE2SHORT ( NPC->client->ps.viewangles[ROLL] ) - client->ps.delta_angles[ROLL]; return exact; - + #else float error, diff; @@ -633,14 +633,14 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) qboolean exact = qtrue; // if angle changes are locked; just keep the current angles - if ( level.time < NPCInfo->aimTime ) + if ( level.time < NPCInfo->aimTime ) { if(doPitch) targetPitch = NPCInfo->lockedDesiredPitch; if(doYaw) targetYaw = NPCInfo->lockedDesiredYaw; } - else + else { if(doPitch) targetPitch = NPCInfo->desiredPitch; @@ -671,31 +671,31 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) { // decay yaw diff diff = AngleDelta ( NPC->client->ps.viewangles[YAW], targetYaw ); - - if ( diff) + + if ( diff) { exact = qfalse; decay = 60.0 + 80.0; decay *= 50.0f / 1000.0f;//msec - if ( diff < 0.0 ) + if ( diff < 0.0 ) { diff += decay; - if ( diff > 0.0 ) + if ( diff > 0.0 ) { diff = 0.0; } } - else + else { diff -= decay; - if ( diff < 0.0 ) + if ( diff < 0.0 ) { diff = 0.0; } } } - + // add yaw error based on NPCInfo->aim value error = NPCInfo->lastAimErrorYaw; @@ -713,30 +713,30 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) { // decay pitch diff diff = AngleDelta ( NPC->client->ps.viewangles[PITCH], targetPitch ); - if ( diff) + if ( diff) { exact = qfalse; decay = 60.0 + 80.0; decay *= 50.0f / 1000.0f;//msec - if ( diff < 0.0 ) + if ( diff < 0.0 ) { diff += decay; - if ( diff > 0.0 ) + if ( diff > 0.0 ) { diff = 0.0; } } - else + else { diff -= decay; - if ( diff < 0.0 ) + if ( diff < 0.0 ) { diff = 0.0; } } } - + error = NPCInfo->lastAimErrorPitch; ucmd.angles[PITCH] = ANGLE2SHORT( targetPitch + diff + error ) - client->ps.delta_angles[PITCH]; @@ -752,12 +752,12 @@ qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw ) //=================================================================================== /* -static void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) +static void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) Does update angles on shootAngles */ -void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) +void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) {//FIXME: shoot angles either not set right or not used! float error; float decay; @@ -774,22 +774,22 @@ void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) { // decay yaw error error = AngleDelta ( NPCInfo->shootAngles[YAW], targetYaw ); - if ( error ) + if ( error ) { decay = 60.0 + 80.0 * NPCInfo->stats.aim; decay *= 100.0f / 1000.0f;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -802,22 +802,22 @@ void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw ) { // decay pitch error error = AngleDelta ( NPCInfo->shootAngles[PITCH], targetPitch ); - if ( error ) + if ( error ) { decay = 60.0 + 80.0 * NPCInfo->stats.aim; decay *= 100.0f / 1000.0f;//msec - if ( error < 0.0 ) + if ( error < 0.0 ) { error += decay; - if ( error > 0.0 ) + if ( error > 0.0 ) { error = 0.0; } } - else + else { error -= decay; - if ( error < 0.0 ) + if ( error < 0.0 ) { error = 0.0; } @@ -879,7 +879,7 @@ qboolean G_ActivateBehavior (gentity_t *self, int bset ) } bs_name = self->behaviorSet[bset]; - + if( !(VALIDSTRING( bs_name )) ) { return qfalse; @@ -898,10 +898,10 @@ qboolean G_ActivateBehavior (gentity_t *self, int bset ) else { /* - char newname[MAX_FILENAME_LENGTH]; + char newname[MAX_FILENAME_LENGTH]; sprintf((char *) &newname, "%s/%s", Q3_SCRIPT_DIR, bs_name ); */ - + //FIXME: between here and actually getting into the ICARUS_RunScript function, the stack gets blown! if ( ( ICARUS_entFilter == -1 ) || ( ICARUS_entFilter == self->s.number ) ) { @@ -1288,7 +1288,7 @@ qboolean NPC_FacePosition( vec3_t position, qboolean doPitch ) //Find the delta between our goal and our current facing float yawDelta = AngleNormalize360( NPCInfo->desiredYaw - ( SHORT2ANGLE( ucmd.angles[YAW] + client->ps.delta_angles[YAW] ) ) ); - + //See if we are facing properly if ( fabs( yawDelta ) > VALID_ATTACK_CONE ) facing = qfalse; @@ -1298,7 +1298,7 @@ qboolean NPC_FacePosition( vec3_t position, qboolean doPitch ) //Find the delta between our goal and our current facing float currentAngles = ( SHORT2ANGLE( ucmd.angles[PITCH] + client->ps.delta_angles[PITCH] ) ); float pitchDelta = NPCInfo->desiredPitch - currentAngles; - + //See if we are facing properly if ( fabs( pitchDelta ) > VALID_ATTACK_CONE ) facing = qfalse; diff --git a/codeJK2/game/Q3_Interface.cpp b/codeJK2/game/Q3_Interface.cpp index 4be6d5216f..24c8e819a2 100644 --- a/codeJK2/game/Q3_Interface.cpp +++ b/codeJK2/game/Q3_Interface.cpp @@ -22,7 +22,7 @@ along with this program; if not, see . // ICARUS Engine Interface File // -// This file is the only section of the ICARUS systems that +// This file is the only section of the ICARUS systems that // is not directly portable from engine to engine. // // -- jweier @@ -83,7 +83,7 @@ extern qboolean stop_icarus; //#define stringIDExpand(str, strEnum) str,strEnum /* -stringID_table_t tagsTable [] = +stringID_table_t tagsTable [] = { } */ @@ -151,7 +151,7 @@ stringID_table_t WPTable[] = // NPC enemy weapons ENUM2STRING(WP_EMPLACED_GUN), ENUM2STRING(WP_BOT_LASER), // Probe droid - Laser blast - ENUM2STRING(WP_TURRET), // turret guns + ENUM2STRING(WP_TURRET), // turret guns ENUM2STRING(WP_ATST_MAIN), ENUM2STRING(WP_ATST_SIDE), ENUM2STRING(WP_TIE_FIGHTER), @@ -407,7 +407,7 @@ stringID_table_t setTable[] = {"", SET_}, }; -qboolean COM_ParseString( char **data, char **s ); +qboolean COM_ParseString( char **data, char **s ); //======================================================================= @@ -423,7 +423,7 @@ vec4_t textcolor_scroll; ============ Q3_ReadScript Description : Reads in a file and attaches the script directory properly - Return type : static int + Return type : static int Argument : const char *name Argument : void **buf ============ @@ -436,9 +436,9 @@ static int Q3_ReadScript( const char *name, void **buf ) /* ============ -Q3_CenterPrint +Q3_CenterPrint Description : Prints a message in the center of the screen - Return type : static void + Return type : static void Argument : const char *format Argument : ... ============ @@ -513,7 +513,7 @@ static void SetTextColor ( vec4_t textcolor,const char *color) { VectorCopy4( colorTable[CT_WHITE], textcolor ); } - else + else { VectorCopy4( colorTable[CT_WHITE], textcolor ); } @@ -614,8 +614,8 @@ static void Q3_TaskIDSet( gentity_t *ent, taskID_t taskType, int taskID ) /* ============ Q3_CheckStringCounterIncrement - Description : - Return type : static float + Description : + Return type : static float Argument : const char *string ============ */ @@ -788,7 +788,7 @@ static void Q3_SetMissionFailed(const char *TextEnum) ent->health = 0; //FIXME: what about other NPCs? Scripts? - // statusTextIndex is looked at on the client side. + // statusTextIndex is looked at on the client side. statusTextIndex = GetIDForString( missionFailedTable, TextEnum ); cg.missionStatusShow = qtrue; if ( ent->client ) @@ -952,7 +952,7 @@ static unsigned int Q3_GetTime( void ) G_AddSexToMunroString Take any string, look for "kyle/" replace with "kyla/" based on "sex" -And: Take any string, look for "/mr_" replace with "/ms_" based on "sex" +And: Take any string, look for "/mr_" replace with "/ms_" based on "sex" returns qtrue if changed to ms ============= */ @@ -1055,7 +1055,7 @@ static int Q3_PlaySound( int taskID, int entID, const char *name, const char *ch if (g_subtitles->integer == 1 || (ent->NPC && (ent->NPC->scriptFlags & SCF_USE_SUBTITLES) ) ) // Show all text { if ( in_camera) // Cinematic - { + { gi.SendServerCommand( 0, "ct \"%s\" %i", finalName, soundHandle ); } else //if (precacheWav[i].speaker==SP_NONE) // lower screen text @@ -1073,7 +1073,7 @@ static int Q3_PlaySound( int taskID, int entID, const char *name, const char *ch else if (g_subtitles->integer == 2) // Show only talking head text and CINEMATIC { if ( in_camera) // Cinematic text - { + { gi.SendServerCommand( 0, "ct \"%s\" %i", finalName, soundHandle); } } @@ -1176,7 +1176,7 @@ static void Q3_SetOrigin( int entID, vec3_t origin ) VectorClear (ent->client->ps.velocity); ent->client->ps.pm_time = 160; // hold time ent->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; - + ent->client->ps.eFlags ^= EF_TELEPORT_BIT; // G_KillBox (ent); @@ -1193,8 +1193,8 @@ static void Q3_SetOrigin( int entID, vec3_t origin ) /* ============ MoveOwner - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *self ============ */ @@ -1242,7 +1242,7 @@ static qboolean Q3_SetTeleportDest( int entID, vec3_t org ) teleporter->e_ThinkFunc = thinkF_MoveOwner; teleporter->nextthink = level.time + FRAMETIME; - + return qfalse; } else @@ -1309,8 +1309,8 @@ static void Q3_SetVelocity( int entID, int axis, float speed ) /* ============ Q3_SetAdjustAreaPortals - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean shields ============ @@ -1331,8 +1331,8 @@ static void Q3_SetAdjustAreaPortals( int entID, qboolean adjust ) /* ============ Q3_SetDmgByHeavyWeapOnly - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean dmg ============ @@ -1346,15 +1346,15 @@ static void Q3_SetDmgByHeavyWeapOnly( int entID, qboolean dmg ) Q3_DebugPrint( WL_WARNING, "Q3_SetDmgByHeavyWeapOnly: invalid entID %d\n", entID); return; } - + ent->flags = (dmg) ? (ent->flags|FL_DMG_BY_HEAVY_WEAP_ONLY) : (ent->flags&~FL_DMG_BY_HEAVY_WEAP_ONLY); } /* ============ Q3_SetShielded - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean dmg ============ @@ -1368,15 +1368,15 @@ static void Q3_SetShielded( int entID, qboolean dmg ) Q3_DebugPrint( WL_WARNING, "Q3_SetShielded: invalid entID %d\n", entID); return; } - + ent->flags = (dmg) ? (ent->flags|FL_SHIELDED) : (ent->flags&~FL_SHIELDED); } /* ============ Q3_SetNoGroups - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean dmg ============ @@ -1396,7 +1396,7 @@ static void Q3_SetNoGroups( int entID, qboolean noGroups ) Q3_DebugPrint( WL_WARNING, "Q3_SetNoGroups: ent %s is not an NPC!\n", ent->targetname ); return; } - + ent->NPC->scriptFlags = noGroups ? (ent->NPC->scriptFlags|SCF_NO_GROUPS) : (ent->NPC->scriptFlags&~SCF_NO_GROUPS); } @@ -1412,18 +1412,18 @@ void moverCallback( gentity_t *ent ) { //complete the task Q3_TaskIDComplete( ent, TID_MOVE_NAV ); - + // play sound ent->s.loopSound = 0;//stop looping sound G_PlayDoorSound( ent, BMS_END );//play end sound - if ( ent->moverState == MOVER_1TO2 ) + if ( ent->moverState == MOVER_1TO2 ) {//reached open // reached pos2 MatchTeam( ent, MOVER_POS2, level.time ); //SetMoverState( ent, MOVER_POS2, level.time ); - } - else if ( ent->moverState == MOVER_2TO1 ) + } + else if ( ent->moverState == MOVER_2TO1 ) {//reached closed MatchTeam( ent, MOVER_POS1, level.time ); //SetMoverState( ent, MOVER_POS1, level.time ); @@ -1527,11 +1527,11 @@ static void Q3_Lerp2Start( int entID, int taskID, float duration ) gentity_t *ent = &g_entities[entID]; if(!ent) - { + { Q3_DebugPrint( WL_WARNING, "Q3_Lerp2Start: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_Lerp2Start: ent %d is NOT a mover!\n", entID); @@ -1554,7 +1554,7 @@ static void Q3_Lerp2Start( int entID, int taskID, float duration ) ent->s.pos.trDuration = duration * 10; //In seconds ent->s.pos.trTime = level.time; - + Q3_TaskIDSet( ent, TID_MOVE_NAV, taskID ); // starting sound G_PlayDoorLoopSound( ent ); @@ -1579,7 +1579,7 @@ static void Q3_Lerp2End( int entID, int taskID, float duration ) Q3_DebugPrint( WL_WARNING, "Q3_Lerp2End: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_Lerp2End: ent %d is NOT a mover!\n", entID); @@ -1610,7 +1610,7 @@ static void Q3_Lerp2End( int entID, int taskID, float duration ) ent->s.pos.trDuration = duration * 10; //In seconds ent->s.time = level.time; - + Q3_TaskIDSet( ent, TID_MOVE_NAV, taskID ); // starting sound G_PlayDoorLoopSound( ent ); @@ -1638,7 +1638,7 @@ static void Q3_Lerp2Pos( int taskID, int entID, vec3_t origin, vec3_t angles, fl Q3_DebugPrint( WL_WARNING, "Q3_Lerp2Pos: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_Lerp2Pos: ent %d is NOT a mover!\n", entID); @@ -1755,7 +1755,7 @@ static void Q3_Lerp2Origin( int taskID, int entID, vec3_t origin, float duration Q3_DebugPrint( WL_WARNING, "Q3_Lerp2Origin: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_Lerp2Origin: ent %d is NOT a mover!\n", entID); @@ -1825,7 +1825,7 @@ static void Q3_SetOriginOffset( int entID, int axis, float offset ) Q3_DebugPrint( WL_WARNING, "Q3_SetOriginOffset: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_SetOriginOffset: ent %d is NOT a mover!\n", entID); @@ -1860,7 +1860,7 @@ static void Q3_Lerp2Angles( int taskID, int entID, vec3_t angles, float duration Q3_DebugPrint( WL_WARNING, "Q3_Lerp2Angles: invalid entID %d\n", entID); return; } - + if ( ent->client || ent->NPC || Q_stricmp(ent->classname, "target_scriptrunner") == 0 ) { Q3_DebugPrint( WL_ERROR, "Q3_Lerp2Angles: ent %d is NOT a mover!\n", entID); @@ -1888,7 +1888,7 @@ static void Q3_Lerp2Angles( int taskID, int entID, vec3_t angles, float duration } ent->s.apos.trTime = level.time; - + Q3_TaskIDSet( ent, TID_ANGLE_FACE, taskID ); //ent->e_ReachedFunc = reachedF_NULL; @@ -1921,7 +1921,7 @@ static int Q3_GetTag( int entID, const char *name, int lookup, vec3_t info ) case TYPE_ANGLES: //return TAG_GetAngles( ent->targetname, name, info ); return TAG_GetAngles( ent->ownername, name, info ); - break; + break; } return false; @@ -2002,8 +2002,8 @@ static void Q3_SetNavGoal( int entID, const char *name ) /* ============ SetLowerAnim - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int animID ============ @@ -2030,9 +2030,9 @@ static void SetLowerAnim( int entID, int animID) /* ============ -SetUpperAnim - Description : - Return type : static void +SetUpperAnim + Description : + Return type : static void Argument : int entID Argument : int animID ============ @@ -2076,7 +2076,7 @@ static qboolean Q3_SetAnimUpper( int entID, const char *anim_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetAnimUpper: unknown animation sequence '%s'\n", anim_name ); return qfalse; } - + if ( !PM_HasAnimation( &g_entities[entID], animID ) ) { return qfalse; @@ -2107,7 +2107,7 @@ static qboolean Q3_SetAnimLower( int entID, const char *anim_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetAnimLower: unknown animation sequence '%s'\n", anim_name ); return qfalse; } - + if ( !PM_HasAnimation( &g_entities[entID], animID ) ) { return qfalse; @@ -2120,8 +2120,8 @@ static qboolean Q3_SetAnimLower( int entID, const char *anim_name ) /* ============ Q3_SetAnimHoldTime - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int int_data Argument : qboolean lower @@ -2144,7 +2144,7 @@ static void Q3_SetAnimHoldTime( int entID, int int_data, qboolean lower ) Q3_DebugPrint( WL_ERROR, "Q3_SetAnimHoldTime: ent %d is NOT a player or NPC!\n", entID); return; } - + if(lower) { PM_SetLegsAnimTimer( ent, &ent->client->ps.legsAnimTimer, int_data ); @@ -2297,7 +2297,7 @@ static void Q3_SetLeader( int entID, const char *name ) } } -stringID_table_t teamTable [] = +stringID_table_t teamTable [] = { ENUM2STRING(TEAM_FREE), ENUM2STRING(TEAM_PLAYER), @@ -2310,8 +2310,8 @@ stringID_table_t teamTable [] = /* ============ Q3_SetPlayerTeam - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *teamName ============ @@ -2341,8 +2341,8 @@ static void Q3_SetPlayerTeam( int entID, const char *teamName ) /* ============ Q3_SetEnemyTeam - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *teamName ============ @@ -2362,7 +2362,7 @@ static void Q3_SetEnemyTeam( int entID, const char *teamName ) Q3_DebugPrint( WL_ERROR, "Q3_SetEnemyTeam: ent %d is NOT a player or NPC!\n", entID); return; } - + ent->client->enemyTeam = (team_t)GetIDForString( teamTable, teamName ); } @@ -2370,8 +2370,8 @@ static void Q3_SetEnemyTeam( int entID, const char *teamName ) /* ============ Q3_SetHealth - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int data ============ @@ -2385,7 +2385,7 @@ static void Q3_SetHealth( int entID, int data ) Q3_DebugPrint( WL_WARNING, "Q3_SetHealth: invalid entID %d\n", entID); return; } - + if ( data < 0 ) { data = 0; @@ -2406,7 +2406,7 @@ static void Q3_SetHealth( int entID, int data ) ent->client->ps.stats[STAT_HEALTH] = data; if ( ent->s.number == 0 ) - {//clamp health to max + {//clamp health to max if ( ent->client->ps.stats[STAT_HEALTH] > ent->client->ps.stats[STAT_MAX_HEALTH] ) { ent->health = ent->client->ps.stats[STAT_HEALTH] = ent->client->ps.stats[STAT_MAX_HEALTH]; @@ -2427,8 +2427,8 @@ static void Q3_SetHealth( int entID, int data ) /* ============ Q3_SetArmor - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int data ============ @@ -2442,7 +2442,7 @@ static void Q3_SetArmor( int entID, int data ) Q3_DebugPrint( WL_WARNING, "Q3_SetArmor: invalid entID %d\n", entID); return; } - + if(!ent->client) { return; @@ -2461,11 +2461,11 @@ static void Q3_SetArmor( int entID, int data ) /* ============ Q3_SetBState - Description : - Return type : static qboolean + Description : + Return type : static qboolean Argument : int entID Argument : const char *bs_name -FIXME: this should be a general NPC wrapper function +FIXME: this should be a general NPC wrapper function that is called ANY time a bState is changed... ============ */ @@ -2479,7 +2479,7 @@ static qboolean Q3_SetBState( int entID, const char *bs_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetBState: invalid entID %d\n", entID); return qtrue; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetBState: '%s' is not an NPC\n", ent->targetname ); @@ -2492,7 +2492,7 @@ static qboolean Q3_SetBState( int entID, const char *bs_name ) if ( bSID == BS_SEARCH || bSID == BS_WANDER ) { //FIXME: Reimplement - + if( ent->waypoint != WAYPOINT_NONE ) { NPC_BSSearchStart( ent->waypoint, bSID ); @@ -2520,7 +2520,7 @@ static qboolean Q3_SetBState( int entID, const char *bs_name ) } } } - + ent->NPC->tempBehavior = BS_DEFAULT;//need to clear any temp behaviour if ( ent->NPC->behaviorState == BS_NOCLIP && bSID != BS_NOCLIP ) @@ -2589,8 +2589,8 @@ static qboolean Q3_SetBState( int entID, const char *bs_name ) /* ============ Q3_SetTempBState - Description : - Return type : static qboolean + Description : + Return type : static qboolean Argument : int entID Argument : const char *bs_name ============ @@ -2605,7 +2605,7 @@ static qboolean Q3_SetTempBState( int entID, const char *bs_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetTempBState: invalid entID %d\n", entID); return qtrue; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetTempBState: '%s' is not an NPC\n", ent->targetname ); @@ -2639,8 +2639,8 @@ static qboolean Q3_SetTempBState( int entID, const char *bs_name ) /* ============ Q3_SetDefaultBState - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *bs_name ============ @@ -2655,7 +2655,7 @@ static void Q3_SetDefaultBState( int entID, const char *bs_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetDefaultBState: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetDefaultBState: '%s' is not an NPC\n", ent->targetname ); @@ -2673,8 +2673,8 @@ static void Q3_SetDefaultBState( int entID, const char *bs_name ) /* ============ Q3_SetDPitch - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2688,13 +2688,13 @@ static void Q3_SetDPitch( int entID, float data ) Q3_DebugPrint( WL_WARNING, "Q3_SetDPitch: invalid entID %d\n", entID); return; } - + if ( !ent->NPC || !ent->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetDPitch: '%s' is not an NPC\n", ent->targetname ); return; } - + int pitchMin = -ent->client->renderInfo.headPitchRangeUp + 1; int pitchMax = ent->client->renderInfo.headPitchRangeDown - 1; @@ -2724,8 +2724,8 @@ static void Q3_SetDPitch( int entID, float data ) /* ============ Q3_SetDYaw - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2733,13 +2733,13 @@ Q3_SetDYaw static void Q3_SetDYaw( int entID, float data ) { gentity_t *ent = &g_entities[entID]; - + if ( !ent ) { Q3_DebugPrint( WL_WARNING, "Q3_SetDYaw: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetDYaw: '%s' is not an NPC\n", ent->targetname ); @@ -2760,8 +2760,8 @@ static void Q3_SetDYaw( int entID, float data ) /* ============ Q3_SetShootDist - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2775,7 +2775,7 @@ static void Q3_SetShootDist( int entID, float data ) Q3_DebugPrint( WL_WARNING, "Q3_SetShootDist: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetShootDist: '%s' is not an NPC\n", ent->targetname ); @@ -2789,8 +2789,8 @@ static void Q3_SetShootDist( int entID, float data ) /* ============ Q3_SetVisrange - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2804,7 +2804,7 @@ static void Q3_SetVisrange( int entID, float data ) Q3_DebugPrint( WL_WARNING, "Q3_SetVisrange: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetVisrange: '%s' is not an NPC\n", ent->targetname ); @@ -2818,8 +2818,8 @@ static void Q3_SetVisrange( int entID, float data ) /* ============ Q3_SetEarshot - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2833,7 +2833,7 @@ static void Q3_SetEarshot( int entID, float data ) Q3_DebugPrint( WL_WARNING, "Q3_SetEarshot: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetEarshot: '%s' is not an NPC\n", ent->targetname ); @@ -2847,8 +2847,8 @@ static void Q3_SetEarshot( int entID, float data ) /* ============ Q3_SetVigilance - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2862,7 +2862,7 @@ static void Q3_SetVigilance( int entID, float data ) Q3_DebugPrint( WL_WARNING, "Q3_SetVigilance: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetVigilance: '%s' is not an NPC\n", ent->targetname ); @@ -2876,8 +2876,8 @@ static void Q3_SetVigilance( int entID, float data ) /* ============ Q3_SetVFOV - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int data ============ @@ -2891,7 +2891,7 @@ static void Q3_SetVFOV( int entID, int data ) Q3_DebugPrint( WL_WARNING, "Q3_SetVFOV: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetVFOV: '%s' is not an NPC\n", ent->targetname ); @@ -2905,8 +2905,8 @@ static void Q3_SetVFOV( int entID, int data ) /* ============ Q3_SetHFOV - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int data ============ @@ -2920,7 +2920,7 @@ static void Q3_SetHFOV( int entID, int data ) Q3_DebugPrint( WL_WARNING, "Q3_SetHFOV: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetHFOV: '%s' is not an NPC\n", ent->targetname ); @@ -2934,8 +2934,8 @@ static void Q3_SetHFOV( int entID, int data ) /* ============ Q3_SetWidth - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float data ============ @@ -2943,13 +2943,13 @@ Q3_SetWidth static void Q3_SetWidth( int entID, int data ) { gentity_t *ent = &g_entities[entID]; - + if ( !ent ) { Q3_DebugPrint( WL_WARNING, "Q3_SetWidth: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetWidth: '%s' is not an NPC\n", ent->targetname ); @@ -2963,8 +2963,8 @@ static void Q3_SetWidth( int entID, int data ) /* ============ Q3_GetTimeScale - Description : - Return type : static unsigned int + Description : + Return type : static unsigned int Argument : void ============ */ @@ -2978,8 +2978,8 @@ static unsigned int Q3_GetTimeScale( void ) /* ============ Q3_SetTimeScale - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *data ============ @@ -2993,8 +2993,8 @@ static void Q3_SetTimeScale( int entID, const char *data ) /* ============ Q3_SetInvisible - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : qboolean invisible ============ @@ -3008,7 +3008,7 @@ static void Q3_SetInvisible( int entID, qboolean invisible ) Q3_DebugPrint( WL_WARNING, "Q3_SetInvisible: invalid entID %d\n", entID); return; } - + if ( invisible ) { self->s.eFlags |= EF_NODRAW; @@ -3031,8 +3031,8 @@ static void Q3_SetInvisible( int entID, qboolean invisible ) /* ============ Q3_SetVampire - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : qboolean vampire ============ @@ -3046,7 +3046,7 @@ static void Q3_SetVampire( int entID, qboolean vampire ) Q3_DebugPrint( WL_WARNING, "Q3_SetVampire: entID %d not a client\n", entID); return; } - + if ( vampire ) { self->client->ps.powerups[PW_DISINT_2] = Q3_INFINITE; @@ -3059,8 +3059,8 @@ static void Q3_SetVampire( int entID, qboolean vampire ) /* ============ Q3_SetGreetAllies - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : qboolean greet ============ @@ -3074,7 +3074,7 @@ static void Q3_SetGreetAllies( int entID, qboolean greet ) Q3_DebugPrint( WL_WARNING, "Q3_SetGreetAllies: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_WARNING, "Q3_SetGreetAllies: ent %s is not an NPC!\n", self->targetname ); @@ -3094,9 +3094,9 @@ static void Q3_SetGreetAllies( int entID, qboolean greet ) /* ============ -Q3_SetViewTarget - Description : - Return type : static void +Q3_SetViewTarget + Description : + Return type : static void Argument : int entID Argument : const char *name ============ @@ -3112,26 +3112,26 @@ static void Q3_SetViewTarget (int entID, const char *name) Q3_DebugPrint( WL_WARNING, "Q3_SetViewTarget: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetViewTarget: '%s' is not a player/NPC!\n", self->targetname ); return; } - + //FIXME: Exception handle here if (viewtarget == NULL) { Q3_DebugPrint( WL_WARNING, "Q3_SetViewTarget: can't find ViewTarget: '%s'\n", name ); return; } - + //FIXME: should we set behavior to BS_FACE and keep facing this ent as it moves //around for a script-specified length of time...? VectorCopy ( self->currentOrigin, selfspot ); selfspot[2] += self->client->ps.viewheight; - if ( viewtarget->client && (!g_skippingcin || !g_skippingcin->integer ) ) + if ( viewtarget->client && (!g_skippingcin || !g_skippingcin->integer ) ) { VectorCopy ( viewtarget->client->renderInfo.eyePoint, viewspot ); } @@ -3139,9 +3139,9 @@ static void Q3_SetViewTarget (int entID, const char *name) { VectorCopy ( viewtarget->currentOrigin, viewspot ); } - + VectorSubtract( viewspot, selfspot, viewvec ); - + vectoangles( viewvec, viewangles ); Q3_SetDYaw( entID, viewangles[YAW] ); @@ -3154,9 +3154,9 @@ static void Q3_SetViewTarget (int entID, const char *name) /* ============ -Q3_SetWatchTarget - Description : - Return type : static void +Q3_SetWatchTarget + Description : + Return type : static void Argument : int entID Argument : const char *name ============ @@ -3171,13 +3171,13 @@ static void Q3_SetWatchTarget (int entID, const char *name) Q3_DebugPrint( WL_WARNING, "Q3_SetWatchTarget: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetWatchTarget: '%s' is not an NPC!\n", self->targetname ); return; } - + if ( Q_stricmp( "NULL", name ) == 0 || Q_stricmp( "NONE", name ) == 0 || ( self->targetname && (Q_stricmp( self->targetname, name ) == 0) ) ) {//clearing watchTarget self->NPC->watchTarget = NULL; @@ -3189,7 +3189,7 @@ static void Q3_SetWatchTarget (int entID, const char *name) Q3_DebugPrint( WL_WARNING, "Q3_SetWatchTarget: can't find WatchTarget: '%s'\n", name ); return; } - + self->NPC->watchTarget = watchTarget; } @@ -3236,7 +3236,7 @@ void Q3_SetICARUSFreeze( int entID, const char *name, qboolean freeze ) Q3_DebugPrint( WL_WARNING, "Q3_SetICARUSFreeze: invalid ent %s\n", name); return; } - + if ( freeze ) { self->svFlags |= SVF_ICARUS_FREEZE; @@ -3250,8 +3250,8 @@ void Q3_SetICARUSFreeze( int entID, const char *name, qboolean freeze ) /* ============ Q3_SetViewEntity - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *name ============ @@ -3274,7 +3274,7 @@ void Q3_SetViewEntity(int entID, const char *name) Q3_DebugPrint( WL_ERROR, "Q3_SetViewEntity: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetViewEntity: '%s' is not a player!\n", self->targetname ); @@ -3286,7 +3286,7 @@ void Q3_SetViewEntity(int entID, const char *name) G_ClearViewEntity( self ); return; } - + if ( viewtarget == NULL ) { Q3_DebugPrint( WL_WARNING, "Q3_SetViewEntity: can't find ViewEntity: '%s'\n", name ); @@ -3298,9 +3298,9 @@ void Q3_SetViewEntity(int entID, const char *name) /* ============ -Q3_SetWeapon - Description : - Return type : static void +Q3_SetWeapon + Description : + Return type : static void Argument : int entID Argument : const char *wp_name ============ @@ -3319,7 +3319,7 @@ static void Q3_SetWeapon (int entID, const char *wp_name) Q3_DebugPrint( WL_WARNING, "Q3_SetWeapon: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetWeapon: '%s' is not a player/NPC!\n", self->targetname ); @@ -3403,9 +3403,9 @@ static void Q3_SetWeapon (int entID, const char *wp_name) /* ============ -Q3_SetItem - Description : - Return type : static void +Q3_SetItem + Description : + Return type : static void Argument : int entID Argument : const char *wp_name ============ @@ -3420,7 +3420,7 @@ static void Q3_SetItem (int entID, const char *item_name) Q3_DebugPrint( WL_WARNING, "Q3_SetWeapon: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetWeapon: '%s' is not a player/NPC!\n", self->targetname ); @@ -3429,7 +3429,7 @@ static void Q3_SetItem (int entID, const char *item_name) inv = GetIDForString( INVTable, item_name ); - + gitem_t *item = FindItemForInventory(inv); RegisterItem( item ); //make sure the item is cached in case this runs at startup @@ -3442,7 +3442,7 @@ static void Q3_SetItem (int entID, const char *item_name) { self->client->ps.inventory[inv] = 1; return; - } + } // else Bacta, seeker, sentry if( self->client->ps.inventory[inv] < 5 ) { @@ -3454,9 +3454,9 @@ static void Q3_SetItem (int entID, const char *item_name) /* ============ -Q3_SetWalkSpeed - Description : - Return type : static void +Q3_SetWalkSpeed + Description : + Return type : static void Argument : int entID Argument : int int_data ============ @@ -3470,7 +3470,7 @@ static void Q3_SetWalkSpeed (int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetWalkSpeed: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetWalkSpeed: '%s' is not an NPC!\n", self->targetname ); @@ -3488,9 +3488,9 @@ static void Q3_SetWalkSpeed (int entID, int int_data) /* ============ -Q3_SetRunSpeed - Description : - Return type : static void +Q3_SetRunSpeed + Description : + Return type : static void Argument : int entID Argument : int int_data ============ @@ -3504,7 +3504,7 @@ static void Q3_SetRunSpeed (int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetRunSpeed: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetRunSpeed: '%s' is not an NPC!\n", self->targetname ); @@ -3522,9 +3522,9 @@ static void Q3_SetRunSpeed (int entID, int int_data) /* ============ -Q3_SetYawSpeed - Description : - Return type : static void +Q3_SetYawSpeed + Description : + Return type : static void Argument : int entID Argument : float float_data ============ @@ -3538,7 +3538,7 @@ static void Q3_SetYawSpeed (int entID, float float_data) Q3_DebugPrint( WL_WARNING, "Q3_SetYawSpeed: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetYawSpeed: '%s' is not an NPC!\n", self->targetname ); @@ -3552,8 +3552,8 @@ static void Q3_SetYawSpeed (int entID, float float_data) /* ============ Q3_SetAggression - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int int_data ============ @@ -3568,7 +3568,7 @@ static void Q3_SetAggression(int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetAggression: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetAggression: '%s' is not an NPC!\n", self->targetname ); @@ -3585,8 +3585,8 @@ static void Q3_SetAggression(int entID, int int_data) /* ============ Q3_SetAim - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int int_data ============ @@ -3600,7 +3600,7 @@ static void Q3_SetAim(int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetAim: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetAim: '%s' is not an NPC!\n", self->targetname ); @@ -3617,8 +3617,8 @@ static void Q3_SetAim(int entID, int int_data) /* ============ Q3_SetFriction - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int int_data ============ @@ -3632,7 +3632,7 @@ static void Q3_SetFriction(int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetFriction: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetFriction: '%s' is not an NPC/player!\n", self->targetname ); @@ -3646,8 +3646,8 @@ static void Q3_SetFriction(int entID, int int_data) /* ============ Q3_SetGravity - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float float_data ============ @@ -3661,7 +3661,7 @@ static void Q3_SetGravity(int entID, float float_data) Q3_DebugPrint( WL_WARNING, "Q3_SetGravity: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetGravity: '%s' is not an NPC/player!\n", self->targetname ); @@ -3677,8 +3677,8 @@ static void Q3_SetGravity(int entID, float float_data) /* ============ Q3_SetWait - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float float_data ============ @@ -3692,7 +3692,7 @@ static void Q3_SetWait(int entID, float float_data) Q3_DebugPrint( WL_WARNING, "Q3_SetWait: invalid entID %d\n", entID); return; } - + self->wait = float_data; } @@ -3706,7 +3706,7 @@ static void Q3_SetShotSpacing(int entID, int int_data) Q3_DebugPrint( WL_WARNING, "Q3_SetShotSpacing: invalid entID %d\n", entID); return; } - + if ( !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetShotSpacing: '%s' is not an NPC!\n", self->targetname ); @@ -3720,8 +3720,8 @@ static void Q3_SetShotSpacing(int entID, int int_data) /* ============ Q3_SetFollowDist - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float float_data ============ @@ -3735,7 +3735,7 @@ static void Q3_SetFollowDist(int entID, float float_data) Q3_DebugPrint( WL_WARNING, "Q3_SetFollowDist: invalid entID %d\n", entID); return; } - + if ( !self->client || !self->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetFollowDist: '%s' is not an NPC!\n", self->targetname ); @@ -3749,8 +3749,8 @@ static void Q3_SetFollowDist(int entID, float float_data) /* ============ Q3_SetScale - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : float float_data ============ @@ -3764,7 +3764,7 @@ static void Q3_SetScale(int entID, float float_data) Q3_DebugPrint( WL_WARNING, "Q3_SetScale: invalid entID %d\n", entID); return; } - + self->s.scale = float_data; } @@ -3772,8 +3772,8 @@ static void Q3_SetScale(int entID, float float_data) /* ============ Q3_SetCount - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *data ============ @@ -3789,7 +3789,7 @@ static void Q3_SetCount(int entID, const char *data) Q3_DebugPrint( WL_WARNING, "Q3_SetCount: invalid entID %d\n", entID); return; } - + if ( (val = Q3_CheckStringCounterIncrement( data )) ) { self->count += (int)(val); @@ -3803,9 +3803,9 @@ static void Q3_SetCount(int entID, const char *data) /* ============ -Q3_SetSquadName - Description : - Return type : static void +Q3_SetSquadName + Description : + Return type : static void Argument : int entID Argument : const char *squadname ============ @@ -3820,7 +3820,7 @@ static void Q3_SetSquadName (int entID, const char *squadname) Q3_DebugPrint( WL_WARNING, "Q3_SetSquadName: invalid entID %d\n", entID); return; } - + if ( !self->client ) { Q3_DebugPrint( WL_ERROR, "Q3_SetSquadName: '%s' is not an NPC/player!\n", self->targetname ); @@ -3840,9 +3840,9 @@ static void Q3_SetSquadName (int entID, const char *squadname) /* ============ -Q3_SetTargetName - Description : - Return type : static void +Q3_SetTargetName + Description : + Return type : static void Argument : int entID Argument : const char *targetname ============ @@ -3877,9 +3877,9 @@ static void Q3_SetTargetName (int entID, const char *targetname) /* ============ -Q3_SetTarget - Description : - Return type : static void +Q3_SetTarget + Description : + Return type : static void Argument : int entID Argument : const char *target ============ @@ -3907,8 +3907,8 @@ static void Q3_SetTarget (int entID, const char *target) /* ============ Q3_SetTarget2 - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : const char *target ============ @@ -3934,9 +3934,9 @@ static void Q3_SetTarget2 (int entID, const char *target2) } /* ============ -Q3_SetRemoveTarget - Description : - Return type : static void +Q3_SetRemoveTarget + Description : + Return type : static void Argument : int entID Argument : const char *target ============ @@ -3970,9 +3970,9 @@ static void Q3_SetRemoveTarget (int entID, const char *target) /* ============ -Q3_SetPainTarget - Description : - Return type : void +Q3_SetPainTarget + Description : + Return type : void Argument : int entID Argument : const char *targetname ============ @@ -3999,9 +3999,9 @@ static void Q3_SetPainTarget (int entID, const char *targetname) /* ============ -Q3_SetFullName - Description : - Return type : static void +Q3_SetFullName + Description : + Return type : static void Argument : int entID Argument : const char *fullName ============ @@ -4098,8 +4098,8 @@ static void Q3_SetForcePowerLevel ( int entID, int forcePower, int forceLevel ) /* ============ Q3_SetParm - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : int parmNum Argument : const char *parmValue @@ -4165,13 +4165,13 @@ static void Q3_SetCaptureGoal( int entID, const char *name ) Q3_DebugPrint( WL_WARNING, "Q3_SetCaptureGoal: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetCaptureGoal: '%s' is not an NPC!\n", ent->targetname ); return; } - + //FIXME: Exception handle here if (goal == NULL) { @@ -4207,7 +4207,7 @@ static void Q3_SetEvent( int entID, const char *event_name ) Q3_DebugPrint( WL_WARNING, "Q3_SetEvent: invalid entID %d\n", entID); return; } - + event = GetIDForString( eventTable, event_name ); switch( event ) { @@ -4247,7 +4247,7 @@ Uses an entity static void Q3_Use( int entID, const char *target ) { gentity_t *ent = &g_entities[entID]; - + if ( !ent ) { Q3_DebugPrint( WL_WARNING, "Q3_Use: invalid entID %d\n", entID); @@ -4354,7 +4354,7 @@ static qboolean Q3_SetBehaviorSet( int entID, int toSet, const char *scriptname) { // gi.TagFree( ent->behaviorSet[bSet] ); } - + ent->behaviorSet[bSet] = G_NewString( (char *) scriptname ); //FIXME: This really isn't good... } @@ -4384,7 +4384,7 @@ static void Q3_SetDelayScriptTime(int entID, int delayTime) ent->delayScriptTime = level.time + delayTime; } - + /* ============ Q3_SetIgnorePain @@ -4401,7 +4401,7 @@ static void Q3_SetIgnorePain( int entID, qboolean data) Q3_DebugPrint( WL_WARNING, "Q3_SetIgnorePain: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetIgnorePain: '%s' is not an NPC!\n", ent->targetname ); @@ -4427,7 +4427,7 @@ static void Q3_SetIgnoreEnemies( int entID, qboolean data) Q3_DebugPrint( WL_WARNING, "Q3_SetIgnoreEnemies: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetIgnoreEnemies: '%s' is not an NPC!\n", ent->targetname ); @@ -4460,7 +4460,7 @@ static void Q3_SetIgnoreAlerts( int entID, qboolean data) Q3_DebugPrint( WL_WARNING, "Q3_SetIgnoreAlerts: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetIgnoreAlerts: '%s' is not an NPC!\n", ent->targetname ); @@ -4544,7 +4544,7 @@ static void Q3_SetDontFire( int entID, qboolean add) Q3_DebugPrint( WL_WARNING, "Q3_SetDontFire: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetDontFire: '%s' is not an NPC!\n", ent->targetname ); @@ -4577,7 +4577,7 @@ static void Q3_SetFireWeapon(int entID, qboolean add) Q3_DebugPrint( WL_WARNING, "Q3_FireWeapon: invalid entID %d\n", entID); return; } - + if ( !ent->NPC ) { Q3_DebugPrint( WL_ERROR, "Q3_SetFireWeapon: '%s' is not an NPC!\n", ent->targetname ); @@ -4611,7 +4611,7 @@ static void Q3_SetInactive(int entID, qboolean add) Q3_DebugPrint( WL_WARNING, "Q3_SetInactive: invalid entID %d\n", entID); return; } - + if(add) { ent->svFlags |= SVF_INACTIVE; @@ -4638,7 +4638,7 @@ static void Q3_SetFuncUsableVisible(int entID, qboolean visible ) Q3_DebugPrint( WL_WARNING, "Q3_SetFuncUsableVisible: invalid entID %d\n", entID); return; } - + // Yeah, I know that this doesn't even do half of what the func_usable use code does, but if I've got two things on top of each other...and only // one is visible at a time....and neither can ever be used......and finally, the shader on it has the shader_anim stuff going on....It doesn't seem // like I can easily use the other version without nasty side effects. @@ -4676,7 +4676,7 @@ static void Q3_SetLockedEnemy ( int entID, qboolean locked) Q3_DebugPrint( WL_ERROR, "Q3_SetLockedEnemy: '%s' is not an NPC!\n", ent->targetname ); return; } - + //FIXME: make an NPCAI_FLAG if(locked) { @@ -4707,7 +4707,7 @@ static void Q3_SetCinematicSkipScript( char *scriptname ) { Q_strncpyz(cinematicSkipScript,scriptname,sizeof(cinematicSkipScript)); } - + } /* @@ -4879,7 +4879,7 @@ static void Q3_SetForcedMarch( int entID, qboolean add) ============ Q3_SetChaseEnemies -indicates whether the npc should chase after an enemy +indicates whether the npc should chase after an enemy ============ */ static void Q3_SetChaseEnemies( int entID, qboolean add) @@ -5423,7 +5423,7 @@ static void Q3_SetInvincible( int entID, qboolean invincible) } return; } - + if ( invincible ) { ent->flags |= FL_GODMODE; @@ -5436,8 +5436,8 @@ static void Q3_SetInvincible( int entID, qboolean invincible) /* ============ Q3_SetForceInvincible - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : qboolean forceInv ============ @@ -5451,7 +5451,7 @@ static void Q3_SetForceInvincible( int entID, qboolean forceInv ) Q3_DebugPrint( WL_WARNING, "Q3_SetForceInvincible: entID %d not a client\n", entID); return; } - + Q3_SetInvincible( entID, forceInv ); if ( forceInv ) { @@ -5499,8 +5499,8 @@ static void Q3_SetNoAvoid( int entID, qboolean noAvoid) /* ============ SolidifyOwner - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *self ============ */ @@ -5542,7 +5542,7 @@ Q3_SetSolid static qboolean Q3_SetSolid( int entID, qboolean solid) { gentity_t *ent = &g_entities[entID]; - + if ( !ent ) { Q3_DebugPrint( WL_WARNING, "Q3_SetSolid: invalid entID %d\n", entID); @@ -5561,7 +5561,7 @@ static qboolean Q3_SetSolid( int entID, qboolean solid) solidifier->e_ThinkFunc = thinkF_SolidifyOwner; solidifier->nextthink = level.time + FRAMETIME; - + ent->contents = oldContents; return qfalse; } @@ -5713,7 +5713,7 @@ static void Q3_SetLockAngle( int entID, const char *lockAngle) { ent->client->renderInfo.renderFlags |= RF_LOCKEDANGLE; - + if(Q_stricmp("auto", lockAngle) == 0) {//use current yaw if( ent->NPC ) // I need this to work on NPCs, so their locked value @@ -5812,7 +5812,7 @@ static void Q3_AddRHandModel( int entID, char *addModel) if ( ent->cinematicModel != -1 ) { // attach it to the hand - gi.G2API_AttachG2Model(&ent->ghoul2[ent->cinematicModel], &ent->ghoul2[ent->playerModel], + gi.G2API_AttachG2Model(&ent->ghoul2[ent->cinematicModel], &ent->ghoul2[ent->playerModel], ent->handRBolt, ent->playerModel); } } @@ -5830,7 +5830,7 @@ static void Q3_AddLHandModel( int entID, char *addModel) if ( ent->cinematicModel != -1 ) { // attach it to the hand - gi.G2API_AttachG2Model(&ent->ghoul2[ent->cinematicModel], &ent->ghoul2[ent->playerModel], + gi.G2API_AttachG2Model(&ent->ghoul2[ent->cinematicModel], &ent->ghoul2[ent->playerModel], ent->handLBolt, ent->playerModel); } } @@ -5911,7 +5911,7 @@ static void Q3_Face( int entID,int expression, float holdtime) Q3_DebugPrint( WL_ERROR, "Q3_Face: '%s' is not an NPC/player!\n", ent->targetname ); return; } - + //FIXME: change to milliseconds to be consistant! holdtime *= 1000; @@ -5963,8 +5963,8 @@ static void Q3_Face( int entID,int expression, float holdtime) /* ============ Q3_SetPlayerUsable - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean usable ============ @@ -5992,8 +5992,8 @@ static void Q3_SetPlayerUsable( int entID, qboolean usable ) /* ============ Q3_SetDisableShaderAnims - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int disabled ============ @@ -6021,8 +6021,8 @@ static void Q3_SetDisableShaderAnims( int entID, int disabled ) /* ============ Q3_SetShaderAnim - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int disabled ============ @@ -6050,8 +6050,8 @@ static void Q3_SetShaderAnim( int entID, int disabled ) /* ============ Q3_SetStartFrame - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int startFrame ============ @@ -6083,8 +6083,8 @@ static void Q3_SetStartFrame( int entID, int startFrame ) /* ============ Q3_SetEndFrame - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int endFrame ============ @@ -6114,8 +6114,8 @@ static void Q3_SetEndFrame( int entID, int endFrame ) /* ============ Q3_SetAnimFrame - Description : - Return type : static void + Description : + Return type : static void Argument : int entID Argument : int startFrame ============ @@ -6185,8 +6185,8 @@ void InflateOwner( gentity_t *self ) /* ============ Q3_SetLoopAnim - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean loopAnim ============ @@ -6214,8 +6214,8 @@ static void Q3_SetLoopAnim( int entID, qboolean loopAnim ) /* ============ Q3_SetShields - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean shields ============ @@ -6249,8 +6249,8 @@ static void Q3_SetShields( int entID, qboolean shields ) /* ============ Q3_SetSaberActive - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean shields ============ @@ -6283,8 +6283,8 @@ static void Q3_SetSaberActive( int entID, qboolean active ) /* ============ Q3_SetNoKnockback - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean noKnockback ============ @@ -6312,8 +6312,8 @@ static void Q3_SetNoKnockback( int entID, qboolean noKnockback ) /* ============ Q3_SetCleanDamagingEnts - Description : - Return type : void + Description : + Return type : void ============ */ static void Q3_SetCleanDamagingEnts( void ) @@ -6354,8 +6354,8 @@ static void Q3_SetCleanDamagingEnts( void ) /* ============ Q3_SetInterface - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : const char *data ============ @@ -6368,8 +6368,8 @@ static void Q3_SetInterface( int entID, const char *data ) /* ============ Q3_SetLocation - Description : - Return type : qboolean + Description : + Return type : qboolean Argument : int entID Argument : const char *location ============ @@ -6378,7 +6378,7 @@ static qboolean Q3_SetLocation( int entID, const char *location ) { gentity_t *ent = &g_entities[entID]; char *currentLoc; - + if ( !ent ) { return qtrue; @@ -6397,8 +6397,8 @@ static qboolean Q3_SetLocation( int entID, const char *location ) /* ============ Q3_SetPlayerLocked - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean locked ============ @@ -6418,8 +6418,8 @@ static void Q3_SetPlayerLocked( int entID, qboolean locked ) /* ============ Q3_SetLockPlayerWeapons - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean locked ============ @@ -6434,15 +6434,15 @@ static void Q3_SetLockPlayerWeapons( int entID, qboolean locked ) { ent->flags |= FL_LOCK_PLAYER_WEAPONS; } - + } /* ============ Q3_SetNoImpactDamage - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : qboolean locked ============ @@ -6457,7 +6457,7 @@ static void Q3_SetNoImpactDamage( int entID, qboolean noImp ) { ent->flags |= FL_NO_IMPACT_DMG; } - + } extern void CG_CameraAutoAim( const char *name ); @@ -6466,8 +6466,8 @@ extern void CG_CameraAutoTrack( const char *name ); /* ============ Q3_SetVar - Description : - Return type : static void + Description : + Return type : static void Argument : int taskID Argument : int entID Argument : const char *type_name @@ -6480,7 +6480,7 @@ void Q3_SetVar( int taskID, int entID, const char *type_name, const char *data ) float float_data; float val = 0.0f; - + if ( vret != VTYPE_NONE ) { switch ( vret ) @@ -6518,8 +6518,8 @@ void Q3_SetVar( int taskID, int entID, const char *type_name, const char *data ) /* ============ Q3_Set - Description : - Return type : void + Description : + Return type : void Argument : int taskID Argument : int entID Argument : const char *type_name @@ -6580,7 +6580,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da float_data = atof((char *) data); Q3_SetVelocity( entID, 0, float_data); break; - + case SET_YVELOCITY: float_data = atof((char *) data); Q3_SetVelocity( entID, 1, float_data); @@ -6659,7 +6659,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da } } break; - + case SET_ANIM_HOLDTIME_LOWER: int_data = atoi((char *) data); Q3_SetAnimHoldTime( entID, int_data, qtrue ); @@ -6862,14 +6862,14 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da else if(!Q_stricmp("false", ((char *)data))) Q3_SetIgnoreAlerts( entID, qfalse); break; - + case SET_DONTSHOOT: if(!Q_stricmp("true", ((char *)data))) Q3_SetDontShoot( entID, qtrue); else if(!Q_stricmp("false", ((char *)data))) Q3_SetDontShoot( entID, qfalse); break; - + case SET_DONTFIRE: if(!Q_stricmp("true", ((char *)data))) Q3_SetDontFire( entID, qtrue); @@ -6913,17 +6913,17 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da float_data = atof((char *) data); Q3_SetVisrange( entID, float_data ); break; - + case SET_EARSHOT: float_data = atof((char *) data); Q3_SetEarshot( entID, float_data ); break; - + case SET_VIGILANCE: float_data = atof((char *) data); Q3_SetVigilance( entID, float_data ); break; - + case SET_VFOV: int_data = atoi((char *) data); Q3_SetVFOV( entID, int_data ); @@ -6945,7 +6945,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da case SET_TARGET2: Q3_SetTarget2( entID, (char *) data ); break; - + case SET_LOCATION: if ( !Q3_SetLocation( entID, (char *) data ) ) { @@ -7026,128 +7026,128 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da case SET_WALKING: if(!Q_stricmp("true", ((char *)data))) - Q3_SetWalking( entID, qtrue); + Q3_SetWalking( entID, qtrue); else - Q3_SetWalking( entID, qfalse); + Q3_SetWalking( entID, qfalse); break; case SET_RUNNING: if(!Q_stricmp("true", ((char *)data))) - Q3_SetRunning( entID, qtrue); + Q3_SetRunning( entID, qtrue); else - Q3_SetRunning( entID, qfalse); + Q3_SetRunning( entID, qfalse); break; case SET_CHASE_ENEMIES: if(!Q_stricmp("true", ((char *)data))) - Q3_SetChaseEnemies( entID, qtrue); + Q3_SetChaseEnemies( entID, qtrue); else - Q3_SetChaseEnemies( entID, qfalse); + Q3_SetChaseEnemies( entID, qfalse); break; case SET_LOOK_FOR_ENEMIES: if(!Q_stricmp("true", ((char *)data))) - Q3_SetLookForEnemies( entID, qtrue); + Q3_SetLookForEnemies( entID, qtrue); else - Q3_SetLookForEnemies( entID, qfalse); + Q3_SetLookForEnemies( entID, qfalse); break; case SET_FACE_MOVE_DIR: if(!Q_stricmp("true", ((char *)data))) - Q3_SetFaceMoveDir( entID, qtrue); + Q3_SetFaceMoveDir( entID, qtrue); else - Q3_SetFaceMoveDir( entID, qfalse); + Q3_SetFaceMoveDir( entID, qfalse); break; case SET_ALT_FIRE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetAltFire( entID, qtrue); + Q3_SetAltFire( entID, qtrue); else - Q3_SetAltFire( entID, qfalse); + Q3_SetAltFire( entID, qfalse); break; case SET_DONT_FLEE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetDontFlee( entID, qtrue); + Q3_SetDontFlee( entID, qtrue); else - Q3_SetDontFlee( entID, qfalse); + Q3_SetDontFlee( entID, qfalse); break; case SET_FORCED_MARCH: if(!Q_stricmp("true", ((char *)data))) - Q3_SetForcedMarch( entID, qtrue); + Q3_SetForcedMarch( entID, qtrue); else - Q3_SetForcedMarch( entID, qfalse); + Q3_SetForcedMarch( entID, qfalse); break; case SET_NO_RESPONSE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetNoResponse( entID, qtrue); + Q3_SetNoResponse( entID, qtrue); else - Q3_SetNoResponse( entID, qfalse); + Q3_SetNoResponse( entID, qfalse); break; case SET_NO_COMBAT_TALK: if(!Q_stricmp("true", ((char *)data))) - Q3_SetCombatTalk( entID, qtrue); + Q3_SetCombatTalk( entID, qtrue); else - Q3_SetCombatTalk( entID, qfalse); + Q3_SetCombatTalk( entID, qfalse); break; case SET_NO_ALERT_TALK: if(!Q_stricmp("true", ((char *)data))) - Q3_SetAlertTalk( entID, qtrue); + Q3_SetAlertTalk( entID, qtrue); else - Q3_SetAlertTalk( entID, qfalse); + Q3_SetAlertTalk( entID, qfalse); break; case SET_USE_CP_NEAREST: if(!Q_stricmp("true", ((char *)data))) - Q3_SetUseCpNearest( entID, qtrue); + Q3_SetUseCpNearest( entID, qtrue); else - Q3_SetUseCpNearest( entID, qfalse); + Q3_SetUseCpNearest( entID, qfalse); break; case SET_NO_FORCE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetNoForce( entID, qtrue); + Q3_SetNoForce( entID, qtrue); else - Q3_SetNoForce( entID, qfalse); + Q3_SetNoForce( entID, qfalse); break; case SET_NO_ACROBATICS: if(!Q_stricmp("true", ((char *)data))) - Q3_SetNoAcrobatics( entID, qtrue); + Q3_SetNoAcrobatics( entID, qtrue); else - Q3_SetNoAcrobatics( entID, qfalse); + Q3_SetNoAcrobatics( entID, qfalse); break; case SET_USE_SUBTITLES: if(!Q_stricmp("true", ((char *)data))) - Q3_SetUseSubtitles( entID, qtrue); + Q3_SetUseSubtitles( entID, qtrue); else - Q3_SetUseSubtitles( entID, qfalse); + Q3_SetUseSubtitles( entID, qfalse); break; case SET_NO_FALLTODEATH: if(!Q_stricmp("true", ((char *)data))) - Q3_SetNoFallToDeath( entID, qtrue); + Q3_SetNoFallToDeath( entID, qtrue); else - Q3_SetNoFallToDeath( entID, qfalse); + Q3_SetNoFallToDeath( entID, qfalse); break; case SET_DISMEMBERABLE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetDismemberable( entID, qtrue); + Q3_SetDismemberable( entID, qtrue); else - Q3_SetDismemberable( entID, qfalse); + Q3_SetDismemberable( entID, qfalse); break; case SET_MORELIGHT: if(!Q_stricmp("true", ((char *)data))) - Q3_SetMoreLight( entID, qtrue); + Q3_SetMoreLight( entID, qtrue); else - Q3_SetMoreLight( entID, qfalse); + Q3_SetMoreLight( entID, qfalse); break; @@ -7161,23 +7161,23 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da case SET_UNDYING: if(!Q_stricmp("true", ((char *)data))) - Q3_SetUndying( entID, qtrue); + Q3_SetUndying( entID, qtrue); else - Q3_SetUndying( entID, qfalse); + Q3_SetUndying( entID, qfalse); break; case SET_INVINCIBLE: if(!Q_stricmp("true", ((char *)data))) - Q3_SetInvincible( entID, qtrue); + Q3_SetInvincible( entID, qtrue); else - Q3_SetInvincible( entID, qfalse); + Q3_SetInvincible( entID, qfalse); break; case SET_NOAVOID: if(!Q_stricmp("true", ((char *)data))) - Q3_SetNoAvoid( entID, qtrue); + Q3_SetNoAvoid( entID, qtrue); else - Q3_SetNoAvoid( entID, qfalse); + Q3_SetNoAvoid( entID, qfalse); break; case SET_SOLID: @@ -7229,7 +7229,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da else Q3_SetPlayerLocked( entID, qfalse ); break; - + case SET_LOCK_PLAYER_WEAPONS: if( !Q_stricmp("true", ((char *)data)) ) Q3_SetLockPlayerWeapons( entID, qtrue ); @@ -7246,18 +7246,18 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da case SET_FORWARDMOVE: int_data = atoi((char *) data); - Q3_SetForwardMove( entID, int_data); + Q3_SetForwardMove( entID, int_data); break; case SET_RIGHTMOVE: int_data = atoi((char *) data); - Q3_SetRightMove( entID, int_data); + Q3_SetRightMove( entID, int_data); break; case SET_LOCKYAW: - Q3_SetLockAngle( entID, data); + Q3_SetLockAngle( entID, data); break; - + case SET_CAMERA_GROUP: Q3_CameraGroup(entID, (char *)data); break; @@ -7302,21 +7302,21 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da break; case SET_SCROLLTEXT: - Q3_ScrollText( (char *)data ); + Q3_ScrollText( (char *)data ); break; case SET_LCARSTEXT: - Q3_LCARSText( (char *)data ); + Q3_LCARSText( (char *)data ); break; case SET_CAPTIONTEXTCOLOR: - Q3_SetCaptionTextColor ( (char *)data ); + Q3_SetCaptionTextColor ( (char *)data ); break; case SET_CENTERTEXTCOLOR: - Q3_SetCenterTextColor ( (char *)data ); + Q3_SetCenterTextColor ( (char *)data ); break; case SET_SCROLLTEXTCOLOR: - Q3_SetScrollTextColor ( (char *)data ); + Q3_SetScrollTextColor ( (char *)data ); break; case SET_PLAYER_USABLE: @@ -7334,7 +7334,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da int_data = atoi((char *) data); Q3_SetStartFrame(entID, int_data); break; - + case SET_ENDFRAME: int_data = atoi((char *) data); Q3_SetEndFrame(entID, int_data); @@ -7348,7 +7348,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da Q3_SetAnimFrame(entID, int_data); return; break; - + case SET_LOOP_ANIM: if(!Q_stricmp("true", ((char *)data))) { @@ -7382,7 +7382,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da Q3_SetShields(entID, qfalse); } break; - + case SET_SABERACTIVE: if(!Q_stricmp("true", ((char *)data))) { @@ -7404,7 +7404,7 @@ static void Q3_Set( int taskID, int entID, const char *type_name, const char *da Q3_SetAdjustAreaPortals( entID, qfalse ); } break; - + case SET_DMG_BY_HEAVY_WEAP_ONLY: if(!Q_stricmp("true", ((char *)data))) { @@ -7546,7 +7546,7 @@ extern void LockDoors(gentity_t *const ent); case SET_OBJECTIVE_SHOW: missionInfo_Updated = qtrue; // Activate flashing text - gi.cvar_set("cg_updatedDataPadObjective", "1"); + gi.cvar_set("cg_updatedDataPadObjective", "1"); Q3_SetObjective((const char *) data ,SET_OBJ_SHOW); Q3_SetObjective((const char *) data ,SET_OBJ_PENDING); @@ -7556,7 +7556,7 @@ extern void LockDoors(gentity_t *const ent); break; case SET_OBJECTIVE_SUCCEEDED: missionInfo_Updated = qtrue; // Activate flashing text - gi.cvar_set("cg_updatedDataPadObjective", "1"); + gi.cvar_set("cg_updatedDataPadObjective", "1"); Q3_SetObjective((const char *) data ,SET_OBJ_SUCCEEDED); break; case SET_OBJECTIVE_FAILED: @@ -7574,7 +7574,7 @@ extern void LockDoors(gentity_t *const ent); case SET_MISSIONSTATUSTEXT: Q3_SetStatusText((const char *) data); break; - + case SET_MISSIONSTATUSTIME: int_data = atoi((char *) data); cg.missionStatusDeadTime = level.time + int_data; @@ -7647,7 +7647,7 @@ extern void LockDoors(gentity_t *const ent); int_data = atoi((char *) data); Q3_SetForcePowerLevel( entID, (toSet-SET_FORCE_HEAL_LEVEL), int_data ); break; - + default: //Q3_DebugPrint( WL_ERROR, "Q3_Set: '%s' is not a valid set field\n", type_name ); Q3_SetVar( taskID, entID, type_name, data ); @@ -7662,8 +7662,8 @@ extern void LockDoors(gentity_t *const ent); /* ============ Q3_Kill - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : const char *name ============ @@ -7722,8 +7722,8 @@ static void Q3_Kill( int entID, const char *name ) /* ============ Q3_RemoveEnt - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *victim ============ */ @@ -7769,8 +7769,8 @@ static void Q3_RemoveEnt( gentity_t *victim ) /* ============ Q3_Remove - Description : - Return type : void + Description : + Return type : void Argument : int entID Argument : const char *name ============ @@ -7820,8 +7820,8 @@ static void Q3_Remove( int entID, const char *name ) /* ============ MakeOwnerInvis - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *self ============ */ @@ -7841,8 +7841,8 @@ void MakeOwnerInvis(gentity_t *self) /* ============ MakeOwnerEnergy - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *self ============ */ @@ -7859,8 +7859,8 @@ void MakeOwnerEnergy(gentity_t *self) /* ============ RemoveOwner - Description : - Return type : void + Description : + Return type : void Argument : gentity_t *self ============ */ @@ -7885,8 +7885,8 @@ void RemoveOwner (gentity_t *self) /* ============ Q3_GetFloat - Description : - Return type : int + Description : + Return type : int Argument : int entID Argument : int type Argument : const char *name @@ -7938,7 +7938,7 @@ static int Q3_GetFloat( int entID, int type, const char *name, float *value ) } *value = atof( ent->parms->parm[toGet - SET_PARM1] ); break; - + case SET_COUNT: *value = ent->count; break; @@ -8513,8 +8513,8 @@ static int Q3_GetFloat( int entID, int type, const char *name, float *value ) /* ============ Q3_GetVector - Description : - Return type : int + Description : + Return type : int Argument : int entID Argument : int type Argument : const char *name @@ -8561,7 +8561,7 @@ static int Q3_GetVector( int entID, int type, const char *name, vec3_t value ) case SET_ANGLES: VectorCopy(ent->currentAngles, value); break; - + case SET_TELEPORT_DEST://## %v="0.0 0.0 0.0" # Set origin here as soon as the area is clear Q3_DebugPrint( WL_WARNING, "Q3_GetVector: SET_TELEPORT_DEST not implemented\n" ); return false; @@ -8581,8 +8581,8 @@ static int Q3_GetVector( int entID, int type, const char *name, vec3_t value ) /* ============ Q3_GetString - Description : - Return type : int + Description : + Return type : int Argument : int entID Argument : int type Argument : const char *name @@ -8881,8 +8881,8 @@ static int Q3_GetString( int entID, int type, const char *name, char **value ) /* ============ Q3_Evaluate - Description : - Return type : int + Description : + Return type : int Argument : int p1Type Argument : const char *p1 Argument : int p2Type @@ -9078,7 +9078,7 @@ static int Q3_Evaluate( int p1Type, const char *p1, int p2Type, const char *p2, } break; - + default: Q3_DebugPrint( WL_ERROR, "Q3_Evaluate unknown operator used!\n"); break; @@ -9143,11 +9143,11 @@ void Q3_DebugPrint( int level, const char *format, ... ) case WL_ERROR: Com_Printf ( S_COLOR_RED"ERROR: %s", text ); break; - + case WL_WARNING: Com_Printf ( S_COLOR_YELLOW"WARNING: %s", text ); break; - + case WL_DEBUG: { int entNum; @@ -9202,7 +9202,7 @@ static void Q3_Play( int taskID, int entID, const char *type, const char *name ) // These need to be initialised up front... VectorCopy( ent->currentOrigin, ent->pos1 ); VectorCopy( ent->currentAngles, ent->pos2 ); - + gi.linkentity( ent ); } } @@ -9212,7 +9212,7 @@ static void Q3_Play( int taskID, int entID, const char *type, const char *name ) ============ Interface_Init Description : Inits the interface for the game - Return type : void + Return type : void Argument : interface_export_t *pe ============ */ @@ -9233,7 +9233,7 @@ void Interface_Init( interface_export_t *pe ) pe->I_Lerp2Angles = Q3_Lerp2Angles; pe->I_GetTag = Q3_GetTag; pe->I_Lerp2Start = Q3_Lerp2Start; - pe->I_Lerp2End = Q3_Lerp2End; + pe->I_Lerp2End = Q3_Lerp2End; pe->I_Use = Q3_Use; pe->I_Kill = Q3_Kill; pe->I_Remove = Q3_Remove; diff --git a/codeJK2/game/Q3_Interface.h b/codeJK2/game/Q3_Interface.h index ecff2f7bdb..9420cd94e4 100644 --- a/codeJK2/game/Q3_Interface.h +++ b/codeJK2/game/Q3_Interface.h @@ -47,7 +47,7 @@ typedef enum //# setType_e SET_PARM15,//## %s="" # Set entity parm15 SET_PARM16,//## %s="" # Set entity parm16 - // NOTE!!! If you add any other SET_xxxxxxSCRIPT types, make sure you update the 'case' statements in + // NOTE!!! If you add any other SET_xxxxxxSCRIPT types, make sure you update the 'case' statements in // ICARUS_InterrogateScript() (game/g_ICARUS.cpp), or the script-precacher won't find them. //# #sep Scripts and other file paths @@ -67,7 +67,7 @@ typedef enum //# setType_e SET_FFDEATHSCRIPT,//## %s="NULL" !!"W:\game\base\scripts\!!#*.txt" # Script to run when player kills a teammate SET_MINDTRICKSCRIPT,//## %s="NULL" !!"W:\game\base\scripts\!!#*.txt" # Script to run when player kills a teammate SET_VIDEO_PLAY,//## %s="filename" !!"W:\game\base\video\!!#*.roq" # Play a video (inGame) - SET_CINEMATIC_SKIPSCRIPT, //## %s="filename" !!"W:\game\base\scripts\!!#*.txt" # Script to run when skipping the running cinematic + SET_CINEMATIC_SKIPSCRIPT, //## %s="filename" !!"W:\game\base\scripts\!!#*.txt" # Script to run when skipping the running cinematic //# #sep Standard strings SET_ENEMY,//## %s="NULL" # Set enemy by targetname @@ -109,7 +109,7 @@ typedef enum //# setType_e SET_ORIGIN,//## %v="0.0 0.0 0.0" # Set origin explicitly or with TAG SET_ANGLES,//## %v="0.0 0.0 0.0" # Set angles explicitly or with TAG SET_TELEPORT_DEST,//## %v="0.0 0.0 0.0" # Set origin here as soon as the area is clear - + //# #sep floats SET_XVELOCITY,//## %f="0.0" # Velocity along X axis SET_YVELOCITY,//## %f="0.0" # Velocity along Y axis @@ -264,7 +264,7 @@ typedef enum //# setType_e SET_TACTICAL_HIDE, //## %t="TACTICAL" # Hide tactical info on mission objectives screen SET_OBJECTIVE_CLEARALL, //## # Force all objectives to be hidden /* - SET_OBJECTIVEFOSTER, + SET_OBJECTIVEFOSTER, */ SET_MISSIONSTATUSTEXT, //## %t="STATUSTEXT" # Text to appear in mission status screen SET_MENU_SCREEN,//## %t="MENUSCREENS" # Brings up specified menu screen @@ -276,7 +276,7 @@ typedef enum //# setType_e //# #eol SET_ -} setType_t; +} setType_t; // this enum isn't used directly by the game, it's mainly for BehavEd to scan for... diff --git a/codeJK2/game/Q3_Registers.cpp b/codeJK2/game/Q3_Registers.cpp index f278c09085..3685161a04 100644 --- a/codeJK2/game/Q3_Registers.cpp +++ b/codeJK2/game/Q3_Registers.cpp @@ -87,7 +87,7 @@ void Q3_DeclareVariable( int type, const char *name ) varFloats[ name ] = 0.0f; break; - case TK_STRING: + case TK_STRING: varStrings[ name ] = "NULL"; break; @@ -238,7 +238,7 @@ int Q3_SetFloatVariable( const char *name, float value ) return VTYPE_FLOAT; (*vfi).second = value; - + return true; } @@ -302,7 +302,7 @@ void Q3_VariableSaveFloats( varFloat_m &fmap ) { //Save out the map id int idSize = strlen( ((*vfi).first).c_str() ); - + //Save out the real data saved_game.write_chunk( INT_ID('F', 'I', 'D', 'L'), @@ -342,7 +342,7 @@ void Q3_VariableSaveStrings( varString_m &smap ) { //Save out the map id int idSize = strlen( ((*vsi).first).c_str() ); - + //Save out the real data saved_game.write_chunk( INT_ID('S', 'I', 'D', 'L'), @@ -403,7 +403,7 @@ void Q3_VariableLoadFloats( varFloat_m &fmap ) for ( int i = 0; i < numFloats; i++ ) { int idSize = 0; - + saved_game.read_chunk( INT_ID('F', 'I', 'D', 'L'), idSize); @@ -453,7 +453,7 @@ void Q3_VariableLoadStrings( int type, varString_m &fmap ) for ( int i = 0; i < numFloats; i++ ) { int idSize = 0; - + saved_game.read_chunk( INT_ID('S', 'I', 'D', 'L'), idSize); diff --git a/codeJK2/game/anims.h b/codeJK2/game/anims.h index cb479b89f2..028e71c32a 100644 --- a/codeJK2/game/anims.h +++ b/codeJK2/game/anims.h @@ -39,24 +39,24 @@ typedef enum //# animNumber_e BOTH_DEATH5, //# Fifth Death anim BOTH_DEATH6, //# Sixth Death anim BOTH_DEATH7, //# Seventh Death anim - BOTH_DEATH8, //# - BOTH_DEATH9, //# - BOTH_DEATH10, //# + BOTH_DEATH8, //# + BOTH_DEATH9, //# + BOTH_DEATH10, //# BOTH_DEATH11, //# - BOTH_DEATH12, //# - BOTH_DEATH13, //# - BOTH_DEATH14, //# - BOTH_DEATH15, //# - BOTH_DEATH16, //# - BOTH_DEATH17, //# - BOTH_DEATH18, //# - BOTH_DEATH19, //# - BOTH_DEATH20, //# - BOTH_DEATH21, //# - BOTH_DEATH22, //# - BOTH_DEATH23, //# - BOTH_DEATH24, //# - BOTH_DEATH25, //# + BOTH_DEATH12, //# + BOTH_DEATH13, //# + BOTH_DEATH14, //# + BOTH_DEATH15, //# + BOTH_DEATH16, //# + BOTH_DEATH17, //# + BOTH_DEATH18, //# + BOTH_DEATH19, //# + BOTH_DEATH20, //# + BOTH_DEATH21, //# + BOTH_DEATH22, //# + BOTH_DEATH23, //# + BOTH_DEATH24, //# + BOTH_DEATH25, //# BOTH_DEATHFORWARD1, //# First Death in which they get thrown forward BOTH_DEATHFORWARD2, //# Second Death in which they get thrown forward @@ -88,24 +88,24 @@ typedef enum //# animNumber_e BOTH_DEAD5, //# Fifth Death finished pose BOTH_DEAD6, //# Sixth Death finished pose BOTH_DEAD7, //# Seventh Death finished pose - BOTH_DEAD8, //# - BOTH_DEAD9, //# - BOTH_DEAD10, //# + BOTH_DEAD8, //# + BOTH_DEAD9, //# + BOTH_DEAD10, //# BOTH_DEAD11, //# - BOTH_DEAD12, //# - BOTH_DEAD13, //# - BOTH_DEAD14, //# - BOTH_DEAD15, //# - BOTH_DEAD16, //# - BOTH_DEAD17, //# - BOTH_DEAD18, //# - BOTH_DEAD19, //# - BOTH_DEAD20, //# - BOTH_DEAD21, //# - BOTH_DEAD22, //# - BOTH_DEAD23, //# - BOTH_DEAD24, //# - BOTH_DEAD25, //# + BOTH_DEAD12, //# + BOTH_DEAD13, //# + BOTH_DEAD14, //# + BOTH_DEAD15, //# + BOTH_DEAD16, //# + BOTH_DEAD17, //# + BOTH_DEAD18, //# + BOTH_DEAD19, //# + BOTH_DEAD20, //# + BOTH_DEAD21, //# + BOTH_DEAD22, //# + BOTH_DEAD23, //# + BOTH_DEAD24, //# + BOTH_DEAD25, //# BOTH_DEADFORWARD1, //# First thrown forward death finished pose BOTH_DEADFORWARD2, //# Second thrown forward death finished pose BOTH_DEADBACKWARD1, //# First thrown backward death finished pose @@ -118,7 +118,7 @@ typedef enum //# animNumber_e BOTH_DEADFLOP2, //# React to being shot from Second Death finished pose BOTH_DEADFLOP3, //# React to being shot from Third Death finished pose BOTH_DEADFLOP4, //# React to being shot from Fourth Death finished pose - BOTH_DEADFLOP5, //# React to being shot from Fifth Death finished pose + BOTH_DEADFLOP5, //# React to being shot from Fifth Death finished pose BOTH_DEADFORWARD1_FLOP, //# React to being shot First thrown forward death finished pose BOTH_DEADFORWARD2_FLOP, //# React to being shot Second thrown forward death finished pose BOTH_DEADBACKWARD1_FLOP, //# React to being shot First thrown backward death finished pose @@ -141,17 +141,17 @@ typedef enum //# animNumber_e BOTH_PAIN6, //# Sixth take pain anim - from behind BOTH_PAIN7, //# Seventh take pain anim - from behind BOTH_PAIN8, //# Eigth take pain anim - from behind - BOTH_PAIN9, //# - BOTH_PAIN10, //# - BOTH_PAIN11, //# - BOTH_PAIN12, //# - BOTH_PAIN13, //# - BOTH_PAIN14, //# - BOTH_PAIN15, //# - BOTH_PAIN16, //# - BOTH_PAIN17, //# - BOTH_PAIN18, //# - BOTH_PAIN19, //# + BOTH_PAIN9, //# + BOTH_PAIN10, //# + BOTH_PAIN11, //# + BOTH_PAIN12, //# + BOTH_PAIN13, //# + BOTH_PAIN14, //# + BOTH_PAIN15, //# + BOTH_PAIN16, //# + BOTH_PAIN17, //# + BOTH_PAIN18, //# + BOTH_PAIN19, //# BOTH_PAIN20, //# GETTING SHOCKED //# #sep BOTH_ ATTACKS @@ -682,9 +682,9 @@ typedef enum //# animNumber_e BOTH_STAND5_REELO, //# Reelo in his stand5 position (cin #18) BOTH_STAND1TOSTAND5, //# Transition from stand1 to stand5 BOTH_STAND5TOSTAND1, //# Transition from stand5 to stand1 - BOTH_STAND5TOAIM, //# Transition of Kye aiming his gun at Desann (cin #9) - BOTH_STAND5STARTLEDLOOKLEFT, //# Kyle turning to watch the bridge drop (cin #9) - BOTH_STARTLEDLOOKLEFTTOSTAND5, //# Kyle returning to stand 5 from watching the bridge drop (cin #9) + BOTH_STAND5TOAIM, //# Transition of Kye aiming his gun at Desann (cin #9) + BOTH_STAND5STARTLEDLOOKLEFT, //# Kyle turning to watch the bridge drop (cin #9) + BOTH_STARTLEDLOOKLEFTTOSTAND5, //# Kyle returning to stand 5 from watching the bridge drop (cin #9) BOTH_STAND5TOSTAND8, //# Transition from stand5 to stand8 BOTH_STAND7TOSTAND8, //# Tavion putting hands on back of chair (cin #11) BOTH_STAND8TOSTAND5, //# Transition from stand8 to stand5 @@ -701,11 +701,11 @@ typedef enum //# animNumber_e BOTH_CONSOLE1START, //# typing at a console BOTH_CONSOLE1, //# typing at a console BOTH_CONSOLE1STOP, //# typing at a console - BOTH_CONSOLE2START, //# typing at a console with comm link in hand (cin #5) - BOTH_CONSOLE2, //# typing at a console with comm link in hand (cin #5) - BOTH_CONSOLE2STOP, //# typing at a console with comm link in hand (cin #5) - BOTH_CONSOLE2HOLDCOMSTART, //# lean in to type at console while holding comm link in hand (cin #5) - BOTH_CONSOLE2HOLDCOMSTOP, //# lean away after typing at console while holding comm link in hand (cin #5) + BOTH_CONSOLE2START, //# typing at a console with comm link in hand (cin #5) + BOTH_CONSOLE2, //# typing at a console with comm link in hand (cin #5) + BOTH_CONSOLE2STOP, //# typing at a console with comm link in hand (cin #5) + BOTH_CONSOLE2HOLDCOMSTART, //# lean in to type at console while holding comm link in hand (cin #5) + BOTH_CONSOLE2HOLDCOMSTOP, //# lean away after typing at console while holding comm link in hand (cin #5) BOTH_GUARD_LOOKAROUND1, //# Cradling weapon and looking around BOTH_GUARD_IDLE1, //# Cradling weapon and standing @@ -734,9 +734,9 @@ typedef enum //# animNumber_e BOTH_TALKGESTURE7START, //# Start touches Kyle on shoulder BOTH_TALKGESTURE7, //# Hold touches Kyle on shoulder BOTH_TALKGESTURE7STOP, //# Ending touches Kyle on shoulder - BOTH_TALKGESTURE8START, //# Lando's chin hold - BOTH_TALKGESTURE8, //# Lando's chin hold - BOTH_TALKGESTURE8STOP, //# Lando's chin hold + BOTH_TALKGESTURE8START, //# Lando's chin hold + BOTH_TALKGESTURE8, //# Lando's chin hold + BOTH_TALKGESTURE8STOP, //# Lando's chin hold BOTH_TALKGESTURE9, //# Same as gesture 2 but with the right hand BOTH_TALKGESTURE10, //# Shoulder shrug BOTH_TALKGESTURE11START, //# Arms folded across chest @@ -776,13 +776,13 @@ typedef enum //# animNumber_e BOTH_SITHEADSHAKE, //# Head shake NO from seated position BOTH_SIT2HEADTILTLSTART, //# Head tilt to left from seated position 2 BOTH_SIT2HEADTILTLSTOP, //# Head tilt to left from seated position 2 - + BOTH_REACH1START, //# Monmothma reaching for crystal BOTH_REACH1STOP, //# Monmothma reaching for crystal - BOTH_EXAMINE1START, //# Start Mon Mothma examining crystal - BOTH_EXAMINE1, //# Mon Mothma examining crystal - BOTH_EXAMINE1STOP, //# Stop Mon Mothma examining crystal + BOTH_EXAMINE1START, //# Start Mon Mothma examining crystal + BOTH_EXAMINE1, //# Mon Mothma examining crystal + BOTH_EXAMINE1STOP, //# Stop Mon Mothma examining crystal BOTH_EXAMINE2START, //# Start Kyle tossing crystal BOTH_EXAMINE2, //# Hold Kyle tossing crystal BOTH_EXAMINE2STOP, //# End Kyle tossing crystal @@ -959,7 +959,7 @@ typedef enum //# animNumber_e BOTH_WALKBACK2, //# Walk2 backwards BOTH_RUNBACK1, //# Run1 backwards BOTH_RUNBACK2, //# Run1 backwards - + //# #sep BOTH_ JUMPING BOTH_JUMP1, //# Jump - wind-up and leave ground BOTH_INAIR1, //# In air loop (from jump) @@ -1023,24 +1023,24 @@ typedef enum //# animNumber_e BOTH_DIVE1, //# Dive! BOTH_ENGAGETAUNT, - BOTH_ARIAL_LEFT, //# - BOTH_ARIAL_RIGHT, //# - BOTH_CARTWHEEL_LEFT, //# - BOTH_CARTWHEEL_RIGHT, //# - BOTH_FLIP_LEFT, //# - BOTH_FLIP_BACK1, //# - BOTH_FLIP_BACK2, //# - BOTH_FLIP_BACK3, //# - BOTH_BUTTERFLY_LEFT, //# - BOTH_BUTTERFLY_RIGHT, //# - BOTH_WALL_RUN_RIGHT, //# + BOTH_ARIAL_LEFT, //# + BOTH_ARIAL_RIGHT, //# + BOTH_CARTWHEEL_LEFT, //# + BOTH_CARTWHEEL_RIGHT, //# + BOTH_FLIP_LEFT, //# + BOTH_FLIP_BACK1, //# + BOTH_FLIP_BACK2, //# + BOTH_FLIP_BACK3, //# + BOTH_BUTTERFLY_LEFT, //# + BOTH_BUTTERFLY_RIGHT, //# + BOTH_WALL_RUN_RIGHT, //# BOTH_WALL_RUN_RIGHT_FLIP,//# - BOTH_WALL_RUN_RIGHT_STOP,//# - BOTH_WALL_RUN_LEFT, //# + BOTH_WALL_RUN_RIGHT_STOP,//# + BOTH_WALL_RUN_LEFT, //# BOTH_WALL_RUN_LEFT_FLIP,//# - BOTH_WALL_RUN_LEFT_STOP,//# - BOTH_WALL_FLIP_RIGHT, //# - BOTH_WALL_FLIP_LEFT, //# + BOTH_WALL_RUN_LEFT_STOP,//# + BOTH_WALL_FLIP_RIGHT, //# + BOTH_WALL_FLIP_LEFT, //# BOTH_WALL_FLIP_FWD, //# BOTH_KNOCKDOWN1, //# knocked backwards BOTH_KNOCKDOWN2, //# knocked backwards hard @@ -1127,7 +1127,7 @@ typedef enum //# animNumber_e BOTH_INJURED2, //# Injured pose 2 BOTH_INJURED3, //# Injured pose 3 BOTH_INJURED6, //# Injured pose 6 - BOTH_INJURED6ATTACKSTART, //# Start attack while in injured 6 pose + BOTH_INJURED6ATTACKSTART, //# Start attack while in injured 6 pose BOTH_INJURED6ATTACKSTOP, //# End attack while in injured 6 pose BOTH_INJURED6COMBADGE, //# Hit combadge while in injured 6 pose BOTH_INJURED6POINT, //# Chang points to door while in injured state @@ -1144,7 +1144,7 @@ typedef enum //# animNumber_e BOTH_SLEEP6START, //# Kyle leaning back to sleep (cin 20) BOTH_SLEEP6STOP, //# Kyle waking up and shaking his head (cin 21) BOTH_SLEEP1GETUP, //# alarmed and getting up out of sleep1 pose to stand - BOTH_SLEEP1GETUP2, //# + BOTH_SLEEP1GETUP2, //# BOTH_SLEEP2GETUP, //# alarmed and getting up out of sleep2 pose to stand BOTH_SLEEP3GETUP, //# alarmed and getting up out of sleep3 pose to stand BOTH_SLEEP3DEATH, //# death in chair, from sleep3 idle @@ -1220,7 +1220,7 @@ typedef enum //# animNumber_e BOTH_COCKPIT_CONSOLE1, //# type at controls BOTH_COCKPIT_CONSOLE2, //# type at controls - BOTH_COCKPIT_CONSOLE2_PARTIAL, //# last part of console2 anim (cin #1) used by Jan + BOTH_COCKPIT_CONSOLE2_PARTIAL, //# last part of console2 anim (cin #1) used by Jan BOTH_COCKPIT_HEADNOD, //# nod head yes while sitting BOTH_COCKPIT_HEADSHAKE, //# shake head no while sitting @@ -1234,11 +1234,11 @@ typedef enum //# animNumber_e BOTH_COCKPIT_TALKGESTURE7STOP, //# Lando's supporting hand away from Kyle (cin #21) BOTH_COCKPIT_TALKGESTURE8START, //# Hand to Lando's chin (cin #21) BOTH_COCKPIT_TALKGESTURE8STOP, //# hand away from Lando's chin *cin #21) - BOTH_COCKPIT_TALKGESTURE11START, //# - BOTH_COCKPIT_TALKGESTURE11STOP, //# + BOTH_COCKPIT_TALKGESTURE11START, //# + BOTH_COCKPIT_TALKGESTURE11STOP, //# - BOTH_COCKPIT_SLEEP6START, //# - BOTH_COCKPIT_SLEEP6STOP, //# + BOTH_COCKPIT_SLEEP6START, //# + BOTH_COCKPIT_SLEEP6STOP, //# //================================================= //ANIMS IN WHICH ONLY THE UPPER OBJECTS ARE IN MD3 @@ -1375,10 +1375,10 @@ typedef enum //# animNumber_e FACE_TALK2, //# semi-quiet FACE_TALK3, //# semi-loud FACE_TALK4, //# loud - FACE_ALERT, //# - FACE_SMILE, //# - FACE_FROWN, //# - FACE_DEAD, //# + FACE_ALERT, //# + FACE_SMILE, //# + FACE_FROWN, //# + FACE_DEAD, //# //# #eol MAX_ANIMATIONS, diff --git a/codeJK2/game/b_local.h b/codeJK2/game/b_local.h index 7684ddc1db..d518196572 100644 --- a/codeJK2/game/b_local.h +++ b/codeJK2/game/b_local.h @@ -251,7 +251,7 @@ inline qboolean NPC_ClearLOS( const vec3_t end ) { return G_ClearLOS( NPC, end ); } -inline qboolean NPC_ClearLOS( gentity_t *ent ) +inline qboolean NPC_ClearLOS( gentity_t *ent ) { return G_ClearLOS( NPC, ent ); } diff --git a/codeJK2/game/b_public.h b/codeJK2/game/b_public.h index 6f08c8292b..5816a9e639 100644 --- a/codeJK2/game/b_public.h +++ b/codeJK2/game/b_public.h @@ -40,7 +40,7 @@ along with this program; if not, see . #define NPCAI_LOST 0x00002000 //Can't nav to his goal #define NPCAI_SHIELDS 0x00004000 //Has shields, borg can adapt #define NPCAI_GREET_ALLIES 0x00008000 //Say hi to nearby allies -#define NPCAI_FORM_TELE_NAV 0x00010000 //Tells formation people to use nav info to get to +#define NPCAI_FORM_TELE_NAV 0x00010000 //Tells formation people to use nav info to get to #define NPCAI_ENROUTE_TO_HOMEWP 0x00020000 //Lets us know to run our lostenemyscript when we get to homeWp #define NPCAI_MATCHPLAYERWEAPON 0x00040000 //Match the player's weapon except when it changes during cinematics #define NPCAI_DIE_ON_IMPACT 0x00100000 //Next time you crashland, die! @@ -249,7 +249,7 @@ class gNPC_t int investigateSoundDebounceTime; int greetingDebounceTime;//when we can greet someone next gentity_t *eventOwner; - + //bState-specific fields gentity_t *coverTarg; jumpState_t jumpState; @@ -316,7 +316,7 @@ class gNPC_t int goalRadius; //FIXME: These may be redundant - + /* int weaponTime; //Time until refire is valid int jumpTime; @@ -341,7 +341,7 @@ class gNPC_t gentity_t *watchTarget; //for BS_CINEMATIC, keeps facing this ent int ffireCount; //sigh... you'd think I'd be able to find a way to do this without having to use 3 int fields, but... - int ffireDebounce; + int ffireDebounce; int ffireFadeDebounce; diff --git a/codeJK2/game/bg_pangles.cpp b/codeJK2/game/bg_pangles.cpp index 7fe3aa55fd..2ccad066ae 100644 --- a/codeJK2/game/bg_pangles.cpp +++ b/codeJK2/game/bg_pangles.cpp @@ -47,7 +47,7 @@ void BG_G2SetBoneAngles( centity_t *cent, gentity_t *gent, int boneIndex, const { if (boneIndex!=-1) { - gi.G2API_SetBoneAnglesIndex( ¢->gent->ghoul2[0], boneIndex, angles, flags, up, left, forward, modelList, 0, 0 ); + gi.G2API_SetBoneAnglesIndex( ¢->gent->ghoul2[0], boneIndex, angles, flags, up, left, forward, modelList, 0, 0 ); } } @@ -60,7 +60,7 @@ void PM_ScaleUcmd( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) //clamp the turn rate int maxPitchSpeed = MAX_PITCHSPEED_X_WING;//switch, eventually? Or read from file? int diff = AngleNormalize180(SHORT2ANGLE((cmd->angles[PITCH]+ps->delta_angles[PITCH]))) - floor(ps->viewangles[PITCH]); - + if ( diff > maxPitchSpeed ) { cmd->angles[PITCH] = ANGLE2SHORT( ps->viewangles[PITCH] + maxPitchSpeed ) - ps->delta_angles[PITCH]; @@ -113,7 +113,7 @@ qboolean PM_AdjustAngleForWallRun( gentity_t *ent, usercmd_t *ucmd, qboolean doM if (( ent->client->ps.legsAnim == BOTH_WALL_RUN_RIGHT || ent->client->ps.legsAnim == BOTH_WALL_RUN_LEFT ) && ent->client->ps.legsAnimTimer > 500 ) {//wall-running and not at end of anim //stick to wall, if there is one - vec3_t rt, traceTo, mins = {ent->mins[0],ent->mins[1],0}, maxs = {ent->maxs[0],ent->maxs[1],24}, fwdAngles = {0, ent->client->ps.viewangles[YAW], 0}; + vec3_t rt, traceTo, mins = {ent->mins[0],ent->mins[1],0}, maxs = {ent->maxs[0],ent->maxs[1],24}, fwdAngles = {0, ent->client->ps.viewangles[YAW], 0}; trace_t trace; float dist, yawAdjust; @@ -317,7 +317,7 @@ qboolean PM_AdjustAnglesForBackAttack( gentity_t *ent, usercmd_t *ucmd ) ucmd->angles[PITCH] = ANGLE2SHORT( ent->client->ps.viewangles[PITCH] ) - ent->client->ps.delta_angles[PITCH]; ucmd->angles[YAW] = ANGLE2SHORT( ent->client->ps.viewangles[YAW] ) - ent->client->ps.delta_angles[YAW]; } - else + else {//keep player facing away from their enemy vec3_t enemyBehindDir; VectorSubtract( ent->currentOrigin, ent->enemy->currentOrigin, enemyBehindDir ); @@ -397,7 +397,7 @@ are being updated isntead of a full move //FIXME: Now that they pmove twice per think, they snap-look really fast ================ */ -void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) +void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) { short temp; float pitchMin=-75, pitchMax=75, yawMin=0, yawMax=0; //just to shut up warnings @@ -406,12 +406,12 @@ void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) trace_t trace; qboolean lockedYaw = qfalse; - if ( ps->pm_type == PM_INTERMISSION ) + if ( ps->pm_type == PM_INTERMISSION ) { return; // no view changes at all } - if ( ps->pm_type != PM_SPECTATOR && ps->stats[STAT_HEALTH] <= 0 ) + if ( ps->pm_type != PM_SPECTATOR && ps->stats[STAT_HEALTH] <= 0 ) { return; // no view changes at all } @@ -426,7 +426,7 @@ void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) { pitchMin = 0 - gent->client->renderInfo.headPitchRangeUp - gent->client->renderInfo.torsoPitchRangeUp; pitchMax = gent->client->renderInfo.headPitchRangeDown + gent->client->renderInfo.torsoPitchRangeDown; - + yawMin = 0 - gent->client->renderInfo.headYawRangeLeft - gent->client->renderInfo.torsoYawRangeLeft; yawMax = gent->client->renderInfo.headYawRangeRight + gent->client->renderInfo.torsoYawRangeRight; @@ -450,32 +450,32 @@ void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) const short pitchClampMax = ANGLE2SHORT(pitchMax); // circularly clamp the angles with deltas - for (i=0 ; i<3 ; i++) + for (i=0 ; i<3 ; i++) { temp = cmd->angles[i] + ps->delta_angles[i]; - if ( i == PITCH ) + if ( i == PITCH ) { //FIXME get this limit from the NPCs stats? // don't let the player look up or down more than 90 degrees - if ( temp > pitchClampMax ) + if ( temp > pitchClampMax ) { ps->delta_angles[i] = (pitchClampMax - cmd->angles[i]) & 0xffff; //& clamp to short temp = pitchClampMax; - } - else if ( temp < pitchClampMin ) + } + else if ( temp < pitchClampMin ) { ps->delta_angles[i] = (pitchClampMin - cmd->angles[i]) & 0xffff; //& clamp to short temp = pitchClampMin; } } - if ( i == ROLL && ps->vehicleModel != 0 ) + if ( i == ROLL && ps->vehicleModel != 0 ) { - if ( temp > pitchClampMax ) + if ( temp > pitchClampMax ) { ps->delta_angles[i] = (pitchClampMax - cmd->angles[i]) & 0xffff; temp = pitchClampMax; - } - else if ( temp < pitchClampMin ) + } + else if ( temp < pitchClampMin ) { ps->delta_angles[i] = (pitchClampMin - cmd->angles[i]) & 0xffff; temp = pitchClampMin; @@ -484,14 +484,14 @@ void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, gentity_t *gent ) //FIXME: Are we losing precision here? Is this why it jitters? ps->viewangles[i] = SHORT2ANGLE(temp); - if ( i == YAW && lockedYaw) + if ( i == YAW && lockedYaw) { // don't let the player look left or right more than the clamp, if any - if ( AngleSubtract(ps->viewangles[i], gent->client->renderInfo.lockYaw) > yawMax ) + if ( AngleSubtract(ps->viewangles[i], gent->client->renderInfo.lockYaw) > yawMax ) { ps->viewangles[i] = yawMax; - } - else if ( AngleSubtract(ps->viewangles[i], gent->client->renderInfo.lockYaw) < yawMin ) + } + else if ( AngleSubtract(ps->viewangles[i], gent->client->renderInfo.lockYaw) < yawMin ) { ps->viewangles[i] = yawMin; } diff --git a/codeJK2/game/bg_public.h b/codeJK2/game/bg_public.h index 3a23d2f9aa..64bdfb68d3 100644 --- a/codeJK2/game/bg_public.h +++ b/codeJK2/game/bg_public.h @@ -93,7 +93,7 @@ typedef enum { } pmtype_t; typedef enum { - WEAPON_READY, + WEAPON_READY, WEAPON_RAISING, WEAPON_DROPPING, WEAPON_FIRING, @@ -154,7 +154,7 @@ typedef struct { // callbacks to test the world // these will be different functions during game and cgame - void (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, + void (*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/* = (EG2_Collision)0*/, const int useLod/* = 0 */); int (*pointcontents)( const vec3_t point, int passEntityNum ); } pmove_t; @@ -191,7 +191,7 @@ void PM_SetSaberMove(short newMove); typedef enum { PERS_SCORE, // !!! MUST NOT CHANGE, SERVER AND GAME BOTH REFERENCE !!! PERS_HITS, // total points damage inflicted so damage beeps can sound on change - PERS_TEAM, + PERS_TEAM, PERS_SPAWN_COUNT, // incremented every respawn // PERS_REWARD_COUNT, // incremented for each reward sound PERS_ATTACKER, // clientnum of last damage inflicter @@ -200,7 +200,7 @@ typedef enum { PERS_ACCURACY_SHOTS, // scoreboard - number of player shots PERS_ACCURACY_HITS, // scoreboard - number of player shots that hit an enemy PERS_ENEMIES_KILLED, // scoreboard - number of enemies player killed - PERS_TEAMMATES_KILLED // scoreboard - number of teammates killed + PERS_TEAMMATES_KILLED // scoreboard - number of teammates killed } persEnum_t; @@ -273,7 +273,7 @@ typedef enum { typedef enum { EV_NONE, - + EV_FOOTSTEP, EV_FOOTSTEP_METAL, EV_FOOTSPLASH, @@ -474,7 +474,7 @@ class animation_t #define MAX_RANDOM_ANIMSOUNDS 8 -typedef struct animsounds_s +typedef struct animsounds_s { int keyFrame; //Frame to play sound on int soundIndex[MAX_RANDOM_ANIMSOUNDS]; //sound file to play - FIXME: should be an index, handle random some other way? @@ -558,7 +558,7 @@ typedef enum { //--------------------------------------------------------- // gitem_t->type -typedef enum +typedef enum { IT_BAD, IT_WEAPON, @@ -568,7 +568,7 @@ typedef enum IT_HOLDABLE, IT_BATTERY, IT_HOLOCRON, - + } itemType_t; @@ -599,7 +599,7 @@ extern const int bg_numItems; //============================================================================== /* -typedef struct ginfoitem_s +typedef struct ginfoitem_s { char *infoString;// Text message vec3_t color; // Text color diff --git a/codeJK2/game/channels.h b/codeJK2/game/channels.h index c8aa2c7f67..b64f4b0e41 100644 --- a/codeJK2/game/channels.h +++ b/codeJK2/game/channels.h @@ -24,9 +24,9 @@ typedef enum //# soundChannel_e { CHAN_AUTO, //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # Auto-picks an empty channel to play sound on CHAN_LOCAL, //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # menu sounds, etc - CHAN_WEAPON,//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" + CHAN_WEAPON,//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" CHAN_VOICE, //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Voice sounds cause mouth animation - CHAN_VOICE_ATTEN, //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Causes mouth animation but still use normal sound falloff + CHAN_VOICE_ATTEN, //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Causes mouth animation but still use normal sound falloff CHAN_ITEM, //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" CHAN_BODY, //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" CHAN_AMBIENT,//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # added for ambient sounds diff --git a/codeJK2/game/events.h b/codeJK2/game/events.h index 5d7f7a8f32..1bec0677b2 100644 --- a/codeJK2/game/events.h +++ b/codeJK2/game/events.h @@ -27,6 +27,6 @@ typedef enum //# eventType_e { EV_BAD = 0, -} eventType_t; +} eventType_t; #endif //__EVENTS__ \ No newline at end of file diff --git a/codeJK2/game/fields.h b/codeJK2/game/fields.h index c801467629..de27c1f9e0 100644 --- a/codeJK2/game/fields.h +++ b/codeJK2/game/fields.h @@ -39,17 +39,17 @@ along with this program; if not, see . #define STOFS(x) offsetof(spawn_temp_t, x) #define LLOFS(x) offsetof(level_locals_t, x) #define CLOFS(x) offsetof(gclient_t, x) -#define NPCOFS(x) offsetof(gNPC_t, x) +#define NPCOFS(x) offsetof(gNPC_t, x) // #define strFOFS(x) #x,FOFS(x) #define strSTOFS(x) #x,STOFS(x) -#define strLLOFS(x) #x,LLOFS(x) +#define strLLOFS(x) #x,LLOFS(x) #define strCLOFS(x) #x,CLOFS(x) #define strNPCOFS(x) #x,NPCOFS(x) typedef enum { -// F_INT, +// F_INT, // F_SHORT, // F_FLOAT, F_STRING, // string @@ -65,7 +65,7 @@ typedef enum // F_PLAYERSTATE, - F_BEHAVIORSET, // special scripting string ptr array handler + F_BEHAVIORSET, // special scripting string ptr array handler F_ALERTEVENT, // special handler for alertevent struct in level_locals_t F_AIGROUPS, // some AI grouping stuff of Mike's diff --git a/codeJK2/game/g_ICARUS.cpp b/codeJK2/game/g_ICARUS.cpp index c5fb26dac8..d75076c589 100644 --- a/codeJK2/game/g_ICARUS.cpp +++ b/codeJK2/game/g_ICARUS.cpp @@ -156,11 +156,11 @@ void ICARUS_Shutdown( void ) gentity_t *ent = &g_entities[0];; //Release all ICARUS resources from the entities - for ( int i = 0; i < globals.num_entities; i++, ent++ ) + for ( int i = 0; i < globals.num_entities; i++, ent++ ) { if ( !ent->inuse ) continue; - + ICARUS_FreeEnt( ent ); } @@ -209,7 +209,7 @@ void ICARUS_FreeEnt( gentity_t *ent ) if VALIDSTRING( ent->script_targetname ) { char temp[1024]; - + strncpy( (char *) temp, ent->script_targetname, 1023 ); temp[ 1023 ] = 0; @@ -223,7 +223,7 @@ void ICARUS_FreeEnt( gentity_t *ent ) //Delete the sequencer and the task manager iICARUS->DeleteSequencer( ent->sequencer ); - + //Clean up the pointers ent->sequencer = NULL; ent->taskManager = NULL; @@ -234,7 +234,7 @@ void ICARUS_FreeEnt( gentity_t *ent ) ============== ICARUS_ValidEnt -Determines whether or not an entity needs ICARUS information +Determines whether or not an entity needs ICARUS information ============== */ @@ -271,7 +271,7 @@ Associate the entity's id and name so that it can be referenced later void ICARUS_AssociateEnt( gentity_t *ent ) { char temp[1024]; - + if ( VALIDSTRING( ent->script_targetname ) == false ) return; @@ -306,8 +306,8 @@ bool ICARUS_RegisterScript( const char *name, bool bCalledDuringInterrogate /* = // if ( ei != ICARUS_BufferList.end() ) return (bCalledDuringInterrogate)?false:true; - - sprintf((char *) newname, "%s%s", name, IBI_EXT ); + + sprintf((char *) newname, "%s%s", name, IBI_EXT ); // small update here, if called during interrogate, don't let gi.FS_ReadFile() complain because it can't @@ -315,15 +315,15 @@ bool ICARUS_RegisterScript( const char *name, bool bCalledDuringInterrogate /* = // the ifndef, this just cuts down on internal error reports while testing release mode... // qboolean qbIgnoreFileRead = qfalse; - // + // // NOTENOTE: For the moment I've taken this back out, to avoid doubling the number of fopen()'s per file. -#if 0//#ifndef FINAL_BUILD +#if 0//#ifndef FINAL_BUILD if (bCalledDuringInterrogate) { fileHandle_t file; gi.FS_FOpenFile( newname, &file, FS_READ ); - + if ( file == NULL ) { qbIgnoreFileRead = qtrue; // warn disk code further down not to try FS_ReadFile() @@ -341,7 +341,7 @@ bool ICARUS_RegisterScript( const char *name, bool bCalledDuringInterrogate /* = { // File not found, but keep quiet during interrogate stage, because of stuff like BS_RUN_AND_SHOOT as scriptname // - if (!bCalledDuringInterrogate) + if (!bCalledDuringInterrogate) { Com_Printf(S_COLOR_RED"Could not open file '%s'\n", newname ); } @@ -350,7 +350,7 @@ bool ICARUS_RegisterScript( const char *name, bool bCalledDuringInterrogate /* = pscript = new pscript_t; - pscript->buffer = (char *) gi.Malloc(length, TAG_ICARUS, qfalse); + pscript->buffer = (char *) gi.Malloc(length, TAG_ICARUS, qfalse); memcpy (pscript->buffer, buffer, length); pscript->length = length; @@ -439,7 +439,7 @@ void ICARUS_InterrogateScript( const char *filename ) break; case ID_PLAY: // to cache ROFF files - + sVal1 = (const char *) block.GetMemberData( 0 ); if (!Q_stricmp(sVal1,"PLAY_ROFF")) @@ -447,19 +447,19 @@ void ICARUS_InterrogateScript( const char *filename ) sVal1 = (const char *) block.GetMemberData( 1 ); G_LoadRoff(sVal1); - } + } break; //Run commands case ID_RUN: - + sVal1 = (const char *) block.GetMemberData( 0 ); - + COM_StripExtension( sVal1, (char *) temp, sizeof( temp ) ); ICARUS_InterrogateScript( (const char *) &temp ); - + break; - + case ID_SOUND: sVal1 = (const char *) block.GetMemberData( 1 ); //0 is channel, 1 is filename G_SoundIndex(sVal1); @@ -475,7 +475,7 @@ void ICARUS_InterrogateScript( const char *filename ) { sVal1 = (const char *) block.GetMemberData( 0 ); sVal2 = (const char *) block.GetMemberData( 1 ); - + //Get the id for this set identifier setID = GetIDForString( setTable, sVal1 ); @@ -510,7 +510,7 @@ extern cvar_t *com_buildScript; { fileHandle_t file; char name[MAX_OSPATH]; - + if (strstr(sVal2, "/") == NULL && strstr(sVal2, "\\") == NULL) { Com_sprintf (name, sizeof(name), "video/%s", sVal2); } else { @@ -650,11 +650,11 @@ void Svcmd_ICARUS_f( void ) { g_ICARUSDebug->integer = WL_DEBUG; if ( VALIDSTRING( gi.argv( 2 ) ) ) - { + { gentity_t *ent = G_Find( NULL, FOFS( script_targetname ), gi.argv(2) ); if ( ent == NULL ) - { + { Com_Printf( "Entity \"%s\" not found!\n", gi.argv(2) ); return; } @@ -666,9 +666,9 @@ void Svcmd_ICARUS_f( void ) return; } - + Com_Printf("Logging ICARUS info for all entities\n"); - + return; } } diff --git a/codeJK2/game/g_active.cpp b/codeJK2/game/g_active.cpp index d204f64116..7b4f4cda74 100644 --- a/codeJK2/game/g_active.cpp +++ b/codeJK2/game/g_active.cpp @@ -104,19 +104,19 @@ int G_FindLookItem( gentity_t *self ) VectorCopy( self->currentOrigin, center ); - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { mins[i] = center[i] - radius; maxs[i] = center[i] + radius; } numListedEntities = gi.EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); - + if ( !numListedEntities ) { return ENTITYNUM_NONE; } - for ( e = 0 ; e < numListedEntities ; e++ ) + for ( e = 0 ; e < numListedEntities ; e++ ) { ent = entityList[ e ]; @@ -263,8 +263,8 @@ qboolean G_ValidateLookEnemy( gentity_t *self, gentity_t *enemy ) } if ( !enemy->client || !enemy->NPC ) {//not valid - if ( (enemy->svFlags&SVF_NONNPC_ENEMY) - && enemy->s.weapon == WP_TURRET + if ( (enemy->svFlags&SVF_NONNPC_ENEMY) + && enemy->s.weapon == WP_TURRET && enemy->noDamageTeam != self->client->playerTeam && enemy->health > 0 ) {//a turret @@ -275,7 +275,7 @@ qboolean G_ValidateLookEnemy( gentity_t *self, gentity_t *enemy ) return qfalse; } } - else + else { if ( enemy->client->playerTeam == self->client->playerTeam ) {//on same team @@ -291,7 +291,7 @@ qboolean G_ValidateLookEnemy( gentity_t *self, gentity_t *enemy ) } } - if ( (!InFront( enemy->currentOrigin, self->currentOrigin, self->client->ps.viewangles, 0.0f) || !G_ClearLOS( self, self->client->renderInfo.eyePoint, enemy ) ) + if ( (!InFront( enemy->currentOrigin, self->currentOrigin, self->client->ps.viewangles, 0.0f) || !G_ClearLOS( self, self->client->renderInfo.eyePoint, enemy ) ) && ( DistanceHorizontalSquared( enemy->currentOrigin, self->currentOrigin ) > 65536 || fabs(enemy->currentOrigin[2]-self->currentOrigin[2]) > 384 ) ) {//(not in front or not clear LOS) & greater than 256 away return qfalse; @@ -322,19 +322,19 @@ void G_ChooseLookEnemy( gentity_t *self, usercmd_t *ucmd ) VectorCopy( self->currentOrigin, center ); - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { mins[i] = center[i] - radius; maxs[i] = center[i] + radius; } numListedEntities = gi.EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); - + if ( !numListedEntities ) {//should we clear the enemy? return; } - for ( e = 0 ; e < numListedEntities ; e++ ) + for ( e = 0 ; e < numListedEntities ; e++ ) { ent = entityList[ e ]; @@ -442,14 +442,14 @@ void P_DamageFeedback( gentity_t *player ) { // world damage (falling, slime, etc) uses a special code // to make the blend blob centered instead of positional - if ( client->damage_fromWorld ) + if ( client->damage_fromWorld ) { client->ps.damagePitch = 255; client->ps.damageYaw = 255; client->damage_fromWorld = qfalse; - } - else + } + else { vectoangles( client->damage_from, angles ); client->ps.damagePitch = angles[PITCH]/360.0 * 256; @@ -478,7 +478,7 @@ Check for lava / slime contents and drowning void P_WorldEffects( gentity_t *ent ) { int mouthContents = 0; - if ( ent->client->noclip ) + if ( ent->client->noclip ) { ent->client->airOutTime = level.time + 12000; // don't need air return; @@ -491,14 +491,14 @@ void P_WorldEffects( gentity_t *ent ) { // // check for drowning // - if ( (mouthContents&(CONTENTS_WATER|CONTENTS_SLIME)) ) + if ( (mouthContents&(CONTENTS_WATER|CONTENTS_SLIME)) ) { if ( ent->client->NPC_class == CLASS_SWAMPTROOPER ) {//they have air tanks ent->client->airOutTime = level.time + 12000; // don't need air ent->damage = 2; } - else if ( ent->client->airOutTime < level.time) + else if ( ent->client->airOutTime < level.time) {// if out of air, start drowning // drown! ent->client->airOutTime += 1000; @@ -509,24 +509,24 @@ void P_WorldEffects( gentity_t *ent ) { ent->damage = 15; // play a gurp sound instead of a normal pain sound - if (ent->health <= ent->damage) + if (ent->health <= ent->damage) { G_AddEvent( ent, EV_WATER_DROWN, 0 ); - } + } else { G_AddEvent( ent, Q_irand(EV_WATER_GURP1, EV_WATER_GURP2), 0 ); - } + } // don't play a normal pain sound ent->painDebounceTime = level.time + 200; - G_Damage (ent, NULL, NULL, NULL, NULL, + G_Damage (ent, NULL, NULL, NULL, NULL, ent->damage, DAMAGE_NO_ARMOR, MOD_WATER); } } - } - else + } + else { ent->client->airOutTime = level.time + 12000; ent->damage = 2; @@ -535,18 +535,18 @@ void P_WorldEffects( gentity_t *ent ) { // // check for sizzle damage (move to pmove?) // - if (ent->waterlevel && + if (ent->waterlevel && (ent->watertype&(CONTENTS_LAVA|CONTENTS_SLIME)) ) { if (ent->health > 0 && ent->painDebounceTime < level.time ) { if (ent->watertype & CONTENTS_LAVA) { - G_Damage (ent, NULL, NULL, NULL, NULL, + G_Damage (ent, NULL, NULL, NULL, NULL, 15*ent->waterlevel, 0, MOD_LAVA); } if (ent->watertype & CONTENTS_SLIME) { - G_Damage (ent, NULL, NULL, NULL, NULL, + G_Damage (ent, NULL, NULL, NULL, NULL, 1, 0, MOD_SLIME); } } @@ -595,7 +595,7 @@ void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ) VectorCopy( self->client->ps.velocity, velocity ); my_mass = self->mass; } - else + else { VectorCopy( self->s.pos.trDelta, velocity ); if ( self->s.pos.trType == TR_GRAVITY ) @@ -674,7 +674,7 @@ void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ) if( ( force >= 1 && other->s.number != 0 ) || force >= 10) { - /* + /* dprint("Damage other ("); dprint(loser.classname); dprint("): "); @@ -693,7 +693,7 @@ void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ) else if ( other->takedamage ) { if ( !self->client || !other->s.number || !other->client ) - {//aw, fuck it, clients no longer take impact damage from other clients, unless you're the player + {//aw, fuck it, clients no longer take impact damage from other clients, unless you're the player G_Damage( other, self, self, velocity, self->currentOrigin, force, DAMAGE_NO_ARMOR, MOD_IMPACT ); } else @@ -745,7 +745,7 @@ void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ) if ( magnitude >= 1 ) { //FIXME: Put in a thingtype impact sound function - /* + /* dprint("Damage self ("); dprint(self.classname); dprint("): "); @@ -766,7 +766,7 @@ void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ) } //FIXME: slow my velocity some? - + self->lastImpact = level.time; /* @@ -887,7 +887,7 @@ void G_TouchTriggersLerped( gentity_t *ent ) { if ( touched[i] == qtrue ) { continue;//already touched this move } - if ( ent->client->ps.stats[STAT_HEALTH] <= 0 ) + if ( ent->client->ps.stats[STAT_HEALTH] <= 0 ) { if ( Q_stricmp( "trigger_teleport", hit->classname ) || !(hit->spawnflags&16/*TTSF_DEAD_OK*/) ) {//dead clients can only touch tiogger_teleports that are marked as touchable @@ -1004,7 +1004,7 @@ Find all trigger entities that ent's current position touches. Spectators will only interact with teleporters. ============ */ -void G_MoverTouchPushTriggers( gentity_t *ent, vec3_t oldOrg ) +void G_MoverTouchPushTriggers( gentity_t *ent, vec3_t oldOrg ) { int i, num; float step, stepSize, dist; @@ -1014,7 +1014,7 @@ void G_MoverTouchPushTriggers( gentity_t *ent, vec3_t oldOrg ) const vec3_t range = { 40, 40, 52 }; // non-moving movers don't hit triggers! - if ( !VectorLengthSquared( ent->s.pos.trDelta ) ) + if ( !VectorLengthSquared( ent->s.pos.trDelta ) ) { return; } @@ -1040,7 +1040,7 @@ void G_MoverTouchPushTriggers( gentity_t *ent, vec3_t oldOrg ) VectorAdd( checkSpot, ent->mins, mins ); VectorAdd( checkSpot, ent->maxs, maxs ); - for ( i=0 ; ie_TouchFunc == touchF_NULL ) + if ( hit->e_TouchFunc == touchF_NULL ) { continue; } - if ( !( hit->contents & CONTENTS_TRIGGER ) ) + if ( !( hit->contents & CONTENTS_TRIGGER ) ) { continue; } - if ( !gi.EntityContact( mins, maxs, hit ) ) + if ( !gi.EntityContact( mins, maxs, hit ) ) { continue; } memset( &trace, 0, sizeof(trace) ); - if ( hit->e_TouchFunc != touchF_NULL ) + if ( hit->e_TouchFunc != touchF_NULL ) { GEntity_TouchFunc(hit, ent, &trace); } @@ -1135,30 +1135,30 @@ Returns qfalse if the client is dropped ================= */ qboolean ClientInactivityTimer( gclient_t *client ) { - if ( ! g_inactivity->integer ) + if ( ! g_inactivity->integer ) { // give everyone some time, so if the operator sets g_inactivity during // gameplay, everyone isn't kicked client->inactivityTime = level.time + 60 * 1000; client->inactivityWarning = qfalse; - } - else if ( client->usercmd.forwardmove || - client->usercmd.rightmove || + } + else if ( client->usercmd.forwardmove || + client->usercmd.rightmove || client->usercmd.upmove || (client->usercmd.buttons & BUTTON_ATTACK) || - (client->usercmd.buttons & BUTTON_ALT_ATTACK) ) + (client->usercmd.buttons & BUTTON_ALT_ATTACK) ) { client->inactivityTime = level.time + g_inactivity->integer * 1000; client->inactivityWarning = qfalse; - } - else if ( !client->pers.localClient ) + } + else if ( !client->pers.localClient ) { - if ( level.time > client->inactivityTime ) + if ( level.time > client->inactivityTime ) { gi.DropClient( client - level.clients, "Dropped due to inactivity" ); return qfalse; } - if ( level.time > client->inactivityTime - 10000 && !client->inactivityWarning ) + if ( level.time > client->inactivityTime - 10000 && !client->inactivityWarning ) { client->inactivityWarning = qtrue; gi.SendServerCommand( client - level.clients, "cp \"Ten seconds until inactivity drop!\n\"" ); @@ -1183,7 +1183,7 @@ void ClientTimerActions( gentity_t *ent, int msec ) { client = ent->client; client->timeResidual += msec; - while ( client->timeResidual >= 1000 ) + while ( client->timeResidual >= 1000 ) { client->timeResidual -= 1000; @@ -1260,11 +1260,11 @@ void ClientEvents( gentity_t *ent, int oldEventSequence ) { } /* //FIXME: isn't there a more accurate way to calculate damage from falls? - if ( event == EV_FALL_FAR ) + if ( event == EV_FALL_FAR ) { damage = 50; - } - else + } + else { damage = 25; } @@ -1328,8 +1328,8 @@ qboolean G_CheckClampUcmd( gentity_t *ent, usercmd_t *ucmd ) { qboolean overridAngles = qfalse; - if ( (!ent->s.number&&ent->aimDebounceTime>level.time) - || (ent->client->ps.pm_time && (ent->client->ps.pm_flags&PMF_TIME_KNOCKBACK)) + if ( (!ent->s.number&&ent->aimDebounceTime>level.time) + || (ent->client->ps.pm_time && (ent->client->ps.pm_flags&PMF_TIME_KNOCKBACK)) || ent->forcePushTime > level.time ) {//being knocked back, can't do anything! ucmd->buttons = 0; @@ -1393,7 +1393,7 @@ qboolean G_CheckClampUcmd( gentity_t *ent, usercmd_t *ucmd ) } } - if ( ent->client->ps.saberMove == LS_A_BACK || ent->client->ps.saberMove == LS_A_BACK_CR + if ( ent->client->ps.saberMove == LS_A_BACK || ent->client->ps.saberMove == LS_A_BACK_CR || ent->client->ps.saberMove == LS_A_BACKSTAB ) {//can't move or turn during back attacks ucmd->forwardmove = ucmd->rightmove = 0; @@ -1422,7 +1422,7 @@ qboolean G_CheckClampUcmd( gentity_t *ent, usercmd_t *ucmd ) } } } - else if ( ent->client->ps.torsoAnim == BOTH_WALL_FLIP_BACK1 + else if ( ent->client->ps.torsoAnim == BOTH_WALL_FLIP_BACK1 || ent->client->ps.torsoAnim == BOTH_WALL_FLIP_BACK2 ) { //pull back the view @@ -1620,7 +1620,7 @@ NPC_GetRunSpeed ------------------------- */ #define BORG_RUN_INCR 25 -#define SPECIES_RUN_INCR 25 +#define SPECIES_RUN_INCR 25 #define STASIS_RUN_INCR 20 #define WARBOT_RUN_INCR 20 @@ -1832,7 +1832,7 @@ void G_StopCinematicSkip( void ) void G_StartCinematicSkip( void ) { - + if (cinematicSkipScript[0]) { ICARUS_RunScript( &g_entities[0], va( "%s/%s", Q3_SCRIPT_DIR, cinematicSkipScript ) ); @@ -1840,7 +1840,7 @@ void G_StartCinematicSkip( void ) gi.cvar_set("skippingCinematic", "1"); gi.cvar_set("timescale", "100"); } - else + else { // no... so start skipping... gi.cvar_set("skippingCinematic", "1"); @@ -1848,7 +1848,7 @@ void G_StartCinematicSkip( void ) } } -void G_CheckClientIdle( gentity_t *ent, usercmd_t *ucmd ) +void G_CheckClientIdle( gentity_t *ent, usercmd_t *ucmd ) { if ( !ent || !ent->client || ent->health <= 0 ) { @@ -1862,15 +1862,15 @@ void G_CheckClientIdle( gentity_t *ent, usercmd_t *ucmd ) } return; } - if ( !VectorCompare( vec3_origin, ent->client->ps.velocity ) - || ucmd->buttons || ucmd->forwardmove || ucmd->rightmove || ucmd->upmove - || !PM_StandingAnim( ent->client->ps.legsAnim ) - || ent->enemy + if ( !VectorCompare( vec3_origin, ent->client->ps.velocity ) + || ucmd->buttons || ucmd->forwardmove || ucmd->rightmove || ucmd->upmove + || !PM_StandingAnim( ent->client->ps.legsAnim ) + || ent->enemy || ent->client->ps.legsAnimTimer || ent->client->ps.torsoAnimTimer ) {//FIXME: also check for turning? - if ( !VectorCompare( vec3_origin, ent->client->ps.velocity ) - || ucmd->buttons || ucmd->forwardmove || ucmd->rightmove || ucmd->upmove + if ( !VectorCompare( vec3_origin, ent->client->ps.velocity ) + || ucmd->buttons || ucmd->forwardmove || ucmd->rightmove || ucmd->upmove || ent->enemy ) { //if in an idle, break out @@ -1959,8 +1959,8 @@ void G_CheckMovingLoopingSounds( gentity_t *ent, usercmd_t *ucmd ) } else {//not moving under your own control, stop loopSound - if ( ent->client->NPC_class == CLASS_R2D2 || ent->client->NPC_class == CLASS_R5D2 - || ent->client->NPC_class == CLASS_MARK2 || ent->client->NPC_class == CLASS_MOUSE + if ( ent->client->NPC_class == CLASS_R2D2 || ent->client->NPC_class == CLASS_R5D2 + || ent->client->NPC_class == CLASS_MARK2 || ent->client->NPC_class == CLASS_MOUSE || ent->client->NPC_class == CLASS_PROBE ) { ent->s.loopSound = 0; @@ -1980,7 +1980,7 @@ usually be a couple times for each server frame on fast clients. */ extern int G_FindLocalInterestPoint( gentity_t *self ); -void ClientThink_real( gentity_t *ent, usercmd_t *ucmd ) +void ClientThink_real( gentity_t *ent, usercmd_t *ucmd ) { gclient_t *client; pmove_t pm; @@ -1991,7 +1991,7 @@ void ClientThink_real( gentity_t *ent, usercmd_t *ucmd ) qboolean controlledByPlayer = qfalse; //Don't let the player do anything if in a camera - if ( ent->s.number == 0 ) + if ( ent->s.number == 0 ) { extern cvar_t *g_skippingcin; @@ -2071,7 +2071,7 @@ extern cvar_t *g_skippingcin; { int diff = AngleNormalize180(SHORT2ANGLE(ucmd->angles[YAW]+ent->client->ps.delta_angles[YAW]) - floor(ent->client->ps.viewangles[YAW])); int slide = floor(((float)(diff))/120.0f*-127.0f); - + if ( (slide > 0 && ucmd->rightmove >= 0) || ((slide < 0 && ucmd->rightmove <= 0)) ) {//note: don't want these to conflict right now because that seems to feel really weird //gi.Printf( "slide %i, diff %i, yaw %i\n", slide, diff, ucmd->angles[YAW] ); @@ -2094,7 +2094,7 @@ extern cvar_t *g_skippingcin; ucmd->angles[YAW] = ANGLE2SHORT( ent->client->ps.viewangles[YAW] ) - ent->client->ps.delta_angles[YAW]; } } - else + else { if ( g_skippingcin->integer ) {//We're skipping the cinematic and it's over now @@ -2117,10 +2117,10 @@ extern cvar_t *g_skippingcin; if ( cg.zoomMode == 2 ) { // Any kind of movement when the player is NOT ducked when the disruptor gun is zoomed will cause us to auto-magically un-zoom - if ( ( (ucmd->forwardmove||ucmd->rightmove) + if ( ( (ucmd->forwardmove||ucmd->rightmove) && ucmd->upmove >= 0 //crouching-moving is ok - && !(ucmd->buttons&BUTTON_USE)/*leaning is ok*/ - ) + && !(ucmd->buttons&BUTTON_USE)/*leaning is ok*/ + ) || ucmd->upmove > 0 //jumping not allowed ) { @@ -2171,9 +2171,9 @@ extern cvar_t *g_skippingcin; } if ( ent->client ) { - if ( ent->client->NPC_class == CLASS_GONK || - ent->client->NPC_class == CLASS_MOUSE || - ent->client->NPC_class == CLASS_R2D2 || + if ( ent->client->NPC_class == CLASS_GONK || + ent->client->NPC_class == CLASS_MOUSE || + ent->client->NPC_class == CLASS_R2D2 || ent->client->NPC_class == CLASS_R5D2 ) {//no jumping or strafing in these guys ucmd->upmove = ucmd->rightmove = 0; @@ -2205,17 +2205,17 @@ extern cvar_t *g_skippingcin; else if ( ent->client->ps.groundEntityNum < ENTITYNUM_WORLD && !ent->client->ps.forceJumpCharge ) {//standing on an entity and not currently force jumping gentity_t *groundEnt = &g_entities[ent->client->ps.groundEntityNum]; - if ( groundEnt && - groundEnt->client && - groundEnt->client->ps.groundEntityNum != ENTITYNUM_NONE && + if ( groundEnt && + groundEnt->client && + groundEnt->client->ps.groundEntityNum != ENTITYNUM_NONE && groundEnt->health > 0 && - !PM_InRoll( &groundEnt->client->ps ) - && !(groundEnt->client->ps.eFlags&EF_LOCKED_TO_WEAPON) + !PM_InRoll( &groundEnt->client->ps ) + && !(groundEnt->client->ps.eFlags&EF_LOCKED_TO_WEAPON) && !inSpinFlipAttack ) {//landed on a live client who is on the ground, jump off them and knock them down if ( ent->health > 0 ) { - if ( !PM_InRoll( &ent->client->ps ) + if ( !PM_InRoll( &ent->client->ps ) && !PM_FlippingAnim( ent->client->ps.legsAnim ) ) { if ( ent->s.number && ent->s.weapon == WP_SABER ) @@ -2282,7 +2282,7 @@ extern cvar_t *g_skippingcin; {//can't knock down desann unless you're luke //FIXME: should he smack you away like Galak Mech? } - else if ( + else if ( ( ( (groundEnt->s.number&&(groundEnt->s.weapon!=WP_SABER||!groundEnt->NPC||groundEnt->NPC->ranks.number||G_ControlledByPlayer(groundEnt)) && !Q_irand( 0, 3 )&&cg.renderingThirdPerson&&!cg.zoomMode) )//or a player in third person, 25% of the time && groundEnt->client->playerTeam != ent->client->playerTeam ) //and not on the same team @@ -2316,38 +2316,38 @@ extern cvar_t *g_skippingcin; client->pers.lastCommand = *ucmd; // sanity check the command time to prevent speedup cheating - if ( ucmd->serverTime > level.time + 200 ) + if ( ucmd->serverTime > level.time + 200 ) { ucmd->serverTime = level.time + 200; } - if ( ucmd->serverTime < level.time - 1000 ) + if ( ucmd->serverTime < level.time - 1000 ) { ucmd->serverTime = level.time - 1000; - } + } msec = ucmd->serverTime - client->ps.commandTime; - if ( msec < 1 ) + if ( msec < 1 ) { msec = 1; } - if ( msec > 200 ) + if ( msec > 200 ) { msec = 200; } // check for inactivity timer, but never drop the local client of a non-dedicated server - if ( !ClientInactivityTimer( client ) ) + if ( !ClientInactivityTimer( client ) ) return; - if ( client->noclip ) + if ( client->noclip ) { client->ps.pm_type = PM_NOCLIP; - } - else if ( client->ps.stats[STAT_HEALTH] <= 0 ) + } + else if ( client->ps.stats[STAT_HEALTH] <= 0 ) { client->ps.pm_type = PM_DEAD; - } - else + } + else { client->ps.pm_type = PM_NORMAL; } @@ -2453,17 +2453,17 @@ extern cvar_t *g_skippingcin; else { //Slow down on turns - don't orbit!!! - float turndelta = 0; + float turndelta = 0; // if the NPC is locked into a Yaw, we want to check the lockedDesiredYaw...otherwise the NPC can't walk backwards, because it always thinks it trying to turn according to desiredYaw if( client->renderInfo.renderFlags & RF_LOCKEDANGLE ) // yeah I know the RF_ flag is a pretty ugly hack... - { + { turndelta = (180 - fabs( AngleDelta( ent->currentAngles[YAW], ent->NPC->lockedDesiredYaw ) ))/180; } else { turndelta = (180 - fabs( AngleDelta( ent->currentAngles[YAW], ent->NPC->desiredYaw ) ))/180; } - + if ( turndelta < 0.75f ) { client->ps.speed = 0; @@ -2477,7 +2477,7 @@ extern cvar_t *g_skippingcin; } } else - { + { ent->NPC->desiredSpeed = ( ucmd->buttons & BUTTON_WALKING ) ? NPC_GetWalkSpeed( ent ) : NPC_GetRunSpeed( ent ); client->ps.speed = ent->NPC->desiredSpeed; @@ -2769,7 +2769,7 @@ extern cvar_t *g_skippingcin; Pmove( &pm ); // save results of pmove - if ( ent->client->ps.eventSequence != oldEventSequence ) + if ( ent->client->ps.eventSequence != oldEventSequence ) { ent->eventTime = level.time; { @@ -2816,7 +2816,7 @@ extern cvar_t *g_skippingcin; // link entity now, after any personal teleporters have been used gi.linkentity( ent ); ent->client->hiddenDist = 0; - if ( !ent->client->noclip ) + if ( !ent->client->noclip ) { G_TouchTriggersLerped( ent ); } @@ -2830,18 +2830,18 @@ extern cvar_t *g_skippingcin; client->latched_buttons |= client->buttons & ~client->oldbuttons; // check for respawning - if ( client->ps.stats[STAT_HEALTH] <= 0 ) + if ( client->ps.stats[STAT_HEALTH] <= 0 ) { // wait for the attack button to be pressed - if ( ent->NPC == NULL && level.time > client->respawnTime ) + if ( ent->NPC == NULL && level.time > client->respawnTime ) { // don't allow respawn if they are still flying through the // air, unless 10 extra seconds have passed, meaning something // strange is going on, like the corpse is caught in a wind tunnel /* - if ( level.time < client->respawnTime + 10000 ) + if ( level.time < client->respawnTime + 10000 ) { - if ( client->ps.groundEntityNum == ENTITYNUM_NONE ) + if ( client->ps.groundEntityNum == ENTITYNUM_NONE ) { return; } @@ -2849,18 +2849,18 @@ extern cvar_t *g_skippingcin; */ // pressing attack or use is the normal respawn method - if ( ucmd->buttons & ( BUTTON_ATTACK ) ) + if ( ucmd->buttons & ( BUTTON_ATTACK ) ) { respawn( ent ); // gi.SendConsoleCommand( va("disconnect;wait;wait;wait;wait;wait;wait;devmap %s\n",level.mapname) ); } } - if ( ent - && !ent->s.number - && ent->enemy - && ent->enemy != ent - && ent->enemy->s.number < ENTITYNUM_WORLD - && ent->enemy->inuse + if ( ent + && !ent->s.number + && ent->enemy + && ent->enemy != ent + && ent->enemy->s.number < ENTITYNUM_WORLD + && ent->enemy->inuse && !(cg.overrides.active&CG_OVERRIDE_3RD_PERSON_ANG) ) {//keep facing enemy vec3_t deadDir; @@ -2923,7 +2923,7 @@ void ClientThink( int clientNum, usercmd_t *ucmd ) { {//you're controlling another NPC gentity_t *controlled = &g_entities[ent->client->ps.viewEntity]; qboolean freed = qfalse; - if ( controlled->NPC + if ( controlled->NPC && controlled->NPC->controlledTime && ent->client->ps.forcePowerLevel[FP_TELEPATHY] > FORCE_LEVEL_3 ) {//An NPC I'm controlling with mind trick @@ -2998,7 +2998,7 @@ void ClientThink( int clientNum, usercmd_t *ucmd ) { ent->client->usercmd = *ucmd; -// if ( !g_syncronousClients->integer ) +// if ( !g_syncronousClients->integer ) { ClientThink_real( ent, ucmd ); } @@ -3014,18 +3014,18 @@ void ClientThink( int clientNum, usercmd_t *ucmd ) { } } -void ClientEndPowerUps( gentity_t *ent ) +void ClientEndPowerUps( gentity_t *ent ) { int i; - if ( ent == NULL || ent->client == NULL ) + if ( ent == NULL || ent->client == NULL ) { return; } // turn off any expired powerups - for ( i = 0 ; i < MAX_POWERUPS ; i++ ) + for ( i = 0 ; i < MAX_POWERUPS ; i++ ) { - if ( ent->client->ps.powerups[ i ] < level.time ) + if ( ent->client->ps.powerups[ i ] < level.time ) { ent->client->ps.powerups[ i ] = 0; } @@ -3040,7 +3040,7 @@ A fast client will have multiple ClientThink for each ClientEdFrame, while a slow client may have multiple ClientEndFrame between ClientThink. ============== */ -void ClientEndFrame( gentity_t *ent ) +void ClientEndFrame( gentity_t *ent ) { // // If the end of unit layout is displayed, don't give diff --git a/codeJK2/game/g_breakable.cpp b/codeJK2/game/g_breakable.cpp index 3414928966..711ae7fca5 100644 --- a/codeJK2/game/g_breakable.cpp +++ b/codeJK2/game/g_breakable.cpp @@ -88,7 +88,7 @@ void funcBBrushDieGo (gentity_t *self) float scale; int numChunks, size = 0; material_t chunkType = self->material; - + // if a missile is stuck to us, blow it up so we don't look dumb for ( int i = 0; i < MAX_GENTITIES; i++ ) { @@ -102,7 +102,7 @@ void funcBBrushDieGo (gentity_t *self) self->s.solid = 0; self->contents = 0; self->clipmask = 0; - gi.linkentity(self); + gi.linkentity(self); VectorSet(up, 0, 0, 1); @@ -149,7 +149,7 @@ void funcBBrushDieGo (gentity_t *self) else { VectorCopy(up, dir); - } + } if ( !(self->spawnflags & 2048) ) // NO_EXPLOSION { @@ -249,7 +249,7 @@ void funcBBrushPain(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, else { VectorSet( dir, 0, 0, 1 ); - } + } CG_Chunks( self->s.number, org, dir, self->mins, self->maxs, 300, Q_irand( 1, 3 ), self->material, 0, scale ); } @@ -262,23 +262,23 @@ void funcBBrushPain(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, self->painDebounceTime = level.time + self->wait; } -static void InitBBrush ( gentity_t *ent ) +static void InitBBrush ( gentity_t *ent ) { float light; vec3_t color; qboolean lightSet, colorSet; VectorCopy( ent->s.origin, ent->pos1 ); - + gi.SetBrushModel( ent, ent->model ); ent->e_DieFunc = dieF_funcBBrushDie; - + ent->svFlags |= SVF_BBRUSH; // if the "model2" key is set, use a seperate model // for drawing, but clip against the brushes - if ( ent->model2 ) + if ( ent->model2 ) { ent->s.modelindex2 = G_ModelIndex( ent->model2 ); } @@ -286,7 +286,7 @@ static void InitBBrush ( gentity_t *ent ) // if the "color" or "light" keys are set, setup constantLight lightSet = G_SpawnFloat( "light", "100", &light ); colorSet = G_SpawnVector( "color", "1 1 1", color ); - if ( lightSet || colorSet ) + if ( lightSet || colorSet ) { int r, g, b, i; @@ -356,13 +356,13 @@ Damage: default is none "neutral" "enemy" -Don't know if these work: +Don't know if these work: "color" constantLight color "light" constantLight radius "material" - default is "0 - MAT_METAL" - choose from this list: 0 = MAT_METAL (basic blue-grey scorched-DEFAULT) -1 = MAT_GLASS +1 = MAT_GLASS 2 = MAT_ELECTRICAL (sparks only) 3 = MAT_ELEC_METAL (METAL2 chunks and sparks) 4 = MAT_DRK_STONE (brown stone chunks) @@ -379,7 +379,7 @@ Don't know if these work: 15 = MAT_WHITE_METAL (white angular chunks for Stu, NS_hideout ) */ -void SP_func_breakable( gentity_t *self ) +void SP_func_breakable( gentity_t *self ) { if(!(self->spawnflags & 1)) { @@ -398,7 +398,7 @@ void SP_func_breakable( gentity_t *self ) self->flags |= FL_DMG_BY_HEAVY_WEAP_ONLY; } - if (self->health) + if (self->health) { self->takedamage = qtrue; } @@ -448,7 +448,7 @@ void misc_model_breakable_pain ( gentity_t *self, gentity_t *inflictor, gentity_ } } -void misc_model_breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath,int dFlags,int hitLoc ) +void misc_model_breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath,int dFlags,int hitLoc ) { int numChunks; float size = 0, scale; @@ -458,7 +458,7 @@ void misc_model_breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t //Turn off animation self->s.frame = self->startFrame = self->endFrame = 0; self->svFlags &= ~SVF_ANIMATING; - + self->health = 0; //Throw some chunks @@ -639,7 +639,7 @@ void misc_model_breakable_init( gentity_t *ent ) if (type == MDL_OTHER) { - ent->e_UseFunc = useF_misc_model_use; + ent->e_UseFunc = useF_misc_model_use; } else if ( type == MDL_ARMOR_HEALTH ) { @@ -662,7 +662,7 @@ void misc_model_breakable_init( gentity_t *ent ) ent->health = 60; } - if ( ent->health ) + if ( ent->health ) { G_SoundIndex("sound/weapons/explosions/cargoexplode.wav"); ent->max_health = ent->health; @@ -695,7 +695,7 @@ void TieFighterThink ( gentity_t *self ) fighterSpeed = VectorNormalize( fighterDir )*1000; AngleVectors( self->currentAngles, fwd, rt, NULL ); - if ( fighterSpeed ) + if ( fighterSpeed ) { float side; @@ -723,7 +723,7 @@ void TieFighterThink ( gentity_t *self ) gentity_t *bolt; bolt = G_Spawn(); - + bolt->classname = "tie_proj"; bolt->nextthink = level.time + 10000; bolt->e_ThinkFunc = thinkF_G_FreeEntity; @@ -866,7 +866,7 @@ Damage: default is none "material" - default is "8 - MAT_NONE" - choose from this list: 0 = MAT_METAL (grey metal) -1 = MAT_GLASS +1 = MAT_GLASS 2 = MAT_ELECTRICAL (sparks only) 3 = MAT_ELEC_METAL (METAL chunks and sparks) 4 = MAT_DRK_STONE (brown stone chunks) @@ -881,18 +881,18 @@ Damage: default is none 13 = MAT_ROPE (for yavin_trial, no chunks, just wispy bits ) 14 = MAT_CRATE2 (red multi-colored crate chunks) 15 = MAT_WHITE_METAL (white angular chunks for Stu, NS_hideout ) -FIXME/TODO: +FIXME/TODO: set size better? multiple damage models? custom explosion effect/sound? */ -void SP_misc_model_breakable( gentity_t *ent ) +void SP_misc_model_breakable( gentity_t *ent ) { char damageModel[MAX_QPATH]; char chunkModel[MAX_QPATH]; char useModel[MAX_QPATH]; int len; - + // Chris F. requested default for misc_model_breakable to be NONE...so don't arbitrarily change this. G_SpawnInt( "material", "8", (int*)&ent->material ); G_SpawnFloat( "radius", "1", &ent->radius ); // used to scale chunk code if desired by a designer @@ -905,14 +905,14 @@ void SP_misc_model_breakable( gentity_t *ent ) damageModel[len] = 0; //chop extension strncpy( chunkModel, damageModel, sizeof(chunkModel)); strncpy( useModel, damageModel, sizeof(useModel)); - + if (ent->takedamage) { //Dead/damaged model if( !(ent->spawnflags & 8) ) { //no dmodel strcat( damageModel, "_d1.md3" ); ent->s.modelindex2 = G_ModelIndex( damageModel ); } - + //Chunk model strcat( chunkModel, "_c1.md3" ); ent->s.modelindex3 = G_ModelIndex( chunkModel ); @@ -954,7 +954,7 @@ void SP_misc_model_breakable( gentity_t *ent ) G_Error("team name %s not recognized", ent->team); } } - + ent->team = NULL; //HACK @@ -991,7 +991,7 @@ void SP_misc_model_breakable( gentity_t *ent ) //---------------------------------- // Really naughty cheating. Put in an EVENT at some point... -extern void cgi_R_GetBModelVerts(int bmodelIndex, vec3_t *verts, vec3_t normal ); +extern void cgi_R_GetBModelVerts(int bmodelIndex, vec3_t *verts, vec3_t normal ); extern void CG_DoGlass( vec3_t verts[4], vec3_t normal, vec3_t dmgPt, vec3_t dmgDir, float dmgRadius ); extern cgs_t cgs; @@ -1021,7 +1021,7 @@ void funcGlassDie( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, i self->s.solid = 0; self->contents = 0; self->clipmask = 0; - gi.linkentity(self); + gi.linkentity(self); if ( self->target && attacker != NULL ) { @@ -1069,7 +1069,7 @@ INVINCIBLE - can only be broken by being used "health" default is 1 */ //----------------------------------------------------- -void SP_func_glass( gentity_t *self ) +void SP_func_glass( gentity_t *self ) { if ( !(self->spawnflags & 1 )) { @@ -1079,7 +1079,7 @@ void SP_func_glass( gentity_t *self ) } } - if ( self->health ) + if ( self->health ) { self->takedamage = qtrue; } @@ -1088,7 +1088,7 @@ void SP_func_glass( gentity_t *self ) self->e_DieFunc = dieF_funcGlassDie; VectorCopy( self->s.origin, self->pos1 ); - + gi.SetBrushModel( self, self->model ); self->svFlags |= (SVF_GLASS_BRUSH|SVF_BBRUSH); self->material = MAT_GLASS; diff --git a/codeJK2/game/g_camera.cpp b/codeJK2/game/g_camera.cpp index e52c6f93b8..67c61fb324 100644 --- a/codeJK2/game/g_camera.cpp +++ b/codeJK2/game/g_camera.cpp @@ -114,7 +114,7 @@ void misc_camera_track_think (gentity_t *self) self->enemy = NULL; } } - + if( !self->enemy) { if( self->target && self->target[0] ) @@ -212,7 +212,7 @@ void cam_point_link( gentity_t *ent ) } void cam_ctrl_point_link( gentity_t *ent ) -{ +{ /* gentity_t *target2 = NULL; target2 = G_Find( NULL, FOFS(targetname), ent->target2 ); @@ -227,7 +227,7 @@ void cam_ctrl_point_link( gentity_t *ent ) // Store the control point here VectorCopy( target2->s.origin, ent->pos1 ); - + //--------------------- if ( ent->target ) { diff --git a/codeJK2/game/g_cmds.cpp b/codeJK2/game/g_cmds.cpp index 7fbc3270d1..ff0ed59863 100644 --- a/codeJK2/game/g_cmds.cpp +++ b/codeJK2/game/g_cmds.cpp @@ -214,7 +214,7 @@ void G_Give( gentity_t *ent, const char *name, const char *args, int argc ) if ( !give_all ) return; } - + if ( !give_all && !Q_stricmp( name, "weaponnum" ) ) { ent->client->ps.stats[STAT_WEAPONS] |= (1 << atoi( args )); @@ -312,7 +312,7 @@ void Cmd_Fx( gentity_t *ent ) if ( gi.argc() == 3 ) { // I guess, only allow one active at a time - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { G_FreeEntity( fx_ent ); } @@ -336,7 +336,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else if ( Q_stricmp( gi.argv(1), "stop" ) == 0 ) { - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { G_FreeEntity( fx_ent ); } @@ -345,7 +345,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else if ( Q_stricmp( gi.argv(1), "delay" ) == 0 ) { - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { if ( gi.argc() == 3 ) { @@ -361,7 +361,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else if ( Q_stricmp( gi.argv(1), "random" ) == 0 ) { - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { if ( gi.argc() == 3 ) { @@ -377,7 +377,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else if ( Q_stricmp( gi.argv(1), "origin" ) == 0 ) { - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { if ( gi.argc() == 5 ) { @@ -389,7 +389,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else { - gi.Printf( S_COLOR_GREEN"FX: current origin is: <%6.2f %6.2f %6.2f>\n", + gi.Printf( S_COLOR_GREEN"FX: current origin is: <%6.2f %6.2f %6.2f>\n", fx_ent->currentOrigin[0], fx_ent->currentOrigin[1], fx_ent->currentOrigin[2] ); } @@ -398,7 +398,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else if ( Q_stricmp( gi.argv(1), "dir" ) == 0 ) { - while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) + while (( fx_ent = G_Find( fx_ent, FOFS(classname), "cmd_fx")) != NULL ) { if ( gi.argc() == 5 ) { @@ -414,7 +414,7 @@ extern void SP_fx_runner( gentity_t *ent ); } else { - gi.Printf( S_COLOR_GREEN"FX: current dir is: <%6.2f %6.2f %6.2f>\n", + gi.Printf( S_COLOR_GREEN"FX: current dir is: <%6.2f %6.2f %6.2f>\n", fx_ent->s.angles[0], fx_ent->s.angles[1], fx_ent->s.angles[2] ); } @@ -426,7 +426,7 @@ extern void SP_fx_runner( gentity_t *ent ); gi.Printf( S_COLOR_CYAN"commands: sample usage:\n" ); gi.Printf( S_COLOR_CYAN"----------------------------------------------------------\n" ); gi.Printf( S_COLOR_CYAN"fx play fx play sparks, fx play env/fire\n" ); - gi.Printf( S_COLOR_CYAN"fx stop fx stop\n" ); + gi.Printf( S_COLOR_CYAN"fx stop fx stop\n" ); gi.Printf( S_COLOR_CYAN"fx delay <#> fx delay 1000\n" ); gi.Printf( S_COLOR_CYAN"fx random <#> fx random 200\n" ); gi.Printf( S_COLOR_CYAN"fx origin <#><#><#> fx origin 10 20 30\n" ); @@ -472,7 +472,7 @@ void Cmd_Undying_f (gentity_t *ent) { const char *msg; - if ( !CheatsOk( ent ) ) + if ( !CheatsOk( ent ) ) { return; } @@ -605,7 +605,7 @@ void Cmd_Where_f( gentity_t *ent ) { const char *s = gi.argv(1); const int len = strlen(s); gentity_t *check; - + if ( gi.argc () < 2 ) { gi.Printf("usage: where classname\n"); return; @@ -639,7 +639,7 @@ void UserSpawn( gentity_t *ent, const char *name ) vec3_t vf; vec3_t angles; gentity_t *ent2; - + //Spawn the ent ent2 = G_Spawn(); ent2->classname = G_NewString( name ); //FIXME: This will leave floating memory... @@ -719,13 +719,13 @@ void Cmd_SetViewpos_f( gentity_t *ent ) { Cmd_SetObjective_f ================= */ -void Cmd_SetObjective_f( gentity_t *ent ) +void Cmd_SetObjective_f( gentity_t *ent ) { int objectiveI,status,displayStatus; if ( gi.argc() == 2 ) { objectiveI = atoi(gi.argv(1)); - gi.Printf("objective #%d display status=%d, status=%d\n",objectiveI, + gi.Printf("objective #%d display status=%d, status=%d\n",objectiveI, ent->client->sess.mission_objectives[objectiveI].display, ent->client->sess.mission_objectives[objectiveI].status ); @@ -736,7 +736,7 @@ void Cmd_SetObjective_f( gentity_t *ent ) return; } - if ( !CheatsOk( ent ) ) + if ( !CheatsOk( ent ) ) { return; } @@ -754,7 +754,7 @@ void Cmd_SetObjective_f( gentity_t *ent ) Cmd_ViewObjective_f ================= */ -void Cmd_ViewObjective_f( gentity_t *ent ) +void Cmd_ViewObjective_f( gentity_t *ent ) { int objectiveI; @@ -876,7 +876,7 @@ void Cmd_UseSeeker_f( gentity_t *ent ) if ( ent->client && ent->client->ps.inventory[INV_SEEKER] > 0 && level.time > ent->client->ps.powerups[PW_SEEKER] ) { gentity_t *tent = G_Spawn(); - + if ( tent ) { vec3_t fwd, right, spot; @@ -1024,7 +1024,7 @@ void ClientCommand( int clientNum ) { Cmd_Spawn( ent ); return; } - + if (Q_stricmp (cmd, "give") == 0) Cmd_Give_f (ent); else if (Q_stricmp (cmd, "god") == 0) diff --git a/codeJK2/game/g_functions.cpp b/codeJK2/game/g_functions.cpp index 5a95f8a263..dd35d8ebc2 100644 --- a/codeJK2/game/g_functions.cpp +++ b/codeJK2/game/g_functions.cpp @@ -38,43 +38,43 @@ void GEntity_ThinkFunc(gentity_t *self) switch (self->e_ThinkFunc) { - case thinkF_NULL: + case thinkF_NULL: break; - THINKCASE( funcBBrushDieGo ) - THINKCASE( ExplodeDeath ) - THINKCASE( RespawnItem ) - THINKCASE( G_FreeEntity ) - THINKCASE( FinishSpawningItem ) - THINKCASE( locateCamera ) - THINKCASE( G_RunObject ) - THINKCASE( ReturnToPos1 ) - THINKCASE( Use_BinaryMover_Go ) - THINKCASE( Think_MatchTeam ) - THINKCASE( Think_BeginMoving ) - THINKCASE( Think_SetupTrainTargets ) - THINKCASE( Think_SpawnNewDoorTrigger ) - THINKCASE( ref_link ) - THINKCASE( Think_Target_Delay ) - THINKCASE( target_laser_think ) - THINKCASE( target_laser_start ) - THINKCASE( target_location_linkup ) - THINKCASE( scriptrunner_run ) - THINKCASE( multi_wait ) - THINKCASE( multi_trigger_run ) - THINKCASE( trigger_always_think ) - THINKCASE( AimAtTarget ) - THINKCASE( func_timer_think ) - THINKCASE( NPC_RemoveBody ) - THINKCASE( Disappear ) - THINKCASE( NPC_Think ) - THINKCASE( NPC_Spawn_Go ) - THINKCASE( NPC_Begin ) + THINKCASE( funcBBrushDieGo ) + THINKCASE( ExplodeDeath ) + THINKCASE( RespawnItem ) + THINKCASE( G_FreeEntity ) + THINKCASE( FinishSpawningItem ) + THINKCASE( locateCamera ) + THINKCASE( G_RunObject ) + THINKCASE( ReturnToPos1 ) + THINKCASE( Use_BinaryMover_Go ) + THINKCASE( Think_MatchTeam ) + THINKCASE( Think_BeginMoving ) + THINKCASE( Think_SetupTrainTargets ) + THINKCASE( Think_SpawnNewDoorTrigger ) + THINKCASE( ref_link ) + THINKCASE( Think_Target_Delay ) + THINKCASE( target_laser_think ) + THINKCASE( target_laser_start ) + THINKCASE( target_location_linkup ) + THINKCASE( scriptrunner_run ) + THINKCASE( multi_wait ) + THINKCASE( multi_trigger_run ) + THINKCASE( trigger_always_think ) + THINKCASE( AimAtTarget ) + THINKCASE( func_timer_think ) + THINKCASE( NPC_RemoveBody ) + THINKCASE( Disappear ) + THINKCASE( NPC_Think ) + THINKCASE( NPC_Spawn_Go ) + THINKCASE( NPC_Begin ) THINKCASE( moverCallback ) THINKCASE( anglerCallback ) - THINKCASE( RemoveOwner ) - THINKCASE( MakeOwnerInvis ) - THINKCASE( MakeOwnerEnergy ) + THINKCASE( RemoveOwner ) + THINKCASE( MakeOwnerInvis ) + THINKCASE( MakeOwnerEnergy ) THINKCASE( func_usable_think ) THINKCASE( misc_dlight_think ) THINKCASE( health_think ) @@ -128,7 +128,7 @@ void GEntity_ThinkFunc(gentity_t *self) THINKCASE( panel_turret_think ) THINKCASE( welder_think ) THINKCASE( gas_random_jet ) - THINKCASE( poll_converter ) // dumb loop sound handling + THINKCASE( poll_converter ) // dumb loop sound handling THINKCASE( spawn_rack_goods ) // delay spawn of goods to help on ents default: @@ -161,12 +161,12 @@ void CEntity_ThinkFunc(centity_s *cent) void GEntity_ReachedFunc(gentity_t *self) -{ +{ //#define REACHEDCASE(blah) case reachedF_ ## blah: blah(self); OutputDebugString(va("%s\n",#blah));break; #define REACHEDCASE(blah) case reachedF_ ## blah: blah(self); break; switch (self->e_ReachedFunc) - { + { case reachedF_NULL: break; @@ -193,8 +193,8 @@ void GEntity_BlockedFunc(gentity_t *self, gentity_t *other) case blockedF_NULL: break; - BLOCKEDCASE( Blocked_Door ) - BLOCKEDCASE( Blocked_Mover ) + BLOCKEDCASE( Blocked_Door ) + BLOCKEDCASE( Blocked_Mover ) default: Com_Error(ERR_DROP, "GEntity_BlockedFunc: case %d not handled!\n",self->e_BlockedFunc); diff --git a/codeJK2/game/g_functions.h b/codeJK2/game/g_functions.h index 23e94d89df..d41cb92e99 100644 --- a/codeJK2/game/g_functions.h +++ b/codeJK2/game/g_functions.h @@ -36,7 +36,7 @@ along with this program; if not, see . #undef dieFunc_t // void (*think)(gentity_t *self); -typedef enum +typedef enum { thinkF_NULL = 0, // @@ -45,7 +45,7 @@ typedef enum thinkF_ExplodeDeath, thinkF_RespawnItem, thinkF_G_FreeEntity, - thinkF_FinishSpawningItem, + thinkF_FinishSpawningItem, thinkF_locateCamera, thinkF_G_RunObject, thinkF_ReturnToPos1, @@ -174,7 +174,7 @@ extern void RemoveOwner ( gentity_t *ent ); extern void MakeOwnerInvis ( gentity_t *ent ); extern void MakeOwnerEnergy ( gentity_t *ent ); extern void func_usable_think ( gentity_t *self ); -extern void misc_dlight_think ( gentity_t *ent ); +extern void misc_dlight_think ( gentity_t *ent ); extern void laser_link ( gentity_t *ent ); extern void blow_chunks_link ( gentity_t *ent ); extern void health_think ( gentity_t *ent ); @@ -234,7 +234,7 @@ extern void spawn_rack_goods ( gentity_t *self ); // void (*clThink)(centity_s *cent); //Think func for equivalent centity typedef enum { - clThinkF_NULL = 0, + clThinkF_NULL = 0, // clThinkF_CG_DLightThink, clThinkF_CG_MatrixEffect, @@ -274,7 +274,7 @@ typedef enum blockedF_NULL = 0, // blockedF_Blocked_Door, - blockedF_Blocked_Mover + blockedF_Blocked_Mover } blockedFunc_t; @@ -287,7 +287,7 @@ extern void Blocked_Mover (gentity_t *self, gentity_t *other); // void (*touch)(gentity_t *self, gentity_t *other, trace_t *trace); typedef enum -{ +{ touchF_NULL = 0, // touchF_Touch_Item, @@ -415,20 +415,20 @@ typedef enum extern void funcBBrushUse ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void misc_model_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void Use_Item ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Shooter ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void GoExplodeDeath ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_BinaryMover ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void use_wall ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Target_Give ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Target_Delay ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Target_Score ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Target_Print ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void Use_Target_Speaker ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Shooter ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void GoExplodeDeath ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_BinaryMover ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void use_wall ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Target_Give ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Target_Delay ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Target_Score ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Target_Print ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void Use_Target_Speaker ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_laser_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_relay_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_kill_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_counter_use ( gentity_t *self, gentity_t *other, gentity_t *activator); -extern void target_random_use ( gentity_t *self, gentity_t *other, gentity_t *activator); +extern void target_random_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_scriptrunner_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_gravity_change_use ( gentity_t *self, gentity_t *other, gentity_t *activator); extern void target_friction_change_use ( gentity_t *self, gentity_t *other, gentity_t *activator); diff --git a/codeJK2/game/g_items.h b/codeJK2/game/g_items.h index 742369afd3..608dbbd4b2 100644 --- a/codeJK2/game/g_items.h +++ b/codeJK2/game/g_items.h @@ -26,7 +26,7 @@ along with this program; if not, see . #define __ITEMS_H__ // Items enums -enum +enum { ITM_NONE, @@ -90,7 +90,7 @@ ITM_GOODIE_KEY_PICKUP, ITM_SECURITY_KEY_PICKUP, ITM_NUM_ITEMS -}; +}; // Inventory item enums enum //# item_e @@ -99,7 +99,7 @@ enum //# item_e INV_BACTA_CANISTER, INV_SEEKER, INV_LIGHTAMP_GOGGLES, - INV_SENTRY, + INV_SENTRY, //# #eol INV_GOODIE_KEY, // don't want to include keys in the icarus list INV_SECURITY_KEY, diff --git a/codeJK2/game/g_local.h b/codeJK2/game/g_local.h index 0c2bf4fdf7..40dbdbb544 100644 --- a/codeJK2/game/g_local.h +++ b/codeJK2/game/g_local.h @@ -42,7 +42,7 @@ along with this program; if not, see . #define BODY_QUEUE_SIZE 8 -#define Q3_INFINITE 16777216 +#define Q3_INFINITE 16777216 #define FRAMETIME 100 // msec #define EVENT_VALID_MSEC 300 @@ -88,7 +88,7 @@ along with this program; if not, see . #define MAX_INTEREST_POINTS 64 -typedef struct +typedef struct { vec3_t origin; char *target; @@ -98,7 +98,7 @@ typedef struct #define MAX_COMBAT_POINTS 512 -typedef struct +typedef struct { vec3_t origin; int flags; diff --git a/codeJK2/game/g_mem.cpp b/codeJK2/game/g_mem.cpp index 4e46abd212..bd8ff91efa 100644 --- a/codeJK2/game/g_mem.cpp +++ b/codeJK2/game/g_mem.cpp @@ -43,7 +43,7 @@ void *G_Alloc( int size ) { allocPoint += size; - + return gi.Malloc(size, TAG_G_ALLOC, qfalse); } diff --git a/codeJK2/game/g_missile.cpp b/codeJK2/game/g_missile.cpp index b340f302aa..aa8d6c789c 100644 --- a/codeJK2/game/g_missile.cpp +++ b/codeJK2/game/g_missile.cpp @@ -26,7 +26,7 @@ along with this program; if not, see . #include "g_local.h" #include "g_functions.h" #include "wp_saber.h" -#include "bg_local.h" +#include "bg_local.h" extern qboolean InFront( vec3_t spot, vec3_t from, vec3_t fromAngles, float threshHold = 0.0f ); qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker ); @@ -79,7 +79,7 @@ void G_MissileReflectEffect( gentity_t *ent, vec3_t org, vec3_t dir ) //------------------------------------------------------------------------- static void G_MissileStick( gentity_t *missile, gentity_t *other, trace_t *tr ) -{ +{ if ( other->NPC || !Q_stricmp( other->classname, "misc_model_breakable" )) { // we bounce off of NPC's and misc model breakables because sticking to them requires too much effort @@ -96,7 +96,7 @@ static void G_MissileStick( gentity_t *missile, gentity_t *other, trace_t *tr ) missile->s.pos.trTime = level.time - 10; // move a bit on the first frame // check for stop - if ( tr->entityNum >= 0 && tr->entityNum < ENTITYNUM_WORLD && + if ( tr->entityNum >= 0 && tr->entityNum < ENTITYNUM_WORLD && tr->plane.normal[2] > 0.7 && missile->s.pos.trDelta[2] < 40 ) //this can happen even on very slightly sloped walls, so changed it from > 0 to > 0.7 { missile->nextthink = level.time + 100; @@ -132,7 +132,7 @@ G_ReflectMissile ================ */ extern gentity_t *Jedi_FindEnemyInCone( gentity_t *self, gentity_t *fallback, float minDot ); -void G_ReflectMissile( gentity_t *ent, gentity_t *missile, vec3_t forward ) +void G_ReflectMissile( gentity_t *ent, gentity_t *missile, vec3_t forward ) { vec3_t bounce_dir; int i; @@ -148,7 +148,7 @@ void G_ReflectMissile( gentity_t *ent, gentity_t *missile, vec3_t forward ) //save the original speed speed = VectorNormalize( missile->s.pos.trDelta ); - if ( ent && owner && owner->client && !owner->client->ps.saberInFlight && + if ( ent && owner && owner->client && !owner->client->ps.saberInFlight && (owner->client->ps.forcePowerLevel[FP_SABER_DEFENSE] > FORCE_LEVEL_2 || (owner->client->ps.forcePowerLevel[FP_SABER_DEFENSE]>FORCE_LEVEL_1&&!Q_irand( 0, 3 )) ) ) {//if high enough defense skill and saber in-hand (100% at level 3, 25% at level 2, 0% at level 1), reflections are perfectly deflected toward an enemy gentity_t *enemy; @@ -169,8 +169,8 @@ void G_ReflectMissile( gentity_t *ent, gentity_t *missile, vec3_t forward ) bullseye[2] += Q_irand( -16, 4 ); VectorSubtract( bullseye, missile->currentOrigin, bounce_dir ); VectorNormalize( bounce_dir ); - if ( !PM_SaberInParry( owner->client->ps.saberMove ) - && !PM_SaberInReflect( owner->client->ps.saberMove ) + if ( !PM_SaberInParry( owner->client->ps.saberMove ) + && !PM_SaberInReflect( owner->client->ps.saberMove ) && !PM_SaberInIdle( owner->client->ps.saberMove ) ) {//a bit more wild if ( PM_SaberInAttack( owner->client->ps.saberMove ) @@ -233,8 +233,8 @@ void G_ReflectMissile( gentity_t *ent, gentity_t *missile, vec3_t forward ) bounce_dir[i] += Q_flrand( -0.2f, 0.2f ); } } - if ( !PM_SaberInParry( owner->client->ps.saberMove ) - && !PM_SaberInReflect( owner->client->ps.saberMove ) + if ( !PM_SaberInParry( owner->client->ps.saberMove ) + && !PM_SaberInReflect( owner->client->ps.saberMove ) && !PM_SaberInIdle( owner->client->ps.saberMove ) ) {//a bit more wild if ( PM_SaberInAttack( owner->client->ps.saberMove ) @@ -290,7 +290,7 @@ G_BounceRollMissile ================ */ -void G_BounceRollMissile( gentity_t *ent, trace_t *trace ) +void G_BounceRollMissile( gentity_t *ent, trace_t *trace ) { vec3_t velocity, normal; float dot, speedXY, velocityZ, normalZ; @@ -324,7 +324,7 @@ void G_BounceRollMissile( gentity_t *ent, trace_t *trace ) } // check for stop - if ( speedXY <= 0 ) + if ( speedXY <= 0 ) { G_SetOrigin( ent, trace->endpos ); VectorCopy( ent->currentAngles, ent->s.apos.trBase ); @@ -361,7 +361,7 @@ void G_BounceMissile( gentity_t *ent, trace_t *trace ) { dot = DotProduct( velocity, trace->plane.normal ); VectorMA( velocity, -2*dot, trace->plane.normal, ent->s.pos.trDelta ); - if ( ent->s.eFlags & EF_BOUNCE_SHRAPNEL ) + if ( ent->s.eFlags & EF_BOUNCE_SHRAPNEL ) { VectorScale( ent->s.pos.trDelta, 0.25f, ent->s.pos.trDelta ); ent->s.pos.trType = TR_GRAVITY; @@ -374,7 +374,7 @@ void G_BounceMissile( gentity_t *ent, trace_t *trace ) { return; } } - else if ( ent->s.eFlags & EF_BOUNCE_HALF ) + else if ( ent->s.eFlags & EF_BOUNCE_HALF ) { VectorScale( ent->s.pos.trDelta, 0.5, ent->s.pos.trDelta ); @@ -421,8 +421,8 @@ void G_BounceMissile( gentity_t *ent, trace_t *trace ) { VectorCopy( ent->currentOrigin, ent->s.pos.trBase ); VectorCopy( trace->plane.normal, ent->pos1 ); - if ( ent->s.weapon != WP_SABER - && ent->s.weapon != WP_THERMAL + if ( ent->s.weapon != WP_SABER + && ent->s.weapon != WP_THERMAL && ent->e_clThinkFunc != clThinkF_CG_Limb && ent->e_ThinkFunc != thinkF_LimbThink ) {//not a saber, bouncing thermal or limb @@ -430,7 +430,7 @@ void G_BounceMissile( gentity_t *ent, trace_t *trace ) { ent->owner = NULL; } } - + /* ================ G_MissileImpact @@ -444,15 +444,15 @@ extern qboolean W_AccuracyLoggableWeapon( int weapon, qboolean alt_fire, int mod void G_MissileImpacted( gentity_t *ent, gentity_t *other, vec3_t impactPos, vec3_t normal, int hitLoc=HL_NONE ) { // impact damage - if ( other->takedamage ) + if ( other->takedamage ) { // FIXME: wrong damage direction? - if ( ent->damage ) + if ( ent->damage ) { vec3_t velocity; EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity ); - if ( VectorLength( velocity ) == 0 ) + if ( VectorLength( velocity ) == 0 ) { velocity[2] = 1; // stepped on a grenade } @@ -481,7 +481,7 @@ void G_MissileImpacted( gentity_t *ent, gentity_t *other, vec3_t impactPos, vec3 } G_Damage( other, ent, ent->owner, velocity, - impactPos, damage, + impactPos, damage, ent->dflags, ent->methodOfDeath, hitLoc); } } @@ -489,13 +489,13 @@ void G_MissileImpacted( gentity_t *ent, gentity_t *other, vec3_t impactPos, vec3 // is it cheaper in bandwidth to just remove this ent and create a new // one, rather than changing the missile into the explosion? //G_FreeEntity(ent); - - if ( (other->takedamage && other->client ) || (ent->s.weapon == WP_FLECHETTE && other->contents&CONTENTS_LIGHTSABER) ) + + if ( (other->takedamage && other->client ) || (ent->s.weapon == WP_FLECHETTE && other->contents&CONTENTS_LIGHTSABER) ) { G_AddEvent( ent, EV_MISSILE_HIT, DirToByte( normal ) ); ent->s.otherEntityNum = other->s.number; - } - else + } + else { G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( normal ) ); ent->s.otherEntityNum = other->s.number; @@ -521,9 +521,9 @@ void G_MissileImpacted( gentity_t *ent, gentity_t *other, vec3_t impactPos, vec3 G_SetOrigin( ent, impactPos ); // splash damage (doesn't apply to person directly hit) - if ( ent->splashDamage ) + if ( ent->splashDamage ) { - G_RadiusDamage( impactPos, ent->owner, ent->splashDamage, ent->splashRadius, + G_RadiusDamage( impactPos, ent->owner, ent->splashDamage, ent->splashRadius, other, ent->splashMethodOfDeath ); } @@ -547,7 +547,7 @@ static void G_MissileAddAlerts( gentity_t *ent ) } //------------------------------------------------------ -void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) +void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) { gentity_t *other; vec3_t diff; @@ -573,7 +573,7 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) { if ( !ent->lastEnemy || ent->lastEnemy == ent->owner ) {//a missile that was not reflected or, if so, still is owned by original owner - if( LogAccuracyHit( other, ent->owner ) ) + if( LogAccuracyHit( other, ent->owner ) ) { ent->owner->client->ps.persistant[PERS_ACCURACY_HITS]++; } @@ -630,10 +630,10 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) } } - if ( bounce ) + if ( bounce ) { // Check to see if there is a bounce count - if ( ent->bounceCount ) + if ( ent->bounceCount ) { // decrement number of bounces and then see if it should be done bouncing if ( !(--ent->bounceCount) ) { @@ -648,8 +648,8 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) } G_BounceMissile( ent, trace ); - - if ( ent->owner )//&& ent->owner->s.number == 0 ) + + if ( ent->owner )//&& ent->owner->s.number == 0 ) { G_MissileAddAlerts( ent ); } @@ -657,10 +657,10 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) return; } - + // I would glom onto the EF_BOUNCE code section above, but don't feel like risking breaking something else - if ( (!other->takedamage && ( ent->s.eFlags&(EF_BOUNCE_SHRAPNEL) ) ) - || ((trace->surfaceFlags&SURF_FORCEFIELD)&&!ent->splashDamage&&!ent->splashRadius) ) + if ( (!other->takedamage && ( ent->s.eFlags&(EF_BOUNCE_SHRAPNEL) ) ) + || ((trace->surfaceFlags&SURF_FORCEFIELD)&&!ent->splashDamage&&!ent->splashRadius) ) { if ( !(other->contents&CONTENTS_LIGHTSABER) || g_spskill->integer <= 0//on easy, it reflects all shots @@ -680,11 +680,11 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) } if ( (!other->takedamage || (other->client && other->health <= 0)) - && ent->s.weapon == WP_THERMAL + && ent->s.weapon == WP_THERMAL && !ent->alt_fire ) {//rolling thermal det - FIXME: make this an eFlag like bounce & stick!!! //G_BounceRollMissile( ent, trace ); - if ( ent->owner )//&& ent->owner->s.number == 0 ) + if ( ent->owner )//&& ent->owner->s.number == 0 ) { G_MissileAddAlerts( ent ); } @@ -693,9 +693,9 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) } // check for sticking - if ( ent->s.eFlags & EF_MISSILE_STICK ) + if ( ent->s.eFlags & EF_MISSILE_STICK ) { - if ( ent->owner )//&& ent->owner->s.number == 0 ) + if ( ent->owner )//&& ent->owner->s.number == 0 ) { //Add the event if ( ent->s.weapon == WP_TRIP_MINE ) @@ -730,9 +730,9 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace, int hitLoc=HL_NONE ) || (g_spskill->integer >= 2 && ent->s.weapon != WP_FLECHETTE && ent->s.weapon != WP_DEMP2 && ent->s.weapon != WP_BOWCASTER && ent->s.weapon != WP_REPEATER )//on hard it won't reflect flechette, demp, repeater or bowcaster shots ) && (!ent->splashDamage || !ent->splashRadius) )//this would be cool, though, to "bat" the thermal det away... - { + { //FIXME: take other's owner's FP_SABER_DEFENSE into account here somehow? - if ( !other->owner || !other->owner->client || other->owner->client->ps.saberInFlight || InFront( ent->currentOrigin, other->owner->currentOrigin, other->owner->client->ps.viewangles, SABER_REFLECT_MISSILE_CONE ) )//other->owner->s.number != 0 || + if ( !other->owner || !other->owner->client || other->owner->client->ps.saberInFlight || InFront( ent->currentOrigin, other->owner->currentOrigin, other->owner->client->ps.viewangles, SABER_REFLECT_MISSILE_CONE ) )//other->owner->s.number != 0 || {//Jedi cannot block shots from behind! if ( (other->owner->client->ps.forcePowerLevel[FP_SABER_DEFENSE] > FORCE_LEVEL_1 && Q_irand( 0, 3 )) ||(other->owner->client->ps.forcePowerLevel[FP_SABER_DEFENSE] > FORCE_LEVEL_0 && Q_irand( 0, 1 ))) @@ -770,7 +770,7 @@ G_ExplodeMissile Explode a missile without an impact ================ */ -void G_ExplodeMissile( gentity_t *ent ) +void G_ExplodeMissile( gentity_t *ent ) { vec3_t dir; vec3_t origin; @@ -795,7 +795,7 @@ void G_ExplodeMissile( gentity_t *ent ) ent->freeAfterEvent = qtrue;*/ // splash damage - if ( ent->splashDamage ) + if ( ent->splashDamage ) { G_RadiusDamage( ent->currentOrigin, ent->owner, ent->splashDamage, ent->splashRadius, NULL , ent->splashMethodOfDeath ); @@ -814,7 +814,7 @@ void G_RunStuckMissile( gentity_t *ent ) { gentity_t *other = &g_entities[ent->s.groundEntityNum]; - if ( (!VectorCompare( vec3_origin, other->s.pos.trDelta ) && other->s.pos.trType != TR_STATIONARY) || + if ( (!VectorCompare( vec3_origin, other->s.pos.trDelta ) && other->s.pos.trType != TR_STATIONARY) || (!VectorCompare( vec3_origin, other->s.apos.trDelta ) && other->s.apos.trType != TR_STATIONARY) ) {//thing I stuck to is moving or rotating now, kill me G_Damage( ent, other, other, NULL, NULL, 99999, 0, MOD_CRUSH ); @@ -846,7 +846,7 @@ int G_GroundTrace( gentity_t *ent, pml_t *pPml ) pPml->groundTrace = trace; // do something corrective if the trace starts in a solid... - if ( trace.allsolid ) + if ( trace.allsolid ) { pPml->groundPlane = qfalse; pPml->walking = qfalse; @@ -854,7 +854,7 @@ int G_GroundTrace( gentity_t *ent, pml_t *pPml ) } // if the trace didn't hit anything, we are in free fall - if ( trace.fraction == 1.0 ) + if ( trace.fraction == 1.0 ) { pPml->groundPlane = qfalse; pPml->walking = qfalse; @@ -862,15 +862,15 @@ int G_GroundTrace( gentity_t *ent, pml_t *pPml ) } // check if getting thrown off the ground - if ( ent->s.pos.trDelta[2] > 0 && DotProduct( ent->s.pos.trDelta, trace.plane.normal ) > 10 ) + if ( ent->s.pos.trDelta[2] > 0 && DotProduct( ent->s.pos.trDelta, trace.plane.normal ) > 10 ) { pPml->groundPlane = qfalse; pPml->walking = qfalse; return ENTITYNUM_NONE; } - + // slopes that are too steep will not be considered onground - if ( trace.plane.normal[2] < MIN_WALK_NORMAL ) + if ( trace.plane.normal[2] < MIN_WALK_NORMAL ) { pPml->groundPlane = qtrue; pPml->walking = qfalse; @@ -881,7 +881,7 @@ int G_GroundTrace( gentity_t *ent, pml_t *pPml ) pPml->walking = qtrue; /* - if ( ent->s.groundEntityNum == ENTITYNUM_NONE ) + if ( ent->s.groundEntityNum == ENTITYNUM_NONE ) { // just hit the ground } @@ -895,11 +895,11 @@ int G_GroundTrace( gentity_t *ent, pml_t *pPml ) G_RollMissile -reworking the rolling object code, -still needs to stop bobbling up & down, -need to get roll angles right, -and need to maybe make the transfer of velocity happen on impacts? -Also need bounce sound for bounces off a floor. +reworking the rolling object code, +still needs to stop bobbling up & down, +need to get roll angles right, +and need to maybe make the transfer of velocity happen on impacts? +Also need bounce sound for bounces off a floor. Also need to not bounce as much off of enemies Also gets stuck inside thrower if looking down when thrown @@ -928,11 +928,11 @@ void G_RollMissile( gentity_t *ent ) gentity_t *hitEnt = NULL; memset( &objPML, 0, sizeof( objPML ) ); - + G_GroundTrace( ent, &objPML ); objPML.frametime = (level.time - level.previousTime)*0.001; - + numbumps = 4; VectorCopy ( ent->s.pos.trDelta, primal_velocity ); @@ -941,7 +941,7 @@ void G_RollMissile( gentity_t *ent ) endVelocity[2] -= g_gravity->value * objPML.frametime; ent->s.pos.trDelta[2] = ( ent->s.pos.trDelta[2] + endVelocity[2] ) * 0.5; primal_velocity[2] = endVelocity[2]; - if ( objPML.groundPlane ) + if ( objPML.groundPlane ) {//FIXME: never happens! // slide along the ground plane PM_ClipVelocity( ent->s.pos.trDelta, objPML.groundTrace.plane.normal, ent->s.pos.trDelta, BUMPCLIP ); @@ -951,12 +951,12 @@ void G_RollMissile( gentity_t *ent ) time_left = objPML.frametime; // never turn against the ground plane - if ( objPML.groundPlane ) + if ( objPML.groundPlane ) { numplanes = 1; VectorCopy( objPML.groundTrace.plane.normal, planes[0] ); - } - else + } + else { numplanes = 0; } @@ -967,7 +967,7 @@ void G_RollMissile( gentity_t *ent ) numplanes++; */ - for ( bumpcount = 0; bumpcount < numbumps; bumpcount++ ) + for ( bumpcount = 0; bumpcount < numbumps; bumpcount++ ) { // calculate position we are trying to move to VectorMA( ent->currentOrigin, time_left, ent->s.pos.trDelta, end ); @@ -999,13 +999,13 @@ void G_RollMissile( gentity_t *ent ) return;// qtrue; } - if ( trace.fraction > 0 ) + if ( trace.fraction > 0 ) { // actually covered some distance VectorCopy( trace.endpos, ent->currentOrigin ); } - if ( trace.fraction == 1 ) + if ( trace.fraction == 1 ) { break; // moved the entire distance } @@ -1025,7 +1025,7 @@ void G_RollMissile( gentity_t *ent ) time_left -= time_left * trace.fraction; - if ( numplanes >= MAX_CLIP_PLANES ) + if ( numplanes >= MAX_CLIP_PLANES ) { // this shouldn't really happen VectorClear( ent->s.pos.trDelta ); @@ -1037,15 +1037,15 @@ void G_RollMissile( gentity_t *ent ) // out along it, which fixes some epsilon issues with // non-axial planes // - for ( i = 0 ; i < numplanes ; i++ ) + for ( i = 0 ; i < numplanes ; i++ ) { - if ( DotProduct( trace.plane.normal, planes[i] ) > 0.99 ) + if ( DotProduct( trace.plane.normal, planes[i] ) > 0.99 ) { VectorAdd( trace.plane.normal, ent->s.pos.trDelta, ent->s.pos.trDelta ); break; } } - if ( i < numplanes ) + if ( i < numplanes ) { continue; } @@ -1055,7 +1055,7 @@ void G_RollMissile( gentity_t *ent ) // // modify velocity so it parallels all of the clip planes // - if ( g_entities[trace.entityNum].inuse && g_entities[trace.entityNum].client ) + if ( g_entities[trace.entityNum].inuse && g_entities[trace.entityNum].client ) {//hit a person, bounce off much less bounceAmt = OVERCLIP; } @@ -1065,16 +1065,16 @@ void G_RollMissile( gentity_t *ent ) } // find a plane that it enters - for ( i = 0 ; i < numplanes ; i++ ) + for ( i = 0 ; i < numplanes ; i++ ) { into = DotProduct( ent->s.pos.trDelta, planes[i] ); - if ( into >= 0.1 ) + if ( into >= 0.1 ) { continue; // move doesn't interact with the plane } // see how hard we are hitting things - if ( -into > pml.impactSpeed ) + if ( -into > pml.impactSpeed ) { pml.impactSpeed = -into; } @@ -1086,13 +1086,13 @@ void G_RollMissile( gentity_t *ent ) PM_ClipVelocity( endVelocity, planes[i], endClipVelocity, bounceAmt ); // see if there is a second plane that the new move enters - for ( j = 0 ; j < numplanes ; j++ ) + for ( j = 0 ; j < numplanes ; j++ ) { - if ( j == i ) + if ( j == i ) { continue; } - if ( DotProduct( clipVelocity, planes[j] ) >= 0.1 ) + if ( DotProduct( clipVelocity, planes[j] ) >= 0.1 ) { continue; // move doesn't interact with the plane } @@ -1102,7 +1102,7 @@ void G_RollMissile( gentity_t *ent ) PM_ClipVelocity( endClipVelocity, planes[j], endClipVelocity, bounceAmt ); // see if it goes back into the first clip plane - if ( DotProduct( clipVelocity, planes[i] ) >= 0 ) + if ( DotProduct( clipVelocity, planes[i] ) >= 0 ) { continue; } @@ -1119,13 +1119,13 @@ void G_RollMissile( gentity_t *ent ) VectorScale( dir, d, endClipVelocity ); // see if there is a third plane the the new move enters - for ( k = 0 ; k < numplanes ; k++ ) + for ( k = 0 ; k < numplanes ; k++ ) { - if ( k == i || k == j ) + if ( k == i || k == j ) { continue; } - if ( DotProduct( clipVelocity, planes[k] ) >= 0.1 ) + if ( DotProduct( clipVelocity, planes[k] ) >= 0.1 ) { continue; // move doesn't interact with the plane } @@ -1148,7 +1148,7 @@ void G_RollMissile( gentity_t *ent ) // don't change velocity if in a timer (FIXME: is this correct?) /* - if ( pm->ps->pm_time ) + if ( pm->ps->pm_time ) { VectorCopy( primal_velocity, ent->s.pos.trDelta ); } @@ -1163,7 +1163,7 @@ G_RunMissile ================ */ void G_MoverTouchPushTriggers( gentity_t *ent, vec3_t oldOrg ); -void G_RunMissile( gentity_t *ent ) +void G_RunMissile( gentity_t *ent ) { vec3_t origin, oldOrg; trace_t tr; @@ -1190,7 +1190,7 @@ void G_RunMissile( gentity_t *ent ) { vec3_t ang, fwdDir, rtDir; float speed; - + ent->s.apos.trType = TR_INTERPOLATE; VectorSet( ang, 0, ent->s.apos.trBase[1], 0 ); AngleVectors( ang, fwdDir, rtDir, NULL ); @@ -1216,21 +1216,21 @@ void G_RunMissile( gentity_t *ent ) // trace a line from the previous position to the current position, // ignoring interactions with the missile owner /* - gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, + gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, ent->owner ? ent->owner->s.number : ENTITYNUM_NONE, ent->clipmask, G2_RETURNONHIT, 10 ); */ - gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, + gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, ent->owner ? ent->owner->s.number : ent->s.number, ent->clipmask, G2_COLLIDE, 10 ); /* if ( !VectorCompare( ent->mins, vec3_origin ) || !VectorCompare( ent->maxs, vec3_origin ) ) {//don't do ghoul trace if ent has size because g2 just ignores that anyway - gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, + gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, ent->owner ? ent->owner->s.number : ENTITYNUM_NONE, ent->clipmask, G2_NOCOLLIDE, 10 ); } else //Now we always do ghoul trace, regardless of bbox size of missile, this is presuming that non-point ghoul traces will be possible...? { - gi.trace( &tr, ent->currentOrigin, vec3_origin, vec3_origin, origin, + gi.trace( &tr, ent->currentOrigin, vec3_origin, vec3_origin, origin, ent->owner ? ent->owner->s.number : ENTITYNUM_NONE, ent->clipmask, G2_RETURNONHIT, 10 ); } */ @@ -1245,7 +1245,7 @@ void G_RunMissile( gentity_t *ent ) EvaluateTrajectory( &ent->s.pos, level.time, origin ); // trace a line from the previous position to the current position, // ignoring interactions with the missile owner - gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, + gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, ent->owner ? ent->owner->s.number : ENTITYNUM_NONE, ent->clipmask | CONTENTS_GHOUL2 ); if ( tr.fraction == 1.0f ) { @@ -1280,7 +1280,7 @@ void G_RunMissile( gentity_t *ent ) //FIXME: Rolling things hitting G2 polys is weird /////////////////////////////////////////////////////// -//? if ( tr.fraction != 1 ) +//? if ( tr.fraction != 1 ) { // did we hit or go near a Ghoul2 model? // qboolean hitModel = qfalse; @@ -1330,7 +1330,7 @@ void G_RunMissile( gentity_t *ent ) // now attach an effect to this new bolt // Bolting on this effect just looks dumb and adds lots of unnecessary effects to the scene -// +// // G_PlayEffect( G_EffectIndex( "blaster/smoke_bolton") , coll.mModelIndex, newBolt, hitEnt->s.number); // // @@ -1349,7 +1349,7 @@ void G_RunMissile( gentity_t *ent ) } ///////////////////////////////////////////////////////// - if ( tr.startsolid ) + if ( tr.startsolid ) { tr.fraction = 0; } @@ -1365,7 +1365,7 @@ void G_RunMissile( gentity_t *ent ) // check think function G_RunThink( ent ); - if ( ent->s.eType != ET_MISSILE ) + if ( ent->s.eType != ET_MISSILE ) { return; // exploded } @@ -1397,7 +1397,7 @@ void G_RunMissile( gentity_t *ent ) if ( ent->s.weapon == WP_TRIP_MINE ) {//??? } - else + else { if ( ent->s.weapon == WP_ROCKET_LAUNCHER && ent->e_ThinkFunc == thinkF_rocketThink ) {//homing rocket- run like hell! @@ -1416,13 +1416,13 @@ void G_RunMissile( gentity_t *ent ) } } - if ( tr.fraction == 1 ) + if ( tr.fraction == 1 ) { return; } // never explode or bounce on sky - if ( tr.surfaceFlags & SURF_NOIMPACT ) + if ( tr.surfaceFlags & SURF_NOIMPACT ) { G_FreeEntity( ent ); return; diff --git a/codeJK2/game/g_object.cpp b/codeJK2/game/g_object.cpp index 100c93965d..c4d35c7b26 100644 --- a/codeJK2/game/g_object.cpp +++ b/codeJK2/game/g_object.cpp @@ -34,7 +34,7 @@ G_BounceMissile ================ */ -void G_BounceObject( gentity_t *ent, trace_t *trace ) +void G_BounceObject( gentity_t *ent, trace_t *trace ) { vec3_t velocity; float dot; @@ -52,7 +52,7 @@ void G_BounceObject( gentity_t *ent, trace_t *trace ) VectorMA( velocity, -2*dot*bounceFactor, trace->plane.normal, ent->s.pos.trDelta ); //FIXME: customized or material-based impact/bounce sounds - if ( ent->s.eFlags & EF_BOUNCE_HALF ) + if ( ent->s.eFlags & EF_BOUNCE_HALF ) { VectorScale( ent->s.pos.trDelta, 0.5, ent->s.pos.trDelta ); @@ -90,14 +90,14 @@ G_RunObject */ extern void DoImpact( gentity_t *self, gentity_t *other, qboolean damageSelf ); extern void pitch_roll_for_slope( gentity_t *forwhom, vec3_t pass_slope ); -void G_RunObject( gentity_t *ent ) +void G_RunObject( gentity_t *ent ) { vec3_t origin, oldOrg; trace_t tr; gentity_t *traceEnt = NULL; //FIXME: floaters need to stop floating up after a while, even if gravity stays negative? - if ( ent->s.pos.trType == TR_STATIONARY )//g_gravity->value <= 0 && + if ( ent->s.pos.trType == TR_STATIONARY )//g_gravity->value <= 0 && { ent->s.pos.trType = TR_GRAVITY; VectorCopy( ent->currentOrigin, ent->s.pos.trBase ); @@ -122,16 +122,16 @@ void G_RunObject( gentity_t *ent ) } // trace a line from the previous position to the current position, // ignoring interactions with the missile owner - gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, + gi.trace( &tr, ent->currentOrigin, ent->mins, ent->maxs, origin, ent->owner ? ent->owner->s.number : ent->s.number, ent->clipmask, G2_NOCOLLIDE, 0 ); - if ( !tr.startsolid && !tr.allsolid && tr.fraction ) + if ( !tr.startsolid && !tr.allsolid && tr.fraction ) { VectorCopy( tr.endpos, ent->currentOrigin ); gi.linkentity( ent ); } else - //if ( tr.startsolid ) + //if ( tr.startsolid ) { tr.fraction = 0; } @@ -152,7 +152,7 @@ void G_RunObject( gentity_t *ent ) } */ - if ( tr.fraction == 1 ) + if ( tr.fraction == 1 ) { if ( g_gravity->value <= 0 ) { @@ -208,7 +208,7 @@ void G_RunObject( gentity_t *ent ) } //do impact physics - if ( ent->s.pos.trType == TR_GRAVITY )//tr.fraction < 1.0 && + if ( ent->s.pos.trType == TR_GRAVITY )//tr.fraction < 1.0 && {//FIXME: only do this if no trDelta if ( g_gravity->value <= 0 || tr.plane.normal[2] < 0.7 ) { @@ -303,7 +303,7 @@ void G_StartObjectMoving( gentity_t *object, vec3_t dir, float speed, trType_t t } } -gentity_t *G_CreateObject ( gentity_t *owner, vec3_t origin, vec3_t angles, int modelIndex, int frame, trType_t trType ) +gentity_t *G_CreateObject ( gentity_t *owner, vec3_t origin, vec3_t angles, int modelIndex, int frame, trType_t trType ) { gentity_t *object; diff --git a/codeJK2/game/g_objectives.cpp b/codeJK2/game/g_objectives.cpp index c5291543c9..7aa6ef469e 100644 --- a/codeJK2/game/g_objectives.cpp +++ b/codeJK2/game/g_objectives.cpp @@ -47,7 +47,7 @@ void OBJ_SetPendingObjectives(gentity_t *ent) for (i=0;iclient->sess.mission_objectives[i].status == OBJECTIVE_STAT_PENDING) && + if ((ent->client->sess.mission_objectives[i].status == OBJECTIVE_STAT_PENDING) && (ent->client->sess.mission_objectives[i].display)) { ent->client->sess.mission_objectives[i].status = OBJECTIVE_STAT_FAILED; diff --git a/codeJK2/game/g_public.h b/codeJK2/game/g_public.h index 7186c4734e..b23c5c9e92 100644 --- a/codeJK2/game/g_public.h +++ b/codeJK2/game/g_public.h @@ -112,7 +112,7 @@ struct gentity_s { Ghoul2 Insert Start */ // this marker thing of Jake's is used for memcpy() length calcs, so don't put any ordinary fields (like above) - // below this point or they won't work, and will mess up all sorts of stuff. + // below this point or they won't work, and will mess up all sorts of stuff. // CGhoul2Info_v ghoul2; /* @@ -211,12 +211,12 @@ typedef struct { void (*SetBrushModel)( gentity_t *ent, const char *name ); // collision detection against all linked entities - void (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, + void (*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 ); // point contents against all linked entities int (*pointcontents)( const vec3_t point, int passEntityNum ); - // what contents are on the map? + // what contents are on the map? int (*totalMapContents)(); qboolean (*inPVS)( const vec3_t p1, const vec3_t p2 ); @@ -264,7 +264,7 @@ Ghoul2 Insert Start qboolean (*G2API_SetBoneAnglesMatrix)(CGhoul2Info *ghlInfo, const char *boneName, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, int blendTime , int currentTime ); void (*G2API_CopyGhoul2Instance)(CGhoul2Info_v &ghoul2From, CGhoul2Info_v &ghoul2To, int modelIndex ); - qboolean (*G2API_SetBoneAnimIndex)(CGhoul2Info *ghlInfo, const int index, const int startFrame, const int endFrame, const int flags, + 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_SetLodBias)(CGhoul2Info *ghlInfo, int lodBias); @@ -295,7 +295,7 @@ Ghoul2 Insert Start 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, + 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, const vec3_t scale); void (*G2API_ListSurfaces)(CGhoul2Info *ghlInfo); @@ -384,7 +384,7 @@ typedef struct { // init and shutdown will be called every single level // levelTime will be near zero, while globalTime will be a large number // that can be used to track spectator entry times across restarts - void (*Init)( const char *mapname, const char *spawntarget, int checkSum, const char *entstring, + void (*Init)( const char *mapname, const char *spawntarget, int checkSum, const char *entstring, int levelTime, int randomSeed, int globalTime, SavedGameJustLoaded_e eSavedGameJustLoaded, qboolean qbLoadTransition ); void (*Shutdown) (void); @@ -423,7 +423,7 @@ typedef struct { // The gentities array is allocated in the game dll so it // can vary in size from one game to another. - // + // // The size will be fixed when ge->Init() is called // the server can't just use pointer arithmetic on gentities, because the // server's sizeof(struct gentity_s) doesn't equal gentitySize diff --git a/codeJK2/game/g_roff.cpp b/codeJK2/game/g_roff.cpp index b1c9539e26..b035f57fb2 100644 --- a/codeJK2/game/g_roff.cpp +++ b/codeJK2/game/g_roff.cpp @@ -337,7 +337,7 @@ qboolean G_InitRoff( char *file, unsigned char *data ) count = LittleLong(hdr->mCount); roffs[num_roffs].frames = count; - roffs[num_roffs].data = (void *) G_Alloc( count * sizeof( move_rotate2_t )); + roffs[num_roffs].data = (void *) G_Alloc( count * sizeof( move_rotate2_t )); move_rotate2_t *mem = (move_rotate2_t *)roffs[num_roffs].data; if ( mem ) @@ -486,7 +486,7 @@ void G_Roff( gentity_t *ent ) { return; } - + if ( ent->next_roff_time > level.time ) {// either I don't think or it's just not time to have me think yet return; @@ -523,7 +523,7 @@ void G_Roff( gentity_t *ent ) #ifdef _DEBUG if ( g_developer->integer ) { - Com_Printf( S_COLOR_GREEN"ROFF dat: num: %d o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", + Com_Printf( S_COLOR_GREEN"ROFF dat: num: %d o:<%.2f %.2f %.2f> a:<%.2f %.2f %.2f>\n", ent->roff_ctr, org[0], org[1], org[2], ang[0], ang[1], ang[2] ); @@ -584,7 +584,7 @@ void G_Roff( gentity_t *ent ) //make it true linear... FIXME: sticks around after ROFF is done, but do we really care? ent->alt_fire = qtrue; - if ( !ent->e_ThinkFunc + if ( !ent->e_ThinkFunc && ent->s.eType != ET_MISSILE && ent->s.eType != ET_ITEM && ent->s.eType != ET_MOVER ) diff --git a/codeJK2/game/g_roff.h b/codeJK2/game/g_roff.h index 666adb6f49..239e2bc963 100644 --- a/codeJK2/game/g_roff.h +++ b/codeJK2/game/g_roff.h @@ -40,9 +40,9 @@ along with this program; if not, see . typedef struct roff_hdr_s { char mHeader[4]; // should be "ROFF" (Rotation, Origin File Format) - int mVersion; + int mVersion; float mCount; // There isn't any reason for this to be anything other than an int, sigh... - // + // // Move - Rotate data follows....vec3_t delta_origin, vec3_t delta_rotation // } roff_hdr_t; diff --git a/codeJK2/game/g_shared.h b/codeJK2/game/g_shared.h index 3bd444940c..2077d65be7 100644 --- a/codeJK2/game/g_shared.h +++ b/codeJK2/game/g_shared.h @@ -37,7 +37,7 @@ typedef struct centity_s centity_t; class CSequencer; class CTaskManager; -enum +enum { HL_NONE = 0, HL_FOOT_RT, @@ -202,7 +202,7 @@ class clientInfo_t //================================================================== -typedef enum +typedef enum { MOVER_POS1, MOVER_POS2, @@ -237,7 +237,7 @@ typedef struct modelInfo_s } } modelInfo_t; -typedef enum +typedef enum { MODEL_LEGS = 0, MODEL_TORSO, @@ -260,7 +260,7 @@ class renderInfo_t // Legs model, or full model on one piece entities union { - modelInfo_t legsModel; + modelInfo_t legsModel; modelInfo_t model; }; @@ -645,7 +645,7 @@ class clientSession_t class clientPersistant_t { public: - clientConnected_t connected; + clientConnected_t connected; usercmd_t lastCommand; qboolean localClient; // true if "ip" info key is "localhost" char netname[34]; @@ -753,7 +753,7 @@ class gclient_t // timeResidual is used to handle events that happen every second // like health / armor countdowns and regeneration int timeResidual; - + // Facial Expression Timers float facial_blink; // time before next blink. If a minus value, we are in blink mode @@ -996,7 +996,7 @@ struct gentity_s { Ghoul2 Insert Start */ // this marker thing of Jake's is used for memcpy() length calcs, so don't put any ordinary fields (like above) - // below this point or they won't work, and will mess up all sorts of stuff. + // below this point or they won't work, and will mess up all sorts of stuff. // CGhoul2Info_v ghoul2; /* @@ -1021,7 +1021,7 @@ Ghoul2 Insert End char *model2; // Torso model int freetime; // sv.time when the object was freed - + int eventTime; // events will be cleared EVENT_VALID_MSEC after set qboolean freeAfterEvent; qboolean unlinkAfterEvent; @@ -1060,7 +1060,7 @@ Ghoul2 Insert End int roff_ctr; // current roff frame we are playing - int next_roff_time; + int next_roff_time; int fx_time; // timer for beam in/out effects. //Think Functions @@ -1197,7 +1197,7 @@ Ghoul2 Insert End qhandle_t cinematicModel; //========================================================================================== - + //FIELDS USED EXCLUSIVELY BY SPECIFIC CLASSES OF ENTITIES //NPC/Player entity fields //FIXME: Make these client only? @@ -1233,7 +1233,7 @@ Ghoul2 Insert End //Variables used only by waypoints (for the most part) float radius; - + union { int wpIndex; @@ -1251,7 +1251,7 @@ Ghoul2 Insert End }; //FIXME: Are these being used anymore? - gitem_t *item; // for bonus items - + gitem_t *item; // for bonus items - char *message; //Used by triggers to print a message when activated float lightLevel; diff --git a/codeJK2/game/g_spawn.cpp b/codeJK2/game/g_spawn.cpp index 9e3672d21e..660e571aa3 100644 --- a/codeJK2/game/g_spawn.cpp +++ b/codeJK2/game/g_spawn.cpp @@ -100,9 +100,9 @@ qboolean G_SpawnVector4( const char *key, const char *defaultString, float *out qboolean G_SpawnFlag( const char *key, int flag, int *out ) { //find that key - for ( int i = 0 ; i < numSpawnVars ; i++ ) + for ( int i = 0 ; i < numSpawnVars ; i++ ) { - if ( !strcmp( key, spawnVars[i][0] ) ) + if ( !strcmp( key, spawnVars[i][0] ) ) { //found the key if ( atoi( spawnVars[i][1] ) != 0 ) @@ -147,7 +147,7 @@ stringID_table_t flagTable [] = // fields are needed for spawning from the entity string // typedef enum { - F_INT, + F_INT, F_FLOAT, F_LSTRING, // string on disk, pointer in memory, TAG_LEVEL F_GSTRING, // string on disk, pointer in memory, TAG_GAME @@ -578,7 +578,7 @@ spawn_t spawns[] = { {"misc_ion_cannon", SP_misc_ion_cannon}, {"misc_sentry_turret", SP_PAS}, {"misc_maglock", SP_misc_maglock}, - + {"misc_model_ghoul", SP_misc_model_ghoul}, {"misc_model_breakable", SP_misc_model_breakable}, {"misc_portal_surface", SP_misc_portal_surface}, @@ -609,7 +609,7 @@ spawn_t spawns[] = { {"misc_atst_drivable", SP_misc_atst_drivable}, {"misc_cubemap", SP_misc_cubemap}, - + {"shooter_rocket", SP_shooter_rocket}, {"shooter_grenade", SP_shooter_grenade}, {"shooter_plasma", SP_shooter_plasma}, @@ -677,7 +677,7 @@ spawn_t spawns[] = { {"waypoint_navgoal_4", SP_waypoint_navgoal_4}, {"waypoint_navgoal_2", SP_waypoint_navgoal_2}, {"waypoint_navgoal_1", SP_waypoint_navgoal_1}, - + {"fx_runner", SP_fx_runner}, {"fx_explosion_trail", SP_fx_explosion_trail}, {"fx_target_beam", SP_fx_target_beam}, @@ -768,7 +768,7 @@ char *G_NewString( const char *string ) { *new_p++ = string[i]; } } - + return newb; } @@ -1009,7 +1009,7 @@ qboolean G_ParseSpawnVars( const char **data ) { } // go through all the key / value pairs - while ( 1 ) { + while ( 1 ) { // parse key com_token = COM_Parse( data ); if ( com_token[0] == '}' ) { @@ -1021,8 +1021,8 @@ qboolean G_ParseSpawnVars( const char **data ) { } Q_strncpyz( keyname, com_token, sizeof(keyname) ); - - // parse value + + // parse value com_token = COM_Parse( data ); if ( com_token[0] == '}' ) { COM_EndParseSession(); @@ -1045,7 +1045,7 @@ qboolean G_ParseSpawnVars( const char **data ) { return qtrue; } -static char *defaultStyles[LS_NUM_STYLES][3] = +static char *defaultStyles[LS_NUM_STYLES][3] = { { // 0 normal "z", @@ -1233,7 +1233,7 @@ void SP_worldspawn( void ) { int i; gi.cvar_set( "region", "0" ); - for ( i = 0 ; i < numSpawnVars ; i++ ) + for ( i = 0 ; i < numSpawnVars ; i++ ) { if ( Q_stricmp( "spawnscript", spawnVars[i][0] ) == 0 ) {//ONly let them set spawnscript, we don't want them setting an angle or something on the world. @@ -1294,10 +1294,10 @@ void SP_worldspawn( void ) { if (lengthRed != lengthGreen || lengthGreen != lengthBlue) { - Com_Error(ERR_DROP, "Style %d has inconsistent lengths: R %d, G %d, B %d", + Com_Error(ERR_DROP, "Style %d has inconsistent lengths: R %d, G %d, B %d", i, lengthRed, lengthGreen, lengthBlue); } - } + } g_entities[ENTITYNUM_WORLD].s.number = ENTITYNUM_WORLD; g_entities[ENTITYNUM_WORLD].classname = "worldspawn"; @@ -1368,14 +1368,14 @@ void G_SpawnEntitiesFromString( const char *entityString ) { if ( !G_ParseSpawnVars( &entities ) ) { G_Error( "SpawnEntities: no entities" ); } - + SP_worldspawn(); // parse ents - while( G_ParseSpawnVars( &entities ) ) + while( G_ParseSpawnVars( &entities ) ) { G_SpawnGEntityFromSpawnVars(); - } + } //Search the entities for precache information G_ParsePrecaches(); diff --git a/codeJK2/game/g_svcmds.cpp b/codeJK2/game/g_svcmds.cpp index 40d45801dc..58ea2eab45 100644 --- a/codeJK2/game/g_svcmds.cpp +++ b/codeJK2/game/g_svcmds.cpp @@ -176,9 +176,9 @@ extern cvar_t *g_skippingcin; gentity_t *G_GetSelfForPlayerCmd( void ) { - if ( g_entities[0].client->ps.viewEntity > 0 - && g_entities[0].client->ps.viewEntity < ENTITYNUM_WORLD - && g_entities[g_entities[0].client->ps.viewEntity].client + if ( g_entities[0].client->ps.viewEntity > 0 + && g_entities[0].client->ps.viewEntity < ENTITYNUM_WORLD + && g_entities[g_entities[0].client->ps.viewEntity].client && g_entities[g_entities[0].client->ps.viewEntity].s.weapon == WP_SABER ) {//you're controlling another NPC return (&g_entities[g_entities[0].client->ps.viewEntity]); @@ -199,7 +199,7 @@ static void Svcmd_SaberColor_f() return; } - + gentity_t *self = G_GetSelfForPlayerCmd(); if ( !Q_stricmp( color, "red" )) @@ -259,7 +259,7 @@ static void Svcmd_ForceSetLevel_f( int forcePower ) { return; } - if ( !g_cheats->integer ) + if ( !g_cheats->integer ) { gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\""); return; @@ -563,7 +563,7 @@ static svcmd_t svcmds[] = { { "ICARUS", Svcmd_ICARUS_f, CMD_CHEAT }, { "saberColor", Svcmd_SaberColor_f, CMD_CHEAT }, - + { "setForceJump", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setSaberThrow", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setForceHeal", Svcmd_ForceSetLevel_f, CMD_CHEAT }, @@ -577,20 +577,20 @@ static svcmd_t svcmds[] = { { "setSaberOffense", Svcmd_ForceSetLevel_f, CMD_CHEAT }, { "setForceAll", Svcmd_SetForceAll_f, CMD_CHEAT }, { "setSaberAll", Svcmd_SetSaberAll_f, CMD_CHEAT }, - + { "saberAttackCycle", Svcmd_SaberAttackCycle_f, CMD_NONE }, - + { "runscript", Svcmd_RunScript_f, CMD_CHEAT }, - + { "playerTeam", Svcmd_PlayerTeam_f, CMD_CHEAT }, - + { "control", Svcmd_Control_f, CMD_CHEAT }, { "exitview", Svcmd_ExitView_f, CMD_NONE }, - + { "secrets", Svcmd_Secrets_f, CMD_NONE }, { "difficulty", Svcmd_Difficulty_f, CMD_NONE }, - + //{ "say", Svcmd_Say_f, qtrue }, //{ "toggleallowvote", Svcmd_ToggleAllowVote_f, qfalse }, //{ "toggleuserinfovalidation", Svcmd_ToggleUserinfoValidation_f, qfalse }, @@ -608,7 +608,7 @@ qboolean ConsoleCommand( void ) { if ( !command ) return qfalse; - + if ( (command->flags & CMD_CHEAT) && !g_cheats->integer ) { diff --git a/codeJK2/game/g_target.cpp b/codeJK2/game/g_target.cpp index 495a4f96b4..36566852d8 100644 --- a/codeJK2/game/g_target.cpp +++ b/codeJK2/game/g_target.cpp @@ -72,12 +72,12 @@ void SP_target_give( gentity_t *ent ) { "wait" seconds to pause before firing targets. "random" delay variance, total delay = delay +/- random seconds */ -void Think_Target_Delay( gentity_t *ent ) +void Think_Target_Delay( gentity_t *ent ) { G_UseTargets( ent, ent->activator ); } -void Use_Target_Delay( gentity_t *ent, gentity_t *other, gentity_t *activator ) +void Use_Target_Delay( gentity_t *ent, gentity_t *other, gentity_t *activator ) { G_ActivateBehavior(ent,BSET_USE); @@ -86,15 +86,15 @@ void Use_Target_Delay( gentity_t *ent, gentity_t *other, gentity_t *activator ) ent->activator = activator; } -void SP_target_delay( gentity_t *ent ) +void SP_target_delay( gentity_t *ent ) { // check delay for backwards compatability - if ( !G_SpawnFloat( "delay", "0", &ent->wait ) ) + if ( !G_SpawnFloat( "delay", "0", &ent->wait ) ) { G_SpawnFloat( "wait", "1", &ent->wait ); } - if ( !ent->wait ) + if ( !ent->wait ) { ent->wait = 1; } @@ -110,7 +110,7 @@ void SP_target_delay( gentity_t *ent ) The activator is given this many points. */ -void Use_Target_Score (gentity_t *ent, gentity_t *other, gentity_t *activator) +void Use_Target_Score (gentity_t *ent, gentity_t *other, gentity_t *activator) { G_ActivateBehavior(ent,BSET_USE); @@ -131,7 +131,7 @@ void SP_target_score( gentity_t *ent ) { "message" text to print If "private", only the activator gets the message. If no checks, all clients get the message. */ -void Use_Target_Print (gentity_t *ent, gentity_t *other, gentity_t *activator) +void Use_Target_Print (gentity_t *ent, gentity_t *other, gentity_t *activator) { G_ActivateBehavior(ent,BSET_USE); @@ -291,7 +291,7 @@ void target_laser_think (gentity_t *self) { if ( tr.entityNum ) { // hurt it if we can - G_Damage ( &g_entities[tr.entityNum], self, self->activator, self->movedir, + G_Damage ( &g_entities[tr.entityNum], self, self->activator, self->movedir, tr.endpos, self->damage, DAMAGE_NO_KNOCKBACK, MOD_ENERGY ); } @@ -404,18 +404,18 @@ INACTIVE Can't be used until activated "delay" - Will actually fire this many seconds after being used "wait" - Cannot be fired again until this many seconds after the last time it was used */ -void target_relay_use_go (gentity_t *self ) +void target_relay_use_go (gentity_t *self ) { G_ActivateBehavior( self, BSET_USE ); - - if ( self->spawnflags & 4 ) + + if ( self->spawnflags & 4 ) { gentity_t *ent; ent = G_PickTarget( self->target ); - if ( ent && (ent->e_UseFunc != useF_NULL) ) + if ( ent && (ent->e_UseFunc != useF_NULL) ) { // e_UseFunc check can be omitted - GEntity_UseFunc( ent, self, self->activator ); + GEntity_UseFunc( ent, self, self->activator ); } return; } @@ -423,14 +423,14 @@ void target_relay_use_go (gentity_t *self ) G_UseTargets( self, self->activator ); } -void target_relay_use (gentity_t *self, gentity_t *other, gentity_t *activator) +void target_relay_use (gentity_t *self, gentity_t *other, gentity_t *activator) { - if ( ( self->spawnflags & 1 ) && activator->client ) + if ( ( self->spawnflags & 1 ) && activator->client ) {//&& activator->client->ps.persistant[PERS_TEAM] != TEAM_RED ) { return; } - if ( ( self->spawnflags & 2 ) && activator->client ) + if ( ( self->spawnflags & 2 ) && activator->client ) {//&& activator->client->ps.persistant[PERS_TEAM] != TEAM_BLUE ) { return; } @@ -467,7 +467,7 @@ void target_relay_use (gentity_t *self, gentity_t *other, gentity_t *activator) } } -void SP_target_relay (gentity_t *self) +void SP_target_relay (gentity_t *self) { self->e_UseFunc = useF_target_relay_use; self->wait *= 1000; @@ -501,7 +501,7 @@ void target_kill_use( gentity_t *self, gentity_t *other, gentity_t *activator ) else if ( self->spawnflags & 2 ) // electrical { G_Damage ( activator, NULL, NULL, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_ELECTROCUTE ); - + if ( activator->client ) { activator->s.powerups |= ( 1 << PW_SHOCKED ); @@ -514,7 +514,7 @@ void target_kill_use( gentity_t *self, gentity_t *other, gentity_t *activator ) } } -void SP_target_kill( gentity_t *self ) +void SP_target_kill( gentity_t *self ) { self->e_UseFunc = useF_target_kill_use; } @@ -532,7 +532,7 @@ void target_location_linkup(gentity_t *ent) { int i; - if (level.locationLinked) + if (level.locationLinked) return; level.locationLinked = qtrue; @@ -584,7 +584,7 @@ void target_counter_use( gentity_t *self, gentity_t *other, gentity_t *activator { return; } - + //gi.Printf("target_counter %s used by %s, entnum %d\n", self->targetname, activator->targetname, activator->s.number ); self->count--; @@ -602,7 +602,7 @@ void target_counter_use( gentity_t *self, gentity_t *other, gentity_t *activator } return; } - + G_ActivateBehavior( self,BSET_USE ); if ( self->spawnflags & 128 ) @@ -622,7 +622,7 @@ void target_counter_use( gentity_t *self, gentity_t *other, gentity_t *activator self->count = self->max_health; if ( self->bounceCount > 0 ) {//-1 means bounce back forever - self->bounceCount--; + self->bounceCount--; } } } @@ -693,7 +693,7 @@ void target_random_use(gentity_t *self, gentity_t *other, gentity_t *activator) { continue; } - + if (t == self) { // gi.Printf ("WARNING: Entity used itself.\n"); @@ -725,7 +725,7 @@ void scriptrunner_run (gentity_t *self) { /* if (self->behaviorSet[BSET_USE]) - { + { char newname[MAX_FILENAME_LENGTH]; sprintf((char *) &newname, "%s/%s", Q3_SCRIPT_DIR, self->behaviorSet[BSET_USE] ); @@ -1041,7 +1041,7 @@ extern cvar_t *com_buildScript; Q_strncpyz( buffer, s, sizeof(buffer) ); COM_DefaultExtension( buffer, sizeof(buffer), ".mp3"); - + gi.FS_FOpenFile(buffer, &hFile, FS_READ); if (hFile) { gi.FS_FCloseFile( hFile ); @@ -1070,7 +1070,7 @@ void SP_target_autosave( gentity_t *self ) } void target_secret_use(gentity_t *self, gentity_t *other, gentity_t *activator) -{ +{ //we'll assume that the activator is the player gclient_t* const client = &level.clients[0]; client->sess.missionStats.secretsFound++; @@ -1091,7 +1091,7 @@ You found a Secret! "count" - how many secrets on this level, if more than one on a level, be sure they all have the same count! */ -void SP_target_secret( gentity_t *self ) +void SP_target_secret( gentity_t *self ) { G_SetOrigin( self, self->s.origin ); self->e_UseFunc = useF_target_secret_use; diff --git a/codeJK2/game/g_trigger.cpp b/codeJK2/game/g_trigger.cpp index 6e6e7ac6af..68b9ea50a4 100644 --- a/codeJK2/game/g_trigger.cpp +++ b/codeJK2/game/g_trigger.cpp @@ -58,7 +58,7 @@ void multi_wait( gentity_t *ent ) { // the trigger was just activated // ent->activator should be set to the activator so it can be held through a delay // so wait for the delay time before firing -void multi_trigger_run( gentity_t *ent ) +void multi_trigger_run( gentity_t *ent ) { ent->e_ThinkFunc = thinkF_NULL; @@ -70,7 +70,7 @@ void multi_trigger_run( gentity_t *ent ) } G_UseTargets (ent, ent->activator); - if ( ent->noise_index ) + if ( ent->noise_index ) { G_Sound( ent->activator, ent->noise_index ); } @@ -80,7 +80,7 @@ void multi_trigger_run( gentity_t *ent ) ent->e_ThinkFunc = thinkF_trigger_cleared_fire; ent->nextthink = level.time + ent->speed; } - else if ( ent->wait > 0 ) + else if ( ent->wait > 0 ) { if ( ent->painDebounceTime != level.time ) {//first ent to touch it this frame @@ -88,7 +88,7 @@ void multi_trigger_run( gentity_t *ent ) ent->nextthink = level.time + ( ent->wait + ent->random * Q_flrand(-1.0f, 1.0f) ) * 1000; ent->painDebounceTime = level.time; } - } + } else if ( ent->wait < 0 ) { // we can't just remove (self) here, because this is a touch function @@ -107,14 +107,14 @@ void multi_trigger_run( gentity_t *ent ) } -void multi_trigger( gentity_t *ent, gentity_t *activator ) +void multi_trigger( gentity_t *ent, gentity_t *activator ) { if ( ent->e_ThinkFunc == thinkF_multi_trigger_run ) {//already triggered, just waiting to run return; } - if ( ent->nextthink > level.time ) + if ( ent->nextthink > level.time ) { if( ent->spawnflags & 2048 ) // MULTIPLE - allow multiple entities to touch this trigger in a single frame { @@ -133,7 +133,7 @@ void multi_trigger( gentity_t *ent, gentity_t *activator ) // if the player has already activated this trigger this frame if( activator && !activator->s.number && ent->aimDebounceTime == level.time ) { - return; + return; } if ( ent->svFlags & SVF_INACTIVE ) @@ -148,7 +148,7 @@ void multi_trigger( gentity_t *ent, gentity_t *activator ) ent->e_ThinkFunc = thinkF_multi_trigger_run; ent->nextthink = level.time + ent->delay; ent->painDebounceTime = level.time; - + } else { @@ -156,14 +156,14 @@ void multi_trigger( gentity_t *ent, gentity_t *activator ) } } -void Use_Multi( gentity_t *ent, gentity_t *other, gentity_t *activator ) +void Use_Multi( gentity_t *ent, gentity_t *other, gentity_t *activator ) { multi_trigger( ent, activator ); } -void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) +void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) { - if( !other->client ) + if( !other->client ) { return; } @@ -316,7 +316,7 @@ void Touch_Multi( gentity_t *self, gentity_t *other, trace_t *trace ) */ //other->client->ps.weaponTime = other->client->ps.torsoAnimTimer; } - + if ( self->e_ThinkFunc == thinkF_trigger_cleared_fire ) {//We're waiting to fire our target2 first self->nextthink = level.time + self->speed; @@ -331,7 +331,7 @@ void trigger_cleared_fire (gentity_t *self) G_UseTargets2( self, self->activator, self->target2 ); self->e_ThinkFunc = thinkF_NULL; // should start the wait timer now, because the trigger's just been cleared, so we must "wait" from this point - if ( self->wait > 0 ) + if ( self->wait > 0 ) { self->nextthink = level.time + ( self->wait + self->random * Q_flrand(-1.0f, 1.0f) ) * 1000; } @@ -406,17 +406,17 @@ so, the basic time between firing is a random time between "soundSet" Ambient sound set to play when this trigger is activated */ team_t TranslateTeamName( const char *name ); -void SP_trigger_multiple( gentity_t *ent ) +void SP_trigger_multiple( gentity_t *ent ) { char buffer[MAX_QPATH]; char *s; - if ( G_SpawnString( "noise", "*NOSOUND*", &s ) ) + if ( G_SpawnString( "noise", "*NOSOUND*", &s ) ) { Q_strncpyz( buffer, s, sizeof(buffer) ); COM_DefaultExtension( buffer, sizeof(buffer), ".wav"); ent->noise_index = G_SoundIndex(buffer); } - + G_SpawnFloat( "wait", "0", &ent->wait );//was 0.5 ... but that means wait can never be zero... we should probably put it back to 0.5, though... G_SpawnFloat( "random", "0", &ent->random ); @@ -473,11 +473,11 @@ so, the basic time between firing is a random time between "soundSet" Ambient sound set to play when this trigger is activated */ -void SP_trigger_once( gentity_t *ent ) +void SP_trigger_once( gentity_t *ent ) { char buffer[MAX_QPATH]; char *s; - if ( G_SpawnString( "noise", "*NOSOUND*", &s ) ) + if ( G_SpawnString( "noise", "*NOSOUND*", &s ) ) { Q_strncpyz( buffer, s, sizeof(buffer) ); COM_DefaultExtension( buffer, sizeof(buffer), ".wav"); @@ -517,7 +517,7 @@ Fires "backwardstarget" when someone moves through it in the opposite direction TODO: count */ -void SP_trigger_bidirectional( gentity_t *ent ) +void SP_trigger_bidirectional( gentity_t *ent ) { G_FreeEntity(ent); //FIXME: Implement @@ -528,13 +528,13 @@ void SP_trigger_bidirectional( gentity_t *ent ) ent->touch = Touch_Multi; ent->use = Use_Multi; - + InitTrigger( ent ); gi.linkentity (ent); */ } -/*QUAKED trigger_location (.1 .5 .1) ? +/*QUAKED trigger_location (.1 .5 .1) ? When an ent is asked for it's location, it will return this ent's "message" field if it is in it. "message" - location name @@ -550,7 +550,7 @@ char *G_GetLocationForEnt( gentity_t *ent ) while( (found = G_Find(found, FOFS(classname), "trigger_location")) != NULL ) { - if ( gi.EntityContact( mins, maxs, found ) ) + if ( gi.EntityContact( mins, maxs, found ) ) { return found->message; } @@ -559,7 +559,7 @@ char *G_GetLocationForEnt( gentity_t *ent ) return NULL; } -void SP_trigger_location( gentity_t *ent ) +void SP_trigger_location( gentity_t *ent ) { if ( !ent->message || !ent->message[0] ) { @@ -604,7 +604,7 @@ trigger_push ============================================================================== */ -#define PUSH_CONVEYOR 32 +#define PUSH_CONVEYOR 32 void trigger_push_touch (gentity_t *self, gentity_t *other, trace_t *trace ) { if ( self->svFlags & SVF_INACTIVE ) {//set by target_deactivate @@ -629,10 +629,10 @@ void trigger_push_touch (gentity_t *self, gentity_t *other, trace_t *trace ) { // if the player has already activated this trigger this frame if( other && !other->s.number && self->aimDebounceTime == level.time ) { - return; + return; } - - + + if( self->spawnflags & PUSH_CONVEYOR ) { // only push player if he's on the ground if( other->s.groundEntityNum == ENTITYNUM_NONE ) @@ -672,7 +672,7 @@ void trigger_push_touch (gentity_t *self, gentity_t *other, trace_t *trace ) { if ( other->client->ps.pm_type != PM_NORMAL ) { return; } - + if ( (self->spawnflags&16) ) {//relative, dir to it * speed vec3_t dir; @@ -704,7 +704,7 @@ void trigger_push_touch (gentity_t *self, gentity_t *other, trace_t *trace ) { else if ( self->wait > 0 ) { self->painDebounceTime = level.time; - + } if( other && !other->s.number ) { // mark that the player has activated this trigger this frame @@ -721,7 +721,7 @@ AimAtTarget Calculate origin2 so the target apogee will be hit ================= */ -void AimAtTarget( gentity_t *self ) +void AimAtTarget( gentity_t *self ) { gentity_t *ent; vec3_t origin; @@ -732,7 +732,7 @@ void AimAtTarget( gentity_t *self ) VectorScale ( origin, 0.5, origin ); ent = G_PickTarget( self->target ); - if ( !ent ) + if ( !ent ) { G_FreeEntity( self ); return; @@ -901,8 +901,8 @@ CONSTANT will push activator in direction of 'target' at constant 'speed' NO_DAMAGE the activator won't take falling damage after being pushed */ void SP_target_push( gentity_t *self ) { - - + + if (!self->speed) { self->speed = 1000; } @@ -918,7 +918,7 @@ void SP_target_push( gentity_t *self ) { VectorCopy( self->s.origin, self->absmax ); self->e_ThinkFunc = thinkF_AimAtTarget; self->nextthink = level.time + START_TIME_LINK_ENTS; - + } self->e_UseFunc = useF_Use_target_push; } @@ -936,7 +936,7 @@ trigger_teleport #define TTSF_STASIS 8 #define TTSF_DEAD_OK 16 void TeleportMover( gentity_t *mover, vec3_t origin, vec3_t diffAngles, qboolean snapAngle ); -void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace ) +void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace ) { gentity_t *dest; @@ -944,17 +944,17 @@ void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace {//set by target_deactivate return; } - + dest = G_PickTarget( self->target ); - if (!dest) + if (!dest) { gi.Printf ("Couldn't find teleporter destination\n"); return; } - if ( other->client ) + if ( other->client ) { - if ( other->client->ps.pm_type == PM_DEAD ) + if ( other->client->ps.pm_type == PM_DEAD ) { if ( !(self->spawnflags&TTSF_DEAD_OK) ) {//dead men can't teleport @@ -973,7 +973,7 @@ void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace {//Don't go through if something blocking on the other side return; } - + TeleportPlayer( other, dest->s.origin, dest->s.angles ); } //FIXME: check for SVF_NO_TELEPORT @@ -1032,7 +1032,7 @@ NO_NPCS - NPCs cannot pass through STASIS - will play stasis teleport sound and fx instead of starfleet DEAD_OK - even if dead, you will teleport */ -void SP_trigger_teleport( gentity_t *self ) +void SP_trigger_teleport( gentity_t *self ) { InitTrigger (self); @@ -1096,7 +1096,7 @@ void trigger_hurt_reset (gentity_t *self) self->e_ThinkFunc = thinkF_NULL; } -void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) +void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) { int dflags; int actualDmg = self->damage; @@ -1105,12 +1105,12 @@ void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) {//set by target_deactivate return; } - - if ( !other->takedamage ) + + if ( !other->takedamage ) { return; } - + if( level.time < self->painDebounceTime + self->wait ) // normal 'wait' check { if( self->spawnflags & 2048 ) // MULTIPLE - allow multiple entities to touch this trigger in one frame @@ -1129,7 +1129,7 @@ void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) // if the player has already activated this trigger this frame if( other && !other->s.number && self->aimDebounceTime == level.time ) { - return; + return; } @@ -1157,7 +1157,7 @@ void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) } // play sound - if ( !(self->spawnflags & 4) ) + if ( !(self->spawnflags & 4) ) { G_Sound( other, self->noise_index ); } @@ -1170,7 +1170,7 @@ void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) { dflags = 0; } - + if ( self->delay ) {//Increase dmg over time if ( self->attackDebounceTime < self->delay ) @@ -1237,14 +1237,14 @@ void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) } } -void SP_trigger_hurt( gentity_t *self ) +void SP_trigger_hurt( gentity_t *self ) { char buffer[MAX_QPATH]; char *s; InitTrigger (self); - if ( !( self->spawnflags & 4 )) + if ( !( self->spawnflags & 4 )) { G_SpawnString( "noise", "sound/world/electro", &s ); @@ -1257,7 +1257,7 @@ void SP_trigger_hurt( gentity_t *self ) if ( !self->damage ) { self->damage = 5; } - + self->delay *= 1000; self->wait *= 1000; @@ -1362,7 +1362,7 @@ ownername - If any, who to calc the distance from- default is the trigger_entdis example: target "biessman telsia" will look for the biessman and telsia NPC if it finds either of these within distance it will fire. - todo - + todo - add delay, count add monster classnames????? add LOS to it??? @@ -1402,7 +1402,7 @@ void trigger_entdist_use( gentity_t *self, gentity_t *other, gentity_t *activato found = &g_entities[0]; if (found) - { + { VectorSubtract(owner->currentOrigin, found->currentOrigin, diff); if(VectorLength(diff) < self->count) { @@ -1425,7 +1425,7 @@ void trigger_entdist_use( gentity_t *self, gentity_t *other, gentity_t *activato found = G_Find(found, FOFS(targetname), token); // Look for the specified NPC if (found) //Found??? - { + { VectorSubtract(owner->currentOrigin, found->currentOrigin, diff); if(VectorLength(diff) < self->count) // Within distance { @@ -1444,12 +1444,12 @@ void trigger_entdist_use( gentity_t *self, gentity_t *other, gentity_t *activato { // This is the negative target G_UseTargets2 (self, self->activator, self->target2); - } + } } -void SP_trigger_entdist( gentity_t *self ) +void SP_trigger_entdist( gentity_t *self ) { G_SpawnInt( "distance", "0", &self->count); @@ -1539,7 +1539,7 @@ void SP_trigger_visible( gentity_t *self ) if ( self->spawnflags & 128 ) {// Make it inactive - self->svFlags |= SVF_INACTIVE; + self->svFlags |= SVF_INACTIVE; } G_SetOrigin( self, self->s.origin ); diff --git a/codeJK2/game/g_usable.cpp b/codeJK2/game/g_usable.cpp index 9b5fc7a77c..ebc57b19d1 100644 --- a/codeJK2/game/g_usable.cpp +++ b/codeJK2/game/g_usable.cpp @@ -125,12 +125,12 @@ void func_usable_use( gentity_t *self, gentity_t *other, gentity_t *activator ) self->svFlags &= ~SVF_PLAYER_USABLE; //also remove ability to call any use func at all! self->e_UseFunc = useF_NULL; - + if(self->target && self->target[0]) { G_UseTargets(self, activator); } - + if ( self->wait ) { self->e_ThinkFunc = thinkF_func_usable_think; @@ -180,7 +180,7 @@ void func_usable_die(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, /*QUAKED func_usable (0 .5 .8) ? STARTOFF AUTOANIMATE ANIM_ONCE ALWAYS_ON BLOCKCHECK NPC_USE PLAYER_USE INACTIVE START_OFF - the wall will not be there -AUTOANIMATE - if a model is used it will animate +AUTOANIMATE - if a model is used it will animate ANIM_ONCE - When turned on, goes through anim once ALWAYS_ON - Doesn't toggle on and off when used, just runs usescript and fires target NPC_ONLY - Only NPCs can directly use this @@ -201,7 +201,7 @@ A bmodel that just sits there, doing nothing. Can be used for conditional walls "endframe" Will make it animate to next shader frame when used, not turn on/off... set this to number of frames in the shader, minus 1 */ -void SP_func_usable( gentity_t *self ) +void SP_func_usable( gentity_t *self ) { gi.SetBrushModel( self, self->model ); InitMover( self ); diff --git a/codeJK2/game/ghoul2_shared.h b/codeJK2/game/ghoul2_shared.h index 076e3d8834..c90978c4f1 100644 --- a/codeJK2/game/ghoul2_shared.h +++ b/codeJK2/game/ghoul2_shared.h @@ -54,7 +54,7 @@ int G2API_GetTime(int argTime); // this may or may not return arg depending on // G H O U L I I D E F I N E S // // we save the whole surfaceInfo_t struct -struct surfaceInfo_t +struct surfaceInfo_t { int offFlags; // what the flags are for this model int surface; // index into array held inside the model definition of pointers to the actual surface data loaded in - used by both client and game @@ -62,7 +62,7 @@ struct surfaceInfo_t float genBarycentricI; // point 1 barycentric coors - point 2 is 1 - point0 - point1 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), @@ -130,16 +130,16 @@ boneInfo_t(): boneBlendTime(0), boneBlendStart(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[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; } }; //we save from top to boltUsed here. Don't bother saving the position, it gets rebuilt every frame anyway struct boltInfo_t{ - int boneNumber; // bone number bolt attaches to - int surfaceNumber; // surface number bolt attaches to + int boneNumber; // bone number bolt attaches to + int surfaceNumber; // surface number bolt attaches to int surfaceType; // if we attach to a surface, this tells us if it is an original surface or a generated one - doesn't go across the network int boltUsed; // nor does this boltInfo_t(): @@ -243,7 +243,7 @@ class CGhoul2Info { mFileName[0] = 0; } -}; +}; class CGhoul2Info_v; diff --git a/codeJK2/game/objectives.h b/codeJK2/game/objectives.h index 1e7e7cd4aa..827085c09b 100644 --- a/codeJK2/game/objectives.h +++ b/codeJK2/game/objectives.h @@ -66,7 +66,7 @@ typedef enum //# Objective_e BESPIN_PLATFORM_OBJ2, //# BESPIN PLATFORM CAIRN_BAY_OBJ1, //# CAIRN BAY CAIRN_BAY_OBJ2, //# CAIRN BAY - CAIRN_ASSEMBLY_OBJ1, //# CAIRN ASSEMBLY + CAIRN_ASSEMBLY_OBJ1, //# CAIRN ASSEMBLY CAIRN_REACTOR_OBJ1, //# CAIRN REACTOR CAIRN_REACTOR_OBJ2, //# CAIRN REACTOR CAIRN_DOCK1_OBJ1, //# CAIRN DOCK1 @@ -85,16 +85,16 @@ typedef enum //# Objective_e YAVIN_COURTYARD_OBJ1, //# YAVIN COURTYARD YAVIN_COURTYARD_OBJ2, //# YAVIN COURTYARD YAVIN_FINAL_OBJ1, //# YAVIN FINAL - KEJIM_POST_OBJ3, //# KEJIM POST - GRAPHICS IN IT. - KEJIM_POST_OBJ4, //# KEJIM POST - GRAPHICS IN IT. - KEJIM_POST_OBJ5, //# KEJIM POST - GRAPHICS IN IT. + KEJIM_POST_OBJ3, //# KEJIM POST - GRAPHICS IN IT. + KEJIM_POST_OBJ4, //# KEJIM POST - GRAPHICS IN IT. + KEJIM_POST_OBJ5, //# KEJIM POST - GRAPHICS IN IT. ARTUS_DETENTION_OBJ3, //# ARTUS DETENTION - DOOM_COMM_OBJ4, //# DOOM COMM - GRAPHICS IN IT. + DOOM_COMM_OBJ4, //# DOOM COMM - GRAPHICS IN IT. DOOM_SHIELDS_OBJ3, //# DOOM SHIELDS - DEMO_OBJ1, //# DEMO - DEMO_OBJ2, //# DEMO - DEMO_OBJ3, //# DEMO - DEMO_OBJ4, //# DEMO + DEMO_OBJ1, //# DEMO + DEMO_OBJ2, //# DEMO + DEMO_OBJ3, //# DEMO + DEMO_OBJ4, //# DEMO //# #eol MAX_OBJECTIVES, @@ -206,7 +206,7 @@ stringID_table_t objectiveTable [] = ENUM2STRING(BESPIN_PLATFORM_OBJ2), //# BESPIN PLATFORM ENUM2STRING(CAIRN_BAY_OBJ1), //# CAIRN BAY ENUM2STRING(CAIRN_BAY_OBJ2), //# CAIRN BAY - ENUM2STRING(CAIRN_ASSEMBLY_OBJ1), //# CAIRN ASSEMBLY + ENUM2STRING(CAIRN_ASSEMBLY_OBJ1), //# CAIRN ASSEMBLY ENUM2STRING(CAIRN_REACTOR_OBJ1), //# CAIRN REACTOR ENUM2STRING(CAIRN_REACTOR_OBJ2), //# CAIRN REACTOR ENUM2STRING(CAIRN_DOCK1_OBJ1), //# CAIRN DOCK1 @@ -225,16 +225,16 @@ stringID_table_t objectiveTable [] = ENUM2STRING(YAVIN_COURTYARD_OBJ1), //# YAVIN COURTYARD ENUM2STRING(YAVIN_COURTYARD_OBJ2), //# YAVIN COURTYARD ENUM2STRING(YAVIN_FINAL_OBJ1), //# YAVIN FINAL - ENUM2STRING(KEJIM_POST_OBJ3), //# KEJIM POST - GRAPHICS IN IT. - ENUM2STRING(KEJIM_POST_OBJ4), //# KEJIM POST - GRAPHICS IN IT. - ENUM2STRING(KEJIM_POST_OBJ5), //# KEJIM POST - GRAPHICS IN IT. + ENUM2STRING(KEJIM_POST_OBJ3), //# KEJIM POST - GRAPHICS IN IT. + ENUM2STRING(KEJIM_POST_OBJ4), //# KEJIM POST - GRAPHICS IN IT. + ENUM2STRING(KEJIM_POST_OBJ5), //# KEJIM POST - GRAPHICS IN IT. ENUM2STRING(ARTUS_DETENTION_OBJ3), //# ARTUS DETENTION ENUM2STRING(DOOM_COMM_OBJ4), //# DOOM COMM - GRAPHICS IN IT. IT MUST BE LAST IN THE LIST ENUM2STRING(DOOM_SHIELDS_OBJ3), //# DOOM SHIELDS - ENUM2STRING(DEMO_OBJ1), //# DEMO - ENUM2STRING(DEMO_OBJ2), //# DEMO - ENUM2STRING(DEMO_OBJ3), //# DEMO - ENUM2STRING(DEMO_OBJ4), //# DEMO + ENUM2STRING(DEMO_OBJ1), //# DEMO + ENUM2STRING(DEMO_OBJ2), //# DEMO + ENUM2STRING(DEMO_OBJ3), //# DEMO + ENUM2STRING(DEMO_OBJ4), //# DEMO //stringID_table_t Must end with a null entry {"", 0} @@ -250,7 +250,7 @@ stringID_table_t missionFailedTable [] = ENUM2STRING(MISSIONFAILED_PRISONERS), //# TOO MANY PRISONERS DIED ENUM2STRING(MISSIONFAILED_EMPLACEDGUNS),//# ALL EMPLACED GUNS GONE ENUM2STRING(MISSIONFAILED_LADYLUCK), //# LADY LUCK DISTROYED - ENUM2STRING(MISSIONFAILED_KYLECAPTURE), //# KYLE HAS BEEN CAPTURED + ENUM2STRING(MISSIONFAILED_KYLECAPTURE), //# KYLE HAS BEEN CAPTURED ENUM2STRING(MISSIONFAILED_TOOMANYALLIESDIED), //# TOO MANY ALLIES DIED //stringID_table_t Must end with a null entry diff --git a/codeJK2/game/statindex.h b/codeJK2/game/statindex.h index 481eef607b..d2c5c09957 100644 --- a/codeJK2/game/statindex.h +++ b/codeJK2/game/statindex.h @@ -32,11 +32,11 @@ typedef enum { STAT_HEALTH, STAT_ITEMS, STAT_WEAPONS, // 16 bit fields - STAT_ARMOR, + STAT_ARMOR, STAT_DEAD_YAW, // look this direction when dead (FIXME: get rid of?) STAT_CLIENTS_READY, // bit mask of clients wishing to exit the intermission (FIXME: configstring?) STAT_MAX_HEALTH // health / armor limit, changable by handicap -} statIndex_t; +} statIndex_t; #endif // #ifndef STATINDEX_H diff --git a/codeJK2/game/teams.h b/codeJK2/game/teams.h index a7981c60b6..b1b018854a 100644 --- a/codeJK2/game/teams.h +++ b/codeJK2/game/teams.h @@ -36,15 +36,15 @@ typedef enum //# team_e } team_t; // This list is made up from the model directories, this MUST be in the same order as the ClassNames array in NPC_stats.cpp -typedef enum +typedef enum { CLASS_NONE, // hopefully this will never be used by an npc, just covering all bases CLASS_ATST, // technically droid... CLASS_BARTENDER, - CLASS_BESPIN_COP, + CLASS_BESPIN_COP, CLASS_CLAW, CLASS_COMMANDO, - CLASS_DESANN, + CLASS_DESANN, CLASS_FISH, CLASS_FLIER2, CLASS_GALAK, @@ -54,18 +54,18 @@ typedef enum CLASS_HOWLER, CLASS_IMPERIAL, CLASS_IMPWORKER, - CLASS_INTERROGATOR, // droid - CLASS_JAN, - CLASS_JEDI, - CLASS_KYLE, - CLASS_LANDO, + CLASS_INTERROGATOR, // droid + CLASS_JAN, + CLASS_JEDI, + CLASS_KYLE, + CLASS_LANDO, CLASS_LIZARD, - CLASS_LUKE, + CLASS_LUKE, CLASS_MARK1, // droid CLASS_MARK2, // droid CLASS_GALAKMECH, // droid CLASS_MINEMONSTER, - CLASS_MONMOTHA, + CLASS_MONMOTHA, CLASS_MORGANKATARN, CLASS_MOUSE, // droid CLASS_MURJJ, @@ -89,7 +89,7 @@ typedef enum CLASS_TRANDOSHAN, CLASS_UGNAUGHT, CLASS_WEEQUAY, - + CLASS_NUM_CLASSES } class_t; diff --git a/codeJK2/game/w_local.h b/codeJK2/game/w_local.h index 5fd05a180f..1635bc4337 100644 --- a/codeJK2/game/w_local.h +++ b/codeJK2/game/w_local.h @@ -68,7 +68,7 @@ void WP_FireRocket( gentity_t *ent, qboolean alt_fire ); void WP_FireStunBaton( gentity_t *ent, qboolean alt_fire ); void thermalDetonatorExplode( gentity_t *ent ); void thermal_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod, int dFlags, int hitLoc ); -qboolean WP_LobFire( gentity_t *self, vec3_t start, vec3_t target, vec3_t mins, vec3_t maxs, int clipmask, +qboolean WP_LobFire( gentity_t *self, vec3_t start, vec3_t target, vec3_t mins, vec3_t maxs, int clipmask, vec3_t velocity, qboolean tracePath, int ignoreEntNum, int enemyNum, float minSpeed = 0, float maxSpeed = 0, float idealSpeed = 0, qboolean mustHit = qfalse ); void WP_ThermalThink( gentity_t *ent ); diff --git a/codeJK2/game/weapons.h b/codeJK2/game/weapons.h index f796fc6533..acb2d00acd 100644 --- a/codeJK2/game/weapons.h +++ b/codeJK2/game/weapons.h @@ -60,7 +60,7 @@ typedef enum //# weapon_e WP_BOT_LASER, // Probe droid - Laser blast - WP_TURRET, // turret guns + WP_TURRET, // turret guns WP_ATST_MAIN, WP_ATST_SIDE, @@ -122,7 +122,7 @@ typedef struct weaponData_s int energyPerShot; // Amount of energy used per shot int fireTime; // Amount of time between firings int range; // Range of weapon - + int altEnergyPerShot; // Amount of energy used for alt-fire int altFireTime; // Amount of time between alt-firings int altRange; // Range of alt-fire @@ -288,8 +288,8 @@ typedef struct ammoData_s // ATST Main Gun //-------------- -#define ATST_MAIN_VEL 4000 // -#define ATST_MAIN_DAMAGE 25 // +#define ATST_MAIN_VEL 4000 // +#define ATST_MAIN_DAMAGE 25 // #define ATST_MAIN_SIZE 3 // make it easier to hit things // ATST Side Gun diff --git a/codeJK2/game/wp_blaster_rifle.cpp b/codeJK2/game/wp_blaster_rifle.cpp index 21eaaac51a..bdd8093e88 100644 --- a/codeJK2/game/wp_blaster_rifle.cpp +++ b/codeJK2/game/wp_blaster_rifle.cpp @@ -43,7 +43,7 @@ static void WP_FireBlasterMissile( gentity_t *ent, vec3_t start, vec3_t dir, qbo if ( ent->client && ent->client->ps.clientNum != 0 ) { if ( g_spskill->integer < 2 ) - { + { velocity *= BLASTER_NPC_VEL_CUT; } else diff --git a/codeJK2/game/wp_bowcaster.cpp b/codeJK2/game/wp_bowcaster.cpp index c4072a0777..1048d0c67e 100644 --- a/codeJK2/game/wp_bowcaster.cpp +++ b/codeJK2/game/wp_bowcaster.cpp @@ -98,7 +98,7 @@ static void WP_BowcasterMainFire( gentity_t *ent ) angs[PITCH] += ( Q_flrand(-1.0f, 1.0f) * (BLASTER_NPC_SPREAD+(6-ent->NPC->currentAim)*0.25f) ); angs[YAW] += ( Q_flrand(-1.0f, 1.0f) * (BLASTER_NPC_SPREAD+(6-ent->NPC->currentAim)*0.25f) ); } - + AngleVectors( angs, dir, NULL, NULL ); missile = CreateMissile( start, dir, vel, 10000, ent ); diff --git a/codeJK2/game/wp_demp2.cpp b/codeJK2/game/wp_demp2.cpp index b7cca42dc2..c75549b51a 100644 --- a/codeJK2/game/wp_demp2.cpp +++ b/codeJK2/game/wp_demp2.cpp @@ -96,10 +96,10 @@ void DEMP2_AltRadiusDamage( gentity_t *ent ) vec3_t v, dir; frac *= frac * frac; // yes, this is completely ridiculous...but it causes the shell to grow slowly then "explode" at the end - + radius = frac * 200.0f; // 200 is max radius...the model is aprox. 100 units tall...the fx draw code mults. this by 2. - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { mins[i] = ent->currentOrigin[i] - radius; maxs[i] = ent->currentOrigin[i] + radius; @@ -107,7 +107,7 @@ void DEMP2_AltRadiusDamage( gentity_t *ent ) numListedEntities = gi.EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); - for ( e = 0 ; e < numListedEntities ; e++ ) + for ( e = 0 ; e < numListedEntities ; e++ ) { gent = entityList[ e ]; @@ -117,17 +117,17 @@ void DEMP2_AltRadiusDamage( gentity_t *ent ) } // find the distance from the edge of the bounding box - for ( i = 0 ; i < 3 ; i++ ) + for ( i = 0 ; i < 3 ; i++ ) { - if ( ent->currentOrigin[i] < gent->absmin[i] ) + if ( ent->currentOrigin[i] < gent->absmin[i] ) { v[i] = gent->absmin[i] - ent->currentOrigin[i]; - } - else if ( ent->currentOrigin[i] > gent->absmax[i] ) + } + else if ( ent->currentOrigin[i] > gent->absmax[i] ) { v[i] = ent->currentOrigin[i] - gent->absmax[i]; - } - else + } + else { v[i] = 0; } @@ -138,7 +138,7 @@ void DEMP2_AltRadiusDamage( gentity_t *ent ) dist = VectorLength( v ); - if ( dist >= radius ) + if ( dist >= radius ) { // shockwave hasn't hit them yet continue; @@ -157,7 +157,7 @@ void DEMP2_AltRadiusDamage( gentity_t *ent ) dir[2] += 12; G_Damage( gent, ent, ent->owner, dir, ent->currentOrigin, weaponData[WP_DEMP2].altDamage, DAMAGE_DEATH_KNOCKBACK, ent->splashMethodOfDeath ); - if ( gent->takedamage && gent->client ) + if ( gent->takedamage && gent->client ) { gent->s.powerups |= ( 1 << PW_SHOCKED ); gent->client->ps.powerups[PW_SHOCKED] = level.time + 2000; diff --git a/codeJK2/game/wp_disruptor.cpp b/codeJK2/game/wp_disruptor.cpp index 4cea823d87..d18d126341 100644 --- a/codeJK2/game/wp_disruptor.cpp +++ b/codeJK2/game/wp_disruptor.cpp @@ -99,7 +99,7 @@ static void WP_DisruptorMainFire( gentity_t *ent ) gi.trace( &tr, start, NULL, NULL, end, ignore, MASK_SHOT, G2_RETURNONHIT, 0 ); traceEnt = &g_entities[tr.entityNum]; - if ( traceEnt && traceEnt->s.weapon == WP_SABER )//&& traceEnt->NPC + if ( traceEnt && traceEnt->s.weapon == WP_SABER )//&& traceEnt->NPC {//FIXME: need a more reliable way to know we hit a jedi? if ( Jedi_DodgeEvasion( traceEnt, ent, &tr, HL_NONE ) ) {//act like we didn't even hit him @@ -113,7 +113,7 @@ static void WP_DisruptorMainFire( gentity_t *ent ) break; } - if ( tr.surfaceFlags & SURF_NOIMPACT ) + if ( tr.surfaceFlags & SURF_NOIMPACT ) { render_impact = qfalse; } @@ -130,10 +130,10 @@ static void WP_DisruptorMainFire( gentity_t *ent ) // Create a simple impact type mark that doesn't last long in the world G_PlayEffect( G_EffectIndex( "disruptor/flesh_impact" ), tr.endpos, tr.plane.normal ); - if ( traceEnt->client && LogAccuracyHit( traceEnt, ent )) + if ( traceEnt->client && LogAccuracyHit( traceEnt, ent )) { ent->client->ps.persistant[PERS_ACCURACY_HITS]++; - } + } int hitLoc = G_GetHitLocFromTrace( &tr, MOD_DISRUPTOR ); if ( traceEnt && traceEnt->client && traceEnt->client->NPC_class == CLASS_GALAKMECH ) @@ -145,9 +145,9 @@ static void WP_DisruptorMainFire( gentity_t *ent ) G_Damage( traceEnt, ent, ent, wpFwd, tr.endpos, damage, DAMAGE_DEATH_KNOCKBACK, MOD_DISRUPTOR, hitLoc ); } } - else + else { - G_PlayEffect( G_EffectIndex( "disruptor/wall_impact" ), tr.endpos, tr.plane.normal ); + G_PlayEffect( G_EffectIndex( "disruptor/wall_impact" ), tr.endpos, tr.plane.normal ); } } @@ -246,7 +246,7 @@ void WP_DisruptorAltFire( gentity_t *ent ) //alternately, if you end up hitting an emplaced_gun that has a sitter, just redo this one trace with the "G2_COLLIDE, 10" to see if we it the sitter gi.trace( &tr, start, NULL, NULL, end, skip, MASK_SHOT, G2_COLLIDE, 10 );//G2_RETURNONHIT, 0 ); - if ( tr.surfaceFlags & SURF_NOIMPACT ) + if ( tr.surfaceFlags & SURF_NOIMPACT ) { render_impact = qfalse; } @@ -259,7 +259,7 @@ void WP_DisruptorAltFire( gentity_t *ent ) VectorCopy( tr.endpos, start ); skip = tr.entityNum; #ifdef _DEBUG - gi.Printf( "BAD! Disruptor gun shot somehow traced back and hit the owner!\n" ); + gi.Printf( "BAD! Disruptor gun shot somehow traced back and hit the owner!\n" ); #endif continue; } @@ -279,7 +279,7 @@ void WP_DisruptorAltFire( gentity_t *ent ) traceEnt = &g_entities[tr.entityNum]; - if ( traceEnt && traceEnt->s.weapon == WP_SABER )//&& traceEnt->NPC + if ( traceEnt && traceEnt->s.weapon == WP_SABER )//&& traceEnt->NPC {//FIXME: need a more reliable way to know we hit a jedi? hitDodged = Jedi_DodgeEvasion( traceEnt, ent, &tr, HL_NONE ); //acts like we didn't even hit him @@ -288,26 +288,26 @@ void WP_DisruptorAltFire( gentity_t *ent ) { if ( render_impact ) { - if (( tr.entityNum < ENTITYNUM_WORLD && traceEnt->takedamage ) || !Q_stricmp( traceEnt->classname, "misc_model_breakable" ) + if (( tr.entityNum < ENTITYNUM_WORLD && traceEnt->takedamage ) || !Q_stricmp( traceEnt->classname, "misc_model_breakable" ) || traceEnt->s.eType == ET_MOVER ) { // Create a simple impact type mark that doesn't last long in the world G_PlayEffect( G_EffectIndex( "disruptor/alt_hit" ), tr.endpos, tr.plane.normal ); - if ( traceEnt->client && LogAccuracyHit( traceEnt, ent )) + if ( traceEnt->client && LogAccuracyHit( traceEnt, ent )) {//NOTE: hitting multiple ents can still get you over 100% accuracy ent->client->ps.persistant[PERS_ACCURACY_HITS]++; - } + } int hitLoc = G_GetHitLocFromTrace( &tr, MOD_DISRUPTOR ); if ( traceEnt && traceEnt->client && traceEnt->client->NPC_class == CLASS_GALAKMECH ) {//hehe - G_Damage( traceEnt, ent, ent, wpFwd, tr.endpos, 10, DAMAGE_NO_KNOCKBACK|DAMAGE_NO_HIT_LOC, fullCharge ? MOD_SNIPER : MOD_DISRUPTOR, hitLoc ); + G_Damage( traceEnt, ent, ent, wpFwd, tr.endpos, 10, DAMAGE_NO_KNOCKBACK|DAMAGE_NO_HIT_LOC, fullCharge ? MOD_SNIPER : MOD_DISRUPTOR, hitLoc ); break; } G_Damage( traceEnt, ent, ent, wpFwd, tr.endpos, damage, DAMAGE_NO_KNOCKBACK|DAMAGE_NO_HIT_LOC, fullCharge ? MOD_SNIPER : MOD_DISRUPTOR, hitLoc ); } - else + else { // we only make this mark on things that can't break or move tent = G_TempEntity( tr.endpos, EV_DISRUPTOR_SNIPER_MISS ); diff --git a/codeJK2/game/wp_emplaced_gun.cpp b/codeJK2/game/wp_emplaced_gun.cpp index 25758823d5..a18e42c780 100644 --- a/codeJK2/game/wp_emplaced_gun.cpp +++ b/codeJK2/game/wp_emplaced_gun.cpp @@ -41,7 +41,7 @@ void WP_EmplacedFire( gentity_t *ent ) missile->classname = "emplaced_proj"; missile->s.weapon = WP_EMPLACED_GUN; - missile->damage = damage; + missile->damage = damage; missile->dflags = DAMAGE_DEATH_KNOCKBACK | DAMAGE_HEAVY_WEAP_CLASS; missile->methodOfDeath = MOD_EMPLACED; missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER; diff --git a/codeJK2/game/wp_flechette.cpp b/codeJK2/game/wp_flechette.cpp index 79130363a9..8f073d719e 100644 --- a/codeJK2/game/wp_flechette.cpp +++ b/codeJK2/game/wp_flechette.cpp @@ -86,9 +86,9 @@ static void WP_FlechetteMainFire( gentity_t *ent ) // { // missile->flags |= FL_OVERCHARGED; // } - + missile->dflags = (DAMAGE_DEATH_KNOCKBACK|DAMAGE_EXTRA_KNOCKBACK); - + missile->methodOfDeath = MOD_FLECHETTE; missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER; @@ -162,7 +162,7 @@ void prox_mine_stick( gentity_t *self, gentity_t *other, trace_t *trace ) self->owner = NULL; WP_Stick( self, trace ); - + self->e_ThinkFunc = thinkF_prox_mine_think; self->nextthink = level.time + 450; @@ -198,7 +198,7 @@ static void WP_FlechetteProxMine( gentity_t *ent ) missile->clipmask = MASK_SHOT; // we don't want it to bounce forever - missile->bounceCount = 0; + missile->bounceCount = 0; } */ //---------------------------------------------- @@ -218,7 +218,7 @@ static void WP_CreateFlechetteBouncyThing( vec3_t start, vec3_t fwd, gentity_t * //------------------------------------------------------------------------------ { gentity_t *missile = CreateMissile( start, fwd, 950 + Q_flrand(0.0f, 1.0f) * 700, 1500 + Q_flrand(0.0f, 1.0f) * 2000, self, qtrue ); - + missile->e_ThinkFunc = thinkF_WP_flechette_alt_blow; missile->s.weapon = WP_FLECHETTE; diff --git a/codeJK2/game/wp_rocket_launcher.cpp b/codeJK2/game/wp_rocket_launcher.cpp index cf7c7b89d5..a3f5431ca7 100644 --- a/codeJK2/game/wp_rocket_launcher.cpp +++ b/codeJK2/game/wp_rocket_launcher.cpp @@ -36,13 +36,13 @@ along with this program; if not, see . void rocketThink( gentity_t *ent ) //--------------------------------------------------------- { - vec3_t newdir, targetdir, - wpUp={0,0,1}, right; + vec3_t newdir, targetdir, + wpUp={0,0,1}, right; vec3_t org; float dot, dot2; if ( ent->enemy && ent->enemy->inuse ) - { + { float vel = ROCKET_VELOCITY; VectorCopy( ent->enemy->currentOrigin, org ); @@ -74,18 +74,18 @@ void rocketThink( gentity_t *ent ) // a dot of 1.0 means right-on-target. if ( dot < 0.0f ) - { + { // Go in the direction opposite, start a 180. CrossProduct( ent->movedir, wpUp, right ); dot2 = DotProduct( targetdir, right ); if ( dot2 > 0 ) - { + { // Turn 45 degrees right. VectorMA( ent->movedir, 0.3f, right, newdir ); } else - { + { // Turn 45 degrees left. VectorMA(ent->movedir, -0.3f, right, newdir); } @@ -97,12 +97,12 @@ void rocketThink( gentity_t *ent ) // vel *= 0.5f; } else if ( dot < 0.70f ) - { + { // Still a bit off, so we turn a bit softer VectorMA( ent->movedir, 0.5f, targetdir, newdir ); } else - { + { // getting close, so turn a bit harder VectorMA( ent->movedir, 0.9f, targetdir, newdir ); } @@ -205,8 +205,8 @@ void WP_FireRocket( gentity_t *ent, qboolean alt_fire ) dif = 8; } - // if we are fully locked, always take on the enemy. - // Also give a slight advantage to higher, but not quite full charges. + // if we are fully locked, always take on the enemy. + // Also give a slight advantage to higher, but not quite full charges. // Finally, just give any amount of charge a very slight random chance of locking. if ( dif == 8 || Q_flrand(0.0f, 1.0f) * dif > 2 || Q_flrand(0.0f, 1.0f) > 0.97f ) { diff --git a/codeJK2/icarus/BlockStream.cpp b/codeJK2/icarus/BlockStream.cpp index af8976518d..bb6213dceb 100644 --- a/codeJK2/icarus/BlockStream.cpp +++ b/codeJK2/icarus/BlockStream.cpp @@ -75,7 +75,7 @@ GetInfo */ void CBlockMember::GetInfo( int *id, int *size, void **data ) -{ +{ *id = m_id; *size = m_size; *data = m_data; @@ -141,7 +141,7 @@ int CBlockMember::ReadMember( char **stream, int *streamPos ) #endif } *streamPos += m_size; - + return true; } @@ -267,7 +267,7 @@ int CBlock::Write( int member_id, const char *member_data ) CBlockMember *bMember = new CBlockMember; bMember->SetID( member_id ); - + bMember->SetData( member_data ); bMember->SetSize( strlen(member_data) + 1 ); @@ -278,7 +278,7 @@ int CBlock::Write( int member_id, const char *member_data ) int CBlock::Write( int member_id, vector_t member_data ) { - CBlockMember *bMember; + CBlockMember *bMember; bMember = new CBlockMember; @@ -321,7 +321,7 @@ int CBlock::Write( int member_id, int member_data ) int CBlock::Write( CBlockMember *bMember ) { // findme: this is wrong: bMember->SetSize( sizeof(bMember->GetData()) ); - + AddMember( bMember ); return true; @@ -571,12 +571,12 @@ int CBlockStream::WriteBlock( CBlock *block ) int numMembers = block->GetNumMembers(); unsigned char flags = block->GetFlags(); - fwrite ( &id, sizeof(id), 1, m_fileHandle ); + fwrite ( &id, sizeof(id), 1, m_fileHandle ); fwrite ( &numMembers, sizeof(numMembers), 1, m_fileHandle ); fwrite ( &flags, sizeof( flags ), 1, m_fileHandle ); for ( int i = 0; i < numMembers; i++ ) - { + { bMember = block->GetMember( i ); bMember->WriteMember( m_fileHandle ); } @@ -626,7 +626,7 @@ int CBlockStream::ReadBlock( CBlock *get ) get->SetFlags( flags ); while ( numMembers-- > 0) - { + { bMember = new CBlockMember; bMember->ReadMember( &m_stream, &m_streamPos ); get->AddMember( bMember ); @@ -645,7 +645,7 @@ int CBlockStream::Open( char *buffer, long size ) { char id_header[IBI_HEADER_ID_LENGTH]; float version; - + Init(); m_fileSize = size; diff --git a/codeJK2/icarus/Instance.cpp b/codeJK2/icarus/Instance.cpp index 7aec690b14..4ee1a44115 100644 --- a/codeJK2/icarus/Instance.cpp +++ b/codeJK2/icarus/Instance.cpp @@ -47,7 +47,7 @@ ICARUS_Instance::ICARUS_Instance( void ) m_DEBUG_NumSequenceFreed = 0; m_DEBUG_NumSequenceResidual = 0; -#endif +#endif } @@ -87,7 +87,7 @@ int ICARUS_Instance::Free( void ) STL_ITERATE( sri, m_sequencers ) { delete (*sri); - + #ifdef _DEBUG m_DEBUG_NumSequencerResidual++; @@ -191,7 +191,7 @@ void ICARUS_Instance::DeleteSequencer( CSequencer *sequencer ) delete taskManager; } - m_sequencers.remove( sequencer ); + m_sequencers.remove( sequencer ); sequencer->Free(); delete sequencer; @@ -224,7 +224,7 @@ CSequence *ICARUS_Instance::GetSequence( void ) m_DEBUG_NumSequenceAlloc++; -#endif +#endif return sequence; } @@ -255,7 +255,7 @@ DeleteSequence void ICARUS_Instance::DeleteSequence( CSequence *sequence ) { - m_sequences.remove( sequence ); + m_sequences.remove( sequence ); delete sequence; @@ -263,7 +263,7 @@ void ICARUS_Instance::DeleteSequence( CSequence *sequence ) m_DEBUG_NumSequenceFreed++; -#endif +#endif } /* @@ -407,7 +407,7 @@ int ICARUS_Instance::SaveSignals( void ) { //m_interface->I_WriteSaveData( INT_ID('I','S','I','G'), &numSignals, sizeof( numSignals ) ); const char *name = ((*si).first).c_str(); - + //Make sure this is a valid string assert( ( name != NULL ) && ( name[0] != '\0' ) ); @@ -435,7 +435,7 @@ Save */ int ICARUS_Instance::Save( void ) -{ +{ //Save out a ICARUS save block header with the ICARUS version double version = ICARUS_VERSION; @@ -597,7 +597,7 @@ int ICARUS_Instance::LoadSequencers( void ) saved_game.read_chunk( INT_ID('#', 'S', 'Q', 'R'), numSequencers); - + //Load all sequencers for ( int i = 0; i < numSequencers; i++ ) { diff --git a/codeJK2/icarus/Interface.cpp b/codeJK2/icarus/Interface.cpp index 106a6d8d36..22d7e01d65 100644 --- a/codeJK2/icarus/Interface.cpp +++ b/codeJK2/icarus/Interface.cpp @@ -1,6 +1,6 @@ // ICARUS Engine Interface File // -// This file is the only section of the ICARUS systems that +// This file is the only section of the ICARUS systems that // is not directly portable from engine to engine. // // -- jweier diff --git a/codeJK2/icarus/Interpreter.cpp b/codeJK2/icarus/Interpreter.cpp index 2fe1f01c78..b986f1f7f4 100644 --- a/codeJK2/icarus/Interpreter.cpp +++ b/codeJK2/icarus/Interpreter.cpp @@ -33,11 +33,11 @@ keywordArray_t CInterpreter::m_symbolKeywords[] = //Blocks "{", TK_BLOCK_START, "}", TK_BLOCK_END, - + //Vectors "<", TK_VECTOR_START, ">", TK_VECTOR_END, - + //Groups "(", TK_OPEN_PARENTHESIS, ")", TK_CLOSED_PARENTHESIS, @@ -160,7 +160,7 @@ int CInterpreter::Error( char *format, ... ) int error_line = m_iCurrentLine; // m_tokenizer->GetCurLine(); m_tokenizer->GetCurFilename( &error_file ); - if (!error_file) + if (!error_file) { // 99% of the time we'll get here now, because of pushed parse streams // @@ -189,7 +189,7 @@ int CInterpreter::Error( char *format, ... ) strcat(out_msg, "\n"); } -#ifdef __POP_UPS__ +#ifdef __POP_UPS__ MessageBox( NULL, out_msg, "Error", MB_OK ); @@ -516,7 +516,7 @@ int CInterpreter::Match( int token_id ) { //This may have been a check, so don't loose the token m_tokenizer->PutBackToken( token ); - + return false; } @@ -558,7 +558,7 @@ int CInterpreter::LookAhead( int token_id ) if ( token->GetType() != token_id ) { m_tokenizer->PutBackToken( token ); - + return false; } @@ -650,7 +650,7 @@ int CInterpreter::GetFloat( CBlock *block ) { return Error("syntax error : expected float; found %s", GetTokenName(type) ); } - + if (type == TK_FLOAT) { block->Write( TK_FLOAT, (float) token->GetFloatValue() ); @@ -734,7 +734,7 @@ int CInterpreter::GetString( CBlock *block ) else temp[i] = temptr[i]; } - + temp[ strlen( temptr ) ] = 0; //UGLY HACK END!!! @@ -742,7 +742,7 @@ int CInterpreter::GetString( CBlock *block ) block->Write( TK_STRING, (const char *) &temp ); token->Delete(); - + return true; } @@ -781,7 +781,7 @@ int CInterpreter::GetIdentifier( CBlock *block ) block->Write( TK_IDENTIFIER, (const char *) token->GetStringValue() ); token->Delete(); - + return true; } @@ -984,7 +984,7 @@ int CInterpreter::GetID( char *id_name ) switch (id) { - + //Affect takes control of an entity case ID_AFFECT: @@ -1018,7 +1018,7 @@ int CInterpreter::GetID( char *id_name ) case ID_FLUSH: return GetFlush(); break; - + case ID_RUN: return GetRun(); break; @@ -1563,7 +1563,7 @@ int CInterpreter::GetAffect( void ) if (!Match( TK_OPEN_PARENTHESIS )) return Error("syntax error : '(' not found"); - if ( GetString( &block ) == false ) + if ( GetString( &block ) == false ) return false; if (!LookAhead( TK_IDENTIFIER )) @@ -1581,7 +1581,7 @@ int CInterpreter::GetAffect( void ) { case TYPE_INSERT: case TYPE_FLUSH: - + block.Write( TK_FLOAT, (float) type ); break; @@ -1677,7 +1677,7 @@ int CInterpreter::GetSet( void ) switch( GetNextType() ) { case TK_INT: - + if ( GetInteger( &block ) == false ) return false; @@ -1691,7 +1691,7 @@ int CInterpreter::GetSet( void ) break; case TK_STRING: - + if ( GetString( &block ) == false ) return false; @@ -1703,7 +1703,7 @@ int CInterpreter::GetSet( void ) return false; break; - + default: if ( MatchTag() ) @@ -1711,7 +1711,7 @@ int CInterpreter::GetSet( void ) GetTag( &block ); break; } - + if ( MatchRandom() ) { GetRandom( &block ); @@ -1959,7 +1959,7 @@ int CInterpreter::GetRemove( void ) // this is just so people can put comments in scripts in BehavEd and not have them lost as normal comments would be. // int CInterpreter::GetRem( void ) -{ +{ CBlock block; block.Create( ID_REM ); @@ -1972,7 +1972,7 @@ int CInterpreter::GetRem( void ) if (Match( TK_CLOSED_PARENTHESIS )) return true; - GetString( &block ); + GetString( &block ); if (!Match( TK_CLOSED_PARENTHESIS )) return Error("rem : function only takes 1 optional parameter"); @@ -2025,17 +2025,17 @@ int CInterpreter::GetCamera( void ) break; case TYPE_ZOOM: //ZOOM ( FOV, DURATION ) - + block.Write( TK_FLOAT, (float) type ); if ( GetFloat( &block ) == false ) return false; - + if ( GetFloat( &block ) == false ) return false; break; - + case TYPE_MOVE: //MOVE ( ORIGIN, DURATION ) block.Write( TK_FLOAT, (float) type ); @@ -2047,9 +2047,9 @@ int CInterpreter::GetCamera( void ) return false; break; - + case TYPE_FADE: //FADE ( SOURCE(R,G,B,A), DEST(R,G,B,A), DURATION ) - + block.Write( TK_FLOAT, (float) type ); //Source color @@ -2357,15 +2357,15 @@ int CInterpreter::Interpret( CTokenizer *Tokenizer, CBlockStream *BlockStream, c int type, blockLevel = 0, parenthesisLevel = 0; m_sCurrentFile = filename; // used during error reporting because you can't ask tokenizer for pushed streams - + m_tokenizer = Tokenizer; m_blockStream = BlockStream; m_iCurrentLine = m_tokenizer->GetCurLine(); - token = m_tokenizer->GetToEndOfLine(TK_STRING); - m_sCurrentLine = token->GetStringValue(); + token = m_tokenizer->GetToEndOfLine(TK_STRING); + m_sCurrentLine = token->GetStringValue(); m_tokenizer->PutBackToken(token, false, NULL, true); - + m_iBadCBlockNumber = 0; while (m_tokenizer->GetRemainingSize() > 0) @@ -2389,11 +2389,11 @@ int CInterpreter::Interpret( CTokenizer *Tokenizer, CBlockStream *BlockStream, c // read the next line, then put it back token->Delete(); m_iCurrentLine = m_tokenizer->GetCurLine(); - token = m_tokenizer->GetToEndOfLine(TK_STRING); - m_sCurrentLine = token->GetStringValue(); + token = m_tokenizer->GetToEndOfLine(TK_STRING); + m_sCurrentLine = token->GetStringValue(); m_tokenizer->PutBackToken(token, false, NULL, true); break; - + case TK_CHAR: case TK_STRING: token->Delete(); @@ -2401,21 +2401,21 @@ int CInterpreter::Interpret( CTokenizer *Tokenizer, CBlockStream *BlockStream, c Error("syntax error : unexpected string"); return m_iBadCBlockNumber; break; - + case TK_INT: token->Delete(); - m_iBadCBlockNumber = -m_iBadCBlockNumber; + m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : unexpected integer"); return m_iBadCBlockNumber; break; - + case TK_FLOAT: token->Delete(); m_iBadCBlockNumber = -m_iBadCBlockNumber; Error("syntax error : unexpected float"); return m_iBadCBlockNumber; break; - + case TK_IDENTIFIER: m_iBadCBlockNumber++; if (!GetID( (char *) token->GetStringValue() )) @@ -2425,7 +2425,7 @@ int CInterpreter::Interpret( CTokenizer *Tokenizer, CBlockStream *BlockStream, c } token->Delete(); break; - + case TK_BLOCK_START: token->Delete(); if (parenthesisLevel) @@ -2446,7 +2446,7 @@ int CInterpreter::Interpret( CTokenizer *Tokenizer, CBlockStream *BlockStream, c Error("syntax error : brace inside parenthesis"); return m_iBadCBlockNumber; } - + block.Create( ID_BLOCK_END ); m_blockStream->WriteBlock( &block ); block.Free(); diff --git a/codeJK2/icarus/Sequence.cpp b/codeJK2/icarus/Sequence.cpp index f2ab7507e4..170c852184 100644 --- a/codeJK2/icarus/Sequence.cpp +++ b/codeJK2/icarus/Sequence.cpp @@ -131,7 +131,7 @@ void CSequence::RemoveChild( CSequence *child ) assert( child ); if ( child == NULL ) return; - + //Remove the child m_children.remove( child ); m_numChildren--; @@ -177,7 +177,7 @@ void CSequence::SetParent( CSequence *parent ) m_flags |= SQ_RETAIN; if ( parent->m_flags & SQ_PENDING ) - m_flags |= SQ_PENDING; + m_flags |= SQ_PENDING; } /* @@ -203,7 +203,7 @@ CBlock *CSequence::PopCommand( int type ) command = m_commands.front(); m_commands.pop_front(); m_numCommands--; - + return command; break; @@ -212,7 +212,7 @@ CBlock *CSequence::PopCommand( int type ) command = m_commands.back(); m_commands.pop_back(); m_numCommands--; - + return command; break; } @@ -236,7 +236,7 @@ int CSequence::PushCommand( CBlock *block, int type ) switch ( type ) { case PUSH_FRONT: - + m_commands.push_front( block ); m_numCommands++; @@ -377,14 +377,14 @@ int CSequence::SaveCommand( CBlock *block ) saved_game.write_chunk( INT_ID('B', 'M', 'I', 'D'), bID); - + //Save out the data size size = bm->GetSize(); saved_game.write_chunk( INT_ID('B', 'S', 'I', 'Z'), size); - + //Save out the raw data const uint8_t* raw_data = static_cast(bm->GetData()); @@ -425,7 +425,7 @@ int CSequence::Save( void ) saved_game.write_chunk( INT_ID('S', 'R', 'I', 'D'), id); - + //Save the number of children saved_game.write_chunk( INT_ID('S', 'N', 'C', 'H'), @@ -473,7 +473,7 @@ Load int CSequence::Load( void ) { - unsigned char flags = 0; + unsigned char flags = 0; CSequence *sequence; CBlock *block; int id = 0, numMembers = 0; @@ -491,7 +491,7 @@ int CSequence::Load( void ) id); m_parent = ( id != -1 ) ? m_owner->GetSequence( id ) : NULL; - + //Get the return sequence saved_game.read_chunk( INT_ID('S', 'R', 'I', 'D'), @@ -515,7 +515,7 @@ int CSequence::Load( void ) //Get the desired sequence if ( ( sequence = m_owner->GetSequence( id ) ) == NULL ) return false; - + //Insert this into the list STL_INSERT( m_children, sequence ); @@ -523,7 +523,7 @@ int CSequence::Load( void ) m_childrenMap[ i ] = sequence; } - + //Get the sequence flags saved_game.read_chunk( INT_ID('S', 'F', 'L', 'G'), @@ -550,9 +550,9 @@ int CSequence::Load( void ) id); block = new CBlock; - + block->Create( id ); - + //Read the block's flags saved_game.read_chunk( INT_ID('B', 'F', 'L', 'G'), @@ -566,7 +566,7 @@ int CSequence::Load( void ) saved_game.read_chunk( INT_ID('B', 'N', 'U', 'M'), numMembers); - + for ( int j = 0; j < numMembers; j++ ) { bID = 0; @@ -630,7 +630,7 @@ int CSequence::Load( void ) case ID_RANDOM: block->Write( ID_RANDOM, *(float *) bData );//(float) ID_RANDOM ); break; - + case TK_EQUALS: case TK_GREATER_THAN: case TK_LESS_THAN: @@ -643,7 +643,7 @@ int CSequence::Load( void ) return false; break; } - + //Get rid of the temp memory ICARUS_Free( bData ); } diff --git a/codeJK2/icarus/Sequencer.cpp b/codeJK2/icarus/Sequencer.cpp index fb6f3db1d9..89c8164e9e 100644 --- a/codeJK2/icarus/Sequencer.cpp +++ b/codeJK2/icarus/Sequencer.cpp @@ -32,7 +32,7 @@ along with this program; if not, see . #include "assert.h" #include "../code/qcommon/ojk_saved_game_helper.h" -// Sequencer +// Sequencer CSequencer::CSequencer( void ) { @@ -129,7 +129,7 @@ int CSequencer::Flush( CSequence *owner ) { if ( owner == NULL ) return SEQ_FAILED; - + Recall(); sequence_l::iterator sli; @@ -145,11 +145,11 @@ int CSequencer::Flush( CSequence *owner ) //Remove it from the map m_sequenceMap.erase( (*sli)->GetID() ); - + //Delete it, and remove all references RemoveSequence( (*sli) ); m_owner->DeleteSequence( (*sli) ); - + //Delete from the sequence list and move on sli = m_sequences.erase( sli ); } @@ -198,7 +198,7 @@ void CSequencer::DeleteStream( bstream_t *bstream ) } bstream->stream->Free(); - + delete bstream->stream; delete bstream; @@ -279,7 +279,7 @@ CSequence *CSequencer::AddSequence( CSequence *parent, CSequence *returnSeq, int sequence->SetFlags( flags ); sequence->SetParent( parent ); sequence->SetReturn( returnSeq ); - + return sequence; } @@ -294,12 +294,12 @@ Retrieves a sequence by its ID CSequence *CSequencer::GetSequence( int id ) { sequenceID_m::iterator mi; - + mi = m_sequenceMap.find( id ); if ( mi == m_sequenceMap.end() ) return NULL; - + return (*mi).second; } @@ -330,12 +330,12 @@ Runs a script int CSequencer::Run( char *buffer, long size ) { bstream_t *blockStream; - + Recall(); //Create a new stream blockStream = AddStream(); - + //Open the stream as an IBI stream if (!blockStream->stream->Open( buffer, size )) { @@ -345,7 +345,7 @@ int CSequencer::Run( char *buffer, long size ) CSequence *sequence = AddSequence( NULL, m_curSequence, SQ_COMMON ); - // Interpret the command blocks and route them properly + // Interpret the command blocks and route them properly if ( S_FAILED( Route( sequence, blockStream )) ) { //Error code is set inside of Route() @@ -402,7 +402,7 @@ int CSequencer::ParseRun( CBlock *block ) m_curSequence->AddChild( new_sequence ); - // Interpret the command blocks and route them properly + // Interpret the command blocks and route them properly if ( S_FAILED( Route( new_sequence, new_stream )) ) { //Error code is set inside of Route() @@ -432,10 +432,10 @@ Parses an if statement int CSequencer::ParseIf( CBlock *block, bstream_t *bstream ) { CSequence *sequence; - + //Create the container sequence sequence = AddSequence( m_curSequence, m_curSequence, SQ_CONDITIONAL ); - + assert( sequence ); if ( sequence == NULL ) { @@ -452,7 +452,7 @@ int CSequencer::ParseIf( CBlock *block, bstream_t *bstream ) //Push this onto the stack to mark the conditional entrance PushCommand( block, PUSH_FRONT ); - + //Recursively obtain the conditional body Route( sequence, bstream ); @@ -475,12 +475,12 @@ int CSequencer::ParseElse( CBlock *block, bstream_t *bstream ) //The else is not retained delete block; block = NULL; - + CSequence *sequence; - + //Create the container sequence sequence = AddSequence( m_curSequence, m_curSequence, SQ_CONDITIONAL ); - + assert( sequence ); if ( sequence == NULL ) { @@ -499,7 +499,7 @@ int CSequencer::ParseElse( CBlock *block, bstream_t *bstream ) } m_elseOwner->Write( TK_FLOAT, (float) sequence->GetID() ); - + m_elseOwner->SetFlag( BF_ELSE ); //Recursively obtain the conditional body @@ -526,23 +526,23 @@ int CSequencer::ParseLoop( CBlock *block, bstream_t *bstream ) float min, max; int rIter; int memberNum = 0; - + //Set the parent sequence = AddSequence( m_curSequence, m_curSequence, ( SQ_LOOP | SQ_RETAIN ) ); - + assert( sequence ); if ( sequence == NULL ) { m_ie->I_DPrintf( WL_ERROR, "ParseLoop : failed to allocate container sequence" ); delete block; - block = NULL; + block = NULL; return SEQ_FAILED; } m_curSequence->AddChild( sequence ); //Set the number of iterations of this sequence - + bm = block->GetMember( memberNum++ ); if ( bm->GetID() == ID_RANDOM ) @@ -550,7 +550,7 @@ int CSequencer::ParseLoop( CBlock *block, bstream_t *bstream ) //Parse out the random number min = *(float *) block->GetMemberData( memberNum++ ); max = *(float *) block->GetMemberData( memberNum++ ); - + rIter = (int) m_ie->I_Random( min, max ); sequence->SetIterations( rIter ); } @@ -558,13 +558,13 @@ int CSequencer::ParseLoop( CBlock *block, bstream_t *bstream ) { sequence->SetIterations ( (int) (*(float *) bm->GetData()) ); } - + //Add a unique loop identifier to the block for reference later block->Write( TK_FLOAT, (float) sequence->GetID() ); //Push this onto the stack to mark the loop entrance PushCommand( block, PUSH_FRONT ); - + //Recursively obtain the loop Route( sequence, bstream ); @@ -591,7 +591,7 @@ int CSequencer::AddAffect( bstream_t *bstream, int retain, int *id ) //This will be replaced once it's actually used, but this will restore the route state properly sequence->SetReturn( m_curSequence ); - + //We need this as a temp holder new_stream.last = m_curStream; new_stream.stream = bstream->stream; @@ -629,7 +629,7 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) if( !ent ) // if there wasn't a valid entname in the affect, we need to check if it's a get command { //try to parse a 'get' command that is embeded in this 'affect' - + int id; char *p1 = NULL; char *name = 0; @@ -639,7 +639,7 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) // bm = block->GetMember( 0 ); id = bm->GetID(); - + switch ( id ) { // these 3 cases probably aren't necessary @@ -649,9 +649,9 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) p1 = (char *) bm->GetData(); break; - case ID_GET: + case ID_GET: { - int type; + int type; //get( TYPE, NAME ) type = (int) (*(float *) block->GetMemberData( 1 )); @@ -659,7 +659,7 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) switch ( type ) // what type are they attempting to get { - + case TK_STRING: //only string is acceptable for affect, store result in p1 if ( m_ie->I_GetString( m_ownerID, type, name, &p1 ) == false) @@ -698,7 +698,7 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) { // a valid entity name was not returned from the get command m_ie->I_DPrintf( WL_WARNING, "'%s' : invalid affect() target\n"); } - + } // end if(!ent) if( ent ) @@ -709,7 +709,7 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) if (stream_sequencer == NULL) { m_ie->I_DPrintf( WL_WARNING, "'%s' : invalid affect() target\n", entname ); - + //Fast-forward out of this affect block onto the next valid code CSequence *backSeq = m_curSequence; @@ -734,12 +734,12 @@ int CSequencer::ParseAffect( CBlock *block, bstream_t *bstream ) //FIXME: If the target sequence is freed, what then? (!suspect!) block->Write( TK_FLOAT, (float) ret ); - + PushCommand( block, PUSH_FRONT ); /* //Don't actually do these right now, we're just pre-processing (parsing) the affect if( ent ) - { // ents need to update upon being affected + { // ents need to update upon being affected ent->taskManager->Update(); } */ @@ -780,7 +780,7 @@ int CSequencer::ParseTask( CBlock *block, bstream_t *bstream ) //The current group is set to this group, all subsequent commands (until a block end) will fall into this task group group->SetParent( m_curGroup ); m_curGroup = group; - + //Keep an association between this task and the container sequence AddTaskSequence( sequence, group ); @@ -831,10 +831,10 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) { //Marks the end of a blocked section case ID_BLOCK_END: - + //Save this as a pre-process marker PushCommand( block, PUSH_FRONT ); - + if ( m_curSequence->HasFlag( SQ_RUN ) || m_curSequence->HasFlag( SQ_AFFECT ) ) { //Go back to the last stream @@ -847,7 +847,7 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) m_curStream = bstream->last; m_curGroup = m_curGroup->GetParent(); } - + m_curSequence = m_curSequence->GetReturn(); return SEQ_OK; @@ -871,7 +871,7 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) //Loop pre-processor case ID_LOOP: - + if S_FAILED( ParseLoop( block, bstream ) ) return SEQ_FAILED; @@ -900,7 +900,7 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) break; case ID_TASK: - + if S_FAILED( ParseTask( block, bstream ) ) return SEQ_FAILED; @@ -931,9 +931,9 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) //Error default: - + m_ie->I_DPrintf( WL_ERROR, "'%d' : invalid block ID", block->GetBlockID() ); - + return SEQ_FAILED; break; } @@ -957,7 +957,7 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) //Check to start the communication if ( ( bstream->last == NULL ) && ( m_numCommands > 0 ) ) - { + { //Everything is routed, so get it all rolling Prime( m_taskManager, PopCommand( POP_BACK ) ); } @@ -966,7 +966,7 @@ int CSequencer::Route( CSequence *sequence, bstream_t *bstream ) //Free the stream DeleteStream( bstream ); - + return SEQ_OK; } @@ -1007,7 +1007,7 @@ void CSequencer::CheckRun( CBlock **command ) } m_curSequence = GetSequence( id ); - + //TODO: Emit warning assert( m_curSequence ); if ( m_curSequence == NULL ) @@ -1020,14 +1020,14 @@ void CSequencer::CheckRun( CBlock **command ) if ( m_curSequence->GetNumCommands() > 0 ) { *command = PopCommand( POP_BACK ); - + Prep( command ); //Account for any other pre-processes return; } return; } - + //Check for the end of a run if ( ( block->GetBlockID() == ID_BLOCK_END ) && ( m_curSequence->HasFlag( SQ_RUN ) ) ) { @@ -1047,10 +1047,10 @@ void CSequencer::CheckRun( CBlock **command ) if ( m_curSequence && m_curSequence->GetNumCommands() > 0 ) { *command = PopCommand( POP_BACK ); - + Prep( command ); //Account for any other pre-processes return; - } + } //FIXME: Check this... } @@ -1111,7 +1111,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) p1 = (char *) bm->GetData(); break; - case ID_GET: + case ID_GET: { int type; char *name; @@ -1135,7 +1135,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) Com_sprintf( tempString1, sizeof( tempString1 ), "%.3f", fVal ); p1 = (char *) tempString1; } - + break; case TK_INT: @@ -1154,7 +1154,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) if ( m_ie->I_GetString( m_ownerID, type, name, &p1 ) == false) return false; - + break; case TK_VECTOR: @@ -1167,7 +1167,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) Com_sprintf( tempString1, sizeof( tempString1 ), "%.3f %.3f %.3f", vVal[0], vVal[1], vVal[2] ); p1 = (char *) tempString1; } - + break; } @@ -1281,7 +1281,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) p2 = (char *) bm->GetData(); break; - case ID_GET: + case ID_GET: { int type; char *name; @@ -1305,7 +1305,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) Com_sprintf( tempString2, sizeof( tempString2 ), "%.3f", fVal ); p2 = (char *) tempString2; } - + break; case TK_INT: @@ -1324,7 +1324,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) if ( m_ie->I_GetString( m_ownerID, type, name, &p2 ) == false) return false; - + break; case TK_VECTOR: @@ -1337,7 +1337,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) Com_sprintf( tempString2, sizeof( tempString2 ), "%.3f %.3f %.3f", vVal[0], vVal[1], vVal[2] ); p2 = (char *) tempString2; } - + break; } @@ -1345,7 +1345,7 @@ int CSequencer::EvaluateConditional( CBlock *block ) } case ID_RANDOM: - + { float min, max; //FIXME: This will not account for nested Q_flrand(0.0f, 1.0f) statements @@ -1450,14 +1450,14 @@ void CSequencer::CheckIf( CBlock **command ) block = NULL; *command = NULL; } - + m_curSequence = successSeq; //Recursively work out any other pre-processors *command = PopCommand( POP_BACK ); Prep( command ); - - return; + + return; } if ( ( ret == false ) && ( block->HasFlag( BF_ELSE ) ) ) @@ -1485,14 +1485,14 @@ void CSequencer::CheckIf( CBlock **command ) block = NULL; *command = NULL; } - + m_curSequence = failureSeq; //Recursively work out any other pre-processors *command = PopCommand( POP_BACK ); Prep( command ); - - return; + + return; } //Only save the conditional statement if the calling sequence is retained @@ -1510,8 +1510,8 @@ void CSequencer::CheckIf( CBlock **command ) //Conditional failed, just move on to the next command *command = PopCommand( POP_BACK ); Prep( command ); - - return; + + return; } if ( ( block->GetBlockID() == ID_BLOCK_END ) && ( m_curSequence->HasFlag( SQ_CONDITIONAL ) ) ) @@ -1534,10 +1534,10 @@ void CSequencer::CheckIf( CBlock **command ) block = NULL; *command = NULL; } - + //Back out of the conditional and resume the previous sequence m_curSequence = ReturnSequence( m_curSequence ); - + //This can safely happen if ( m_curSequence == NULL ) { @@ -1566,7 +1566,7 @@ void CSequencer::CheckLoop( CBlock **command ) int iterations; int loopID; int memberNum = 0; - + if ( block == NULL ) return; @@ -1581,18 +1581,18 @@ void CSequencer::CheckLoop( CBlock **command ) //Parse out the random number min = *(float *) block->GetMemberData( memberNum++ ); max = *(float *) block->GetMemberData( memberNum++ ); - + iterations = (int) m_ie->I_Random( min, max ); } else { iterations = (int) (*(float *) bm->GetData()); } - + loopID = (int) (*(float *) block->GetMemberData( memberNum++ )); CSequence *loop = GetSequence( loopID ); - + //TODO: Emit warning assert( loop ); if ( loop == NULL ) @@ -1623,16 +1623,16 @@ void CSequencer::CheckLoop( CBlock **command ) block = NULL; *command = NULL; } - + m_curSequence = loop; //Recursively work out any other pre-processors *command = PopCommand( POP_BACK ); Prep( command ); - + return; } - + //Check for the end of the loop if ( ( block->GetBlockID() == ID_BLOCK_END ) && ( m_curSequence->HasFlag( SQ_LOOP ) ) ) { @@ -1645,10 +1645,10 @@ void CSequencer::CheckLoop( CBlock **command ) { //Another iteration is going to happen, so this will need to be considered again PushCommand( block, PUSH_FRONT ); - + *command = PopCommand( POP_BACK ); Prep( command ); - + return; } else @@ -1671,10 +1671,10 @@ void CSequencer::CheckLoop( CBlock **command ) block = NULL; *command = NULL; } - + //Back out of the loop and resume the previous sequence m_curSequence = ReturnSequence( m_curSequence ); - + //This can safely happen if ( m_curSequence == NULL ) { @@ -1753,11 +1753,11 @@ void CSequencer::CheckAffect( CBlock **command ) CSequencer *sequencer = NULL; entname = (char*) block->GetMemberData( memberNum++ ); ent = m_ie->I_GetEntityByName( entname ); - + if( !ent ) // if there wasn't a valid entname in the affect, we need to check if it's a get command { //try to parse a 'get' command that is embeded in this 'affect' - + int id; char *p1 = NULL; char *name = 0; @@ -1767,7 +1767,7 @@ void CSequencer::CheckAffect( CBlock **command ) // bm = block->GetMember( 0 ); id = bm->GetID(); - + switch ( id ) { // these 3 cases probably aren't necessary @@ -1777,9 +1777,9 @@ void CSequencer::CheckAffect( CBlock **command ) p1 = (char *) bm->GetData(); break; - case ID_GET: + case ID_GET: { - int type; + int type; //get( TYPE, NAME ) type = (int) (*(float *) block->GetMemberData( memberNum++ )); @@ -1787,7 +1787,7 @@ void CSequencer::CheckAffect( CBlock **command ) switch ( type ) // what type are they attempting to get { - + case TK_STRING: //only string is acceptable for affect, store result in p1 if ( m_ie->I_GetString( m_ownerID, type, name, &p1 ) == false) @@ -1820,7 +1820,7 @@ void CSequencer::CheckAffect( CBlock **command ) { // a valid entity name was not returned from the get command m_ie->I_DPrintf( WL_WARNING, "'%s' : invalid affect() target\n"); } - + } // end if(!ent) if( ent ) @@ -1831,9 +1831,9 @@ void CSequencer::CheckAffect( CBlock **command ) { //there was no get, increment manually before next step memberNum++; } - int type = (int) (*(float *) block->GetMemberData( memberNum )); + int type = (int) (*(float *) block->GetMemberData( memberNum )); int id = (int) (*(float *) block->GetMemberData( memberNum+1 )); - + if ( m_curSequence->HasFlag( SQ_RETAIN ) ) { PushCommand( block, PUSH_FRONT ); @@ -1844,7 +1844,7 @@ void CSequencer::CheckAffect( CBlock **command ) block = NULL; *command = NULL; } - + //NOTENOTE: If this isn't found, continue on to the next command if ( sequencer == NULL ) { @@ -1858,7 +1858,7 @@ void CSequencer::CheckAffect( CBlock **command ) *command = PopCommand( POP_BACK ); Prep( command ); if( ent ) - { // ents need to update upon being affected + { // ents need to update upon being affected ent->taskManager->Update(); } @@ -1877,7 +1877,7 @@ void CSequencer::CheckAffect( CBlock **command ) block = NULL; *command = NULL; } - + m_curSequence = ReturnSequence( m_curSequence ); if ( m_curSequence == NULL ) @@ -1889,7 +1889,7 @@ void CSequencer::CheckAffect( CBlock **command ) *command = PopCommand( POP_BACK ); Prep( command ); if( ent ) - { // ents need to update upon being affected + { // ents need to update upon being affected ent->taskManager->Update(); } @@ -1961,7 +1961,7 @@ void CSequencer::CheckDo( CBlock **command ) //Recursively work out any other pre-processors *command = PopCommand( POP_BACK ); Prep( command ); - + return; } @@ -1977,7 +1977,7 @@ void CSequencer::CheckDo( CBlock **command ) block = NULL; *command = NULL; } - + m_taskManager->MarkTask( m_curGroup->GetGUID(), TASK_END ); m_curGroup = m_curGroup->GetParent(); @@ -2142,22 +2142,22 @@ int CSequencer::Affect( int id, int type ) //Get rid of all old code Flush( sequence ); - sequence->RemoveFlag( SQ_PENDING, true ); - + sequence->RemoveFlag( SQ_PENDING, true ); + m_curSequence = sequence; Prime( m_taskManager, PopCommand( POP_BACK ) ); break; - + case TYPE_INSERT: Recall(); - + sequence->SetReturn( m_curSequence ); - + sequence->RemoveFlag( SQ_PENDING, true ); - + m_curSequence = sequence; Prime( m_taskManager, PopCommand( POP_BACK ) ); @@ -2190,7 +2190,7 @@ int CSequencer::PushCommand( CBlock *command, int flag ) m_curSequence->PushCommand( command, flag ); m_numCommands++; - + //Invalid flag return SEQ_OK; } @@ -2210,7 +2210,7 @@ CBlock *CSequencer::PopCommand( int flag ) if ( m_curSequence == NULL ) return NULL; - CBlock *block = m_curSequence->PopCommand( flag ); + CBlock *block = m_curSequence->PopCommand( flag ); if ( block != NULL ) m_numCommands--; @@ -2250,7 +2250,7 @@ int CSequencer::RemoveSequence( CSequence *sequence ) temp->SetReturn( NULL ); } - + return SEQ_OK; } @@ -2287,7 +2287,7 @@ int CSequencer::DestroySequence( CSequence *sequence ) } m_owner->DeleteSequence( sequence ); - + return SEQ_OK; } @@ -2364,7 +2364,7 @@ int CSequencer::Save( void ) numTasks); STL_ITERATE( ti, m_taskSequences ) - { + { //Save the task group's ID id = ((*ti).first)->GetGUID(); @@ -2408,7 +2408,7 @@ Load */ int CSequencer::Load( void ) -{ +{ int i; ojk::SavedGameHelper saved_game( @@ -2464,7 +2464,7 @@ int CSequencer::Load( void ) saved_game.read_chunk( INT_ID('S', 'T', 'I', 'D'), taskID); - + //Read in the sequence's ID saved_game.read_chunk( INT_ID('S', 'S', 'I', 'D'), diff --git a/codeJK2/icarus/TaskManager.cpp b/codeJK2/icarus/TaskManager.cpp index feb0014b33..d0cbf4b3a6 100644 --- a/codeJK2/icarus/TaskManager.cpp +++ b/codeJK2/icarus/TaskManager.cpp @@ -20,7 +20,7 @@ along with this program; if not, see . =========================================================================== */ -// Task Manager +// Task Manager // // -- jweier @@ -75,7 +75,7 @@ Free void CTask::Free( void ) { - //NOTENOTE: The block is not consumed by the task, it is the sequencer's job to clean blocks up + //NOTENOTE: The block is not consumed by the task, it is the sequencer's job to clean blocks up delete this; } @@ -134,7 +134,7 @@ Add int CTaskGroup::Add( CTask *task ) { m_completedTasks[ task->GetGUID() ] = false; - return TASK_OK; + return TASK_OK; } /* @@ -229,7 +229,7 @@ int CTaskManager::Free( void ) { delete (*gi); } - + m_taskGroups.clear(); m_taskGroupNameMap.clear(); m_taskGroupIDMap.clear(); @@ -244,9 +244,9 @@ Flush */ int CTaskManager::Flush( void ) -{ +{ //FIXME: Rewrite - + return true; } @@ -267,10 +267,10 @@ CTaskGroup *CTaskManager::AddTaskGroup( const char *name ) if ( tgni != m_taskGroupNameMap.end() ) { group = (*tgni).second; - + //Clear it and just move on group->Init(); - + return group; } @@ -403,7 +403,7 @@ int CTaskManager::GetFloat( int entID, CBlock *block, int &memberNum, float &val if ( type != TK_FLOAT ) { (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() call tried to return a non-FLOAT parameter!\n" ); - return false; + return false; } return (m_owner->GetInterface())->I_GetFloat( entID, type, name, &value ); @@ -432,7 +432,7 @@ int CTaskManager::GetFloat( int entID, CBlock *block, int &memberNum, float &val } CBlockMember *bm = block->GetMember( memberNum ); - + if ( bm->GetID() == TK_INT ) { value = (float) (*(int *) block->GetMemberData( memberNum++ )); @@ -514,7 +514,7 @@ int CTaskManager::GetVector( int entID, CBlock *block, int &memberNum, vector_t (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Unable to find tag \"%s\"!\n", tagName ); assert(0); return TASK_FAILED; - } + } return true; } @@ -574,7 +574,7 @@ int CTaskManager::Get( int entID, CBlock *block, int &memberNum, char **value ) (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() parameter \"%s\" could not be found!\n", name ); return false; } - + return true; break; @@ -584,14 +584,14 @@ int CTaskManager::Get( int entID, CBlock *block, int &memberNum, char **value ) if ( (m_owner->GetInterface())->I_GetFloat( entID, type, name, &temp ) == false ) { - (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() parameter \"%s\" could not be found!\n", name ); + (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() parameter \"%s\" could not be found!\n", name ); return false; } Com_sprintf( tempBuffer, sizeof( tempBuffer ), "%f", temp ); *value = (char *) tempBuffer; } - + return true; break; @@ -601,14 +601,14 @@ int CTaskManager::Get( int entID, CBlock *block, int &memberNum, char **value ) if ( (m_owner->GetInterface())->I_GetVector( entID, type, name, vval ) == false ) { - (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() parameter \"%s\" could not be found!\n", name ); + (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Get() parameter \"%s\" could not be found!\n", name ); return false; } Com_sprintf( tempBuffer, sizeof( tempBuffer ), "%f %f %f", vval[0], vval[1], vval[2] ); *value = (char *) tempBuffer; } - + return true; break; @@ -700,7 +700,7 @@ int CTaskManager::Get( int entID, CBlock *block, int &memberNum, char **value ) return true; } - + //TODO: Emit warning assert( 0 ); (m_owner->GetInterface())->I_DPrintf( WL_WARNING, "Unexpected value; expected type STRING\n" ); @@ -739,16 +739,16 @@ int CTaskManager::Go( void ) (m_owner->GetInterface())->I_DPrintf( WL_ERROR, "Invalid task found in Go()!\n" ); return TASK_FAILED; } - + //If this hasn't been stamped, do so if ( task->GetTimeStamp() == 0 ) task->SetTimeStamp( ( m_owner->GetInterface())->I_GetTime() ); - + //Switch and call the proper function switch( task->GetID() ) { case ID_WAIT: - + Wait( task, completed ); //Push it to consider it again on the next frame if not complete @@ -763,7 +763,7 @@ int CTaskManager::Go( void ) break; case ID_WAITSIGNAL: - + WaitSignal( task, completed ); //Push it to consider it again on the next frame if not complete @@ -776,7 +776,7 @@ int CTaskManager::Go( void ) Completed( task->GetGUID() ); break; - + case ID_PRINT: //print( STRING ) Print( task ); break; @@ -842,10 +842,10 @@ int CTaskManager::Go( void ) task->Free(); } - + //FIXME: A command surge limiter could be implemented at this point to be sure a script doesn't // execute too many commands in one cycle. This may, however, cause timing errors to surface. - + return TASK_OK; } @@ -1032,14 +1032,14 @@ CTask *CTaskManager::PopTask( int flag ) case POP_FRONT: task = m_tasks.front(); m_tasks.pop_front(); - + return task; break; case POP_BACK: task = m_tasks.back(); m_tasks.pop_back(); - + return task; break; } @@ -1079,7 +1079,7 @@ CBlock *CTaskManager::GetCurrentTask( void ) int CTaskManager::Wait( CTask *task, bool &completed ) { CBlockMember *bm; - CBlock *block = task->GetBlock(); + CBlock *block = task->GetBlock(); char *sVal; float dwtime; int memberNum = 0; @@ -1132,7 +1132,7 @@ int CTaskManager::Wait( CTask *task, bool &completed ) { ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, dwtime ) ); } - + if ( task->GetTimeStamp() == (m_owner->GetInterface())->I_GetTime() ) { //Print out the debug info @@ -1204,7 +1204,7 @@ int CTaskManager::Print( CTask *task ) (m_owner->GetInterface())->I_CenterPrint( sVal ); Completed( task->GetGUID() ); - + return TASK_OK; } @@ -1228,7 +1228,7 @@ int CTaskManager::Sound( CTask *task ) //Only instantly complete if the user has requested it if( (m_owner->GetInterface())->I_PlaySound( task->GetGUID(), m_ownerID, sVal2, sVal ) ) Completed( task->GetGUID() ); - + return TASK_OK; } @@ -1273,7 +1273,7 @@ int CTaskManager::Rotate( CTask *task ) (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d rotate( <%f,%f,%f>, %d); [%d]", m_ownerID, vector[0], vector[1], vector[2], (int) duration, task->GetTimeStamp() ); (m_owner->GetInterface())->I_Lerp2Angles( task->GetGUID(), m_ownerID, vector, duration ); - + return TASK_OK; } @@ -1290,12 +1290,12 @@ int CTaskManager::Remove( CTask *task ) int memberNum = 0; ICARUS_VALIDATE( Get( m_ownerID, block, memberNum, &sVal ) ); - + (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d remove(\"%s\"); [%d]", m_ownerID, sVal, task->GetTimeStamp() ); (m_owner->GetInterface())->I_Remove( m_ownerID, sVal ); Completed( task->GetGUID() ); - + return TASK_OK; } @@ -1320,7 +1320,7 @@ int CTaskManager::Camera( CTask *task ) switch ( (int) type ) { case TYPE_PAN: - + ICARUS_VALIDATE( GetVector( m_ownerID, block, memberNum, vector ) ); ICARUS_VALIDATE( GetVector( m_ownerID, block, memberNum, vector2 ) ); @@ -1331,7 +1331,7 @@ int CTaskManager::Camera( CTask *task ) break; case TYPE_ZOOM: - + ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal2 ) ); @@ -1370,7 +1370,7 @@ int CTaskManager::Camera( CTask *task ) break; case TYPE_TRACK: - + ICARUS_VALIDATE( Get( m_ownerID, block, memberNum, &sVal ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal2 ) ); @@ -1383,7 +1383,7 @@ int CTaskManager::Camera( CTask *task ) ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal2 ) ); - + (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d camera( DISTANCE, %f, %f); [%d]", m_ownerID, fVal, fVal2, task->GetTimeStamp() ); ie->I_CameraDistance( fVal, fVal2 ); break; @@ -1395,7 +1395,7 @@ int CTaskManager::Camera( CTask *task ) ICARUS_VALIDATE( GetVector( m_ownerID, block, memberNum, vector2 ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal2 ) ); - + ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal3 ) ); (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d camera( FADE, <%f %f %f>, %f, <%f %f %f>, %f, %f); [%d]", m_ownerID, vector[0], vector[1], vector[2], fVal, vector2[0], vector2[1], vector2[2], fVal2, fVal3, task->GetTimeStamp() ); @@ -1418,7 +1418,7 @@ int CTaskManager::Camera( CTask *task ) (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d camera( DISABLE ); [%d]", m_ownerID, task->GetTimeStamp() ); ie->I_CameraDisable(); break; - + case TYPE_SHAKE: ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal ) ); ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, fVal2 ) ); @@ -1453,8 +1453,8 @@ int CTaskManager::Move( CTask *task ) if ( GetVector( m_ownerID, block, memberNum, vector2 ) == false ) { ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, duration ) ); - - + + (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d move( <%f %f %f>, %f ); [%d]", m_ownerID, vector[0], vector[1], vector[2], duration, task->GetTimeStamp() ); (m_owner->GetInterface())->I_Lerp2Pos( task->GetGUID(), m_ownerID, vector, NULL, duration ); @@ -1463,10 +1463,10 @@ int CTaskManager::Move( CTask *task ) //Get the duration and make the call ICARUS_VALIDATE( GetFloat( m_ownerID, block, memberNum, duration ) ); - + (m_owner->GetInterface())->I_DPrintf( WL_DEBUG, "%4d move( <%f %f %f>, <%f %f %f>, %f ); [%d]", m_ownerID, vector[0], vector[1], vector[2], vector2[0], vector2[1], vector2[2], duration, task->GetTimeStamp() ); (m_owner->GetInterface())->I_Lerp2Pos( task->GetGUID(), m_ownerID, vector, vector2, duration ); - + return TASK_OK; } @@ -1674,14 +1674,14 @@ int CTaskManager::SaveCommand( CBlock *block ) saved_game.write_chunk( INT_ID('B', 'M', 'I', 'D'), bID); - + //Save out the data size size = bm->GetSize(); saved_game.write_chunk( INT_ID('B', 'S', 'I', 'Z'), size); - + //Save out the raw data const uint8_t* raw_data = static_cast(bm->GetData()); @@ -1727,7 +1727,7 @@ void CTaskManager::Save( void ) //Save out all the tasks tasks_l::iterator ti; - + STL_ITERATE( ti, m_tasks ) { //Save the GUID @@ -1791,7 +1791,7 @@ void CTaskManager::Save( void ) //Save out the command map CTaskGroup::taskCallback_m::iterator tci; - + STL_ITERATE( tci, (*tgi)->m_completedTasks ) { //Write out the ID @@ -1837,7 +1837,7 @@ void CTaskManager::Save( void ) STL_ITERATE( tmi, m_taskGroupNameMap ) { name = ((*tmi).first).c_str(); - + //Make sure this is a valid string assert( ( name != NULL ) && ( name[0] != '\0' ) ); @@ -1899,7 +1899,7 @@ void CTaskManager::Load( void ) saved_game.read_chunk( INT_ID('T', 'S', 'K', '#'), numTasks); - + //Reload all the tasks for ( i = 0; i < numTasks; i++ ) { @@ -1931,9 +1931,9 @@ void CTaskManager::Load( void ) id); block = new CBlock; - + block->Create( id ); - + //Read the block's flags saved_game.read_chunk( INT_ID('B', 'F', 'L', 'G'), @@ -1945,14 +1945,14 @@ void CTaskManager::Load( void ) saved_game.read_chunk( INT_ID('B', 'N', 'U', 'M'), numMembers); - + for ( int j = 0; j < numMembers; j++ ) { //Get the member ID saved_game.read_chunk( INT_ID('B', 'M', 'I', 'D'), bID); - + //Get the member size saved_game.read_chunk( INT_ID('B', 'S', 'I', 'Z'), @@ -2007,11 +2007,11 @@ void CTaskManager::Load( void ) assert( 0 ); break; } - + //Get rid of the temp memory ICARUS_Free( bData ); } - + task->SetBlock( block ); STL_INSERT( m_tasks, task ); @@ -2019,7 +2019,7 @@ void CTaskManager::Load( void ) //Load the task groups int numTaskGroups = 0; - + saved_game.read_chunk( INT_ID('T', 'G', '#', 'G'), numTaskGroups); @@ -2042,7 +2042,7 @@ void CTaskManager::Load( void ) taskIDs[i]); taskGroup->m_GUID = taskIDs[i]; - + m_taskGroupIDMap[ taskIDs[i] ] = taskGroup; STL_INSERT( m_taskGroups, taskGroup ); @@ -2058,7 +2058,7 @@ void CTaskManager::Load( void ) saved_game.read_chunk( INT_ID('T', 'K', 'G', 'P'), id); - + if ( id != -1 ) taskGroup->m_parent = ( GetTaskGroup( id ) != NULL ) ? GetTaskGroup( id ) : NULL; @@ -2102,7 +2102,7 @@ void CTaskManager::Load( void ) { char name[1024]; int length = 0; - + //Get the size of the string saved_game.read_chunk( INT_ID('T', 'G', 'N', 'L'), diff --git a/codeJK2/icarus/Tokenizer.cpp b/codeJK2/icarus/Tokenizer.cpp index 3324355931..d97b594715 100644 --- a/codeJK2/icarus/Tokenizer.cpp +++ b/codeJK2/icarus/Tokenizer.cpp @@ -1,7 +1,7 @@ // Tokenizer.cpp #ifndef NOT_USING_MODULES // !!! if you are not using modules, read BELOW !!! -#include "module.h" // if you are not using modules, +#include "module.h" // if you are not using modules, // create an empty Module.h in your // project -- use of modules allows // the error handler to be overridden @@ -226,7 +226,7 @@ void CSymbolTable::Delete() bool CSymbolTable::AddSymbol(CSymbol* theSymbol) { LPCTSTR name = theSymbol->GetName(); - + symbolmap_t::iterator iter = m_symbols.find(name); if (iter != m_symbols.end()) { @@ -377,7 +377,7 @@ void CParsePutBack::Init(byte theByte, int curLine, LPCTSTR filename) m_curFile = (char*)malloc(strlen(filename) + 1); strcpy(m_curFile, filename); } - else + else { m_curFile = NULL; } @@ -426,7 +426,7 @@ CParseFile::~CParseFile() CParseFile* CParseFile::Create() { CParseFile* theParseFile = new CParseFile(); - + if ( !theParseFile->Init() ) { delete theParseFile; @@ -439,7 +439,7 @@ CParseFile* CParseFile::Create() CParseFile* CParseFile::Create(LPCTSTR filename, CTokenizer* tokenizer) { CParseFile* theParseFile = new CParseFile(); - + if ( theParseFile->Init(filename, tokenizer) ) return theParseFile; @@ -1490,7 +1490,7 @@ void CTokenizer::Error(LPCTSTR errString, int theError) m_errorProc(errString); } #ifdef USES_MODULES - else + else { ReportError(theError, errString); } @@ -1656,7 +1656,7 @@ CToken* CTokenizer::GetToEndOfLine(int tokenType) // the default string size of only 128 chars... // if (tokenType == TK_STRING) - { + { #define iRETURN_STRING_SIZE 2048 char theString[iRETURN_STRING_SIZE]; theString[0] = ' '; @@ -1673,15 +1673,15 @@ CToken* CTokenizer::GetToEndOfLine(int tokenType) } theString[i] = '\0'; - return CStringToken::Create(theString); + return CStringToken::Create(theString); } // line would maks a string too big to fit in buffer... - // + // Error(TKERR_STRINGLENGTHEXCEEDED); } else - { + { char theString[MAX_IDENTIFIER_LENGTH]; theString[0] = ' '; while (theString[0] == ' ') @@ -1712,7 +1712,7 @@ CToken* CTokenizer::GetToEndOfLine(int tokenType) } } Error(TKERR_IDENTIFIERLENGTHEXCEEDED); - } + } return NULL; } diff --git a/codeJK2/icarus/blockstream.h b/codeJK2/icarus/blockstream.h index 1e5643dece..03cae5f485 100644 --- a/codeJK2/icarus/blockstream.h +++ b/codeJK2/icarus/blockstream.h @@ -40,7 +40,7 @@ const int MAX_FILENAME_LENGTH = 1024; typedef float vector_t[3]; -enum +enum { POP_FRONT, POP_BACK, @@ -56,7 +56,7 @@ class CBlockMember { public: - CBlockMember(); + CBlockMember(); ~CBlockMember(); void Free( void ); @@ -110,7 +110,7 @@ class CBlockMember int m_size; //Size of the data member variable void *m_data; //Data for this member }; - + //CBlock class CBlock @@ -149,7 +149,7 @@ class CBlock void SetFlags( unsigned char flags ) { m_flags = flags; } void SetFlag( unsigned char flag ) { m_flags |= flag; } - + int HasFlag( unsigned char flag ) const { return ( m_flags & flag ); } unsigned char GetFlags( void ) const { return m_flags; } @@ -180,19 +180,19 @@ class CBlockStream int WriteBlock( CBlock * ); //Write the block out int ReadBlock( CBlock * ); //Read the block in - + int Open( char *, long ); //Open a stream for reading / writing protected: unsigned GetUnsignedInteger( void ); int GetInteger( void ); - + char GetChar( void ); long GetLong( void ); float GetFloat( void ); - long m_fileSize; //Size of the file + long m_fileSize; //Size of the file FILE *m_fileHandle; //Global file handle of current I/O source char m_fileName[MAX_FILENAME_LENGTH]; //Name of the current file diff --git a/codeJK2/icarus/instance.h b/codeJK2/icarus/instance.h index 9d5667694c..9925114f13 100644 --- a/codeJK2/icarus/instance.h +++ b/codeJK2/icarus/instance.h @@ -55,7 +55,7 @@ class ICARUS_Instance interface_export_t *GetInterface( void ) const { return m_interface; } //These are overriddable for "worst-case" save / loads - virtual int Save( void /*FIXME*/ ); + virtual int Save( void /*FIXME*/ ); virtual int Load( void /*FIXME*/ ); void Signal( const char *identifier ); diff --git a/codeJK2/icarus/interface.h b/codeJK2/icarus/interface.h index 8b83fa00fe..cb3f1eba22 100644 --- a/codeJK2/icarus/interface.h +++ b/codeJK2/icarus/interface.h @@ -42,7 +42,7 @@ typedef struct interface_export_s gentity_t * (*I_GetEntityByName)( const char *name ); //Polls the engine for the sequencer of the entity matching the name passed unsigned int (*I_GetTime)( void ); //Gets the current time unsigned int (*I_GetTimeScale)(void ); - int (*I_PlaySound)( int taskID, int entID, const char *name, const char *channel ); + int (*I_PlaySound)( int taskID, int entID, const char *name, const char *channel ); void (*I_Lerp2Pos)( int taskID, int entID, vec3_t origin, vec3_t angles, float duration ); void (*I_Lerp2Origin)( int taskID, int entID, vec3_t origin, float duration ); void (*I_Lerp2Angles)( int taskID, int entID, vec3_t angles, float duration ); diff --git a/codeJK2/icarus/interpreter.h b/codeJK2/icarus/interpreter.h index e5e9ec0e61..94abce33e3 100644 --- a/codeJK2/icarus/interpreter.h +++ b/codeJK2/icarus/interpreter.h @@ -33,7 +33,7 @@ along with this program; if not, see . typedef float vector_t[3]; //Token defines -enum +enum { TK_BLOCK_START = TK_USERDEF, TK_BLOCK_END, @@ -101,9 +101,9 @@ enum TYPE_ORIGIN, //Affect types - TYPE_INSERT, - TYPE_FLUSH, - + TYPE_INSERT, + TYPE_FLUSH, + //Camera types TYPE_PAN, TYPE_ZOOM, @@ -117,7 +117,7 @@ enum TYPE_TRACK, TYPE_DISTANCE, TYPE_FOLLOW, - + //Variable type TYPE_VARIABLE, @@ -144,7 +144,7 @@ typedef std::vector < variable_t * > variable_v; //CInterpreter -class CInterpreter +class CInterpreter { public: @@ -152,7 +152,7 @@ class CInterpreter ~CInterpreter(); int Interpret( CTokenizer *, CBlockStream *, char *filename=NULL ); //Main interpretation function - + int Match( int ); //Looks ahead to the next token to try and match it to the passed token, consumes token on success int LookAhead( int ); //Looks ahead without consuming on success @@ -168,7 +168,7 @@ class CInterpreter int GetFlush( void ); //Handles the flush() function int GetRun( void ); //Handles the run() function int GetKill( void ); //Handles the kill() function - int GetRemove( void ); //Handles the remove() function + int GetRemove( void ); //Handles the remove() function int GetCamera( void ); //Handles the camera() function int GetIf( void ); //Handles the if() conditional statement int GetSound( void ); //Handles the sound() function @@ -184,7 +184,7 @@ class CInterpreter int GetSignal( void ); int GetWaitSignal( void ); int GetPlay( void ); - + int GetRandom( CBlock *block ); int GetGet( CBlock *block ); //Heh int GetTag( CBlock *block ); //Handles the tag() identifier @@ -203,7 +203,7 @@ class CInterpreter int GetVariable( int type ); int GetID ( char * ); //Attempts to match and interpret an identifier - + keywordArray_t *GetSymbols( void ) { return (keywordArray_t *) &m_symbolKeywords; } //Returns the interpreter's symbol table keywordArray_t *GetIDs( void ) { return (keywordArray_t *) &m_IDKeywords; } //Returns the interpreter's ID table keywordArray_t *GetTypes( void ) { return (keywordArray_t *) &m_typeKeywords; } //Returns the interpreter's type table @@ -212,13 +212,13 @@ class CInterpreter void InitVars( void ); void FreeVars( void ); - + variable_t *AddVar( const char *name, int type ); variable_t *FindVar( const char *name ); const char *GetTokenName( int ); //Returns the name of a token int Error( char *, ... ); //Prints an error message - + int MatchTag( void ); //Attempts to match to a tag identifier int MatchGet( void ); //Attempts to match to a get identifier int MatchRandom( void ); //Attempts to match to a random identifier diff --git a/codeJK2/icarus/sequencer.h b/codeJK2/icarus/sequencer.h index ec52d3f772..808d710352 100644 --- a/codeJK2/icarus/sequencer.h +++ b/codeJK2/icarus/sequencer.h @@ -40,7 +40,7 @@ along with this program; if not, see . #define SQ_COMMON 0x00000000 //Common one-pass sequence #define SQ_LOOP 0x00000001 //Looping sequence #define SQ_RETAIN 0x00000002 //Inside a looping sequence list, retain the information -#define SQ_AFFECT 0x00000004 //Affect sequence +#define SQ_AFFECT 0x00000004 //Affect sequence #define SQ_RUN 0x00000008 //A run block #define SQ_PENDING 0x00000010 //Pending use, don't free when flushing the sequences #define SQ_CONDITIONAL 0x00000020 //Conditional statement @@ -164,7 +164,7 @@ class CSequencer CSequence *GetTaskSequence( CTaskGroup *group ); //Member variables - + ICARUS_Instance *m_owner; int m_ownerID; diff --git a/codeJK2/icarus/taskmanager.h b/codeJK2/icarus/taskmanager.h index db9e24431d..c347409971 100644 --- a/codeJK2/icarus/taskmanager.h +++ b/codeJK2/icarus/taskmanager.h @@ -40,14 +40,14 @@ enum TASK_RETURN_FAILED, }; -enum +enum { TASK_OK, TASK_FAILED, TASK_START, TASK_END, }; - + // CTask class CTask @@ -91,7 +91,7 @@ class CTaskGroup void Init( void ); int Add( CTask *task ); - + void SetGUID( int GUID ); void SetParent( CTaskGroup *group ) { m_parent = group; } @@ -199,7 +199,7 @@ class CTaskManager int m_GUID; int m_count; - + taskGroupName_m m_taskGroupNameMap; taskGroupID_m m_taskGroupIDMap; diff --git a/codeJK2/icarus/tokenizer.h b/codeJK2/icarus/tokenizer.h index f792da3097..3ca0ae2321 100644 --- a/codeJK2/icarus/tokenizer.h +++ b/codeJK2/icarus/tokenizer.h @@ -185,7 +185,7 @@ class CIntToken : public CToken protected: void Init(long value); - + long m_value; }; @@ -437,7 +437,7 @@ class CTokenizer const char *LookupToken(int tokenID, keywordArray_t* theTable = NULL); protected: - void SetError(int theError, const char *errString); + void SetError(int theError, const char *errString); virtual void Init(unsigned dwFlags = 0); CToken* FetchToken(); bool AddDefineSymbol(CDirectiveSymbol* definesymbol); diff --git a/codeJK2/qcommon/safe/memory.h b/codeJK2/qcommon/safe/memory.h index 1299509102..5caec82d91 100644 --- a/codeJK2/qcommon/safe/memory.h +++ b/codeJK2/qcommon/safe/memory.h @@ -80,7 +80,7 @@ namespace Zone using other = Allocator< U, tag >; }; }; - + template< typename T > using UniquePtr = std::unique_ptr< T, Deleter >; diff --git a/codeJK2/win32/game.rc b/codeJK2/win32/game.rc index d8a95ca3aa..408dea4f48 100644 --- a/codeJK2/win32/game.rc +++ b/codeJK2/win32/game.rc @@ -27,18 +27,18 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" diff --git a/codeJK2/win32/resource.h b/codeJK2/win32/resource.h index 2a145bf827..1a25b5a313 100644 --- a/codeJK2/win32/resource.h +++ b/codeJK2/win32/resource.h @@ -9,7 +9,7 @@ #define IDC_CURSOR1 129 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 diff --git a/codemp/CMakeLists.txt b/codemp/CMakeLists.txt index d170c1b2c9..1e424ffd51 100644 --- a/codemp/CMakeLists.txt +++ b/codemp/CMakeLists.txt @@ -140,7 +140,7 @@ if(BuildMPEngine OR BuildMPDed) "${MPDir}/qcommon/qcommon.h" "${MPDir}/qcommon/qfiles.h" "${MPDir}/qcommon/tags.h" - + ${SharedCommonFiles} ) source_group("common" FILES ${MPBotlibCommonFiles}) @@ -268,7 +268,7 @@ if(BuildMPEngine OR BuildMPDed) endif(WIN32) source_group("common" FILES ${MPEngineAndDedCommonFiles}) set(MPEngineAndDedFiles ${MPEngineAndDedFiles} ${MPEngineAndDedCommonFiles}) - + set(MPEngineAndDedCommonSafeFiles "${SharedDir}/qcommon/safe/files.cpp" "${SharedDir}/qcommon/safe/files.h" diff --git a/codemp/cgame/CMakeLists.txt b/codemp/cgame/CMakeLists.txt index 3bb751c74a..00348972a3 100644 --- a/codemp/cgame/CMakeLists.txt +++ b/codemp/cgame/CMakeLists.txt @@ -106,7 +106,7 @@ set(MPCGameCommonFiles "${MPDir}/qcommon/q_shared.h" "${MPDir}/qcommon/qfiles.h" "${MPDir}/qcommon/tags.h" - + ${SharedCommonFiles} ) source_group("common" FILES ${MPCGameCommonFiles}) diff --git a/codemp/client/cl_uiapi.cpp b/codemp/client/cl_uiapi.cpp index 29cf09b06a..4ed911798b 100644 --- a/codemp/client/cl_uiapi.cpp +++ b/codemp/client/cl_uiapi.cpp @@ -271,7 +271,7 @@ static qboolean CL_G2API_HaveWeGhoul2Models( void *ghoul2) { static qboolean CL_G2API_GetBoltMatrix( void *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 ) { if ( !ghoul2 ) { return qfalse; - + } return re->G2API_GetBoltMatrix( *((CGhoul2Info_v *)ghoul2), modelIndex, boltIndex, matrix, angles, position, frameNum, modelList, scale ); } diff --git a/codemp/game/CMakeLists.txt b/codemp/game/CMakeLists.txt index c1d4ae39ba..28ae98bd01 100644 --- a/codemp/game/CMakeLists.txt +++ b/codemp/game/CMakeLists.txt @@ -150,7 +150,7 @@ set(MPGameCommonFiles "${MPDir}/qcommon/disablewarnings.h" "${MPDir}/qcommon/q_shared.h" "${MPDir}/qcommon/tags.h" - + ${SharedCommonFiles} ) source_group("common" FILES ${MPGameCommonFiles}) diff --git a/codemp/game/NPC_combat.c b/codemp/game/NPC_combat.c index 7b855edc0c..8b62e87dc4 100644 --- a/codemp/game/NPC_combat.c +++ b/codemp/game/NPC_combat.c @@ -2452,7 +2452,7 @@ float IdealDistance ( gentity_t *self ) case WP_THERMAL: ideal += 50; break; - + case WP_SABER: case WP_BRYAR_PISTOL: // case WP_BLASTER_PISTOL: diff --git a/codemp/qcommon/cvar.cpp b/codemp/qcommon/cvar.cpp index 157cddeb2e..a705e18623 100644 --- a/codemp/qcommon/cvar.cpp +++ b/codemp/qcommon/cvar.cpp @@ -503,11 +503,11 @@ cvar_t *Cvar_Get( const char *var_name, const char *var_value, uint32_t flags, c return var; } -static void Cvar_QSortByName( cvar_t **a, int n ) +static void Cvar_QSortByName( cvar_t **a, int n ) { cvar_t *temp; cvar_t *m; - int i, j; + int i, j; i = 0; j = n; @@ -519,10 +519,10 @@ static void Cvar_QSortByName( cvar_t **a, int n ) while ( strcmp( a[j]->name, m->name ) < 0 ) j--; if ( i <= j ) { - temp = a[i]; - a[i] = a[j]; + temp = a[i]; + a[i] = a[j]; a[j] = temp; - i++; + i++; j--; } } while ( i <= j ); @@ -532,7 +532,7 @@ static void Cvar_QSortByName( cvar_t **a, int n ) } -static void Cvar_Sort( void ) +static void Cvar_Sort( void ) { cvar_t *list[ MAX_CVARS ], *var; int count; @@ -551,7 +551,7 @@ static void Cvar_Sort( void ) } Cvar_QSortByName( &list[0], count-1 ); - + cvar_vars = NULL; // relink cvars diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index aa152699c8..f93a2ad8fb 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -289,7 +289,7 @@ qboolean G2API_OverrideServerWithClientData(CGhoul2Info_v& ghoul2, int modelInde 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); @@ -312,7 +312,7 @@ 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); @@ -329,7 +329,7 @@ static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) // 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; @@ -337,7 +337,7 @@ static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) // 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; @@ -420,7 +420,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray size_t GetSerializedSize() const { - size_t size = 0; + size_t size = 0; size += sizeof (int); // size of mFreeIndecies linked list size += mFreeIndecies.size() * sizeof (int); @@ -495,7 +495,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray buffer += sizeof (int); mInfos[i].resize (count); - + for ( size_t j = 0; j < count; j++ ) { buffer += DeserializeGhoul2Info (buffer, mInfos[i][j]); @@ -548,7 +548,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray Com_Error(ERR_FATAL, "Out of ghoul2 info slots"); } - // gonna pull from the front, doing a + // gonna pull from the front, doing a int idx=*mFreeIndecies.begin(); mFreeIndecies.erase(mFreeIndecies.begin()); return mIds[idx]; @@ -585,7 +585,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray assert((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 std::vector &Get(int handle) const @@ -747,7 +747,7 @@ void G2API_CleanGhoul2Models(CGhoul2Info_v **ghoul2Ptr) delete *ghoul2Ptr; *ghoul2Ptr = NULL; - } + } } qboolean G2_ShouldRegisterServer(void) @@ -822,7 +822,7 @@ int G2API_InitGhoul2Model(CGhoul2Info_v **ghoul2Ptr, const char *fileName, int m 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()); + ghoul2.push_back(CGhoul2Info()); } strcpy(ghoul2[model].mFileName, fileName); @@ -1291,7 +1291,7 @@ qboolean G2API_SetBoneAnim(CGhoul2Info_v &ghoul2, const int modelIndex, const ch CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; qboolean setPtrs = qfalse; qboolean res = qfalse; - + //rww - RAGDOLL_BEGIN if (ghlInfo) { @@ -2274,7 +2274,7 @@ void G2API_SetGhoul2ModelIndexes( // broken into 3 lines for debugging, STL is a pain to view... // int iModelIndex = ghoul2[i].mModelindex; - qhandle_t mModel = modelList[iModelIndex]; + qhandle_t mModel = modelList[iModelIndex]; ghoul2[i].mModel = mModel; ghoul2[i].mSkin = skinList[ghoul2[i].mCustomSkin]; @@ -2600,7 +2600,7 @@ int G2API_CopyGhoul2Instance(CGhoul2Info_v &g2From, CGhoul2Info_v &g2To, int mod { 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()) { @@ -2709,7 +2709,7 @@ void G2API_DuplicateGhoul2Instance(CGhoul2Info_v &g2From, CGhoul2Info_v **g2To) CGhoul2Info_v &ghoul2 = *(*g2To); /*ignore = */G2API_CopyGhoul2Instance(g2From, ghoul2, -1); - + return; } @@ -2874,7 +2874,7 @@ qboolean G2API_SkinlessModel(CGhoul2Info_v& ghoul2, int modelIndex) surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); - for (i = 0; i < mdxm->numSurfaces; i++) + for (i = 0; i < mdxm->numSurfaces; i++) { if (surf->shader[0]) { //found a surface with a shader name, ok. @@ -3070,7 +3070,7 @@ qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo) // returns true if the mode // RJ - experimental optimization! if (!ghlInfo->mModel || 1) - { + { if (ri.Cvar_VariableIntegerValue( "dedicated" ) || (G2_ShouldRegisterServer())) //supreme hackery! { diff --git a/codemp/rd-rend2/G2_bolts.cpp b/codemp/rd-rend2/G2_bolts.cpp index cddbc5a067..c0eceb3119 100644 --- a/codemp/rd-rend2/G2_bolts.cpp +++ b/codemp/rd-rend2/G2_bolts.cpp @@ -48,7 +48,7 @@ int G2_Find_Bolt_Surface_Num(boltInfo_v &bltlist, const int surfaceNum, const in // didn't find it return -1; } - + //========================================================================================= //// Public Bolt Routines int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, const int surfNum) @@ -74,7 +74,7 @@ int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_ } } - // we have a surface + // we have a surface // look through entire list - see if it's already there first for(size_t i=0; i #else #include -#endif +#endif #include "ghoul2/G2_gore.h" //#define RAG_TRACE_DEBUG_LINES @@ -20,7 +20,7 @@ //===================================================================================================================== // 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 +// 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) { @@ -65,7 +65,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) //rww - RAGDOLL_BEGIN memset(&tempBone, 0, sizeof(tempBone)); //rww - RAGDOLL_END - + 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 @@ -168,7 +168,7 @@ qboolean G2_Remove_Bone_Index ( boneInfo_v &blist, int index) // yes, so lets do it blist.resize(newSize); } - + return qtrue; } } @@ -308,7 +308,7 @@ void G2_Generate_Matrix(const model_t *mod, boneInfo_v &blist, int index, const Mat3x4_Multiply(&temp1, boneOverride,&skel->BasePoseMatInv); Mat3x4_Multiply(boneOverride,&skel->BasePoseMat, &temp1); - + } else { @@ -421,7 +421,7 @@ qboolean G2_Remove_Bone (CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *bo assert(ghlInfo->animModel); index = G2_Find_Bone(ghlInfo->animModel, blist, boneName); - + return G2_Remove_Bone_Index(blist, index); } @@ -457,7 +457,7 @@ qboolean G2_Set_Bone_Angles_Index( return qtrue; } } - + if (flags & (BONE_ANGLES_PREMULT | BONE_ANGLES_POSTMULT)) { // you CANNOT call this with an index with these kinds of bone @@ -501,7 +501,7 @@ qboolean G2_Set_Bone_Angles(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char mod_a = (model_t *)ghlInfo->animModel; int index = G2_Find_Bone(mod_a, blist, boneName); - + // did we find it? if (index != -1) { @@ -592,9 +592,9 @@ 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->header->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) { if (blist[index].flags & BONE_ANGLES_RAGDOLL) @@ -639,19 +639,19 @@ qboolean G2_Set_Bone_Angles_Matrix(const char *fileName, boneInfo_v &blist, cons // 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, + 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 @@ -676,7 +676,7 @@ qboolean G2_Set_Bone_Anim_Index( } if (flags & BONE_ANIM_BLEND) { - float currentFrame, animSpeed; + 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)) @@ -697,11 +697,11 @@ qboolean G2_Set_Bone_Anim_Index( { 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 + // 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; @@ -720,11 +720,11 @@ qboolean G2_Set_Bone_Anim_Index( } } } - + // 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 + // 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; @@ -828,18 +828,18 @@ qboolean G2_Set_Bone_Anim_Index( } // 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, +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; + model_t *mod_a = (model_t *)ghlInfo->animModel; int index = G2_Find_Bone(mod_a, blist, boneName); if (index == -1) @@ -866,10 +866,10 @@ qboolean G2_Get_Bone_Anim_Range(CGhoul2Info *ghlInfo, boneInfo_v &blist, const c { 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)) { @@ -885,13 +885,13 @@ qboolean G2_Get_Bone_Anim_Range(CGhoul2Info *ghlInfo, boneInfo_v &blist, const c // 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, +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)) @@ -918,13 +918,13 @@ qboolean G2_Get_Bone_Anim_Index( boneInfo_v &blist, const int index, const int c // 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, +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); @@ -934,7 +934,7 @@ qboolean G2_Get_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *b return qfalse; } } - + assert(ghlInfo->aHeader); if (G2_Get_Bone_Anim_Index(blist, index, currentTime, currentFrame, startFrame, endFrame, flags, retAnimSpeed, modelList, ghlInfo->aHeader->numFrames)) @@ -951,10 +951,10 @@ qboolean G2_Get_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *b // 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; + model_t *mod_a = (model_t *)ghlInfo->animModel; int index = G2_Find_Bone(mod_a, blist, boneName); - + // did we find it? if (index != -1) { @@ -976,7 +976,7 @@ qboolean G2_Pause_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char { blist[index].pauseTime = currentTime; } - + return qtrue; } assert(0); @@ -986,10 +986,10 @@ 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->header->animIndex); + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + 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? if (index != -1) { @@ -1008,7 +1008,7 @@ qboolean G2_IsPaused(const char *fileName, boneInfo_v &blist, const char *boneNa // 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 @@ -1024,10 +1024,10 @@ qboolean G2_Stop_Bone_Anim_Index(boneInfo_v &blist, const int 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->data.glm->header->animIndex); + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + 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? if (index != -1) { @@ -1043,13 +1043,13 @@ qboolean G2_Stop_Bone_Anim(const char *fileName, boneInfo_v &blist, const char * // 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 @@ -1060,10 +1060,10 @@ qboolean G2_Stop_Bone_Angles_Index(boneInfo_v &blist, const int 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->data.glm->header->animIndex); + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + 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? if (index != -1) { @@ -1111,7 +1111,7 @@ void G2_Animate_Bone_List(CGhoul2Info_v &ghoul2, const int currentTime, const in if (animSize) { // did we run off the end? - if (((animSpeed > 0.0f) && (newFrame_g > endFrame-1 )) || + if (((animSpeed > 0.0f) && (newFrame_g > endFrame-1 )) || ((animSpeed < 0.0f) && (newFrame_g < endFrame+1 ))) { // yep - decide what to do @@ -1260,7 +1260,7 @@ static std::vector rag; // once we get the dependents precompute static void G2_Generate_MatrixRag( // caution this must not be called before the whole skeleton is "remembered" - boneInfo_v &blist, + boneInfo_v &blist, int index) { @@ -1326,13 +1326,13 @@ int G2_Find_Bone_Rag(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneNa } #if _DEBUG // G2_Bone_Not_Found(boneName,ghlInfo->mFileName); -#endif +#endif // didn't find it return -1; } static int G2_Set_Bone_Rag(const mdxaHeader_t *mod_a, - boneInfo_v &blist, + boneInfo_v &blist, const char *boneName, CGhoul2Info &ghoul2, const vec3_t scale, @@ -1365,7 +1365,7 @@ static int G2_Set_Bone_Rag(const mdxaHeader_t *mod_a, static int G2_Set_Bone_Angles_Rag( CGhoul2Info &ghoul2, const mdxaHeader_t *mod_a, - boneInfo_v &blist, + boneInfo_v &blist, const char *boneName, const int flags, const float radius, @@ -1436,8 +1436,8 @@ static int G2_Set_Bone_Angles_Rag( } if (!bone.lastTimeUpdated) { - static mdxaBone_t id = - { + static mdxaBone_t id = + { { { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, @@ -1524,12 +1524,12 @@ static void G2_RagDollMatchPosition() VectorSubtract(desiredPos,e.currentOrigin,desiredPelvisOffset); // last arg is dest haveDesiredPelvisOffset=true; VectorCopy(e.currentOrigin,bone.lastPosition); // last arg is dest - continue; + continue; } if (!(bone.RagFlags & RAG_EFFECTOR)) { - continue; + continue; } VectorCopy(bone.originalOrigin,desiredPos); VectorSubtract(desiredPos,e.currentOrigin,e.desiredDirection); @@ -1564,7 +1564,7 @@ qboolean G2_Set_Bone_Anim_No_BS(CGhoul2Info &ghoul2, const mdxaHeader_t *mod,bon return qtrue; } - + index = G2_Add_Bone(ghoul2.animModel, blist, boneName); if (index != -1) @@ -1599,7 +1599,7 @@ void G2_ResetRagDoll(CGhoul2Info_v &ghoul2V) break; } } - + if (model == ghoul2V.size()) { return; @@ -2969,12 +2969,12 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve VectorSubtract(desiredPos,e.currentOrigin,desiredPelvisOffset); // last arg is dest haveDesiredPelvisOffset=true; VectorCopy(e.currentOrigin,bone.lastPosition); // last arg is dest - continue; + continue; } if (!(bone.RagFlags & RAG_EFFECTOR)) { - continue; + continue; } vec3_t testMins; vec3_t testMaxs; @@ -3008,12 +3008,12 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve // above the origin, so lets try lower if (e.currentOrigin[2] > groundSpot[2]) { - testStart[2]=groundSpot[2]+(e.radius-10.0f); + testStart[2]=groundSpot[2]+(e.radius-10.0f); } else { // lets try higher - testStart[2]=groundSpot[2]+8.0f; + testStart[2]=groundSpot[2]+8.0f; Rag_Trace(&tr,testStart,testMins,testMaxs,testEnd,ignoreNum,RAG_MASK,G2_NOCOLLIDE,0); if (tr.entityNum==0) { @@ -3053,7 +3053,7 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve else { vertEffectorTraceFraction=tr.fraction; - if (params && + if (params && vertEffectorTraceFraction < .95f && fabsf(tr.plane.normal[2]) < .707f) { @@ -3076,7 +3076,7 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve 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 + // 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) @@ -3111,7 +3111,7 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve } if (ztestvelocity, givenVelocity); vSpeed = VectorNormalize(givenVelocity); @@ -3310,7 +3310,7 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve 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) { @@ -3512,12 +3512,12 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve VectorSubtract(goalSpot, e.currentOrigin, desiredPelvisOffset); haveDesiredPelvisOffset = true; VectorCopy(e.currentOrigin, bone.lastPosition); - continue; + continue; } if (!(bone.RagFlags & RAG_EFFECTOR)) { - continue; + continue; } if (bone.hasOverGoal) @@ -3728,7 +3728,7 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve { if (hasBasePos) { - VectorSubtract(basePos, e.currentOrigin, velDir); + VectorSubtract(basePos, e.currentOrigin, velDir); } else { @@ -3955,7 +3955,7 @@ static void G2_RagDollSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int f // END this is the objective function thing for (i=0;i=0.0f); #if 0 - if (bone.RagFlags & RAG_PCJ_PELVIS) + if (bone.RagFlags & RAG_PCJ_PELVIS) { magicFactor9=.85f; // we don't want this swinging radically, make the whole thing kindof unstable } @@ -4233,16 +4233,16 @@ static void G2_IKReposition(const vec3_t currentOrg,CRagDollUpdateParams *params if (!(bone.RagFlags & RAG_EFFECTOR)) { - continue; + continue; } - + //Most effectors are not going to be PCJ, so this is not appplicable. //The actual desired angle of the PCJ is factored around the desired //directions of the effectors which are dependant on it. /* if (!(bone.RagFlags & RAG_PCJ_IK_CONTROLLED)) { - continue; + continue; } */ @@ -4280,7 +4280,7 @@ static void G2_IKSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameN // END this is the objective function thing for (i = 0; i < numRags; i++) - { + { // these are used for affecting the end result boneInfo_t &bone = *ragBoneData[i]; @@ -4295,7 +4295,7 @@ static void G2_IKSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameN } Inverse_Matrix(&ragBones[i], &N); // dest 2nd arg - + int k; vec3_t tAngles; VectorCopy(bone.currentAngles, tAngles); @@ -4371,7 +4371,7 @@ static void G2_IKSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameN { magicFactor1 = 0.40f; } - + recip = sqrt(4.0f/1.0f); float fac = (decay*recip*magicFactor1); @@ -4500,7 +4500,7 @@ void G2_Animate_Bone_List(CGhoul2Info_v &ghoul2, const int currentTime, const in static int G2_Set_Bone_Angles_IK( CGhoul2Info &ghoul2, const mdxaHeader_t *mod_a, - boneInfo_v &blist, + boneInfo_v &blist, const char *boneName, const int flags, const float radius, @@ -4536,8 +4536,8 @@ static int G2_Set_Bone_Angles_IK( } if (!bone.lastTimeUpdated) { - static mdxaBone_t id = - { + static mdxaBone_t id = + { { { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, @@ -4657,7 +4657,7 @@ qboolean G2_SetBoneIKState(CGhoul2Info_v &ghoul2, int time, const char *boneName } int index = G2_Find_Bone(mod_a, blist, boneName); - + if (index == -1) { index = G2_Add_Bone(mod_a, blist, boneName); @@ -4753,7 +4753,7 @@ qboolean G2_IKMove(CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params } 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.. @@ -4823,8 +4823,8 @@ 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->header->animIndex); + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(ghoul2->mFileName)); + 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 ac64001c4e..d5cf343366 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -16,7 +16,7 @@ static int CurrentTag=GORE_TAG_UPPER+1; static int CurrentTagUpper=GORE_TAG_UPPER; static std::map GoreRecords; -static std::map,int> GoreTagsTemp; // this is a surface index to gore tag map used only +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; @@ -218,11 +218,11 @@ class CTraceSurface #endif surfaceNum(initsurfaceNum), - rootSList(initrootSList), + rootSList(initrootSList), currentModel(initcurrentModel), - lod(initlod), - collRecMap(initcollRecMap), - entNum(initentNum), + lod(initlod), + collRecMap(initcollRecMap), + entNum(initentNum), modelIndex(initmodelIndex), skin(initskin), cust_shader(initcust_shader), @@ -243,7 +243,7 @@ class CTraceSurface VectorCopy(initrayStart, rayStart); VectorCopy(initrayEnd, rayEnd); hitOne = false; - } + } }; @@ -259,7 +259,7 @@ void G2_List_Model_Surfaces(const char *fileName) surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); mdxmSurface_t *surface = (mdxmSurface_t *)((byte *)mdxm + mdxm->ofsLODs + sizeof(mdxmLOD_t)); - for ( x = 0 ; x < 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,7 +283,7 @@ 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_m = R_GetModelByHandle(RE_RegisterModel(fileName)); model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); // mdxaFrame_t *aframe=0; // int frameSize; @@ -292,7 +292,7 @@ void G2_List_Model_Bones(const char *fileName, int frame) // figure out where the offset list is offsets = (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); -// frameSize = (size_t)( &((mdxaFrame_t *)0)->boneIndexes[ header->numBones ] ); +// 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 @@ -321,7 +321,7 @@ void G2_List_Model_Bones(const char *fileName, int frame) * obtain the .gla filename for a model * * Input - * filename of model + * filename of model * * Output * true if we successfully obtained a filename, false otherwise @@ -346,7 +346,7 @@ qboolean G2_GetAnimFileName(const char *fileName, char **filename) ///////////////////////////////////////////////////////////////////// -// +// // Code for collision detection for models gameside // ///////////////////////////////////////////////////////////////////// @@ -361,7 +361,7 @@ int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod) returnLod = ghoul2.mLodBias; } // assert(G2_MODEL_OK(&ghoul2)); - + mdxmHeader_t *mdxm = ghoul2.currentModel->data.glm->header; assert(ghoul2.currentModel); assert(mdxm); @@ -376,7 +376,7 @@ int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod) return returnLod; } -void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAllocator *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; @@ -386,7 +386,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl // 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; @@ -403,7 +403,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl // optimisation issue if ((scale[0] != 1.0) || (scale[1] != 1.0) || (scale[2] != 1.0)) { - for ( j = 0; j < numVerts; j++ ) + for ( j = 0; j < numVerts; j++ ) { vec3_t tempVert, tempNormal; // mdxmWeight_t *w; @@ -415,7 +415,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl const int iNumWeights = G2_GetVertWeights( v ); float fTotalWeight = 0.0f; - for ( k = 0 ; k < iNumWeights ; k++ ) + for ( k = 0 ; k < iNumWeights ; k++ ) { int iBoneIndex = G2_GetVertBoneIndex( v, k ); float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); @@ -446,7 +446,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl else { int pos = 0; - for ( j = 0; j < numVerts; j++ ) + for ( j = 0; j < numVerts; j++ ) { vec3_t tempVert, tempNormal; // const mdxmWeight_t *w; @@ -458,7 +458,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl const int iNumWeights = G2_GetVertWeights( v ); float fTotalWeight = 0.0f; - for ( k = 0 ; k < iNumWeights ; k++ ) + for ( k = 0 ; k < iNumWeights ; k++ ) { int iBoneIndex = G2_GetVertBoneIndex( v, k ); float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); @@ -487,7 +487,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAl } } -void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, +void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, CBoneCache *boneCache, const model_t *currentModel, int lod, vec3_t scale, IHeapAllocator *G2VertSpace, size_t *TransformedVertArray, bool secondTimeAround) { int i; @@ -497,7 +497,7 @@ void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void*)currentModel, surfaceNum, lod); 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 const surfaceInfo_t *surfOverride = G2_FindOverrideSurface(surfaceNum, rootSList); @@ -619,7 +619,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, } } - memset(g.mTransformedVertsArray, 0,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 @@ -691,15 +691,15 @@ qboolean G2_SegmentTriangleTest( const vec3_t start, const vec3_t end, vec3_t edgeAC; VectorSubtract(C, A, edgeAC); - VectorSubtract(B, A, returnedNormalT); + 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 @@ -709,16 +709,16 @@ qboolean G2_SegmentTriangleTest( const vec3_t start, const vec3_t end, 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; @@ -729,9 +729,9 @@ qboolean G2_SegmentTriangleTest( const vec3_t start, const vec3_t end, vec3_t edgePC; VectorSubtract(C, returnedPoint, edgePC); - + vec3_t temp; - + CrossProduct(edgePA, edgePB, temp); if (DotProduct(temp, returnedNormal)<0.0f) { @@ -743,12 +743,12 @@ qboolean G2_SegmentTriangleTest( const vec3_t start, const vec3_t end, { return qfalse; // off triangle } - + CrossProduct(edgePB, edgePC, temp); if (DotProduct(temp, returnedNormal)<0.0f) { return qfalse; // off triangle - } + } return qtrue; } @@ -775,7 +775,7 @@ 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; @@ -817,7 +817,7 @@ void G2_GorePolys( const mdxmSurface_t *surface, CTraceSurface &TS, const mdxmSu int numVerts = surface->numVerts; int flags=15; assert(numVerts=0&&tris[j].indexes[0]=0&&tris[j].indexes[1]growDuration != 0); add.mGoreGrowFactor = ( 1.0f - TS.gore->goreScaleStartFraction) / (float)(TS.gore->growDuration); //curscale = (curtime-mGoreGrowStartTime)*mGoreGrowFactor; - add.mGoreGrowOffset = TS.gore->goreScaleStartFraction; + add.mGoreGrowOffset = TS.gore->goreScaleStartFraction; goreSet->mGoreRecords.insert(std::pair(TS.surfaceNum,add)); GoreTagsTemp[std::pair(goreModelIndex,TS.surfaceNum)]=newTag; @@ -1007,7 +1007,7 @@ void G2_GorePolys( const mdxmSurface_t *surface, CTraceSurface &TS, const mdxmSu 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++) @@ -1050,12 +1050,12 @@ static SVertexTemp GoreVerts[MAX_GORE_VERTS]; 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++ ) + for ( j = 0; j < numTris; j++ ) { float face; vec3_t hitPoint, normal; @@ -1074,7 +1074,7 @@ static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_ CollisionRecord_t &newCol = TS.collRecMap[i]; vec3_t distVect; float x_pos = 0, y_pos = 0; - + newCol.mPolyIndex = j; newCol.mEntityNum = TS.entNum; newCol.mSurfaceIndex = surface->thisSurfaceIndex; @@ -1104,32 +1104,32 @@ static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_ 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); - + 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 ) + if ( cust_shader ) { shader = cust_shader; - } - else if ( skin ) + } + 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 ) ) + if ( !strcmp( skin->surfaces[j]->name, surfInfo->name ) ) { shader = skin->surfaces[j]->shader; break; } } - } - else + } + else { shader = R_GetShaderByHandle( surfInfo->shaderIndex ); } @@ -1143,7 +1143,7 @@ static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_ 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); + Com_Printf("G2_TracePolys hit location: %d\n", newCol.mLocation); } if (shader->hitMaterial) @@ -1178,7 +1178,7 @@ static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_ // 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, + const mdxmSurface_t *surface, CTraceSurface &TS ) { @@ -1224,15 +1224,15 @@ static bool G2_RadiusTracePolys( 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); + const float f = VectorLengthSquared(v3RayDir); v3RayDir[0]/=f; v3RayDir[1]/=f; v3RayDir[2]/=f; - for ( j = 0; j < numVerts; j++ ) + for ( j = 0; j < numVerts; j++ ) { const int pos=j*5; vec3_t delta; @@ -1281,7 +1281,7 @@ static bool G2_RadiusTracePolys( const int numTris = surface->numTriangles; const mdxmTriangle_t * const tris = (mdxmTriangle_t *) ((byte *)surface + surface->ofsTriangles); - for ( j = 0; j < numTris; j++ ) + for ( j = 0; j < numTris; j++ ) { assert(tris[j].indexes[0]>=0&&tris[j].indexes[0]=0&&tris[j].indexes[1]thisSurfaceIndex; @@ -1318,7 +1318,7 @@ static bool G2_RadiusTracePolys( // newCol.mFlags = G2_BACKFACE; // } - //get normal from triangle + //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)]; @@ -1392,7 +1392,7 @@ static void G2_TraceSurfaces(CTraceSurface &TS) 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->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 const surfaceInfo_t *surfOverride = G2_FindOverrideSurface(TS.surfaceNum, TS.rootSList); @@ -1422,7 +1422,7 @@ static void G2_TraceSurfaces(CTraceSurface &TS) { // .. then use radius check // - if (G2_RadiusTracePolys(surface, // const mdxmSurface_t *surface, + if (G2_RadiusTracePolys(surface, // const mdxmSurface_t *surface, TS ) && (TS.traceFlags == G2_RETURNONHIT) @@ -1511,11 +1511,11 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli } // assert(G2_MODEL_OK(&ghoul2[i])); // do we really want to collide with this object? - if (ghoul2[i].mFlags & GHOUL2_NOCOLLIDE) + if (ghoul2[i].mFlags & GHOUL2_NOCOLLIDE) { continue; } - + if (ghoul2[i].mCustomShader && ghoul2[i].mCustomShader != -20) //rww - -20 is a server instance (hack) { cust_shader = (shader_t *)R_GetShaderByHandle( ghoul2[i].mCustomShader ); @@ -1526,7 +1526,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli } // figure out the custom skin thing - if ( ghoul2[i].mSkin > 0 && ghoul2[i].mSkin < tr.numSkins ) + if ( ghoul2[i].mSkin > 0 && ghoul2[i].mSkin < tr.numSkins ) { skin = R_GetSkinByHandle( ghoul2[i].mSkin ); } @@ -1546,7 +1546,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli } #endif //reset the quick surface override lookup - G2_FindOverrideSurface(-1, ghoul2[i].mSlist); + 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); @@ -1698,20 +1698,20 @@ qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) int ghoul2BlockSize = (size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex; // add in count for number of ghoul2 models - *size += 4; + *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; idata.glm->header; surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); - for ( int i = 0 ; i < mdxm->numSurfaces ; i++) + for ( int i = 0 ; i < mdxm->numSurfaces ; i++) { if (!Q_stricmp(surfaceName, surf->name)) { @@ -104,7 +104,7 @@ mdxmSurface_t *G2_FindSurface(CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const } return 0; } - + // first find if we already have this surface in the list for (i = slist.size() - 1; i >= 0; i--) { @@ -139,7 +139,7 @@ qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const c { int surfIndex = -1; surfaceInfo_t temp_slist_entry; - mdxmSurface_t *surf; + mdxmSurface_t *surf; // find the model we want model_t *mod = (model_t *)ghlInfo->currentModel; @@ -149,7 +149,7 @@ qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const c assert(0); return qfalse; } - + // first find if we already have this surface in the list surf = G2_FindSurface(ghlInfo, slist, surfaceName, &surfIndex); if (surf) @@ -179,7 +179,7 @@ qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const c { // 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; @@ -203,7 +203,7 @@ void G2_SetSurfaceOnOffFromSkin (CGhoul2Info *ghlInfo, qhandle_t renderSkin) if ( !strcmp( ((shader_t *)skin->surfaces[j]->shader)->name, "*off") ) { G2_SetSurfaceOnOff(ghlInfo, ghlInfo->mSlist, skin->surfaces[j]->name, G2SURFACEFLAG_OFF); } - else + else { int flags; int surfaceNum = G2_IsSurfaceLegal((void *)ghlInfo->currentModel, skin->surfaces[j]->name, &flags); @@ -228,7 +228,7 @@ int G2_IsSurfaceOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *sur { return 0; } - + // first find if we already have this surface in the list surf = G2_FindSurface(ghlInfo, slist, surfaceName, &surfIndex); if (surf) @@ -240,7 +240,7 @@ int G2_IsSurfaceOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *sur mdxmSurfHierarchy_t *surface = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); - for ( int i = 0 ; i < mdxm->numSurfaces ; i++) + for ( int i = 0 ; i < mdxm->numSurfaces ; i++) { if (!Q_stricmp(surfaceName, surface->name)) { @@ -367,7 +367,7 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch G2_FindRecursiveSurface(mod_m, surf, ghoul2[modelIndex].mSlist, activeSurfaces); // now generate the used bone list - CConstructBoneList CBL(ghoul2[modelIndex].mSurfaceRoot, + CConstructBoneList CBL(ghoul2[modelIndex].mSurfaceRoot, activeBones, ghoul2[modelIndex].mSlist, mod_m, @@ -393,8 +393,8 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch int boltMod = (ghoul2[i].mModelBoltLink >> 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) && + if (((int)ghoul2[boltMod].mBltlist.size() <= boltNum) || + ((ghoul2[boltMod].mBltlist[boltNum].boneNumber == -1) && (ghoul2[boltMod].mBltlist[boltNum].surfaceNumber == -1))) { CGhoul2Info_v *g2i = &ghoul2; @@ -415,7 +415,7 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch { 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); + model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); int surf; int flags; int *activeSurfaces, *activeBones; @@ -451,7 +451,7 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch G2_FindRecursiveSurface(mod_m, surf, ghoul2[modelIndex].mSlist, activeSurfaces); // now generate the used bone list - CConstructBoneList CBL(ghoul2[modelIndex].mSurfaceRoot, + CConstructBoneList CBL(ghoul2[modelIndex].mSurfaceRoot, activeBones, ghoul2[modelIndex].mSlist, mod_m, @@ -477,8 +477,8 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch int boltMod = (ghoul2[i].mModelBoltLink >> 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) && + if ((ghoul2[boltMod].mBltlist.size() <= boltNum) || + ((ghoul2[boltMod].mBltlist[boltNum].boneNumber == -1) && (ghoul2[boltMod].mBltlist[boltNum].surfaceNumber == -1))) { G2API_RemoveGhoul2Model(entstate, i); @@ -595,7 +595,7 @@ int G2_GetSurfaceIndex(CGhoul2Info *ghlInfo, const char *surfaceName) { model_t *mod = (model_t *)ghlInfo->currentModel; int flags; - + return G2_IsSurfaceLegal(mod, surfaceName, &flags); } @@ -632,7 +632,7 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI //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 + // now see if we already have overriden this surface in the slist parentSurf = G2_FindSurface(ghlInfo, slist, parentSurfInfo->name, &surfIndex); if (parentSurf) { @@ -643,7 +643,7 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI if (parentFlags & G2SURFACEFLAG_NODESCENDANTS) { flags |= G2SURFACEFLAG_OFF; - break; + break; } // set up scan of next parent surfNum = parentSurfInfo->parentIndex; @@ -655,7 +655,7 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI } if ( flags == 0 ) {//it's not being overridden by a parent - // now see if we already have overriden this surface in the slist + // now see if we already have overriden this surface in the slist const mdxmSurface_t *surf = G2_FindSurface(ghlInfo, slist, surfaceName, &surfIndex); if (surf) { diff --git a/codemp/rd-rend2/MikkTSpace/mikktspace.c b/codemp/rd-rend2/MikkTSpace/mikktspace.c index 0342ae0146..8a0b8c66f3 100644 --- a/codemp/rd-rend2/MikkTSpace/mikktspace.c +++ b/codemp/rd-rend2/MikkTSpace/mikktspace.c @@ -130,7 +130,7 @@ typedef struct { tbool bOrientPreservering; } SGroup; -// +// #define MARK_DEGENERATE 1 #define QUAD_ONE_DEGEN_TRI 2 #define GROUP_WITH_ANY 4 @@ -141,7 +141,7 @@ typedef struct { typedef struct { int FaceNeighbors[3]; SGroup * AssignedGroup[3]; - + // normalized first order face derivatives SVec3 vOs, vOt; float fMagS, fMagT; // original magnitudes @@ -301,13 +301,13 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre // put the degenerate triangles last. DegenPrologue(pTriInfos, piTriListIn, iNrTrianglesIn, iTotTris); - + // evaluate triangle level attributes and neighbor list //printf("gen neighbors list begin\n"); InitTriInfo(pTriInfos, piTriListIn, pContext, iNrTrianglesIn); //printf("gen neighbors list end\n"); - + // based on the 4 rules, identify groups based on connectivity iNrMaxGroups = iNrTrianglesIn*3; pGroups = (SGroup *) malloc(sizeof(SGroup)*iNrMaxGroups); @@ -349,7 +349,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre //printf("gen tspaces begin\n"); bRes = GenerateTSpaces(psTspace, pTriInfos, pGroups, iNrActiveGroups, piTriListIn, fThresCos, pContext); //printf("gen tspaces end\n"); - + // clean up free(pGroups); free(piGroupTrianglesBuffer); @@ -375,7 +375,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre { const int verts = pContext->m_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. @@ -415,7 +415,7 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThre free(psTspace); - + return TTRUE; } @@ -544,7 +544,7 @@ static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SM if (iMaxCountiNrFaces; j++) { @@ -1298,7 +1298,7 @@ static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], con bFound = CompareSubGroups(&tmp_group, &pUniSubGroups[l]); if (!bFound) ++l; } - + // assign tangent space index assert(bFound || l==iUniqueSubGroups); //piTempTangIndices[f*3+index] = iUniqueTspaces+l; @@ -1626,7 +1626,7 @@ static void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], co ++j; } } - + if (!bFound) ++t; } @@ -1703,7 +1703,7 @@ static void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int 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) { @@ -1851,7 +1851,7 @@ static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriLis const int iSrcOffs=pTriInfos[iTri].iTSpacesOffs; const int iDstVert=pTriInfos[t].vert_num[i]; const int iDstOffs=pTriInfos[t].iTSpacesOffs; - + // copy tspace psTspace[iDstOffs+iDstVert] = psTspace[iSrcOffs+iSrcVert]; } diff --git a/codemp/rd-rend2/glsl/bokeh.glsl b/codemp/rd-rend2/glsl/bokeh.glsl index c2337c28be..5d53884d5e 100644 --- a/codemp/rd-rend2/glsl/bokeh.glsl +++ b/codemp/rd-rend2/glsl/bokeh.glsl @@ -56,7 +56,7 @@ void main() 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); - + out_Color = color * 0.04166667 * u_Color; #endif @@ -81,6 +81,6 @@ void main() 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); - + out_Color = color * 0.0625 * u_Color; } diff --git a/codemp/rd-rend2/glsl/calclevels4x.glsl b/codemp/rd-rend2/glsl/calclevels4x.glsl index 4c9252230e..da58eeea16 100644 --- a/codemp/rd-rend2/glsl/calclevels4x.glsl +++ b/codemp/rd-rend2/glsl/calclevels4x.glsl @@ -51,12 +51,12 @@ void main() 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); diff --git a/codemp/rd-rend2/glsl/depthblur.glsl b/codemp/rd-rend2/glsl/depthblur.glsl index ab32f9c000..50fc22cb79 100644 --- a/codemp/rd-rend2/glsl/depthblur.glsl +++ b/codemp/rd-rend2/glsl/depthblur.glsl @@ -48,10 +48,10 @@ vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFa #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 = texture(imageMap, tex) * gauss[0]; float total = gauss[0]; @@ -69,14 +69,14 @@ vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFa total += gauss[j]; } } - + direction = -direction; - } - + } + return result / total; } void main() -{ +{ out_Color = depthGaussian1D(u_ScreenImageMap, u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y); } diff --git a/codemp/rd-rend2/glsl/down4x.glsl b/codemp/rd-rend2/glsl/down4x.glsl index 7034cb81e9..b89e7f0172 100644 --- a/codemp/rd-rend2/glsl/down4x.glsl +++ b/codemp/rd-rend2/glsl/down4x.glsl @@ -25,7 +25,7 @@ void main() { vec4 color; vec2 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); @@ -45,8 +45,8 @@ void main() 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; - + out_Color = color; } diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 57dcf0ac87..ab69f6de99 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -166,7 +166,7 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) vec3 outNormal = normal; const float scale = 0.98; - + outNormal.x += amplitude * GetNoiseValue( position.x * scale, position.y * scale, diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index f249657e89..9d814303a7 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -237,7 +237,7 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) vec3 outNormal = normal; const float scale = 0.98; - + outNormal.x += amplitude * GetNoiseValue( position.x * scale, position.y * scale, @@ -298,7 +298,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 } break; } - + return tex; } #endif @@ -313,10 +313,10 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) 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; + + return st2 + texOffset * amplitude; } #endif @@ -324,7 +324,7 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) 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); @@ -370,7 +370,7 @@ vec4 CalcColor(vec3 position, vec3 normal) { 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; @@ -379,7 +379,7 @@ vec4 CalcColor(vec3 position, vec3 normal) { color.a = clamp(length(viewer) / u_PortalRange, 0.0, 1.0); } - + return color; } #endif @@ -532,7 +532,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 < 0.995); if (inFog == intersects) return 0.0; diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 759bbc8144..33f54bba68 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -190,7 +190,7 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase)); - return st2 + texOffset * amplitude; + return st2 + texOffset * amplitude; } #endif @@ -462,26 +462,26 @@ float random( const vec2 p ) 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) ); + 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 ) +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) @@ -524,7 +524,7 @@ float PCF(const sampler2DArrayShadow shadowmap, const float layer, const vec2 st } mult *= 1.0 / 17.0; #endif - + return mult; } @@ -581,7 +581,7 @@ float sunShadow(in vec3 viewOrigin, in vec3 viewDir, in vec3 biasOffset) } } } - + return result; } #endif @@ -610,10 +610,10 @@ float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, for(int i = 0; i < linearSearchSteps - 1; ++i) { depth += size; - + // height is flipped before uploaded to the gpu float t = textureGrad(normalMap, dp + ds * depth, dx, dy).r; - + if(depth >= t) { bestDepth = depth; // store best depth @@ -627,10 +627,10 @@ float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, for(int i = 0; i < binarySearchSteps; ++i) { size *= 0.5; - + // height is flipped before uploaded to the gpu float t = textureGrad(normalMap, dp + ds * depth, dx, dy).r; - + if(depth >= t) { bestDepth = depth; @@ -858,7 +858,7 @@ float pcfShadow(in sampler2DArrayShadow depthMap, in vec3 L, in float distance, { 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; @@ -912,7 +912,7 @@ vec3 CalcDynamicLightContribution( continue; } Light light = u_Lights[i]; - + vec3 L = light.origin.xyz - position; float sqrLightDist = dot(L, L); @@ -1066,7 +1066,7 @@ void main() float shadowValue = sunShadow(u_ViewOrigin, viewDir, normalBias) * NPL; // surfaces not facing the light are always shadowed - + //shadowValue = mix(0.0, shadowValue, dot(N, primaryLightDir) > 0.0); #if defined(SHADOWMAP_MODULATE) @@ -1113,7 +1113,7 @@ void main() 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 @@ -1148,7 +1148,7 @@ void main() out_Color.rgb = lightColor * reflectance * (attenuation * NL); out_Color.rgb += ambientColor * diffuse.rgb; - + #if defined(USE_PRIMARY_LIGHT) vec3 L2 = normalize(u_PrimaryLightOrigin.xyz); vec3 H2 = normalize(L2 + E); @@ -1166,18 +1166,18 @@ void main() out_Color.rgb += lightColor * reflectance * NL2; #endif - + 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; - #if defined(USE_LIGHTMAP) + #if defined(USE_LIGHTMAP) lightColor *= lightmapColor.rgb; #endif out_Color.rgb = diffuse.rgb * lightColor; #endif - + out_Color.a = diffuse.a; #if defined(USE_GLOW_BUFFER) diff --git a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl index 6df85b582b..273ccf532a 100644 --- a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl +++ b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl @@ -99,12 +99,12 @@ vec3 PrefilterEnvMap( float Roughness, vec3 R ) 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; + float pdf = (D * NH / (4.0 * HV)) + 0.0001; 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); + float mipLevel = Roughness == 0.0 ? 0.0 : 0.5 * log2(saSample / saTexel); PrefilteredColor += textureLod(u_CubeMap, L, mipLevel).rgb * NoL; TotalWeight += NoL; @@ -119,7 +119,7 @@ void main() // from http://www.codinglabs.net/article_physically_based_rendering.aspx vec3 normal = normalize(vec3(-vector.x, -vector.y, -1.0)); - + if (cubeFace == 0) normal = normalize(vec3(1.0, -vector.y, -vector.x)); else if (cubeFace == 1) @@ -129,13 +129,13 @@ void main() else if (cubeFace == 3) normal = normalize(vec3(vector.x, -1.0, -vector.y)); else if (cubeFace == 4) - normal = normalize(vec3(vector.x, -vector.y, 1.0)); + normal = normalize(vec3(vector.x, -vector.y, 1.0)); 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/refraction.glsl b/codemp/rd-rend2/glsl/refraction.glsl index dfee37f149..5f5eabcd48 100644 --- a/codemp/rd-rend2/glsl/refraction.glsl +++ b/codemp/rd-rend2/glsl/refraction.glsl @@ -197,7 +197,7 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) vec3 outNormal = normal; const float scale = 0.98; - + outNormal.x += amplitude * GetNoiseValue( position.x * scale, position.y * scale, @@ -240,7 +240,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 { tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); } - + return tex; } #endif @@ -255,10 +255,10 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) 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; + + return st2 + texOffset * amplitude; } #endif @@ -266,7 +266,7 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) 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); @@ -280,7 +280,7 @@ vec4 CalcColor(vec3 position, vec3 normal) { 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; @@ -289,7 +289,7 @@ vec4 CalcColor(vec3 position, vec3 normal) { color.a = clamp(length(viewer) / u_PortalRange, 0.0, 1.0); } - + return color; } #endif @@ -384,12 +384,12 @@ void main() vec3 new_pos = (distance * refraction_vec) + ws_Position; var_RefractPosR = vec4(inverseModel * new_pos, 1.0); 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 = 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); @@ -457,11 +457,11 @@ vec3 FilmicTonemap(vec3 x) 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; } @@ -478,7 +478,7 @@ void main() color.a = var_Color.a; color.rgb *= var_Color.rgb; color.rgb *= u_Color.rgb; - + #if defined(USE_ALPHA_TEST) if (u_AlphaTestType == ALPHA_TEST_GT0) { @@ -506,7 +506,7 @@ void main() 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)); diff --git a/codemp/rd-rend2/glsl/shadowvolume.glsl b/codemp/rd-rend2/glsl/shadowvolume.glsl index e0a1dcbb03..fe7d45d3c3 100644 --- a/codemp/rd-rend2/glsl/shadowvolume.glsl +++ b/codemp/rd-rend2/glsl/shadowvolume.glsl @@ -108,7 +108,7 @@ void main() if (dot(cross(BmA,CmA), -u_ModelLightDir.xyz) > 0.0) { vec3 L = u_ModelLightDir.xyz*u_LocalLightRadius; - + // front cap gl_Position = MVP * vec4(var_Position[0].xyz, 1.0); EmitVertex(); @@ -117,12 +117,12 @@ void main() gl_Position = MVP * vec4(var_Position[2].xyz, 1.0); EmitVertex(); EndPrimitive(); - + // sides 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 = MVP * vec4(var_Position[2].xyz - L, 1.0); EmitVertex(); diff --git a/codemp/rd-rend2/glsl/ssao.glsl b/codemp/rd-rend2/glsl/ssao.glsl index 53aeb67630..10dcedadad 100644 --- a/codemp/rd-rend2/glsl/ssao.glsl +++ b/codemp/rd-rend2/glsl/ssao.glsl @@ -49,7 +49,7 @@ float random( const vec2 p ) 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) ); + return mod( 123456789., 1e-7 + 256. * dot(p,r) ); } mat2 randomRotation( const vec2 p ) @@ -73,14 +73,14 @@ float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZN 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 < 9; i++) { @@ -95,15 +95,15 @@ float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZN result += step(expectedZ - 1.0, sampleZ2); } } - + result *= 0.11111; - + return result; } void main() { float result = ambientOcclusion(u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y); - + 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 338f7a421e..63ec0b321a 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -77,7 +77,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), @@ -236,7 +236,7 @@ void main() #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; @@ -278,7 +278,7 @@ void main() discard; } #endif - + #if defined(USE_FOG) Fog fog = u_Fogs[u_FogIndex]; float fogFactor = CalcFog(u_ViewOrigin, var_WSPosition, fog); @@ -292,6 +292,6 @@ void main() #if defined(ADDITIVE_BLEND) out_Color.rgb *= out_Color.a; #endif - + out_Glow = vec4(0.0); } diff --git a/codemp/rd-rend2/glsl/tonemap.glsl b/codemp/rd-rend2/glsl/tonemap.glsl index 58162d7ed2..05b8ba2e63 100644 --- a/codemp/rd-rend2/glsl/tonemap.glsl +++ b/codemp/rd-rend2/glsl/tonemap.glsl @@ -39,11 +39,11 @@ vec3 FilmicTonemap(vec3 x) 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; @@ -96,7 +96,7 @@ void main() 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); //float maxLum = exp2(logMinAvgMaxLum.z); diff --git a/codemp/rd-rend2/stb_image.h b/codemp/rd-rend2/stb_image.h index a184dddb43..e67c1805d0 100644 --- a/codemp/rd-rend2/stb_image.h +++ b/codemp/rd-rend2/stb_image.h @@ -6295,7 +6295,7 @@ static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) g->history[idx / 4] = 1; c = &g->color_table[g->codes[code].suffix * 4]; - if (c[3] > 128) { // don't render transparent pixels; + if (c[3] > 128) { // don't render transparent pixels; p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; @@ -6423,9 +6423,9 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i 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; + // 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. + // 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 @@ -6448,7 +6448,7 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i } } else if (dispose == 2) { - // restore what was changed last frame to background before that frame; + // 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); @@ -6456,17 +6456,17 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i } } else { - // This is a non-disposal case eithe way, so just + // 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; + // 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; + // clear my history; memset(g->history, 0x00, g->w * g->h); // pixels that were affected previous frame for (;;) { @@ -6516,13 +6516,13 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i o = stbi__process_gif_raster(s, g); if (o == NULL) return NULL; - // if this was the first frame, + // 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; + 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); } } @@ -6624,12 +6624,12 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, } } while (u != 0); - // free temp buffer; + // free temp buffer; STBI_FREE(g.out); STBI_FREE(g.history); STBI_FREE(g.background); - // do the final conversion after loading everything; + // 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); @@ -6654,12 +6654,12 @@ static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req *y = g.h; // moved conversion to after successful load so that the same - // can be done for multiple frames. + // 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; + // free buffers needed for multiple frame loading; STBI_FREE(g.history); STBI_FREE(g.background); diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index b1ca5e95f8..b8b794901d 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 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 +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. @@ -48,7 +48,7 @@ static int R_MDRCullModel( mdrHeader_t *header, trRefEntity_t *ent ) { 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); @@ -62,7 +62,7 @@ static int R_MDRCullModel( mdrHeader_t *header, trRefEntity_t *ent ) { { // Ummm... yeah yeah I know we don't really have an md3 here.. but we pretend // we do. After all, the purpose of mdrs are not that different, are they? - + case CULL_OUT: tr.pc.c_sphere_cull_md3_out++; return CULL_OUT; @@ -106,7 +106,7 @@ static int R_MDRCullModel( mdrHeader_t *header, trRefEntity_t *ent ) { } } } - + // 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]; @@ -145,7 +145,7 @@ int R_MDRComputeFogNum( mdrHeader_t *header, trRefEntity_t *ent ) { if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { return 0; } - + frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); // FIXME: non-normalized axis issues @@ -192,25 +192,25 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { qboolean personalModel; header = (mdrHeader_t *)tr.currentModel->data.mdr; - + personalModel = (qboolean)( (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal || (tr.viewParms.flags & VPF_DEPTHSHADOW))); - + 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) + if ((ent->e.frame >= header->numFrames) || (ent->e.frame < 0) || (ent->e.oldframe >= header->numFrames) || (ent->e.oldframe < 0) ) @@ -228,7 +228,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { 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); @@ -253,14 +253,14 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { 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)) @@ -326,12 +326,12 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) // 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) + 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 + } + else { backlerp = backEnd.currentEntity->e.backlerp; frontlerp = 1.0f - backlerp; @@ -352,9 +352,9 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) indexes = surface->numTriangles * 3; baseIndex = tess.numIndexes; baseVertex = tess.numVertexes; - + // Set up all triangles. - for (j = 0 ; j < indexes ; j++) + for (j = 0 ; j < indexes ; j++) { tess.indexes[baseIndex + j] = baseVertex + triangles[j]; } @@ -363,16 +363,16 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) // // lerp all the needed bones // - if ( !backlerp ) + if ( !backlerp ) { // no lerping needed bonePtr = frame->bones; - } - else + } + else { bonePtr = bones; - - for ( i = 0 ; i < header->numBones*12 ; i++ ) + + for ( i = 0 ; i < header->numBones*12 ; i++ ) { ((float *)bonePtr)[i] = frontlerp * ((float *)frame->bones)[i] + backlerp * ((float *)oldFrame->bones)[i]; } @@ -383,7 +383,7 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) // numVerts = surface->numVerts; v = (mdrVertex_t *) ((byte *)surface + surface->ofsVerts); - for ( j = 0; j < numVerts; j++ ) + for ( j = 0; j < numVerts; j++ ) { vec3_t tempVert, tempNormal; mdrWeight_t *w; @@ -391,14 +391,14 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) VectorClear( tempVert ); VectorClear( tempNormal ); w = v->weights; - for ( k = 0 ; k < v->numWeights ; k++, w++ ) + 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 ); diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 65c19308ff..295223d453 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -130,15 +130,15 @@ void GL_Cull( int cullType ) { if ( backEnd.projection2D ) cullType = CT_TWO_SIDED; - if ( cullType == CT_TWO_SIDED ) + if ( cullType == CT_TWO_SIDED ) { if ( glState.faceCulling != CT_TWO_SIDED ) qglDisable( GL_CULL_FACE ); - } - else + } + else { qboolean cullFront = (qboolean)(cullType == CT_FRONT_SIDED); - + if ( glState.faceCulling == CT_TWO_SIDED ) qglEnable( GL_CULL_FACE ); @@ -476,14 +476,14 @@ void GL_Draw( GLenum primitiveType, int firstVertex, int numVertices, int numIns void GL_SetProjectionMatrix(matrix_t matrix) { Matrix16Copy(matrix, glState.projection); - Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection); + Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection); } void GL_SetModelviewMatrix(matrix_t matrix) { Matrix16Copy(matrix, glState.modelview); - Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection); + Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection); } @@ -505,18 +505,18 @@ static void SetViewportAndScissor( void ) { GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); // set the window clipping - qglViewport( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, + qglViewport( 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, + qglScissor( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight ); } else { - qglScissor( backEnd.viewParms.scissorX, backEnd.viewParms.scissorY, + qglScissor( backEnd.viewParms.scissorX, backEnd.viewParms.scissorY, backEnd.viewParms.scissorWidth, backEnd.viewParms.scissorHeight ); } } @@ -587,7 +587,7 @@ void RB_BeginDrawingView (void) { 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; @@ -1099,7 +1099,7 @@ static void RB_DrawItems( drawItem.draw.params.indexed.numIndices, drawItem.draw.params.indexed.indexType, drawItem.draw.params.indexed.firstIndex, - drawItem.draw.numInstances, + drawItem.draw.numInstances, drawItem.draw.params.indexed.baseVertex); break; } @@ -1601,7 +1601,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * VectorSet2(texCoords[3], 0.5f / cols, (rows - 0.5f) / rows); GLSL_BindProgram(&tr.textureColorShader); - + GLSL_SetUniformMatrix4x4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite); @@ -1620,7 +1620,7 @@ void RE_UploadCinematic (int cols, int rows, const byte *data, int client, qbool 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 ); + 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 @@ -1737,7 +1737,7 @@ static const void *RB_StretchPic ( const void *data ) { RB_DrawRotatePic ============= */ -static const void *RB_RotatePic ( const void *data ) +static const void *RB_RotatePic ( const void *data ) { const rotatePicCommand_t *cmd; shader_t *shader; @@ -1830,7 +1830,7 @@ static const void *RB_RotatePic ( const void *data ) RB_DrawRotatePic2 ============= */ -static const void *RB_RotatePic2 ( const void *data ) +static const void *RB_RotatePic2 ( const void *data ) { const rotatePicCommand_t *cmd; shader_t *shader; @@ -2102,7 +2102,7 @@ static void RB_RenderMainPass( drawSurf_t *drawSurfs, int numDrawSurfs ) { FBO_t *oldFbo = glState.currentFBO; FBO_Bind(tr.sunRaysFbo); - + qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); qglClear( GL_COLOR_BUFFER_BIT ); @@ -2453,7 +2453,7 @@ void RB_AddShaderToShaderInstanceUBO(shader_t *shader) shader->ShaderInstanceUboOffset = -1; return; } - + ShaderInstanceBlock shaderInstanceBlock = {}; ComputeDeformValues( shader, @@ -2637,7 +2637,7 @@ static const void *RB_ColorMask(const void *data) backEnd.colorMask[3] = (qboolean)(!cmd->rgba[3]); qglColorMask(cmd->rgba[0], cmd->rgba[1], cmd->rgba[2], cmd->rgba[3]); - + return (const void *)(cmd + 1); } @@ -2650,7 +2650,7 @@ RB_ClearDepth static const void *RB_ClearDepth(const void *data) { const clearDepthCommand_t *cmd = (clearDepthCommand_t *)data; - + // finish any 2D drawing if needed if(tess.numIndexes) RB_EndSurface(); @@ -2677,7 +2677,7 @@ static const void *RB_ClearDepth(const void *data) qglClear(GL_DEPTH_BUFFER_BIT); } - + return (const void *)(cmd + 1); } diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 4b546f90c9..0e5d5a2b99 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -38,7 +38,7 @@ CModelCacheManager::FileCache::iterator CModelCacheManager::FindFile( const char }); } -static const byte FakeGLAFile[] = +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, @@ -86,7 +86,7 @@ qboolean CModelCacheManager::LoadFile( const char *pFileName, void **ppFileBuffe memcpy(pvFakeGLAFile, &FakeGLAFile[0], sizeof (FakeGLAFile)); *ppFileBuffer = pvFakeGLAFile; - return qtrue; + return qtrue; } int len = ri.FS_ReadFile(path, ppFileBuffer); @@ -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 ) @@ -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; } @@ -302,7 +302,7 @@ void CModelCacheManager::StoreShaderRequest( const char *psModelFileName, const assert(0); return; } - + int iNameOffset = psShaderName - (char *)file->pDiskImage; int iPokeOffset = (char*) piShaderIndexPoke - (char *)file->pDiskImage; @@ -335,9 +335,9 @@ void CModelCacheManager::AllocateShaders( const char *psFileName ) int *piShaderPokePtr = (int *)((char*)file->pDiskImage + shader.pokeOffset); shader_t *sh = R_FindShader(psShaderName, lightmapsNone, stylesDefault, qtrue); - if ( sh->defaultShader ) + if ( sh->defaultShader ) *piShaderPokePtr = 0; - else + else *piShaderPokePtr = sh->index; } } diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 12027fdb05..e29d63ee02 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -41,32 +41,32 @@ 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", - 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) ); + 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_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_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", + 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", + 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 ) @@ -245,7 +245,7 @@ R_AddConvolveCubemapsCmd */ void R_AddConvolveCubemapCmd( cubemap_t *cubemap , int cubemapId ) { convolveCubemapCommand_t *cmd; - + if (!tr.registered) { return; } @@ -254,7 +254,7 @@ void R_AddConvolveCubemapCmd( cubemap_t *cubemap , int cubemapId ) { return; } cmd->commandId = RC_CONVOLVECUBEMAP; - + cmd->cubemap = cubemap; cmd->cubemapId = cubemapId; } @@ -363,7 +363,7 @@ void RE_SetColor( const float *rgba ) { RE_RotatePic ============= */ -void RE_RotatePic ( float x, float y, float w, float h, +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; @@ -392,7 +392,7 @@ void RE_RotatePic ( float x, float y, float w, float h, RE_RotatePic2 ============= */ -void RE_RotatePic2 ( float x, float y, float w, float h, +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; @@ -421,7 +421,7 @@ void RE_RotatePic2 ( float x, float y, float w, float h, RE_StretchPic ============= */ -void RE_StretchPic ( float x, float y, float w, float h, +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; @@ -453,17 +453,17 @@ void RE_StretchPic ( float x, float y, float w, float h, 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) @@ -478,7 +478,7 @@ void R_SetColorMode(GLboolean *rgba, stereoFrame_t stereoFrame, int colormode) else if(stereoFrame == STEREO_RIGHT) { rgba[0] = GL_FALSE; - + if(colormode == MODE_RED_BLUE) rgba[1] = GL_FALSE; else if(colormode == MODE_RED_GREEN) @@ -640,9 +640,9 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { if (glConfig.stereoEnabled) { if( !(cmd = (drawBufferCommand_t *)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 ) { @@ -664,7 +664,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { backEnd.colorMask[2] = qfalse; backEnd.colorMask[3] = qfalse; qglClearColor(0.0f, 0.0f, 0.0f, 1.0f); - + // clear all framebuffers if (tr.msaaResolveFbo) { @@ -687,19 +687,19 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { r_anaglyphMode->modified = qfalse; } - + if(stereoFrame == STEREO_LEFT) { if( !(cmd = (drawBufferCommand_t *)R_GetCommandBuffer(sizeof(*cmd))) ) return; - + if( !(colcmd = (colorMaskCommand_t *)R_GetCommandBuffer(sizeof(*colcmd))) ) return; } else if(stereoFrame == STEREO_RIGHT) { clearDepthCommand_t *cldcmd; - + if( !(cldcmd = (clearDepthCommand_t *)R_GetCommandBuffer(sizeof(*cldcmd))) ) return; @@ -743,7 +743,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { cmd->buffer = (int)GL_BACK; } } - + tr.refdef.stereoFrame = stereoFrame; } diff --git a/codemp/rd-rend2/tr_decals.cpp b/codemp/rd-rend2/tr_decals.cpp index 6bf4222da7..5a1c98d087 100644 --- a/codemp/rd-rend2/tr_decals.cpp +++ b/codemp/rd-rend2/tr_decals.cpp @@ -3,7 +3,7 @@ #define MAX_VERTS_ON_DECAL_POLY 10 #define MAX_DECAL_POLYS 500 -typedef struct decalPoly_s +typedef struct decalPoly_s { int time; int fadetime; @@ -49,7 +49,7 @@ void R_InitDecals( void ) { void RE_FreeDecal( int type, int index ) { if ( !re_decalPolys[type][index].time ) return; - + if ( type == DECALPOLY_TYPE_NORMAL ) { decalPoly_t* fade; @@ -75,7 +75,7 @@ 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(); @@ -85,9 +85,9 @@ decalPoly_t* RE_AllocDecal( int 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]; + int i = re_decalPolyHead[type]; - // since we are killing one that existed before, make sure we + // since we are killing one that existed before, make sure we // kill all the other marks that belong to the group do { i++; @@ -99,7 +99,7 @@ decalPoly_t* RE_AllocDecal( int type ) { break; RE_FreeDecal ( type, i ); - } while ( i != re_decalPolyHead[type] ); + } while ( i != re_decalPolyHead[type] ); RE_FreeDecal( type, re_decalPolyHead[type] ); } @@ -151,7 +151,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ if ( r_markcount->integer <= 0 && !temporary ) return; - if ( radius <= 0 ) + if ( radius <= 0 ) Com_Error( ERR_FATAL, "RE_AddDecalToScene: called with <= 0 radius" ); // create the texture axis @@ -163,7 +163,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ texCoordScale = 0.5 * 1.0 / radius; // create the full polygon - for ( i = 0 ; i < 3 ; i++ ) + 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]; @@ -182,7 +182,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ colors[2] = blue * 255; colors[3] = alpha * 255; - for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) + for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) { polyVert_t *v; polyVert_t verts[MAX_VERTS_ON_DECAL_POLY]; @@ -193,7 +193,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ 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++ ) + for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) { vec3_t delta; @@ -207,7 +207,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ } // if it is a temporary (shadow) mark, add it immediately and forget about it - if ( temporary ) + if ( temporary ) { RE_AddPolyToScene( decalShader, mf->numPoints, verts, 1 ); continue; @@ -231,7 +231,7 @@ void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_ R_AddDecals =============== */ -void R_AddDecals( void ) +void R_AddDecals( void ) { int decalPoly; int type; @@ -256,21 +256,21 @@ void R_AddDecals( void ) 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 ) + 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++ ) + + for ( j = 0 ; j < p->poly.numVerts ; j++ ) { p->verts[j].modulate[3] = fade; } diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 55bf6c9ffe..83190a3425 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -337,7 +337,7 @@ void GLimp_InitCoreFunctions() GetGLFunction (qglVertexAttrib2f, "glVertexAttrib2f", qtrue); GetGLFunction (qglVertexAttrib3f, "glVertexAttrib3f", qtrue); GetGLFunction (qglVertexAttrib4f, "glVertexAttrib4f", qtrue); - + // Buffer objects qglGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &glRefConfig.uniformBufferOffsetAlignment); qglGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &glRefConfig.maxUniformBlockSize); @@ -518,7 +518,7 @@ void GLimp_InitCoreFunctions() GetGLFunction (qglDeleteSync, "glDeleteSync", qtrue); GetGLFunction (qglClientWaitSync, "glClientWaitSync", qtrue); GetGLFunction (qglWaitSync, "glWaitSync", qtrue); - + } void GLW_InitTextureCompression( void ); @@ -606,7 +606,7 @@ void GLimp_InitExtensions() if( GLimp_HaveExtension( 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)); @@ -626,7 +626,7 @@ void GLimp_InitExtensions() if( GLimp_HaveExtension( extension ) ) { qboolean loaded = qtrue; - + if ( r_arb_buffer_storage->integer ) { loaded = (qboolean)(loaded && GetGLFunction (qglBufferStorage, "glBufferStorage", qfalse)); diff --git a/codemp/rd-rend2/tr_extramath.cpp b/codemp/rd-rend2/tr_extramath.cpp index 76cf7c5cb5..09b8015d45 100644 --- a/codemp/rd-rend2/tr_extramath.cpp +++ b/codemp/rd-rend2/tr_extramath.cpp @@ -44,10 +44,10 @@ void Matrix16Identity( matrix_t out ) 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]; + 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 ) @@ -140,7 +140,7 @@ 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]); @@ -167,7 +167,7 @@ qboolean SpheresIntersect(vec3_t origin1, float radius1, vec3_t origin2, float r { float radiusSum = radius1 + radius2; vec3_t diff; - + VectorSubtract(origin1, origin2, diff); if (DotProduct(diff, diff) <= radiusSum * radiusSum) @@ -202,7 +202,7 @@ int NextPowerOfTwo(int in) unsigned short FloatToHalf(float in) { unsigned short out; - + union { float f; diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 9a7e4f97a6..d86085412d 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -344,7 +344,7 @@ 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! @@ -415,7 +415,7 @@ void FBO_Init(void) { 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) @@ -844,7 +844,7 @@ void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexS GL_State( blend ); GLSL_BindProgram(shaderProgram); - + GLSL_SetUniformMatrix4x4(shaderProgram, UNIFORM_MODELVIEWPROJECTIONMATRIX, projection); GLSL_SetUniformVec4(shaderProgram, UNIFORM_COLOR, color); GLSL_SetUniformVec2(shaderProgram, UNIFORM_INVTEXRES, invTexRes); diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index be6d4120e1..3a4637d81a 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -185,7 +185,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]; @@ -217,7 +217,7 @@ void RB_AddDlightFlares( void ) { if(fog) { - // find which fog volume the light is in + // find which fog volume the light is in for ( j = 1 ; j < tr.world->numfogs ; j++ ) { fog = &tr.world->fogs[j]; for ( k = 0 ; k < 3 ; k++ ) { @@ -279,7 +279,7 @@ void RB_TestFlare( flare_t *f ) { FBO_Bind(oldFbo); } - screenZ = backEnd.viewParms.projectionMatrix[14] / + screenZ = backEnd.viewParms.projectionMatrix[14] / ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); visible = (qboolean)(( -f->eyeZ - -screenZ ) < 24); @@ -291,7 +291,7 @@ void RB_TestFlare( flare_t *f ) { } fade = ( ( backEnd.refdef.time - f->fadeTime ) / 500.0f ); } else { - // Dont fade out when flare is occluded. Will result in the ability to see + // 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; diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index aea553066e..97fa30cad6 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -1,4 +1,4 @@ -#include "client/client.h" //FIXME!! EVIL - just include the definitions needed +#include "client/client.h" //FIXME!! EVIL - just include the definitions needed #include "tr_local.h" #include "qcommon/matcomp.h" #include "qcommon/qcommon.h" @@ -113,8 +113,8 @@ qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2); extern cvar_t *r_Ghoul2AnimSmooth; extern cvar_t *r_Ghoul2UnSqashAfterSmooth; -static const mdxaBone_t identityMatrix = -{ +static const mdxaBone_t identityMatrix = +{ { { 0.0f, -1.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 0.0f }, @@ -162,7 +162,7 @@ void Mat3x4_Multiply(mdxaBone_t *out, const mdxaBone_t *in2, const mdxaBone_t *i 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); @@ -267,7 +267,7 @@ class CConstructBoneList int *boneUsedList; surfaceInfo_v &rootSList; model_t *currentModel; - boneInfo_v &boneList; + boneInfo_v &boneList; CConstructBoneList( int initsurfaceNum, @@ -390,9 +390,9 @@ class CBoneCache } 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; @@ -405,7 +405,7 @@ class CBoneCache int mCurrentTouch; int mCurrentTouchRender; - int mLastTouch; + int mLastTouch; int mLastLastTouch; // for render smoothing @@ -435,7 +435,7 @@ class CBoneCache { assert(amod); assert(aheader); - + Com_Memset(boneMatrices, 0, sizeof(boneMatrices)); int numBones = header->numBones; @@ -860,7 +860,7 @@ class CRenderSurface 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 +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. @@ -890,7 +890,7 @@ static int R_GCullModel( trRefEntity_t *ent ) { largestScale = 1; } - // cull bounding sphere + // cull bounding sphere switch ( R_CullLocalPointAndRadius( vec3_origin, ent->e.radius * largestScale) ) { case CULL_OUT: @@ -943,7 +943,7 @@ static int R_GComputeFogNum( trRefEntity_t *ent ) { } // work out lod for this entity. -static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int lodBias ) +static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int lodBias ) { float flod, lodscale; float projectedRadius; @@ -954,7 +954,7 @@ static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int l return(0); } - if ( r_lodbias->integer > lodBias ) + if ( r_lodbias->integer > lodBias ) { lodBias = r_lodbias->integer; } @@ -979,12 +979,12 @@ static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int l // we reduce the radius to make the LOD match other model types which use // the actual bound box size - if ( projectedRadius != 0 ) + if ( projectedRadius != 0 ) { lodscale = (r_lodscale->value+r_autolodscalevalue->value); - if ( lodscale > 20 ) + if ( lodscale > 20 ) { - lodscale = 20; + lodscale = 20; } else if ( lodscale < 0 ) { @@ -1011,7 +1011,7 @@ static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int l lod += lodBias; - + if ( lod >= currentModel->numLods ) lod = currentModel->numLods - 1; if ( lod < 0 ) @@ -1050,15 +1050,15 @@ void G2_CreateQuaterion(mdxaBone_t *mat, vec4_t quat) // 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: + // 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: + // 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; @@ -1150,7 +1150,7 @@ void G2_TimingModel( time = (bone.pauseTime - bone.startTime) / 50.0f; } else - { + { time = (currentTime - bone.startTime) / 50.0f; } @@ -1164,7 +1164,7 @@ void G2_TimingModel( if ( numFramesInAnim != 0 ) { // did we run off the end? - if ( (animSpeed > 0.0f && newLerpFrame > (endFrame - 1)) || + if ( (animSpeed > 0.0f && newLerpFrame > (endFrame - 1)) || (animSpeed < 0.0f && newLerpFrame < (endFrame + 1)) ) { // yep - decide what to do @@ -1303,7 +1303,7 @@ void G2_TimingModel( if (newFrame >= (int)endFrame) { // we only want to lerp with the first frame of the anim if - // we are looping + // we are looping if (bone.flags & BONE_ANIM_OVERRIDE_LOOP) { newFrame = bone.startFrame; @@ -1336,7 +1336,7 @@ void G2_TimingModel( if (newFrame < endFrame+1) { // we only want to lerp with the first frame of the - // anim if we are looping + // anim if we are looping if (bone.flags & BONE_ANIM_OVERRIDE_LOOP) { newFrame = bone.startFrame; @@ -1465,7 +1465,7 @@ void G2_RagGetAnimMatrix( boneInfo_t &pbone = ghoul2.mBlist[parentBlistIndex]; // this should have been calc'd in the recursive call - assert(pbone.hasAnimFrameMatrix == frame); + assert(pbone.hasAnimFrameMatrix == frame); Mat3x4_Multiply(&bone.animFrameMatrix, &pbone.animFrameMatrix, &animMatrix); @@ -1527,7 +1527,7 @@ static void G2_TransformBone( int child, CBoneCache& BC ) // 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 ( boneFlags & BONE_ANGLES_TOTAL ) { @@ -1676,7 +1676,7 @@ static void G2_TransformBone( int child, CBoneCache& BC ) assert(child >=0 && child < BC.header->numBones); // decide where the transformed bone is going - + // lerp this bone - use the temp space on the ref entity to put the bone // transforms into if ( !TB.backlerp ) @@ -1688,7 +1688,7 @@ static void G2_TransformBone( int child, CBoneCache& BC ) mdxaBone_t newFrameBone; mdxaBone_t currentFrameBone; UnCompressBone(newFrameBone.matrix, child, BC.header, TB.newFrame); - UnCompressBone(currentFrameBone.matrix, child, BC.header, TB.currentFrame); + UnCompressBone(currentFrameBone.matrix, child, BC.header, TB.currentFrame); Mat3x4_Lerp(¤tBone, &newFrameBone, ¤tFrameBone, TB.backlerp); } @@ -1740,8 +1740,8 @@ static void G2_TransformBone( int child, CBoneCache& BC ) // are doing post mults to compensate. mdxaBone_t temp = firstPass * skel->BasePoseMat; const float matrixScale = VectorLength((float*)&temp); - mdxaBone_t toMatrix = - { + mdxaBone_t toMatrix = + { { { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, @@ -1928,7 +1928,7 @@ static void G2_TransformGhoulBones( #endif } ghoul2.mBoneCache->mod=currentModel; - ghoul2.mBoneCache->header=aHeader; + ghoul2.mBoneCache->header=aHeader; assert(ghoul2.mBoneCache->mBones.size()==(unsigned)aHeader->numBones); ghoul2.mBoneCache->mSmoothingActive=false; @@ -2024,7 +2024,7 @@ static void G2_TransformGhoulBones( //====================================================================== // -// Surface Manipulation code +// 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 @@ -2358,27 +2358,27 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum // if this surface is not off, add it to the shader render list if (!offFlags) { - if ( RS.cust_shader ) + if ( RS.cust_shader ) { shader = RS.cust_shader; - } - else if ( RS.skin ) + } + 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 ) ) + if ( !strcmp( RS.skin->surfaces[j]->name, surfInfo->name ) ) { shader = (shader_t*)RS.skin->surfaces[j]->shader; break; } } - } - else + } + else { shader = R_GetShaderByHandle( surfInfo->shaderIndex ); } @@ -2392,7 +2392,7 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum int cubemapIndex = R_CubemapForPoint(ent->e.origin); // don't add third_person objects if not viewing through a portal - if ( !RS.personalModel ) + 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 @@ -2524,7 +2524,7 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum R_AddDrawSurf((surfaceType_t *)newSurf, entityNum, tr.projectionShadowShader, 0, qfalse, qfalse, 0); } } - + // if we are turning off all descendants, then stop this recursion now if (offFlags & G2SURFACEFLAG_NODESCENDANTS) { @@ -2590,7 +2590,7 @@ void ProcessModelBoltSurfaces( G2_ProcessSurfaceBolt(bonePtr, surface, boltNum, boltList, surfOverride, currentModel); } } - + // if we are turning off all descendants, then stop this recursion now if (offFlags & G2SURFACEFLAG_NODESCENDANTS) { @@ -2666,14 +2666,14 @@ void G2_ConstructUsedBoneList(CConstructBoneList &CBL) } // 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 *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[iParentBone]); + skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[iParentBone]); iParentBone = skel->parent; } } @@ -2841,13 +2841,13 @@ void G2_ProcessSurfaceBolt2( const mdxmTriangle_t *originalTriangleIndexes = (mdxmTriangle_t *)((byte*)originalSurf + originalSurf->ofsTriangles); - // get the original polys indexes + // get the original polys indexes 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 - const mdxmVertex_t *surfVerts = + const mdxmVertex_t *surfVerts = (mdxmVertex_t *)((byte *)originalSurf + originalSurf->ofsVerts); const mdxmVertex_t *verts[3] = { surfVerts + index0, @@ -2868,7 +2868,7 @@ void G2_ProcessSurfaceBolt2( // was hit originally const int iNumWeights = G2_GetVertWeights(verts[i]); float fTotalWeight = 0.0f; - for ( int k = 0 ; k < iNumWeights ; k++ ) + for ( int k = 0 ; k < iNumWeights ; k++ ) { const int iBoneIndex = G2_GetVertBoneIndex(verts[i], k); const float fBoneWeight = G2_GetVertBoneWeight( @@ -2943,13 +2943,13 @@ void G2_ProcessSurfaceBolt2( (const mdxmVertex_t *)((byte *)surface + surface->ofsVerts); const int *piBoneReferences = (const int*)((byte *)surface + surface->ofsBoneReferences); - for ( int j = 0; j < 3; j++ ) + for ( int j = 0; j < 3; j++ ) { VectorClear(pTri[j]); const int iNumWeights = G2_GetVertWeights( v ); float fTotalWeight = 0.0f; - for ( int k = 0 ; k < iNumWeights ; k++) + for ( int k = 0 ; k < iNumWeights ; k++) { const int iBoneIndex = G2_GetVertBoneIndex(v, k); const float fBoneWeight = @@ -2963,7 +2963,7 @@ void G2_ProcessSurfaceBolt2( pTri[j][2] += fBoneWeight * (DotProduct(bone.matrix[2], v->vertCoords) + bone.matrix[2][3]); } - + v++; } @@ -3112,7 +3112,7 @@ static void RootMatrix( mdxaBone_t bolt; mdxaBone_t tempMatrix; - G2_ConstructGhoulSkeleton(ghoul2, time, false, scale); + G2_ConstructGhoulSkeleton(ghoul2, time, false, scale); G2_GetBoltMatrixLow(ghoul2[i], ghoul2[i].mNewOrigin, scale, bolt); tempMatrix.matrix[0][0] = 1.0f; @@ -3174,7 +3174,7 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ) // 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 ) + if ( cull == CULL_OUT ) { return; } @@ -3215,7 +3215,7 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ) { continue; } - + if ( (g2Info.mFlags & (GHOUL2_NOMODEL | GHOUL2_NORENDER)) != 0 ) { continue; @@ -3241,7 +3241,7 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ) { skin = R_GetSkinByHandle(ent->e.customSkin ); } - else if ( g2Info.mSkin > 0 && g2Info.mSkin < tr.numSkins ) + else if ( g2Info.mSkin > 0 && g2Info.mSkin < tr.numSkins ) { skin = R_GetSkinByHandle( g2Info.mSkin ); } @@ -3403,7 +3403,7 @@ void G2_ConstructGhoulSkeleton( #ifdef G2_PERFORMANCE_ANALYSIS G2Time_G2_ConstructGhoulSkeleton += G2PerformanceTimer_G2_ConstructGhoulSkeleton.End(); #endif -} +} static inline float G2_GetVertBoneWeightNotSlow( const mdxmVertex_t *pVert, const int iWeightNum) { @@ -3538,7 +3538,7 @@ void RB_FillBoneBlock(CRenderableSurface *surf, mat3x4_t *outMatrices) sizeof(surf->boneCache->boneMatrices)); } -void RB_SurfaceGhoul( CRenderableSurface *surf ) +void RB_SurfaceGhoul( CRenderableSurface *surf ) { mdxmVBOMesh_t *surface = surf->vboMesh; @@ -3593,8 +3593,8 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) 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][0] = + tess.svars.colors[tess.firstIndex][1] = tess.svars.colors[tess.firstIndex][2] = lFade; } tess.svars.colors[tess.firstIndex][3] = lFade; @@ -3701,7 +3701,7 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) glState.skeletalAnimation = qtrue; } - + /* ================= R_LoadMDXM - load a Ghoul 2 Mesh file @@ -4072,11 +4072,11 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & int version; int size; 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); @@ -4093,8 +4093,8 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & } mod->type = MOD_MDXM; - mod->dataSize += size; - + 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); @@ -4124,12 +4124,12 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & 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) + if (!mdxm->animIndex) { Com_Printf (S_COLOR_YELLOW "R_LoadMDXM: missing animation file %s for mesh %s\n", mdxm->animName, mdxm->name); return qfalse; @@ -4149,7 +4149,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & } surfInfo = (mdxmSurfHierarchy_t *)( (byte *)mdxm + mdxm->ofsSurfHierarchy); - for ( i = 0 ; i < mdxm->numSurfaces ; i++) + for ( i = 0 ; i < mdxm->numSurfaces ; i++) { LL(surfInfo->numChildren); LL(surfInfo->parentIndex); @@ -4170,7 +4170,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & // get the shader name sh = R_FindShader( surfInfo->shader, lightmapsNone, stylesDefault, qtrue ); // insert it in the surface list - if ( sh->defaultShader ) + if ( sh->defaultShader ) { surfInfo->shaderIndex = 0; } @@ -4179,12 +4179,12 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & surfInfo->shaderIndex = sh->index; } - CModelCache->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 + 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) lod = (mdxmLOD_t *) ( (byte *)mdxm + mdxm->ofsLODs ); for ( l = 0 ; l < mdxm->numLODs ; l++) @@ -4194,7 +4194,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & 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++) + for ( i = 0 ; i < mdxm->numSurfaces ; i++) { LL(surf->numTriangles); LL(surf->ofsTriangles); @@ -4207,7 +4207,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & // LL(surf->maxVertBoneWeights); triCount += surf->numTriangles; - + if ( surf->numVerts > SHADER_MAX_VERTEXES ) { Com_Error( ERR_DROP, @@ -4224,7 +4224,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & SHADER_MAX_INDEXES / 3, surf->numTriangles); } - + // change to surface identifier surf->ident = SF_MDX; // register the shaders @@ -4232,7 +4232,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & if (isAnOldModelFile) { int *boneRef = (int *) ( (byte *)surf + surf->ofsBoneReferences ); - for ( j = 0 ; j < surf->numBoneReferences ; j++ ) + for ( j = 0 ; j < surf->numBoneReferences ; j++ ) { if (boneRef[j] >= 0 && boneRef[j] < 72) { @@ -4780,7 +4780,7 @@ qboolean R_LoadMDXA(model_t *mod, void *buffer, const char *mod_name, qboolean & int childNumber = (NUM_ROOTPARENTS + NUM_OTHERPARENTS); // Allocate us some extra space so we can shift memory down. - size += (childNumber * (CHILD_PADDING * 8)); + size += (childNumber * (CHILD_PADDING * 8)); #endif // CREATE_LIMB_HIERARCHY mdxa = (mdxaHeader_t *)CModelCache->Allocate( @@ -4788,7 +4788,7 @@ qboolean R_LoadMDXA(model_t *mod, void *buffer, const char *mod_name, qboolean & mod->data.gla = mdxa; // I should probably eliminate 'bAlreadyFound', but wtf? - assert(bAlreadyCached == bAlreadyFound); + assert(bAlreadyCached == bAlreadyFound); if (!bAlreadyFound) { @@ -4860,7 +4860,7 @@ qboolean R_LoadMDXA(model_t *mod, void *buffer, const char *mod_name, qboolean & ShiftMemoryDown(offsets, mdxa, i, &sizeMarker); boneInfo = (mdxaSkel_t *) - ((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); + ((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); int newChild = BoneParentChildIndex(mdxa, offsets, boneInfo, qtrue); if (newChild != -1) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 5a3201fa52..25b289fcca 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -335,7 +335,7 @@ static size_t GLSL_GetShaderHeader( Q_strcat(dest, size, va("#define ALPHA_TEST_GT0 %d\n" - "#define ALPHA_TEST_LT128 %d\n" + "#define ALPHA_TEST_LT128 %d\n" "#define ALPHA_TEST_GE128 %d\n" "#define ALPHA_TEST_GE192 %d\n", ALPHA_TEST_GT0, @@ -498,7 +498,7 @@ static size_t GLSL_LoadGPUShaderSource( { ri.FS_FreeFile(buffer); } - + return result; } @@ -718,7 +718,7 @@ bool ShaderProgramBuilder::AddShader( const GPUShaderDesc& shaderDesc, const cha { shaderSource.resize(shaderSource.size() * 2); } - + ++attempts; } @@ -818,7 +818,7 @@ void GLSL_InitUniforms(shaderProgram_t *program) uniforms[i] = qglGetUniformLocation(program->program, uniformsInfo[i].name); if (uniforms[i] == -1) continue; - + program->uniformBufferOffsets[i] = size; switch(uniformsInfo[i].type) { @@ -1087,7 +1087,7 @@ void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat valu } *compare = value; - + qglUniform1f(uniforms[uniformNum], value); } @@ -1394,7 +1394,7 @@ static const GPUProgramDesc *LoadProgramSource( const char *programName, Allocator& allocator, const GPUProgramDesc& fallback ) { const GPUProgramDesc *result = &fallback; - + if ( r_externalGLSL->integer ) { char *buffer; @@ -1544,7 +1544,7 @@ static int GLSL_LoadGPUProgramFogPass( qglUseProgram(0); GLSL_FinishGPUShader(&tr.fogShader[i]); - + ++numPrograms; } @@ -1784,7 +1784,7 @@ static int GLSL_LoadGPUProgramLightAll( qglUseProgram(0); GLSL_FinishGPUShader(&tr.lightallShader[i]); - + ++numPrograms; } @@ -1884,7 +1884,7 @@ static int GLSL_LoadGPUProgramPShadow( qglUseProgram(0); GLSL_FinishGPUShader(&tr.pshadowShader); - + return 1; } @@ -1932,7 +1932,7 @@ static int GLSL_LoadGPUProgramDownscale4x( qglUseProgram(0); GLSL_FinishGPUShader(&tr.down4xShader); - + return 1; } @@ -1954,7 +1954,7 @@ static int GLSL_LoadGPUProgramBokeh( qglUseProgram(0); GLSL_FinishGPUShader(&tr.bokehShader); - + return 1; } @@ -2025,7 +2025,7 @@ static int GLSL_LoadGPUProgramCalcLuminanceLevel( qglUseProgram(0); GLSL_FinishGPUShader(&tr.calclevels4xShader[i]); - + ++numPrograms; } @@ -2232,7 +2232,7 @@ static int GLSL_LoadGPUProgramSurfaceSprites( 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)) @@ -2344,7 +2344,7 @@ void GLSL_LoadGPUShaders() Allocator allocator(512 * 1024); ShaderProgramBuilder builder; - + int numGenShaders = 0; int numLightShaders = 0; int numEtcShaders = 0; @@ -2369,8 +2369,8 @@ 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", - numGenShaders + numLightShaders + numEtcShaders, numGenShaders, numLightShaders, + 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); } @@ -2599,7 +2599,7 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) break; } - if (tess.fogNum && + if (tess.fogNum && pStage->adjustColorsForFog != ACFF_NONE && r_drawfog->integer) shaderAttribs |= GENERICDEF_USE_FOG; diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index b2ae7ec4af..62d4c29e6e 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -132,7 +132,7 @@ 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); @@ -145,7 +145,7 @@ 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 ) @@ -299,7 +299,7 @@ void R_ImageList_f( void ) { if (image->flags & IMGFLAG_MIPMAP) estSize += estSize / 2; - float printSize = GetReadableSize(estSize, &sizeSuffix); + 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); estTotalSize += estSize; @@ -323,11 +323,11 @@ 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 +If a larger shrinking is needed, use the mipmap function before or after. ================ */ -static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out, +static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out, int outwidth, int outheight ) { int i, j; byte *inrow, *inrow2; @@ -337,7 +337,7 @@ static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out, if (outwidth>2048) ri.Error(ERR_DROP, "ResampleTexture: max width"); - + fracstep = inwidth*0x10000/outwidth; frac = fracstep>>2; @@ -557,7 +557,7 @@ static void DoFCBI(byte *in, byte *out, int width, int height, int component) inbyte += 8; } } - + for (y = 3; y < height - 3; y += 2) { // diagonals @@ -707,7 +707,7 @@ static void DoFCBI(byte *in, byte *out, int width, int height, int component) inbyte += 8; } } - + for (y = 2; y < height - 3; y++) { // horizontal & vertical @@ -747,7 +747,7 @@ static void DoFCBI(byte *in, byte *out, int width, int height, int component) //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); @@ -804,7 +804,7 @@ static void DoFCBI(byte *in, byte *out, int width, int height, int component) sj = *line4; line4 += 8; sl = *line5; line5 += 8; - hp = sf + sg; + hp = sf + sg; vp = sd + si; hd = abs(sf - sg); vd = abs(sd - si); @@ -828,7 +828,7 @@ static void DoFCBI(byte *in, byte *out, int width, int height, int component) if (hdd > vdd) *outbyte = hp >> 1; - else + else *outbyte = vp >> 1; } @@ -920,7 +920,7 @@ static void DoFCBIQuick(byte *in, byte *out, int width, int height, int componen inbyte += 8; } } - + for (y = 2; y < height - 3; y++) { byte sd, sf, sg, si; @@ -943,8 +943,8 @@ static void DoFCBIQuick(byte *in, byte *out, int width, int height, int componen sd = *line2; line2 += 8; sg = *line3; line3 += 8; si = *line4; line4 += 8; - - hp = sf + sg; + + hp = sf + sg; vp = sd + si; hd = abs(sf - sg); vd = abs(sd - si); @@ -1005,7 +1005,7 @@ static void DoLinear(byte *in, byte *out, int width, int height) COPYSAMPLE(si, line3); line3 += 8; for (i = 0; i < 4; i++) - { + { *outbyte++ = (sd[i] + si[i] + se[i] + sh[i]) >> 2; } @@ -1031,7 +1031,7 @@ static void DoLinear(byte *in, byte *out, int width, int height) inbyte += 8; } } - + for (y = 1; y < height - 1; y++) { byte sd[4], sf[4], sg[4], si[4]; @@ -1169,7 +1169,7 @@ static void FCBIByBlock(byte *data, int width, int height, qboolean clampToEdge, } outbyte = workdata + y2 * fullworkwidth * 4; - inbyte = data + srcy * width * 4; + inbyte = data + srcy * width * 4; for (x2 = 0; x2 < fullworkwidth; x2 += 2) { @@ -1328,7 +1328,7 @@ static void R_MipMap2( byte *in, int inWidth, int inHeight ) { for ( j = 0 ; j < outWidth ; j++ ) { outpix = (byte *) ( temp + i * outWidth + j ); for ( k = 0 ; k < 4 ; k++ ) { - total = + 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] + @@ -1435,8 +1435,8 @@ static void R_MipMapLuminanceAlpha (const byte *in, byte *out, int width, int he if ( width == 0 || height == 0 ) { width += height; // get largest for (i=0 ; i> 1; out[3] = (in[3] + in[7]) >> 1; } @@ -1445,8 +1445,8 @@ static void R_MipMapLuminanceAlpha (const byte *in, byte *out, int width, int he for (i=0 ; i> 2; out[3] = (in[3] + in[7] + in[row+3] + in[row+7]) >> 2; } @@ -1472,7 +1472,7 @@ static void R_MipMapNormalHeight (const byte *in, byte *out, int width, int heig row = width * 4; width >>= 1; height >>= 1; - + for (i=0 ; iinteger && scaled_height > height ) scaled_height >>= 1; - if ( picmip && data && resampledBuffer && r_imageUpsample->integer && + if ( picmip && data && resampledBuffer && r_imageUpsample->integer && scaled_width < r_imageUpsampleMaxSize->integer && scaled_height < r_imageUpsampleMaxSize->integer) { int finalwidth, finalheight; @@ -1730,7 +1730,7 @@ static qboolean RawImage_HasAlpha(const byte *scan, int numPixels) for ( i = 0; i < numPixels; i++ ) { - if ( scan[i*4 + 3] != 255 ) + if ( scan[i*4 + 3] != 255 ) { return qtrue; } @@ -2017,7 +2017,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei // the data is NULL. All levels have already been allocated by glTexStorage2D. int miplevel = 0; - + while (width > 1 || height > 1) { if (data) @@ -2042,7 +2042,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei R_MipMap( data, width, height ); } } - + width >>= 1; height >>= 1; if (width < 1) @@ -2110,7 +2110,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla // c = width*height; scan = data; - + if( r_greyscale->integer ) { for ( i = 0; i < c; i++ ) @@ -2152,7 +2152,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla } // copy or resample data as appropriate for first MIP level - if ( ( scaled_width == width ) && + if ( ( scaled_width == width ) && ( scaled_height == height ) ) { if (!(flags & IMGFLAG_MIPMAP)) { @@ -2488,7 +2488,7 @@ R_Create2DImageArray 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) +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; @@ -2543,7 +2543,7 @@ image_t *R_Create2DImageArray(const char *name, byte *pic, int width, int height 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) @@ -2609,10 +2609,10 @@ 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 ); GL_SelectTexture( image->TMU ); - GL_Bind(image); + GL_Bind(image); // copy or resample data as appropriate for first MIP level - if ( ( scaled_width == width ) && + if ( ( scaled_width == width ) && ( scaled_height == height ) ) { if (!(image->flags & IMGFLAG_MIPMAP)) { @@ -2666,7 +2666,7 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h 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(); @@ -2729,7 +2729,7 @@ void R_LoadPackedMaterialImage(shaderStage_t *stage, const char *packedImageName image = R_GetLoadedImage(packedName, flags); if (image != NULL) { - // Don't scale occlusion, roughness and metalness + // Don't scale occlusion, roughness and metalness stage->specularScale[0] = stage->specularScale[2] = stage->specularScale[3] = 1.0f; @@ -2744,12 +2744,12 @@ void R_LoadPackedMaterialImage(shaderStage_t *stage, const char *packedImageName return; } - // Don't scale occlusion, roughness and metalness + // 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 }; switch (stage->specularType) @@ -2822,7 +2822,7 @@ image_t *R_BuildSDRSpecGlossImage(shaderStage_t *stage, const char *specImageNam currentColor[1] = ByteToFloat(specPic[i + 1]); currentColor[2] = ByteToFloat(specPic[i + 2]); - float ratio = + float ratio = (sRGBtoRGB(currentColor[0]) + sRGBtoRGB(currentColor[1]) + sRGBtoRGB(currentColor[1])) / (currentColor[0] + currentColor[1] + currentColor[2]); @@ -2842,26 +2842,26 @@ static void R_CreateNormalMap ( const char *name, byte *pic, int width, int heig image_t *normalImage; int normalWidth, normalHeight; int normalFlags; - + normalFlags = (flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; - + 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); - + // 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); @@ -2882,44 +2882,44 @@ static void R_CreateNormalMap ( const char *name, byte *pic, int width, int heig // 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; @@ -2927,13 +2927,13 @@ static void R_CreateNormalMap ( const char *name, byte *pic, int width, int heig blurbyte += 1; } } - + ri.Free(blurPic); - + YCoCgAtoRGBA(pic, pic, width, height); } #endif - + R_CreateImage( normalName, normalPic, normalWidth, normalHeight, IMGTYPE_NORMAL, normalFlags, 0 ); Z_Free( normalPic ); } @@ -2975,7 +2975,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) { R_LoadImage(name, &pic, &width, &height); } - else + else { for (int i = 0; i < width*height; i++) { @@ -3026,7 +3026,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) image = R_CreateImage( name, pic, width, height, type, loadFlags, internalFormat); Z_Free( pic ); - + return image; } @@ -3066,10 +3066,10 @@ static void R_CreateDlightImage( void ) { } else if ( b < 75 ) { b = 0; } - data[y][x][0] = - data[y][x][1] = + data[y][x][0] = + data[y][x][1] = data[y][x][2] = b; - data[y][x][3] = 255; + data[y][x][3] = 255; } } tr.dlightImage = R_CreateImage("*dlight", (byte *)data, DLIGHT_SIZE, DLIGHT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 ); @@ -3086,7 +3086,7 @@ void R_InitFogTable( void ) { int i; float d; float exp; - + exp = 0.5; for ( i = 0 ; i < FOG_TABLE_SIZE ; i++ ) { @@ -3151,8 +3151,8 @@ static void R_CreateFogImage( void ) { for (y=0 ; yinteger == 4) { tr.pshadowArrayImage = R_Create2DImageArray( - va("*pshadowmapArray"), - NULL, + va("*pshadowmapArray"), + NULL, PSHADOW_MAP_SIZE, - PSHADOW_MAP_SIZE, - MAX_DRAWN_PSHADOWS, + PSHADOW_MAP_SIZE, + MAX_DRAWN_PSHADOWS, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP | IMGFLAG_MUTABLE, GL_DEPTH_COMPONENT16); @@ -3521,10 +3521,10 @@ void R_CreateBuiltinImages( void ) { hdrFormat); tr.renderCubeDepthImage = R_CreateImage( - "*renderdepth", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, + "*renderdepth", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | - IMGFLAG_CLAMPTOEDGE, + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE, GL_DEPTH24_STENCIL8); } diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 4716956cf4..27a368c77b 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #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 +#define DLIGHT_MINIMUM_RADIUS 16 // never calculate a range less than this to prevent huge light numbers @@ -203,7 +203,7 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { } data = world->lightGridData + *(world->lightGridArray+gridPos); - if ( data->styles[0] == LS_LSNONE ) + if ( data->styles[0] == LS_LSNONE ) { continue; // ignore samples in walls } @@ -327,7 +327,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { vec3_t lightDir; vec3_t lightOrigin; - // lighting calculations + // lighting calculations if ( ent->lightingCalculated ) { return; } @@ -346,13 +346,13 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { } // if NOWORLDMODEL, only use dynamic lights (menu system, etc) - if ( !(refdef->rdflags & RDF_NOWORLDMODEL ) + if ( !(refdef->rdflags & RDF_NOWORLDMODEL ) && tr.world->lightGridData ) { R_SetupEntityLightingGrid( ent, tr.world ); } else { - ent->ambientLight[0] = ent->ambientLight[1] = + ent->ambientLight[0] = ent->ambientLight[1] = ent->ambientLight[2] = tr.identityLight * 150; - ent->directedLight[0] = ent->directedLight[1] = + ent->directedLight[0] = ent->directedLight[1] = ent->directedLight[2] = tr.identityLight * 150; VectorCopy( tr.sunDirection, ent->lightDir ); } @@ -409,7 +409,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { ((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 VectorNormalize( lightDir ); VectorCopy(lightDir, ent->lightDir); @@ -427,7 +427,7 @@ 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; @@ -445,7 +445,7 @@ 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 ) { trRefEntity_t ent; - + if ( world->lightGridData == NULL ) return qfalse; @@ -471,7 +471,7 @@ int R_DLightsForPoint(const vec3_t point, const float radius) 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; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 17c5c736a9..7f8e5e10fb 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -559,7 +559,7 @@ int R_CullPointAndRadiusEx( const vec3_t pt, float radius, const cplane_t* frust } // check against frustum planes - for (i = 0 ; i < numPlanes ; i++) + for (i = 0 ; i < numPlanes ; i++) { frust = &frustum[i]; @@ -568,7 +568,7 @@ int R_CullPointAndRadiusEx( const vec3_t pt, float radius, const cplane_t* frust { return CULL_OUT; } - else if ( dist <= radius ) + else if ( dist <= radius ) { mightBeClipped = qtrue; } @@ -637,7 +637,7 @@ void R_TransformModelToClip( const vec3_t src, const float *modelViewMatrix, con int i; for ( i = 0 ; i < 4 ; i++ ) { - eye[i] = + eye[i] = src[0] * modelViewMatrix[ i + 0 * 4 ] + src[1] * modelViewMatrix[ i + 1 * 4 ] + src[2] * modelViewMatrix[ i + 2 * 4 ] + @@ -645,7 +645,7 @@ void R_TransformModelToClip( const vec3_t src, const float *modelViewMatrix, con } for ( i = 0 ; i < 4 ; i++ ) { - dst[i] = + dst[i] = eye[0] * projectionMatrix[ i + 0 * 4 ] + eye[1] * projectionMatrix[ i + 1 * 4 ] + eye[2] * projectionMatrix[ i + 2 * 4 ] + @@ -703,7 +703,7 @@ Called by both the front end and the back end ================= */ void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, - orientationr_t *ori ) + orientationr_t *ori ) { vec3_t delta; float axisLength; @@ -767,7 +767,7 @@ R_RotateForViewer Sets up the modelview matrix for a given viewParm ================= */ -static void R_RotateForViewer(orientationr_t *ori, viewParms_t *viewParms) +static void R_RotateForViewer(orientationr_t *ori, viewParms_t *viewParms) { float viewerMatrix[16]; vec3_t origin; @@ -828,7 +828,7 @@ static void R_SetFarClip( viewParms_t *viewParms, const trRefdef_t *refdef ) return; } } - + // // set far clipping planes dynamically // @@ -891,7 +891,7 @@ void R_SetupFrustum (viewParms_t *dest, float xmin, float xmax, float ymax, floa vec3_t ofsorigin; float oppleg, adjleg, length; int i; - + if(stereoSep == 0 && xmin == -xmax) { // symmetric case can be simplified @@ -912,7 +912,7 @@ void R_SetupFrustum (viewParms_t *dest, float xmin, float xmax, float ymax, floa // 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->ori.origin, stereoSep, dest->ori.axis[1], ofsorigin); - + oppleg = xmax + stereoSep; length = sqrt(oppleg * oppleg + zProj * zProj); VectorScale(dest->ori.axis[0], oppleg / length, dest->frustum[0].normal); @@ -933,7 +933,7 @@ void R_SetupFrustum (viewParms_t *dest, float xmin, float xmax, float ymax, floa 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; dest->frustum[i].dist = DotProduct (ofsorigin, dest->frustum[i].normal); @@ -965,7 +965,7 @@ void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean comp float width, height, stereoSep = r_stereoSeparation->value; /* - * offset the view origin of the viewer for stereo rendering + * offset the view origin of the viewer for stereo rendering * by setting the projection matrix appropriately. */ @@ -987,7 +987,7 @@ void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean comp width = xmax - xmin; height = ymax - ymin; - + dest->projectionMatrix[0] = 2 * zProj / width; dest->projectionMatrix[4] = 0; dest->projectionMatrix[8] = (xmax + xmin + 2 * stereoSep) / width; @@ -1002,7 +1002,7 @@ void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean comp 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); @@ -1018,7 +1018,7 @@ Sets the z-component transformation part in the projection matrix void R_SetupProjectionZ(viewParms_t *dest) { float zNear, zFar, depth; - + zNear = dest->zNear; zFar = dest->zFar; @@ -1127,7 +1127,7 @@ void R_SetupProjectionOrtho(viewParms_t *dest, const vec3_t viewBounds[2]) 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++) { dest->frustum[i].type = PLANE_NON_AXIAL; @@ -1197,13 +1197,13 @@ void R_PlaneForSurface (surfaceType_t *surfType, cplane_t *plane) { v2 = tri->verts + tri->indexes[1]; v3 = tri->verts + tri->indexes[2]; PlaneFromPoints( plane4, v1->xyz, v2->xyz, v3->xyz ); - VectorCopy( plane4, plane->normal ); + 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 ); + VectorCopy( plane4, plane->normal ); plane->dist = plane4[3]; return; default: @@ -1275,8 +1275,8 @@ qboolean R_GetPortalOrientations(const msurface_t *surf, int entityNum, 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] && + 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 ); @@ -1292,7 +1292,7 @@ qboolean R_GetPortalOrientations(const msurface_t *surf, int entityNum, // 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 ); @@ -1352,7 +1352,7 @@ static qboolean IsMirror( const msurface_t *surface, int entityNum ) R_PlaneForSurface( surface->data, &originalPlane ); // rotate the plane if necessary - if ( entityNum != REFENTITYNUM_WORLD ) + if ( entityNum != REFENTITYNUM_WORLD ) { const trRefEntity_t *currentEntity = &tr.refdef.entities[entityNum]; @@ -1366,12 +1366,12 @@ static qboolean IsMirror( const msurface_t *surface, int entityNum ) // translate the original plane originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.ori.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++ ) + for ( i = 0 ; i < tr.refdef.num_entities ; i++ ) { e = &tr.refdef.entities[i]; if ( e->e.reType != RT_PORTALSURFACE ) { @@ -1384,9 +1384,9 @@ static qboolean IsMirror( const msurface_t *surface, int entityNum ) } // 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] ) + 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; } @@ -1611,7 +1611,7 @@ qboolean R_MirrorViewBySurface (msurface_t *surface, int entityNum) { VectorSubtract( vec3_origin, camera.axis[0], newParms.portalPlane.normal ); newParms.portalPlane.dist = DotProduct( camera.origin, newParms.portalPlane.normal ); - + 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]); @@ -1822,7 +1822,7 @@ void R_AddDrawSurf( surf->dlightBits = dlightMap; surf->fogIndex = fogIndex; } - + tr.refdef.numDrawSurfs++; } @@ -1855,7 +1855,7 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int // // the weapon model must be handled special -- - // we don't want the hacked weapon position showing in + // 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.flags & VPF_NOVIEWMODEL)) { @@ -1935,7 +1935,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 + // FIX ME: always draw null axis model instead of rejecting the drawcall if (tr.currentModel->dataSize > 0) R_AddDrawSurf( &entitySurface, @@ -2154,19 +2154,19 @@ void R_RenderDlightCubemaps(const refdef_t *fd) VectorSet( shadowParms.ori.axis[1], 0, 0, -1); VectorSet( shadowParms.ori.axis[2], 0, 1, 0); break; - case 1: + 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: + 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: + case 3: // +Y VectorSet( shadowParms.ori.axis[0], 0, 1, 0); VectorSet( shadowParms.ori.axis[1], 1, 0, 0); @@ -2857,7 +2857,7 @@ void R_GatherFrameViews(trRefdef_t *refdef) tr.numCachedViewParms++; } } - + } // sun shadowmaps @@ -2929,7 +2929,7 @@ void R_GatherFrameViews(trRefdef_t *refdef) 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); @@ -2986,7 +2986,7 @@ void R_GatherFrameViews(trRefdef_t *refdef) 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; diff --git a/codemp/rd-rend2/tr_marks.cpp b/codemp/rd-rend2/tr_marks.cpp index 6e12616d13..aa2e761a1b 100644 --- a/codemp/rd-rend2/tr_marks.cpp +++ b/codemp/rd-rend2/tr_marks.cpp @@ -39,7 +39,7 @@ Out must have space for two more vertexes than in #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], + int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY], vec3_t normal, float dist, float epsilon) { float dists[MAX_VERTS_ON_POLY+4] = { 0 }; int sides[MAX_VERTS_ON_POLY+4] = { 0 }; @@ -88,13 +88,13 @@ static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON 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)++; @@ -104,7 +104,7 @@ static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON if ( sides[i+1] == SIDE_ON || sides[i+1] == sides[i] ) { continue; } - + // generate a split point p2 = inPoints[ (i+1) % numInPoints ]; diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 4b93f07377..503c7a9b29 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -41,22 +41,22 @@ float ProjectRadius( float r, vec3_t location ) p[1] = fabs( r ); p[2] = -dist; - projected[0] = p[0] * tr.viewParms.projectionMatrix[0] + + 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] + + 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] + + 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] + + projected[3] = p[0] * tr.viewParms.projectionMatrix[3] + p[1] * tr.viewParms.projectionMatrix[7] + p[2] * tr.viewParms.projectionMatrix[11] + tr.viewParms.projectionMatrix[15]; @@ -134,7 +134,7 @@ static int R_CullModel( mdvModel_t *model, trRefEntity_t *ent ) { } } } - + // 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]; @@ -187,9 +187,9 @@ int R_ComputeLOD( trRefEntity_t *ent ) { int frameSize; 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); - + radius = RadiusFromBounds(mdrframe->bounds[0], mdrframe->bounds[1]); } else @@ -228,7 +228,7 @@ int R_ComputeLOD( trRefEntity_t *ent ) { } lod += r_lodbias->integer; - + if ( lod >= tr.currentModel->numLods ) lod = tr.currentModel->numLods - 1; if ( lod < 0 ) @@ -292,7 +292,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { qboolean personalModel; // 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_DEPTHSHADOW))); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { @@ -306,7 +306,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { // when the surfaces are rendered, they don't need to be // range checked again. // - if ( (ent->e.frame >= tr.currentModel->data.mdv[0]->numFrames) + if ( (ent->e.frame >= tr.currentModel->data.mdv[0]->numFrames) || (ent->e.frame < 0) || (ent->e.oldframe >= tr.currentModel->data.mdv[0]->numFrames) || (ent->e.oldframe < 0) ) { diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 0f9d746110..3856f0872a 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -73,7 +73,7 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) ident = *(unsigned *)buf; if( !bAlreadyCached ) LL(ident); - + switch(ident) { case MD3_IDENT: @@ -141,20 +141,20 @@ qhandle_t R_RegisterMDR(const char *name, model_t *mod) 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; } @@ -178,18 +178,18 @@ qhandle_t R_RegisterIQM(const char *name, model_t *mod) 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; } @@ -207,7 +207,7 @@ static modelExtToLoaderMap_t modelLoaders[ ] = { "iqm", R_RegisterIQM }, { "mdr", R_RegisterMDR }, { "md3", R_RegisterMD3 }, - /* + /* Ghoul 2 Insert Start */ { "glm", R_RegisterMD3 }, @@ -430,7 +430,7 @@ qboolean R_LoadMDXA_Server( model_t *mod, void *buffer, const char *mod_name, qb 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); @@ -439,7 +439,7 @@ qboolean R_LoadMDXA_Server( model_t *mod, void *buffer, const char *mod_name, qb LL(version); LL(size); } - + if (version != MDXA_VERSION) { return qfalse; } @@ -455,7 +455,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 + // 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... // @@ -499,11 +499,11 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb 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); @@ -518,8 +518,8 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb } mod->type = MOD_MDXM; - mod->dataSize += size; - + 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); @@ -529,7 +529,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 + // 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... // @@ -547,10 +547,10 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb 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) + if (!mdxm->animIndex) { return qfalse; } @@ -563,7 +563,7 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb } surfInfo = (mdxmSurfHierarchy_t *)( (byte *)mdxm + mdxm->ofsSurfHierarchy); - for ( i = 0 ; i < mdxm->numSurfaces ; i++) + for ( i = 0 ; i < mdxm->numSurfaces ; i++) { LL(surfInfo->numChildren); LL(surfInfo->parentIndex); @@ -577,7 +577,7 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb // 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); @@ -585,7 +585,7 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb // 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++) @@ -595,7 +595,7 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb 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++) + for ( i = 0 ; i < mdxm->numSurfaces ; i++) { LL(surf->numTriangles); LL(surf->ofsTriangles); @@ -608,14 +608,14 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb // 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; @@ -674,7 +674,7 @@ qhandle_t R_RegisterMDX_Server(const char *name, model_t *mod) ident = *(unsigned *)buf; if( !bAlreadyCached ) LL(ident); - + switch(ident) { case MDXA_IDENT: @@ -722,7 +722,7 @@ qhandle_t R_RegisterMDX_Server(const char *name, model_t *mod) // when there are multiple models of different formats available static modelExtToLoaderMap_t serverModelLoaders[ ] = { - /* + /* Ghoul 2 Insert Start */ { "glm", R_RegisterMDX_Server }, @@ -1217,7 +1217,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN R_LoadMDR ================= */ -static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char *mod_name ) +static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char *mod_name ) { int i, j, k, l; mdrHeader_t *pinmodel, *mdr; @@ -1234,20 +1234,20 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char pinmodel = (mdrHeader_t *)buffer; pinmodel->version = LittleLong(pinmodel->version); - if (pinmodel->version != MDR_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); @@ -1263,7 +1263,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // 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) @@ -1276,7 +1276,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char 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. - + 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)); @@ -1288,7 +1288,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char mod->numLods = mdr->numLODs; - if ( mdr->numFrames < 1 ) + if ( mdr->numFrames < 1 ) { ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has no frames\n", mod_name); return qfalse; @@ -1297,14 +1297,14 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char /* 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... + + // compressed model... cframe = (mdrCompFrame_t *)((byte *) pinmodel - pinmodel->ofsFrames); - + for(i = 0; i < mdr->numFrames; i++) { for(j = 0; j < 3; j++) @@ -1316,7 +1316,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char 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++) @@ -1324,15 +1324,15 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // 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]; @@ -1341,14 +1341,14 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char 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 ( i = 0 ; i < mdr->numFrames ; i++) { for(j = 0; j < 3; j++) { @@ -1356,26 +1356,26 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char 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++) + + 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++) { @@ -1387,12 +1387,12 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char } 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 @@ -1403,26 +1403,26 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char } // 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 ) + 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-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 ) - 1, surf->name[0] ? surf->name : "a surface", @@ -1439,16 +1439,16 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char } 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) { @@ -1459,37 +1459,37 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char 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) { @@ -1502,11 +1502,11 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char 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; @@ -1522,7 +1522,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // 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); @@ -1534,21 +1534,21 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char 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; } @@ -1687,7 +1687,7 @@ void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t mdrFrame_t *frame; mdrTag_t *tag; - if ( framenum >= mod->numFrames ) + if ( framenum >= mod->numFrames ) { // it is possible to have a bad frame while changing models, so don't error framenum = mod->numFrames - 1; @@ -1711,7 +1711,7 @@ void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t 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]; + dest->origin[2]=frame->bones[tag->boneIndex].matrix[2][3]; return; } @@ -1726,7 +1726,7 @@ void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t R_LerpTag ================ */ -int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, +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; @@ -1766,7 +1766,7 @@ int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFram return qfalse; } } - + frontLerp = frac; backLerp = 1.0f - frac; @@ -1796,7 +1796,7 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { if(model->type == MOD_BRUSH) { VectorCopy( model->data.bmodel->bounds[0], mins ); VectorCopy( model->data.bmodel->bounds[1], maxs ); - + return; } else if (model->type == MOD_MESH) { mdvModel_t *header; @@ -1807,7 +1807,7 @@ 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_MDR) { mdrHeader_t *header; @@ -1818,11 +1818,11 @@ 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_IQM) { iqmData_t *iqmData; - + 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 7639ac1b2d..3d6e007842 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -108,7 +108,7 @@ 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]; @@ -308,7 +308,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na 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 ) { @@ -337,14 +337,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 ) + 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-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 ) - 1, meshName[0] ? meshName : "a surface", @@ -534,10 +534,10 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na 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 ); @@ -600,14 +600,14 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na // 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; } @@ -862,7 +862,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent, int entityNum ) { // when the surfaces are rendered, they don't need to be // range checked again. // - if ( (ent->e.frame >= data->num_frames) + if ( (ent->e.frame >= data->num_frames) || (ent->e.frame < 0) || (ent->e.oldframe >= data->num_frames) || (ent->e.oldframe < 0) ) { @@ -913,9 +913,9 @@ void R_AddIQMSurfaces( trRefEntity_t *ent, int entityNum ) { // stencil shadows can't do personal models unless I polyhedron clip if ( !personalModel - && r_shadows->integer == 2 + && r_shadows->integer == 2 && fogNum == 0 - && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) + && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.shadowShader, 0, 0, R_IsPostRenderEntity(ent), 0 ); } @@ -968,7 +968,7 @@ static void ComputePoseMats( iqmData_t *data, int frame, int oldframe, } else { mat1 = data->poseMats + 12 * data->num_poses * frame; mat2 = data->poseMats + 12 * data->num_poses * oldframe; - + for( i = 0; i < data->num_poses; i++, joint++ ) { if( *joint >= 0 ) { float tmpMat[12]; @@ -976,7 +976,7 @@ static void ComputePoseMats( iqmData_t *data, int frame, int oldframe, backlerp, tmpMat ); Matrix34Multiply( mat + 12 * *joint, tmpMat, mat + 12*i ); - + } else { InterpolateMatrix( mat1 + 12*i, mat2 + 12*i, backlerp, mat ); @@ -1150,7 +1150,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { } int R_IQMLerpTag( orientation_t *tag, iqmData_t *data, - int startFrame, int endFrame, + int startFrame, int endFrame, float frac, const char *tagName ) { float jointMats[IQM_MAX_JOINTS * 12]; int joint; diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index 9502cb50e7..35a8ba29d8 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -66,7 +66,7 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in // blend with old log luminance for gradual change VectorSet4(srcBox, 0, 0, 0, 0); - color[0] = + color[0] = color[1] = color[2] = 1.0f; @@ -97,14 +97,14 @@ RB_BokehBlur Blurs a part of one framebuffer to another. -Framebuffers can be identical. +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) @@ -229,7 +229,7 @@ static void RB_RadialBlur(FBO_t *srcFbo, FBO_t *dstFbo, int passes, float stretc { vec2_t texScale; - texScale[0] = + texScale[0] = texScale[1] = 1.0f; alpha *= inc; @@ -263,7 +263,7 @@ static void RB_RadialBlur(FBO_t *srcFbo, FBO_t *dstFbo, int passes, float stretc 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 ); scale *= mul; @@ -295,7 +295,7 @@ static qboolean RB_UpdateSunFlareVis(void) ri.Printf(PRINT_DEVELOPER, "Waited %d iterations\n", iter); } - + qglGetQueryObjectuiv(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT, &sampleCount); return (qboolean)(sampleCount > 0); } @@ -348,7 +348,7 @@ void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) vec2_t texScale; vec4i_t rayBox, quarterBox; - texScale[0] = + texScale[0] = texScale[1] = 1.0f; VectorSet4(color, mul, mul, mul, 1); @@ -396,13 +396,13 @@ void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) stretch += stretch_add; } } - + // add result back on top of the main buffer { float mul = 1.f; vec2_t texScale; - texScale[0] = + texScale[0] = texScale[1] = 1.0f; VectorSet4(color, mul, mul, mul, 1); @@ -437,7 +437,7 @@ static void RB_BlurAxis(FBO_t *srcFbo, FBO_t *dstFbo, float strength, qboolean h vec4_t color; vec2_t texScale; - texScale[0] = + texScale[0] = texScale[1] = 1.0f; VectorSet4(color, weights[0], weights[0], weights[0], 1.0f); diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index b62dca2004..6835c305a3 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -137,7 +137,7 @@ void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts poly->hShader = hShader; poly->numVerts = numVerts; poly->verts = &backEndData->polyVerts[r_numpolyverts]; - + Com_Memcpy( poly->verts, &verts[numVerts*j], numVerts * sizeof( *verts ) ); // done. @@ -159,7 +159,7 @@ void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts AddPointToBounds( poly->verts[i].xyz, bounds[0], bounds[1] ); } for ( fogIndex = 1 ; fogIndex < tr.world->numfogs ; fogIndex++ ) { - fog = &tr.world->fogs[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] @@ -262,7 +262,7 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa dl->color[1] = g; dl->color[2] = b; - if (r_hdr->integer) + if (r_hdr->integer) { float maxValue = MAX(r, MAX(g, b)); if (maxValue > 1.0f) @@ -272,7 +272,7 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa } dl->radius = MIN(dl->radius, 65535.0f); } - + dl->additive = additive; } @@ -432,7 +432,7 @@ void RE_BeginScene(const refdef_t *fd) VectorCopy(extra->sunCol, tr.refdef.sunCol); VectorCopy(extra->sunAmbCol, tr.refdef.sunAmbCol); } - } + } else { tr.refdef.blurFactor = 0.0f; @@ -518,7 +518,7 @@ Rendering a scene may require multiple views to be rendered to handle mirrors, @@@@@@@@@@@@@@@@@@@@@ */ -void RE_RenderScene( const refdef_t *fd ) +void RE_RenderScene( const refdef_t *fd ) { int startTime; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index bc65a71cb7..062cb6166a 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // tr_shade.c -#include "tr_local.h" +#include "tr_local.h" #include "tr_allocator.h" /* @@ -52,7 +52,7 @@ void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex } -static void R_DrawMultiElementsVBO( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex, +static void R_DrawMultiElementsVBO( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex, GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex) { GL_MultiDrawIndexed( @@ -195,7 +195,7 @@ static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatr 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; @@ -217,9 +217,9 @@ static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatr RB_CalcScaleTexMatrix( bundle->texMods[tm].scale, matrix ); break; - + case TMOD_STRETCH: - RB_CalcStretchTexMatrix( &bundle->texMods[tm].wave, + RB_CalcStretchTexMatrix( &bundle->texMods[tm].wave, matrix ); break; @@ -239,7 +239,7 @@ static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatr } switch ( bundle->texMods[tm].type ) - { + { case TMOD_NONE: case TMOD_TURBULENT: default: @@ -276,14 +276,14 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t colorGen_t rgbGen = pStage->rgbGen; alphaGen_t alphaGen = pStage->alphaGen; - baseColor[0] = - baseColor[1] = - baseColor[2] = - baseColor[3] = 1.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = + baseColor[0] = + baseColor[1] = + baseColor[2] = + baseColor[3] = 1.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = vertColor[3] = 0.0f; if ( forceRGBGen != NULL && *forceRGBGen != CGEN_BAD ) @@ -299,20 +299,20 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t switch ( rgbGen ) { case CGEN_IDENTITY_LIGHTING: - baseColor[0] = + baseColor[0] = baseColor[1] = baseColor[2] = tr.identityLight; break; case CGEN_EXACT_VERTEX: case CGEN_EXACT_VERTEX_LIT: - baseColor[0] = + baseColor[0] = baseColor[1] = - baseColor[2] = + baseColor[2] = baseColor[3] = 0.0f; vertColor[0] = vertColor[1] = - vertColor[2] = + vertColor[2] = vertColor[3] = 1.0f; break; case CGEN_CONST: @@ -322,7 +322,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t baseColor[3] = pStage->constantColor[3]; break; case CGEN_VERTEX: - baseColor[0] = + baseColor[0] = baseColor[1] = baseColor[2] = baseColor[3] = 0.0f; @@ -333,18 +333,18 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor[3] = 1.0f; break; case CGEN_VERTEX_LIT: - baseColor[0] = + baseColor[0] = baseColor[1] = - baseColor[2] = + baseColor[2] = baseColor[3] = 0.0f; vertColor[0] = vertColor[1] = - vertColor[2] = + vertColor[2] = vertColor[3] = tr.identityLight; break; case CGEN_ONE_MINUS_VERTEX: - baseColor[0] = + baseColor[0] = baseColor[1] = baseColor[2] = tr.identityLight; @@ -359,8 +359,8 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t } break; case CGEN_WAVEFORM: - baseColor[0] = - baseColor[1] = + baseColor[0] = + baseColor[1] = baseColor[2] = RB_CalcWaveColorSingle( &pStage->rgbWave ); break; case CGEN_ENTITY: @@ -460,9 +460,9 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t { *forceRGBGen = rgbGen; } - + // multiply color by overbrightbits if this isn't a blend - if (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) @@ -484,7 +484,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t 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; @@ -1044,7 +1044,7 @@ 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 && + if (tr.world && tr.world->globalFog && input->fogNum != tr.world->globalFogIndex && input->shader->sort != SS_FOG) shaderBits |= FOGDEF_USE_FALLBACK_GLOBAL_FOG; @@ -1052,7 +1052,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v if (input->numPasses > 0) if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) shaderBits |= FOGDEF_USE_ALPHA_TEST; - + shaderProgram_t *sp = tr.fogShader + shaderBits; backEnd.pc.c_fogDraws++; @@ -1062,7 +1062,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v uniformDataWriter.SetUniformInt(UNIFORM_FOGINDEX, input->fogNum - 1); 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 ) stateBits |= GLS_DEPTHFUNC_EQUAL; @@ -1310,7 +1310,7 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag if (glState.skeletalAnimation) { index |= LIGHTDEF_USE_SKELETAL_ANIMATION; - } + } } if ( !useAlphaTestGE192 ) @@ -1482,7 +1482,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays assert(sp); uniformDataWriter.Start(sp); - + if ( input->fogNum ) { vec4_t fogColorMask; ComputeFogColorMask(pStage, fogColorMask); @@ -1521,7 +1521,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if (backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA) { - baseColor[3] = backEnd.currentEntity->e.shaderRGBA[3] / 255.0f; + baseColor[3] = backEnd.currentEntity->e.shaderRGBA[3] / 255.0f; vertColor[3] = 0.0f; } @@ -1586,7 +1586,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays texMatrix[0] = texMatrix[3] = input->texCoords[input->firstIndex][0][0]; else #endif - ComputeTexMods(pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb); + ComputeTexMods(pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); @@ -1759,7 +1759,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[0], 0); samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[1], 1); } - else + else { // // set state @@ -1785,7 +1785,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec4(UNIFORM_CUBEMAPINFO, vec); } - + if (enableDLights) { uniformDataWriter.SetUniformInt(UNIFORM_LIGHTMASK, tess.dlightBits); @@ -1854,7 +1854,7 @@ void RB_StageIteratorGeneric( void ) // // log this call // - if ( r_logFile->integer ) + if ( r_logFile->integer ) { // don't just call LogComment, or we will get // a call to va() every frame! @@ -1863,7 +1863,7 @@ void RB_StageIteratorGeneric( void ) // // update vertex buffer data - // + // uint32_t vertexAttribs = RB_CalcShaderVertexAttribs( input->shader ); if (tess.useInternalVBO) { @@ -1982,7 +1982,7 @@ void RB_EndSurface( void ) { 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"); } diff --git a/codemp/rd-rend2/tr_shade_calc.cpp b/codemp/rd-rend2/tr_shade_calc.cpp index 840bc8087a..d51a4e3b11 100644 --- a/codemp/rd-rend2/tr_shade_calc.cpp +++ b/codemp/rd-rend2/tr_shade_calc.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #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 ) +static float *TableForFunc( genFunc_t func ) { switch ( func ) { @@ -54,7 +54,7 @@ static float *TableForFunc( genFunc_t func ) ** ** Evaluates a given waveForm_t, referencing backEnd.refdef.time directly */ -static float EvalWaveForm( const waveForm_t *wf ) +static float EvalWaveForm( const waveForm_t *wf ) { float *table; @@ -133,7 +133,7 @@ void RB_CalcDeformVertexes( deformStage_t *ds ) for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal++ ) { R_VboUnpackNormal(offset, *normal); - + xyz[0] += offset[0] * scale; xyz[1] += offset[1] * scale; xyz[2] += offset[2] * scale; @@ -147,7 +147,7 @@ void RB_CalcDeformVertexes( deformStage_t *ds ) { float off = ( xyz[0] + xyz[1] + xyz[2] ) * ds->deformationSpread; - scale = WAVEVALUE( table, ds->deformationWave.base, + scale = WAVEVALUE( table, ds->deformationWave.base, ds->deformationWave.amplitude, ds->deformationWave.phase + off, ds->deformationWave.frequency ); @@ -225,7 +225,7 @@ void RB_CalcBulgeVertexes( deformStage_t *ds ) { off = (float)( FUNCTABLE_SIZE / (M_PI*2) ) * ( st[0] * ds->bulgeWidth + now ); scale = tr.sinTable[ off & FUNCTABLE_MASK ] * ds->bulgeHeight; - + xyz[0] += fNormal[0] * scale; xyz[1] += fNormal[1] * scale; xyz[2] += fNormal[2] * scale; @@ -249,7 +249,7 @@ void RB_CalcMoveVertexes( deformStage_t *ds ) { table = TableForFunc( ds->deformationWave.func ); - scale = WAVEVALUE( table, ds->deformationWave.base, + scale = WAVEVALUE( table, ds->deformationWave.base, ds->deformationWave.amplitude, ds->deformationWave.phase, ds->deformationWave.frequency ); @@ -486,7 +486,7 @@ static void Autosprite2Deform( void ) { v2 = xyz + 4 * edgeVerts[j][1]; VectorSubtract( v1, v2, temp ); - + l = DotProduct( temp, temp ); if ( l < lengths[0] ) { nums[1] = nums[0]; @@ -514,7 +514,7 @@ static void Autosprite2Deform( void ) { // 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; @@ -523,7 +523,7 @@ static void Autosprite2Deform( void ) { 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++ ) { @@ -623,7 +623,7 @@ float RB_CalcWaveColorSingle( const waveForm_t *wf ) } else { glow = EvalWaveForm( wf ) * tr.identityLight; } - + if ( glow < 0 ) { glow = 0; } @@ -706,11 +706,11 @@ void RB_CalcFogTexCoords( float *st ) { // rotate the gradient vector for this orientation if ( fog->hasSurface ) { - fogDepthVector[0] = fog->surface[0] * backEnd.ori.axis[0][0] + + 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] + + 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] + + 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 ); @@ -736,7 +736,7 @@ void RB_CalcFogTexCoords( float *st ) { s = DotProduct( v, fogDistanceVector ) + fogDistanceVector[3]; t = DotProduct( v, fogDepthVector ) + fogDepthVector[3]; - // partially clipped fogs use the T axis + // partially clipped fogs use the T axis if ( eyeOutside ) { if ( t < 1.0 ) { t = 1.0/32; // point is outside, so no fogging diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index c3f8e2c470..f938dff0fc 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -27,7 +27,7 @@ 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 shaderStage_t stages[MAX_SHADER_STAGES]; static shader_t shader; static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS]; @@ -41,31 +41,31 @@ static shader_t* hashTable[FILE_HASH_SIZE]; #define MAX_SHADERTEXT_HASH 2048 static char **shaderTextHashTable[MAX_SHADERTEXT_HASH] = { 0 }; -const int lightmapsNone[MAXLIGHTMAPS] = -{ +const int lightmapsNone[MAXLIGHTMAPS] = +{ LIGHTMAP_NONE, LIGHTMAP_NONE, LIGHTMAP_NONE, - LIGHTMAP_NONE + LIGHTMAP_NONE }; -const int lightmaps2d[MAXLIGHTMAPS] = -{ +const int lightmaps2d[MAXLIGHTMAPS] = +{ LIGHTMAP_2D, LIGHTMAP_2D, LIGHTMAP_2D, - LIGHTMAP_2D + LIGHTMAP_2D }; -const int lightmapsVertex[MAXLIGHTMAPS] = -{ +const int lightmapsVertex[MAXLIGHTMAPS] = +{ LIGHTMAP_BY_VERTEX, LIGHTMAP_BY_VERTEX, LIGHTMAP_BY_VERTEX, - LIGHTMAP_BY_VERTEX + LIGHTMAP_BY_VERTEX }; -const int lightmapsFullBright[MAXLIGHTMAPS] = +const int lightmapsFullBright[MAXLIGHTMAPS] = { LIGHTMAP_WHITEIMAGE, LIGHTMAP_WHITEIMAGE, @@ -73,7 +73,7 @@ const int lightmapsFullBright[MAXLIGHTMAPS] = LIGHTMAP_WHITEIMAGE }; -const byte stylesDefault[MAXLIGHTMAPS] = +const byte stylesDefault[MAXLIGHTMAPS] = { LS_NORMAL, LS_LSNONE, @@ -243,7 +243,7 @@ ParseAlphaTestFunc =============== */ static void ParseAlphaTestFunc( shaderStage_t *stage, const char *funcname ) -{ +{ stage->alphaTestType = ALPHA_TEST_NONE; if ( !Q_stricmp( funcname, "GT0" ) ) @@ -610,7 +610,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) return; } tmi->wave.frequency = atof( token ); - + tmi->type = TMOD_STRETCH; } // @@ -1222,7 +1222,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else if ( !Q_stricmp( token, "map" ) || (!Q_stricmp(token, "clampmap"))) { int flags = !Q_stricmp(token, "clampmap") ? IMGFLAG_CLAMPTOEDGE : IMGFLAG_NONE; - + token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { @@ -1375,7 +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; } - + } // // rmoMap || rmosMap @@ -1605,8 +1605,8 @@ 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->specularScale[0] = - stage->specularScale[1] = + stage->specularScale[0] = + stage->specularScale[1] = stage->specularScale[2] = Com_Clamp( 0.0f, 1.0f, atof( token ) ); } // @@ -1624,13 +1624,13 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } 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 - exponent = CLAMP(exponent, 1.0, 8192.0); + // 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] = 1.0f - (log(exponent) / log(8192.0)); } // - // gloss + // gloss // else if ( !Q_stricmp( token, "gloss" ) ) { @@ -1862,7 +1862,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } } // - // alphaGen + // alphaGen // else if ( !Q_stricmp( token, "alphaGen" ) ) { @@ -1939,7 +1939,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // // tcGen // - else if ( !Q_stricmp(token, "texgen") || !Q_stricmp( token, "tcGen" ) ) + else if ( !Q_stricmp(token, "texgen") || !Q_stricmp( token, "tcGen" ) ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) @@ -1967,7 +1967,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->bundle[0].tcGen = TCGEN_VECTOR; } - else + else { ri.Printf( PRINT_WARNING, "WARNING: unknown texgen parm in shader '%s'\n", shader.name ); } @@ -2136,7 +2136,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // if ( stage->rgbGen == CGEN_BAD ) { if ( blendSrcBits == 0 || - blendSrcBits == GLS_SRCBLEND_ONE || + blendSrcBits == GLS_SRCBLEND_ONE || blendSrcBits == GLS_SRCBLEND_SRC_ALPHA ) { stage->rgbGen = CGEN_IDENTITY_LIGHTING; } else { @@ -2148,7 +2148,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // // implicitly assume that a GL_ONE GL_ZERO blend mask disables blending // - if ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && + if ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && ( blendDstBits == GLS_DSTBLEND_ZERO ) ) { blendDstBits = blendSrcBits = 0; @@ -2166,8 +2166,8 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // // compute state bits // - stage->stateBits = depthMaskBits | - blendSrcBits | blendDstBits | + stage->stateBits = depthMaskBits | + blendSrcBits | blendDstBits | depthFuncBits; return qtrue; @@ -2223,7 +2223,7 @@ static void ParseDeform( const char **text ) { if ( !Q_stricmpn( token, "text", 4 ) ) { int n; - + n = token[4] - '0'; if ( n < 0 || n > 7 ) { n = 0; @@ -2432,7 +2432,7 @@ void ParseSort( const char **text ) { shader.sort = SS_MID_OUTSIDE; } else if ( !Q_stricmp( token, "outside" ) ) { shader.sort = SS_OUTSIDE; - } + } else { shader.sort = atof( token ); } @@ -2448,20 +2448,20 @@ const char *materialNames[MATERIAL_LAST] = MATERIALS }; -void ParseMaterial( const char **text ) +void ParseMaterial( const char **text ) { char *token; int i; token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) + 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] ) ) + if ( !Q_stricmp( token, materialNames[i] ) ) { shader.surfaceFlags |= i; break; @@ -2483,13 +2483,13 @@ infoParm_t infoParms[] = { { "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 }, // + { "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 }, // + { "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 }, // + { "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 @@ -2502,17 +2502,17 @@ infoParm_t infoParms[] = { /* Game surface flags */ { "sky", CONTENTS_ALL, SURF_SKY, CONTENTS_NONE }, // emit light from an environment map - { "slick", CONTENTS_ALL, SURF_SLICK, CONTENTS_NONE }, // + { "slick", CONTENTS_ALL, SURF_SLICK, CONTENTS_NONE }, // - { "nodamage", CONTENTS_ALL, SURF_NODAMAGE, 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 }, // + { "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 }, // + { "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 }, // + { "forcefield", CONTENTS_ALL, SURF_FORCEFIELD, CONTENTS_NONE }, // { "forcesight", CONTENTS_ALL, SURF_FORCESIGHT, CONTENTS_NONE }, // only visible with force sight }; @@ -2605,7 +2605,7 @@ static qboolean ParseShader( const char **text ) else if ( !Q_stricmp( token, "material" ) || !Q_stricmp( token, "q3map_material" ) ) { ParseMaterial( text ); - } + } // sun parms else if ( !Q_stricmp( token, "sun" ) || !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) || !Q_stricmp( token, "q3gl2_sun" ) ) { float a, b; @@ -2623,7 +2623,7 @@ static qboolean ParseShader( const char **text ) tr.sunLight[1] = atof( token ); token = COM_ParseExt( text, qfalse ); tr.sunLight[2] = atof( token ); - + VectorNormalize( tr.sunLight ); token = COM_ParseExt( text, qfalse ); @@ -2764,14 +2764,14 @@ static qboolean ParseShader( const char **text ) continue; } // fogParms - else if ( !Q_stricmp( token, "fogParms" ) ) + else if ( !Q_stricmp( token, "fogParms" ) ) { if ( !ParseVector( text, 3, shader.fogParms.color ) ) { return qfalse; } token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) + if ( !token[0] ) { ri.Printf( PRINT_WARNING, "WARNING: missing parm for 'fogParms' keyword in shader '%s'\n", shader.name ); continue; @@ -2796,13 +2796,13 @@ static qboolean ParseShader( const char **text ) continue; } // light determines flaring in q3map, not needed here - else if ( !Q_stricmp(token, "light") ) + else if ( !Q_stricmp(token, "light") ) { COM_ParseExt( text, qfalse ); continue; } // cull - else if ( !Q_stricmp( token, "cull") ) + else if ( !Q_stricmp( token, "cull") ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) @@ -2960,7 +2960,7 @@ static void ComputeVertexAttribs(void) { shaderStage_t *pStage = &stages[stage]; - if ( !pStage->active ) + if ( !pStage->active ) { break; } @@ -3087,8 +3087,8 @@ 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); @@ -3169,7 +3169,7 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm 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, imageName, MAX_QPATH); @@ -3257,7 +3257,7 @@ static qboolean CollapseStagesToGLSL(void) pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3) { 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_ONE | GLS_SRCBLEND_ONE)) //lightstyle lightmap stages @@ -3474,7 +3474,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->rgbGen != CGEN_LIGHTMAPSTYLE) //don't convert lightstyled lightmap stages { @@ -3660,7 +3660,7 @@ static void SortNewShader( void ) { { break; } - + tr.sortedShaders[i+1] = shader; tr.sortedShaders[i+1]->sortedIndex++; } @@ -3731,7 +3731,7 @@ static shader_t *GeneratePermanentShader( void ) { tr.shaders[ tr.numShaders ] = newShader; newShader->index = tr.numShaders; - + tr.sortedShaders[ tr.numShaders ] = newShader; newShader->sortedIndex = tr.numShaders; @@ -3819,7 +3819,7 @@ static void VertexLightingCollapse( void ) { } else { stages[0].rgbGen = CGEN_EXACT_VERTEX; } - stages[0].alphaGen = AGEN_SKIP; + stages[0].alphaGen = AGEN_SKIP; } else { // don't use a lightmap (tesla coils) if ( stages[0].bundle[0].isLightmap ) { @@ -4040,23 +4040,23 @@ static shader_t *FinishShader( void ) { 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; } @@ -4131,7 +4131,7 @@ static shader_t *FinishShader( void ) { } } } - + stage++; } @@ -4223,7 +4223,7 @@ static const char *FindShaderInShaderText( const char *shadername ) { { p = shaderTextHashTable[hash][i]; token = COM_ParseExt(&p, qtrue); - + if(!Q_stricmp(token, shadername)) return p; } @@ -4534,7 +4534,7 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte return FinishShader(); } -shader_t *R_FindServerShader( const char *name, const int *lightmapIndexes, const byte *styles, qboolean mipRawImage ) +shader_t *R_FindServerShader( const char *name, const int *lightmapIndexes, const byte *styles, qboolean mipRawImage ) { char strippedName[MAX_QPATH]; int hash; @@ -4566,7 +4566,7 @@ shader_t *R_FindServerShader( const char *name, const int *lightmapIndexes, cons ClearGlobalShader(); Q_strncpyz(shader.name, strippedName, sizeof(shader.name)); Com_Memcpy (shader.lightmapIndex, lightmapIndexes, sizeof (shader.lightmapIndex)); - + shader.defaultShader = qtrue; return FinishShader(); } @@ -4660,11 +4660,11 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, const int *lightmapIndexe } sh = FinishShader(); - return sh->index; + return sh->index; } -/* +/* ==================== RE_RegisterShader @@ -4698,7 +4698,7 @@ qhandle_t RE_RegisterShaderLightMap( const char *name, const int *lightmapIndexe } -/* +/* ==================== RE_RegisterShader @@ -4898,20 +4898,20 @@ static void ScanAndLoadShaderFiles( void ) 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] ); - + 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; @@ -4950,17 +4950,17 @@ static void ScanAndLoadShaderFiles( void ) break; } } - - + + if (buffers[i]) - sum += summand; + sum += summand; } // build single large buffer s_shaderText = (char *)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-- ) { diff --git a/codemp/rd-rend2/tr_skin.cpp b/codemp/rd-rend2/tr_skin.cpp index d14f211b6a..69c9c9d204 100644 --- a/codemp/rd-rend2/tr_skin.cpp +++ b/codemp/rd-rend2/tr_skin.cpp @@ -46,9 +46,9 @@ bool RE_SplitSkins(const char *INname, char *skinhead, char *skintorso, char *sk strcpy (skinlower, name); //now get the the individual files - + //advance to second - char *p2 = strchr(p, '|'); + char *p2 = strchr(p, '|'); assert(p2); if (!p2) { @@ -74,14 +74,14 @@ bool RE_SplitSkins(const char *INname, char *skinhead, char *skintorso, char *sk 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) +qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) { skin_t *skin; skinSurface_t *surf; @@ -121,7 +121,7 @@ qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) 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 ); @@ -274,13 +274,13 @@ static char *CommaParse( char **data_p ) { data++; } // skip /* */ comments - else if ( c=='/' && data[1] == '*' ) + else if ( c=='/' && data[1] == '*' ) { - while ( *data && ( *data != '*' || data[1] != '/' ) ) + while ( *data && ( *data != '*' || data[1] != '/' ) ) { data++; } - if ( *data ) + if ( *data ) { data += 2; } @@ -409,7 +409,7 @@ void R_SkinList_f( void ) { Com_Printf ("%3i:%s\n", i, skin->name ); for ( j = 0 ; j < skin->numSurfaces ; j++ ) { - Com_Printf (" %s = %s\n", + Com_Printf (" %s = %s\n", skin->surfaces[j]->name, ((shader_t* )skin->surfaces[j]->shader)->name ); } } diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 98a60c6058..9f9d8eb148 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -36,14 +36,14 @@ POLYGON TO BOX SIDE PROJECTION =================================================================================== */ -static vec3_t sky_clip[6] = +static vec3_t sky_clip[6] = { {1,1,0}, {1,-1,0}, {0,-1,1}, {0,1,1}, {1,0,1}, - {-1,0,1} + {-1,0,1} }; static float sky_mins[2][6], sky_maxs[2][6]; @@ -54,7 +54,7 @@ static float sky_min, sky_max; AddSkyPolygon ================ */ -static void AddSkyPolygon (int nump, vec3_t vecs) +static void AddSkyPolygon (int nump, vec3_t vecs) { int i,j; vec3_t v, av; @@ -147,7 +147,7 @@ static void AddSkyPolygon (int nump, vec3_t vecs) ClipSkyPolygon ================ */ -static void ClipSkyPolygon (int nump, vec3_t vecs, int stage) +static void ClipSkyPolygon (int nump, vec3_t vecs, int stage) { float *norm; float *v; @@ -266,10 +266,10 @@ void RB_ClipSkyPolygons( shaderCommands_t *input ) for ( i = 0; i < input->numIndexes; i += 3 ) { - for (j = 0 ; j < 3 ; j++) + for (j = 0 ; j < 3 ; j++) { VectorSubtract( input->xyz[input->indexes[i+j]], - backEnd.viewParms.ori.origin, + backEnd.viewParms.ori.origin, p[j] ); } ClipSkyPolygon( 3, p[0], 0 ); @@ -369,7 +369,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max int maxIndex = tess.maxIndex; tess.firstIndex = tess.numIndexes; - + for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t <= maxs[1]+HALF_SKY_SUBDIVISIONS; t++ ) { @@ -482,7 +482,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max RB_AddDrawItem(backEndData->currentPass, key, item); RB_CommitInternalBufferData(); - + tess.useInternalVBO = qfalse; tess.numIndexes = tess.firstIndex; tess.numVertexes = firstVertex; @@ -521,22 +521,22 @@ static void DrawSkyBox( shader_t *shader ) 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 ) + if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; - else if ( 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 ) + else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; - if ( sky_maxs_subd[0] < -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 ) + else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS; - if ( sky_maxs_subd[1] < -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 ) + else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; // @@ -548,10 +548,10 @@ static void DrawSkyBox( shader_t *shader ) 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], + 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] ); } } @@ -593,7 +593,7 @@ static void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean ad // 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 ); @@ -641,22 +641,22 @@ static void FillCloudBox( const shader_t *shader, int stage ) 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 ) + if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; - else if ( 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 ) + else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; - if ( sky_maxs_subd[0] < -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 ) + 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 ) + else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; // @@ -668,9 +668,9 @@ static void FillCloudBox( const shader_t *shader, int stage ) 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, + MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + i, NULL, s_skyPoints[t][s] ); @@ -743,20 +743,20 @@ void R_InitSkyTexCoords( float heightCloud ) 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, + 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 * skyVec[2] * radiusWorld + + 2 * sqrt( SQR( skyVec[2] ) * SQR( radiusWorld ) + 2 * SQR( skyVec[0] ) * radiusWorld * heightCloud + - SQR( skyVec[0] ) * SQR( heightCloud ) + + SQR( skyVec[0] ) * SQR( heightCloud ) + 2 * SQR( skyVec[1] ) * radiusWorld * heightCloud + - SQR( skyVec[1] ) * SQR( heightCloud ) + + SQR( skyVec[1] ) * SQR( heightCloud ) + 2 * SQR( skyVec[2] ) * radiusWorld * heightCloud + SQR( skyVec[2] ) * SQR( heightCloud ) ) ); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index fc3255a5ed..95bb89c24e 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -240,14 +240,14 @@ void RB_InstantQuad(vec4_t quadVerts[4]) VectorSet2(texCoords[3], 0.0f, 1.0f); GLSL_BindProgram(&tr.textureColorShader); - + GLSL_SetUniformMatrix4x4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite); RB_InstantQuad2(quadVerts, texCoords); } -void RB_InstantTriangle() +void RB_InstantTriangle() { qglDrawArrays(GL_TRIANGLES, 0, 3); } @@ -273,7 +273,7 @@ static void RB_SurfaceSprite( void ) { } else { float s, c; float ang; - + ang = M_PI * ent->e.rotation / 180; s = sin( ang ); c = cos( ang ); @@ -310,17 +310,17 @@ static void RB_SurfaceOrientedQuad( void ) VectorCopy( backEnd.currentEntity->e.axis[1], left ); VectorCopy( backEnd.currentEntity->e.axis[2], up ); - if ( backEnd.currentEntity->e.rotation == 0 ) + if ( backEnd.currentEntity->e.rotation == 0 ) { VectorScale( left, radius, left ); VectorScale( up, radius, up ); - } - else + } + else { vec3_t tempLeft, tempUp; float s, c; float ang; - + ang = M_PI * backEnd.currentEntity->e.rotation / 180; s = sin( ang ); c = cos( ang ); @@ -336,7 +336,7 @@ static void RB_SurfaceOrientedQuad( void ) VectorCopy( tempLeft, left ); } - if ( backEnd.viewParms.isMirror ) + if ( backEnd.viewParms.isMirror ) { VectorSubtract( vec3_origin, left, left ); } @@ -679,12 +679,12 @@ 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, NULL); GLSL_BindProgram(sp); - + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - + GLSL_SetUniformVec4(sp, UNIFORM_COLOR, colorRed); R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); @@ -702,13 +702,13 @@ static void RB_SurfaceBeam( void ) //------------------ // DoSprite //------------------ -static void DoSprite( vec3_t origin, float radius, float rotation ) +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 ); c = cos( ang ); @@ -719,7 +719,7 @@ static void DoSprite( vec3_t origin, float radius, float rotation ) VectorScale( backEnd.viewParms.ori.axis[2], c * radius, up ); VectorMA( up, s * radius, backEnd.viewParms.ori.axis[1], up ); - if ( backEnd.viewParms.isMirror ) + if ( backEnd.viewParms.isMirror ) { VectorSubtract( vec3_origin, left, left ); } @@ -733,7 +733,7 @@ static void DoSprite( vec3_t origin, float radius, float rotation ) // RB_SurfaceSaber //------------------ static void RB_SurfaceSaberGlow() -{ +{ vec3_t end; refEntity_t *e; @@ -765,13 +765,13 @@ RB_SurfaceLine // 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 ) { @@ -907,7 +907,7 @@ static void DoLine_Oriented( const vec3_t start, const vec3_t end, const vec3_t //----------------- // RB_SurfaceLine //----------------- -static void RB_SurfaceLine( void ) +static void RB_SurfaceLine( void ) { refEntity_t *e; vec3_t right; @@ -928,7 +928,7 @@ static void RB_SurfaceLine( void ) DoLine( start, end, right, e->radius); } -static void RB_SurfaceOrientedLine( void ) +static void RB_SurfaceOrientedLine( void ) { refEntity_t *e; vec3_t right; @@ -971,7 +971,7 @@ static void DoCylinderPart(polyVert_t *verts) VectorScale4 (verts->modulate, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; verts++; - } + } tess.indexes[tess.numIndexes++] = vbase; tess.indexes[tess.numIndexes++] = vbase + 1; @@ -1036,12 +1036,12 @@ static void RB_SurfaceCylinder( void ) //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; @@ -1136,7 +1136,7 @@ static void ApplyShape( vec3_t start, vec3_t end, vec3_t right, float sradius, f DoLine2( start, end, right, sradius, eradius ); return; } - + CreateShape(); VectorSubtract( end, start, fwd ); @@ -1165,7 +1165,7 @@ static void ApplyShape( vec3_t start, vec3_t end, vec3_t right, float sradius, f 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 ); @@ -1191,7 +1191,7 @@ static void DoBoltSeg( vec3_t start, vec3_t end, vec3_t right, float radius ) MakeNormalVectors( fwd, rt, up ); VectorCopy( start, old ); - + oldRadius = newRadius = radius; for ( i = 20; i <= dis; i+= 20 ) @@ -1231,7 +1231,7 @@ static void DoBoltSeg( vec3_t start, vec3_t end, vec3_t right, float radius ) // 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 ) { @@ -1316,13 +1316,13 @@ static void RB_SurfaceElectricity() 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 @@ -1331,14 +1331,14 @@ static void VectorArrayNormalize(vec4_t *normals, unsigned int count) 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__ +#ifdef __GNUC__ asm("frsqrte %0,%1" : "=f" (y0) : "f" (B)); #else y0 = __frsqrte(B); @@ -1404,11 +1404,11 @@ static void LerpMeshVertexes_altivec(md3Surface_t *surf, float backlerp) 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); + newXyzScaleVec = vec_splat(newXyzScaleVec,0); newNormalsLoadPermute = vec_lvsl(0,newXyz); newNormalsStorePermute = vec_lvsr(0,outXyz); zero = (vector float)vec_splat_s8(0); @@ -1417,7 +1417,7 @@ static void LerpMeshVertexes_altivec(md3Surface_t *surf, float backlerp) // for (vertNum=0 ; vertNum < numVerts ; vertNum++, newXyz += 4, newNormals += 4, - outXyz += 4, outNormal += 4) + outXyz += 4, outNormal += 4) { newNormalsLoadPermute = vec_lvsl(0,newXyz); newNormalsStorePermute = vec_lvsr(0,outXyz); @@ -1462,7 +1462,7 @@ static void LerpMeshVertexes_altivec(md3Surface_t *surf, float backlerp) for (vertNum=0 ; vertNum < numVerts ; vertNum++, oldXyz += 4, newXyz += 4, oldNormals += 4, newNormals += 4, - outXyz += 4, outNormal += 4) + outXyz += 4, outNormal += 4) { vec3_t uncompressedOldNormal, uncompressedNewNormal; @@ -1530,7 +1530,7 @@ static void LerpMeshVertexes_scalar(mdvSurface_t *surf, float backlerp) // for (vertNum=0 ; vertNum < numVerts ; vertNum++, newXyz += 4, newNormals += 4, - outXyz += 4, outNormal += 4) + outXyz += 4, outNormal += 4) { outXyz[0] = newXyz[0] * newXyzScale; @@ -1563,7 +1563,7 @@ static void LerpMeshVertexes_scalar(mdvSurface_t *surf, float backlerp) for (vertNum=0 ; vertNum < numVerts ; vertNum++, oldXyz += 4, newXyz += 4, oldNormals += 4, newNormals += 4, - outXyz += 4, outNormal += 4) + outXyz += 4, outNormal += 4) { vec3_t uncompressedOldNormal, uncompressedNewNormal; @@ -1742,11 +1742,11 @@ static float LodErrorForVolume( vec3_t local, float radius ) { return 0; } - world[0] = local[0] * backEnd.ori.axis[0][0] + local[1] * backEnd.ori.axis[1][0] + + 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] + + 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] + + 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.ori.origin, world ); @@ -1848,7 +1848,7 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { break; } } while ( 1 ); - + rows = irows; if ( vrows < irows + 1 ) { rows = vrows - 1; @@ -1932,7 +1932,7 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { 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; @@ -1942,7 +1942,7 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { 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; @@ -2043,7 +2043,7 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) { const int count = backEnd.currentEntity->e.uRefEnt.uMini.miniCount; assert(count > 0); backEnd.currentEntity = &tempEnt; - + assert(backEnd.currentEntity->e.renderfx >= 0); for (int i = 0, j = start; i < count; i++, j++) @@ -2094,7 +2094,7 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) RB_EndSurface(); } - //drawSurf_t drawSurf = + //drawSurf_t drawSurf = R_BindVBO(surface->vbo); R_BindIBO(surface->ibo); @@ -2197,7 +2197,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) // 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]; @@ -2231,7 +2231,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); @@ -2304,8 +2304,8 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) } void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { - (void(*)(void*))RB_SurfaceBad, // SF_BAD, - (void(*)(void*))RB_SurfaceSkip, // SF_SKIP, + (void(*)(void*))RB_SurfaceBad, // SF_BAD, + (void(*)(void*))RB_SurfaceSkip, // SF_SKIP, (void(*)(void*))RB_SurfaceBSPFace, // SF_FACE, (void(*)(void*))RB_SurfaceBSPGrid, // SF_GRID, (void(*)(void*))RB_SurfaceBSPTriangles, // SF_TRIANGLES, diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index f3a5620673..af070e72dd 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -55,7 +55,7 @@ namespace } return; } - + wo->targetVelocityTimeRemaining--; vec3_t deltaVelocity; VectorSubtract(wo->targetVelocity, wo->currentVelocity, deltaVelocity); @@ -131,7 +131,7 @@ namespace vec3_t mapSize; vec3_t halfMapSize; VectorSubtract( - tr.world->bmodels[0].bounds[0], + tr.world->bmodels[0].bounds[0], tr.world->bmodels[0].bounds[1], mapSize); VectorScale(mapSize, -0.5f, halfMapSize); @@ -147,7 +147,7 @@ namespace orientationr_t orientation; R_SetOrientationOriginAndAxis(orientation, viewOrigin, forward, left, up); - + const vec3_t viewBounds[2] = { { 0.0f, -halfMapSize[1], -halfMapSize[0] }, { halfMapSize[2] * 2.0f, halfMapSize[1], halfMapSize[0] } @@ -171,7 +171,7 @@ 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 { qglClearDepth(0.0f); @@ -296,8 +296,8 @@ namespace continue; // Just draw it when batch is full - if (tess.numVertexes + 4 >= SHADER_MAX_VERTEXES || tess.numIndexes + 6 >= SHADER_MAX_INDEXES) - { + 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); @@ -315,7 +315,7 @@ namespace tess.multiDrawPrimitives = 0; tess.externalIBO = nullptr; } - + RB_AddQuadStamp(rayPos, left, up, color); } } @@ -382,7 +382,7 @@ namespace void RB_SimulateWeather(weatherObject_t *ws, vec2_t *zoneOffsets, int zoneIndex) { - if (ws->vboLastUpdateFrame == backEndData->realFrameNumber || + if (ws->vboLastUpdateFrame == backEndData->realFrameNumber || tr.weatherSystem->frozen) { // Already simulated for this frame @@ -632,8 +632,8 @@ void RE_WorldEffectCommand(const char *command) else VectorMA( tr.weatherSystem->constWindDirection, - 0.001f, - parsedWind, + 0.001f, + parsedWind, tr.weatherSystem->constWindDirection); } @@ -888,8 +888,8 @@ void RE_WorldEffectCommand(const char *command) 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, + 0.75f, tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].color); } @@ -996,7 +996,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_FOG].gravity = 0.0f; tr.weatherSystem->weatherSlots[WEATHER_FOG].fadeDistance = 2400.f; tr.weatherSystem->weatherSlots[WEATHER_FOG].size[0] = 300.f; diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 0204652440..01a84dc0d9 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -97,7 +97,7 @@ static qboolean R_CullSurface( msurface_t *surf, int entityNum ) { // 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 + // epsilon isn't allowed here if ( ct == CT_FRONT_SIDED ) { if ( d < surf->cullinfo.plane.dist - 8 ) { return qtrue; @@ -160,7 +160,7 @@ 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++ ) { @@ -175,7 +175,7 @@ static int R_DlightSurface( msurface_t *surf, int dlightBits ) { } } } - + if ( surf->cullinfo.type & CULLINFO_BOX ) { for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { @@ -244,7 +244,7 @@ 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++ ) { @@ -259,7 +259,7 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { } } } - + if ( surf->cullinfo.type & CULLINFO_BOX ) { for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { @@ -272,7 +272,7 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { || 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] + || 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 ); @@ -361,7 +361,7 @@ static void R_AddWorldSurface( R_AddDrawSurf( surf->data, entityNum, surf->shader, surf->fogIndex, dlightBits, isPostRenderEntity, surf->cubemapIndex ); - for ( int i = 0, numSprites = surf->numSurfaceSprites; + for ( int i = 0, numSprites = surf->numSurfaceSprites; i < numSprites; ++i ) { srfSprites_t *sprites = surf->surfaceSprites + i; @@ -390,14 +390,14 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent, int entityNum ) { if ( clip == CULL_OUT ) { return; } - + 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; - + if (world->surfacesViewCount[surf] != tr.viewCount) { world->surfacesViewCount[surf] = tr.viewCount; @@ -608,7 +608,7 @@ void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, int psh 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 ); } @@ -628,7 +628,7 @@ void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, int psh 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 ); } @@ -717,7 +717,7 @@ 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"); } @@ -735,7 +735,7 @@ static mnode_t *R_PointInLeaf( const vec3_t p ) { node = node->children[1]; } } - + return node; } @@ -831,7 +831,7 @@ void R_MarkLeaves( void ) } const byte *vis = R_ClusterPVS(tr.visClusters[tr.visIndex]); - + int i; for (i = 0, leaf = (tr.world->nodes + tr.world->numDecisionNodes); i < (tr.world->numnodes - tr.world->numDecisionNodes); i++, leaf++) { cluster = leaf->cluster; diff --git a/codemp/rd-vanilla/CMakeLists.txt b/codemp/rd-vanilla/CMakeLists.txt index 288997556e..b7909a608a 100644 --- a/codemp/rd-vanilla/CMakeLists.txt +++ b/codemp/rd-vanilla/CMakeLists.txt @@ -99,7 +99,7 @@ set(MPVanillaRendererFiles ${MPVanillaRendererFiles} ${MPVanillaRendererRdCommon set(MPVanillaRendererCommonFiles "${MPDir}/qcommon/matcomp.cpp" "${MPDir}/qcommon/q_shared.cpp" - + ${SharedCommonFiles}) source_group("common" FILES ${MPVanillaRendererCommonFiles}) set(MPVanillaRendererFiles ${MPVanillaRendererFiles} ${MPVanillaRendererCommonFiles}) diff --git a/codemp/rd-vanilla/tr_shader.cpp b/codemp/rd-vanilla/tr_shader.cpp index 5fdc4ea61e..8d1733e5ff 100644 --- a/codemp/rd-vanilla/tr_shader.cpp +++ b/codemp/rd-vanilla/tr_shader.cpp @@ -2373,7 +2373,7 @@ static qboolean ParseShader( const char **text ) // functioned because rgbGen identity doesn't work with setcolor. // // We match against retail version of gfx/menus/radar/arrow_w by calculating - // the hash value of the shader text, and comparing it against a + // the hash value of the shader text, and comparing it against a // precalculated value. if ( shaderHash == RETAIL_ARROW_W_SHADER_HASH && Q_stricmp( shader.name, "gfx/menus/radar/arrow_w" ) == 0 ) diff --git a/codemp/rd-vanilla/tr_shadows.cpp b/codemp/rd-vanilla/tr_shadows.cpp index d5480fc62c..334b5faa77 100644 --- a/codemp/rd-vanilla/tr_shadows.cpp +++ b/codemp/rd-vanilla/tr_shadows.cpp @@ -400,7 +400,7 @@ void RB_DoShadowTessEnd( vec3_t lightPos ) // reenable writing to the color buffer qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); - + #ifdef _DEBUG_STENCIL_SHADOWS qglPolygonMode(GL_FRONT_AND_BACK, GL_FILL); #endif diff --git a/codemp/ui/CMakeLists.txt b/codemp/ui/CMakeLists.txt index f44d4fcf4e..c4ecb7bdbd 100644 --- a/codemp/ui/CMakeLists.txt +++ b/codemp/ui/CMakeLists.txt @@ -54,7 +54,7 @@ set(MPUICommonFiles "${MPDir}/qcommon/q_shared.h" "${MPDir}/qcommon/qfiles.h" "${MPDir}/qcommon/tags.h" - + ${SharedCommonFiles} ) source_group("common" FILES ${MPUICommonFiles}) diff --git a/codemp/ui/ui_shared.c b/codemp/ui/ui_shared.c index f2ed6d56f9..cda2bbc6e6 100644 --- a/codemp/ui/ui_shared.c +++ b/codemp/ui/ui_shared.c @@ -8488,7 +8488,7 @@ static void Item_ApplyHacks( itemDef_t *item ) { } } #endif - + // Fix length of favorite address in createfavorite.menu if ( item->type == ITEM_TYPE_EDITFIELD && item->cvar && !Q_stricmp( item->cvar, "ui_favoriteAddress" ) ) { editFieldDef_t *editField = item->typeData.edit; diff --git a/rv-readme.txt b/rv-readme.txt index 779675e6e3..8c5bfb3916 100644 --- a/rv-readme.txt +++ b/rv-readme.txt @@ -1,4 +1,4 @@ -Activision and Raven are releasing this code for people to learn from and play with. +Activision and Raven are releasing this code for people to learn from and play with. This code is copyright Activision 2003. This source is released under GNU GPLv2. diff --git a/scripts/docker/server.cfg b/scripts/docker/server.cfg index cfdd09e7e7..5bbdc5a213 100644 --- a/scripts/docker/server.cfg +++ b/scripts/docker/server.cfg @@ -1,9 +1,9 @@ // Server Config seta sv_hostname "Sample OpenJK server" -//seta g_motd "woot" +//seta g_motd "woot" //rconpassword "my secret password" -seta sv_maxclients 16 +seta sv_maxclients 16 set timelimit 20 // gametypes // 0 = FFA diff --git a/shared/qcommon/q_string.c b/shared/qcommon/q_string.c index 280de852ff..a4f581f659 100644 --- a/shared/qcommon/q_string.c +++ b/shared/qcommon/q_string.c @@ -109,7 +109,7 @@ void Q_strncpyz( char *dest, const char *src, int destsize ) { assert(src); assert(dest); assert(destsize); - + strncpy( dest, src, destsize-1 ); dest[destsize-1] = 0; } diff --git a/shared/qcommon/safe/files.h b/shared/qcommon/safe/files.h index e82d3964e7..c477ddea35 100644 --- a/shared/qcommon/safe/files.h +++ b/shared/qcommon/safe/files.h @@ -87,7 +87,7 @@ namespace FS { return static_cast< std::size_t >( _end - begin() ); } - + private: // TODO: this should really be const; it's a matter of making FS_ListFiles' result const. char** _begin = nullptr; diff --git a/ui/menudef.h b/ui/menudef.h index 203a95dff9..df27d11f45 100644 --- a/ui/menudef.h +++ b/ui/menudef.h @@ -7,12 +7,12 @@ #define CT_DKCYAN 0 0.25 0.25 #define ITEM_TYPE_TEXT 0 // simple text -#define ITEM_TYPE_BUTTON 1 // button, basically text with a border -#define ITEM_TYPE_RADIOBUTTON 2 // toggle button, may be grouped +#define ITEM_TYPE_BUTTON 1 // button, basically text with a border +#define ITEM_TYPE_RADIOBUTTON 2 // toggle button, may be grouped #define ITEM_TYPE_CHECKBOX 3 // check box #define ITEM_TYPE_EDITFIELD 4 // editable text, associated with a cvar #define ITEM_TYPE_COMBO 5 // drop down list -#define ITEM_TYPE_LISTBOX 6 // scrollable list +#define ITEM_TYPE_LISTBOX 6 // scrollable list #define ITEM_TYPE_MODEL 7 // model #define ITEM_TYPE_OWNERDRAW 8 // owner draw, name specs what it is #define ITEM_TYPE_NUMERICFIELD 9 // editable text, associated with a cvar @@ -21,7 +21,7 @@ #define ITEM_TYPE_MULTI 12 // multiple list setting, enumerated #define ITEM_TYPE_BIND 13 // multiple list setting, enumerated #define ITEM_TYPE_TEXTSCROLL 14 // scrolls text - + #define ITEM_ALIGN_LEFT 0 // left alignment #define ITEM_ALIGN_CENTER 1 // center alignment #define ITEM_ALIGN_RIGHT 2 // right alignment @@ -33,17 +33,17 @@ #define ITEM_TEXTSTYLE_OUTLINED 4 // drop shadow ( need a color for this ) #define ITEM_TEXTSTYLE_OUTLINESHADOWED 5 // drop shadow ( need a color for this ) #define ITEM_TEXTSTYLE_SHADOWEDMORE 6 // drop shadow ( need a color for this ) - + #define WINDOW_BORDER_NONE 0 // no border #define WINDOW_BORDER_FULL 1 // full border based on border color ( single pixel ) #define WINDOW_BORDER_HORZ 2 // horizontal borders only -#define WINDOW_BORDER_VERT 3 // vertical borders only +#define WINDOW_BORDER_VERT 3 // vertical borders only #define WINDOW_BORDER_KCGRADIENT 4 // horizontal border using the gradient bars - + #define WINDOW_STYLE_EMPTY 0 // no background #define WINDOW_STYLE_FILLED 1 // filled with background color -#define WINDOW_STYLE_GRADIENT 2 // gradient bar based on background color -#define WINDOW_STYLE_SHADER 3 // gradient bar based on background color +#define WINDOW_STYLE_GRADIENT 2 // gradient bar based on background color +#define WINDOW_STYLE_SHADER 3 // gradient bar based on background color #define WINDOW_STYLE_TEAMCOLOR 4 // team color #define WINDOW_STYLE_CINEMATIC 5 // cinematic @@ -166,10 +166,10 @@ // owner draw types // ideally these should be done outside of this file but -// this makes it much easier for the macro expansion to +// this makes it much easier for the macro expansion to // convert them for the designers ( from the .menu files ) #define CG_OWNERDRAW_BASE 1 -#define CG_PLAYER_ARMOR_ICON 1 +#define CG_PLAYER_ARMOR_ICON 1 #define CG_PLAYER_ARMOR_VALUE 2 #define CG_PLAYER_HEAD 3 #define CG_PLAYER_HEALTH 4 @@ -208,13 +208,13 @@ #define CG_PLAYER_LOCATION 33 #define CG_TEAM_COLOR 34 #define CG_CTF_POWERUP 35 - + #define CG_AREA_POWERUP 36 #define CG_AREA_LAGOMETER 37 // painted with old system -#define CG_PLAYER_HASFLAG 38 +#define CG_PLAYER_HASFLAG 38 #define CG_GAME_TYPE 39 // not done -#define CG_SELECTEDPLAYER_ARMOR 40 +#define CG_SELECTEDPLAYER_ARMOR 40 #define CG_SELECTEDPLAYER_HEALTH 41 #define CG_PLAYER_STATUS 42 #define CG_FRAGGED_MSG 43 // painted with old system @@ -225,7 +225,7 @@ #define CG_AREA_CHAT 48 // painted with old system #define CG_GAME_STATUS 49 #define CG_KILLER 50 -#define CG_PLAYER_ARMOR_ICON2D 51 +#define CG_PLAYER_ARMOR_ICON2D 51 #define CG_PLAYER_AMMO_ICON2D 52 #define CG_ACCURACY 53 #define CG_ASSISTS 54 @@ -238,9 +238,9 @@ #define CG_TEAMINFO 61 #define CG_VOICE_HEAD 62 #define CG_VOICE_NAME 63 -#define CG_PLAYER_HASFLAG2D 64 +#define CG_PLAYER_HASFLAG2D 64 #define CG_HARVESTER_SKULLS2D 65 // only shows in harvester -#define CG_CAPFRAGLIMIT 66 +#define CG_CAPFRAGLIMIT 66 #define CG_1STPLACE 67 #define CG_2NDPLACE 68 #define CG_CAPTURES 69 @@ -391,7 +391,7 @@ #define UI_PLAYERKICK_DESC 194 #define UI_VOTE_LISTENER 195 #define UI_VOTE_DESC 196 -#define UI_SOFT_KEYBOARD_ACCEPT 197 -#define UI_SOFT_KEYBOARD_DELETE 198 -#define UI_SOFT_KEYBOARD 199 +#define UI_SOFT_KEYBOARD_ACCEPT 197 +#define UI_SOFT_KEYBOARD_DELETE 198 +#define UI_SOFT_KEYBOARD 199 From 7412f623d1d2ace0c5e5ac360a65a9c496eb5dc8 Mon Sep 17 00:00:00 2001 From: razor Date: Mon, 19 Feb 2024 22:04:34 +1100 Subject: [PATCH 785/801] [Meta] deprecated WinXP builds, introduce macOS-14 runner for M1 builds (#1206) * deprecated WinXP builds, introduce macOS-14 runner for M1 builds * also allow running deprecated actions manually --- .github/workflows/build-deprecated.yml | 83 ++++++++++++++++++++++ .github/workflows/build.yml | 98 +++++--------------------- 2 files changed, 102 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/build-deprecated.yml diff --git a/.github/workflows/build-deprecated.yml b/.github/workflows/build-deprecated.yml new file mode 100644 index 0000000000..fa948eb378 --- /dev/null +++ b/.github/workflows/build-deprecated.yml @@ -0,0 +1,83 @@ +name: build + +# runs every 4 months +on: + workflow_dispatch: + schedule: + - cron: "0 0 1 */4 *" + +jobs: + msvcxp: + name: WinXP ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable }}) + runs-on: windows-2022 + strategy: + matrix: + arch: [x86, x86_64] + build_type: [Release] + 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 ${{ github.workspace }}/build + + - name: Configure CMake + shell: bash + working-directory: ${{ github.workspace }}/build + run: | + OPTIONS="-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=bin" + if [ "${{ matrix.portable }}" == "Portable" ]; then + OPTIONS+=" -DBuildPortableVersion=ON" + else + OPTIONS+=" -DBuildPortableVersion=OFF" + fi + OPTIONS+=" -DBuildJK2SPEngine=ON -DBuildJK2SPGame=ON -DBuildJK2SPRdVanilla=ON" + cmake $GITHUB_WORKSPACE -T v141_xp -A ${{ matrix.platform }} $OPTIONS + + - name: Build + working-directory: ${{ github.workspace }}/build + shell: bash + run: cmake --build . --config ${{ matrix.build_type }} -j $NUMBER_OF_PROCESSORS + + - name: Install + if: ${{ matrix.build_type == 'Release' }} + working-directory: ${{ github.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: ${{ github.workspace }}/build/bin/JediAcademy + if-no-files-found: error + + - uses: actions/upload-artifact@v3 + if: ${{ matrix.build_type == 'Release' }} + with: + name: OpenJO-windowsxp-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{ github.workspace }}/build/bin/JediOutcast + if-no-files-found: error diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4418953d8..bc10b1b995 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,81 +82,6 @@ jobs: path: ${{ github.workspace }}/build/bin/JediOutcast 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: [Release] - 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 ${{ github.workspace }}/build - - - name: Configure CMake - shell: bash - working-directory: ${{ github.workspace }}/build - run: | - OPTIONS="-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=bin" - if [ "${{ matrix.portable }}" == "Portable" ]; then - OPTIONS+=" -DBuildPortableVersion=ON" - else - OPTIONS+=" -DBuildPortableVersion=OFF" - fi - OPTIONS+=" -DBuildJK2SPEngine=ON -DBuildJK2SPGame=ON -DBuildJK2SPRdVanilla=ON" - cmake $GITHUB_WORKSPACE -T v141_xp -A ${{ matrix.platform }} $OPTIONS - - - name: Build - working-directory: ${{ github.workspace }}/build - shell: bash - run: cmake --build . --config ${{ matrix.build_type }} -j $NUMBER_OF_PROCESSORS - - - name: Install - if: ${{ matrix.build_type == 'Release' }} - working-directory: ${{ github.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: ${{ github.workspace }}/build/bin/JediAcademy - if-no-files-found: error - - - uses: actions/upload-artifact@v3 - if: ${{ matrix.build_type == 'Release' }} - with: - name: OpenJO-windowsxp-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} - path: ${{ github.workspace }}/build/bin/JediOutcast - if-no-files-found: error - ubuntu: name: Ubuntu ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable }}) runs-on: ubuntu-22.04 @@ -240,13 +165,18 @@ jobs: macos: name: macOS ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable}}) - runs-on: macos-12 + runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: - arch: [x86_64] + runner: [macos-12, macos-14] build_type: [Debug, Release] portable: [Non-Portable] + include: + - runner: macos-12 + arch: x86_64 + - runner: macos-14 + arch: arm64 steps: - uses: actions/checkout@v3 @@ -285,7 +215,7 @@ jobs: working-directory: ${{ github.workspace }}/install/JediAcademy shell: bash run: | - chmod +x openjk.x86_64.app/Contents/MacOS/openjk.x86_64 + chmod +x openjk.${{ matrix.arch }}.app/Contents/MacOS/openjk.${{ matrix.arch }} tar -czvf openjk-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz * - name: Create OpenJO binary archive @@ -293,7 +223,7 @@ jobs: working-directory: ${{ github.workspace }}/install/JediOutcast shell: bash run: | - chmod +x openjo_sp.x86_64.app/Contents/MacOS/openjo_sp.x86_64 + chmod +x openjo_sp.${{ matrix.arch }}.app/Contents/MacOS/openjo_sp.${{ matrix.arch }} tar -czvf openjo_sp-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz * - uses: actions/upload-artifact@v3 @@ -329,12 +259,14 @@ jobs: mv ./OpenJK-linux-x86-Release-Non-Portable/* OpenJK-linux-x86.tar.gz 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 + mv ./OpenJK-macos-arm64-Release-Non-Portable/* OpenJK-macos-arm64.tar.gz 7z a -r OpenJO-windows-x86.zip ./OpenJO-windows-x86-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' 7z a -r OpenJO-windows-x86_64.zip ./OpenJO-windows-x86_64-Release-Non-Portable/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' mv ./OpenJO-linux-x86-Release-Non-Portable/* OpenJO-linux-x86.tar.gz mv ./OpenJO-linux-x86_64-Release-Non-Portable/* OpenJO-linux-x86_64.tar.gz mv ./OpenJO-macos-x86_64-Release-Non-Portable/* OpenJO-macos-x86_64.tar.gz + mv ./OpenJO-macos-arm64-Release-Non-Portable/* OpenJO-macos-arm64.tar.gz - name: Create latest build uses: marvinpinto/action-automatic-releases@latest @@ -375,6 +307,10 @@ jobs: artifact_name: OpenJK-macos-x86_64.tar.gz zip: false + - artifact_dir: OpenJK-macos-arm64-Release-Non-Portable + artifact_name: OpenJK-macos-arm64.tar.gz + zip: false + - artifact_dir: OpenJO-windows-x86-Release-Non-Portable/JediOutcast artifact_name: OpenJO-windows-x86.zip zip: true @@ -395,6 +331,10 @@ jobs: artifact_name: OpenJO-macos-x86_64.tar.gz zip: false + - artifact_dir: OpenJO-macos-arm64-Release-Non-Portable + artifact_name: OpenJO-macos-arm64.tar.gz + zip: false + steps: - uses: actions/checkout@v3 with: From 6a8a88095604e2ed8013134fea17629eb1734ec5 Mon Sep 17 00:00:00 2001 From: razor Date: Mon, 19 Feb 2024 22:05:26 +1100 Subject: [PATCH 786/801] [Shared] misc loop overrun fixes (#1201) * misc loop overrun fixes * revert RT_BEAM changes the extra iteration is intentional to seal the tri strip * revert inadvertent whitespace changes --- code/game/wp_saberLoad.cpp | 2 +- codemp/cgame/cg_draw.c | 2 +- codemp/cgame/cg_newDraw.c | 2 +- codemp/game/NPC_stats.c | 2 +- codemp/game/bg_saberLoad.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/game/wp_saberLoad.cpp b/code/game/wp_saberLoad.cpp index 1b89f34b8f..298d1775eb 100644 --- a/code/game/wp_saberLoad.cpp +++ b/code/game/wp_saberLoad.cpp @@ -490,7 +490,7 @@ static void Saber_ParseSaberType( saberInfo_t *saber, const char **p ) { if ( COM_ParseString( p, &value ) ) return; saberType = GetIDForString( SaberTable, value ); - if ( saberType >= SABER_SINGLE && saberType <= NUM_SABERS ) + if ( saberType >= SABER_SINGLE && saberType < NUM_SABERS ) saber->type = (saberType_t)saberType; } static void Saber_ParseSaberModel( saberInfo_t *saber, const char **p ) { diff --git a/codemp/cgame/cg_draw.c b/codemp/cgame/cg_draw.c index 8b793c1593..bc6e4983a7 100644 --- a/codemp/cgame/cg_draw.c +++ b/codemp/cgame/cg_draw.c @@ -3978,7 +3978,7 @@ static float CG_DrawTeamOverlay( float y, qboolean right, qboolean upper ) { } else { xx = x + w - TINYCHAR_WIDTH; } - for (j = 0; j <= PW_NUM_POWERUPS; j++) { + for (j = 0; j < PW_NUM_POWERUPS; j++) { if (ci->powerups & (1 << j)) { item = BG_FindItemForPowerup( j ); diff --git a/codemp/cgame/cg_newDraw.c b/codemp/cgame/cg_newDraw.c index 6fb6e93848..ab2b384284 100644 --- a/codemp/cgame/cg_newDraw.c +++ b/codemp/cgame/cg_newDraw.c @@ -367,7 +367,7 @@ void CG_DrawNewTeamInfo(rectDef_t *rect, float text_x, float text_y, float scale if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) { xx = rect->x + 1; - for (j = 0; j <= PW_NUM_POWERUPS; j++) { + for (j = 0; j < PW_NUM_POWERUPS; j++) { if (ci->powerups & (1 << j)) { item = BG_FindItemForPowerup( j ); diff --git a/codemp/game/NPC_stats.c b/codemp/game/NPC_stats.c index 4920ad8a68..3293411e58 100644 --- a/codemp/game/NPC_stats.c +++ b/codemp/game/NPC_stats.c @@ -2554,7 +2554,7 @@ qboolean NPC_ParseParms( const char *NPCName, gentity_t *NPC ) } //FIXME: need to precache the weapon, too? (in above func) weap = GetIDForString( WPTable, value ); - if ( weap >= WP_NONE && weap <= WP_NUM_WEAPONS )///*WP_BLASTER_PISTOL*/WP_SABER ) //?! + if ( weap >= WP_NONE && weap < WP_NUM_WEAPONS )///*WP_BLASTER_PISTOL*/WP_SABER ) //?! { NPC->client->ps.weapon = weap; NPC->client->ps.stats[STAT_WEAPONS] |= ( 1 << NPC->client->ps.weapon ); diff --git a/codemp/game/bg_saberLoad.c b/codemp/game/bg_saberLoad.c index ae7460dc1c..a2d02cd2ab 100644 --- a/codemp/game/bg_saberLoad.c +++ b/codemp/game/bg_saberLoad.c @@ -532,7 +532,7 @@ static void Saber_ParseSaberType( saberInfo_t *saber, const char **p ) { if ( COM_ParseString( p, &value ) ) return; saberType = GetIDForString( saberTable, value ); - if ( saberType >= SABER_SINGLE && saberType <= NUM_SABERS ) + if ( saberType >= SABER_SINGLE && saberType < NUM_SABERS ) saber->type = (saberType_t)saberType; } static void Saber_ParseSaberModel( saberInfo_t *saber, const char **p ) { From 3a697c7f35b3147ef7e7485cbbbf024a30e67eb9 Mon Sep 17 00:00:00 2001 From: razor Date: Tue, 20 Feb 2024 13:11:20 +1100 Subject: [PATCH 787/801] [Meta] Update readme (#1171) * update readme * github-friendly emoji * normalise build links * missed a build link, clarified linux instructions * link to publicly viewable org, normalise paths * remove mention of OpenJKDF2 --- README.md | 130 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 069c314e9d..88e23d3c64 100644 --- a/README.md +++ b/README.md @@ -1,99 +1,105 @@ # OpenJK -OpenJK is an effort by the JACoders group to maintain and improve the game engines on which the Jedi Academy (JA) and Jedi Outcast (JO) games run on, while maintaining *full backwards compatibility* with the existing games. *This project does not attempt to rebalance or otherwise modify core gameplay*. +OpenJK is a community effort to maintain and improve the game and engine powering Jedi Academy and Jedi Outcast, while maintaining _full backwards compatibility_ with the existing games and mods. +This project does not intend to add major features, rebalance, or otherwise modify core gameplay. Our aims are to: -* Improve the stability of the engine by fixing bugs and improving performance. -* Provide a clean base from which new JO and JA code modifications can be made. -* Make available this engine to more operating systems. To date, we have ports on Linux and macOS. -Currently, the most stable portion of this project is the Jedi Academy multiplayer code, with the single player code in a reasonable state. +- Improve the stability of the engine by fixing bugs and improving performance. +- Support more hardware (x86_64, Arm, Apple Silicon) and software platforms (Linux, macOS) +- Provide a clean base from which new code modifications can be made. -Rough support for Jedi Outcast single player is also available, however this should be considered heavily work in progress. This is not currently actively worked on or tested. OpenJK does not have Jedi Outcast multiplayer support. +[![discord](https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&longCache=true&style=flat)](https://discord.gg/dPNCfeQ) +[![forum](https://img.shields.io/badge/forum-JKHub.org%20OpenJK-brightgreen.svg)](https://jkhub.org/forums/forum/49-openjk/) -Please use discretion when making issue requests on GitHub. The [JKHub sub-forum](https://jkhub.org/forums/forum/49-openjk/) is a better place for support queries, discussions, and feature requests. +[![build](https://github.com/JACoders/OpenJK/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/JACoders/OpenJK/actions/workflows/build.yml?query=branch%3Amaster) +[![coverity](https://scan.coverity.com/projects/1153/badge.svg)](https://scan.coverity.com/projects/1153) - -[![Forum](https://img.shields.io/badge/forum-JKHub.org%20OpenJK-brightgreen.svg)](https://jkhub.org/forums/forum/49-openjk/) +## Supported Games -[![Coverity Scan Build Status](https://scan.coverity.com/projects/1153/badge.svg)](https://scan.coverity.com/projects/1153) +| Game | Single Player | Multi Player | +| - | - | - | +| Jedi Academy | ✅ Stable | ✅ Stable | +| Jedi Outcast | 😧 Works, needs attention | 🙅 Not supported - consider [JK2MV](https://jk2mv.org) | -## License +Please direct support queries, discussions and feature requests to the JKHub sub-forum or Discord linked above. -OpenJK is licensed under GPLv2 as free software. You are free to use, modify and redistribute OpenJK following the terms in LICENSE.txt. +## License +OpenJK is licensed under GPLv2 as free software. You are free to use, modify and redistribute OpenJK following the terms in [LICENSE.txt](https://github.com/JACoders/OpenJK/blob/master/LICENSE.txt) ## For players -To install OpenJK, you will first need Jedi Academy installed. If you don't already own the game you can buy it from online stores such as [Steam](http://store.steampowered.com/app/6020/), [Amazon](http://www.amazon.com/Star-Wars-Jedi-Knight-Academy-Pc/dp/B0000A2MCN) or [GOG](https://www.gog.com/game/star_wars_jedi_knight_jedi_academy). +To install OpenJK, you will first need Jedi Academy installed. If you don't already own the game you can buy it from online stores such as [Steam](https://store.steampowered.com/app/6020/), [Amazon](https://www.amazon.com/Star-Wars-Jedi-Knight-Academy-Pc/dp/B0000A2MCN) or [GOG](https://www.gog.com/game/star_wars_jedi_knight_jedi_academy). -Installing and running OpenJK: +Download the [latest build](https://github.com/JACoders/OpenJK/releases/tag/latest) ([alt link](https://builds.openjk.org)) for your operating system. -1. [Download the latest build](http://builds.openjk.org) for your operating system. -2. Extract the contents of the file into the Jedi Academy `GameData/` folder. For Steam users, this will be in `/steamapps/common/Jedi Academy/GameData`. -3. Run `openjk.x86.exe` (Windows), `openjk.i386` (Linux 32-bit), `openjk.x86_64` (Linux 64-bit) or the `OpenJK` app bundle (macOS), depending on your operating system. +Installing and running OpenJK: +1. Extract the contents of the file into the Jedi Academy `GameData/` folder. For Steam users, this will be in `/steamapps/common/Jedi Academy/GameData/`. +1. Run `openjk.x86.exe` (Windows), `openjk.i386` (Linux 32-bit), `openjk.x86_64` (Linux 64-bit) or the `OpenJK` app bundle (macOS), depending on your operating system. -**Linux Instructions** +### Linux Instructions -If you do not have a windows partition and need to download the game base. +If you do not have an existing JKA installation and need to download the base game: -1. Download and Install SteamCMD [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD#Linux) . -2. Set the download path using steamCMD, force_install_dir . -3. Using SteamCMD Set the platform to windows to download any windows game on steam. @sSteamCmdForcePlatformType "windows" -4. Using SteamCMD download the game, app_update 6020. -5. [Download the latest build](http://builds.openjk.org) for your operating system. -6. Extract the contents of the file into the Jedi Academy `GameData/` folder. For Steam users, this will be in `/steamapps/common/Jedi Academy/GameData`. +1. Download and Install SteamCMD [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD#Linux). +1. Set the download path using steamCMD: `force_install_dir /path/to/install/jka/` +1. Using SteamCMD Set the platform to windows to download any windows game on steam. @sSteamCmdForcePlatformType "windows" +1. Using SteamCMD download the game, `app_update 6020`. +Extract the contents of the file into the Jedi Academy `GameData/` folder. For Steam users, this will be in `/steamapps/common/Jedi Academy/GameData/`. -**macOS Instructions** +### macOS Instructions If you have the Mac App Store Version of Jedi Academy, follow these steps to get OpenJK runnning under macOS: -1. Install [Homebrew](http://brew.sh/) if you don't have it. -2. Open the Terminal app, and enter the command `brew install sdl2`. -3. Extract the contents of the OpenJK DMG ([Download the latest build](http://builds.openjk.org)) into the game directory `/Applications/Star Wars Jedi Knight: Jedi Academy.app/Contents/` -4. Run `OpenJK.app` or `OpenJK SP.app` -5. Savegames, Config Files and Log Files are stored in `/Users//Library/Application Support/OpenJK/` - +1. Install [Homebrew](https://brew.sh/) if you don't have it. +1. Open the Terminal app, and enter the command `brew install sdl2`. +1. Extract the contents of the OpenJK DMG into the game directory `/Applications/Star Wars Jedi Knight: Jedi Academy.app/Contents/` +1. Run `OpenJK.app` or `OpenJK SP.app` +1. Savegames, Config Files and Log Files are stored in `/Users/$USER/Library/Application Support/OpenJK/` ## For Developers - ### Building OpenJK -* [Compilation guide](https://github.com/JACoders/OpenJK/wiki/Compilation-guide) -* [Debugging guide](https://github.com/JACoders/OpenJK/wiki/Debugging) - +- [Compilation guide](https://github.com/JACoders/OpenJK/wiki/Compilation-guide) +- [Debugging guide](https://github.com/JACoders/OpenJK/wiki/Debugging) ### Contributing to OpenJK -* [Fork](https://github.com/JACoders/OpenJK/fork) the project on GitHub -* Create a new branch and make your changes -* Send a [pull request](https://help.github.com/articles/creating-a-pull-request) to upstream (JACoders/OpenJK) - +- [Fork](https://github.com/JACoders/OpenJK/fork) the project on GitHub +- Create a new branch and make your changes +- Send a [pull request](https://help.github.com/articles/creating-a-pull-request) to upstream (JACoders/OpenJK) ### Using OpenJK as a base for a new mod -* [Fork](https://github.com/JACoders/OpenJK/fork) the project on GitHub -* Change the GAMEVERSION define in codemp/game/g_local.h from "OpenJK" to your project name -* If you make a nice change, please consider back-porting to upstream via pull request as described above. This is so everyone benefits without having to reinvent the wheel for every project. - - -## Maintainers (in alphabetical order) - -* Ensiform -* Razish -* Xycaleth - - -## Significant contributors (in alphabetical order) - -* eezstreet -* exidl -* ImperatorPrime -* mrwonko -* redsaurus -* Scooper -* Sil -* smcv +- [Fork](https://github.com/JACoders/OpenJK/fork) the project on GitHub +- Change the `GAMEVERSION` define in [codemp/game/g_local.h](https://github.com/JACoders/OpenJK/blob/master/codemp/game/g_local.h) from "OpenJK" to your project name +- If you make a nice change, please consider back-porting to upstream via pull request as described above. This is so everyone benefits without having to reinvent the wheel for every project. + +## Maintainers (full list: [@JACoders](https://github.com/orgs/JACoders/people)) + +Leads: + +- [Ensiform](https://github.com/ensiform) +- [razor](https://github.com/Razish) +- [Xycaleth](https://github.com/xycaleth) + +## Significant contributors ([full list](https://github.com/JACoders/OpenJK/graphs/contributors)) + +- [bibendovsky](https://github.com/bibendovsky) (save games, platform support) +- [BobaFett](https://github.com/Lrns123) +- [BSzili](https://github.com/BSzili) (JK2, platform support) +- [Cat](https://github.com/deepy) (infra) +- [Didz](https://github.com/dionrhys) +- [eezstreet](https://github.com/eezstreet) +- exidl (SDL2, platform support) +- [ImperatorPrime](https://github.com/ImperatorPrime) (JK2) +- [mrwonko](https://github.com/mrwonko) +- [redsaurus](https://github.com/redsaurus) +- [Scooper](https://github.com/xScooper) +- [Sil](https://github.com/TheSil) +- [smcv](https://github.com/smcv) (debian packaging) +- [Tristamus](https://tristamus.com>) (icon) From 142e0b71cca84f53ddbe1eb74fb088db51ad8756 Mon Sep 17 00:00:00 2001 From: razor Date: Tue, 20 Feb 2024 19:24:16 +1100 Subject: [PATCH 788/801] [MP] reconcile game module changes with the original source releases by diffing codemp/game (#1178) * reconcile game module changes with the SDK release by diffing codemp/game * revert saberMoveData changes to match basejka, provide a new cvar (g_fixSaberMoveData) to patch it if desired * introduce a new configstring (26: CS_LEGACY_FIXES) to inform the client of which fixes it should also apply, e.g. saberMoveData * client module obtains gamestate (including configstrings) earlier to prevent use before initialisation, which is now checked for in debug builds * revert a change to saber disarm bonus calculation if g_fixSaberDisarmBonus is not enabled * G_CanBeEnemy considers private duels once again (removed from modbase before its git history) * add disclaimer to legacyFixes_e * revert: client module obtains gamestate (including configstrings) earlier to prevent use before initialisation this was causing issues loading incorrect clientinfo --- codemp/cgame/cg_draw.c | 2 +- codemp/cgame/cg_main.c | 5 + codemp/cgame/cg_servercmds.c | 5 + codemp/game/NPC_AI_MineMonster.c | 2 +- codemp/game/NPC_combat.c | 4 +- codemp/game/bg_g2_utils.c | 20 --- codemp/game/bg_misc.c | 3 +- codemp/game/bg_public.h | 20 ++- codemp/game/bg_saber.c | 57 ++++-- codemp/game/g_bot.c | 3 + codemp/game/g_cmds.c | 6 + codemp/game/g_cvar.c | 21 ++- codemp/game/g_main.c | 5 + codemp/game/g_xcvar.h | 287 ++++++++++++++++--------------- codemp/game/w_saber.c | 16 +- 15 files changed, 266 insertions(+), 190 deletions(-) diff --git a/codemp/cgame/cg_draw.c b/codemp/cgame/cg_draw.c index bc6e4983a7..5be400800e 100644 --- a/codemp/cgame/cg_draw.c +++ b/codemp/cgame/cg_draw.c @@ -3064,7 +3064,7 @@ static float CG_DrawEnemyInfo ( float y ) clientNum = cgs.duelWinner; } - if ( clientNum >= MAX_CLIENTS || !(&cgs.clientinfo[ clientNum ]) ) + if ( clientNum < 0 || clientNum >= MAX_CLIENTS || !cgs.clientinfo[clientNum].infoValid ) { return y; } diff --git a/codemp/cgame/cg_main.c b/codemp/cgame/cg_main.c index b9c926d787..b7fcdcb01f 100644 --- a/codemp/cgame/cg_main.c +++ b/codemp/cgame/cg_main.c @@ -1623,6 +1623,9 @@ CG_ConfigString ================= */ const char *CG_ConfigString( int index ) { + // FIXME: don't read configstrings before initialisation + // assert( cgs.gameState.dataCount != 0 ); + if ( index < 0 || index >= MAX_CONFIGSTRINGS ) { trap->Error( ERR_DROP, "CG_ConfigString: bad index: %i", index ); } @@ -2626,6 +2629,8 @@ Ghoul2 Insert End cg.distanceCull = trap->R_GetDistanceCull(); CG_ParseEntitiesFromString(); + + BG_FixSaberMoveData(); } //makes sure returned string is in localized format diff --git a/codemp/cgame/cg_servercmds.c b/codemp/cgame/cg_servercmds.c index 82f4e20254..c10ffbaadf 100644 --- a/codemp/cgame/cg_servercmds.c +++ b/codemp/cgame/cg_servercmds.c @@ -27,6 +27,7 @@ along with this program; if not, see . // be a valid snapshot this frame #include "cg_local.h" +#include "game/bg_public.h" #include "ui/menudef.h" #include "ghoul2/G2.h" #include "ui/ui_public.h" @@ -909,6 +910,10 @@ static void CG_ConfigStringModified( void ) { else if ( num == CS_SHADERSTATE ) { CG_ShaderStateChanged(); } + else if ( num == CS_LEGACY_FIXES ) { + // LEGACYFIX_SABERMOVEDATA may have changed + BG_FixSaberMoveData(); + } else if ( num >= CS_LIGHT_STYLES && num < CS_LIGHT_STYLES + (MAX_LIGHT_STYLES * 3)) { CG_SetLightstyle(num - CS_LIGHT_STYLES); diff --git a/codemp/game/NPC_AI_MineMonster.c b/codemp/game/NPC_AI_MineMonster.c index 3c801728d1..5342a640ed 100644 --- a/codemp/game/NPC_AI_MineMonster.c +++ b/codemp/game/NPC_AI_MineMonster.c @@ -90,7 +90,7 @@ void MineMonster_Patrol( void ) } //rwwFIXMEFIXME: Care about all clients, not just client 0 - //OJKFIXME: clietnum 0 + //OJKFIXME: clientnum 0 VectorSubtract( g_entities[0].r.currentOrigin, NPCS.NPC->r.currentOrigin, dif ); if ( VectorLengthSquared( dif ) < 256 * 256 ) diff --git a/codemp/game/NPC_combat.c b/codemp/game/NPC_combat.c index 8b62e87dc4..67d169d1a1 100644 --- a/codemp/game/NPC_combat.c +++ b/codemp/game/NPC_combat.c @@ -1494,7 +1494,7 @@ gentity_t *NPC_PickEnemy( gentity_t *closestTo, int enemyTeam, qboolean checkVis minVis = VIS_360; } - //OJKFIXME: care about clients other than 0 + //OJKFIXME: clientnum 0 //OJKFIXME: choice[] is not size checked? if( findPlayersFirst ) {//try to find a player first @@ -2178,7 +2178,7 @@ qboolean NPC_EvaluateShot( int hit, qboolean glassOK ) return qfalse; } - if ( hit == NPCS.NPC->enemy->s.number || (&g_entities[hit] != NULL && (g_entities[hit].r.svFlags&SVF_GLASS_BRUSH)) ) + if ( hit == NPCS.NPC->enemy->s.number || (g_entities[hit].inuse && (g_entities[hit].r.svFlags&SVF_GLASS_BRUSH)) ) {//can hit enemy or will hit glass, so shoot anyway return qtrue; } diff --git a/codemp/game/bg_g2_utils.c b/codemp/game/bg_g2_utils.c index f8e6739a95..e4ba4dda19 100644 --- a/codemp/game/bg_g2_utils.c +++ b/codemp/game/bg_g2_utils.c @@ -42,26 +42,14 @@ void BG_AttachToRancor( void *ghoul2, float rancYaw, vec3_t rancOrigin, int time // Getting the bolt here if ( inMouth ) {//in mouth - #if defined(_GAME) boltIndex = trap->G2API_AddBolt(ghoul2, 0, "jaw_bone"); - #elif defined(_CGAME) - boltIndex = trap->G2API_AddBolt(ghoul2, 0, "jaw_bone"); - #endif } else {//in right hand - #if defined(_GAME) - boltIndex = trap->G2API_AddBolt(ghoul2, 0, "*r_hand"); - #elif defined(_CGAME) boltIndex = trap->G2API_AddBolt(ghoul2, 0, "*r_hand"); - #endif } VectorSet( rancAngles, 0, rancYaw, 0 ); -#if defined(_GAME) trap->G2API_GetBoltMatrix( ghoul2, 0, boltIndex, &boltMatrix, rancAngles, rancOrigin, time, modelList, modelScale ); -#elif defined(_CGAME) - trap->G2API_GetBoltMatrix( ghoul2, 0, boltIndex, &boltMatrix, rancAngles, rancOrigin, time, modelList, modelScale ); -#endif // Storing ent position, bolt position, and bolt axis if ( out_origin ) { @@ -112,11 +100,7 @@ void BG_AttachToRancor( void *ghoul2, float rancYaw, vec3_t rancOrigin, int time #define MAX_VARIANTS 8 qboolean BG_GetRootSurfNameWithVariant( void *ghoul2, const char *rootSurfName, char *returnSurfName, int returnSize ) { -#if defined(_GAME) - if ( !ghoul2 || !trap->G2API_GetSurfaceRenderStatus( ghoul2, 0, rootSurfName ) ) -#elif defined(_CGAME) if ( !ghoul2 || !trap->G2API_GetSurfaceRenderStatus( ghoul2, 0, rootSurfName ) ) -#endif {//see if the basic name without variants is on Q_strncpyz( returnSurfName, rootSurfName, returnSize ); return qtrue; @@ -127,11 +111,7 @@ qboolean BG_GetRootSurfNameWithVariant( void *ghoul2, const char *rootSurfName, for ( i = 0; i < MAX_VARIANTS; i++ ) { Com_sprintf( returnSurfName, returnSize, "%s%c", rootSurfName, 'a'+i ); - #if defined(_GAME) - if ( !trap->G2API_GetSurfaceRenderStatus( ghoul2, 0, returnSurfName ) ) - #elif defined(_CGAME) if ( !trap->G2API_GetSurfaceRenderStatus( ghoul2, 0, returnSurfName ) ) - #endif { return qtrue; } diff --git a/codemp/game/bg_misc.c b/codemp/game/bg_misc.c index b7fc7ba955..fb6181812f 100644 --- a/codemp/game/bg_misc.c +++ b/codemp/game/bg_misc.c @@ -2056,8 +2056,7 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play {//force powers and saber only if ( item->giType != IT_TEAM //not a flag && item->giType != IT_ARMOR//not shields - && (item->giType != IT_WEAPON - || item->giTag != WP_SABER)//not a saber + && (item->giType != IT_WEAPON || item->giTag != WP_SABER)//not a saber && (item->giType != IT_HOLDABLE || item->giTag != HI_SEEKER)//not a seeker && (item->giType != IT_POWERUP || item->giTag == PW_YSALAMIRI) )//not a force pick-up { diff --git a/codemp/game/bg_public.h b/codemp/game/bg_public.h index e3da414b2f..4cb83fe577 100644 --- a/codemp/game/bg_public.h +++ b/codemp/game/bg_public.h @@ -111,7 +111,7 @@ along with this program; if not, see . #define CS_FLAGSTATUS 23 // string indicating flag status in CTF #define CS_SHADERSTATE 24 #define CS_BOTINFO 25 - +#define CS_LEGACY_FIXES 26 #define CS_ITEMS 27 // string of 0's and 1's that tell which items are present #define CS_CLIENT_JEDIMASTER 28 // current jedi master @@ -156,6 +156,22 @@ Ghoul2 Insert End #error overflow: (CS_MAX) > MAX_CONFIGSTRINGS #endif +typedef enum legacyFixes_e { + LEGACYFIX_SABERMOVEDATA = 0, + /* + m m ""# " m m + # # mmm m m # mmm mmm mm#mm mmm m mm # + #mmmm# #" # "m m" # # # " # #" # #" # # + # # #"""" #m# # # """m # #"""" # # " + # # "#mm" "# # "mm mm#mm "mmm" "mm "#mm" # # # + m" " + "" + Forks of OpenJK should NOT add to or modify the legacy fixes values + Removal, replacement or adding of new flags might lead to incompatibilities + Forks should define their own configstring or serverinfo cvar instead of modifying this + */ +} legacyFixes_t; + typedef enum { G2_MODELPART_HEAD = 10, G2_MODELPART_WAIST, @@ -1717,6 +1733,8 @@ qboolean BG_InDeathAnim( int anim ); qboolean BG_InSaberLockOld( int anim ); qboolean BG_InSaberLock( int anim ); +void BG_FixSaberMoveData( void ); + void BG_SaberStartTransAnim( int clientNum, int saberAnimLevel, int weapon, int anim, float *animSpeed, int broken ); void BG_ForcePowerDrain( playerState_t *ps, forcePowers_t forcePower, int overrideAmt ); diff --git a/codemp/game/bg_saber.c b/codemp/game/bg_saber.c index e59413515b..7abb1642fd 100644 --- a/codemp/game/bg_saber.c +++ b/codemp/game/bg_saber.c @@ -26,6 +26,12 @@ along with this program; if not, see . #include "bg_local.h" #include "w_saber.h" +#if defined(_GAME) + #include "g_local.h" // for cvars +#elif defined(_CGAME) + #include "cgame/cg_local.h" // for configstrings +#endif + extern qboolean BG_SabersOff( playerState_t *ps ); saberInfo_t *BG_MySaber( int clientNum, int saberNum ); @@ -316,30 +322,23 @@ saberMoveData_t saberMoveData[LS_MOVE_MAX] = {// NB:randomized {"BParry Top", BOTH_H1_S1_T_, Q_T, Q_B, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_UP, {"BParry UR", BOTH_H1_S1_TR, Q_TR, Q_BL, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_UR, {"BParry UL", BOTH_H1_S1_TL, Q_TL, Q_BR, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_UL, - {"BParry LR", BOTH_H1_S1_BR, Q_BL, Q_TR, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LR, + {"BParry LR", BOTH_H1_S1_BL, Q_BL, Q_TR, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LR, {"BParry Bot", BOTH_H1_S1_B_, Q_B, Q_T, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LR - {"BParry LL", BOTH_H1_S1_BL, Q_BR, Q_TL, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LL - //{"BParry LR", BOTH_H1_S1_BL, Q_BL, Q_TR, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LR, - //{"BParry Bot", BOTH_H1_S1_B_, Q_B, Q_T, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LL - //{"BParry LL", BOTH_H1_S1_BR, Q_BR, Q_TL, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LL + {"BParry LL", BOTH_H1_S1_BR, Q_BR, Q_TL, AFLAG_ACTIVE, 50, BLK_NO, LS_READY, LS_READY, 150 }, // LS_PARRY_LL // Knockaways {"Knock Top", BOTH_K1_S1_T_, Q_R, Q_T, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_T1_T__BR, 150 }, // LS_PARRY_UP, {"Knock UR", BOTH_K1_S1_TR, Q_R, Q_TR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_T1_TR__R, 150 }, // LS_PARRY_UR, {"Knock UL", BOTH_K1_S1_TL, Q_R, Q_TL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BR2TL, LS_T1_TL__L, 150 }, // LS_PARRY_UL, - {"Knock LR", BOTH_K1_S1_BR, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_T1_BL_TL, 150 }, // LS_PARRY_LR, - {"Knock LL", BOTH_K1_S1_BL, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_T1_BR_TR, 150 }, // LS_PARRY_LL - //{"Knock LR", BOTH_K1_S1_BL, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_T1_BL_TL, 150 }, // LS_PARRY_LR, - //{"Knock LL", BOTH_K1_S1_BR, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_T1_BR_TR, 150 }, // LS_PARRY_LL + {"Knock LR", BOTH_K1_S1_BL, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_T1_BL_TL, 150 }, // LS_PARRY_LR, + {"Knock LL", BOTH_K1_S1_BR, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_T1_BR_TR, 150 }, // LS_PARRY_LL // Parry {"Parry Top", BOTH_P1_S1_T_, Q_R, Q_T, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_A_T2B, 150 }, // LS_PARRY_UP, {"Parry UR", BOTH_P1_S1_TR, Q_R, Q_TL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_A_TR2BL, 150 }, // LS_PARRY_UR, {"Parry UL", BOTH_P1_S1_TL, Q_R, Q_TR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BR2TL, LS_A_TL2BR, 150 }, // LS_PARRY_UL, - {"Parry LR", BOTH_P1_S1_BR, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_A_BR2TL, 150 }, // LS_PARRY_LR, - {"Parry LL", BOTH_P1_S1_BL, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_A_BL2TR, 150 }, // LS_PARRY_LL - //{"Parry LR", BOTH_P1_S1_BL, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_A_BR2TL, 150 }, // LS_PARRY_LR, - //{"Parry LL", BOTH_P1_S1_BR, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_A_BL2TR, 150 }, // LS_PARRY_LL + {"Parry LR", BOTH_P1_S1_BL, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_A_BR2TL, 150 }, // LS_PARRY_LR, + {"Parry LL", BOTH_P1_S1_BR, Q_R, Q_BL, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TR2BL, LS_A_BL2TR, 150 }, // LS_PARRY_LL // Reflecting a missile {"Reflect Top", BOTH_P1_S1_T_, Q_R, Q_T, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_BL2TR, LS_A_T2B, 300 }, // LS_PARRY_UP, @@ -349,6 +348,38 @@ saberMoveData_t saberMoveData[LS_MOVE_MAX] = {// NB:randomized {"Reflect LL", BOTH_P1_S1_BL, Q_R, Q_BR, AFLAG_ACTIVE, 50, BLK_WIDE, LS_R_TL2BR, LS_A_BR2TL, 300 }, // LS_PARRY_LL, }; +void BG_FixSaberMoveData(void) { +#if defined(_GAME) + const qboolean doFix = !!g_fixSaberMoveData.integer; +#elif defined(_CGAME) + const char *cs = CG_ConfigString(CS_LEGACY_FIXES); + const uint32_t legacyFixes = strtoul(cs, NULL, 0); + const qboolean doFix = !!(legacyFixes & (1 << LEGACYFIX_SABERMOVEDATA)); +#endif + saberMoveData_t *move; + + for (move = saberMoveData; move - saberMoveData < ARRAY_LEN(saberMoveData); move++) { + if (!strcmp(move->name, "BParry LR")) { + move->animToUse = doFix ? BOTH_H1_S1_BR : BOTH_H1_S1_BL; + } + else if (!strcmp(move->name, "BParry LL")) { + move->animToUse = doFix ? BOTH_H1_S1_BL : BOTH_H1_S1_BR; + } + else if (!strcmp(move->name, "Knock LR")) { + move->animToUse = doFix ? BOTH_K1_S1_BR : BOTH_K1_S1_BL; + } + else if (!strcmp(move->name, "Knock LL")) { + move->animToUse = doFix ? BOTH_K1_S1_BL : BOTH_K1_S1_BR; + } + else if (!strcmp(move->name, "Parry LR")) { + move->animToUse = doFix ? BOTH_P1_S1_BR : BOTH_P1_S1_BL; + } + else if (!strcmp(move->name, "Parry LL")) { + move->animToUse = doFix ? BOTH_P1_S1_BL : BOTH_P1_S1_BR; + } + } +} + int transitionMove[Q_NUM_QUADS][Q_NUM_QUADS] = { { LS_NONE, LS_T1_BR__R, LS_T1_BR_TR, LS_T1_BR_T_, LS_T1_BR_TL, LS_T1_BR__L, LS_T1_BR_BL, LS_NONE }, diff --git a/codemp/game/g_bot.c b/codemp/game/g_bot.c index 474370b3cb..8d065d141d 100644 --- a/codemp/game/g_bot.c +++ b/codemp/game/g_bot.c @@ -139,6 +139,9 @@ int G_GetMapTypeBits(char *type) typeBits |= (1 << GT_TEAM); typeBits |= (1 << GT_JEDIMASTER); } + if( strstr( type, "team" ) ) { + typeBits |= (1 << GT_TEAM); + } if( strstr( type, "holocron" ) ) { typeBits |= (1 << GT_HOLOCRON); } diff --git a/codemp/game/g_cmds.c b/codemp/game/g_cmds.c index e5c7e24d29..8227f5ee3f 100644 --- a/codemp/game/g_cmds.c +++ b/codemp/game/g_cmds.c @@ -2358,6 +2358,12 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) { char arg1[MAX_CVAR_VALUE_STRING] = {0}; char arg2[MAX_CVAR_VALUE_STRING] = {0}; + if ( g_gametype.integer < GT_TEAM ) + { + trap->SendServerCommand( ent-g_entities, "print \"Cannot call a team vote in a non-team gametype!\n\"" ); + return; + } + if ( team == TEAM_RED ) cs_offset = 0; else if ( team == TEAM_BLUE ) diff --git a/codemp/game/g_cvar.c b/codemp/game/g_cvar.c index ea8f8d0468..c0839be5e7 100644 --- a/codemp/game/g_cvar.c +++ b/codemp/game/g_cvar.c @@ -21,18 +21,29 @@ along with this program; if not, see . =========================================================================== */ +#include + #include "g_local.h" +#include "game/bg_public.h" // // Cvar callbacks // -/* -static void CVU_Derpity( void ) { - // ... -} -*/ +static void CVU_FixSaberMoveData(void) { + BG_FixSaberMoveData(); + char sLegacyFixes[32]; + trap->GetConfigstring(CS_LEGACY_FIXES, sLegacyFixes, sizeof(sLegacyFixes)); + + uint32_t legacyFixes = strtoul(sLegacyFixes, NULL, 0); + if (g_fixSaberMoveData.integer) { + legacyFixes |= (1 << LEGACYFIX_SABERMOVEDATA); + } else { + legacyFixes &= ~(1 << LEGACYFIX_SABERMOVEDATA); + } + trap->SetConfigstring(CS_LEGACY_FIXES, va("%" PRIu32, legacyFixes)); +} // // Cvar table diff --git a/codemp/game/g_main.c b/codemp/game/g_main.c index 31715742ad..a8d33959e1 100644 --- a/codemp/game/g_main.c +++ b/codemp/game/g_main.c @@ -28,6 +28,7 @@ along with this program; if not, see . #include "g_nav.h" #include "bg_saga.h" #include "b_local.h" +#include "game/bg_public.h" #include "qcommon/q_version.h" NORETURN_PTR void (*Com_Error)( int level, const char *error, ... ); @@ -202,6 +203,10 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) { trap->Print ("gamename: %s\n", GAMEVERSION); trap->Print ("gamedate: %s\n", SOURCE_DATE); + // init as zero, to be updated by the following cvar registration + // relevant cvars call their update func to modify CS_LEGACY_FIXES when necessary + trap->SetConfigstring(CS_LEGACY_FIXES, "0"); + G_RegisterCvars(); G_ProcessIPBans(); diff --git a/codemp/game/g_xcvar.h b/codemp/game/g_xcvar.h index dca8c3ccd8..b21a6c430c 100644 --- a/codemp/game/g_xcvar.h +++ b/codemp/game/g_xcvar.h @@ -23,159 +23,160 @@ along with this program; if not, see . #include "qcommon/q_version.h" -#ifdef XCVAR_PROTO +#if defined(XCVAR_PROTO) #define XCVAR_DEF( name, defVal, update, flags, announce ) extern vmCvar_t name; -#endif - -#ifdef XCVAR_DECL +#elif defined(XCVAR_DECL) #define XCVAR_DEF( name, defVal, update, flags, announce ) vmCvar_t name; -#endif - -#ifdef XCVAR_LIST +#elif defined(XCVAR_LIST) #define XCVAR_DEF( name, defVal, update, flags, announce ) { & name , #name , defVal , update , flags , announce }, +#else + #warning "missing XCVAR expansion def" + #define XCVAR_DEF( ... ) #endif -XCVAR_DEF( bg_fighterAltControl, "0", NULL, CVAR_SYSTEMINFO, qtrue ) -XCVAR_DEF( capturelimit, "8", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( com_optvehtrace, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( d_altRoutes, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_asynchronousGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_break, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_JediAI, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_noGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_noroam, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_npcai, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_npcaiming, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_npcfreeze, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_noIntermissionWait, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( d_patched, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_perPlayerGhoul2, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_powerDuelPrint, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( d_projectileGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberAlwaysBoxTrace, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberBoxTraceSize, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberCombat, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_saberGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberInterpolate, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberKickTweak, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( d_saberSPStyleDamage, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( d_saberStanceDebug, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( d_siegeSeekerNPC, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( dedicated, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( developer, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( dmflags, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( duel_fraglimit, "10", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( fraglimit, "20", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( g_adaptRespawn, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_allowDuelSuicide, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_allowHighPingDuelist, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_allowNPC, "1", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( g_allowTeamVote, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_allowVote, "-1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_antiFakePlayer, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_armBreakage, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_austrian, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_autoMapCycle, "0", NULL, CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( g_banIPs, "", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_charRestrictRGB, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_duelWeaponDisable, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) -XCVAR_DEF( g_debugAlloc, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_debugDamage, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_debugMelee, "0", NULL, CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( g_debugMove, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_debugSaberLocks, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( g_debugServerSkel, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( bg_fighterAltControl, "0", NULL, CVAR_SYSTEMINFO, qtrue ) +XCVAR_DEF( capturelimit, "8", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( com_optvehtrace, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( d_altRoutes, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_asynchronousGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_break, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_JediAI, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_noGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_noroam, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_npcai, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_npcaiming, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_npcfreeze, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_noIntermissionWait, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( d_patched, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_perPlayerGhoul2, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_powerDuelPrint, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( d_projectileGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberAlwaysBoxTrace, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberBoxTraceSize, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberCombat, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_saberGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberInterpolate, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberKickTweak, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( d_saberSPStyleDamage, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( d_saberStanceDebug, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( d_siegeSeekerNPC, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( dedicated, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( developer, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( dmflags, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( duel_fraglimit, "10", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( fraglimit, "20", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_adaptRespawn, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_allowDuelSuicide, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_allowHighPingDuelist, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_allowNPC, "1", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( g_allowTeamVote, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_allowVote, "-1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_antiFakePlayer, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_armBreakage, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_austrian, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_autoMapCycle, "0", NULL, CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_banIPs, "", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_charRestrictRGB, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_duelWeaponDisable, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) +XCVAR_DEF( g_debugAlloc, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_debugDamage, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_debugMelee, "0", NULL, CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( g_debugMove, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_debugSaberLocks, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_debugServerSkel, "0", NULL, CVAR_CHEAT, qfalse ) #ifdef _DEBUG -XCVAR_DEF( g_disableServerG2, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_disableServerG2, "0", NULL, CVAR_NONE, qtrue ) #endif -XCVAR_DEF( g_dismember, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_doWarmup, "0", NULL, CVAR_NONE, qtrue ) -//XCVAR_DEF( g_engineModifications, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_ff_objectives, "0", NULL, CVAR_CHEAT|CVAR_NORESTART, qtrue ) -XCVAR_DEF( g_filterBan, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_forceBasedTeams, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) -XCVAR_DEF( g_forceClientUpdateRate, "250", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_forceDodge, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_forcePowerDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) -XCVAR_DEF( g_forceRegenTime, "200", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_forceRespawn, "60", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_fraglimitVoteCorrection, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_friendlyFire, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_friendlySaber, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_g2TraceLod, "3", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_gametype, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH, qfalse ) -XCVAR_DEF( g_gravity, "800", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_inactivity, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_jediVmerc, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_knockback, "1000", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_locationBasedDamage, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_log, "games.log", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_logClientInfo, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_logSync, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_maxConnPerIP, "3", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_maxForceRank, "7", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) -XCVAR_DEF( g_maxGameClients, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_maxHolocronCarry, "3", NULL, CVAR_LATCH, qfalse ) -XCVAR_DEF( g_motd, "", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_needpass, "0", NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) -XCVAR_DEF( g_noSpecMove, "0", NULL, CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( g_npcspskill, "0", NULL, CVAR_ARCHIVE|CVAR_INTERNAL, qfalse ) -XCVAR_DEF( g_password, "", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_powerDuelEndHealth, "90", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_powerDuelStartHealth, "150", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_privateDuel, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_randFix, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_restarted, "0", NULL, CVAR_ROM, qfalse ) -XCVAR_DEF( g_saberBladeFaces, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_saberDamageScale, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_dismember, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_doWarmup, "0", NULL, CVAR_NONE, qtrue ) +//XCVAR_DEF( g_engineModifications, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_ff_objectives, "0", NULL, CVAR_CHEAT|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_filterBan, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_fixSaberDisarmBonus, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_fixSaberMoveData, "1", CVU_FixSaberMoveData, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_forceBasedTeams, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) +XCVAR_DEF( g_forceClientUpdateRate, "250", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_forceDodge, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_forcePowerDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) +XCVAR_DEF( g_forceRegenTime, "200", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_forceRespawn, "60", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_fraglimitVoteCorrection, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_friendlyFire, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_friendlySaber, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_g2TraceLod, "3", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_gametype, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH, qfalse ) +XCVAR_DEF( g_gravity, "800", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_inactivity, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_jediVmerc, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_knockback, "1000", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_locationBasedDamage, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_log, "games.log", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_logClientInfo, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_logSync, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_maxConnPerIP, "3", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_maxForceRank, "7", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) +XCVAR_DEF( g_maxGameClients, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_maxHolocronCarry, "3", NULL, CVAR_LATCH, qfalse ) +XCVAR_DEF( g_motd, "", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_needpass, "0", NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) +XCVAR_DEF( g_noSpecMove, "0", NULL, CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( g_npcspskill, "0", NULL, CVAR_ARCHIVE|CVAR_INTERNAL, qfalse ) +XCVAR_DEF( g_password, "", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_powerDuelEndHealth, "90", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_powerDuelStartHealth, "150", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_privateDuel, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_randFix, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_restarted, "0", NULL, CVAR_ROM, qfalse ) +XCVAR_DEF( g_saberBladeFaces, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_saberDamageScale, "1", NULL, CVAR_ARCHIVE, qtrue ) #ifdef DEBUG_SABER_BOX -XCVAR_DEF( g_saberDebugBox, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_saberDebugBox, "0", NULL, CVAR_CHEAT, qfalse ) #endif #ifndef FINAL_BUILD -XCVAR_DEF( g_saberDebugPrint, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_saberDebugPrint, "0", NULL, CVAR_CHEAT, qfalse ) #endif -XCVAR_DEF( g_saberDmgDelay_Idle, "350", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberDmgDelay_Wound, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberDmgVelocityScale, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberLockFactor, "2", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberLocking, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberLockRandomNess, "2", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_saberRealisticCombat, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( g_saberRestrictForce, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_saberTraceSaberFirst, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberWallDamageScale, "0.4", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_securityLog, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_showDuelHealths, "0", NULL, CVAR_SERVERINFO, qfalse ) -XCVAR_DEF( g_siegeRespawn, "20", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_siegeTeam1, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) -XCVAR_DEF( g_siegeTeam2, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) -XCVAR_DEF( g_siegeTeamSwitch, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_slowmoDuelEnd, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_smoothClients, "1", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_spawnInvulnerability, "3000", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_speed, "250", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_statLog, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_statLogFile, "statlog.log", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_stepSlideFix, "1", NULL, CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( g_synchronousClients, "0", NULL, CVAR_SYSTEMINFO, qfalse ) -XCVAR_DEF( g_teamAutoJoin, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_teamForceBalance, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_timeouttospec, "70", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_userinfoValidate, "25165823", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_useWhileThrowing, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_voteDelay, "3000", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_warmup, "20", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_weaponDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) -XCVAR_DEF( g_weaponRespawn, "5", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( gamedate, SOURCE_DATE, NULL, CVAR_ROM, qfalse ) -XCVAR_DEF( gamename, GAMEVERSION, NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) -XCVAR_DEF( pmove_fixed, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( pmove_float, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( pmove_msec, "8", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( RMG, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( sv_cheats, "1", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( sv_fps, "40", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( sv_maxclients, "8", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( timelimit, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_saberDmgDelay_Idle, "350", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberDmgDelay_Wound, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberDmgVelocityScale, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberLockFactor, "2", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberLocking, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberLockRandomNess, "2", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_saberRealisticCombat, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_saberRestrictForce, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_saberTraceSaberFirst, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberWallDamageScale, "0.4", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_securityLog, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_showDuelHealths, "0", NULL, CVAR_SERVERINFO, qfalse ) +XCVAR_DEF( g_siegeRespawn, "20", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_siegeTeam1, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) +XCVAR_DEF( g_siegeTeam2, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) +XCVAR_DEF( g_siegeTeamSwitch, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_slowmoDuelEnd, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_smoothClients, "1", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_spawnInvulnerability, "3000", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_speed, "250", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_statLog, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_statLogFile, "statlog.log", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_stepSlideFix, "1", NULL, CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( g_synchronousClients, "0", NULL, CVAR_SYSTEMINFO, qfalse ) +XCVAR_DEF( g_teamAutoJoin, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_teamForceBalance, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_timeouttospec, "70", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_userinfoValidate, "25165823", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_useWhileThrowing, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_voteDelay, "3000", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_warmup, "20", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_weaponDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) +XCVAR_DEF( g_weaponRespawn, "5", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( gamedate, SOURCE_DATE, NULL, CVAR_ROM, qfalse ) +XCVAR_DEF( gamename, GAMEVERSION, NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) +XCVAR_DEF( pmove_fixed, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( pmove_float, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( pmove_msec, "8", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( RMG, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( sv_cheats, "1", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( sv_fps, "40", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( sv_maxclients, "8", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( timelimit, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) #undef XCVAR_DEF diff --git a/codemp/game/w_saber.c b/codemp/game/w_saber.c index 5561b3ed8d..b143eae0b8 100644 --- a/codemp/game/w_saber.c +++ b/codemp/game/w_saber.c @@ -109,6 +109,16 @@ qboolean G_CanBeEnemy( gentity_t *self, gentity_t *enemy ) if ( !self->inuse || !enemy->inuse || !self->client || !enemy->client ) return qfalse; + if (self->client->ps.duelInProgress && self->client->ps.duelIndex != enemy->s.number) + { //dueling but not with this person + return qfalse; + } + + if (enemy->client->ps.duelInProgress && enemy->client->ps.duelIndex != self->s.number) + { //other guy dueling but not with me + return qfalse; + } + if (level.gametype < GT_TEAM) return qtrue; @@ -6745,7 +6755,8 @@ qboolean saberCheckKnockdown_DuelLoss(gentity_t *saberent, gentity_t *saberOwner if ( other && other->client ) { disarmChance += other->client->saber[0].disarmBonus; - if ( other->client->saber[1].model[0] + if ( g_fixSaberDisarmBonus.integer + && other->client->saber[1].model[0] && !other->client->ps.saberHolstered ) { disarmChance += other->client->saber[1].disarmBonus; @@ -6829,7 +6840,8 @@ qboolean saberCheckKnockdown_BrokenParry(gentity_t *saberent, gentity_t *saberOw if ( other && other->client ) { disarmChance += other->client->saber[0].disarmBonus; - if ( other->client->saber[1].model[0] + if ( g_fixSaberDisarmBonus.integer + && other->client->saber[1].model[0] && !other->client->ps.saberHolstered ) { disarmChance += other->client->saber[1].disarmBonus; From 1e8a7998ca2fe434daebb41d586ac3cd5296433a Mon Sep 17 00:00:00 2001 From: razor Date: Tue, 20 Feb 2024 23:31:21 +1100 Subject: [PATCH 789/801] [MP] Remove BASE_COMPAT define (#1211) * move BASE_COMPAT flag behind cmake option BuildMPWithCompatMode, add g_fixWeaponAttackAnim making use of CS_LEGACY_FIXES * remove BASE_COMPAT and BuildMPWithCompatMode, add g_fixRunWalkAnims * actually remove BuildMPWithCompatMode --- CMakeLists.txt | 5 +- codemp/cgame/cg_event.c | 2 - codemp/cgame/cg_main.c | 1 + codemp/cgame/cg_players.c | 8 +- codemp/cgame/cg_servercmds.c | 3 +- codemp/cgame/cg_weapons.c | 10 +- codemp/game/NPC_AI_GalakMech.c | 8 +- codemp/game/bg_misc.c | 36 ++++- codemp/game/bg_pmove.c | 264 +++++++++++++++---------------- codemp/game/bg_public.h | 15 +- codemp/game/bg_saga.c | 6 +- codemp/game/g_active.c | 16 +- codemp/game/g_combat.c | 18 +-- codemp/game/g_cvar.c | 25 ++- codemp/game/g_xcvar.h | 278 +++++++++++++++++---------------- codemp/qcommon/q_shared.h | 4 - 16 files changed, 353 insertions(+), 346 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d32ed22ab8..c168794694 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ option(BuildMPGame "Whether to create projects for the MP server-side gamecode ( 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) option(BuildSPRdVanilla "Whether to create projects for the SP default renderer (rdsp-vanilla_x86.dll)" ON) @@ -193,11 +194,11 @@ if(WIN64) endif() if (APPLE) - set(SharedDefines "MACOS_X") + set(SharedDefines ${SharedDefines} "MACOS_X") endif() if (NOT WIN32 AND NOT APPLE) - set(SharedDefines "ARCH_STRING=\"${Architecture}\"") + set(SharedDefines ${SharedDefines} "ARCH_STRING=\"${Architecture}\"") endif() if(CMAKE_SYSTEM_NAME MATCHES "BSD") diff --git a/codemp/cgame/cg_event.c b/codemp/cgame/cg_event.c index 98d3992a7c..45af332e4a 100644 --- a/codemp/cgame/cg_event.c +++ b/codemp/cgame/cg_event.c @@ -3341,7 +3341,6 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { // // powerup events // -#ifdef BASE_COMPAT case EV_POWERUP_QUAD: DEBUGNAME("EV_POWERUP_QUAD"); if ( es->number == cg.snap->ps.clientNum ) { @@ -3358,7 +3357,6 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { } //trap->S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.protectSound ); break; -#endif // BASE_COMPAT case EV_FORCE_DRAINED: DEBUGNAME("EV_FORCE_DRAINED"); diff --git a/codemp/cgame/cg_main.c b/codemp/cgame/cg_main.c index b7fcdcb01f..12bbd470ec 100644 --- a/codemp/cgame/cg_main.c +++ b/codemp/cgame/cg_main.c @@ -2631,6 +2631,7 @@ Ghoul2 Insert End CG_ParseEntitiesFromString(); BG_FixSaberMoveData(); + BG_FixWeaponAttackAnim(); } //makes sure returned string is in localized format diff --git a/codemp/cgame/cg_players.c b/codemp/cgame/cg_players.c index d9262deb87..300503a8d4 100644 --- a/codemp/cgame/cg_players.c +++ b/codemp/cgame/cg_players.c @@ -4499,11 +4499,9 @@ static void CG_PlayerPowerups( centity_t *cent, refEntity_t *torso ) { return; } - #ifdef BASE_COMPAT - // quad gives a dlight - if ( powerups & ( 1 << PW_QUAD ) ) - trap->R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2f, 0.2f, 1 ); - #endif // BASE_COMPAT + // quad gives a dlight + if ( powerups & ( 1 << PW_QUAD ) ) + trap->R_AddLightToScene( cent->lerpOrigin, 200 + (rand()&31), 0.2f, 0.2f, 1 ); if (cent->currentState.eType == ET_NPC) assert(cent->npcClient); diff --git a/codemp/cgame/cg_servercmds.c b/codemp/cgame/cg_servercmds.c index c10ffbaadf..91f0272944 100644 --- a/codemp/cgame/cg_servercmds.c +++ b/codemp/cgame/cg_servercmds.c @@ -911,8 +911,9 @@ static void CG_ConfigStringModified( void ) { CG_ShaderStateChanged(); } else if ( num == CS_LEGACY_FIXES ) { - // LEGACYFIX_SABERMOVEDATA may have changed + // LEGACYFIX_SABERMOVEDATA etc may have changed BG_FixSaberMoveData(); + BG_FixWeaponAttackAnim(); } else if ( num >= CS_LIGHT_STYLES && num < CS_LIGHT_STYLES + (MAX_LIGHT_STYLES * 3)) { diff --git a/codemp/cgame/cg_weapons.c b/codemp/cgame/cg_weapons.c index f6f191e0e9..4bb3b55524 100644 --- a/codemp/cgame/cg_weapons.c +++ b/codemp/cgame/cg_weapons.c @@ -1910,12 +1910,10 @@ void CG_FireWeapon( centity_t *cent, qboolean altFire ) { } } - #ifdef BASE_COMPAT - // play quad sound if needed - if ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) { - //trap->S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.media.quadSound ); - } - #endif // BASE_COMPAT + // play quad sound if needed + if ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) { + //trap->S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.media.quadSound ); + } // play a sound diff --git a/codemp/game/NPC_AI_GalakMech.c b/codemp/game/NPC_AI_GalakMech.c index b8fd462f7c..b3bae38ca5 100644 --- a/codemp/game/NPC_AI_GalakMech.c +++ b/codemp/game/NPC_AI_GalakMech.c @@ -1181,9 +1181,7 @@ void NPC_BSGM_Attack( void ) //if ( NPC->client->ps.powerups[PW_GALAK_SHIELD] > 0 ) if (0) { - #ifdef BASE_COMPAT - NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME; - #endif + NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME; G_Damage( NPCS.NPC->enemy, NPCS.NPC, NPCS.NPC, NULL, NPCS.NPC->r.currentOrigin, 100, DAMAGE_NO_KNOCKBACK, MOD_UNKNOWN ); } else @@ -1208,9 +1206,7 @@ void NPC_BSGM_Attack( void ) //FIXME: debounce this? NPCS.NPCInfo->touchedByPlayer = NULL; //FIXME: some shield effect? - #ifdef BASE_COMPAT - NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME; - #endif + NPCS.NPC->client->ps.powerups[PW_BATTLESUIT] = level.time + ARMOR_EFFECT_TIME; VectorSubtract( NPCS.NPC->enemy->r.currentOrigin, NPCS.NPC->r.currentOrigin, smackDir ); smackDir[2] += 30; diff --git a/codemp/game/bg_misc.c b/codemp/game/bg_misc.c index fb6181812f..b283dcc446 100644 --- a/codemp/game/bg_misc.c +++ b/codemp/game/bg_misc.c @@ -312,9 +312,7 @@ int WeaponAttackAnim[WP_NUM_WEAPONS] = BOTH_THERMAL_THROW,//WP_THERMAL, BOTH_ATTACK3,//BOTH_ATTACK11,//WP_TRIP_MINE, BOTH_ATTACK3,//BOTH_ATTACK12,//WP_DET_PACK, - #ifndef BASE_COMPAT - BOTH_ATTACK3,//WP_CONCUSSION, - #endif // BASE_COMPAT + BOTH_ATTACK3,//WP_CONCUSSION, BOTH_ATTACK2,//WP_BRYAR_OLD, //NOT VALID (e.g. should never really be used): @@ -322,6 +320,32 @@ int WeaponAttackAnim[WP_NUM_WEAPONS] = BOTH_ATTACK1//WP_TURRET, }; +void BG_FixWeaponAttackAnim(void) { +#if defined(_GAME) + const qboolean doFix = !!g_fixWeaponAttackAnim.integer; +#elif defined(_CGAME) + const char *cs = CG_ConfigString(CS_LEGACY_FIXES); + const uint32_t legacyFixes = strtoul(cs, NULL, 0); + const qboolean doFix = !!(legacyFixes & (1 << LEGACYFIX_WEAPONATTACKANIM)); +#elif defined(UI_BUILD) + const qboolean doFix = qtrue; // no chance of prediction error from UI code +#endif + int *move; + + for (move = WeaponAttackAnim; move - WeaponAttackAnim < ARRAY_LEN(WeaponAttackAnim); move++) { + const weapon_t wpIndex = (weapon_t)(move - WeaponAttackAnim); + if (wpIndex == WP_CONCUSSION) { + *move = doFix ? BOTH_ATTACK3 : BOTH_ATTACK2; + } else if (wpIndex == WP_BRYAR_OLD) { + *move = doFix ? BOTH_ATTACK2 : BOTH_STAND1; + } else if (wpIndex == WP_EMPLACED_GUN) { + *move = doFix ? BOTH_STAND1 : BOTH_ATTACK1; + } else if (wpIndex == WP_TURRET) { + *move = doFix ? BOTH_ATTACK1 : BOTH_ATTACK2; // better than UB? + } + } +} + qboolean BG_FileExists( const char *fileName ) { if ( fileName && fileName[0] ) { fileHandle_t f = NULL_FILE; @@ -2439,10 +2463,8 @@ const char *eventnames[EV_NUM_ENTITY_EVENTS] = { "EV_DEATH3", "EV_OBITUARY", - #ifdef BASE_COMPAT - "EV_POWERUP_QUAD", - "EV_POWERUP_BATTLESUIT", - #endif // BASE_COMPAT + "EV_POWERUP_QUAD", + "EV_POWERUP_BATTLESUIT", //"EV_POWERUP_REGEN", "EV_FORCE_DRAINED", diff --git a/codemp/game/bg_pmove.c b/codemp/game/bg_pmove.c index 62ac9c8772..894867f1c4 100644 --- a/codemp/game/bg_pmove.c +++ b/codemp/game/bg_pmove.c @@ -5161,6 +5161,16 @@ int PM_LegsSlopeBackTransition(int desiredAnim) return resultingAnim; } +static qboolean BG_AreRunWalkAnimsFixed(void) { +#if defined(_GAME) + return !!g_fixRunWalkAnims.integer; +#elif defined(_CGAME) + const char *cs = CG_ConfigString(CS_LEGACY_FIXES); + const uint32_t legacyFixes = strtoul(cs, NULL, 0); + return !!(legacyFixes & (1 << LEGACYFIX_RUNWALKANIMS)); +#endif +} + /* =============== PM_Footsteps @@ -5430,116 +5440,106 @@ static void PM_Footsteps( void ) { #endif else if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) { -#ifndef BASE_COMPAT - if( pm->ps->weapon != WP_SABER ) - { + if ( BG_AreRunWalkAnimsFixed() && pm->ps->weapon != WP_SABER ) { desiredAnim = BOTH_RUNBACK1; } - else - { -#endif - switch (pm->ps->fd.saberAnimLevel) - { - case SS_STAFF: - if ( pm->ps->saberHolstered > 1 ) - {//saber off - desiredAnim = BOTH_RUNBACK1; - } - else - { - //desiredAnim = BOTH_RUNBACK_STAFF; - //hmm.. stuff runback anim is pretty messed up for some reason. - desiredAnim = BOTH_RUNBACK2; - } - break; - case SS_DUAL: - if ( pm->ps->saberHolstered > 1 ) - {//sabers off - desiredAnim = BOTH_RUNBACK1; - } - else - { - //desiredAnim = BOTH_RUNBACK_DUAL; - //and so is the dual - desiredAnim = BOTH_RUNBACK2; - } - break; - default: - if ( pm->ps->saberHolstered ) - {//saber off - desiredAnim = BOTH_RUNBACK1; - } - else + else { + switch (pm->ps->fd.saberAnimLevel) { - desiredAnim = BOTH_RUNBACK2; + case SS_STAFF: + if ( pm->ps->saberHolstered > 1 ) + {//saber off + desiredAnim = BOTH_RUNBACK1; + } + else + { + //desiredAnim = BOTH_RUNBACK_STAFF; + //hmm.. stuff runback anim is pretty messed up for some reason. + desiredAnim = BOTH_RUNBACK2; + } + break; + case SS_DUAL: + if ( pm->ps->saberHolstered > 1 ) + {//sabers off + desiredAnim = BOTH_RUNBACK1; + } + else + { + //desiredAnim = BOTH_RUNBACK_DUAL; + //and so is the dual + desiredAnim = BOTH_RUNBACK2; + } + break; + default: + if ( pm->ps->saberHolstered ) + {//saber off + desiredAnim = BOTH_RUNBACK1; + } + else + { + desiredAnim = BOTH_RUNBACK2; + } + break; } - break; - } -#ifndef BASE_COMPAT } -#endif } else { -#ifndef BASE_COMPAT // FIXME: this doesn't break base compatibility at all, remove #ifndef - if ( pm->ps->weapon != WP_SABER ) + if ( BG_AreRunWalkAnimsFixed() && pm->ps->weapon != WP_SABER ) { desiredAnim = BOTH_RUN1; } else { -#endif - switch (pm->ps->fd.saberAnimLevel) - { - case SS_STAFF: - if ( pm->ps->saberHolstered > 1 ) - {//blades off - desiredAnim = BOTH_RUN1; - } - else if ( pm->ps->saberHolstered == 1 ) - {//1 blade on - desiredAnim = BOTH_RUN2; - } - else + switch (pm->ps->fd.saberAnimLevel) { - if (pm->ps->fd.forcePowersActive & (1<ps->saberHolstered > 1 ) + {//blades off + desiredAnim = BOTH_RUN1; + } + else if ( pm->ps->saberHolstered == 1 ) + {//1 blade on + desiredAnim = BOTH_RUN2; + } + else { + if (pm->ps->fd.forcePowersActive & (1<ps->saberHolstered > 1 ) + {//blades off desiredAnim = BOTH_RUN1; } + else if ( pm->ps->saberHolstered == 1 ) + {//1 saber on + desiredAnim = BOTH_RUN2; + } else { - desiredAnim = BOTH_RUN_STAFF; + desiredAnim = BOTH_RUN_DUAL; } + break; + default: + if ( pm->ps->saberHolstered ) + {//saber off + desiredAnim = BOTH_RUN1; + } + else + { + desiredAnim = BOTH_RUN2; + } + break; } - break; - case SS_DUAL: - if ( pm->ps->saberHolstered > 1 ) - {//blades off - desiredAnim = BOTH_RUN1; - } - else if ( pm->ps->saberHolstered == 1 ) - {//1 saber on - desiredAnim = BOTH_RUN2; - } - else - { - desiredAnim = BOTH_RUN_DUAL; - } - break; - default: - if ( pm->ps->saberHolstered ) - {//saber off - desiredAnim = BOTH_RUN1; - } - else - { - desiredAnim = BOTH_RUN2; - } - break; } -#ifndef BASE_COMPAT - } -#endif } } else @@ -5547,58 +5547,54 @@ static void PM_Footsteps( void ) { bobmove = 0.2f; // walking bobs slow if ( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) { -#ifndef BASE_COMPAT // fixme, doesn't break base compat if enabled (I tested this to be sure) - if( pm->ps->weapon != WP_SABER ) + if ( BG_AreRunWalkAnimsFixed() && pm->ps->weapon != WP_SABER ) { desiredAnim = BOTH_WALKBACK1; } else { -#endif - switch (pm->ps->fd.saberAnimLevel) - { - case SS_STAFF: - if ( pm->ps->saberHolstered > 1 ) - { - desiredAnim = BOTH_WALKBACK1; - } - else if ( pm->ps->saberHolstered ) - { - desiredAnim = BOTH_WALKBACK2; - } - else - { - desiredAnim = BOTH_WALKBACK_STAFF; - } - break; - case SS_DUAL: - if ( pm->ps->saberHolstered > 1 ) - { - desiredAnim = BOTH_WALKBACK1; - } - else if ( pm->ps->saberHolstered ) - { - desiredAnim = BOTH_WALKBACK2; - } - else - { - desiredAnim = BOTH_WALKBACK_DUAL; - } - break; - default: - if ( pm->ps->saberHolstered ) - { - desiredAnim = BOTH_WALKBACK1; - } - else + switch (pm->ps->fd.saberAnimLevel) { - desiredAnim = BOTH_WALKBACK2; + case SS_STAFF: + if ( pm->ps->saberHolstered > 1 ) + { + desiredAnim = BOTH_WALKBACK1; + } + else if ( pm->ps->saberHolstered ) + { + desiredAnim = BOTH_WALKBACK2; + } + else + { + desiredAnim = BOTH_WALKBACK_STAFF; + } + break; + case SS_DUAL: + if ( pm->ps->saberHolstered > 1 ) + { + desiredAnim = BOTH_WALKBACK1; + } + else if ( pm->ps->saberHolstered ) + { + desiredAnim = BOTH_WALKBACK2; + } + else + { + desiredAnim = BOTH_WALKBACK_DUAL; + } + break; + default: + if ( pm->ps->saberHolstered ) + { + desiredAnim = BOTH_WALKBACK1; + } + else + { + desiredAnim = BOTH_WALKBACK2; + } + break; } - break; - } -#ifndef BASE_COMPAT } -#endif } else { @@ -5610,12 +5606,10 @@ static void PM_Footsteps( void ) { { desiredAnim = BOTH_WALK1; } -#ifndef BASE_COMPAT - else if ( pm->ps->weapon != WP_SABER ) + else if ( BG_AreRunWalkAnimsFixed() && pm->ps->weapon != WP_SABER ) { desiredAnim = BOTH_WALK1; } -#endif else { switch (pm->ps->fd.saberAnimLevel) diff --git a/codemp/game/bg_public.h b/codemp/game/bg_public.h index 4cb83fe577..1c2d7b6311 100644 --- a/codemp/game/bg_public.h +++ b/codemp/game/bg_public.h @@ -158,6 +158,8 @@ Ghoul2 Insert End typedef enum legacyFixes_e { LEGACYFIX_SABERMOVEDATA = 0, + LEGACYFIX_WEAPONATTACKANIM, + LEGACYFIX_RUNWALKANIMS, /* m m ""# " m m # # mmm m m # mmm mmm mm#mm mmm m mm # @@ -714,10 +716,8 @@ typedef enum { typedef enum { PW_NONE, - #ifdef BASE_COMPAT - PW_QUAD, - PW_BATTLESUIT, - #endif // BASE_COMPAT + PW_QUAD, + PW_BATTLESUIT, PW_PULL, @@ -924,10 +924,8 @@ typedef enum { EV_DEATH3, EV_OBITUARY, - #ifdef BASE_COMPAT - EV_POWERUP_QUAD, - EV_POWERUP_BATTLESUIT, - #endif // BASE_COMPAT + EV_POWERUP_QUAD, + EV_POWERUP_BATTLESUIT, EV_FORCE_DRAINED, @@ -1734,6 +1732,7 @@ qboolean BG_InSaberLockOld( int anim ); qboolean BG_InSaberLock( int anim ); void BG_FixSaberMoveData( void ); +void BG_FixWeaponAttackAnim( void ); void BG_SaberStartTransAnim( int clientNum, int saberAnimLevel, int weapon, int anim, float *animSpeed, int broken ); diff --git a/codemp/game/bg_saga.c b/codemp/game/bg_saga.c index d67e339d80..e1ab740c6a 100644 --- a/codemp/game/bg_saga.c +++ b/codemp/game/bg_saga.c @@ -157,10 +157,8 @@ stringID_table_t HoldableTable[] = stringID_table_t PowerupTable[] = { ENUM2STRING(PW_NONE), - #ifdef BASE_COMPAT - ENUM2STRING(PW_QUAD), - ENUM2STRING(PW_BATTLESUIT), - #endif // BASE_COMPAT + ENUM2STRING(PW_QUAD), + ENUM2STRING(PW_BATTLESUIT), ENUM2STRING(PW_PULL), ENUM2STRING(PW_REDFLAG), ENUM2STRING(PW_BLUEFLAG), diff --git a/codemp/game/g_active.c b/codemp/game/g_active.c index 8fd94adc50..5f1f90c44e 100644 --- a/codemp/game/g_active.c +++ b/codemp/game/g_active.c @@ -144,9 +144,7 @@ Check for lava / slime contents and drowning ============= */ void P_WorldEffects( gentity_t *ent ) { -#ifdef BASE_COMPAT qboolean envirosuit = qfalse; -#endif int waterlevel; if ( ent->client->noclip ) { @@ -156,19 +154,15 @@ void P_WorldEffects( gentity_t *ent ) { waterlevel = ent->waterlevel; - #ifdef BASE_COMPAT - envirosuit = ent->client->ps.powerups[PW_BATTLESUIT] > level.time; - #endif // BASE_COMPAT + envirosuit = ent->client->ps.powerups[PW_BATTLESUIT] > level.time; // // check for drowning // if ( waterlevel == 3 ) { - #ifdef BASE_COMPAT - // envirosuit give air - if ( envirosuit ) - ent->client->airOutTime = level.time + 10000; - #endif // BASE_COMPAT + // envirosuit give air + if ( envirosuit ) + ent->client->airOutTime = level.time + 10000; // if out of air, start drowning if ( ent->client->airOutTime < level.time) { @@ -208,11 +202,9 @@ void P_WorldEffects( gentity_t *ent ) { { if ( ent->health > 0 && ent->client->tempSpectate < level.time && ent->pain_debounce_time <= level.time ) { - #ifdef BASE_COMPAT if ( envirosuit ) G_AddEvent( ent, EV_POWERUP_BATTLESUIT, 0 ); else - #endif { if ( ent->watertype & CONTENTS_LAVA ) G_Damage( ent, NULL, NULL, NULL, NULL, 30*waterlevel, 0, MOD_LAVA ); diff --git a/codemp/game/g_combat.c b/codemp/game/g_combat.c index 3540974377..caed2fa430 100644 --- a/codemp/game/g_combat.c +++ b/codemp/game/g_combat.c @@ -4908,17 +4908,15 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_ } } - #ifdef BASE_COMPAT - // battlesuit protects from all radius damage (but takes knockback) - // and protects 50% against all damage - if ( client && client->ps.powerups[PW_BATTLESUIT] ) { - G_AddEvent( targ, EV_POWERUP_BATTLESUIT, 0 ); - if ( ( dflags & DAMAGE_RADIUS ) || ( mod == MOD_FALLING ) ) { - return; - } - damage *= 0.5; + // battlesuit protects from all radius damage (but takes knockback) + // and protects 50% against all damage + if ( client && client->ps.powerups[PW_BATTLESUIT] ) { + G_AddEvent( targ, EV_POWERUP_BATTLESUIT, 0 ); + if ( ( dflags & DAMAGE_RADIUS ) || ( mod == MOD_FALLING ) ) { + return; } - #endif + damage *= 0.5; + } // add to the attacker's hit counter (if the target isn't a general entity like a prox mine) if ( attacker->client && targ != attacker && targ->health > 0 diff --git a/codemp/game/g_cvar.c b/codemp/game/g_cvar.c index c0839be5e7..e2c7600e0c 100644 --- a/codemp/game/g_cvar.c +++ b/codemp/game/g_cvar.c @@ -23,6 +23,7 @@ along with this program; if not, see . #include +#include "bg_public.h" #include "g_local.h" #include "game/bg_public.h" @@ -30,21 +31,33 @@ along with this program; if not, see . // Cvar callbacks // -static void CVU_FixSaberMoveData(void) { - BG_FixSaberMoveData(); - +static void UpdateLegacyFixesConfigstring( legacyFixes_t legacyFix, qboolean enabled ) { char sLegacyFixes[32]; trap->GetConfigstring(CS_LEGACY_FIXES, sLegacyFixes, sizeof(sLegacyFixes)); uint32_t legacyFixes = strtoul(sLegacyFixes, NULL, 0); - if (g_fixSaberMoveData.integer) { - legacyFixes |= (1 << LEGACYFIX_SABERMOVEDATA); + if (enabled) { + legacyFixes |= (1 << legacyFix); } else { - legacyFixes &= ~(1 << LEGACYFIX_SABERMOVEDATA); + legacyFixes &= ~(1 << legacyFix); } trap->SetConfigstring(CS_LEGACY_FIXES, va("%" PRIu32, legacyFixes)); } +static void CVU_FixSaberMoveData(void) { + BG_FixSaberMoveData(); + UpdateLegacyFixesConfigstring(LEGACYFIX_SABERMOVEDATA, g_fixSaberMoveData.integer); +} + +static void CVU_FixRunWalkAnims(void) { + UpdateLegacyFixesConfigstring(LEGACYFIX_RUNWALKANIMS, g_fixRunWalkAnims.integer); +} + +static void CVU_FixWeaponAttackAnim(void) { + BG_FixWeaponAttackAnim(); + UpdateLegacyFixesConfigstring(LEGACYFIX_WEAPONATTACKANIM, g_fixWeaponAttackAnim.integer); +} + // // Cvar table // diff --git a/codemp/game/g_xcvar.h b/codemp/game/g_xcvar.h index b21a6c430c..df9ee8094a 100644 --- a/codemp/game/g_xcvar.h +++ b/codemp/game/g_xcvar.h @@ -34,149 +34,151 @@ along with this program; if not, see . #define XCVAR_DEF( ... ) #endif -XCVAR_DEF( bg_fighterAltControl, "0", NULL, CVAR_SYSTEMINFO, qtrue ) -XCVAR_DEF( capturelimit, "8", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( com_optvehtrace, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( d_altRoutes, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_asynchronousGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_break, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_JediAI, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_noGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_noroam, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_npcai, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_npcaiming, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_npcfreeze, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_noIntermissionWait, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( d_patched, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_perPlayerGhoul2, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_powerDuelPrint, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( d_projectileGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberAlwaysBoxTrace, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberBoxTraceSize, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberCombat, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( d_saberGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberInterpolate, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( d_saberKickTweak, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( d_saberSPStyleDamage, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( d_saberStanceDebug, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( d_siegeSeekerNPC, "0", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( dedicated, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( developer, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( dmflags, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( duel_fraglimit, "10", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( fraglimit, "20", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( g_adaptRespawn, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_allowDuelSuicide, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_allowHighPingDuelist, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_allowNPC, "1", NULL, CVAR_CHEAT, qtrue ) -XCVAR_DEF( g_allowTeamVote, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_allowVote, "-1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_antiFakePlayer, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_armBreakage, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_austrian, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_autoMapCycle, "0", NULL, CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) -XCVAR_DEF( g_banIPs, "", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_charRestrictRGB, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_duelWeaponDisable, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) -XCVAR_DEF( g_debugAlloc, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_debugDamage, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_debugMelee, "0", NULL, CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( g_debugMove, "0", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_debugSaberLocks, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( g_debugServerSkel, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( bg_fighterAltControl, "0", NULL, CVAR_SYSTEMINFO, qtrue ) +XCVAR_DEF( capturelimit, "8", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( com_optvehtrace, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( d_altRoutes, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_asynchronousGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_break, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_JediAI, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_noGroupAI, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_noroam, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_npcai, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_npcaiming, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_npcfreeze, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_noIntermissionWait, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( d_patched, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_perPlayerGhoul2, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_powerDuelPrint, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( d_projectileGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberAlwaysBoxTrace, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberBoxTraceSize, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberCombat, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( d_saberGhoul2Collision, "1", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberInterpolate, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( d_saberKickTweak, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( d_saberSPStyleDamage, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( d_saberStanceDebug, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( d_siegeSeekerNPC, "0", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( dedicated, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( developer, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( dmflags, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( duel_fraglimit, "10", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( fraglimit, "20", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_adaptRespawn, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_allowDuelSuicide, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_allowHighPingDuelist, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_allowNPC, "1", NULL, CVAR_CHEAT, qtrue ) +XCVAR_DEF( g_allowTeamVote, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_allowVote, "-1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_antiFakePlayer, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_armBreakage, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_austrian, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_autoMapCycle, "0", NULL, CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_banIPs, "", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_charRestrictRGB, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_duelWeaponDisable, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) +XCVAR_DEF( g_debugAlloc, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_debugDamage, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_debugMelee, "0", NULL, CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( g_debugMove, "0", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_debugSaberLocks, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_debugServerSkel, "0", NULL, CVAR_CHEAT, qfalse ) #ifdef _DEBUG -XCVAR_DEF( g_disableServerG2, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_disableServerG2, "0", NULL, CVAR_NONE, qtrue ) #endif -XCVAR_DEF( g_dismember, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_doWarmup, "0", NULL, CVAR_NONE, qtrue ) -//XCVAR_DEF( g_engineModifications, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_ff_objectives, "0", NULL, CVAR_CHEAT|CVAR_NORESTART, qtrue ) -XCVAR_DEF( g_filterBan, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_fixSaberDisarmBonus, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_fixSaberMoveData, "1", CVU_FixSaberMoveData, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_forceBasedTeams, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) -XCVAR_DEF( g_forceClientUpdateRate, "250", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_forceDodge, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_forcePowerDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) -XCVAR_DEF( g_forceRegenTime, "200", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_forceRespawn, "60", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_fraglimitVoteCorrection, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_friendlyFire, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_friendlySaber, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_g2TraceLod, "3", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_gametype, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH, qfalse ) -XCVAR_DEF( g_gravity, "800", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_inactivity, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_jediVmerc, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_knockback, "1000", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_locationBasedDamage, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_log, "games.log", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_logClientInfo, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_logSync, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_maxConnPerIP, "3", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_maxForceRank, "7", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) -XCVAR_DEF( g_maxGameClients, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_maxHolocronCarry, "3", NULL, CVAR_LATCH, qfalse ) -XCVAR_DEF( g_motd, "", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_needpass, "0", NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) -XCVAR_DEF( g_noSpecMove, "0", NULL, CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( g_npcspskill, "0", NULL, CVAR_ARCHIVE|CVAR_INTERNAL, qfalse ) -XCVAR_DEF( g_password, "", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_powerDuelEndHealth, "90", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_powerDuelStartHealth, "150", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_privateDuel, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_randFix, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_restarted, "0", NULL, CVAR_ROM, qfalse ) -XCVAR_DEF( g_saberBladeFaces, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_saberDamageScale, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_dismember, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_doWarmup, "0", NULL, CVAR_NONE, qtrue ) +//XCVAR_DEF( g_engineModifications, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_ff_objectives, "0", NULL, CVAR_CHEAT|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_filterBan, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_fixSaberDisarmBonus, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_fixSaberMoveData, "1", CVU_FixSaberMoveData, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_fixRunWalkAnims, "1", CVU_FixRunWalkAnims, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_fixWeaponAttackAnim, "1", CVU_FixWeaponAttackAnim, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_forceBasedTeams, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) +XCVAR_DEF( g_forceClientUpdateRate, "250", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_forceDodge, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_forcePowerDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) +XCVAR_DEF( g_forceRegenTime, "200", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_forceRespawn, "60", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_fraglimitVoteCorrection, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_friendlyFire, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_friendlySaber, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_g2TraceLod, "3", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_gametype, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH, qfalse ) +XCVAR_DEF( g_gravity, "800", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_inactivity, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_jediVmerc, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_knockback, "1000", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_locationBasedDamage, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_log, "games.log", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_logClientInfo, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_logSync, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_maxConnPerIP, "3", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_maxForceRank, "7", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qfalse ) +XCVAR_DEF( g_maxGameClients, "0", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_maxHolocronCarry, "3", NULL, CVAR_LATCH, qfalse ) +XCVAR_DEF( g_motd, "", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_needpass, "0", NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) +XCVAR_DEF( g_noSpecMove, "0", NULL, CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( g_npcspskill, "0", NULL, CVAR_ARCHIVE|CVAR_INTERNAL, qfalse ) +XCVAR_DEF( g_password, "", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_powerDuelEndHealth, "90", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_powerDuelStartHealth, "150", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_privateDuel, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_randFix, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_restarted, "0", NULL, CVAR_ROM, qfalse ) +XCVAR_DEF( g_saberBladeFaces, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_saberDamageScale, "1", NULL, CVAR_ARCHIVE, qtrue ) #ifdef DEBUG_SABER_BOX -XCVAR_DEF( g_saberDebugBox, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_saberDebugBox, "0", NULL, CVAR_CHEAT, qfalse ) #endif #ifndef FINAL_BUILD -XCVAR_DEF( g_saberDebugPrint, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_saberDebugPrint, "0", NULL, CVAR_CHEAT, qfalse ) #endif -XCVAR_DEF( g_saberDmgDelay_Idle, "350", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberDmgDelay_Wound, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberDmgVelocityScale, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberLockFactor, "2", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberLocking, "1", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberLockRandomNess, "2", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_saberRealisticCombat, "0", NULL, CVAR_CHEAT, qfalse ) -XCVAR_DEF( g_saberRestrictForce, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_saberTraceSaberFirst, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_saberWallDamageScale, "0.4", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_securityLog, "1", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_showDuelHealths, "0", NULL, CVAR_SERVERINFO, qfalse ) -XCVAR_DEF( g_siegeRespawn, "20", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_siegeTeam1, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) -XCVAR_DEF( g_siegeTeam2, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) -XCVAR_DEF( g_siegeTeamSwitch, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_slowmoDuelEnd, "0", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_smoothClients, "1", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_spawnInvulnerability, "3000", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_speed, "250", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_statLog, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_statLogFile, "statlog.log", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_stepSlideFix, "1", NULL, CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( g_synchronousClients, "0", NULL, CVAR_SYSTEMINFO, qfalse ) -XCVAR_DEF( g_teamAutoJoin, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_teamForceBalance, "0", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_timeouttospec, "70", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_userinfoValidate, "25165823", NULL, CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( g_useWhileThrowing, "1", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( g_voteDelay, "3000", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( g_warmup, "20", NULL, CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( g_weaponDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) -XCVAR_DEF( g_weaponRespawn, "5", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( gamedate, SOURCE_DATE, NULL, CVAR_ROM, qfalse ) -XCVAR_DEF( gamename, GAMEVERSION, NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) -XCVAR_DEF( pmove_fixed, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( pmove_float, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( pmove_msec, "8", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) -XCVAR_DEF( RMG, "0", NULL, CVAR_NONE, qtrue ) -XCVAR_DEF( sv_cheats, "1", NULL, CVAR_NONE, qfalse ) -XCVAR_DEF( sv_fps, "40", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qtrue ) -XCVAR_DEF( sv_maxclients, "8", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) -XCVAR_DEF( timelimit, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) +XCVAR_DEF( g_saberDmgDelay_Idle, "350", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberDmgDelay_Wound, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberDmgVelocityScale, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberLockFactor, "2", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberLocking, "1", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberLockRandomNess, "2", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_saberRealisticCombat, "0", NULL, CVAR_CHEAT, qfalse ) +XCVAR_DEF( g_saberRestrictForce, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_saberTraceSaberFirst, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_saberWallDamageScale, "0.4", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_securityLog, "1", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_showDuelHealths, "0", NULL, CVAR_SERVERINFO, qfalse ) +XCVAR_DEF( g_siegeRespawn, "20", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_siegeTeam1, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) +XCVAR_DEF( g_siegeTeam2, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qfalse ) +XCVAR_DEF( g_siegeTeamSwitch, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_slowmoDuelEnd, "0", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_smoothClients, "1", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_spawnInvulnerability, "3000", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_speed, "250", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_statLog, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_statLogFile, "statlog.log", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_stepSlideFix, "1", NULL, CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( g_synchronousClients, "0", NULL, CVAR_SYSTEMINFO, qfalse ) +XCVAR_DEF( g_teamAutoJoin, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_teamForceBalance, "0", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_timeouttospec, "70", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_userinfoValidate, "25165823", NULL, CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( g_useWhileThrowing, "1", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( g_voteDelay, "3000", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( g_warmup, "20", NULL, CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( g_weaponDisable, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_LATCH, qtrue ) +XCVAR_DEF( g_weaponRespawn, "5", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( gamedate, SOURCE_DATE, NULL, CVAR_ROM, qfalse ) +XCVAR_DEF( gamename, GAMEVERSION, NULL, CVAR_SERVERINFO|CVAR_ROM, qfalse ) +XCVAR_DEF( pmove_fixed, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( pmove_float, "0", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( pmove_msec, "8", NULL, CVAR_SYSTEMINFO|CVAR_ARCHIVE, qtrue ) +XCVAR_DEF( RMG, "0", NULL, CVAR_NONE, qtrue ) +XCVAR_DEF( sv_cheats, "1", NULL, CVAR_NONE, qfalse ) +XCVAR_DEF( sv_fps, "40", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO, qtrue ) +XCVAR_DEF( sv_maxclients, "8", NULL, CVAR_SERVERINFO|CVAR_LATCH|CVAR_ARCHIVE, qfalse ) +XCVAR_DEF( timelimit, "0", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE|CVAR_NORESTART, qtrue ) #undef XCVAR_DEF diff --git a/codemp/qcommon/q_shared.h b/codemp/qcommon/q_shared.h index cea7b5c833..526ede7d25 100644 --- a/codemp/qcommon/q_shared.h +++ b/codemp/qcommon/q_shared.h @@ -44,10 +44,6 @@ along with this program; if not, see . #define MAX_TEAMNAME 32 #define MAX_MASTER_SERVERS 5 // number of supported master servers -#define BASE_COMPAT // some unused and leftover code has been stripped out, but this breaks compatibility - // between base<->modbase clients and servers (mismatching events, powerups, etc) - // leave this defined to ensure compatibility - #include "qcommon/q_math.h" #include "qcommon/q_color.h" #include "qcommon/q_string.h" From c79e6576a0d19e961f096c44835f93e0ba6b8fe6 Mon Sep 17 00:00:00 2001 From: razor Date: Thu, 29 Feb 2024 11:22:34 +1100 Subject: [PATCH 790/801] [MP] fix g_weaponDisable + g_forcePowerDisable regression when creating listen servers (#1217) * fix g_weaponDisable + g_forcePowerDisable regression when creating listen servers. re-enabling this block that turns e.g. g_weaponDisable 1 --> g_weaponDisable 524279 also fix some stray uninitialised warnings * replace commented code with commented words --- codemp/ui/ui_main.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/codemp/ui/ui_main.c b/codemp/ui/ui_main.c index 45501d9479..3375301f79 100644 --- a/codemp/ui/ui_main.c +++ b/codemp/ui/ui_main.c @@ -6505,7 +6505,6 @@ static void UI_RunMenuScript(char **args) { UI_UpdateCharacterSkin(); } -#if 0 else if (Q_stricmp(name, "setui_dualforcepower") == 0) { int forcePowerDisable = trap->Cvar_VariableValue("g_forcePowerDisable"); @@ -6540,7 +6539,7 @@ static void UI_RunMenuScript(char **args) } else if (Q_stricmp(name, "dualForcePowers") == 0) { - int dualforcePower,i, forcePowerDisable; + int dualforcePower,i, forcePowerDisable=0; dualforcePower = trap->Cvar_VariableValue("ui_dualforcepower"); if (dualforcePower==0) // All force powers @@ -6598,8 +6597,8 @@ static void UI_RunMenuScript(char **args) int weaponDisable,i; const char *cvarString; - if (uiInfo.gameTypes[ui_netGameType.integer].gtEnum == GT_DUEL || - uiInfo.gameTypes[ui_netGameType.integer].gtEnum == GT_POWERDUEL) + if (uiInfo.gameTypes[ui_netGametype.integer].gtEnum == GT_DUEL || + uiInfo.gameTypes[ui_netGametype.integer].gtEnum == GT_POWERDUEL) { cvarString = "g_duelWeaponDisable"; } @@ -6624,7 +6623,6 @@ static void UI_RunMenuScript(char **args) trap->Cvar_Set(cvarString, va("%i",weaponDisable)); } } -#endif // If this is siege, change all the bots to humans, because we faked it earlier // swapping humans for bots on the menu else if (Q_stricmp(name, "setSiegeNoBots") == 0) @@ -7414,7 +7412,6 @@ static void UI_BuildServerDisplayList(int force) { int i, count, clients, maxClients, ping, game, len, passw/*, visible*/; char info[MAX_STRING_CHARS]; // qboolean startRefresh = qtrue; TTimo: unused - static int numinvisible; int lanSource; if (!(force || uiInfo.uiDC.realTime > uiInfo.serverStatus.nextDisplayRefresh)) { @@ -7440,7 +7437,6 @@ static void UI_BuildServerDisplayList(int force) { lanSource = UI_SourceForLAN(); if (force) { - numinvisible = 0; // clear number of displayed servers uiInfo.serverStatus.numDisplayServers = 0; uiInfo.serverStatus.numPlayersOnServers = 0; @@ -7535,7 +7531,6 @@ static void UI_BuildServerDisplayList(int force) { // done with this server if (ping > 0) { trap->LAN_MarkServerVisible(lanSource, i, qfalse); - numinvisible++; } } } @@ -7705,7 +7700,7 @@ UI_BuildFindPlayerList ================== */ static void UI_BuildFindPlayerList(qboolean force) { - static int numFound, numTimeOuts; + static int numFound; int i, j, resend; serverStatusInfo_t info; char name[MAX_NAME_LENGTH+2]; @@ -7745,7 +7740,6 @@ static void UI_BuildFindPlayerList(qboolean force) { // sizeof(uiInfo.foundPlayerServerNames[uiInfo.numFoundPlayerServers-1]), // "searching %d...", uiInfo.pendingServerStatus.num); numFound = 0; - numTimeOuts++; } for (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) { // if this pending server is valid @@ -7796,7 +7790,7 @@ static void UI_BuildFindPlayerList(qboolean force) { if (!uiInfo.pendingServerStatus.server[i].valid || uiInfo.pendingServerStatus.server[i].startTime < uiInfo.uiDC.realTime - ui_serverStatusTimeOut.integer) { if (uiInfo.pendingServerStatus.server[i].valid) { - numTimeOuts++; + // timed out } // reset server status request for this address UI_GetServerStatusInfo( uiInfo.pendingServerStatus.server[i].adrstr, NULL ); From 2a7c5262802f6b254c1d270a7ba72d1f97e5a9fc Mon Sep 17 00:00:00 2001 From: razor Date: Tue, 5 Mar 2024 17:59:55 +1100 Subject: [PATCH 791/801] avoid configstring index clash with base_entranced (#1218) --- codemp/game/bg_public.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/codemp/game/bg_public.h b/codemp/game/bg_public.h index 1c2d7b6311..0326fb64f4 100644 --- a/codemp/game/bg_public.h +++ b/codemp/game/bg_public.h @@ -111,7 +111,7 @@ along with this program; if not, see . #define CS_FLAGSTATUS 23 // string indicating flag status in CTF #define CS_SHADERSTATE 24 #define CS_BOTINFO 25 -#define CS_LEGACY_FIXES 26 + #define CS_ITEMS 27 // string of 0's and 1's that tell which items are present #define CS_CLIENT_JEDIMASTER 28 // current jedi master @@ -120,6 +120,8 @@ along with this program; if not, see . #define CS_CLIENT_DUELHEALTHS 31 // nmckenzie: DUEL_HEALTH. Hopefully adding this cs is safe and good? #define CS_GLOBAL_AMBIENT_SET 32 +#define CS_LEGACY_FIXES 36 + #define CS_AMBIENT_SET 37 #define CS_SIEGE_STATE (CS_AMBIENT_SET+MAX_AMBIENT_SETS) From 62124e18ef09b293ea66a1f673b827d83e073928 Mon Sep 17 00:00:00 2001 From: razor Date: Tue, 5 Mar 2024 18:15:51 +1100 Subject: [PATCH 792/801] [Shared] add a custom CMake target to copy compilation DB from build dir to source dir (#1177) * add a custom cmake target to copy compilation DB from build dir to source dir see https://clang.llvm.org/docs/JSONCompilationDatabase.html for further details * gitignore compile_commands.json --- .gitignore | 3 ++- CMakeLists.txt | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a8a1494a1f..87aa203888 100644 --- a/.gitignore +++ b/.gitignore @@ -182,6 +182,7 @@ pip-log.txt ## clangd ############# .clangd +compile_commands.json ############# ## CLion @@ -192,4 +193,4 @@ pip-log.txt ## CMake Builds ############# [Bb]uild*/ -cmake-build-* \ No newline at end of file +cmake-build-* diff --git a/CMakeLists.txt b/CMakeLists.txt index c168794694..4947258619 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,14 @@ endif() #============================================================================= list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake/Modules") +if(CMAKE_EXPORT_COMPILE_COMMANDS) + add_custom_target( + copy-compile-commands ALL + ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_BINARY_DIR}/compile_commands.json + ${CMAKE_CURRENT_LIST_DIR}) +endif() + #============================================================================= # # Architecture/OS defines From d2afcfefb5eb07d6f3787b48b947482160f27a1d Mon Sep 17 00:00:00 2001 From: Daggolin Date: Mon, 25 Mar 2024 22:16:13 +0100 Subject: [PATCH 793/801] [SP] Adjust MenuFontToReal to only try to register fonts once. (#1225) This fixes #1214, which was introduced in d786f197d1ebb967707f0570c7d5c0f45205c0a5. --- code/ui/ui_shared.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/code/ui/ui_shared.cpp b/code/ui/ui_shared.cpp index 07461b8adf..f2d5a3cf3b 100644 --- a/code/ui/ui_shared.cpp +++ b/code/ui/ui_shared.cpp @@ -3074,12 +3074,29 @@ qboolean ItemParse_name( itemDef_t *item) int MenuFontToReal( int menuFontIndex ) { + static int fonthandle_aurabesh; + static int fonthandle_ergoec; + static int fonthandle_anewhope; + static int fonthandle_arialnb; + + static qboolean fontsRegistered = qfalse; + + if ( !fontsRegistered ) + { // Only try registering the fonts once + fonthandle_aurabesh = UI_RegisterFont( "aurabesh" ); + fonthandle_ergoec = UI_RegisterFont( "ergoec" ); + fonthandle_anewhope = UI_RegisterFont( "anewhope" ); + fonthandle_arialnb = UI_RegisterFont( "arialnb" ); + + fontsRegistered = qtrue; + } + // Default fonts from a clean installation switch ( menuFontIndex ) { - case 1: return UI_RegisterFont( "aurabesh" ); - case 2: return UI_RegisterFont( "ergoec" ); - case 3: return UI_RegisterFont( "anewhope" ); - case 4: return UI_RegisterFont( "arialnb" ); + case 1: return fonthandle_aurabesh; + case 2: return fonthandle_ergoec; + case 3: return fonthandle_anewhope; + case 4: return fonthandle_arialnb; default: return DC->Assets.qhMediumFont; From 77be2ef6bb49369d6f7d1977fcabf6bcc5223d69 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sun, 7 Apr 2024 02:10:34 +0200 Subject: [PATCH 794/801] [SP] Add CG_MagicFontToReal function to map magic number fonts to their vanilla equivalents. This fixes #1226. --- code/cgame/cg_local.h | 2 ++ code/cgame/cg_main.cpp | 39 ++++++++++++++++++++++++++++++++++++++- code/cgame/cg_weapons.cpp | 2 +- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/code/cgame/cg_local.h b/code/cgame/cg_local.h index 3a1f7e8bff..8c0960f8b4 100644 --- a/code/cgame/cg_local.h +++ b/code/cgame/cg_local.h @@ -1231,4 +1231,6 @@ void CG_ClearLightStyles( void ); void CG_RunLightStyles( void ); void CG_SetLightstyle( int i ); +int CG_MagicFontToReal( int menuFontIndex ); + #endif //__CG_LOCAL_H__ diff --git a/code/cgame/cg_main.cpp b/code/cgame/cg_main.cpp index 86bf1a0c78..db6f7dc4e0 100644 --- a/code/cgame/cg_main.cpp +++ b/code/cgame/cg_main.cpp @@ -4353,13 +4353,50 @@ void CG_DrawDataPadForceSelect( void ) const float textScale = 1.0f; CG_DisplayBoxedText(textboxXPos,textboxYPos,textboxWidth,textboxHeight,va("%s%s",text,text2), - 4, + CG_MagicFontToReal(4), textScale, colorTable[CT_WHITE] ); } } +int CG_MagicFontToReal( int menuFontIndex ) +{ + // As the engine supports multiple renderers now we can no longer assume the + // order of fontindex values to be the same as it was on vanilla jasp with + // vanilla assets. Sadly the code uses magic numbers in various places that + // no longer match. This function tries to map these magic numbers to the + // fonts the would refer to on vanilla jasp with vanilla assets. + + static int fonthandle_aurabesh; + static int fonthandle_ergoec; + static int fonthandle_anewhope; + static int fonthandle_arialnb; + + static qboolean fontsRegistered = qfalse; + + if ( !fontsRegistered ) + { // Only try registering the fonts once + fonthandle_aurabesh = cgi_R_RegisterFont( "aurabesh" ); + fonthandle_ergoec = cgi_R_RegisterFont( "ergoec" ); + fonthandle_anewhope = cgi_R_RegisterFont( "anewhope" ); + fonthandle_arialnb = cgi_R_RegisterFont( "arialnb" ); + + fontsRegistered = qtrue; + } + + // Default fonts from a clean installation + switch ( menuFontIndex ) { + case 1: return fonthandle_aurabesh; + case 2: return fonthandle_ergoec; + case 3: return fonthandle_anewhope; + case 4: return fonthandle_arialnb; + + default: + return cgs.media.qhFontMedium; + } +} + // actually, these are pretty pointless so far in CHC, since in TA codebase they were used only so init some HUD // function ptrs to allow cinematics in onscreen displays. So far, we don't use those, but here they are anyway... // diff --git a/code/cgame/cg_weapons.cpp b/code/cgame/cg_weapons.cpp index dc90ee497e..09a5b20ad4 100644 --- a/code/cgame/cg_weapons.cpp +++ b/code/cgame/cg_weapons.cpp @@ -1685,7 +1685,7 @@ void CG_DrawDataPadWeaponSelect( void ) textboxXPos, textboxYPos, textboxWidth, textboxHeight, text, - 4, + CG_MagicFontToReal(4), textScale, colorTable[CT_WHITE] ); From a7855cec31ae9ba7994e99fe303a82f4f6109788 Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sun, 7 Apr 2024 02:14:03 +0200 Subject: [PATCH 795/801] [SP] Rename MenuFontToReal to UI_MenuFontToReal and replace hardcoded font mapping with a dynamic list of up to 64 fonts. This might help with possible corner cases where custom assets have the menu loads differents fonts in place of the vanilla ones. The maximum of 64 fonts was chosen, because I wanted to avoid dynamic allocation. As the vanilla game only loads 5 different fonts and as I am not aware of custom mods that add a lot more I chose the value 64 to hopefully leave enough room for mods. The same change can NOT be applied to CG_MagicFontToReal, because the cgame module does not parse the menu files and does not know the order of fonts in menu files. --- code/ui/ui_atoms.cpp | 19 +++++++++++++++++++ code/ui/ui_local.h | 4 ++++ code/ui/ui_shared.cpp | 44 ++++++++++++++----------------------------- 3 files changed, 37 insertions(+), 30 deletions(-) diff --git a/code/ui/ui_atoms.cpp b/code/ui/ui_atoms.cpp index 69ccfb6e3b..21488388bb 100644 --- a/code/ui/ui_atoms.cpp +++ b/code/ui/ui_atoms.cpp @@ -441,6 +441,9 @@ UI_RegisterFont ================= */ +int registeredFontsCount = 0; +int registeredFonts[MAX_FONTS]; + int UI_RegisterFont(const char *fontName) { int iFontIndex = ui.R_RegisterFont(fontName); @@ -449,6 +452,22 @@ int UI_RegisterFont(const char *fontName) iFontIndex = ui.R_RegisterFont("ergoec"); // fall back } + // Store font + if ( iFontIndex ) + { + int i; + for ( i = 0; i < registeredFontsCount; i++ ) + { + if ( registeredFonts[i] == iFontIndex ) break; + } + + if ( i == registeredFontsCount ) + { // It's not in the list: add it + if ( registeredFontsCount >= MAX_FONTS ) Com_Printf( "^3UI_RegisterFont: MAX_FONTS (%i) exceeded\n", MAX_FONTS ); + else registeredFonts[registeredFontsCount++] = iFontIndex; + } + } + return iFontIndex; } diff --git a/code/ui/ui_local.h b/code/ui/ui_local.h index e39c4f902d..6767efd5dd 100644 --- a/code/ui/ui_local.h +++ b/code/ui/ui_local.h @@ -246,4 +246,8 @@ void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ); void _UI_Refresh( int realtime ); +#define MAX_FONTS 64 +extern int registeredFontsCount; +extern int registeredFonts[MAX_FONTS]; + #endif diff --git a/code/ui/ui_shared.cpp b/code/ui/ui_shared.cpp index f2d5a3cf3b..2f5cbdf877 100644 --- a/code/ui/ui_shared.cpp +++ b/code/ui/ui_shared.cpp @@ -352,7 +352,7 @@ qboolean MenuParse_font( itemDef_t *item) if (!DC->Assets.fontRegistered) { - DC->Assets.qhMediumFont = DC->registerFont(menu->font); + DC->Assets.qhMediumFont = UI_RegisterFont(menu->font); DC->Assets.fontRegistered = qtrue; } return qtrue; @@ -3072,35 +3072,19 @@ qboolean ItemParse_name( itemDef_t *item) return qtrue; } -int MenuFontToReal( int menuFontIndex ) +int UI_MenuFontToReal( int menuFontIndex ) { - static int fonthandle_aurabesh; - static int fonthandle_ergoec; - static int fonthandle_anewhope; - static int fonthandle_arialnb; + // The font array starts at 0, but the valid font indexes start at 1. As the + // original menu files have direct font indexes we need to subtract 1 from + // the given index to get the correct index for our mapping array. + menuFontIndex--; - static qboolean fontsRegistered = qfalse; + // Make sure we don't go out of bound, fallback to medium font + if ( menuFontIndex < 0 || menuFontIndex >= registeredFontsCount ) + return DC->Assets.qhMediumFont; - if ( !fontsRegistered ) - { // Only try registering the fonts once - fonthandle_aurabesh = UI_RegisterFont( "aurabesh" ); - fonthandle_ergoec = UI_RegisterFont( "ergoec" ); - fonthandle_anewhope = UI_RegisterFont( "anewhope" ); - fonthandle_arialnb = UI_RegisterFont( "arialnb" ); - - fontsRegistered = qtrue; - } - - // Default fonts from a clean installation - switch ( menuFontIndex ) { - case 1: return fonthandle_aurabesh; - case 2: return fonthandle_ergoec; - case 3: return fonthandle_anewhope; - case 4: return fonthandle_arialnb; - - default: - return DC->Assets.qhMediumFont; - } + // Use the mapped index + return registeredFonts[menuFontIndex]; } qboolean ItemParse_font( itemDef_t *item ) @@ -3111,7 +3095,7 @@ qboolean ItemParse_font( itemDef_t *item ) } // Translate to real font - item->font = MenuFontToReal( item->font ); + item->font = UI_MenuFontToReal( item->font ); return qtrue; } @@ -8294,7 +8278,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw) while (1) { // FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu. - textWidth = DC->textWidth(textPtr, fDescScale, MenuFontToReal(4)); // item->font); + textWidth = DC->textWidth(textPtr, fDescScale, UI_MenuFontToReal(4)); // item->font); if (parent->descAlignment == ITEM_ALIGN_RIGHT) { @@ -8330,7 +8314,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw) } // FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu. - DC->drawText(xPos, parent->descY + iYadj, fDescScale, parent->descColor, textPtr, 0, parent->descTextStyle, MenuFontToReal(4)); //item->font); + DC->drawText(xPos, parent->descY + iYadj, fDescScale, parent->descColor, textPtr, 0, parent->descTextStyle, UI_MenuFontToReal(4)); //item->font); break; } } From 39096763d717bb7ce431f3438e088dfcf373339f Mon Sep 17 00:00:00 2001 From: Daggolin Date: Sun, 7 Apr 2024 02:26:01 +0200 Subject: [PATCH 796/801] [Shared] Fix CFontInfo::m_isVariant not getting initialized for non-variant fonts. This fixes r_reloadfonts in SP. --- code/rd-common/tr_font.cpp | 1 + codemp/rd-common/tr_font.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/code/rd-common/tr_font.cpp b/code/rd-common/tr_font.cpp index f968fdb89d..253d58fd51 100644 --- a/code/rd-common/tr_font.cpp +++ b/code/rd-common/tr_font.cpp @@ -1019,6 +1019,7 @@ CFontInfo::CFontInfo(const char *_fontName) m_fAltSBCSFontScaleFactor = -1; #endif m_bIsFakeAlienLanguage = !strcmp(_fontName,"aurabesh"); // dont try and make SBCS or asian overrides for this + m_isVariant = qfalse; len = ri.FS_ReadFile(fontName, NULL); if (len == sizeof(dfontdat_t)) diff --git a/codemp/rd-common/tr_font.cpp b/codemp/rd-common/tr_font.cpp index 956e182f75..20f3ce8894 100644 --- a/codemp/rd-common/tr_font.cpp +++ b/codemp/rd-common/tr_font.cpp @@ -882,6 +882,7 @@ CFontInfo::CFontInfo(const char *_fontName) m_iOriginalFontWhenSBCSOverriden = -1; m_fAltSBCSFontScaleFactor = -1; m_bIsFakeAlienLanguage = !strcmp(_fontName,"aurabesh"); // dont try and make SBCS or asian overrides for this + m_isVariant = qfalse; len = ri.FS_ReadFile(fontName, NULL); if (len == sizeof(dfontdat_t)) From 3f4ca6bf50a2448966e4f88b11584d61250b6e43 Mon Sep 17 00:00:00 2001 From: fau Date: Wed, 1 May 2024 13:51:54 +0200 Subject: [PATCH 797/801] Fix opengl context leak on vid_restart (causing thread, memory and other resource leaks) SDL opengl context must be destroyed before destroying its window and also before SDL_QuitSubSystem(SDL_INIT_VIDEO) to prevent leaks --- shared/sdl/sdl_window.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shared/sdl/sdl_window.cpp b/shared/sdl/sdl_window.cpp index 5fa0f8b623..8ff66a8e4b 100644 --- a/shared/sdl/sdl_window.cpp +++ b/shared/sdl/sdl_window.cpp @@ -810,8 +810,17 @@ void WIN_Shutdown( void ) IN_Shutdown(); + if ( opengl_context ) { + SDL_GL_DeleteContext( opengl_context ); + opengl_context = NULL; + } + + if ( screen ) { + SDL_DestroyWindow( screen ); + screen = NULL; + } + SDL_QuitSubSystem( SDL_INIT_VIDEO ); - screen = NULL; } void GLimp_EnableLogging( qboolean enable ) From a84dcc84e88632dfe70fae95338fe5479b6f3fc8 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 20 Jun 2024 09:03:36 -0500 Subject: [PATCH 798/801] Fix setting wrong servertime on mapchange with active clients --- codemp/server/sv_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/server/sv_init.cpp b/codemp/server/sv_init.cpp index be62b91bf1..cc1728f2da 100644 --- a/codemp/server/sv_init.cpp +++ b/codemp/server/sv_init.cpp @@ -568,7 +568,7 @@ Ghoul2 Insert End for (i=0 ; iinteger ; i++) { // save when the server started for each client already connected if (svs.clients[i].state >= CS_CONNECTED) { - svs.clients[i].oldServerTime = svs.time; + svs.clients[i].oldServerTime = sv.time; } } From 414ebc59e0aa79cd43fe5ee983204dc18d8115ec Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 20 Jun 2024 09:18:20 -0500 Subject: [PATCH 799/801] Check netadr by const pointer instead of by value Not as beneficial with only ipv4 but once the netadr struct expands for ipv6 it will be more beneficial performance. --- codemp/client/cl_input.cpp | 2 +- codemp/client/cl_lan.cpp | 14 ++--- codemp/client/cl_main.cpp | 110 ++++++++++++++++----------------- codemp/client/client.h | 2 +- codemp/qcommon/common.cpp | 6 +- codemp/qcommon/net_chan.cpp | 87 +++++++++++++------------- codemp/qcommon/net_ip.cpp | 36 +++++------ codemp/qcommon/qcommon.h | 30 ++++----- codemp/server/server.h | 12 ++-- codemp/server/sv_ccmds.cpp | 34 +++++----- codemp/server/sv_challenge.cpp | 6 +- codemp/server/sv_client.cpp | 26 ++++---- codemp/server/sv_main.cpp | 52 ++++++++-------- codemp/server/sv_snapshot.cpp | 2 +- shared/sys/sys_public.h | 4 +- 15 files changed, 210 insertions(+), 213 deletions(-) diff --git a/codemp/client/cl_input.cpp b/codemp/client/cl_input.cpp index 647efee0f8..5fbb500d0f 100644 --- a/codemp/client/cl_input.cpp +++ b/codemp/client/cl_input.cpp @@ -1451,7 +1451,7 @@ qboolean CL_ReadyToSendPacket( void ) { } // send every frame for LAN - if ( cl_lanForcePackets->integer && Sys_IsLANAddress( clc.netchan.remoteAddress ) ) { + if ( cl_lanForcePackets->integer && Sys_IsLANAddress( &clc.netchan.remoteAddress ) ) { return qtrue; } diff --git a/codemp/client/cl_lan.cpp b/codemp/client/cl_lan.cpp index b530cb1991..fd574b360b 100644 --- a/codemp/client/cl_lan.cpp +++ b/codemp/client/cl_lan.cpp @@ -137,7 +137,7 @@ int LAN_AddServer(int source, const char *name, const char *address) { if (servers && *count < max) { NET_StringToAdr( address, &adr ); for ( i = 0; i < *count; i++ ) { - if (NET_CompareAdr(servers[i].adr, adr)) { + if (NET_CompareAdr(&servers[i].adr, &adr)) { break; } } @@ -164,7 +164,7 @@ int LAN_AddFavAddr( const char *address ) { } for ( int i = 0; i < cls.numfavoriteservers; i++ ) { - if ( NET_CompareAdr( cls.favoriteServers[i].adr, adr ) ) { + if ( NET_CompareAdr( &cls.favoriteServers[i].adr, &adr ) ) { return 0; } } @@ -207,7 +207,7 @@ void LAN_RemoveServer(int source, const char *addr) { netadr_t comp; NET_StringToAdr( addr, &comp ); for (i = 0; i < *count; i++) { - if (NET_CompareAdr( comp, servers[i].adr)) { + if (NET_CompareAdr( &comp, &servers[i].adr)) { int j = i; while (j < *count - 1) { Com_Memcpy(&servers[j], &servers[j+1], sizeof(servers[j])); @@ -251,20 +251,20 @@ void LAN_GetServerAddressString( int source, int n, char *buf, int buflen ) { switch (source) { case AS_LOCAL : if (n >= 0 && n < MAX_OTHER_SERVERS) { - Q_strncpyz(buf, NET_AdrToString( cls.localServers[n].adr) , buflen ); + Q_strncpyz(buf, NET_AdrToString( &cls.localServers[n].adr) , buflen ); return; } break; case AS_MPLAYER: case AS_GLOBAL : if (n >= 0 && n < MAX_GLOBAL_SERVERS) { - Q_strncpyz(buf, NET_AdrToString( cls.globalServers[n].adr) , buflen ); + Q_strncpyz(buf, NET_AdrToString( &cls.globalServers[n].adr) , buflen ); return; } break; case AS_FAVORITES : if (n >= 0 && n < MAX_OTHER_SERVERS) { - Q_strncpyz(buf, NET_AdrToString( cls.favoriteServers[n].adr) , buflen ); + Q_strncpyz(buf, NET_AdrToString( &cls.favoriteServers[n].adr) , buflen ); return; } break; @@ -315,7 +315,7 @@ void LAN_GetServerInfo( int source, int n, char *buf, int buflen ) { Info_SetValueForKey( info, "fdisable", va("%i", server->forceDisable ) ); Info_SetValueForKey( info, "game", server->game); Info_SetValueForKey( info, "gametype", va("%i",server->gameType)); - Info_SetValueForKey( info, "addr", NET_AdrToString(server->adr)); + Info_SetValueForKey( info, "addr", NET_AdrToString(&server->adr)); Info_SetValueForKey( info, "g_humanplayers", va( "%i", server->humans ) ); Info_SetValueForKey( info, "bots", va( "%i", server->bots ) ); // Info_SetValueForKey( info, "sv_allowAnonymous", va("%i", server->allowAnonymous)); diff --git a/codemp/client/cl_main.cpp b/codemp/client/cl_main.cpp index 0a3ac54269..0eff37d9bf 100644 --- a/codemp/client/cl_main.cpp +++ b/codemp/client/cl_main.cpp @@ -148,7 +148,7 @@ extern void SV_BotFrame( int time ); void CL_CheckForResend( void ); void CL_ShowIP_f(void); void CL_ServerStatus_f(void); -void CL_ServerStatusResponse( netadr_t from, msg_t *msg ); +void CL_ServerStatusResponse( const netadr_t *from, msg_t *msg ); static void CL_ShutdownRef( qboolean restarting ); /* @@ -297,7 +297,7 @@ void CL_Record_f( void ) { } // sync 0 doesn't prevent recording, so not forcing it off .. everyone does g_sync 1 ; record ; g_sync 0 .. - if ( NET_IsLocalAddress( clc.serverAddress ) && !Cvar_VariableValue( "g_synchronousClients" ) ) { + if ( NET_IsLocalAddress( &clc.serverAddress ) && !Cvar_VariableValue( "g_synchronousClients" ) ) { Com_Printf (S_COLOR_YELLOW "WARNING: You should set 'g_synchronousClients 1' for smoother demo recording\n"); } @@ -914,7 +914,7 @@ void CL_RequestMotd( void ) { to.type = NA_IP; to.port = BigShort( PORT_UPDATE ); - Com_Printf( "Requesting motd from update %s (%s)...\n", motdaddress, NET_AdrToString( to ) ); + Com_Printf( "Requesting motd from update %s (%s)...\n", motdaddress, NET_AdrToString( &to ) ); cls.updateServer = to; @@ -940,7 +940,7 @@ void CL_RequestMotd( void ) { Info_SetValueForKey( info, "joystick", Cvar_VariableString("in_joystick") ); Info_SetValueForKey( info, "colorbits", va("%d",cls.glconfig.colorBits) ); - NET_OutOfBandPrint( NS_CLIENT, cls.updateServer, "getmotd \"%s\"\n", info ); + NET_OutOfBandPrint( NS_CLIENT, &cls.updateServer, "getmotd \"%s\"\n", info ); } @@ -1049,7 +1049,7 @@ void CL_Connect_f( void ) { clc.serverAddress.port = BigShort( PORT_SERVER ); } - serverString = NET_AdrToString(clc.serverAddress); + serverString = NET_AdrToString(&clc.serverAddress); Com_Printf( "%s resolved to %s\n", cls.servername, serverString ); @@ -1059,7 +1059,7 @@ void CL_Connect_f( void ) { CL_UpdateGUID( NULL, 0 ); // if we aren't playing on a lan, we need to authenticate - if ( NET_IsLocalAddress( clc.serverAddress ) ) { + if ( NET_IsLocalAddress( &clc.serverAddress ) ) { cls.state = CA_CHALLENGING; } else { cls.state = CA_CONNECTING; @@ -1142,7 +1142,7 @@ void CL_Rcon_f( void ) { } } - NET_SendPacket (NS_CLIENT, strlen(message)+1, message, rcon_address); + NET_SendPacket (NS_CLIENT, strlen(message)+1, message, &rcon_address); } /* @@ -1600,7 +1600,7 @@ void CL_CheckForResend( void ) { // The challenge request shall be followed by a client challenge so no malicious server can hijack this connection. Com_sprintf(data, sizeof(data), "getchallenge %d", clc.challenge); - NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, data); + NET_OutOfBandPrint(NS_CLIENT, &clc.serverAddress, data); break; case CA_CHALLENGING: @@ -1613,7 +1613,7 @@ void CL_CheckForResend( void ) { Info_SetValueForKey( info, "challenge", va("%i", clc.challenge ) ); Com_sprintf(data, sizeof(data), "connect \"%s\"", info ); - NET_OutOfBandData( NS_CLIENT, clc.serverAddress, (byte *)data, strlen(data) ); + NET_OutOfBandData( NS_CLIENT, &clc.serverAddress, (byte *)data, strlen(data) ); // the most current userinfo has been sent, so watch for any // newer changes to userinfo variables @@ -1636,13 +1636,13 @@ to the server, the server will send out of band disconnect packets to the client so it doesn't have to wait for the full timeout period. =================== */ -void CL_DisconnectPacket( netadr_t from ) { +void CL_DisconnectPacket( const netadr_t *from ) { if ( cls.state < CA_AUTHORIZING ) { return; } // if not from our server, ignore it - if ( !NET_CompareAdr( from, clc.netchan.remoteAddress ) ) { + if ( !NET_CompareAdr( from, &clc.netchan.remoteAddress ) ) { return; } @@ -1665,12 +1665,12 @@ CL_MotdPacket =================== */ -void CL_MotdPacket( netadr_t from ) { +void CL_MotdPacket( const netadr_t *from ) { char *challenge; char *info; // if not from our server, ignore it - if ( !NET_CompareAdr( from, cls.updateServer ) ) { + if ( !NET_CompareAdr( from, &cls.updateServer ) ) { return; } @@ -1693,7 +1693,7 @@ void CL_MotdPacket( netadr_t from ) { CL_InitServerInfo =================== */ -void CL_InitServerInfo( serverInfo_t *server, netadr_t *address ) { +void CL_InitServerInfo( serverInfo_t *server, const netadr_t *address ) { server->adr = *address; server->clients = 0; server->hostName[0] = '\0'; @@ -1726,7 +1726,7 @@ void CL_ServersResponsePacket( const netadr_t *from, msg_t *msg ) { byte* buffptr; byte* buffend; - Com_Printf("CL_ServersResponsePacket from %s\n", NET_AdrToString( *from ) ); + Com_Printf("CL_ServersResponsePacket from %s\n", NET_AdrToString( from ) ); if (cls.numglobalservers == -1) { // state to detect lack of servers or lack of response @@ -1792,7 +1792,7 @@ void CL_ServersResponsePacket( const netadr_t *from, msg_t *msg ) { // We just avoid to add a server if it is still in the global servers list. for (j = 0; j < count; j++) { - if (NET_CompareAdr(cls.globalServers[j].adr, addresses[i])) + if (NET_CompareAdr(&cls.globalServers[j].adr, &addresses[i])) break; } @@ -1901,7 +1901,7 @@ CL_ConnectionlessPacket Responses to broadcasts, etc ================= */ -void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { +void CL_ConnectionlessPacket( const netadr_t *from, msg_t *msg ) { char *s; char *c; int challenge = 0; @@ -1932,7 +1932,7 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { if(*c) challenge = atoi(c); - if(!NET_CompareAdr(from, clc.serverAddress)) + if(!NET_CompareAdr(from, &clc.serverAddress)) { // This challenge response is not coming from the expected address. // Check whether we have a matching client challenge to prevent @@ -1953,7 +1953,7 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { // take this address as the new server address. This allows // a server proxy to hand off connections to multiple servers - clc.serverAddress = from; + clc.serverAddress = *from; Com_DPrintf ("challengeResponse: %d\n", clc.challenge); return; } @@ -1968,7 +1968,7 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { Com_Printf ("connectResponse packet while not connecting. Ignored.\n"); return; } - if ( !NET_CompareAdr( from, clc.serverAddress ) ) { + if ( !NET_CompareAdr( from, &clc.serverAddress ) ) { Com_Printf( "connectResponse from wrong address. Ignored.\n" ); return; } @@ -2019,7 +2019,7 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { if ( !Q_stricmp(c, "print") ) { // NOTE: we may have to add exceptions for auth and update servers - if (NET_CompareAdr(from, clc.serverAddress) || NET_CompareAdr(from, rcon_address)) + if (NET_CompareAdr(from, &clc.serverAddress) || NET_CompareAdr(from, &rcon_address)) { char sTemp[MAX_STRINGED_SV_STRING]; @@ -2033,7 +2033,7 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { // list of servers sent back by a master server (classic) if ( !Q_strncmp(c, "getserversResponse", 18) ) { - CL_ServersResponsePacket( &from, msg ); + CL_ServersResponsePacket( from, msg ); return; } @@ -2048,7 +2048,7 @@ CL_PacketEvent A packet has arrived from the main event loop ================= */ -void CL_PacketEvent( netadr_t from, msg_t *msg ) { +void CL_PacketEvent( const netadr_t *from, msg_t *msg ) { int headerBytes; clc.lastPacketTime = cls.realtime; @@ -2070,7 +2070,7 @@ void CL_PacketEvent( netadr_t from, msg_t *msg ) { // // packet from server // - if ( !NET_CompareAdr( from, clc.netchan.remoteAddress ) ) { + if ( !NET_CompareAdr( from, &clc.netchan.remoteAddress ) ) { if ( com_developer->integer ) { Com_Printf( "%s:sequenced packet without connection\n", NET_AdrToString( from ) ); @@ -2652,7 +2652,7 @@ static void CL_AddFavorite_f( void ) { return; } - const char *server = (argc == 2) ? Cmd_Argv( 1 ) : NET_AdrToString( clc.serverAddress ); + const char *server = (argc == 2) ? Cmd_Argv( 1 ) : NET_AdrToString( &clc.serverAddress ); const int status = LAN_AddFavAddr( server ); switch ( status ) { case -1: @@ -3007,23 +3007,23 @@ static void CL_SetServerInfo(serverInfo_t *server, const char *info, int ping) { } } -static void CL_SetServerInfoByAddress(netadr_t from, const char *info, int ping) { +static void CL_SetServerInfoByAddress(const netadr_t *from, const char *info, int ping) { int i; for (i = 0; i < MAX_OTHER_SERVERS; i++) { - if (NET_CompareAdr(from, cls.localServers[i].adr)) { + if (NET_CompareAdr(from, &cls.localServers[i].adr)) { CL_SetServerInfo(&cls.localServers[i], info, ping); } } for (i = 0; i < MAX_GLOBAL_SERVERS; i++) { - if (NET_CompareAdr(from, cls.globalServers[i].adr)) { + if (NET_CompareAdr(from, &cls.globalServers[i].adr)) { CL_SetServerInfo(&cls.globalServers[i], info, ping); } } for (i = 0; i < MAX_OTHER_SERVERS; i++) { - if (NET_CompareAdr(from, cls.favoriteServers[i].adr)) { + if (NET_CompareAdr(from, &cls.favoriteServers[i].adr)) { CL_SetServerInfo(&cls.favoriteServers[i], info, ping); } } @@ -3034,7 +3034,7 @@ static void CL_SetServerInfoByAddress(netadr_t from, const char *info, int ping) CL_ServerInfoPacket =================== */ -void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { +void CL_ServerInfoPacket( const netadr_t *from, msg_t *msg ) { int i, type; char info[MAX_INFO_STRING]; char *infoString; @@ -3069,7 +3069,7 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { // iterate servers waiting for ping response for (i=0; itype) { case NA_BROADCAST: case NA_IP: @@ -3112,7 +3112,7 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { } // avoid duplicate - if ( NET_CompareAdr( from, cls.localServers[i].adr ) ) { + if ( NET_CompareAdr( from, &cls.localServers[i].adr ) ) { return; } } @@ -3124,7 +3124,7 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { // add this to the list cls.numlocalservers = i+1; - CL_InitServerInfo( &cls.localServers[i], &from ); + CL_InitServerInfo( &cls.localServers[i], from ); Q_strncpyz( info, MSG_ReadString( msg ), MAX_INFO_STRING ); if (strlen(info)) { @@ -3140,11 +3140,11 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { CL_GetServerStatus =================== */ -serverStatus_t *CL_GetServerStatus( netadr_t from ) { +serverStatus_t *CL_GetServerStatus( const netadr_t *from ) { int i, oldest, oldestTime; for (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) { - if ( NET_CompareAdr( from, cl_serverStatusList[i].address ) ) { + if ( NET_CompareAdr( from, &cl_serverStatusList[i].address ) ) { return &cl_serverStatusList[i]; } } @@ -3190,7 +3190,7 @@ int CL_ServerStatus( const char *serverAddress, char *serverStatusString, int ma if ( !NET_StringToAdr( serverAddress, &to ) ) { return qfalse; } - serverStatus = CL_GetServerStatus( to ); + serverStatus = CL_GetServerStatus( &to ); // if no server status string then reset the server status request for this address if ( !serverStatusString ) { serverStatus->retrieved = qtrue; @@ -3198,7 +3198,7 @@ int CL_ServerStatus( const char *serverAddress, char *serverStatusString, int ma } // if this server status request has the same address - if ( NET_CompareAdr( to, serverStatus->address) ) { + if ( NET_CompareAdr( &to, &serverStatus->address) ) { // if we received a response for this server status request if (!serverStatus->pending) { Q_strncpyz(serverStatusString, serverStatus->string, maxLen); @@ -3213,7 +3213,7 @@ int CL_ServerStatus( const char *serverAddress, char *serverStatusString, int ma serverStatus->retrieved = qfalse; serverStatus->time = 0; serverStatus->startTime = Com_Milliseconds(); - NET_OutOfBandPrint( NS_CLIENT, to, "getstatus" ); + NET_OutOfBandPrint( NS_CLIENT, &to, "getstatus" ); return qfalse; } } @@ -3225,7 +3225,7 @@ int CL_ServerStatus( const char *serverAddress, char *serverStatusString, int ma serverStatus->retrieved = qfalse; serverStatus->startTime = Com_Milliseconds(); serverStatus->time = 0; - NET_OutOfBandPrint( NS_CLIENT, to, "getstatus" ); + NET_OutOfBandPrint( NS_CLIENT, &to, "getstatus" ); return qfalse; } return qfalse; @@ -3236,7 +3236,7 @@ int CL_ServerStatus( const char *serverAddress, char *serverStatusString, int ma CL_ServerStatusResponse =================== */ -void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) { +void CL_ServerStatusResponse( const netadr_t *from, msg_t *msg ) { char *s; char info[MAX_INFO_STRING]; int i, l, score, ping; @@ -3245,7 +3245,7 @@ void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) { serverStatus = NULL; for (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) { - if ( NET_CompareAdr( from, cl_serverStatusList[i].address ) ) { + if ( NET_CompareAdr( from, &cl_serverStatusList[i].address ) ) { serverStatus = &cl_serverStatusList[i]; break; } @@ -3262,7 +3262,7 @@ void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) { if (serverStatus->print) { Com_Printf( "Server (%s)\n", - NET_AdrToString( serverStatus->address ) ); + NET_AdrToString( &serverStatus->address ) ); Com_Printf("Server settings:\n"); // print cvars while (*s) { @@ -3319,7 +3319,7 @@ void CL_ServerStatusResponse( netadr_t from, msg_t *msg ) { Com_sprintf(&serverStatus->string[len], sizeof(serverStatus->string)-len, "\\"); serverStatus->time = Com_Milliseconds(); - serverStatus->address = from; + serverStatus->address = *from; serverStatus->pending = qfalse; if (serverStatus->print) { serverStatus->retrieved = qtrue; @@ -3363,7 +3363,7 @@ void CL_LocalServers_f( void ) { to.port = BigShort( (short)(PORT_SERVER + j) ); to.type = NA_BROADCAST; - NET_SendPacket( NS_CLIENT, strlen( message ), message, to ); + NET_SendPacket( NS_CLIENT, strlen( message ), message, &to ); } } } @@ -3436,7 +3436,7 @@ void CL_GlobalServers_f( void ) { to.type = NA_IP; to.port = BigShort(PORT_MASTER); - Com_Printf( "Requesting servers from the master %s (%s)...\n", masteraddress, NET_AdrToString( to ) ); + Com_Printf( "Requesting servers from the master %s (%s)...\n", masteraddress, NET_AdrToString( &to ) ); cls.numglobalservers = -1; cls.pingUpdateSource = AS_GLOBAL; @@ -3450,7 +3450,7 @@ void CL_GlobalServers_f( void ) { Q_strcat(command, sizeof(command), Cmd_Argv(i)); } - NET_OutOfBandPrint( NS_SERVER, to, "%s", command ); + NET_OutOfBandPrint( NS_SERVER, &to, "%s", command ); } /* @@ -3472,7 +3472,7 @@ void CL_GetPing( int n, char *buf, int buflen, int *pingtime ) return; } - str = NET_AdrToString( cl_pinglist[n].adr ); + str = NET_AdrToString( &cl_pinglist[n].adr ); Q_strncpyz( buf, str, buflen ); time = cl_pinglist[n].time; @@ -3491,7 +3491,7 @@ void CL_GetPing( int n, char *buf, int buflen, int *pingtime ) } } - CL_SetServerInfoByAddress(cl_pinglist[n].adr, cl_pinglist[n].info, cl_pinglist[n].time); + CL_SetServerInfoByAddress(&cl_pinglist[n].adr, cl_pinglist[n].info, cl_pinglist[n].time); *pingtime = time; } @@ -3636,9 +3636,9 @@ void CL_Ping_f( void ) { pingptr->start = Sys_Milliseconds(); pingptr->time = 0; - CL_SetServerInfoByAddress(pingptr->adr, NULL, 0); + CL_SetServerInfoByAddress(&pingptr->adr, NULL, 0); - NET_OutOfBandPrint( NS_CLIENT, to, "getinfo xxx" ); + NET_OutOfBandPrint( NS_CLIENT, &to, "getinfo xxx" ); } /* @@ -3691,7 +3691,7 @@ qboolean CL_UpdateVisiblePings_f(int source) { if (!cl_pinglist[j].adr.port) { continue; } - if (NET_CompareAdr( cl_pinglist[j].adr, server[i].adr)) { + if (NET_CompareAdr( &cl_pinglist[j].adr, &server[i].adr)) { // already on the list break; } @@ -3706,7 +3706,7 @@ qboolean CL_UpdateVisiblePings_f(int source) { memcpy(&cl_pinglist[j].adr, &server[i].adr, sizeof(netadr_t)); cl_pinglist[j].start = Sys_Milliseconds(); cl_pinglist[j].time = 0; - NET_OutOfBandPrint( NS_CLIENT, cl_pinglist[j].adr, "getinfo xxx" ); + NET_OutOfBandPrint( NS_CLIENT, &cl_pinglist[j].adr, "getinfo xxx" ); slots++; } } @@ -3776,9 +3776,9 @@ void CL_ServerStatus_f(void) { return; } - NET_OutOfBandPrint( NS_CLIENT, *toptr, "getstatus" ); + NET_OutOfBandPrint( NS_CLIENT, toptr, "getstatus" ); - serverStatus = CL_GetServerStatus( *toptr ); + serverStatus = CL_GetServerStatus( toptr ); serverStatus->address = *toptr; serverStatus->print = qtrue; serverStatus->pending = qtrue; diff --git a/codemp/client/client.h b/codemp/client/client.h index ced59fcf44..4f2cf54097 100644 --- a/codemp/client/client.h +++ b/codemp/client/client.h @@ -519,7 +519,7 @@ void CL_ParseServerMessage( msg_t *msg ); //==================================================================== -void CL_ServerInfoPacket( netadr_t from, msg_t *msg ); +void CL_ServerInfoPacket( const netadr_t *from, msg_t *msg ); void CL_LocalServers_f( void ); void CL_GlobalServers_f( void ); void CL_FavoriteServers_f( void ); diff --git a/codemp/qcommon/common.cpp b/codemp/qcommon/common.cpp index 4b84c4d141..d4609a1fdd 100644 --- a/codemp/qcommon/common.cpp +++ b/codemp/qcommon/common.cpp @@ -868,7 +868,7 @@ sysEvent_t Com_GetEvent( void ) { Com_RunAndTimeServerPacket ================= */ -void Com_RunAndTimeServerPacket( netadr_t *evFrom, msg_t *buf ) { +void Com_RunAndTimeServerPacket( const netadr_t *evFrom, msg_t *buf ) { int t1, t2, msec; t1 = 0; @@ -877,7 +877,7 @@ void Com_RunAndTimeServerPacket( netadr_t *evFrom, msg_t *buf ) { t1 = Sys_Milliseconds (); } - SV_PacketEvent( *evFrom, buf ); + SV_PacketEvent( evFrom, buf ); if ( com_speeds->integer ) { t2 = Sys_Milliseconds (); @@ -910,7 +910,7 @@ int Com_EventLoop( void ) { if ( ev.evType == SE_NONE ) { // manually send packet events for the loopback channel while ( NET_GetLoopPacket( NS_CLIENT, &evFrom, &buf ) ) { - CL_PacketEvent( evFrom, &buf ); + CL_PacketEvent( &evFrom, &buf ); } while ( NET_GetLoopPacket( NS_SERVER, &evFrom, &buf ) ) { diff --git a/codemp/qcommon/net_chan.cpp b/codemp/qcommon/net_chan.cpp index 69ee3ed5cf..0741c81833 100644 --- a/codemp/qcommon/net_chan.cpp +++ b/codemp/qcommon/net_chan.cpp @@ -82,11 +82,11 @@ Netchan_Setup called to open a channel to a remote system ============== */ -void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport ) { +void Netchan_Setup( netsrc_t sock, netchan_t *chan, const netadr_t *adr, int qport ) { Com_Memset (chan, 0, sizeof(*chan)); chan->sock = sock; - chan->remoteAddress = adr; + chan->remoteAddress = *adr; chan->qport = qport; chan->incomingSequence = 0; chan->outgoingSequence = 1; @@ -125,7 +125,7 @@ void Netchan_TransmitNextFragment( netchan_t *chan ) { MSG_WriteData( &send, chan->unsentBuffer + chan->unsentFragmentStart, fragmentLength ); // send the datagram - NET_SendPacket( chan->sock, send.cursize, send.data, chan->remoteAddress ); + NET_SendPacket( chan->sock, send.cursize, send.data, &chan->remoteAddress ); if ( showpackets->integer ) { Com_Printf ("%s send %4i : s=%i fragment=%i,%i\n" @@ -196,7 +196,7 @@ void Netchan_Transmit( netchan_t *chan, int length, const byte *data ) { MSG_WriteData( &send, data, length ); // send the datagram - NET_SendPacket( chan->sock, send.cursize, send.data, chan->remoteAddress ); + NET_SendPacket( chan->sock, send.cursize, send.data, &chan->remoteAddress ); if ( showpackets->integer ) { Com_Printf( "%s send %4i : s=%i ack=%i\n" @@ -272,7 +272,7 @@ qboolean Netchan_Process( netchan_t *chan, msg_t *msg ) { if ( sequence <= chan->incomingSequence ) { if ( showdrop->integer || showpackets->integer ) { Com_Printf( "%s:Out of order packet %i at %i\n" - , NET_AdrToString( chan->remoteAddress ) + , NET_AdrToString( &chan->remoteAddress ) , sequence , chan->incomingSequence ); } @@ -286,7 +286,7 @@ qboolean Netchan_Process( netchan_t *chan, msg_t *msg ) { if ( chan->dropped > 0 ) { if ( showdrop->integer || showpackets->integer ) { Com_Printf( "%s:Dropped %i packets at %i\n" - , NET_AdrToString( chan->remoteAddress ) + , NET_AdrToString( &chan->remoteAddress ) , chan->dropped , sequence ); } @@ -308,7 +308,7 @@ qboolean Netchan_Process( netchan_t *chan, msg_t *msg ) { if ( fragmentStart != chan->fragmentLength ) { if ( showdrop->integer || showpackets->integer ) { Com_Printf( "%s:Dropped a message fragment\n" - , NET_AdrToString( chan->remoteAddress ) + , NET_AdrToString( &chan->remoteAddress ) , sequence); } // we can still keep the part that we have so far, @@ -333,7 +333,7 @@ qboolean Netchan_Process( netchan_t *chan, msg_t *msg ) { chan->fragmentLength + fragmentLength > (int)sizeof( chan->fragmentBuffer ) ) { if ( showdrop->integer || showpackets->integer ) { Com_Printf ("%s:illegal fragment length\n" - , NET_AdrToString (chan->remoteAddress ) ); + , NET_AdrToString (&chan->remoteAddress ) ); } return qfalse; } @@ -350,7 +350,7 @@ qboolean Netchan_Process( netchan_t *chan, msg_t *msg ) { if ( chan->fragmentLength+4 > msg->maxsize ) { Com_Printf( "%s:fragmentLength %i > msg->maxsize\n" - , NET_AdrToString (chan->remoteAddress ), + , NET_AdrToString (&chan->remoteAddress ), chan->fragmentLength+4 ); return qfalse; } @@ -389,28 +389,28 @@ NET_CompareBaseAdrMask Compare without port, and up to the bit number given in netmask. =================== */ -qboolean NET_CompareBaseAdrMask( netadr_t a, netadr_t b, int netmask ) +qboolean NET_CompareBaseAdrMask( const netadr_t *a, const netadr_t *b, unsigned int netmask ) { byte cmpmask, *addra, *addrb; int curbyte; - if ( a.type != b.type ) + if ( a->type != b->type ) return qfalse; - if ( a.type == NA_LOOPBACK ) + if ( a->type == NA_LOOPBACK ) return qtrue; - if ( a.type == NA_IP ) + if ( a->type == NA_IP ) { - addra = (byte *)&a.ip; - addrb = (byte *)&b.ip; + addra = (byte *)&a->ip; + addrb = (byte *)&b->ip; - if ( netmask < 0 || netmask > 32 ) + if ( netmask > 32 ) netmask = 32; } else { - Com_Printf( "NET_CompareBaseAdr: bad address type\n" ); + Com_Printf( "%s: bad address type\n", __func__ ); return qfalse; } @@ -441,23 +441,23 @@ NET_CompareBaseAdr Compares without the port =================== */ -qboolean NET_CompareBaseAdr( netadr_t a, netadr_t b ) +qboolean NET_CompareBaseAdr( const netadr_t *a, const netadr_t *b ) { - return NET_CompareBaseAdrMask( a, b, -1 ); + return NET_CompareBaseAdrMask( a, b, ~0U ); } -const char *NET_AdrToString (netadr_t a) +const char *NET_AdrToString (const netadr_t *a) { - static char s[64]; + static char s[NET_ADDRSTRMAXLEN]; - if (a.type == NA_LOOPBACK) { + if (a->type == NA_LOOPBACK) { Com_sprintf (s, sizeof(s), "loopback"); - } else if (a.type == NA_BOT) { + } else if (a->type == NA_BOT) { Com_sprintf (s, sizeof(s), "bot"); - } else if (a.type == NA_IP) { + } else if (a->type == NA_IP) { Com_sprintf (s, sizeof(s), "%i.%i.%i.%i:%hu", - a.ip[0], a.ip[1], a.ip[2], a.ip[3], BigShort(a.port)); - } else if (a.type == NA_BAD) { + a->ip[0], a->ip[1], a->ip[2], a->ip[3], BigShort(a->port)); + } else if (a->type == NA_BAD) { Com_sprintf (s, sizeof(s), "BAD"); } @@ -465,28 +465,25 @@ const char *NET_AdrToString (netadr_t a) } -qboolean NET_CompareAdr (netadr_t a, netadr_t b) +qboolean NET_CompareAdr (const netadr_t *a, const netadr_t *b) { - if (a.type != b.type) + if (!NET_CompareBaseAdr(a, b)) return qfalse; - if (a.type == NA_LOOPBACK) - return qtrue; - - if (a.type == NA_IP) + if (a->type == NA_IP) { - if ((memcmp(a.ip, b.ip, 4) == 0) && a.port == b.port) + if (a->port == b->port) return qtrue; - return qfalse; } + else + return qtrue; - Com_Printf ("NET_CompareAdr: bad address type\n"); return qfalse; } -qboolean NET_IsLocalAddress( netadr_t adr ) { - return (qboolean)(adr.type == NA_LOOPBACK); +qboolean NET_IsLocalAddress( const netadr_t *adr ) { + return adr->type == NA_LOOPBACK ? qtrue : qfalse; } @@ -541,7 +538,7 @@ qboolean NET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, msg_t *net_messag } -void NET_SendLoopPacket (netsrc_t sock, int length, const void *data, netadr_t to) +void NET_SendLoopPacket (netsrc_t sock, int length, const void *data) { int i; loopback_t *loop; @@ -558,21 +555,21 @@ void NET_SendLoopPacket (netsrc_t sock, int length, const void *data, netadr_t t //============================================================================= -void NET_SendPacket( netsrc_t sock, int length, const void *data, netadr_t to ) { +void NET_SendPacket( netsrc_t sock, int length, const void *data, const netadr_t *to ) { // sequenced packets are shown in netchan, so just show oob if ( showpackets->integer && *(int *)data == -1 ) { Com_Printf ("send packet %4i\n", length); } - if ( to.type == NA_LOOPBACK ) { - NET_SendLoopPacket (sock, length, data, to); + if ( to->type == NA_LOOPBACK ) { + NET_SendLoopPacket (sock, length, data); return; } - if ( to.type == NA_BOT ) { + if ( to->type == NA_BOT ) { return; } - if ( to.type == NA_BAD ) { + if ( to->type == NA_BAD ) { return; } @@ -586,7 +583,7 @@ NET_OutOfBandPrint Sends a text message in an out-of-band datagram ================ */ -void QDECL NET_OutOfBandPrint( netsrc_t sock, netadr_t adr, const char *format, ... ) { +void QDECL NET_OutOfBandPrint( netsrc_t sock, const netadr_t *adr, const char *format, ... ) { va_list argptr; char string[MAX_MSGLEN]; @@ -612,7 +609,7 @@ NET_OutOfBandPrint Sends a data message in an out-of-band datagram (only used for "connect") ================ */ -void QDECL NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len ) { +void QDECL NET_OutOfBandData( netsrc_t sock, const netadr_t *adr, byte *format, int len ) { byte string[MAX_MSGLEN*2]; int i; msg_t mbuf; diff --git a/codemp/qcommon/net_ip.cpp b/codemp/qcommon/net_ip.cpp index bf72ebcc9e..889969a9b0 100644 --- a/codemp/qcommon/net_ip.cpp +++ b/codemp/qcommon/net_ip.cpp @@ -168,7 +168,7 @@ char *NET_ErrorString( void ) { #endif } -static void NetadrToSockadr( netadr_t *a, struct sockaddr_in *s ) { +static void NetadrToSockadr( const netadr_t *a, struct sockaddr_in *s ) { memset( s, 0, sizeof(*s) ); if( a->type == NA_BROADCAST ) { @@ -292,7 +292,7 @@ qboolean NET_GetPacket( netadr_t *net_from, msg_t *net_message, fd_set *fdr ) { } if( ret >= net_message->maxsize ) { - Com_Printf( "Oversize packet from %s\n", NET_AdrToString (*net_from) ); + Com_Printf( "Oversize packet from %s\n", NET_AdrToString (net_from) ); return qfalse; } @@ -309,11 +309,11 @@ static char socksBuf[4096]; Sys_SendPacket ================== */ -void Sys_SendPacket( int length, const void *data, netadr_t to ) { +void Sys_SendPacket( int length, const void *data, const netadr_t *to ) { int ret; struct sockaddr_in addr; - if ( to.type != NA_BROADCAST && to.type != NA_IP ) { + if ( to->type != NA_BROADCAST && to->type != NA_IP ) { Com_Error( ERR_FATAL, "Sys_SendPacket: bad address type" ); return; } @@ -322,9 +322,9 @@ void Sys_SendPacket( int length, const void *data, netadr_t to ) { return; } - NetadrToSockadr( &to, &addr ); + NetadrToSockadr( to, &addr ); - if( usingSocks && to.type == NA_IP ) { + if( usingSocks && to->type == NA_IP ) { socksBuf[0] = 0; // reserved socksBuf[1] = 0; socksBuf[2] = 0; // fragment (not fragmented) @@ -346,7 +346,7 @@ void Sys_SendPacket( int length, const void *data, netadr_t to ) { } // some PPP links do not allow broadcasts and return an error - if( err == EADDRNOTAVAIL && to.type == NA_BROADCAST ) { + if( err == EADDRNOTAVAIL && to->type == NA_BROADCAST ) { return; } @@ -363,31 +363,31 @@ Sys_IsLANAddress LAN clients will have their rate var ignored ================== */ -qboolean Sys_IsLANAddress( netadr_t adr ) { +qboolean Sys_IsLANAddress( const netadr_t *adr ) { if ( !net_forcenonlocal ) net_forcenonlocal = Cvar_Get( "net_forcenonlocal", "0", 0 ); if ( net_forcenonlocal && net_forcenonlocal->integer ) return qfalse; - if( adr.type == NA_LOOPBACK ) + if( adr->type == NA_LOOPBACK ) return qtrue; - if( adr.type != NA_IP ) + if( adr->type != NA_IP ) return qfalse; // RFC1918: // 10.0.0.0 - 10.255.255.255 (10/8 prefix) // 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) // 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) - if ( adr.ip[0] == 10 ) + if ( adr->ip[0] == 10 ) return qtrue; - if ( adr.ip[0] == 172 && (adr.ip[1]&0xf0) == 16 ) + if ( adr->ip[0] == 172 && (adr->ip[1]&0xf0) == 16 ) return qtrue; - if ( adr.ip[0] == 192 && adr.ip[1] == 168 ) + if ( adr->ip[0] == 192 && adr->ip[1] == 168 ) return qtrue; - if ( adr.ip[0] == 127 ) + if ( adr->ip[0] == 127 ) return qtrue; // choose which comparison to use based on the class of the address being tested @@ -395,7 +395,7 @@ qboolean Sys_IsLANAddress( netadr_t adr ) { // Class C for ( int i=0; iip, localIP[i], 3 ) == 0 ) return qtrue; } return qfalse; @@ -418,7 +418,7 @@ void Sys_ShowIP(void) { NET_IPSocket ==================== */ -SOCKET NET_IPSocket( char *net_interface, int port, int *err ) { +static SOCKET NET_IPSocket( const char *net_interface, int port, int *err ) { SOCKET newsocket; struct sockaddr_in address; u_long _true = 1; @@ -468,7 +468,7 @@ SOCKET NET_IPSocket( char *net_interface, int port, int *err ) { address.sin_port = 0; } else { - address.sin_port = htons( port ); + address.sin_port = htons( (short)port ); } if( bind( newsocket, (const struct sockaddr *)&address, sizeof(address) ) == SOCKET_ERROR ) { @@ -1025,7 +1025,7 @@ void NET_Event(fd_set *fdr) if(com_sv_running->integer) Com_RunAndTimeServerPacket(&from, &netmsg); else - CL_PacketEvent(from, &netmsg); + CL_PacketEvent(&from, &netmsg); } else break; diff --git a/codemp/qcommon/qcommon.h b/codemp/qcommon/qcommon.h index 1b5c0324c9..92d6724f35 100644 --- a/codemp/qcommon/qcommon.h +++ b/codemp/qcommon/qcommon.h @@ -136,23 +136,23 @@ void NET_Shutdown( void ); void NET_Restart_f( void ); void NET_Config( qboolean enableNetworking ); -void NET_SendPacket (netsrc_t sock, int length, const void *data, netadr_t to); -void NET_OutOfBandPrint( netsrc_t net_socket, netadr_t adr, const char *format, ...); -void NET_OutOfBandData( netsrc_t sock, netadr_t adr, byte *format, int len ); - -qboolean NET_CompareAdr (netadr_t a, netadr_t b); -qboolean NET_CompareBaseAdrMask( netadr_t a, netadr_t b, int netmask ); -qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b); -qboolean NET_IsLocalAddress (netadr_t adr); -const char *NET_AdrToString (netadr_t a); +void NET_SendPacket (netsrc_t sock, int length, const void *data, const netadr_t *to); +void NET_OutOfBandPrint( netsrc_t net_socket, const netadr_t *adr, const char *format, ...); +void NET_OutOfBandData( netsrc_t sock, const netadr_t *adr, byte *format, int len ); + +qboolean NET_CompareAdr (const netadr_t *a, const netadr_t *b); +qboolean NET_CompareBaseAdrMask( const netadr_t *a, const netadr_t *b, unsigned int netmask ); +qboolean NET_CompareBaseAdr (const netadr_t *a, const netadr_t *b); +qboolean NET_IsLocalAddress (const netadr_t *adr); +const char *NET_AdrToString (const netadr_t *a); qboolean NET_StringToAdr ( const char *s, netadr_t *a); qboolean NET_GetLoopPacket (netsrc_t sock, netadr_t *net_from, msg_t *net_message); void NET_Sleep(int msec); -void Sys_SendPacket( int length, const void *data, netadr_t to ); +void Sys_SendPacket( int length, const void *data, const netadr_t *to ); //Does NOT parse port numbers, only base addresses. qboolean Sys_StringToAdr( const char *s, netadr_t *a ); -qboolean Sys_IsLANAddress (netadr_t adr); +qboolean Sys_IsLANAddress (const netadr_t *adr); void Sys_ShowIP(void); @@ -195,7 +195,7 @@ typedef struct netchan_s { } netchan_t; void Netchan_Init( int qport ); -void Netchan_Setup( netsrc_t sock, netchan_t *chan, netadr_t adr, int qport ); +void Netchan_Setup( netsrc_t sock, netchan_t *chan, const netadr_t *adr, int qport ); void Netchan_Transmit( netchan_t *chan, int length, const byte *data ); void Netchan_TransmitNextFragment( netchan_t *chan ); @@ -764,7 +764,7 @@ int Com_Filter(char *filter, char *name, int casesensitive); int Com_FilterPath(char *filter, char *name, int casesensitive); int Com_RealTime(qtime_t *qtime); qboolean Com_SafeMode( void ); -void Com_RunAndTimeServerPacket(netadr_t *evFrom, msg_t *buf); +void Com_RunAndTimeServerPacket(const netadr_t *evFrom, msg_t *buf); void Com_StartupVariable( const char *match ); // checks for and removes command line "+set var arg" constructs @@ -936,7 +936,7 @@ void CL_MouseEvent( int dx, int dy, int time ); void CL_JoystickEvent( int axis, int value, int time ); -void CL_PacketEvent( netadr_t from, msg_t *msg ); +void CL_PacketEvent( const netadr_t *from, msg_t *msg ); void CL_ConsolePrint( const char *text ); @@ -984,7 +984,7 @@ void SCR_DebugGraph (float value, int color); // FIXME: move logging to common? void SV_Init( void ); void SV_Shutdown( char *finalmsg ); void SV_Frame( int msec ); -void SV_PacketEvent( netadr_t from, msg_t *msg ); +void SV_PacketEvent( const netadr_t *from, msg_t *msg ); int SV_FrameMsec( void ); qboolean SV_GameCommand( void ); diff --git a/codemp/server/server.h b/codemp/server/server.h index 6a14f7d78d..6a049f92c7 100644 --- a/codemp/server/server.h +++ b/codemp/server/server.h @@ -294,9 +294,9 @@ struct leakyBucket_s { extern leakyBucket_t outboundLeakyBucket; qboolean SVC_RateLimit( leakyBucket_t *bucket, int burst, int period, int now ); -qboolean SVC_RateLimitAddress( netadr_t from, int burst, int period, int now ); +qboolean SVC_RateLimitAddress( const netadr_t *from, int burst, int period, int now ); void SVC_LoadWhitelist( void ); -void SVC_WhitelistAdr( netadr_t adr ); +void SVC_WhitelistAdr( const netadr_t *adr ); void SV_FinalMessage (char *message); void QDECL SV_SendServerCommand( client_t *cl, const char *fmt, ...); @@ -331,15 +331,15 @@ void SV_SpawnServer( char *server, qboolean killBots, ForceReload_e eForceReload // void SV_ChallengeInit(); void SV_ChallengeShutdown(); -int SV_CreateChallenge(netadr_t from); -qboolean SV_VerifyChallenge(int receivedChallenge, netadr_t from); +int SV_CreateChallenge(const netadr_t *from); +qboolean SV_VerifyChallenge(int receivedChallenge, const netadr_t *from); // // sv_client.c // -void SV_GetChallenge( netadr_t from ); +void SV_GetChallenge( const netadr_t *from ); -void SV_DirectConnect( netadr_t from ); +void SV_DirectConnect( const netadr_t *from ); void SV_SendClientMapChange( client_t *client ); void SV_ExecuteClientMessage( client_t *cl, msg_t *msg ); diff --git a/codemp/server/sv_ccmds.cpp b/codemp/server/sv_ccmds.cpp index 47c2deb879..466ba98177 100644 --- a/codemp/server/sv_ccmds.cpp +++ b/codemp/server/sv_ccmds.cpp @@ -682,7 +682,7 @@ static void SV_WriteBans( void ) curban = &serverBans[index]; Com_sprintf( writebuf, sizeof( writebuf ), "%d %s %d\n", - curban->isexception, NET_AdrToString( curban->ip ), curban->subnet ); + curban->isexception, NET_AdrToString( &curban->ip ), curban->subnet ); FS_Write( writebuf, strlen( writebuf ), writeto ); } @@ -847,24 +847,24 @@ static void SV_AddBanToList( qboolean isexception ) if ( curban->subnet <= mask ) { - if ( (curban->isexception || !isexception) && NET_CompareBaseAdrMask( curban->ip, ip, curban->subnet ) ) + if ( (curban->isexception || !isexception) && NET_CompareBaseAdrMask( &curban->ip, &ip, curban->subnet ) ) { - Q_strncpyz( addy2, NET_AdrToString( ip ), sizeof( addy2 ) ); + Q_strncpyz( addy2, NET_AdrToString( &ip ), sizeof( addy2 ) ); Com_Printf( "Error: %s %s/%d supersedes %s %s/%d\n", curban->isexception ? "Exception" : "Ban", - NET_AdrToString( curban->ip ), curban->subnet, + NET_AdrToString( &curban->ip ), curban->subnet, isexception ? "exception" : "ban", addy2, mask ); return; } } if ( curban->subnet >= mask ) { - if ( !curban->isexception && isexception && NET_CompareBaseAdrMask( curban->ip, ip, mask ) ) + if ( !curban->isexception && isexception && NET_CompareBaseAdrMask( &curban->ip, &ip, mask ) ) { - Q_strncpyz( addy2, NET_AdrToString( curban->ip ), sizeof( addy2 ) ); + Q_strncpyz( addy2, NET_AdrToString( &curban->ip ), sizeof( addy2 ) ); Com_Printf( "Error: %s %s/%d supersedes already existing %s %s/%d\n", isexception ? "Exception" : "Ban", - NET_AdrToString( ip ), mask, + NET_AdrToString( &ip ), mask, curban->isexception ? "exception" : "ban", addy2, curban->subnet ); return; } @@ -877,7 +877,7 @@ static void SV_AddBanToList( qboolean isexception ) { curban = &serverBans[index]; - if ( curban->subnet > mask && (!curban->isexception || isexception) && NET_CompareBaseAdrMask( curban->ip, ip, mask ) ) + if ( curban->subnet > mask && (!curban->isexception || isexception) && NET_CompareBaseAdrMask( &curban->ip, &ip, mask ) ) SV_DelBanEntryFromList( index ); else index++; @@ -892,7 +892,7 @@ static void SV_AddBanToList( qboolean isexception ) SV_WriteBans(); Com_Printf( "Added %s: %s/%d\n", isexception ? "ban exception" : "ban", - NET_AdrToString( ip ), mask ); + NET_AdrToString( &ip ), mask ); } /* @@ -941,11 +941,11 @@ static void SV_DelBanFromList( qboolean isexception ) if ( curban->isexception == isexception && curban->subnet >= mask && - NET_CompareBaseAdrMask( curban->ip, ip, mask ) ) + NET_CompareBaseAdrMask( &curban->ip, &ip, mask ) ) { Com_Printf( "Deleting %s %s/%d\n", isexception ? "exception" : "ban", - NET_AdrToString( curban->ip ), curban->subnet ); + NET_AdrToString( &curban->ip ), curban->subnet ); SV_DelBanEntryFromList( index ); } @@ -973,7 +973,7 @@ static void SV_DelBanFromList( qboolean isexception ) { Com_Printf( "Deleting %s %s/%d\n", isexception ? "exception" : "ban", - NET_AdrToString( serverBans[index].ip ), serverBans[index].subnet ); + NET_AdrToString( &serverBans[index].ip ), serverBans[index].subnet ); SV_DelBanEntryFromList( index ); @@ -1015,7 +1015,7 @@ static void SV_ListBans_f( void ) count++; Com_Printf( "Ban #%d: %s/%d\n", count, - NET_AdrToString( ban->ip ), ban->subnet ); + NET_AdrToString( &ban->ip ), ban->subnet ); } } // List all exceptions @@ -1027,7 +1027,7 @@ static void SV_ListBans_f( void ) count++; Com_Printf( "Except #%d: %s/%d\n", count, - NET_AdrToString( ban->ip ), ban->subnet ); + NET_AdrToString( &ban->ip ), ban->subnet ); } } } @@ -1194,7 +1194,7 @@ static void SV_Status_f( void ) } ps = SV_GameClientNum( i ); - s = NET_AdrToString( cl->netchan.remoteAddress ); + s = NET_AdrToString( &cl->netchan.remoteAddress ); if (!avoidTruncation) { @@ -1921,8 +1921,8 @@ static void SV_WhitelistIP_f( void ) { netadr_t adr; if ( NET_StringToAdr( Cmd_Argv(i), &adr ) ) { - SVC_WhitelistAdr( adr ); - Com_Printf("Added %s to the IP whitelist\n", NET_AdrToString(adr)); + SVC_WhitelistAdr( &adr ); + Com_Printf("Added %s to the IP whitelist\n", NET_AdrToString(&adr)); } else { Com_Printf("Incorrect IP address: %s\n", Cmd_Argv(i)); } diff --git a/codemp/server/sv_challenge.cpp b/codemp/server/sv_challenge.cpp index 147c48da58..4586b78ce3 100644 --- a/codemp/server/sv_challenge.cpp +++ b/codemp/server/sv_challenge.cpp @@ -105,7 +105,7 @@ SV_CreateChallenge (internal) Create a challenge for the given client address and timestamp. ==================== */ -static int SV_CreateChallenge(int timestamp, netadr_t from) +static int SV_CreateChallenge(int timestamp, const netadr_t *from) { const char *clientParams = NET_AdrToString(from); size_t clientParamsLen = strlen(clientParams); @@ -141,7 +141,7 @@ SV_CreateChallenge Create an unforgeable, temporal challenge for the given client address. ==================== */ -int SV_CreateChallenge(netadr_t from) +int SV_CreateChallenge(const netadr_t *from) { if (!challengerInitialized) { Com_Error(ERR_FATAL, "SV_CreateChallenge: The challenge subsystem has not been initialized"); @@ -160,7 +160,7 @@ SV_VerifyChallenge Verify a challenge received by the client matches the expected challenge. ==================== */ -qboolean SV_VerifyChallenge(int receivedChallenge, netadr_t from) +qboolean SV_VerifyChallenge(int receivedChallenge, const netadr_t *from) { if (!challengerInitialized) { Com_Error(ERR_FATAL, "SV_VerifyChallenge: The challenge subsystem has not been initialized"); diff --git a/codemp/server/sv_client.cpp b/codemp/server/sv_client.cpp index fb2d4418ca..b19ff6f935 100644 --- a/codemp/server/sv_client.cpp +++ b/codemp/server/sv_client.cpp @@ -59,7 +59,7 @@ to their packets, to make it more difficult for malicious servers to hi-jack client connections. ================= */ -void SV_GetChallenge( netadr_t from ) { +void SV_GetChallenge( const netadr_t *from ) { int challenge; int clientChallenge; @@ -91,7 +91,7 @@ Check whether a certain address is banned ================== */ -static qboolean SV_IsBanned( netadr_t *from, qboolean isexception ) +static qboolean SV_IsBanned( const netadr_t *from, qboolean isexception ) { int index; serverBan_t *curban; @@ -113,7 +113,7 @@ static qboolean SV_IsBanned( netadr_t *from, qboolean isexception ) if ( curban->isexception == isexception ) { - if ( NET_CompareBaseAdrMask( curban->ip, *from, curban->subnet ) ) + if ( NET_CompareBaseAdrMask( &curban->ip, from, curban->subnet ) ) return qtrue; } } @@ -128,7 +128,7 @@ SV_DirectConnect A "connect" OOB command has been received ================== */ -void SV_DirectConnect( netadr_t from ) { +void SV_DirectConnect( const netadr_t *from ) { char userinfo[MAX_INFO_STRING]; int i; client_t *cl, *newcl; @@ -147,7 +147,7 @@ void SV_DirectConnect( netadr_t from ) { Com_DPrintf ("SVC_DirectConnect ()\n"); // Check whether this client is banned. - if ( SV_IsBanned( &from, qfalse ) ) + if ( SV_IsBanned( from, qfalse ) ) { NET_OutOfBandPrint( NS_SERVER, from, "print\nYou are banned from this server.\n" ); Com_DPrintf( " rejected connect from %s (banned)\n", NET_AdrToString(from) ); @@ -178,9 +178,9 @@ void SV_DirectConnect( netadr_t from ) { } */ - if ( NET_CompareBaseAdr( from, cl->netchan.remoteAddress ) + if ( NET_CompareBaseAdr( from, &cl->netchan.remoteAddress ) && ( cl->netchan.qport == qport - || from.port == cl->netchan.remoteAddress.port ) ) { + || from->port == cl->netchan.remoteAddress.port ) ) { if (( svs.time - cl->lastConnectTime) < (sv_reconnectlimit->integer * 1000)) { NET_OutOfBandPrint( NS_SERVER, from, "print\nReconnect rejected : too soon\n" ); @@ -223,9 +223,9 @@ void SV_DirectConnect( netadr_t from ) { if ( cl->state == CS_FREE ) { continue; } - if ( NET_CompareBaseAdr( from, cl->netchan.remoteAddress ) + if ( NET_CompareBaseAdr( from, &cl->netchan.remoteAddress ) && ( cl->netchan.qport == qport - || from.port == cl->netchan.remoteAddress.port ) ) { + || from->port == cl->netchan.remoteAddress.port ) ) { Com_Printf ("%s:reconnect\n", NET_AdrToString (from)); newcl = cl; // VVFIXME - both SOF2 and Wolf remove this call, claiming it blows away the user's info @@ -553,7 +553,7 @@ void SV_ClientEnterWorld( client_t *client, usercmd_t *cmd ) { client->state = CS_ACTIVE; if (sv_autoWhitelist->integer) { - SVC_WhitelistAdr( client->netchan.remoteAddress ); + SVC_WhitelistAdr( &client->netchan.remoteAddress ); } // resend all configstrings using the cs commands since these are @@ -1071,7 +1071,7 @@ void SV_UserinfoChanged( client_t *cl ) { // if the client is on the same subnet as the server and we aren't running an // internet public server, assume they don't need a rate choke - if ( Sys_IsLANAddress( cl->netchan.remoteAddress ) && com_dedicated->integer != 2 && sv_lanForceRate->integer == 1 ) { + if ( Sys_IsLANAddress( &cl->netchan.remoteAddress ) && com_dedicated->integer != 2 && sv_lanForceRate->integer == 1 ) { cl->rate = 100000; // lans should not rate limit } else { val = Info_ValueForKey (cl->userinfo, "rate"); @@ -1125,10 +1125,10 @@ void SV_UserinfoChanged( client_t *cl ) { // TTimo // maintain the IP information // the banning code relies on this being consistently present - if( NET_IsLocalAddress(cl->netchan.remoteAddress) ) + if( NET_IsLocalAddress(&cl->netchan.remoteAddress) ) ip = "localhost"; else - ip = (char*)NET_AdrToString( cl->netchan.remoteAddress ); + ip = (char*)NET_AdrToString( &cl->netchan.remoteAddress ); val = Info_ValueForKey( cl->userinfo, "ip" ); if( val[0] ) diff --git a/codemp/server/sv_main.cpp b/codemp/server/sv_main.cpp index 1bb2f7daf6..3b29b4ca1d 100644 --- a/codemp/server/sv_main.cpp +++ b/codemp/server/sv_main.cpp @@ -273,15 +273,15 @@ void SV_MasterHeartbeat( void ) { if ( !strstr( ":", sv_master[i]->string ) ) { adr[i].port = BigShort( PORT_MASTER ); } - Com_Printf( "%s resolved to %s\n", sv_master[i]->string, NET_AdrToString(adr[i]) ); + Com_Printf( "%s resolved to %s\n", sv_master[i]->string, NET_AdrToString(&adr[i]) ); - SVC_WhitelistAdr( adr[i] ); + SVC_WhitelistAdr( &adr[i] ); } Com_Printf ("Sending heartbeat to %s\n", sv_master[i]->string ); // this command should be changed if the server info / status format // ever incompatably changes - NET_OutOfBandPrint( NS_SERVER, adr[i], "heartbeat %s\n", HEARTBEAT_GAME ); + NET_OutOfBandPrint( NS_SERVER, &adr[i], "heartbeat %s\n", HEARTBEAT_GAME ); } } @@ -323,11 +323,11 @@ Find or allocate a bucket for an address */ #include -static leakyBucket_t *SVC_BucketForAddress( netadr_t address, int burst, int period, int now ) { +static leakyBucket_t *SVC_BucketForAddress( const netadr_t *address, int burst, int period, int now ) { static std::map bucketMap; static int lastGC = 0; - if (address.type != NA_IP) { + if (address->type != NA_IP) { return NULL; } @@ -361,7 +361,7 @@ static leakyBucket_t *SVC_BucketForAddress( netadr_t address, int burst, int per } } - return &bucketMap[address.ipi]; + return &bucketMap[address->ipi]; } /* @@ -402,7 +402,7 @@ SVC_RateLimitAddress Rate limit for a particular address ================ */ -qboolean SVC_RateLimitAddress( netadr_t from, int burst, int period, int now ) { +qboolean SVC_RateLimitAddress( const netadr_t *from, int burst, int period, int now ) { leakyBucket_t *bucket = SVC_BucketForAddress( from, burst, period, now ); return SVC_RateLimit( bucket, burst, period, now ); @@ -417,7 +417,7 @@ and all connected players. Used for getting detailed information after the simple info query. ================ */ -void SVC_Status( netadr_t from ) { +void SVC_Status( const netadr_t *from ) { char player[1024]; char status[MAX_MSGLEN]; int i; @@ -473,7 +473,7 @@ Responds with a short info message that should be enough to determine if a user is interested in a server to do a full status ================ */ -void SVC_Info( netadr_t from ) { +void SVC_Info( const netadr_t *from ) { int i, count, humans, wDisable; char *gamedir; char infostring[MAX_INFO_STRING]; @@ -560,7 +560,7 @@ SVC_FlushRedirect ================ */ void SV_FlushRedirect( char *outputbuf ) { - NET_OutOfBandPrint( NS_SERVER, svs.redirectAddress, "print\n%s", outputbuf ); + NET_OutOfBandPrint( NS_SERVER, &svs.redirectAddress, "print\n%s", outputbuf ); } /* @@ -572,7 +572,7 @@ Shift down the remaining args Redirect all printfs =============== */ -void SVC_RemoteCommand( netadr_t from, msg_t *msg ) { +void SVC_RemoteCommand( const netadr_t *from, msg_t *msg ) { qboolean valid; char remaining[1024]; // TTimo - scaled down to accumulate, but not overflow anything network wise, print wise etc. @@ -591,7 +591,7 @@ void SVC_RemoteCommand( netadr_t from, msg_t *msg ) { } // start redirecting all print outputs to the packet - svs.redirectAddress = from; + svs.redirectAddress = *from; Com_BeginRedirect (sv_outputbuf, SV_OUTPUTBUF_LENGTH, SV_FlushRedirect); if ( !strlen( sv_rconPassword->string ) ) { @@ -654,14 +654,14 @@ void SVC_LoadWhitelist( void ) { data = NULL; } -void SVC_WhitelistAdr( netadr_t adr ) { +void SVC_WhitelistAdr( const netadr_t *adr ) { fileHandle_t f; - if (adr.type != NA_IP) { + if (adr->type != NA_IP) { return; } - if (!svc_whitelist.insert(adr.ipi).second) { + if (!svc_whitelist.insert(adr->ipi).second) { return; } @@ -673,13 +673,13 @@ void SVC_WhitelistAdr( netadr_t adr ) { return; } - FS_Write(adr.ip, sizeof(adr.ip), f); + FS_Write(adr->ip, sizeof(adr->ip), f); FS_FCloseFile(f); } -static qboolean SVC_IsWhitelisted( netadr_t adr ) { - if (adr.type == NA_IP) { - return (qboolean)(svc_whitelist.find(adr.ipi) != svc_whitelist.end()); +static qboolean SVC_IsWhitelisted( const netadr_t *adr ) { + if (adr->type == NA_IP) { + return (qboolean)(svc_whitelist.find(adr->ipi) != svc_whitelist.end()); } else { return qtrue; } @@ -695,7 +695,7 @@ Clients that are in the game can still send connectionless packets. ================= */ -void SV_ConnectionlessPacket( netadr_t from, msg_t *msg ) { +void SV_ConnectionlessPacket( const netadr_t *from, msg_t *msg ) { static leakyBucket_t bucket; static int dropped = 0; static int lastMsg = 0; @@ -783,7 +783,7 @@ void SV_ConnectionlessPacket( netadr_t from, msg_t *msg ) { SV_ReadPackets ================= */ -void SV_PacketEvent( netadr_t from, msg_t *msg ) { +void SV_PacketEvent( const netadr_t *from, msg_t *msg ) { int i; client_t *cl; int qport; @@ -805,7 +805,7 @@ void SV_PacketEvent( netadr_t from, msg_t *msg ) { if (cl->state == CS_FREE) { continue; } - if ( !NET_CompareBaseAdr( from, cl->netchan.remoteAddress ) ) { + if ( !NET_CompareBaseAdr( from, &cl->netchan.remoteAddress ) ) { continue; } // it is possible to have multiple clients from a single IP @@ -817,9 +817,9 @@ void SV_PacketEvent( netadr_t from, msg_t *msg ) { // the IP port can't be used to differentiate them, because // some address translating routers periodically change UDP // port assignments - if (cl->netchan.remoteAddress.port != from.port) { + if (cl->netchan.remoteAddress.port != from->port) { Com_Printf( "SV_ReadPackets: fixing up a translated port\n" ); - cl->netchan.remoteAddress.port = from.port; + cl->netchan.remoteAddress.port = from->port; } // make sure it is a valid, in sequence packet @@ -1029,7 +1029,7 @@ void SV_CheckCvars( void ) { for (i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++) { // if the client is on the same subnet as the server and we aren't running an // internet public server, assume they don't need a rate choke - if (Sys_IsLANAddress(cl->netchan.remoteAddress) && com_dedicated->integer != 2 && sv_lanForceRate->integer == 1) { + if (Sys_IsLANAddress(&cl->netchan.remoteAddress) && com_dedicated->integer != 2 && sv_lanForceRate->integer == 1) { cl->rate = 100000; // lans should not rate limit } else { @@ -1049,7 +1049,7 @@ void SV_CheckCvars( void ) { for (i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++) { // if the client is on the same subnet as the server and we aren't running an // internet public server, assume they don't need a rate choke - if (Sys_IsLANAddress(cl->netchan.remoteAddress) && com_dedicated->integer != 2 && sv_lanForceRate->integer == 1) { + if (Sys_IsLANAddress(&cl->netchan.remoteAddress) && com_dedicated->integer != 2 && sv_lanForceRate->integer == 1) { cl->rate = 100000; // lans should not rate limit } else { diff --git a/codemp/server/sv_snapshot.cpp b/codemp/server/sv_snapshot.cpp index b8515bf376..5f844a9bf0 100644 --- a/codemp/server/sv_snapshot.cpp +++ b/codemp/server/sv_snapshot.cpp @@ -730,7 +730,7 @@ void SV_SendMessageToClient( msg_t *msg, client_t *client ) { // local clients get snapshots every server frame // TTimo - https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=491 // added sv_lanForceRate check - if ( client->netchan.remoteAddress.type == NA_LOOPBACK || (sv_lanForceRate->integer && Sys_IsLANAddress (client->netchan.remoteAddress)) ) { + if ( client->netchan.remoteAddress.type == NA_LOOPBACK || (sv_lanForceRate->integer && Sys_IsLANAddress (&client->netchan.remoteAddress)) ) { client->nextSnapshotTime = svs.time + ((int) (1000.0 / sv_fps->integer * com_timescale->value)); return; } diff --git a/shared/sys/sys_public.h b/shared/sys/sys_public.h index c93006a698..62e2244508 100644 --- a/shared/sys/sys_public.h +++ b/shared/sys/sys_public.h @@ -123,12 +123,12 @@ bool Sys_RandomBytes( byte *string, int len ); void Sys_SetErrorText( const char *text ); -void Sys_SendPacket( int length, const void *data, netadr_t to ); +void Sys_SendPacket( int length, const void *data, const netadr_t *to ); qboolean Sys_StringToAdr( const char *s, netadr_t *a ); //Does NOT parse port numbers, only base addresses. -qboolean Sys_IsLANAddress (netadr_t adr); +qboolean Sys_IsLANAddress (const netadr_t *adr); void Sys_ShowIP(void); qboolean Sys_Mkdir( const char *path ); From 819a980686839cc4f421bf4d940719202a00500a Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 20 Jun 2024 09:20:38 -0500 Subject: [PATCH 800/801] [Rend2] Fix glext header Not using matching include guard from khronos, therefore it causes a conflict with system version on Linux --- codemp/rd-rend2/glext.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glext.h b/codemp/rd-rend2/glext.h index 63ea7f2465..67be181648 100644 --- a/codemp/rd-rend2/glext.h +++ b/codemp/rd-rend2/glext.h @@ -1,5 +1,5 @@ -#ifndef __glext_h_ -#define __glext_h_ 1 +#ifndef __gl_glext_h_ +#define __gl_glext_h_ 1 #ifdef __cplusplus extern "C" { From c11082b0899e590d30120615dcf520253c4bb0f2 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 20 Jun 2024 09:24:43 -0500 Subject: [PATCH 801/801] Missed reference in null client for CL_PacketEvent --- codemp/null/null_client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/null/null_client.cpp b/codemp/null/null_client.cpp index a0bafab5fa..fff73ff1c0 100644 --- a/codemp/null/null_client.cpp +++ b/codemp/null/null_client.cpp @@ -41,7 +41,7 @@ void Key_WriteBindings( fileHandle_t f ) { void CL_Frame ( int msec ) { } -void CL_PacketEvent( netadr_t from, msg_t *msg ) { +void CL_PacketEvent( const netadr_t *from, msg_t *msg ) { } void CL_CharEvent( int key ) {

wb-Gm*8B~c?%2atig4?auE297Ts zC&GM_3-@Ubuf%<$xPtiH&q$8X;%D`DqoHw<^nFq}rS984<+Vk37iVxG0yCM{G2?vR z6mt^BH;!|^7av`=x3&W5@6Xh$WqLESGd)|xP2P9NhsoVy?QvWy4JL;!jkxw4wyaaW1#u+eW5)+KMd=r7m*zR}01EPtJRWAI zlkpDFCW-i4`F(z99nTD`kn(^WAI5|5~|;jscWSHSc8o|@phdhjpDdct-z-XBx9rUR)FRF=^{b8|p$NJibTC1P9 zLGYBqy)l^xY*)+T{8Te==cD&&PUnMogE-+ls;u{Xp5%h;S$~NopbVxLd ziBUh=$+Z7Zh*!xk?#LrN%=vv(at@p&FT(AJNqLXdocJ0dJI^PVU!1SfXH^GBz?8vCU;G(Up=QL41jsHh zcHWI(lX`*yyBy~{biJU>XZTvRL9ZJRbNvj}pA+!)Jtcn1zuPAtXkwz2+aIU)5zKyeij1lkSfp5eF7@WU}i$qHbKW+wUs{S>VryC42cDPdfgdSsKG zZ0ee;WIZ&v`?GmEi*zeq)q$!PHEJK(!k#-m68EhD^8VHNAAVX@z@*gH*M}x@iGikK zc)U^Y`-KrZq}bW32Cbq`N1P*HGZC+lb8j8oAYsmO6Q;#xyT8$Ihf}}5dSdq4Ewm=L z*6RD4VF7$ftz-0ayV`amQcOiRuPz&#^>{SKl9<_$PK~3xOhisbXtV|?6dvJnhYw0I zV$cT2m~r|I6{h%vum+$^X&;LJl3J=1c5U^kL5k=!WHGURME zg}{H0$=9`0FFCA@TGtV1@LWV;Ujdfi4e^CSwxz7CV=cHAL<4UufCW5p?_Xp0Q3?b4O^4QKh2un<^c>vRB78 zU6&ftTj6lEAPo1WlE#-pZe@<7G4T;k!*zIKPfaZ zFNTO~U zROoUMqN8A^M8JuIzMf5vM8E@VR|vZ&_Ry5a;B&>l{wcF0{$+`5>WN&V*haUE^=v6V zPAb%8gruQm|M#9#!M>N3KXwoFZ2d)s^U-IJJAVjBUx8lmAJIf+(heetzcbf+Bxkxi zT2(~tC{cFw3#)y}y{|8-xeS5@qMz1A)7#5EvXsFjKvLHwf#^1VrL#emZ$g}zT>G_Y z?|#)1FN>TOnp8p7-FHR`DK^XV*uSC?-j8U&r*r$Ya=gF@JWyE>|nIiJjyVfTx9R$yUq@rKm_ z?Dz@n&D57`)OUYX=5X`=Kxr)^X2h_%Ox75SWv|0amvyAPXvQ-(^cu-Ao_CYpK(TAV z8{C8TE(XY~B{@T6!HjsJzr>=fLX!YJbRrF;}gxEqv_>ov-&Ds0gave!Z#| zmEW3Tlg~>~1Y3e%Z2eUO6#mu%C+dJ}r8EU17$XjXBcO3vRzI1tst{0we=J%)X=5_q zA_}a8P@B4G6)tP{8~diSed?iM@V7BK$+UsMB;&h0Dc^>E!NoJ3lZbR~z5OAzchNer zN&4>#WQ1aKG=+j-$SOVlJ)T=NG6n(wz>?(lGT%J4sN&TgiItaov^yLl+CZxfP<+U~ zK?FYHEvZH4Jz8az-=~=ul}4VQLLbNf7kv;3H9RT4_h%&@)8ocQ4!+VD0RQWgZpwQ9 zo^Beeu#*?&4h||NO@NZZn(?BF%Z4^(U*S=ambr7G`#w?bdA8Y#a+arP42aj009?cq zhHvlPr=%@a&Jymd3<`J%yc^+h5PiVgeuiAN%goGD{dvfIQ1Ml|M)fU|nk|(nbv&tU}%^Tk!u??dGqluYXycmE+~z6vYCxFFhW`Lzyj=m;y^eo2g5bG_P3bl0KE zW;XStCw&S3Xp*)!UBCEfgERoBnEwXG%>R-RyuYpWZ_$e@G5@;`~O;imI!>>3@Ac}88BCk*`$dB zLh(g3o+6*91LWkn$PR9&MDS0ldmNyofSJkIz}1sJ+>r}g_<9=ZU|xOs1Z1>(@2ybPzl3oi3qpd=&+2Wh=@qaVLkwxnNC1#&^uKVbBULaeak6r zzO>IGW5EWhVjE9?ydLfN*p>$0&LkQb+jWDlc9@j+sK)VAOQB3{49;3S{qZzE# zfj>gGA9`6a{I9)59u^V4NEx3bqAbU4u%E^^nRx_n(K*|bNn~c=AHqv=V^it)gR?L) zX6zqY;y*BNr9=={NN1lcj0KKZiuI)h3zCvc+w9#t5G5rgS&E6&?T1hg;JKq^I}g|* zQuu>#-#y>Qh<4xN;$kdJ!B*X_t3e%4CE9=#4z=q9brL$kghc*W`#}UxF03Frm8m)p z&zlpA&zE$*x0!?RG@K83AP8kJfOEdzSmIfB8a5;T5G{48-BFEkhhjbYci6O+0Z4gP zJH12kzt;gYx{(VV*IgThuv7ibm7T*ejk3>$$<&(+*r@zHdV>Gb?n@K7j_xk+9^)R% z1z~>9G8$jBoA&jcF>1~8V#9rq%+LO(LAslH6fpy!bSOX2Xs^%S%W3>B;ETd(zCMSC zDu!Q#0NlwVLs&xBUq+G@bzv$W}Z@*M%Q=Y)|VmwCh+N_4b$R0 z6DeTFVS#>fl@_3oYn)>P^&Lu6Fz3_7*_REMy(2-})FxNSzF~d7hlk+bN zY?S)DhFpj8DV(+@E_Ajn-#}8CWd3yIWXvEw!B}YuxjiLSHy)I!(k{+QwSPPoUu#7a8S}Lb*rvgoA=P+*sGw;BSWM8T00yCM>U`F)Wcw z=bPluPt_aS4=!}X1iR`t0jB^4>gqvSB7mf>O1rZi2k1aszg7I94C!n0`FuU;0UfN2 z{x8)qh8$N+G9%;T)u5tXt*q5aMApAxpP8?$hz@GGl6zAclaC=%E6cdWq-16dGm0-N zLdb&CbkFpI?fa^$s}b1sxqh_Ki(VcHYFq$C^eM>BO9B+Lt<3N&5@E^(ZFUxmnnqj$ zw~M#&DsE0r_jVZ;NB4(lzX!g~R&JVE?vb{9VD}_+O(4I!GfMQAv$miRftxP$TA3a3 z*Qn04z>8!5MZn=*SaQ*IlbixcLRP2tk@I{V<55?P1cv44uo5XFi`sS4x{;}mS^G4x ztb5Lwl!x!^zjC;x47>Bk`OhO{;`9!iN#-5**Y=2s04z8v{1E0z4EGyv^N=N*y?nU7 z-X-zTx+7Xqw>uJ5Os26tVb!urO}*qL}@So_q2 ze_SaOZ$h^dWX^477z%XH-^9QDq0YMYS}qzlMBuezk7OupkdE^khxB<(EHZtY1j!Fh zUx}Jqs?xuzy!qZ>7QNv!i6Q^HQm3kH_q%HJ=+yd6(GJ1r)H{9gC@4Okdg-5}g;Fa~ ziuKp|zA$^t1NM%c13#fydCcx`CHk7?T-2XfV zu2+TZ%Ib)JD8FDy!16X{CHFy#_ zRHAn~fh}t{`#vRp3veL7;ZctG)_|0Yl?My%>b(5|`4+Nn_}(4S>4TNGm{XI-B|3-t z4kWx)Ff$s)vWhP^X-V9v)+Tmh_jY4W=o`{4gQOVbQm`(4cm~@Y*52Bv5AqKGt-m{M z*SFY8IBM~fCAz)EjhB}C^}_Qqv8j9x1iQgAZW1Ldg2N_PdjHYSiOll=W_z9~q>l>v zlS6Vp`^d-ccr~~)jmsuI25>A}i8Czd7&u(i}dRZt<1mj=|QJIk*Z zH3GX-7_%5~bx2yHC7-f8+E3gSo%vX|@e%W=_+`t>p3)G{%vtJJj3qf*O%5f$p6c5` z?w&Er5~7}{+LXNAF%E&>NOIQ((v%IpSM@p$wYMqM8<4u&Z1BEw&wh`9oB3GXAH~Y1 zp33vehBw|{hubcecJ@A)-9=#Xu^y@}zqPeL{>*8M7(wjDnVM&kgM1MZi>~@`{h$5d zc-^1KZl?*RiEAL`Azj*o;1qtB|L&iDDfP7hBC7ASo>2+@66}DZMsJw_a5mEnB5VCA5V4GVej>jD+=4nu z@0>EIc=z9rpYlj0s#2uc?f88D0Nz@D#UMUK+N5}BV;5bp5Y{eobEzGo7inE*cNOSX z^IxsQ(xz9iD;^@Zy`pf&1gJ++g3s-A5b&7RIeQQwNg%Jn%?id+;@A>#pB-~O^+4bgQ|#Z<+6WaZNy18;c#{-gzU zc(Qw7cv5`2wNO0g(r|r(MM|*nWdDq0hwQ}Klm1>3yU;lUSfgqzqjJ>(ggHyDqJ6vt zgH3W}en<73ZbYPVdfI(C^ZtAHe;?5lNFTh5lKO%rl@#LT`C*kXLz2);&|rj-HexHT zgrXAi)!uEiHJ^lKkgJ&CeP9_w@4rOX3apH;W4{{NdAo!j#fT=e-*3c4XXJEi_%W0} zY*7w@16YOCLi@oz@71~-k^y#G+>{ijqsiKGT6D%_ZF2k7x~U8c35x4Q2uAdo>)PeN zVW}6Ibgd}>;ezp70p&vY&6QP-X>dyQ^)yeina7Vb<4CNYUQ;&| ztL)+7{c1c9Pj;ijUWIz02`Femy?W?~uCjsCeCtO8@fSS^Exxn?Hg{~0OP#19wnj?8 zMiQIF9Zf<;bf6=Xc%16NeB&=(kdn5EkH_C?-SwU3MCr6&GCV{E!CtQv>Kn9RI2*pV zDJSsWQcXF}PKO7T>UFDemZmbu*#FktTGnv>()zG(I;(HZ@Irx@_qiSY2MO8rT&E1Q zvDs?Q?Hy{}^svo{-rvY`V(*E_ik3*ezT5sp&A5qQ?%FV`Fe}3c91xJC$uXvNysN_R zQht_w_NgzgcBInaj%}he?N%9ZAS_)@?J)?$CbO2UmDPA(!ccE;w*pXTTmjd9xJ z%O&en^%>&C&%AjW4551EeLq>GJpZN{^cy`%mJ4kB$jkLvP5C|D&BL4vK8ClW@d?`W zr@c!j0J0BiI_qLx`$?sO5WJ45z1(q4c{rE8N0aWe@UyI~%=e|HeM6|6*(fe?5B?PG z5%Hq6koB=JqqInN_+XunG^4;IX&|lzAAL1@9YLrZpTfXmSP*p-F|IlyWwpNE5IYfe z_3hHz{r4>$Fk!Y$CCgtOO|9RI=DtMUtyKE4VLz-QlM-t*T-vCLe%pX=wx+FmMT4`l zuKg)RsD=~V?QGzFk@Ph6xg-H33hUKx`APaShM(#Ct5RgTdG+ss+&cz@ATOmE(@*D< z0QGg#C*~eoX%Ffi5n$7Dl47MJUtMK3zwYf-M2)H5JrD@kI0sl2xuDN^Up_CL+i0x> zFci!M2)JUa!Fo>WTz6MLpFtze+NsOlx;_g1HYa`?DOhWTR~a~Gq|5zFNN?=j)*>*G z^kA{U??JJ~`H+$70XbTma=SDj&F>^|d#I}O_c>}5b|qt(sa5~Pe?UI}N6*+_X=?g$ zC7J}|KRz*Y%DBI73**r6czqgxx*rj*dy^bbqzKK9x}9-Hbte`JQuzf_xsz~KwUb~a z{HgDL(6P7%p7r7#$C_RdY7`1ji|8h~FEtWOdBu6WU^P=`2Yx61`#y@Lej%td=urUd zXHQ%lP)Sb-VtB#{^7rn{VFsz4f3i6lNbRJ>oVCPSI68_l!ooZ~s0({z@v9e-p@8O) z;0$%)H%Dz2ozHHG!w#-jGz*WcDm6sYEd6vS5OJ$|gXA))7xAQ}c{d4?0?K&byN*$p zmv6JW7s#epz9O5-hw8bRZApO7Pns3{%dG_GclTvy9Hi5Uu0||4hzaIaKEU z*2{VTJi5adK%h*qSeQovm^H`7cmJxk^Cx3i(6|1VJS=ei)w98lf>^B`L(sOO#P>l{ z<@@S~>~6~3s?+)Jg>m!v2pjc0Yaa~1{g8BU-u{t@p>=%q5TY#Rgn4XT$fcbbcQB39r0fY|zUm=k=DX7PGV|ioZ->=j4x69)kkc(i}|}B zicTccs~jCRQ0q#f$TY$kU&Wwz;g=-n4fqvl&-Rk5BOkxGkVqH8x{cxU>*dZ8P6-t| zS2^Mpj`ZK#sjsF-iisE}nK^`nJHbbkR|022i-SfJt6>1yexdbXZ)fQn|H~Rm?j7MY zTAtiAuj;#62bc4*Rq*I=-vYoGh^FheT$Q~GT_|-eZO4c&IJjOl(cin7dL8CBi;Cia z>*xR)3b|OL9xE5UK)p8=l;wXKsNytZIAjQ3WYKtNBmmb!%Bn@3nJ3=7D6T64Y$hB# z((mVX!u6Yl;-YlFFO$fz?WDW36HwQj++G`Y*y2JgTgEtR>gYR5ODG~K;QKl3c?w9$ z%Gb;Njrv(4hJA~)Xfe_b1nkmKyPW*u(Y2cUob4l(p(>jpzdkek_*(wEcu{s;&w%*i zyhZ@JScCBSp`Kk=F&{+m+1>fq1;q{~hu;ZW4p1aVGO>V7)7pdTS5dmw(^^nk5G=RZ zMfYopF$wch+z{#Y{g`Q+&f18LAl9^Pz$}smIXg?`Z@Q9`L9h3R0-$SV<(umZ$2_WN7>kKeFpbsw4Vt|AL7cUnZnoREpdR=&PIct!*W~TbjPa zS5y7*cwz9)!oArUjZ#UR!Y7?yf5xhjc7dNAv3aNSPw~Yn z#ktxWDpOS;(8CVl?X9)GR?sFEpym<(ow398`U=;GCE1duP;Z3C!{I;~ziNgm{_e?p z>~Qvs{`Ga{u<-DFiWkM9WR$G4j1-AFa(b8LE*c4pQjuu-emwLRKgItA8Kf z%C&-DUw_S{LyG9hemR@(NXO%upB1p@AHPdepYBTZ0qI77-I*?t~TH(NQKgABIG*Godc8RHVGIF^*XxfZC zFajxoM!_(oe`&N~fDjl0MMF|KQHS+Qi?>6)sA4!e(w`A2=sK>mHImxN_^~{sCg>rj z3gJ`lZ=r{OVKFU+Gsr^Ry;;q)6)&bg#iUVaN6rw^&Rx=@l!Y!_V)D3pKKf+)d#8mO z?N;X81A@mSCVg)xKho~qu+K4fzDNKt=EJXvhv+ElPKE7Z@%&$T!mYj57;)rCnco ztH(8V_DLkM;+~MF<+5#Hnr!yYHg(Y=cx5nvhn7Qr*H|f_Ic2t91v_i2o-ey@Uvu^& zaqjNrIjcRkHEgbMQ$`@AL7aw9puDKI@ykb+u!T6&m^}JTNvj(q>i2KEv9U4k3QKg3 zvNVAIG@2!w&sonCn~dn155;@eLLSyLo<<4veLzRY!U*UZwePShUvuq{PkNOiGQ89)Q+p7AZD;qCzF}y*XV0=Hqag0!lv2F z5V+8zUdY`K>YwABjMvkoHT(OfiD3_E#ou~C_~FwIag#s)+cbOCK(S02gI-Lqpzr3R z#CK(5HvLcbYPDAiNOUW4Zaj~r-=M#y=It{;TI z{PNvcUBKG>S3uF^$8np(^1YSyC1Fkiy5k%*hRMO8#8cG#szo(l*l;{6?kOFy^I|YV zmH(qmv>dw%@KDwtpXp{#)%E)9w>Ld9&D%QRgNq|k`XYo`^Um7a7=RF%#mhcUg&u7h z0G0bH>~if?a!|Z8i(2L*i?{cu{!kuX?tD%}U9aTy5LLFlS`Hy&*~w{Udhf*e?x7HD zqfuv@G1cgL42DzBnY;EG`utZR2)%!W7Lcn{{v~#p#bH%H#bmAy}N&hYX5uxZ;TF&y0 z+CzMLaX^#;VXSDnz#gONIlCu=AZt(|^5lZsPHwcP}af}k?3M{z1@sz%C zp6+=26)^0d`V-&ElLH+kw9mvDxp-pN<7I2h9SN!qG_D_Zc(L9@kE@6T)_ppU4M@q> zK62-ZL~2NtbQevU*oyGhXP#uuW-x=zx5jL3h(QIO4RE= zmcPS_V1|K{~E4O=+flXy+T9;aDeVt@sw&;8N$o0p0l^n~ynZID{d9Tl33CSq9 z&k6fT)Ios^70Nbsa$_v^jsOc|hfJTyMz+28fth@`J?*C5e7sIeJz|ygNbG~LK=yR- zJJP*mwOb9YTfRg`Z%=j>PT*MDI66G-Vd&!VQyIf$WIUoWNTY_WMD zkFOO?Vpbj3KXv^X8;IH!to2SUNe0U&zi-)gcG>*($#zMr63&OaRJ;8iG_VaMK*=mU z(2nPakj5E zpvlZx5OX>cvLEUhqxCsIolAUG2!J70KePAmNw{K07xnKi;MVai{s4zXN}vMDF}sYQ zk!$#j1gFtY%e8PrA0MRS=_4ObDN%+;+~OF+R?C?Opd&{$$!3#;qk_Mzu(xbrEq3sA zEQA@FMRFlFpiizaQnPnx+!8Z<{7z5`V*P{L?>o`@)K^89w-Q?fdkX&BO_0ASRQWu_ zg|3aES%BlxfLsmYc={azWa2|s(jpay8y|w9jj*^dtnj3 zTSq)BZ%YRv=S^|a6nPz17Deb>H6a*ibTI<+eqZl31-fh@7NJ!v8GZ#J9k`ADH%L?k z2gzO@lUi7c8p7?2#ElpFu{d!2m1Z!UFK$k z>7q8O^y4{sgSQ`cLd!I=wb8qKgw!wAb=q692Y)^MDgh@fW<>d+-fRAHUTP;dMJ;vp zxqF%rL1|oWGMw-1QMg3vOfoayT6FTB(C*=JncZ9kKHVycaAueXUBR7?r0CbON7ejj{l+ml@oWls|mIp?LbB^uImj%l=>S_v6F0ywBA9j(-g&a;J_02yNsPN#5@C z1dXmU=K_W+wfRfX2U^^nEdn>-+t{WjCy$LuV_Asr%D*REAKTwRZYRHB&v9cnJD!1L zUYBUOuC-P@oXB!b(~JVdC#vqE)=;|nC-Dya;#gS35Slz5^oDwboos!hH(a;$1uN(t z=iSNqo%t=-50d9r_2Yz266#(Xd4zGeokGM!0|NtbquX)Amen5mR2~w<(&SEW#K>~b zmGzf#EtD!k>;{R~jW88lD{@my`Fp61Qz?dfLfKZwr0P3=1CZ$5Q)#x8sO(CKK8wk`AbU!$#0 zzk@Jm+4@J5T>|s_sEa3F8>*zTaw9*RH^UYzw!~l`6(+i`H^3^mZr(?wBB+gSkrJ_I z>ubsu7qk;-RGG$IgH%-?4a`@h(Rqb<02pi}4`taII{73Rr(51@>!NhicHz;YPFGe? zvs&SA>QS+234SB`9hQ1Uev|^b^6pdAA@n@RRvA67as2@Fek3Mjvset= z5@3_!-m2&0OF9Z7^#`!c<&V2QHT;qC&_t(U+ic)RG}|WhDZ5~)$^@-Ejqkm zZb=ZsaWK@J(|KqS?K4gF|Fr=2zJ{4JI0e>bDWAWZlb_!2yjufM&qQv5TBTln9~F0U zs~Bac;DG8O;9pX!<4dNxitkL=@c0Y=Tb8WDmW~3Wz>|*h07@{YxxCa`pTUDofP44j zpX0qazI{9vTF75V5Efech&S&^`(5y9XC*jz@GRyB87uJt|9D4|#a>1Ski3Jbd&WaN*B0T7B2azUX^M8|&6!`1sIw`F3+ELIJ>BsVE-rXZZ_wW$A4&hW!eG zRCU-89SLWQxuILxU0D6V_8xPT!$za}xXFpA;uU=z5fS#}jyF0g#J_v23Bt_TBER<`7Mt_AjL;VU+WAUTRx5AW=CD8vpu~T;^)Bh zFTj|*RxW53tKSnx3q6g2OkN5#J?}AB9MFzHc4=IDh%LUBJa48J>Cn-93UA;{Ci}&X z;E*M8#dtZ=|A?k!ib@3{W^a8i(15?OX$A=6^HI}H&DQ0{GHkA4?z(=&2(FLzzL%Typh9 z2(Ctg0=Ud%$o|#QZ3Gk_EURBOF`-8nH*V>&>-1!c!TE|~+Eg&t-}1>9cP?`19br6R zZ^Bx_i?eP#udg77DNF2lzU^1bIOMOPfuFT-Aj8_KJp()Q!B$>3>;t08m%ORE9+_io zYaUDTGh2}|1;2kP1xUl7=tknAR=ZwW;dJ7#u&}sM>;6+ZnT)tmz*e^AvHr?rYT7l6 zX(GEwp4WuAc_~fQaFBIfP`+wxr2C_69BU~vZR(8qd-)~ z(i%Kh9_rsFHo}>BO|8pE0#3On5UmDelQ2kHE|bK8;iI*4>(7;{FEwtHHo{W>avio3 z*6(#T?JSX-fA~O^u7$fKu5&_-bebjer9c+coqape&e&EH0n|7OGVKw_xMIlX7XpC2 zC1Jd5c5D;C#I{cw3_e>BO%trT;ti9{)U{?x56kcC-ns46#GnE*)ONX zy0W!W{}eyutf5*LHs`ziNgbsOSuK{Rzl>AwP>>v9+tZlZL3cGh z-251^>*Iasw-yzGN9xG|dN@d}3DjB^BMK7$e`4Qw;N3&o=L67)Mo57a1fLZdtA=2X z&USx~R}c?0I&C<^ju_Dw&Yg;9G{hxZ2g>d{wBWV<94J|9@Q{OIHndf1-i{eJl!RIM z)rfZy|K%Tfu-Xb#d2m?Lf}_RORfokBjXFQGSar0aj74djs0`&jiH-= zL(!`~TLt)q2&KDBa;dzi`tg;q^0s{}0ST+hnQ)uF_F39Q3!Y7<$pnqet~TdPGu+NK zwS(YS*_g*FtBsFEAB^Lpo7j$+>_z6w=+Gk8xELa$Q`E`Y%4bC#CMv4~N6_oFGx2EW z7K#uFJo>PxAuFflCJglA*?3+$fMG#v6D9v16ud-TCbK!;_U8<)bz*elCau`2_ZDrv zBn`MY$tr^gkqoKo&iF>2+z>3X!d8;#OJ4st%WSk>}I^bOHj~rU9f5(7*eCt!WLzIauhS+%6r5{9D&F#;x0g^kb zBU|cGO6pWl-rHis3fnCBqX@8`$Y^lZqr7?BZp%~NL>FITJ`D%|l zxMsDl^&J=M-F+!YZq3r7T&foId=1%v?8oZxcrAe({s?AMbl}Iz&BnfcaYAPv7mEE9 zwdZmhgg7N4cP|9PYWA69MePd2GR5uq1 zgm3>ztp#m?abAUOPrb^x9)-^z_!exmL5xTvE`WUHmNj_bR)bcw);sJK_-USPM=?i5P_JeVF9{>1rYF)BpgL zk2#j|K4iLO24TOx>KYDK@S18qN_OJke8=_4s$iOwx3BW0 zLU01Y&UMGe-cUF-4cJ+pY}*VB$LY{KbQF{_gwga#TE~waE8T3M?nd4i%lIFPTh*w^VH9r<}Bt=uS*I ztQ=7!SBvp(HhlMi^eo`WACXGIhh+<=T}XA?LTnbH4N2o9P2EuzA@96icBiIPs3za@ z;aWSMJ^pF)6}h&qc|{U_7(Lq&ATYm2Nsb_;l#yh<+mRe)hFpfYGee>TSs|8v#1Qu( zRrNsJ*2Ay}4R&M%nxrR^r0YNrHS2$i5}DFtQrnwSRD$|uys~p0@(;8hB zbB85>z#-jN=Htfs<{;>t>%BHh;);q2z&M19Ju)5Z*z$Pe;lrNLS4ZKyVwykku6kE4 zvSwd_;m;4L7^FhY-dLR5XG#|K^=~q7rvz@$*q!`L;8pU~FBCAw{KT(6d5T%CuhZS+ zU%K(fXYVz{kNxub;ZHhksvt`ft?a^P@WZ-5r#T2KTX(7y=^* z_qv|q4!us*D>vj$I&SL~vOIZh(>HmE17B~-XP`we#k2-oP!bnEEL(kny%Ki9fP+xk73<6$;%-@+R0hDfq@;6wJuhCB_&ekk2uMEU#k#r-#5^1 zD_MGsm?}kR7DM_e+9rl{I2}}rw{DG#DtBt%qJ=Yls}-p(R9RYZRFa71)y#;_5whBJ z=w7?Z8%?ZVFqY-#+XDOxG6~uo(UFmgYd%srf<(jnl-Z@*&7pn;(vMG#u12PK!h6pD)3 zMDoO%!|XD@e17?#TKPd^w5UzX{Jug0z<7w2Nf|%--hHpE+LSs`DgCG*46QdR(NH}- z!0|hc($2}-7My#q-Qq^s_?%F?J#Ia%^{X5|rcW^=RZ<8DaN@{}E7>ODPSw_ z0qcE%<-1pxXEs4>Uj>tg29+v7muw|L05%fi{p$)5kz`JANfHIT(`6XiW4d_`D_%K{ z%^(W=?h;NE&E^2!ph8klR7TGZQa~r{j?kj+bBN-FU@cv;XYTj4=$NvOz)VzQ+ljA51&>JVj;#3qG7g+6yv2$nQ2@s z1li|LN6tB~xejV34e(L*(>n8ZZy10)&Zl=THl8=Wx=$iY?Owr=YSsJ#3U;s+6>L95 z9$QWiYHFGQrv;3c&_n=BJ~`IAD-~?{A3~GA?4D z{aVHO#>g41gOrle|0b5Qw`Oady-|1fl<`{qG>fcMdwZMWwsudeeI@CnW9*o-u8h9G zH(Au-iO`g&Lrxyi;=PwcB`Oa8@;5Cw3VS~?1(N(Zy`E7+$&1VIOw(!B0=MsId#|;? z28Wy!TM@DP%c%8^f=M}EKbtSr5`5sg}>wI>7 z<3m>Wg1uBA^J8_^o6rDi_x^=YZUi{wRzVdA#U=Lzq?_;a(g@nPtaK0Q{x{#@P)`I0 zpll_6pSIpvM`w)I8-0sdp(sIOk;s(7KBz8Q7r{!kAdT#CkqNMPPnQUG0N9F*d))Gn zT|s7b`A0JWC`N4r*>jR`E{Rah9$zDU(D@q3GquK zgL6nF(*gnMS&kzhlN~Fa9TNYiEI4T!?^tN7-WbZjd^a8M?;Vj7T3Mq1?Wmoq9vos+m|uEL7oxKWN!syYdiHTnr&d*%Sy#$VyPNjqGb&*?|wTtN77c zB-To2;tsOW4Qz}p#FK67EcIsVz1~g9{nQW{ApXrUlI)JjRMF2RJA6w4#TR6H8PSm@ zC0k`(%c+%h*?o)6=<=cxyd*yn{QB0zWwre)Qf5Mg42OkGl5U5_$w2vGEUffv>e%iH z5@GoK%nav~e&1TVf#3qfm5{0t&P>ocMK(x9y&rn8k@N+wK>gtj4QVmJa+Lqr&I|;I z{z?)PT*-**)!`yh0Z+X^a6s`_v%k?l*0kK|6kHKJiA+d&{<9D4$*HsPP|DKp5w-jY z-YGpt6_Cq6``Ou!lW?Bsj2EIG;7yMgJuQ#@BdUD-4oPr&mK2<>y+k*36T7Jhf<-NEaJD&C z3f)U;aR_xau1?o=yAQ&YUtMPKXMg*qK+z@za2AKk@A`_eTI11W;dLZj3b{e)-i6x& z!h_mBEUNk!Dz+Y#;|}<(IAq7@&-1+3w$|EXE`8^%|t<8~(@RIj-ZO++fzfsX$Dxo&>fYwln)L-aM^VFBXfN zsv9dc$$b=K8MeNDxn0z<@}8$9`hXl7V-MQ1P=D0ZQB2IXdurH$85 z1~TN8KK@KdT>9Z|ky&=4b8@hXcUy38yvfJA;0P5a2dj#Dj5^Jp@OqFzdY`{-8JQ$v z9XUc$`eU1Y_X$-$R?PzD$L(g)OM3O_->L_vy~Q+VVf821omkR!n-U+%@FxQQd!3b^ zeodNOQjlQU8LHOv=@rf-w5z81Dq2#aY?U6v(?h(8Pf?&oke>%pS%A#ni_W44nq0H* z7^2L$!M%AP&&KUWtq|RMw=)VDI%9}l)WpeQ+y9*1X2c_n&xJTPnOlCbau-+!QNQbA zGGn7WGu7SzgVTgLyvje>1rheVv?n9d7Fjoy_EXQ@?B`#dr##$I!Qj)Tzv-Hp&v~Bo zjPfP&4YyxSzhb$b?4lXPBYe{6EXd*0q-usB%A)Nzt?127LAi?`B&(`3J%EDfC~X{4 zsV(Z|N8*_*lui3u708tbSM|yVOcTqH=*gb3@1t+6zTMql@D~GPTKI-HeEu)uYeeW5 z>N6qwJ@=kbuRP*8!|LfTfk1xr(XSTUld6$wcb=CyOcRLX1{6vj&lqHpepFB~DzT4}U&)x&pIbXsCu{Hy^5sEl{hmRCN z6A+VEQLrnWGOOF)y)u-|>4P#Gjr*ndwKiqequ#qd*#&eCel}XU63!P3;-MsVSY2E? z(LH7i2)6}$Z?<{a*bsoUu#TzFCzd>V%4o%E^&lZ|!_59J;@z)a3OyN?!SXdH)_VG( z-sS|Mv0NAO>JxF7EQ_kpu$vxssnV3RKxdPi0;UQIuR$lEs=@d;^8$-|1BoPFL|Y!G2cQnT!4Y#@E=`FV`({wNXs;L*T> z$G}MmJvLPnZyeaJ+B~dyQa{AM^Y;NZdVo&LB6zj6F6j>Riyw6Rw$NA%()_maV)XC4 z)%m}8@9J~1|E7FC2SQ`UuML=M__+^dkM3Ij90y-obA}%~0OSG%K>RL@RvG)&CSS<1 z!Lgkh2RL-qH4Zmw9BHlyC=kF+@}2s&-0`$28n;+FSE3)AY9%kVj{sv90yY6>)x|4?iD&`j+bMIeqVS!1@ zN2kB^l1{$;H-#}PU=UA+ml}FxHrJfju8=9n$o44|UFmJp72(C_;d`R=&a!p!HjyQH z<^J;RY0lRTCgmHye>VPC3(o(-7J8`T_mY>5O6fXaiRcOS;~Mxg!^wht!)`coO-$k9 zaS`84gI}K@FDIedh!aq0sBxa)(iD5o1#m1cY3$D$2<`f;{4#ww z`^$6%F>kz2dK_o@0Q&9SkH|pTYWEKr&FoR=2an-D)!mkQ+@C+dgESf|2ub^WjZ6nv z%K5f6_2gBC8Er?abS{7Hwb*Us^E3%lm|`gFI{#AZ4@=X~58K(lMMS^T1flcQ{MvII3}EZ* z{i%o-K>bJDVqGk!Rj5~-y|H_}fshN|G-BXP-goABz@B#={#sA7duSu?iJ1pq8RLrB zD{-8o5LbgXETAE8Uh`e>=s;SrTr`tx7>+}9&OvyRN1c}s+kn)rOQvig2)wBcD?XZS8|aPji{ zJ{My^#bVNZ=`*C+%^}cH<;`G8&2#go3f&jDx2DoRE}%ypz0PPUsbLM}|2AkSb=?n= zx@1wFo&a*OIW1!758gnSn>VV%z}!e60g|3CYQ#A=)k|<=ta+MEX|K@3e^vZOf7iOF z?W4-?gX4A%`JH+sA^kT{oR+6;4ISbH|?$ z-gEG5R23Xm8ktDEmovIPwFFGj0MZMEl;{^VOsjv^{(uE-`&aCTk3JNM$jBuBPZ(bl z1_n{TiM#+qNPuBYVU9dyG|RP4a;bYME86W8ii%58g-DmuKh(fVWcd;P$N!~5KmSLJGPjdyhiCP7Su)>g#APoY%%aO@SWCVL ziRTZ+Wk8E1<$6Zd{!^ZIv6%OL3qgq-h29;4I6lUg#!1L9mh z-a8rGyyI1ySF@|vSZZGQTe5ndjC&UR_oaP_No4%!*amoilThoA zNz?SKT+IgF)#eB-e{rGiKF+D{@Ao6Xw_S*Wm5xHW@R4T=i5Wm>AyQ$V6g4PLk8 zaXJHM;PQtKRK@I&O|yD>`T@{!!`-<%AV9eXMZ~^~NY?ecXGimxQ4u1L_g7N}AQ%?& zT=d~a-0N^kU`N#H#qhITYyU7my>e_frOR#r%*yw}v!*KF?`wbLv6GR&>Ds=*t7M%<9c@Q+6%+!&sZ?E(yl6%7C{}c9?->$z5nbY;-hs&Fc~fn4~gkz zYF#Cj=6~%-emgx69aoy}CiGUUw8z*XJ{>E;#Xzw-^x6i;_L=6DA7ajsh+>t^)*lDr z3O>ojvLWOh5Kjq#hKW{22&tS%KP8*eL#>yRd}11^oGH8mM5%#L_Be4}Wo6|fVSo;| zG%DRAKn+em@1I-VTASu&(xB zgpToLXWwlJIDv^T${ln4(H9tCxji6{hB`^e^=ib_cHyjE<^QK}i(U_06iX)jv=7n9 zA{_HZ^5W)ZsdoHQ>#|n=@>I2BDRp5E6QV;j?aXd~CHHYDY_YJr-Y0?M?#eOU0tTIg zLabXu=AL&1o*qiwqLAEh>P9npLj|D?+ucT&hO1Z%-B_dQ+zq%@^J39QkD*_j5|x<= z&<^EVU}frYtRfQv@XQRznc>)A@7q-L23Fb&xp@Eq&X#ED82XnZ{#68?@qlZnX=uQE zKkCU9!&m0bE=oj{r%tZXnj^=&xA@WkW6c}?m$2h(2NJV@9+gBN`g_}I`{HJC= zS0lH1Oyo%KswuWP>`OMSq;W)J?SKG-;HTC>bI;bir6>th;UpwOK%O3|Uxj?eKoR*a zE_p)rO(bDPt1Qiu9M2yJGFM2Mx2_gpSQ9hE6k&N9);o$2qW9-`rL(FGwy7MP%|910 zMjBDRdghgXJ}0mmrYX_sw_qqkN{ln*&`-M`iu^|2RlfeuOX#3U_1elz{#TNAtVT5f z`RZ%7uPdy^*ppZMSb#l?<~%id8e-0yXn{kG?ZWz*L+@z9zk|6Z-2c>SdF_V*`~I%x z-f7R#7Mm`0o;QLqHxR6By!64GWNd|{zrK}{!ouVsz%Wu{-=0?ST@AwS&mUt{eWZPO zu_&OerksWrsiGr&eZ=l;P)c(z_|ChEbs*6GCB2RX_Yd=2UL2p523!4laRiD&QLUPabG^6 zHx!404V&_WSgm=tzlyqtfBw6;uKZ;$$zj_>7_pC!56WR!16W8zh7C5P^g@axBPulz z%mKNl)wYt&z7n$+URaVru*# zb~}f9hT`%lRmGtF<&C&w(_G-4{9D-y9skWplN)oK$$H*>r+V&#$WPdnIy8HfUmaoq zaH)z{D6vXI)h$E5Q{M;?vXN%Kj*!_h>Za$}#mksT842S-^%^bW#D8Iha@H(u;q}?p z9CwSAdJJ`y&eEVgtMG9HJ?b9P9Np@%)KLb|PBUN;=ksuf$t zjrFS-b9Zr!qn-2w2oenrBhi^nl)KiLBPjDM-`Tug-ZSW%bSsV{{~THJ2< zqAw+-c9yR$k9;i>kkD~Oq7=aOCt@xj=5T`F7+YS19}p2;R+?QIRxy|cw)j^GC=K7- zamUX`;xFS8+e?JSRz5h|Y?5Q!kFj^3xX{kr?XW9=cF8Z8PH>mmvch^Op!-fo z<`8*je{Zmn*EM2fM=)qyuPoi?lRH=1k4T2_z(e?bnLwN`{|F)@L`20obQi72xsSeA zolfDg!~Nb&9GSdXJLczJppsZ5%zw>Da#Q8(wTz}1c4pLuQ?rrVu2Rh&i}V1a8Gl?z zWKT)=J5Rs?_88vbm_6xo5)4%g-eY85?$-|>#(DN!!3kNwA_en2w!%JK0TWz|J9EMo za3Dy^t|0o`TYIzBS%h}cYjpfFrKLMzldDwt3)A?Okpc?R-ubURs>AKwu;s7wh-U?L znV+>sX8d4~@3+D2NfE|RvG0!Zd8B86S(C2kFZS&8N7fwegJr#}-xtrEXpmGhvK-Sy zFF#F=njU11kvM2RNMXYgJsU| zHG#A+Tiev=1iy-WzUg?`MA)pUt0nWfXNsHM=Em~{NZfW?+4V~GS=EEPR<%=ndYc{& z?yNUc7GKYP|9r0tzM2np@45oHp;5&F_s48{aLB9zRO$=c>kMO zOq89TvT63X2VW7jt~M7MaH+7Txmi5_BAs7kqfjxIY{?}+b~vG!i+?-w-ej?3XD4v& z@2k}%fQEOWmr5W6OMEv_4g?N=lTZm7j{QYry*rvL^8o?b(U*^2xMJ>}>eQ&yPt=l} zUhP3Sfa(JYjoK83t>!=3{E*?*=t!{Z1b_wK)@lGIai#5d`i>;EYY?lG!FrK0z?@=CyF33oXY_U zidX)_-+^qrQg%RTpMY;DMou0aG3NFJO8hzdZj<(!s^wGgt(WLCJyv)qduP3=$kXq@rXAx!C#wx?bz^6MV5*)rI zOoj2WFv6+NyK%PNj>d;-3oY>b+NJ4gX%VBW^C~(OYy1~SrZ0Wr{9j*ML{Q^*(XZ6D zQ>F#hW?CcvaoFWG9X~3e-!EaojhD57SnRWk>_DhJEigWVP2@z2wM37gyO&Lq9>t$L zQL$GF!YbVbhEx{6heiS3xS&S3?Q(ZmenCNo+e#csz*S-k#2Egd4nF%0f+ZDWAipNv zs?Vij$54s4T2{sa3VOSphVHntHGIs6UF-_~BB%!H{yl(`s2IZn1(hI((R*7mU~srFaZpp1TNwml`-+ z0AIf4kX!cqvfjig=bDibAGf~knlT;RR6d*9Jh;Zzsf}>uf&h>20);e^n|D@6Cz#G_MG>Bpi()_`^!w_O_dU~{OacEw0l9YP66GR@o_m)hl zcJh|Ug^^9hF6P)4Y`=3nl&`cV&r^e(9bL7fwSfrPI(ScAT}Tk^uiXghq8u85JG#$B zUW61u_;WN5EvBu%glX+&WcD5&e#$>ebL~lLLiaF*=xlQQ4!e{rx8g)q85CJ*_u&rjOnhI^8E&~0n)7)02}=_``R?DCr3t1`K~svVzx}HT`>Fm z)29jlp;s10?+>-@pnY%COO>?9Sgn8_Tj^M4=@KX4JuV>n%!KT{9YU>^XyU|nBMCGL zB<963sU;#$WMs~!jPUFs;|j46FinPqR5)8B96_h7W~-1RCHA_VecP&c2{W)OZ$nLe zy!x0%V|8_Pc-=ej&vzbG`o(ML?GvNs1UiXywfiP(V~%Dt@WQttcCNff!UU6*gV_DM z?Jq-XaEzm1%vu5}h2%{3tq*&Pczu=@14TkjhZ0ZiYU(gGL9f*zN$2hE{BM+;UV@7g z0Mtj1P+7UtjR=B;RA|&(Zme2uY?~qeM}Lc5BPLoC{Xb<|__ulY?j4fYbmQvDpJfXo z-?$P#vc9^P?Dqdrsm_dx7qj@gMXwc`R{3i8Cbm@|(U}+U$|Ts^i3{N;N`uTbL;OnH zfpWyfPmwL>_pz`*UaQ|$E;{l^!!=~C5Ve+Az6-i=ycXPA{(|10hxiKiP*BUbEz~%J zkt%waXTofg&vc-d;o8tk18v|wN$D?xJeZ0Qrjj_h8Ki`>=2r ze_e)areeK-ORsL^v&{H2ygLOiOwY@ZHMG2_DEmI=j0v^NT~DT{)bJTOhPX->IwyVv zuKL_*pKWq(k?h%4kE|*v>g~V8d#3eecI<)wd+52&4~*1a*+S!*<*%50dy-c#yTaJR zyLI7j$ssFUdcA~I*E2sKDhLIlCs*AK zrHA##E-B)&nFymuovGiq+W(T|9aTh@n*lPim#FCKnH`k_uUJki%-(E#Bd=C_j1bN< zGJP$g%9F>7C^CR}TNp8{Biu$0Fx{N(%z&X2E5{!Tg+ys+6<{YDMo1 za$)Fk?$h~j8We?Vr(z)j(DMt2-SSsqibWvKH=sswLI^H{FVdpBJ#j^Wq4ZG^P%~j*iAwIFi*zM{RE*B zAk*35>9g?L^fQ0QMYjC|np69_I2RtQPZ(krfmN(IX{?nP0N1PE2xs%=- z$w-p0O=ZdO+g5f65{6Ie26@gc1X=S2z<6)J@8SvLz4EvAu=I0fD69;0!ZAV@Q6JF_sR@SEX02(*cGg#I?hU7N-i(5^UXc9bna*D+ z;J2k&5`gGBa;B7c{rSGLx4kz3oF7zS@3}X-DMdRjINY35N_2r>+Kk z+N4czzPnSX!{qtvdZ2p96LzXLJ3_5n!<>a)92}X6CYy8d@!B5z=_)S{62KLtZ_XNM zPA~wc2Ww&J4ev=`-iK`Lq4gm0V@-Fj?>^2BtJyaZdX+95COEik&E-yk zJ$K*NNP+-JQZpjKS(DezKStx9S#5uM&3Pfcj;Op!^@khk1>ogaYxo2%4$lAlagsm5 z9A}F{J+CHKoXB$Iv`p43K-2+}*jquzYt;p)6y*l%j3W%=f$>io%;LmjSFQwNugOs* zv=@H5?FQuKh;xJbq=0)C&I<4dHNP#FgGbKNIH9LA=aDv%ZC^ZMU&n zN0Vl64?0wVE+JXf!cCY!l+^y;qEsllsib#KcLD9&SF zHjYzotRf78#9+j@RmF=0@ISpC#u5oyT5e;wy)fDscnq4{4hw`qlbh1eNrTtt__9!( zfggUe=Zz99Mhs+5&d$zWC*u+hFJBULGX)KJk|TCLCA%fjfOULA9+u?SM<}IC0CEO9 zWJN9?b;iRytpe?(5bO}vqM0Jte}y}Kz+$jS;~c#8jr;fe>UV33m+n0HlVbHenuD+L zt#s-QSo6~w%bCQ;6~?ZI&Ww<6)Bpt3#j1z=Q17&=L1*&BB&;rr(4g=OV{rQ{j;P)Y zwtEFZy*U;DzehORY8OTc2wG#9=A^wx9lFsaxUyBF_picizFXvL8gqUdQJB298j0aO zdi0*N|8JlAW?{L@i#q< zzNNJ{J^Qqt#Wl;)zlUQ?vcU6YQrw=E!*4Eyl-uNH4k1XcThN@rr_a!Hp-?wyVXq~j*yn})zGIs=jG(x$yP3l8e=fRwucF{ z4Mc9JdI^Ct>gt^1n^{6;Yn=2Hd`P!4U`5OfT?X$g&nt?!uNEo$#7J=NNm9NCIYT0f z-(>=JlhpW!aWh@_Y;M;+a#0?ayMdC#R4Nl<`Ne=+-oFn@yM{%j!+x(noBQcF$FKVO z7h8*zIhzPGUl};egvrB(mR%%Bt;-;cTu-$pg&pDR(RlR;0epyUha=YtoJyegGXA@W&cjN9n>kq*Y7@hBgn+&9rK{K}`Zf&ABwd zgx?zq$%UMf`j+Y9;3-9>- zBVDo#6p1KaKBh%>KCd{}t1)6D0@$&*X~7(h2~G98ckDoq8mhS=@SotliTh-$&n(2z zyJ;BC@ST}Iae{c*o^?~(W?ZH}wpzc9y(UI~!PT5FClim5LX}{Fc3a(I$+!i1w1Fr+ z5k!=LZRgX8O&23p#VY8E6p|7~q;5FO>~k~78O80?M`9j4_|@^JV$l$s3x2S^cvv{T zb+-G921s=y)4eI!d$oZpDQ+=PC;O}Vi?k4ax~iQg&3{F?Hygdm9Jm}>{-#O3uT1$> zdnS-tK>-1wp#CF3WzyoeJU)O&4j`BzlCu@;K*`a;a|>*5a?ZW^!&$&?2EF43L^{BSM}ZA^q^f81h@OU zR(H@>A0m)lfGBI}Ol=E8*q|Tf0Vk8`U$n=_Ug=ervu!?@eBT}BebWQJer9m+^~*i0 z$mcduUC4F7AJ7$ObQ_*Ilz!EF)ju0LH95x%4#N@Eb#fwsU~BnFd#%7lEhlXV8Y4rdPTB96`_ zFsw>3<*Aw<;|wbaF3h3mK4#?6){8~-Q5wr3Rzq{6q+CLgL>Cs8as>_lnjlE`R_v|N zr|CMptRnCrx~;d|_F~Gp;QyGI^q23`*O~<$1qZ;)k@rb78E8cQpDXb~^jngfD+4{! zQz+>c$=v+sP;G69LlxXMd(?f=MS@Gru$crKwqzz}hOv9;JpPZnNcs=?QSXJcftFcI z1y0DywyOM#;JJxT(&g5TUuF_=9BVBtW@=6^85K7r9 zNXY6?=_sYF)1+3X+vhh1J>E(-Gd2m*WzC8|)}=3out56628A`Sw=MG( zQD2~Iu$kyRlbmw-sG5xJ8JZ|AdfsQ6Gy{uuNLz^65KbD_Z1bp?OBv2RpsX113x>OY zI`0_w&Soa!CrMV)1ICupUn+ZRkpCFSiaARhrmLNcztots2^P5WA? zYDn?eEgo!`6Fcmga`bl4m9KhJU6ccce6Zj?@zJz^IxJ$B7V>uvbK@z2gc^9Ky%;ko zoRySDWY`nO+LKv$1hNtAG;^)XgINKnqamhOJN|$#C*<-R!77O&NCyy89zP5DSYcdb zsNilemhS;1e5HM3<&VH}tWFjM>x9d1(CSO?-b6=ME9(H+Y>(gJR7NTcD1TRg>MyA! z0CMhCX&)HzNnjM0oD;55$?-1RuOCNTc~~7NUyb*?24klUBA3B!_HatV*3cae$<%1S zo!_e1N@CwLELUhYT(ZDsCtW-h#qw12SU_5#54HZ~~gH6!c9$M0;1 z(r-0zJ_&>?3qA3z=)Zhq$2Aa?xFD-S`^yl)j&D0FH==;U9uIk1Y-zN{#(2xKR~1&i zn)@s?!&Z+qje?{+4XhQ)gKsrJa#58&DHaNni}m1oF9Bs5wNhF*R}K%?%=V!rF*cp}s6MuqmX&{(BdVwL6`dcbW0&LL0H!JzH-?cIU zw3d3=cjL&Li7;Pl&Y#TNT%nIsV3zWJR!Rvtkk21l<+%^0L~^2-`wM=u?k|a?G_9+; zGVs{H%~u8!4}Ry}vL@2=8-2q}+uTu|?=8I2eaDzkCZ_@Hlc6Me)S-u!ZZFsoTDe%m z`2c8QscYNT4Bg===>vn*;~uACg}+NV&R9C67dw0qRa0!;UR z`1nQX(^Yvlz8+n={KwC8k{@T{F2!RB-S_47wJQ2VRh^nsV^m1JT;j8SKHSG%I50W+ z>F^n)meOUvn(MNDVfv2LgO8IP!;d?#z0&^dW1MwMdNbHwsmh*&-ydtX+aSnipzpV= zA=acLcr*q4TUXK3R6w?74_l<(^gMZT^>NDCA2jk3&4=kPU-4g5FWgzEdi(SJ7oq3> z^xLRo@Z6VG**wVe9*R+*I(^0EELJcpDnP^qLO z-m^KgL&C!Z!v)ZhCNq&0N1oLS1g&|?(v+%F%CHd}g^t^OBQMcoK!E=Q7O>2oFEYi8 z{_U3iSNy#`Wh)Ny>_Gal^ZW-Tfq;>Icnoo)!{nG~wDJp*w`JVNzbrYogn@99*3lmO z$>(acv?O#>8e({+%!f=4htfL6@0gU|Nptc)k`axW2*2$M+)4_kQ-H}Rfm9H7&Qsa> z`#d<9TkCgGnCy)gQZELOJsW?KS$ZhKlA8}uw0g^af2!%N@bMJ`m~4{Iz_)U$1oPAt z;8nAT`dGRCfTGkC(23ai(C=qz^wWl@9foXnTrl-SA9ZF*`_Mo(nkrTQ;}mtjPyeSl zJr{aq$)Ch0e-aFL?NpM&^f93Y{SW@|$t;qyBPg&jqv>u?5n9|i$>krN5Pnho$%Gbc z@Oh`tJHqM_Ah*3~{&@LsIf8h`IxL4leOY;Hvd=prSSMnnm?j>u3W(fMXg{}}q0skB zt6SC%9(x-Q)FG;5H6xMG*(z{+?mJ_pxwIDk@J{e^2Bi|JW7GHneETLHvBu}Cq8RiX?6Y2=%o3uFJI=h zBh*L(b~j+UZ4#U6MGN#4e-FlaaUU>DPyB*;jiPjYSfkEDYOlOH7E1d_q8_)Y36GDS z5Uj6l(Caq(HO7u?ZIQ~XdFmk#DFgtm_E%nqS-IB+YUFE*r+(laG&nSrF|i>eEfZ7Q z>_IgIx;A3Zs?@Oj*0oxZ9LWH5zJpd%rrvateF^xxyp=5d0IKpR6DJE+I)aRSp`!dV zKIw!nMaE1Q)gu@)^S;8{wO)_ly9iNOlUu>Vw>>SDiWu+5w8HQ7@w zp8Q2)aQQs1}iu?~Q@5>0jO`BebTg(kBF8OZ& z{EWwc#Wr|k|24c>?c8X#vE;$G%nt*Nu7-_|6Je$ql#ij55Kk-!DGXwN5N5OgH0Pw^ zp@<&8$;CO8l;|AdzSwPIZf;_pv+?HO5vK^fH9)#Hk>#^_;Qp#a03k%;pxDvbeRSl-@W@}gSltoasK*uWHFp0FZ*mKm zsxor?lJ=M8g&TZGQc4PE(Ur|gvy$AqjlsQROWF%k{XLo0b*czqo?WJ9!-mK3!<$Ao zl27ez3@NOtX$7{qCiCqF=?~u-a?RArEC%j;|Ig8(E;X3#cB9y-t>pK>b7N{jpIb3l zPLTOBsw(_;C!mLg&A5Am1un($&RI~R2NBF>mWPt}j;E}CKD85gmScL@R3cZZN{n0A zMztV!tV-!)e%habspu04+&;_7&*$+#V8qf@SSJ=sey4qr%m3to?XAdEUuKaN^Bq$9 zh0z>G5dV{fZZLex^wdl8j;!EgTm-&-V5mEpUY9>qeL}~<$dtYv8{c!sc{1qAZ~iXq zq;R<(B$D*`)eAf`Vd>2}8GyYX!cx381E5`=c?{UGVdEna>lwhCS|_OT7bV0PP?RL~x$jQ?(9W**^nFIc`o9BJN(7j(e_j7+V#O^rm1Bre9YO7*Yc8w`$qvnvLA<2M%3u@H~L1`f6V0$t?fqL`|vaL zsRD^(27;=qrT;Wyi;!Nfq>uV-cykU~@4-l(#5Z$uteP9si!t%Fl?);%%AS(CqvfmU zo6py#vT#JMgo1S5a#_`fQf}4bj+_yo2C8jXZWmwql1k)6t2ML~x41;LVB^zc4y@3> zvD9y)VG4B0LbRnDHM~F$q%;?HI{U4ID8(>AJaZL2KnlFzmGX6{+1}dQQw6J+JqasL zA|JPK@|16#t=!&Ee$ncy715?5#QAORN#q(gKI>}9oAr^_uk$hB?1$2iT`J_T=q5{1 zG~uKFUgyqy{Ox0{amw_j!n(L`?8hD6d#9jvQ_FDL`E-%@a{f(-UroO44m|qiZCx3^nQ|JyfzCz6NY8N~10wxSN`OP2Tgj2weCFcU zHvJ;?JxP7UfSSmpAm;;+~4nijNS{oX_!SS}j_^V#{Azvu^R|zQz z9UvI60=)O3$k6M}|LpX_F^{K_AJ5Gs0E(}$tzm_YgxroBN8qDBn%|Yx4Snj#wayd& z(R5+4UU&nSfqy>56#BcWix;Yb79Y8iygoVdJWPebF`*;Y^Lq+UuOq%Z8K@6G%an1K z8!JnEu3OEAC7b`oO6AKRL~glWl=%u{j)Yq1)9D_@EzIvjv!@3HKQVj=53KNy{P|%s zlKxVScC#}%uB5<@)d%8t(T+{L64D`~-y(1S4YpJzZ%S=?oxZkYGL`b7x67Mua1?_W z@UKbAO2>YTmbIN@pmCsK(}M0V_b~PK_02y>gadY@!roE}Hg&|M^tRswM>QR-#$&Q> z)-1=dnBUxQ6Gi~9aJZXZ{Nex^G)up$d+<~Lp+{dO#nKjLGS(K;!=9QGd`Q`ACq;5G z@@~JS`A&|#H}9{inp8&98OaD>6c@h^bw#V;_c8-WIFCFfg1|nvXFoB?&(7 zeMq9L#^e7B5k^ZaDF9C6EWF+S=oK{VqjeE7ELA9@_%Uh%CIKi z_wRdSlpx(*5(3g)qq_~dJEWv*fOLa^NJ^?mNQ1*5{Gnm*Pi?PdyfD6z1VhK z_jRA=Clj5pLGZS&2x~tR*?x!n;+z>7af0(ydo<^0mzLwGKi&)fRnz;*r*PRF+ez(< z;*D+7#+%!}7hSO%g~0@giHRTC5LD2#pUTF-+*=rt;u0AyQkVqp(9IhK!wIC)Jsl7s zDYo!XI)V1)0yg5nBZ$I)Cvf%0hKu6C<%HZV@BLTQb;)mvlS+d3l0quae?(wyKf1!3 z6ixG}xc6HS@$C@u-oFNd=9CU~YiF!;AhYMAY_;mfn+q8+B%8jfB%&@KMw5q8Vtca; zy7x20d#Ukm>3hsw_7sRs3SMB?enCPt@54axF4fQdvMsc&t?g`!N0D?`y*}(Dq|S}O zRP4+uzy|9TiK{XdNda@i)u}zubR!UI(WYIyfVs>oh@5-Q3p*Yef#e9!75R0XT)m{a zPt*~`L0m+aAwu-OL(bbOT21t*p2BXnpy(qJuRXfqB7A;#b>!C7qkyE+hNsXIp|=DJ zL}@djAcF+5guf(6Q0Wn%e|r`7@eySD6Yw~i@8NFcLyWkj*N2Q*hGY;$j9aPs0)ZHX z_XyB@PZ++5)z&E~^?>2Ej;C$`?U@*6C;`z(1|5UY@e&PRuJ>o+HcDTot@QP?$y4)kEFYIB&1J9CTT9acbj!>hp`V-nDgX4R3V}C zn7eYKF&l&heY*y}&t|%qUwUDLP{R3#JJ7v_7zjiF9OH%;Bgk{FG!rw#o^j?6Al*Ci zog^%931%TB8W}OlaxM9Q(=PPX5>0#>w&b^G5q?_A_;0JSsQ>$S1yETgn&>9V9Sg+) zDVQs;stETLMEjrueDf)004$_TCYbPQ{NidNz5f!oh;{}uM-pKqOgTT7rNVD=E{np@ z!xJ%=G#g`G(L<*=L|DJ>#cv`oU*o>tqdr$?px5(@oSk(jx`dD8bUwV7DGl>VvR0(O zut}fkAHrG=+G;AhA~-9T5Y8@Aw?1RL@MjqC#kL>5Xd-OObWV zveQ4N^qeuM`~W3Co4|z{X2aMPXp*r;Q^ss=?C-3=0EiQQ>JK~!$HG9Y%*@AG+BB$H ziJ{9XQDK@A)@+Z&P1CI_qk!n!Z<}#Zq|7g-KHZ zxNp?AJ0`c{AE%?%f2o6FZ>>ingBW`>r-Yby#WR)kj*;P5Gj`$4rH+3|{}7Pb!l_D{ z`J;1JYCqjLAn98c6Bxrc4#pR!F?)4Xs{bN;Pw|J=hT0+MDfz4=xqZqc0Uq8b%X5~} z$s0weM+47-x?;KaZy(}Y1WSRDWY>~-n=i*!%2`=w?|w^+=K{Yv9ixI$)m(BCQOyYZzP;^v;EAKrer)AwGDSvO@v}lO-TD1c$Zt5Ki3U zkO#g+PsOggQoFB)(23|fLNw*|>X(3h`ll7K-=bow(OkHnA?}=c#NBc)zpgVSJ&aro zAeE2k{%o3t4ZU^k_FbN5Y5DmcdTN4yv(B)sdaqc#pt83szj3O32SmA2)cv*XwQ-8ALmW`9GR zh;|TVr7jTstD4H%{XWak4jMJjp3g?Lz|uFuFDQ{%)pE-E!b!17f51uaJ9{_;sB3MF zQ;a3Bwz2}c4p?2t2vP$lnugy443PnWWlZ@0qM5~Qai}p?^l8LxdAjz0N8=3$b@55M z)=()@Qo}5%wfZ47zve+o0`yWv(t?j1bCF`XiK1RrNwave%@?x8OfsmIL{fKOgIJi) z;@m&0qpOu}YK$oC6e0w6j9w?@vj6Sd)sMZXd{s6?NR57IzO1fc8LN#rZv}=u^t{!~ zAjt9LRQ(yp2J`mGqP)x7_mOe{-feJU zY;>E1^x5i4z+Te}^2;$h&oy&PCDiYo@$8d{8GX2_KrAIeQQy6-E$0kPRr~ovu$Y_! zL-H`;jCheR)ie96uo9rnbk#h9575~ANVGnQG%Mg;GchRGCy(>`b8Cb7m9S7@9LICU zHz$gjhGpFUjMvHni!|2ajeYoeL(zMS+7&#@OQ@uj)Hfv3c;s6Q!xDyiO>sh5KMC-j z@;jc)Yn*8YYqX65{Eu8>3vPx~4LNg(Bvfg&TT^jXJ1f3M{@pVo9!>DIeqt+3e?JxdUl3bbo;|d($KX>_m#tHvy}_ zN_eq7gbf-V`&sx7)o8t3=qs34c7MYFq}UFm+S(|j)2<|+4`Po{)_wf?I%hPA1gTw$ zJ{SEr<7{UYq8n6(0*>{W>mSk#>K^ltSze`v42kZ_Mo@aWDZ;RxU9R(;U zR@d&9DZ7!kw;k;k#1l+h88+s2*YAh(akC{lwKEqUw?A$9_ofOePOz3=s>k`?qnb7b z3Q#`H6<1A`dUupkpJn!^-#^@ji~p8*9=wNxBNGc7=V_C^G9AWZTC%XiG-9M84&T`Q zk-~$>&e17paZyD}5bEdAzgUu!T^Ex*Q4hK3zNaKRzS^u0AjP^e4-UN{1)8gcr(bF`ak|Q2RSVSk*;ur+6g@-Wy(u#zG5Rq=94mUk;0p0 zCVbU%0eK=vC~P7hm?%T|PPrV7BLco7*X*DGlJRZ;jp)9el#BP30r=kx=)RZsqA~mY zw)8K-q6MCEwpnHp4;y5M-Q z)6?~77$WIkb6$<=lbqyibRq_y4Fjt?CLqvF3>jQDuAX8kYpUkKVD~WA+2{Gz%@JGk z?D4bRFs~Nrm+2dNDg-0LOUDrmT4Q`RA5ErNPh)E0!av;W2nLi95HHxtv_H`gt1V1_ z^X}fG&@|58Bl)=As6G50n{)G@tEXaaXk{*17&3@lHCD2_2XM15Ex#YoNEz7LvC%63 zoS|Z}>?1k(sPBrtL9nHRt(aehdEmzcm)Vz(v=*X->w#1cHILuvfVwAtROpMp-GWqF z^*vn&-^MPzJKpARnE|RqD_oC73$Ux{adJs48%)?$%ak7sWDIXcY6fD!!Bmb$x}{{P z)sNf_wm3U>9Zl9#XE+fFg8Y-j>7#nyCg4V;Te|JM@<`oy+se3sJ#U!>-wc7e%`!Z_>(c*vvZdL5g&DHqYAN482JpN)tTp>+;~hk?=JG7Ka0l~NXm%;w zA&7?X{**&JWV0BiA0`^>ei4EzljE)$42lD5ILWVa#dMalR!TWv>_`HF*JoHequ0lT9Kxdh z8Zn*Xs<#7hN7{LB*>*lugtk~{B%r$VgQKVy40%C-RUSAbOeR+`X+RfWEXMeOo2Ui5 zo>t1&em3}^FG=wPPNO>Hg(CF!ANm%xLTh>RAjHyM;tj``wev08cNJ~yyGF*hqES$9 z-PE^2{Yg&Jn6v8{&F9|DBxS7a6!fc!-oj^=9LJ?DAKW#wS5L!NTHceooEQ@Ih};CX zdrhw?f>KW^s#&(8N+V1roMl|b6?H}~rnNtNJ~c*3J7p2nM`k6@T&G~ouc9j_CWt$( zx4Dlmk5q!~R=fkvn%b}{RV$H-3u3-H_o|@|lihw0KkaZfL?HYm(D^qY)^)b>N48Wt zHr@RP{hHwyjsep|mhc5*fg19==0sT`RdnOXGYI`r{ zBI)p#TMV3%aDN+?oq?{kzV05P!?!%#bet;9$}PPDU+dz)Kt0~OMe)#@q_!Z)Gr1_~ z#0-L>;C+eR*)JIG?(XTbw&{kXf&{1)FA6v!>45d{Zm=$p;XD894T0DB5!3`~uBj^F z>{CC=b_1zkOI?(-6cc~91u};L(>7)+n?i~0$a|nZ?#}=AUf|ebRwv%{6;USi9#`Eu>dvktLIoX2 zR4gf#5bbl|M6i!OJP5-^U!kv9&$Ogt%F7>AII`26a*?%iM6(z5%B&nQl08GV^V+vp&b@0-2McC=2~6lklxxw9!x z==3O(XT>>;&ufVgu%b&u+AsXOqE70%Pa44q-f!E`tC~Js;|r$_4Gkq?nm$qBXDIJ= zeQZS36yr|GbptV>B_Nu+b)ucw*MEqO(@BK$rw8IT5sLwzXZPPip^tOMC-lE}qkGU8 zO+mtp>h?io7VNPKV-AR``pD~ z^xz5~u`4@Sj}e{(?}ay1*grLH^xMs3;H>`Q!<-WJ zP1>d;i(6m=S|Xi)E~I4eigI~c{6dS_nGdO8A}*f#9q6e>F;kRn7D*={GRFclH;*eVd_MkqQ!kz=#A(4 z2z8(?3m%;3AuD_Gkx-Y3tP0N~<)kETC`ssCCd))cX*!1lA>a`zfgByx0e{}<#raYU zpqcgRYD(4oC7tYa%}GX>u(Wc7=%f=#7v`-Sp`E+#r# z5i^wbwU3pVM@MSx!>1KvT!)N|H;ng7s121sE6HeKBVv)f|57KQSTq`don`YSI0Wx`(v3 zD^W~0rPQQKv0U57c9tMM;n&?diCfB83{^c3P`D)g75Mfk;x0P;`Ea1z=PV$u)6>2p zH$9|nEWpDw{<4MaigH7n%3_J;rC!a{;m}0GWnb06c;T3hp}*ApiSaA^mwijTMOds8 z2a8|*S7POEnL)DW{a`6)#zC6a&Bd=T~_j}${RGQj9r zne9jOrxm}$7{hk(iuy3*Zm}E57go6~804br^mArDA)B0wPH%`8Mznx7bA*miRkGX6 zE)^ykch0BTT;xR~(~R3Zd^ja>7xp!&oSRBf&s@Rxd2)L9UO)Yyo#5u?CZHVW;l9 zduONFh5$K^Z@dcw&w3-&+4SUcuT$C&+@^AuG6%xN;{c`~eD3Tz=3lLgX3D`OnXolaDIre8oiwxzU5E%2K2w!v+CMfi_$?p@h!0$z z(s@%eb}kkm4r~RTX0l-+M}3s~)z5K1KB1$*JXa24)21h7i{KaK6_arGNbjP$irilV z6e0Jdf3XGdmsndualQwt4 zUnXQZ=vP0wN0P6TAxN%$v%5!yel1?eh)%Y~9le6y3GXSoMWF@Sv6XcCmkp>V8%{p_ z-ga4B5pR0N8swx*NdqRYdV=sEQV!gSk`B--{`?{mT$7w9dj-Uo2h`yDk@$1beJOwC zOX$JU;SaB;I}b5h@djdupj=BX5@pDk*=5-2u#5^_jtbW2cWkZjvcZ|7QX+=yu6~ap zhwbcXcNba+QFr_P0$@-Car&!t08~EtwDHtai_kIU{TPgM5h7u_W?_SW#tX!!A;%?R z&j4(mA%aR7s%gfV*x;K?CiG+XhKy(`hU=VgB}YeWqP6{x)|IuKRSd!Y=1Vz>`81_*L|xTTob*a zp6l^M&OxNztP!`(!Hd>n*D~&zORp+E=8|;pdqwOojg4$ow0Kg;Tm1SfmTRd6aE+~6 z5ZDXSMpMmqnk;05m~Th9x?5k4_j{SVDN4iGo+s%&-m$*fs<$v&AZ>{cGU55ke9-wH zLSsxv&#m4j3F*>&?-dLELiaL?&gq}zS_d#6cqWhy|ykEAOw!oScNj4%kfxEa<1C8lbD&&~R? z%M3XUw#0K^d@C=DaH4{PiCC&~Aq~RIXUEdpi4C99hBrCt?)=J-VE;*xfOAGOZ!!#V zTP>ld1%wE6BUEL#jo9-U@opDZgiI|Yx!C2u7pDyMI`bqKB>1sRa_#v5Q}We7YYcOvN1cL=XvGZ~3x zQ`Toc6R~eyb%a8(4gO-IE>^mRpH5K048Ph$1VWp$lK+X0i=ljHRD;nujAy#zUina4|~X z$Y*@LckrX;tH9>gLjNiBlaTH4#ZR$)xNK1> zJJS;~B5(0YG)6UFYbcZ9^LO{U7XtkJx^_U?546&$+~4NbI>bg{=yL|S0lW`KJZ}$H zw%^NYjqrf`o4{_e>l0d=9vm*!P(3((>5yKL2m=NDG=ladhhB9y3b8 zZDh=!5xmRnkpQ<4><7_M(X)%?dG{AXJ0G-C(;OYkZa|ZnBf{6Q5jpDs4RnxXa{@gV zPgT>B0HFuA&E;6PeQj%j%a1Y*vULRM>4aE8&bCh2@4?y+p<^o4#nBo1K=%k6y>j5{ z-q!lG|Ic?8m$MixpQ(b0-`~(K_SH!ARwl<$wa2|oqzaRx#uGn6s~Z_h1yfZ@$wUda zedhs#rW94nFffcHPpSH^8WtRD{0j$Eivx4yJ%)|~P{wHf%cf&2#j)_g`U?%{XHw@r z(V#+AQ9~(PAbcX$dV%)N+#d+NuHj=nF47_@3rW&?tx+8zmP)wtB_|bWi>%o9d-Fh| z@xtxNssLz8XEk!X}1a_X+N; zsa&JWAAxId-;<37A8HMx!GrZS5kaJ$!f}8G49+F|>8(?s0f%qJDG$PE4*IhJ7&+FW&yp^v(g55hp-d>?29r_@%A5nk z(ep4#7nTCM;@Q7{8SEi{yb@c3o>q)1S3$&qIwAUrII6~c%%xl_GfNSsc<_r9Y* z9LW=Wqdmi#GyJ}#h3|LE_%C!1lQiEJT0Ka;!L^stP;)Nmn4V%-{KaE?>2B8?w}i)I zN}5VH)NWe`Dqs@w$Zg4bRWr@q%lWR(d#|&XDm(s?M>>9j_;?&b z7+@Lo&?&J)gs-J-twySd4!Xv(SjcxKM5nKS`ji1>st0}0u*2%wm6oncW8X2W4^u8i zk6+jfyeX54>{?mAVjm7vze+vOzE>Z5w`BP_kq!%zLLW+tLJu4uh!0U;wjP+>O`uf1 z=)oNYV&CtR^gB`{KfqNJy6FRrEB8{AAS;$H zL3_s`sQhcLa7wl}Q~UaqN5;l%L2Yg_6G*9EeTkm)Q*g_f?Ormq7ZqP1| z+N)=~(tn^|kFl=UFC!vF&yJgFul89z!{tEvj&;o zb8gzKw8c+b4;T3=1}1@bSi9OqQqzB%tnjppis)Q(7Sc53LHgGBaeUqP?R;GN_Gz76 zD{gHYM0UFV4cQ}yY3)JmZ8t8UmfPG%A^Uj);6OP9>JO09iZWJVSoRi3I=-Rdxi%li z4i#@6GX6li%7H7S=`)U5NP={FjW$P$(D9}-v%oV$Am2Oj6k z_NPaB?a2NJxGbxxym*KbFu;!|2V^hhcN;(+Rh;*lnp zi5n>;qP6vKjdDNf!#j_EK1J6sFS`hr>KKw(p+ zA0i);MVDF{0JUz0inv^za3l`IkEP9P92Rq~c;UzPodGB^`GF z1A7$7k}9e4hM;VJ<%aNrwF-I#@3%W)Q}{dd10z|1qi@y1_pL8q9BM%V_hofX_O#LS zP8)dEqt$xm?<_gbo+ zT>BHj#08`yxJA#3!8%4C2q(4^XlMjI9dII8`p?%;EtYxR1^|X|5y3;c5L7#p89w=S zk6Fs#twZJeqCtgL^MC5N{mz}|ZMA}d1lFA;w1M0iwU$*P_)He;sge|;oBVXC4s1ZN z>X8Tw)5Czc_M~TkmZwL-q~E(T5-jo zfBhBFjdz;qUzF|Nb)vHEX(Ni@CWYTn-K0OYeD&YKvUTh~8cg)C`C`_m=Yicm|G{Kvtqt`= zG-lStyV#g%B&p5;4~3y3`_jC4Ojk0VKv*>b1D;u`9lXkpLAE)wSD0vb*oe9wl4`CN z0%<9tsMj|-?X>~HpE!~yNUsJUA!kS%@1 zcp|Npq`O32e~MBvQrNsYyrrvY`%GA=QmOZG+IpUxDDT&=U*Y=J%axKbz*}Qg<}cB_ z@q1AV#YNCC&<4OrcYRbN^vEjmp>g+rqd&Iu?;mtGd4w2D4_LqHYhqkvX9ys_>IK+% zKYIN>lp*;QLb|a2^SoWyC=al>r8@$R%Q{=#Wuf4H=0>}Xc@i@6K2EuYU3tFEhr_|a zVM@f{(9RBGCwO094`jqZ1|5-Yg85!kia@x#Aid@{)n6!7YKUxVD(dcEK#Xflv4x7e z_52kbIQfy6`1QYXrVC%OksBzZlS?*J zt#!)`>P-2ctuLKb6>KKd>d#?=r+g+$`+4cA0e#&lqu$=8cIN@}A`8kj23DiTyQfon z!^#(EN;@FEz6ywZLslHCS(P)>Zm>7dnnX_Z)N;-%Csb>HhK_DJcj8if3FC!%g!Y}x z;Km7OmIlct9-}geaESXPIAYsg)%drA-A zv#&v50VKqeD`8rlRMJr>13_b#C^JR>=#!^G1C+BzJ&VCw^;ze8Nk(gB(^2R+pw?JB z;k0x)=LOOognc%|AZoz2n~@_1CNhH5e^WkY-JdqV%w5;8pSMy~>$BqT>2d;s(AQTX z4B&_Ju5UbtL0aqlxYzlRX{rRO-UE6Lk#SFqjDgdx*DK%62oh-D=GjFQEE5jDCmGlx zCK!-VGrn>c*Hln?jRDlO?g~m@XEOfl-|<&t!A?r|y5A0rx29$ei;}eA;>xGUiW(Av0;;~un-m*wzrRol^`c(f zAuWSqWd-=o0fC+hy{MtT(;Tq#%&hC$1%4I84tdV?l*5xLtoB1Pt5Ox_ZL(T8bZI6< z6S$CMwo<(##f3KLwxv|snV2=}dn`>2vN6ns0+|hX#JGBo!Nb$DZYmoc@}m2FJQD)vuah7Cb;LFd1?*{Sc*O znvR3obfkY`To649i}+mloVC6`)Q&CV2vR=+4Js=RlK<RQ-;+Un^SPu72_Okg%ej&&kw>yu4(rhTPa$$*yV1Qt7@b>w(3518u6z zwNKkf(S`uN*^RYZ+tJI_2H7B~dH(U~l$n%*p2=FezSTc0xhRC`k}Ub#vUDgf2{hgg z0hw<+_a#ZDb1fI;lbnF#EdF`mX(@s0`GpAMPsly)@N8sSnPu$3N2CPgOa(m&7v;6xq`dBO`Npg2`O{5m61$~AF}avV;%_t~PbBhB zjYngP`(S$pDE&4dR&~@eXlKXEwW!7zA8yAlR~p)UFj_tJ!DjWlKC_jjIGkO;YI@Fv z0)FdXZ80F_sNyxP#|Z8VZ#S&p+ClOqeIJ1NcNWhn5T37|3sWNaX}t12`%%H)>mg;|fy;2@^N+RbQP%Ib~u!gunhaNY7dp?i3RMm}8YI$xS&Ag2LS}n~vL`7Ca;AYlQ{hAp*}B z-pxUtd@ojCMco!?w9hfl^hPABAbeIP172O^iA#wlzwgok-5^!PV?p;Ex%O?N#QXOqX*s{X&bilP3_Z0CC@Q z7re7fx}qEwPWWeSBk|`sTk>1=Un2NJqZ7r6R5yHgjY)j5(2<`%myZVghD?iAlzEPz zZ;QTx>($#r%U&>vaya2$)gQh~{HWuZWlkAzRAg>tev;lKxE=6wMkM9gOap$f~W&v9*Amz^>dO)$~IrV7;& zBW#y^e7yhW9K#~ayF+v|v;KHb%FH(2Igoi%pZYhwZz+wF!Pd2!p&j7=+6t2ydVB5# z1mPvIkwW+HaP8oREC^ZbMTzz@wuy8P;<8#+{_f{C7aT{0@kPB9xd&#@!xnh><5`X} zIJfiN^RjOB=MhoT{5yEx0oKe05E78jrz-5#v*ZAM2w>Tl+x3!+(@wXU>-*a9yB$z8 z&GGkji+ZDh9#&QkJaw` z&Jo$noJQ>tew<0Tp3L$}vl3EYOqzGL7V7hZqYm2nVr3|1$fmeIXcZ)1D5{_r7BsEk z`1kah_kCm086pWt<8tx+N9}Iu1t0nDHWJAJX~KM;j;nQf_pHhufFeuk#u1wH%!kHB|D6^e=Zfb! zw)pnuF%52y-zk+Vev@(QS~43AXHNABI&} z)OUMJ2Lh%7lA;s`LWSgkvJ)P^29jdyDb{^?L3?JPQGU^Yp{{gH&iO9;5^BJ{C4}Ve zg?Vao2v%PE!UQO`I;mwGNc5l^_--Q+Iwwey(BX&w=g`#&)%eV{r5ntZ8yM#6-erTV2JK*hh`9q8 zrSo~XNyrr84OjkJ*jD}sQb^W5G>j5;6BCXMHuyJexgjl7wtlhx36ow9q;T~`e@as#_4Gb2jy5SeNG zYMi8gFgWY*+m;JvIOo(0hq5}GN9;dUuPo$zM$a?u>M3Eo>H%IaU8%nX1SRkoVp_fH zC@t8dxc){wm@)$huA%=filmNIxold{s$ip&j2e+;@}mbfnvExps&hTWI*h z+e#vWnwzXMr7?Kp$vfqY=SE}4-{kU_!e73mkYc=(un4ser}I5ovKMS!KG%J}QNPEz z-axhKqUvbMFxGiZU?KU6r4WY;H@|g&*0A^`DU5wqKn>$dEiQHOtJpl8;!%^SbKxvf zB#q3k3#}(Ohc63Yt($QOiffwA{iK7c3q=g{c*%V=fMy#%2t(7~B0Uc$T) z7PeHcsfr2*R`}?9|7G@2ZSN_0sM3NSD6EZZlei^W(_;!tY#1oQ%Y_Ta>Y z|IZ6B`*SS=_%*zg7FsYsTjD0sbRY8J?1BP0Qr}l6MiEirrsJ(*8j@OJvo`X7T7dNj z;y;ny!xW^ZmCER3*XG)3UTGY?LUG=3R7g(~6)uS^StZxgvDYd4Q9{aBc==V1ZIytEnl~Va@p}hfiE+AHh zb~51RRaa=& zR^TbJ#w8Dw1Pq30bL9>gRB}B}c=x^W4b{g?x61U~-}Qi#k^wfC1O1u?xvFmJ@-}a% zlLt3cYYZwLe9l9_ApOA+62Q`ASwslWfb@P*ABLulYJX=Xn$aGZi*HKpK{9NprD7n? z&;7tC%#dwc{~ztcE0x5*tLCqGkok?NVXiA=eRrJ58fAI|bpVdB!8Q8kPT!rYMr6+- zgI+Y~iSOvz_jk|p3)TiTkm09c+skN(2Jrv{|8>+O`p4VC=8`3G z+!tT>p~uzskk1~@SdX1(1CCIS7jqEdUkc{GI3VSSPdN~ww&B})h~8AG??p-kt!fb; z=K`hAsuTlOW~uSd{fb*kA6}VZVa$Y4(VNN^H=#fTk|ft)dzikv3;5+9*;G_wvJj8g}GnCxf~W5L~8Gv1LS_Lr1UHg2U< zSWE+w8WoF+%`!3*L7hc+my2<_DIjgq6umWj&dq^@ZLYVF2d1IgF_tynYq3IBlkSCS zfz^34oh;j;ECcmnmx=I|g$@qIUrxZ>`LJ+VwUYF6jQh0=ReTU1M(XaP1yVYFo`NF3 zCyWv32wo>XJAqk41=*FAqa4DOEY`}prytwoL$(J-Vf^x1;P#z{O@Ux(XNt!uo&$)G z53z9J-C}I!zX_R(PuUl<%`84ckyMF$^i9m3U5XWkMGtOy$BPKgCvh8Lo+!4vB51g) z1%S;=gau)D1dCbzDh8bG8O}}_Dp)$wf@YMU+BWin7iN`B|G*|;4A2H81TH;VY>;|8 z287#_A?Tn(!+f2DGL&B(swTx%n2sA#d|KO>b^O<4^2^6%*mVjD>w`muyLZUv@|U^w zrjnPGClDe^a|HS=zf}^Q>T}rmZZ_6w@-rCz%^($qxLyHm;ti&vsX%J#Vql&II(5S= z?IW7ydhFTnd=p*=t&ku#;%yPvDxGRdM>IH({1_1V{`H$QAvk@%czE`& zK&bS?^v;7#@Ur90&?QuGh8NBAmGGUqK}udA_axtg6*jEV_rGzYD(;YnmD8doz4`-J zVRf|L-|V7*)~Pb*4K0AT0?MBi7sZp7pz(&a`)7L@38{ui8KUTo*qb7Q;>VG-4+;6n z__a|aI`lI`dIk}tW*?Uae-OJZ{7Fn{WE zUT45tWKfL#2Ytht6UFx1<4@3tj~=o+xe z{6Kf~L3U+vf+gT*ME6doHUojxzSxaYW~#`a{>`u2>JfT>CrAE33+IBVf(Z+daDUv+ z0`OfcxY@SN{>r^m-*tcyeK`=Y{jsvHu5O79B0ZMq#_|YKZ_I&9v{e^iAfGOQ%^5oS z%qdcHyrfVjw$(k8X&jYlpBRPsjk5;JdviLmUEYAMM4%g|!uM$KOPHto7sMU_I8l;A zE06EcrHoye<>#VcL4s#5B%Z0x0Npo^*QP=IaEdKo;Nw_@GP*BJoviO-TcDzPkSz|; z7mX=>{+8y(Qd#()PzO&l!8sE?G)ZUVQ3dN(52jtWSzov~9E3u$DzBf>tZWi$XxS%v*(6-0y?L`EtU2phCI zO&Kd5B9d%7e?o2La220M9`TbJ#gBTsCob3p`ksaweI}Wh-r?8jae|R0?W+6Sx`pzk^&h~n$3nia;C??R z)W};5IBG@`x40fsLLvGCxUuD-9&}n<@091O^b^%R_n!*vVk7?lYP$-g93nm4`gSQ8 z)wkOF`c;Z|A4&7ytH3wy*m^F*wmu#l;^O~7d>#yPi5k^45KLUE*Q~3TY^nO9H#PD& zY!28&OOp?X0i*6rb>O`m&xM1z=7}{>Rdr{RHLVorEO(O2(E#*Hamlk`qL1^3oIS`d zckC66{CJrcyUTfinv0&NkxbEK#lE9Yc$RZ&JEC*`O2D#g5o1vYF&OJpF zQ`ti##w>{GudlBIo~rBsGk9iJy_cmdSjI2X$xk-;-{BVTm#K3h_=sv7bt{`8#pkHexi2yOjUCEo>M$tb~@9L5cqM}x+TL@Iy0z&fi zJqP}~%G^z_kIuLBpYHfhV{-N;R6AvW+;s3xQ z8m8}CD>?QfLykbxQV0TeX+KQ^pFJ4tvDpNWi;Ih#WDhQHIl>>h_eK7($fb$jUxeOB z7W+9s)D+;@yQA*`-gMxa1ko(iMGZ&hhOc4$pN zT)f7^Z)b-u{0Q3U1_*ON#O>xTa%K;Hm%qWRGn;q;iBrxPpOWoefVh7xEL?beI1};u zw4`6+qE^&2X*q*m*$U zoDoCNCi8!}DM$5flDJC(AS4}PCq#^!_EQN4YE05a4LKl2Zc_1`{BCq&A<1taFpX7_ z8>h&seMvs@8%B(~YqeO8%)XrGdw4tS^Wn-re^ttMe^c&iK?96qRI?9K%HBEH`{piY z{vVx`GD_gdpt6Ei6uAeJ5kenfbxB&iCA+Ju;>zKwYcEq*t|5y;Wp!C6AZ86JLTO4CW@?^rK=lBKb^yNPt%?=+>E?3?fhMZ$IYFr??pxD$H` znFpI31enDOr0Re#!-G|O6*vit`FER}{syA{wJvn%T>cIjzRMtXz8- zX*zGMdWx!#)hQry$8#m;NiKRb5OO@T4<0#XQ&TBm5Em_c$oT0CTKEHNXv6Df)0bGO zb>UvF$_Lq(Y127^MR&oDf`(O3Xfzp!BhK*_|EF z9YL*$AdZ@f>8qCJaIF@_gGulpkF1o1MK+9NI<2MQ3hqIri&48GCH@nlJEfRjSN&Z>l2+ed7S#Yg<> z|J-J|YpXzJESk~+-emH~&lK_O8+<1h2q5*HYZxbYU~Zh#&2Hg&ojHa3xz2B+0Sm_DU3W}G#$a+Ue3-ftH%f)#raBV?)`JAX zfL3%zJ5bF&2ZmrBNhwC|2JtX*b}^tCGoq4{56^q9u;>5r!8AQoblQ7fBvl~4y^_Au zdZkg(;I;Bk>;DKO@>Nz2G}VcgOq=$0S;bdukm(dl$dJtKVF5@EvGY zmmL4oSlb+a#MzQ^c)6`G2*fzAi0uUF!Jp9k3pFoy9l zXP-_acC~KD+DoIvGGDsKis!$^eWL7=r!#k9*F9|5^a|2%-nZ@429r_a;80 z!foCcqFvAoxF#b)3X^rVn>^v;tJD4jB|SAsYgUBFSnm&vEDEsBEtLmdGRTsB7}j^q z12Ur7T)hyd+0gdvT7w{!zJ#9pUT>Xqk9NIe-psXrk|MAqT$!);IVqtJ)D-_4$KP=6 z0^e*7riqXvGA)Bd-ih-IOC>6s2co>||5C!A1A2oNrJIX7Mw=k8z3_o`jCUEwZ`|hX zBCn{NjD7P>Ud&w_#bvC({gtyMOGgdHBZqx>yLYi#d1;XdbWO#84k>wqA);p=!g8>hB0zJIk_BJ z^~v9TXUS9hqCjar-Xi5iTw0QUwIY)CE_}Jwo>#RiTO1AE`uZ}Z(f~C5?)#l`ic9j} z&ys*~!Y|~Jz0Fi3840oyPM?E>l;Ci}HC z!h=9w&+!F~G=Cg-km>y5Uoc!U7w5h~!uM>D4Ukoo3J+kuNOkfOro(5@rBY;J=E?kw zCi7NH$T1L+qKElkuY}d(Qqrf%>QE9X`p3yXf1&}|2IA?VcGy#ob-Y;H2!@{o26v^W z$}(TP@4Vtal1;qYPo>)3X1Emij7OL$>lM5oID1P%L(B2H7>B}m7WF}d%J+WYE%^;E zo=GI9%RNg>1XIf^MW@~Uo?oX9l5P9?xwJWQ%=WM^?6tSbqM9sBy9+f05}4J&swH2B z#F#1{KUPO>xwn2uaC1QBd;8Ob2uv3*@S`uhliRJ?{qJ{NLy%IsCE?#tTy) z0|l1;v#D3StM>?Gu%r#odu4Lo)9rxC2~kUCMPbmRFd(!ZPxPYpv-+BiS4Ve(I?W z!MzPMd;LTa9?bv12T*A99$cSIhKxr&;g~yq_&^SzJB8oA#7WxuVq_g#19%hQ=y_s8 z^T@W6W0%E&6lA<}wX5TnxT7~dv`USZtIe{l9REgwuDXlljG5=95d62${j?Frr}&I{nTqYN#nDp9yr>^3s2Zb>BTP6mh#AVsYifBA zi)tYW*5Ep)DZP6Ir9=Jkrd%A-T-$gFy9)^@fKGV(Y5F0}V$85>2StPlK5)Ch zz4Tt~{pJ1;I9DYqA{?PqQq*-RFcte2otpT<(-1%`DJ`ya*9<2S3nQ0W5K8euv4n_NvcVO?{q%7_y)fbUaG3?h&c}2mVi=H zhB6$Qu*hV7gKH&(~%PYYCVP( z<=~*}o%E@;-)JmzKhZ4b*iPscd)J~Se4~n+>f{Z6bons_+$2^_rWV13Gu4;yMW&Nt z+m+bzS62%8AzydM#(}Sgk?Q#QM8(`GoVs?M?HU;?Z1iR>qssjc#!ISD>!U!BG~&>74G0KE(jdE&dVZ#1L00@O4EJ{c*7y?y0{l`}5-Jsu%#0e2_Wg zgPxI>RDjxR;l~Uu7K&cEB6WkaJ1w26sh8pl8WvbK9tdusardswFy*`6qBSpVC*qX@ zh>~-KHi_U_5kq-19`|sb#vVAfzh<+MuC0HGc=$-v>HXHO!{EEscEIzf3epuJDsJip^ zk0wLTXmNQn2FO4jFFXo$LJ;)kB{0&kC?Pk0hVWk17yFcI*IJL~OKE4kT~ylck>=a7 zENuPADRQ||ow}`6IqOxBbQe#WH7sp?ml8v&)nRwO)2SFM`tY`ODGrpQ{fU!=;W2NU zJIyH6WbeZzaXKEvLh6-Vxnl;}N=#3A-fv*FSNjMFG9F_g!TmHO+BqzyX{|E-1B98x z$DCxGr}UAv<_EB^4O9}P#rT;>PvE^w?S>vJ#gAm)cA*gT{-9N6iiGgN8*IUwgrF8B z=c(^7tdBAqgmT~z0d!6176Wd#d@AE?S$jL}oJ%LR&(am+FK71+(J+7R4y?bSbw5A@ zwAAoF>X(`QB;~Bxs3!-`Jj!glC8_}A)|4B z@0ny|hqH*)$--Oa6U2WB-OCznA2wL>7thgI-))sx((zazu#?=FHZ&<$7=HMU zWRG))mKTRq_q@f(IR3bVgq8X{30wUi_Wdaa9}D7(k)E-(aq1%wW2E2#xyX^SO_W@E zbC4FwPAw}i%g{s%r*4O@2Wc|1T88WsDAJ~$#5JrPzmxFC0(3=gm9c+{a=hJ8Hd+(f zlZ-(A?^{<*h!i<#X)>+Kh8Di1iYsqq{kc`7k$Ms4oO3@h_a`#R531DJHVQb`9{l;y zZ%m$)@E^Ix>kCE_NX$UBqnylwOT!<$5*A!{`7q>GD)@ts4Tw+fPmU`aLg3J^n*tv? z>u@xsPJg05-8UoRx(`K)vc`)#t7vmtBex|FN~V zWe6WcF}$A~QDEwFtHGo!@`?t080G(){hYvr+Wl;=D>rkM>rI1O9%iGMm*>L)V2e6A zHzKs9@b2$-+2!!z@9rmZa+9zx_ja(T*q2eoyR2CRL$tK_d?>bUW^8Qd( z*8ZR!dJKD-KJol~qsXKBgH2X} zesnyTI9naPECC;e60c=`r>TUD9+Re@4DrqzDtC*2r0CVEHtzc|E=`S)MuEB|T!-@$ z04L~wo4_i`?~2*?jyMc^|IY>JWhIg`en@a;`p8=u>XS#R^~3}|+{hwRM(Q)_u+211 z1Z|_#@sbES4cq}GWhICsqem5VJ}X^At?{*ROqm?^ZMe*-(o+*0E??>RF?0)-Y>mY~ zX)omVZ~)E105q1dR*avXds$#{e0Tq6J2#RoxRR^f1byEl{DQIYlR9fY34^Vi3hICXR+}5oN}z4S2fYsak;i2zI8F)WeWxQ^ff}R}{WSzuuAgZ3IBuu0G(Jcn6_A zwZ7Wf=dirqcU}L}j=?X{sd5){c=6Vz>vLd*ZWidomNeC6Za7+igBo=DVc>89f#3eS z(e>V_Eo75vpWcx{XIrePRlyuhh77+ifSo`%*O_psh32FH^#M;{1nchC9zl&dO@MR) zs}UGqfG?WRJ^~l;xb(f>5R<$)7-l#4IzNSoAG?BJA3nP<4-pZFNO4-r&ZZ39r@0@~cCQw5mh#z$1G6=81w zwl|X@h#&8sFkq={nrnR&W@-AbOK|ivl#7!3uecwxvaUybb|sK*D{r@8J5*r`8wFa1xf_^jxhJMq@h zZ1&r@4%2JW*{?r9KXqd4hSJn2Gt_dvw=SBICvn_Q1aWoocj|TL9OrfeG-zC}^e##I zclD}{pV;z!A+fRVA9DE`06Vu|#4@Q^;Aw#S@lg#H;wjL@z{iTBmnfGC*q{LHyujP$ z5P6p>^?dmf$#;s+8wTV8UH9Im6OlkZ7cQed0j`bZG~{>(5>cS?aK$TX>OpU_z$x5+ zes*QRb?N&P*r2o=T~HKa1hD)Dz# zA`SBN+;BEG=VO}Y4HXL zU|L9Q?Sk&eL-8$)Lb+J(mer=rv!im`s2*ff%lY9UPCr9Di;%0YQDlmSJ&p4X zYAq}u(%A1aLsppq`e=z(968ccN_uI6#9wJ@Hl&!`z=2e!Uv5H#>9(Tgp%X9)D9;bn z@kM6aT90u23mUjeoA~=D()zb`#V3gsw?D;U<0-gAksYoRM3iC`*Yw5THhqyLHhp!O zN4mewub%qF&aG(Qdu*X!JB(%Ew$E0eflLTUe>1F|RgS3pM-IlZ57ibps-=eM2**MA zBzdz$E}te*k}cNM(mu}K#Sk--3jb0cJ5c6%ZTZ0xON8L6@JH6~u=LC(w8f4fiGRNc zKQmG^nI>-R9&+8+yqHi5w5|v)r1bj>jGjNt4wk{;Zi9A!wWh~S<9HzUq4Q)0>{aS^ zcc8)fok#*?f{Y3j(;No9ST)tpj*dsyl0^$H2Qyfl&Gt^|XE@4!jKVD*fWM4`BM%O6 z^8?rT50+Zlj33xHElv^=3mq+(fq3S-7B%+9&69^Qd0%e?{|GPF&`|s2em^k<`r9MM zbhc2)cSd<;&lDI)HCkuv1z}gOZrZt{0JeqLV{7z-YwJLEl?o}S&Kbw#4?&ureT>gk zn~4!+;vHLwt@baaxObDyudPE9UMrkc?JkL>F%vk}=4>_71 zu=Cv6+k>F2{NgFD{!~&80#tXMEXOa?W7kZ4pKOmikM98p1)4xB!5Z_qu4R=eKH*Bz zh3=p)BAPQR7tpY!aJ*F!r_VWSp`C%2chM$`RGmD%DwGde+DnJhm=Uh6mtvmnA>Tkc+iuebxj8vttL_CSsB{n{xMjVk0VOaC@8tj z%=jwm^&T~7$$96PhcWd7UkshE&5k4xgqoF~Pd*pO0keIM1M%pKP=K7I$3F|j0A-M2 z!Rqi)>cXP?Ktb?cD;OQc#H!D|T*c1J@^V6gjzsXIU;%NMkL3aB;*ix13hB65dj_si z-w#mV$(#&GK>|ex4LBE9h)nY8M3_d}i|_MwmYSv8aR0<| zvos&j_w0w?os4KAx)S8&4GoP2sP6FMeJ<^7wAgR;AgXB>A*f0i##)_!rMuyjjn0-lN{$8C>*$)`>rF0ILw?@z!Ac>?WSd z1?0ae`V&5_oRrB&VJy^v(&;tAWKgArwpjtMM!%>Q-OwvLVPC6OmE6!q8Yc9>X?Te5 zvm?&i7ug&~BI}PL<^h*fRXTJv%P79g*(fE@=+#vqGU$J>E{xyW3>o3@r# zm?o9~A;uqh%R|T%CUEgIK03Cx`iYKwIb=@FGR(VMwaiT(K%OFK5(=mZe9#%h^O@e= zi0aP`N5PwLv9(OKKZsV3-D?gfZyI>HtciVJl(#+(8M(Lq(cgIVzW-J1vd()jXb#ec zE9Wrr)sG6#*Un0M!-!-$HS41)(I@y%^|-{)LHp~uwsm0SIivmjKt-WV{?Y+JELuMt%2mH%K3l9~U@&TktTo$*lB0fP z@1a3k`P7+Ma!QJNA{F#XM*kN#DfYi|(}TSE#gHc8lsUACV=*$`VEl1AQtH}} zMI80>MvHwx-RG1&f(`=Jc*=mPN$l}PUU^Nc0FUYVr$V0AD>I(zM1RMHLu zK)|!sVDdj#0_=~YhzC4;8c~>WHC01Av21@c=8O#J`|pH#GPVbF2X2~W3_WXgq55u> z*j*9J?P$%!WGTG(kl~E;?5->5uZ4+w*Ca#++6=`P?SjM){C5xA((zv6;lQE3>$_HM z>r_uj&EP$~fij-2GYzz0<8hk-mIb&GxtUS~d^m=0Y?QKFkL-oI{$bC=o|n{uPyDKP zlcEt&idf!`y`l)p8zND3-H;4RRMa=n^PV5Dyd?KWhAW6^(qvyekeg1=KtMH~Q^lYZ z^q{!9nKP9kQCo{sZBR;>W@o6tt74k$p6@mhYS+R_wn;mnuYuaU7?xd^EwR?WO9tLe z&rke~wh|73z2h*lhlETZKSl%?bI^Jy0>b$e?sbv@o<#u>Ic;9;6`MCe(|P z6G;d6e9@v%i&tILvji&?FRvJrgK5G;T)+p)UXrmeU@@V*ibZ4Gu{nY@s z(U(dbrG+m;1fUY5S7nA1VmJO` zj?C-k;JF;kN09)eb=%_uU2=2BzLn)egUVmN`NRU`$c*IkcLLS@K>zC=+O*;8MeTjhEB$*7 z*T~LFZtcsLk#7#9u$a$ZwLztE_8nFmw<1M9h?yKY5;;O<0tN$3vW>bX1xw~7C*nOS zG5b|56^sZ^D$Dby$Wa>(?PX=y6l%g9K&zxMLYkFZr#@GsUNBNRub{vSQ&AP<^cqSQ9T^VBNr(2mA7Ny(<2)#27E%k zQ1IUQL&vrsv>>a;n)j$@(9;^abEp6e;U+xcM>)%}CUfGIub+;NpYU6Kj+GjX!Gr?@ z*oDenex%?etP;r7Zkl0*#)0;+=fq;-UD*2yxEE2LrqHm+8>@$5kpFZMG6T(<4U~Fq zewT5Q-zvoE{CHg(d?+|z_ubynH5`rg(?fu^7uxmHG^V`#<_jYO|Ix`lH%rA>=HaR* z4CO}SKF@KfSHUF_+EoM@)_{=}9`&5}>PaO|*4u9kDbKzqu!nkLi+1Iyr%1E!W|9uP z$upaT{^D2;>HBGL@8~HWa(+nqcKHR5W-Z3Q9)juJQAcU( z)wL*!kbrJuo2WJInOK_F=ud`mU8UEQ0=5qpxcSGcGZ9#NU%j2^xJpWrez)oO3Kf$j zG`k`an3WT{yiHeEH^WA@V&{`CK|0S9?9SO?_G38?+#s`0(l}%^1+^%IieRDEXAFc2 zV5eV?rZ+p|k8vtF^t53HRXgY*H{4t7AhCk^PEmI$7^@8ENn|PDBYBS zz%*}TKq{XKWk$Ut<`y;`A-?%Zp&n5}tMm`!U*jlgecw<7{YTF@u0@Hd@OJ0x_slR9 z{>YBK$GO?5QzvI^iC_f)a3YytwmuJmS+mWy(z|o&?KuhfD#EE_7yS^cYoAC;I@VqE#bR}$w zjT_VVA1-vZIlT5+1I^8e4o(gNJFtE3&%!PN7juIz*+J+vBdC{y&8TrqAmAHP<0NXV z)`TGrIpo-A{{$Sj&B5}4fXPRpco08fFlRKR&Sum01p`d@nFX2*EMxmMkRC^9af(oE zYJ*rq#a_k*9N&s_q(8HKco+N3>F2&RdqZPUiD8$8D+Nb7N0U@1it>1_ay6abQ$#l+ zuBdj={J&5YBONgK1()HAxMF^lVsMl@%PH}TPMe+S)7qvVjF0~45URM$=03UXs#3dR zN#6}JP^qqlSGYT~srE$lciytoHla>zEfl47df3J##^q5}WT#ib0LNOH6Xq->+}<-X zL;y-Cp~w(8b}gx{@p?Tv^LphZ+7kD|t7vgDGEg|Y1{jqwF<>2M|1vksKeOQ0lR&N{_yX; zHf!<1s%<;N=19j*zAPdp;d#jPkXtWMKvB^J=VD^kMFRwV4ih5XX4DP299OI?1>orJ z(~0DH7%@F2ayX~Z=&CX>AVjlpbV!*jDt!R~m)gUii9_$1A<#qDD$>X)sMX|R2;HRR zTkXFK33yxgQ0V}4#7%zy2%QKm#qqfJu2niFuqaB0KQVNfXJmxiV&C&+U-S=VH^)n8 z`0~ngJ%aa1Rc76`G=4n>Qg{@1}eTybJKDx-DZNNV-X{}HG-E<3NR33~0d`@a%DC!`-GA;9bn z14mYX$Z$`B2r_F&Rw@lXSR*D=cX)k@7yl%f2*;06yT}(^D^-5!ysUOz-OLPOk^$it zz76Csg^E#d<3bfsXZCsaybbc3kM0=>2|-(y=R2dH=eI^v%Z4OUPiqJDjm+SoTWe1O z?Z^kIk?T4kKUqB>RQhJr9LWXH_0Db~Q0wH$V-8&oL&Fe->$f<^or*`E<;p_NQ^}IZ z=l!9__w&ui-f_7vd4u;p>PNmS{}+iix*y>7v_=Z&9cP$2478ObV$R*qM_)?b3lX>( z8GvrCYi^>H){wGg3|W6ZeVX>N-l)rjTjfFN!bm_D`NT2Vc?LW?rxF6jwb!_T8@yYz*m6-qH z6*qcogLaBO{qtV-&8NV8v3J?HYb87>1X9k%mcdizVfocX_LeR}4Ub@a+F&0qm|%%m z>yQa}MF0wqyz>dxE&Y`)ruU8q?Q+hB6oz>(QbyFL@M4EMyr=lN0Gc>%WA&7Igtr^w8d*r>+Ja5?Xs81UI&&}Thn`b-rSqXH4VVhm{@Zy5=)IdL@a*A%cpyWFA!qGe!ZgHc07N1~E35|jmT2-)jSqM(b zeJ!HLKxcVPMCkF~H4ym``>v@o!Sqw)#N1M7{@8~NK?g6VpJdMa!m7?*z!e>cm&@;e zcnD;tX3#9dnVV8A*H!r>f#Tbd*s_m44eogk4oo&NHjrH!qP4Sycj7Ch#-gsjR7&Uz z-IB|whTpq(*K%71d#R8<4kiW@Qln!e@orceVYWT3hQ)Y^NA$~rT3WTjCg+oI8G=tD zl9!o#p3*N4)tfQ9F>J#WBvO4R=f0zBW7VAbPuTcc-}*4R*$ zvly7OUT5ig`mmV8Vyd{dEz#pEZ~G@R_v(WF zX=NG{#J%>3ZYl_kfx#MqipdfNHolONgz`xVe%dwQ4w=zO6)w^E-JrjwpT9(6#r##oXZfjES$R?LU`Vq z7OMeRa-DTQKJZgoZAbQuH7TgPjd3M_0uxbBHTYLO`z$JE!FE`td&zT?^f?mrmj;2r z_kSajNzt^p$diXRPc{)xnM~CkqVanNEL@Xsu(Uz-yWc&2@5`W|lGbA8Q87euD7Vqv z`G_@O7eUQgN+=Yx|BFXjD<`hpBktb~-neoSSgc6-FatD&D!pD{7K&76I~h2a;1l@p z{N#Z;?ujMbT=)!+2m=3YVbTjF`HC@ximrvC7>mv@r;SLH1&yw2k};F;GD<2qo@Yp( zCzLAb2CB!rpCa6bTWd9)C7sHK3)F1b!aFKAQj7mfW2czx9Q4jzt);vpB^3(w7jRR? z`!IbYqDb~E6r8+@pn(GRATWv#NBx`u1V!aPP})tOk$M=V%{t57uW;*(x-PZgX-eOs z+HG$ElE${)9u*cDfAI+8cAf{peGjoEe+93 zeEf1nKa-=?Re$>igZq_5HAb`^^)EwJ5(A z0AWAqrSV&*^SL$`F&FfG33UNhq1+Zi@TNOHy;w}zPLSRkZQ6_k37O~Pr6PMlN>iGZ zTqP}nu{XbSwjRxu-tus2#x4^94a=BRYq9W)I=g6U8a1N~wIuIZP8OAI*XL~w{-?^d zT0XN=F3SeJ(4u1pe-6+Kx2O|C!>?AzQ%`muQvUgAfJ{lAsS{N3*5TB%^Sb?b_2KsX zBA-x{fGy+IaQ*p0S|i zFPh)V;*w$!GOY8WV@91@Xc59Vl&Hp&K=7!HGVmb zor(-&U(zwxFE(Vk?WNa?3n??lK!+4kv1@fXI($3Fgehr*h<(|pkL)ZMQcBz{WJ;bx zSothmTiRFP4ZSfhMr&M&l7||8Y7pZ1H@0@gPw+lCOT~wdtzWng$A1q@nJJ*lyIrY?qgyx0=Ezb9!R+R%r!0a zhq9@9VV2==rkMPhHV)`#f{N8&{*hJgXb9iZblP*2q(VOPXd}UArj|!|uf-~dTVoHcV+93WTb4sL=($ccQfS+Z3o?*DTE z7;bFdc3HH8%xje8fa&Ho5I^Li3_*-AGS5}=-b#srO!SbK38mEdGlj){-=m-M)K9-lxk@cy> zdz3O24Lswb3vkEa(a`9=ZZ|CHwA|qdf_sIaVf?gYrX=E0Gnm%nefa{_N(Qv5%9u|q zC{xI($-%%79?kt;yAB;BB2Dw@00R2Oixz?zqLuENoJx7FdM)I)GwhemWnNJa89kXR zL9;5q%9@H_H>RH!XCNd%SF!F?1>Q(7QSFgf)OJV<0ieS8wtu9+56EoB8Puqkxlb?X zUp@*oxh%y1(L10}+!dlXP1YDh-j*z;+$I=>Z)!`9X2T~wWFF(L{C>xwtaUqdR`E+8 zscI(gWl|D>>`6sm4!I5Ry)~;2yPYIi1DGm{2?TAfIDjdKg%R*yY9i_Gy!|9{_C!tb zB={|P;}_3|qxsOv;nd^Pc<3{i8VUKM3s%V<<-&%Req+R}Ta+wXBhE=@ z|B~QbVq9%?T|?`;RgYv5Mm&n!F>N}w=~J3N$0{_Q zCl%{u8^IMHquO4zpsR+T1%_Rl2aM%*d>w#gJhXlJH`TmLgQ8jJ`DXC1#482#u23n1 zVeA@b=0!rP@U{mR*7S1!d%TM36c_wK76y=QkL8~qIInyk=Z!ABGx@Z57zLe;xdahAiXRAkPckVCk4v@cMif$K=j}w93FCw(TT?p2QmDt z=8{i{_`8KwfCbf1GE`YI@mM*%GC{cq#h%VInwWC7G`?2ky%6H*P=jVeov8&KcJWPHRrvXa z0zO)Hyx)s)nq=;{3-2GNbWA2E-5^AvK;opX9l z{{#XYH!QOMS6gD=zk=Eio8Bb4-m`fz_A7~RTDV(+fyP&-#Rlavsl!N8mDoAtvRZH9 zp^rUG-{yvR;s(L!wO* z17lw1pW^*6;6C1{W}v!j`hgS{P1MIHnXN5%`wB1VB#3n;okJz^6cs zyBtO3RUZ#)>EWKW?FqZtM$X`uF1RPs-zZV__*MC?yu*u5!R*HdaTu0SDnmM`sF-DO z$P56Y#w$(34fG_HnZf6^DaP!1k#kRvgKlWG z`m+9zK6_}@kH-wrN>Q$n5AmT^|6}Tw2LZMe;7%02d#ebr}4|*^Yaf3X333Y zg)!D{&8)RB{73zwjxi-Djs7EB3XSe2iS9Vrl4x`%r7@d$Y(P!+*{p|2!;Z5oH-JpD zyzb6$p(1tsFE!clXH8(gBC36il>X;zl zPt?}~b>!W=sFsp4f1+9oiKoV=ij2qmYwPW?Jh&;iH>SDLjTXj-4P#o9EM5G!ZSVhN zhgrDGXl|&=We8^Dp54-P+@i&%!}Z$v$Y@}H9El|JKoAAAJ+t&i zU^L&0jUQ}?${IJE=Mg5~+CJ&=9A7E_YfcnXY5RAlb(04OT9aeURCM*h7%CHPYw&z& zw)l%)@W*))-UBK@PH`!9e9$N+9~5voPc5Iolp%ap009g23RJM#fxu~Z+unuj1#;Ob z3%G^WM*Dvqt0$TPz>fwP!D_)WQUOXjX~(FPgMYgxkO`E^QxQ6QJ|diRGy z%?rA}*qYHOC{ePm5XguHXw`XRc}fSZmR>xe-`p4Pk2=+3`;tBHmNvV0k>@nIp$4h` zH9S=0q}nx@1o&XY>?+wfuwP1_sK6@*_c(xruo=J?4&<18q0_FB*NC*5;8=rN)n(*s z5f?xwa(lkI7y|PPt`iPBdB8{xYYU!rItsaHg!rz%T|bLJhAAS8BamFfJvZ~v;ENR$ zhdHwr6PT{(Uw(=x`&!yOXhF$87R^sbea8z=I5?PumtwK-?Uu>f z?w&>O{Yc}5Zsy2Ib{13MwS z^3$irN>HdzmJ$SYA3*1yi!zF?h$ir{?COCMhCCzsNYNOs6h5?nDFI2}1KW}5v0t;6 z+SV9tsQFu5&#Yn)!*gLJH-@ntg6WG&(1uyAfEU@|#_>u~>_e{kNwBpM`PRF4rz5(W zmdE)^b#m6f>uE0#cV=E!)qpGbKiY)&0=Dl_dF^_-6b8RY=R_`KDb7IStS%cDW=lsZ zstb=3lQa@}pCSt~;!pJr6<_un&cZDvfAOVC(r%f&&9Nv`Ys(~4>AVgD_s*{&Oe){h9}i$jJ{)km zIpLrHFNAYL+kRhW?hAKao_%KCdVk_-!P71^l%D$2v7emRiT(zqwVV9<%P0`0+>%rg zhRjTA@Px2)n7Rk&&&eCH%{I#85FI_4B)C>yc2XPC{I;E!A#Hx&-ut@2oQ352VMP-3{u3D}1K99`v_rG|>1$fgI-5#d(&o z1k;|aP`b2NXrkG;tW*1CUvDQ9gIV4PpfhNq5ke+pKf^#){4!x#=arxg=h$N>R_wy; zMi5QEERZ)9^03YuD}<=Bb~tO(%8d)4Wb<7okz#OHlTTeug|ow;DP)#EGW!=t*ZXm< zS^0tdTETcWx)9V)_;iFa@rR`o$eQbt_Qgai=}+F98VwZZH>XvtrwhySS>}dmcMCCb zPw4RA+-BZet@da;8JPs*r1RKqGD6tgbLMs9HMBq{<~9AeHr^(w6kjDLoTds!Q~54% z9)$1&zcGY`a}*v-DOGs=T7OIxBqF#WNR6Bnd!b<8kmw;qw99;s=FLUTl*Ce}xy>uC zsfLbH>WbOfY+SvzQm^ZK^T)sfY}i?Y;oK+b(f7g2r3K{!2ea|+LH3WI*UKTj^Yc)^ ziD%(Ou1jBYpZBc>$OK(jsCX9kwxa9C7@%GD;8_c(oxdj=Nu;6h5k~w3cb@HP0>T-T zx|M*Ac_wX9%#Ss79><-#*UFiwH_f;>$O!n$b4eOWHxLE^Ep`byjItc(KRpSx2wdSy zA0RPseIOgh&D3BPQR->?O$DGZ>Vj-vM{4~l+0E*e1&W~`9LWK?&N+HCe_rkF$L;@C z3phqj#-KM(>M}jQP?JtJ2b1+mSz(^kar!3$3EmEBxYSGqH~1xIy~Dbcjm7g>sMxkA zU&FTUEA*=7Ljs|3xAXIe_yjrfbT6zQ8kskJ$_X^xjjWs74VmM|DD!AGCbTV0RZz2q&Tn0R2eh2=2C+>{5XV45T$i&es?xyf4z3#XkfI4Yo&ErU#(Jm zkUay8&OttnTm0%j`4?ji^>}3m8EaEa+4iV1;(g_yEK)bS4&}i@w^#YH)p06g72l(` zVnv?(5VP^Y{N#Zz7ygTk2JWo<%6XSf@~pB!ZWrfr^YwGi;AY_uht8I zi~l$Cxp1Ag;9Dz+77^Fb)UlX5I%?{^cBC%>oF}g5T(UC0q}n~mH=lYyI`N!-iU)qB zAIDLa_u2-vAyXEw9mzs9)@F_0m6f=6fx6gdKU!29cp9Q4oFgkt4P)z`jdE#FsiW2) zVrd~MdF0#*AZbTR(rWK?Zan&2a04hqPv5C~;Bm*j#i!X$$1=C)|0Mm z3qIho+on(~C|ZxCLhk*XltT`RPEM2c6MC64d_&bXFV@iWQ@WdfyZ2~NU~u~;wubXx z!x69617~EVtHe>HvBKrDvh~QV;hs`yLz%~nR{6y1L#;U3=*6?(PnyLlEgkP(VVuC8cKo z>F$v3kd%<_M!J;l6o#&W`OfoQ*ZU7(_C9;9b+0@6$;=ucq0u&*PrRRT9+6%AS5qL% zKCm#Df!~{+RBW=TJAMII0z9Vx(7|MGtR&SD_u|GaLZc_D`40e9Q7WUBe1v(Oig{40 zrbZRMz3NIURwF{9pZVF0jg*(d^eFNQG;gD3qU1U8h87IkegiVOu#8c*ph$H4tXDJd zAzvg|dD>!|dVL#fa`Yj$01;Q4;>M6hQ8T+YM6>goeN)&?00MdfS7U+S z9F3BdTj3<1Y3_i``V}5I1;*DE45kzA72MtYgWju5>TQi47wvdMs@eooZlvqQ$s)PW zJ;))B%=tm4wPt59?Zl`3-y+-Y-7sZh%)z>f2iJ#`06Ql%Sw6(fc*;f~;bL^&Cc%!s``flOV*|zY zv+~a5b6LW0E#5W{1tXwJzx95vD;WzxNCD3uduEHe;~M1!5&)K!|J5ZLYUJe(lnTc; zdOLs_@LA^p-IteDe&eOs?M8ADm^@PYD2&N_Po?umguwbk^-z8b$|qXNgW2JdWcPi) za<$mrYTk(5+LtY|#BnQt;b-;{zX0z1>#sEPD3HLQL z{$rmt%1+i+Kt2ayUQt^It9OlxJLnce)6;<5HP`z4!ZyGzz*plDpW+6zMZuGd9Mk+bV(S0 z$B>R?!M3?n6%mg}PwWs=D~V~wl5*OqOYHXchJh=}P0A-X{OUjvI<@hlUsoefzMe6; zU%wUCuI+d(tLTRi5@7W!H@sRCj*J$UBiE!aUkt5$Cvl$V=7BjyM-^N}4ih#uy@LsH z)B+%muLe0oVp0tv&QNO_gq-L&!>V}WLM3%J0&zH%=##RxHL<-FhzG7i*aXWn4 zwC-K6imKi_N3WCqcURm$3q+~!pb?SdY5(2xZ*wd5d6K1Q_>66<(&?zi&%a$QQqX&` z9>~DYT+4l-RT=yalS-GEQf8UNY$|c?@W`?MF;|25ieh3PO{>MdFe^9k(GIxF_<#we z8p=mE+kgu$8b6j zABciMs+CEp=oE-)#y!-};P<#Bj!EyV2-#Cd(u$EsRoIG)(Wns(LOC$&U5qc&%p2;w z^QXbW!YV`+d|-6`brr(im^wY9-y`cnp$f3Aq@M-jvc;o)t63kv|M~8Gd7B)F_D3|m z^9j45z~%CB*ayyJwN8y88x#2IlVICX3mdtJY;d0?|N8qq-S@%sFc_^+%0i(-E+xl6 zTF{iRUSXv19Eqz~-pJIhwBzy8@8FF}21Y88sF_;w+nM_aG4=>q2m%g1l;nl}QbACE z&miS%xxYM`6pk4vcmXzrZQ8TQW;#&9HTPj-Bcvwo^)435wc~oQN7pCHt&NxcPI6l5 zXkfoMg3f!8LAOhk>A9YN7qagi&JEt~hsQ?4BZs$J#z^+EN-;s8t2&PdME@4nvFEv3 ze~e5u(q>>p>vcxA^m}WdhJn3=a`{}B+jnbsoIbwc!bth(5{^ZA6)~hY*4qb@r1iVj z?r8|&Yk`cOqKam6kCh<4#=G7;U1rIq`u^?Q?_#KXUa_d2@kT)Rup2oz^F~JfT=)8S zc^>;?rSf{vtQMc^XNhTXYSd+jw`l}sSjpf^62sgW`xM``;{LroL4Y=aW{(cDm=5&oGBo%D=r6sHWkMn!;#Z;R zq%R-e5%=lABdbr0gXRO{ZJZPaDNGNIlqL zX70u8C#6q%9O=7Ex|iQf87Z()eH1QLO&+E{M2_hrbc#;bBHSzXATyEUQ_6Yxg21m| ze^y2j;i!#5K$6_(hlUC``W>^xXc`YadUhTj+bZ(rDQ^7!%4l$keTDkU2e4m`6e`mM zqHad3e_T=w+D2vZw#p3nblpV!8k%vqSb1R4#L71dY8Q_G;~qZv4=-Tz`5ySyV*RDb zM))@roAk-VAsLK^PmK2bi{yGf4cD=k=lk6mesHH~@z>sm-LZ{3^f_*uKD4)IYtcKy zaVS{u-ah|ItW*y)amQ?S# zDBLJ`%1k$ev}bihKjvz3eXKmGI({}C72;{z2Q~wZO4g6#=GX!;DqIF*HfD8y#ohA0Ot#B7DdhG zNr7hJ#M5!D?Uk28~Es3o+IVp+uypaJ|3PO z59Gb9@F{F`@<)%&hicUoV3gQoN+8Mtb&QU<)}JSQ`;i9;MC$vtPa(07f3#$bFpgF_ z*ze`#yhNNUrR~d38Xlu5cm7Ykfk#iNjI7+j|C-X|elo4vB^*ouDUuc8{9RaEF%%%T z3$X+V>%4ec$dZGAcfu4bZR99QaX?r@nTwpb;$FIKw%IvR!$Gil9WmDG99Y|p$f#&z2FiM$Zj0zg5FRZ473u8tT$b4a##8_y`*+grmx4` z$s`&IUS*Y$f~E_HiUrtYtz-#z3bFZc7xXA-q(nGmJ0vF^aUv?U-jxf~2%ey-$>@la zbEIbvm(1KHoPWbR8svsHe_kUN$p{(`dO>JKUWyjL6j!13RP3Ji-%+(erm#Mj&9v{YBO5cf zGk0oILpgv<3>JJbwb4$xuHMt|8I)%Yf2`mLs3?p+k~~5yI{cTX#zVvk)iE zbkSZ_57`OL%g)TE3Xtw=cd};@(iWjB59#(dyKuZ(5}pZ6m}dKRVXjMCBH7N(#IG^B zG^RgpIV&}q5g{N~>>g6U?Ttkb+CTX$Qp{x?2Co|vvug9dx3_FdYyjw^+kIEC{Y&1c=RMSX!OWV z>@g3)kicKhi3d+mx$|zSNw|9nJH%4Hviifo(#tkD($RU}!WD+?UrTEYjOxM>__n}e zR3}F5fQx=8;!^%^9u@q*ka#-`APT8hCSb=ztN&MZJKpzZn6Vk`Ya0LbQiyvISv^pu zzBr#UN^Z=NxF;7@arUo551vO3{~5#tE^Hn=C$is0hTDUt-6GP_G4bhR@rcmPbRgIk z8KzvZM5!f+KKYV;{H3oF3KXgeTih*Wg;aP(`Dh7BVj}4kMeO~zBgP;C4~z)J&_%0GgLg!UP}RQO`4NK0lb3$dZT&? zdOXf&aouP8;ag~{8eWGZM#*Pds;BYt#ZMis{^Se3IU|_%1B%bdaY&W$3JVRyU*$1c zRvCh~R-3ezlDaubi>VBJJi{Iu4jc3E?cL0z_5awL6u^Dqv5ymGMJbOdHz$T3Okm1}=ZUD77xuw0-%e?-Ns6jMv7ne5*=v;> zxAV?Bz}OZ$X7C4Ef(lCwnrsVdu`a@gh|4Q6_$m}HC5W96Qu{*1?gqRp!OwGf_vF$~ zs(JW!SY(<-(qBUxt#pWGS36nd;i;D~?u@Vw};frO(_i)8-=l zSh1}k`2T*M?M4~oQGecJ{0kiSAw{BIY2`r#ekkL_-J${YqQ~7F=pz0OOY)WfT^pSuI(PM ztbv-AjMx_;)+)9Aw?S;y(#S(z+En2lDBB=_(V+hM=(2p|Y6X6|`jCgeV&b6IlYToII#F;iraCsP#Oi_@C0TqX;TLg^>|_H-0ozVCgLA#7kw ziH`n)6DtcDEWz}mlSWx`uXoLliEE~YIbvM3dT!fHP5vhvrW=}=h*63*!lPF&MV`I^ zW#hZ1mm>0`ZbXy9E{ru#5hlK(Lgk7UcW?5eY5=Z$RrkFR5EJ!9!4g2Q?wy-lpN1)3 z)FqLK66#cD@xLaW{mjqZ2NsT(TYBn(i7Hg=E-gkc5Bi34H+~#$)Xo?!y zy-ZVGF&C=oy(($?Q2xbC9T0ai=M4)rs6U6|qdtxu z9vuVH?tYx}E}|3XU!%*c6^^tO{#4m&2+hfhm%{3?j0-9Lu#O`r{IKssvq9B=XrAlZ z!b}hx>e3bA_!?=_C%v+F6)cUTb%+oMy65}4(tYnzZ2F!05qva@-1W5Pf>j6U9nuSA z63i3^f(Yw?qp<+8?*jb=k!K?v8J?9tedTB?JNfECeVi{WX7I$@tq8vqXK>R@b8u~| zknW1L9JAPEU`$@u=Sl_hwEC?5w>8kd8bIHPCQRk7Y`}}O8+-UnUgv>Zu9CDbHXnmG zGLe;DF>zFg?XPfx@C8N5{48l!9=o+7)8|yun{ZEu3bnr)feZ_&yd-M7>_36mN{fqP ziH_5dI+D>d*AuXRcY+~Tu04rm{i_hz^Z{tVHC z%^~ITw;-eD{Dj|ys|!Id>&~YV{?zfEbu{UvrF%YA26NEx*(JghuU7*G;@CdrGiKDo zU6Sj+E{cOdFfpAt($?hiWqMA{_qkaNCL%m8iqXWgmZ{`LIJrXPmu}s{*RK>J4Xny9 z43m5sboeOX*WZ;)Qe~z?G+qhP7zPrdE8P#+LqL%-uW^vy3NGDA8s}yW>GE}kNuk9R zcDGP2DGn;Fd+|HL1=KuWQD&_0X=|hQ4u1XpxoHDh&J(D0knDL5?2z z0C2j=v`izYQNfqt-QjKqWd3=*pRt>KX_^dq0=K&Hkv}BffkO-6s?k^8mlwlZi=VXD zjm`1(Ya(iH5ntn`2ne-6LI7*V>c#wHBQ-nlQ7$21`|p`3O3abgFL&oU!OsdIsDy08U89{sA6`~!12;pHm>R;=A}y8@P1 zzZ>wa<8nhufNkAm-;Xr2zMymoC5xEehC&Z|ZV}5qm>4AJV-Um=YTk?bgCCCoF)eK$ z&2$T?4gu>mM|f{A-oAXt_jDS6yiGvL9%s@AkY+E|jYK}z>&UO&@Efg0oc&=~oLD_u>n$Tv?t3UVmX|0_ zPqUL~4cf35Qcq94`BM=7*9@EwX||NwVD#fh%@=6&{mbGozoZ}{C_~B*KeO4n7?Y(n zw*P?A&w{6-llwz#Xo{`oUI)f(m*NOqHWM(4^1l6Z0KK<}e}|borPZ}%eZBq#>#~&_ z=ohY2CF)ONi@cqmoQ*ScV=;AOR-t|6mP1^iu>fsr;#;l-g7q*1v1d&y+Mp#C+ad6Vh4 zGrFE+SQmNzl2{L+gc2qvjwB6#FKwKY6xhRXDH_o2yU>gUkI@k$4Z);FyZI`^Hs7uY zCdR|RzyzIZ9|OP8>|@`{-5bgEFODdBi@{oZis#47&81a!h=On11*Jl4Ox7``uAsel zE^mzLA!_2G?aoi!(s!*>g&9-5R{?5jCcPJ1+Soar{}lq(+KKI1y+*8fW4y%Gq63_Y z85sN*6h6RcMZa1-VPSor{|h|6AA8>kKf3y&!vP)XHmq)L2!&$@`0&WV0UwmJPwihe zH-kX*AT8Ce`AMeXxBjG5k8RT?BU_nyv^^86j38E@S+V7}G!nk^8KdR<7M3IhaQntL zS`yn&Y6Wn~_{`dYn3-kQRd4RvzfT*5CsBq3ARa?n3KGmxO96g5`yb>P%vQ#w?vVwx z)|?;`;>rYDc7E*gdQREH_R)4xLF4L$FJElQi_%N$>bqlVnh~=dY262@N{$~Nm%8I- zX0-3STuksFnkaxj%Mqv|1-*8sZ?VBiR0GoIUcg6+Ol*XRstZc{$wLn!jz)pCbl?9h z_X)tm+9}&?f5prx=)jL-_OF>k_t6Qx_*YH%Pn#)~q3&~`YiHjU{ujS?iD`qgfm3AzUz6D)*PDziJT_mE;MH4<$Bpr-hW9Rx=k(sPLqx!Z> zxQ>_N0MK9bcM+Gq(pZu0{omiA>pbVZY|__1?-w)!k|ziSk&GNQ9j#Z zlah~Fc0~_f2x%J`^?;u>O%)0f$hr#*s|pN_+C$-L8;%^x{xhF-4`o2v(w>;{lCU}u zmcK;EpIh}2o7oRbpZah*KP`Vf#eT>4DbkXWJfpIkqT|`2spsla9&VR&v=c9FAz9X> zIqb(|s9{>-l*O!Sum(4})+hv2|D8I0vP&INze&iG4a_5Ov^2F?t0*6`J~yK3B7Eyh zr4~$!pqz6^&L=#_UKeVwi=aW%1eyH;&Oh!mZD0YG>VvHm1aNlxf9+CkoFvh)FQ`Hf zlY@=KiGZCHW0(F7e%Qe`EE5#-)7%e#a;aYYUGw)GvCu)?FI;&;Wr15oGa{PUMX&w- zOykuI2}52XBW2v<)f{}bwniO}ry(+jOCv3=!Dv&^L<$ndKYwZ^+M6UaS-lW9@pj^~ z-rs-o)H-uAm1;i-4KKzXA8S^wc+Iiaf&Fe{f&J7}YMuimFxD=dR!;af)#m+0P+)c3 z5i?#&>nL^f?C*waoaDM2TLWL|DgfAq@NouJ{o z{*h&5Kwf=)mo~FuG$d<^2Ta+Y^J}rE?pzNCDAY_MXwUbN-k2oyNJulL!?)CgM-|CO|G*C(Qq6@~mdr8iTb|iev^P(=MrZOmH zb={Bw8@$B;^*BDU7SH~d@BSa%?uv}7^B1Ey?rnr2L7UHkHb9md^T3JCEdUoOV@ z!9#HSwG65C$00pPejSt+S=S0`{s8*wGeK^~xxlieI6~|2_|5ZX?LCh) zuljGZ;UJ>>d9;>%!>azffC+P{*)v9+8!=GN%k$F(>}qPqJ@1JcGgJ;bnikrV+Y+*o z>&E=%Ec_gOmmuWd+u;5y$@?@CZbW3P=6}6S+@f)4!=3=?Q z0!N~Indt7>-X;W@dEL|NJa`qmg#zOgN3|JcPt>ShO(<|pf8F?QvY1Qva9?i#j4D4g z?FpM1gEKirKZ2>wHmcfxQV|b>3JMWaDY_v^^c+YrzMc78_vop9Zkl}ZuXXedT}bh| z*(?&iGcab8fqv3Iq9W;*B0-5rSt0}(uJHKf;e<>kj6;P`_`8A^?LRu(mt4gP7z0#~ z|KuA!(`q(5Ib2p0v~7J}vce*5-!tyI|4xHV(uh4V#dtavA;>zzJm=u( zb^HIo86msi*j2fZCQ!^2VJMw(X3MU}5F&!+H)G3`anx^tld)mt+z6Q84*Cw+hQczU zUFt{3(XbAPn6eDiWRc8ezsUtno|C)qN{rsPpbEt=U!bkZjzBzgXW_@JPfg@ca+XEeC@ z_r2nvI_~9Mw3UWU%$*IK{i8p(mjCWsVn(~fw~{HKln-@Z#zgYbn{y|4h%rW|YxZ{|t&jSf z?xsROZzUDTZ<=w2VCY)Rva$p6DS`ucP?#|;nrUBO6B;9QCiuiBJE_yPPBg!}(;zD&2+I7N(+5u6 zLa97pC&~t}W+l5%=u1lv=>1Mx3Dk>T^-EWi@3+P52@2AZZzg(qxZ1u@7lD0p5?m6G zRWfn&<8AuyDlYTV72lw|57%Y~&QgjIz#5sGL@sn)L|jEuP3+ zj1gBbLuWR~Z|L$+Pi4!|etML;z`a@pf3xLRsNOrj1SW&J^JTkiV52n@B-pls1+Y;v z_?%GROLo27)b3m#%|RvkrfGUwmg^PD!DFroUWL^N556Fdu2=a)KhOX&#u(@hJ;DxD z)4?i>|Dw^4^4sY}(e#mK)pPjYwr}9>hdM!5W0~nbm+B0UX9}Kp!*_&({_$32W@SQO z+y+5i7XiiD#IILx13j*P$omPz12Y>jmYC#4pV#T~*AYjU(E9#cWrUP3V3SBUcJqFp zm+c4JzmX$&h=lCs@ZT^ZPx-MD;J^J?pVW(??20k2m&#I&O(Lv47BR$CVR0j6DD-pS z#355H_nnk3k_+qSq5RuZiS(H6bIw~L3t`!8x!PM-&ulFu8FN^9KJ!%nTa%Z`d->hF zfXMj43&Bz-UgXy=frKs6kUn^$psf_E28Px#eZ{Ax{NL(Ek4Kq=JrL`4g8i#XtPCkC z9@y8Nus5&^I+*i)a>#~hg}!#}lKjpFo9-W_oW3419M2i{YdVO)wM>p%f*17%Gtq!! zVp?BYt^r{LiO|;D-++Ak@So#w?8%t-&Hz6!6a}BO=C|dDS1YtBdhptb%VtZLjS+~y zPaeFccyyjUQ25iuC&PBF|MxtL{HZjMGc|oxqrP}-mi4mf@Uh^(jz~9&QJo@;BX8io zuxytbHB9MSLZpw5u&#tb#t)B;fnpA=o(;uu?P*gB_DuV0e2*+lM9;HsX4}uQkk(L^ z4lgtGrnYFRMbDz28R4lXJvuAC6|~(Ku`Xu*{>HG^U9^x7#0kzgOw2Qz>Z!Uylk(9)b-&3r6QD{MdU%eE#1J#}q9e*$%(6163LP`#Rk_y-Bjs>R zq?bJjJ~|qz4S8rjN{2uT3#{GR;>QiFFOIt`00T{dvTy1J2V{E?mHH zfEo)lf~n(V5e*G$J5r;Erg2L$k$oFl+@1`&oICw=Fp#(k&HZuSi{dq2jiR3sz^Re? zqJvB8b8B@fA^AElXiZ*ehus>7au`k#HS{VUK#ze1qGq0A0g`H3>{O_42! zJ#5YgZrt*vPpKbZGi+}o(t=O5_0l-EJkaxXs6kv_MMW9II45HuaxYrR$UmV9wnN>8 ziaahe-Ig>Ovlok!*QRGKLl=rCS*8vaE7PRoiLsn~c8sR~$pWeorVAkmKiqggLx(UE zRL<31KY??=Wm5hl|Lh4gTi|jSEre#D{=mO8=*xOQ;|u5`TF+gtB^t3*{1hr@F2)(>D`*wmZ+tG?8-aJ zv=4j?whksaZtX7zGEWwgkMr)LB5nvEehGi_qh{V>teh>_MAc7R2zz?1h?%h@p#1jR z_}7vTz-DwlaGLwf6_KLO`JmRyaNo{2!_K(y+&~ln{{=W_B3yr>rWZR1L5-m=+mfH& zeq2Z~c^_0Z6@B+T<<~E9gTEmyW#kfSS>ae*cD*vHw8I6#cG*vKX*4{yWO4OYlQ(!> zp&X}jfzs?P72Af5jN3Gu{}f{Hv138`?n_IB-2;kE8QqZ_JNkQ{>et~=$$Qm@=s!wv zdw9y83O=v*@cKjxkK}~W?plA~n=)Jx**QVV-+oA=38+G0{ObQe+t-Xmx*7R5ZpN=I z@bk7Jm%T^7P}N525Vh5&KAC{uS;DW$1NZxrZrDa~mo`u_ssK38@rYcmy8p>4)+^~DGe*FYNrC$%WQXWWi~*FA?g z$d7b;zZQP6=y<_a$z#s#*j(|ZQ_n)hUkCi<%H5a(zGF0+&3skfQQjf);8w86?o#Yz zfTC-VMYSypR;yUnF~WA^R&8b5#RZk=*ZNgYQ=P!PyWQVccXjURti;%ON7_Ki;gigfg1=GC4=ux() zzp~yHq5zgaJ7Jz{qWm7XWqiip4t%n5tpr~xeuNanBZT>>wU!+RaqM*(QRY|JY%lmzIHnK?Rx8jepqio52U z>nbE$cpX>hxmOR(U}lw`G9zTcBt`9nfy$R4!p}kH$eZCVEy}{OhrdOPuLQ4^KnXVa zr+b^FKvV~SN5HJD#!yus|r3q%#xj#%#W zq6(}V1MfuOC|y?})gZ{jI^DBJBHAh8N~VVjxdkgK2fhuSL8n)mJA0blILx)bC)|_ud95*1HqT$ITd6C( ze!cd3V3Ni^=Em6%>wjDT#whfy9o@0vZa#J%dx?HhFb>lt)g`grI$689wx z4nOVm`NjI)hwriKabIdmYHlI|J<5Vm{hE1(ZRxvMtFlHCTWjPUwaeM)_3rMjcT&-e zZ447D;0GH~m~ZF4#`7gt<&%P`S+_IPm1rWeV6p!Z?xQk zpT2at{C?kLUwwCHbnZ(QZ+(&Ie{nLhP4ZaYW}6LtHj^yqc5;1{S7xJQ^2QW2g9Z6u zI(_rzuYu=tGoCVKchU$%*c@A92l*K7>qS16X#nlZI31i;tdK z1ISot2MoI0a2!{*m)5Bzuu9xsE#Gxp6F%Y54DQpk&m4I$@P)Bs2~uil@PG>MA~{@z zYsFi1lHT0&5KJqV!rR*V^sdh?Z8&6BCU#<3Kk@B+;%z--W&^n$eIgt|^%g)OaiyCOnaWz@1z}<>lpZL zaFhWL=L8x@htwd;d!iZUp&rc8dk=*1V4IaMJXoQ@|KT`fazZjIxYT&0Kjy1Jbk98- zTWoidkY}_!G<;EHZk)IRN$MwId}hJ5gZw<(!0SIk)=GJwY#$Gw5{rKR+UfoM3tnHQ zRTr#F_%{bvJcn0uYVLpyGgz`0D?fMDK};G4hE??mk)8hLyZ%7Z2k@S6#4A*UCF6p4 zHJeDn$&Equ-7ACFjEHZ8>AwrsIMIuh3eAyFjE`E0?ad4Fb;cnz@(m%&h6%DS=c|AX zpRTKB0JEmo@2l+jAwhayQ6>u&QRdMwp-R#KjC@8B$z0 z8DcD&lJgvOAepEUZ}4 z*`98H!{oDN8J`U>wN3Mwp8oyOQw8YhkcObz^xK00BaU~6wMp9OFSRPTHVtfsVhELk z+w^&gMfs8k)H;yFPtT0Y%v`IVIi1FZ^GoMJ{8nGznizzt?yr}|KZ-9~a&cez3Xg~t z!fYeN$;G`$cdi&c7afOUDhlXxX;;E#3MdzU$5@mbqEdZCs(n3pJ_UnGc0DfCZXeDR z!NiM_5gfU)Qhu``OU9}h5Pj@U)aS335=_739MUDHd($hoJ(O-rI%~~Pt)`TldV$W2TbmK>&Jz~&$)8o0(v462T z%R-_RZHla1M%uy5?^HSJ0WS=TcaJxhsTO~(^Crr+34*pe6ISREi;!j5-26T0iciY! zMnyIFhBFf1VUuqYy^)Eu=nB8B4>??nzp8^@Dt5;&WrJxE1^a_f+H6}^zQ`$dsX9Hn zT;zoXz?*;HJ-2*Uhe6ZmHV4V#2e2@alA+;CpS|;AnuK=9DJr+te@lFE^rE$f@*O!C z%Ord9e8dxyK;GRnMT7j3+M>&9rR^aOPr(mI2Z1aNnaSiBZT-GC`g#347e7B>gr4`rf7RqFSu^ z%{)0OCkxxdVe4vj2DRyfCRo*LjzOWRLa`67$Y7 zpZVSKj@v8y$l|;^r^vS=U}klW(uc4|P~E=~EveS28^(r(c-GL?oYIH*7@W2{dES2H z7lqBKZ5iqGL>WrD#R5WvV^MZE>98~g@o2s&IoU|(Y!KVp^RaG{XYy&)Q7{RaHsza$l8?ZI{)b_Pzw(5O$Qt?Si=F1gS zS`EIp5xEn5Z|q^UR|Rk7PTfV8 zKAayUG+Fv=MQA3J2qNC)x?xEMt!a>Ho~=e#Po4IMy(h|`rFvJb6C~lu`=MasyeH@D zdZfg82hne9q1+Z0qR!8UpgKKnRAyOQ0{jG|f>#hHtT@o8rO=&UU*w?Y-ib*BA21_+ z0Ms+2hfO%lA=~HC4tCcU1enlLN2m6(qz6KjgSV@{sRn548+)oi-hCt?SvBbemw$sk zMj#fl-$m>+fj9R?R61Svw7&9O)7nXUGOr~mZGTAR60Ox6ZKzZa01;#DlJ{6;z+?U; zZoHrSsxB>nqua$61kQ~!ai3jg>u8y6=SHAsEqPUQ%NFYgF<+f4BN;ZeRPgnb~ zn;Jkb;cES{;0TUOXt}jR=Szob|0)nCM}zF2vq(mfl*;ta7j?Mb>YXV!>82lTv(s9X zk#lQkS@@@KLO!(ise+|LVfC&z%wE!WlDWQ*VjeV#Ghg+fd2Xw83rECdU`CAmff7SM zdo_4ypxOa{mS!Lt&>Wo{cZ;)Ho>qUA55 znOT0=xb*WBdqVT%`5I#F+Wd7$pp~6IlU=(fDR*QQoH)QdW|Hlsa#~=ytrY!~-GMS(q3*@!nsJqY{-X zA`~(eoo5M~T$d6bLC*BZbAzPR1T9*=xmaKK&{=iK{56Yc2*!8vkEm_u{`vd5Ju$H^QbX_k^wL^C1{h5+zCC8w5;iz@MnVDqg49gpN70lR2i>H(R zC_6L`HYqcWJ-6Ec&%==&v{{dw>CN%i*?2~lj*w=b+3@6Wgubz*$X?3IgH!xY;yKI1F;q%2NOOt<;4k9d;v245cjrqsvxZlix=E$BB zbI+NpR%dpT(up9no>8!)WciM5E3U8_5o>x!X1S1 z5~z2N4uREY46~2==rANidMMK7bt4HxdL_?yXYju2?gaz>&(p}Z1B&fm_8kWEOJOD& zvLaDHSYj_kwR$g+>5yX1bdUGcgbCYmD|ahu@{Z)%w<_a2oo$LVGrd~pm9ykGSDTaf z=55siI?d&=BcZH2?l{Kt*8R1)Abb>9a>Mn2Ijk%J0T~LtJse_}r)&*)=l0%ChGNR2 zM@HQ@u=&sJF&o*;j`0BE9QgR&<@xWc`)T+i6?D!Y(sSLtLh|F*pAQ)xE&QC`+YS7{ zz0Iz$!J=QcTua~d5kcHkXUlf%*l`w?`B6Aktea2L|22fx2ULbMN;Bym*0;fv#UH;g zw57bTTiZ#qT&10j$UJf^qKsI|le0_8`^Kk=QScM)9^WU|Pt~Nja;2xI{P+GzsWP^s z+oH<;_emiTYa5C`%n70hUGm4BH<6ALp_+|B$B3{;%0|^Dc4JsMbzeUju$HbXf$|=_ zFP1S@>+P_j6sS(h*!U$sD42T_zAU3|@tU}evUoopm2I`vs30b|`>GD=s3E4P_(#ju zn-%GC2P633$RIw)Q8}XVJE0^fgE-;P7I2VA$C=zqyQhcDUpCyJhg@m-;)uhPGApz@ z)=$-z)j9f^)|=W^(TfsOT&ePRPqX5C(4MMC^ObK zZYT#VtX#vsvS;EkgUAr8kL>AkSS+Q={+OXNcQO9f6B9DYJz&@*TPjVNHaDU#3qm1R z;&#kV3G9=5tXhpwQ6OWq7mH-{M{t;M6dwr5{GXT;_vr@fJiM0f8D!tY=`SPNn!k2b zxNtPo<@;+1Tv#hx1XlL_m^3Ft%l+?(kI5z?GJTlVmy;iZQlolKAmIT6~cKhyv_P=io z;d2eb`!AoV9+?sR>2lA_HwwsHmzazMUQ0qe=XS_x%M1CtXvs}@R?Gea$ACvbMy88b zoFd>k;Kll1-={1zE`5rKsm6D0)`<-Uuq<}o}C;Kbb{e=(-jP{-XlsFq&QsgJ0V zxl_i*!MUt^=+x}9n^X;8tNLRZOwNPwh{jw>!l|y3rF>tUZ=!{7Ynpzg)U$&9@`ji( zHi;Lmyi{7#Fur7?WlOkjP{8X%^Q=^}yvwMfnV%8ih6%#QCE)r&mpMdBQEV&Qte3!F zV;j`q{6lM<%PvM>!HK-z>^^4=6O{G(4OLglB6VhSKQlE#hC;?c;mvlSXe^QBsV02$ zD|E4?Ba+V<5J2kxL>YG7Y-ND5J-s|EN(RCU`-sj$hmPph?o8{Py3RLnY2ZypJgZ(O z)c}XeCgi#fGKRi9|A+iXTD`9uu|w$)bULl<;xwoqYOJ{sFxvy}V^k^B1VucHxV{Nb zyezqk%yleCz|t1?(U>RrFms;rlF|5>w|uAkp?k-iw^nTw17bXp#BX*ZGaZ3c@X?&X zX&R@rm>Y#0V=Oj^f3y4M1vJo>xtPMe!pzcKZ$n7$n11qWx%G~o*5A#5zf~jdbDd$B zQ~)bKe=nb%xjBNtCr^?%YO%iaAge!P7m#_xd_7J~He}*HBE-)&5DiBZd@A61AM0&s8fmYs1xjLgA+0(@mx`m>$QArTQ+wKT6wy%e-@M_#@=|v zGO=#8NQaU6QrZLzOP|%)OmwY3%9Ti`E9p<#KkGzPgiqJ>=cJBOXugM!>9`nD;zYa- zF|#{m*fD5G)k-nYL>$>kqb{u}mm77U6xnOcG!Rce&b(E9OO>3!1kZ?feil8RI^Q-g z%WI|u!#Cj6fsNES zLB?=TT8>{3Qxyt7d6f9Kl65y^`SE9Q(o{~XQW6oU^_oXb=sprdIK)WD*QajbhjS$o z>od=godN7J6~7#Q2F()xZ_ARr>qgHcSRZY3-I+#N^lyo;I~O^A_0HCa zLPSjEspEA9IcR!e51&?l+Thi6zxV<^q%j*r58ge9uGr-G2nuJ!{NfDxTI|rP(DoTp z$QL8X&b$5az>dp=ZM@B|;41^DMEAuwtOc;Iy&7?cN-55f2{(MsP8uDnEf-{-GM^a+5!J?aWGmAefmc88)zo@h{~D`9b%E_qFpVo#Eob zOJE#GIQ3uC_lymI6~#;J2wNGJ{$^i7_+hzMu6^!J``Rnohhfvnd$PZku8#&0 z@sH7QPZnMAPDag}Pa+${A#gbY$9;dj%2zS**k(If9Mqy7#CX!JK${$Ws9j)Ef&d@; z9D)3@)2gzHD|^$xTn3hmPsmk%D3Rto@-dIeZyB`P6VnOE171sCrJ;kg*HimI3xCZC zJcgXGPyvaF+Uo;GYcn$`aTH=U)Z>_U8Jom}vIo2G z+=(^3fB&|o!jr5=lDMNDc+A95i^VB0)($d zB~8iSjLM!G7cnR8;NP zy%RJ7(hbr`qlDy$C=4wi(jcLt($X;lNGSr+DBVg52#UneQc?mU4bt5M3^U*L{nl?S z*8Is@bMHLQ*=O&4_Sx;C7|ior)Lf&^Ic)~_`6UZN$TJPg1DPl`n`Zg;^y#Uct?u2u zWfh{|pYP|xOS==mvFBbSgLbU?O{JXub9)lH2tgR1OIICo-pEHgImwv%LJKpJ(}c>Q>7t*;`ehrl7p>hZCbdZQ8|GHS(wQrtkHUcQom4 zKMFar`lMYvFS30TcqwCjL?wU3&>GGP)Mt}E`e1gpodT|%$H3KpopxVj$a$}tT<`Shm6+RN{ObE>Mb6NlkJgtm>Am#QNfcrpbw2Vv$7 zvSD}BLn}X`xkK01P#Hf3EnXvL&N92pBRB}ge3WqX)=J(y-devUu&Kv2>fOElTct?0 zpB)N6GT3Gtv5I~Vu~O*wKCv5B)t&v-Wne)6t=n1JT>q}X0&NMp=WQJsosDvo^dvUh zuk$%^Yow6itZzAGQG94z`Wk&ao>3I8UQ@$7^pTFUT;rICX7zqKEOfWV(+l@^K}`O$ zL3hN1L}oTlgrgg2_}D7U1ZO@McsTI&@TcPN3)yfol|OS#tW{?VYqz# zk#gn&F)KHk{l~>3alL7j(8b2iz!^C?SGUvG+$EyvLFi5xfxIwKuLrJ|FsBfXC0 zXA2;3a)ktR%g5#pg$L5tCdn~MKOe)C-XG}ode(fczxeCGqF?!l(#4bWa8S83EP|NC zeZ82#Li8Qz3Vi{RVdZ*HhA;5C&I_dkgG`X`ApBV1#rDcPe3JsTe}4b{G~$R6FsF zWJp1E?}3V3GCW?nUmy{9ma!Wkf3PU(60k=G9``GyMUv8{cO88xJ7rcW5^-|P`&XvH zJ!4P5m~ZT(!?91fcBpeK$?J*emqwwlJAEk-Pl<-Spdx7TIr5xyn56QYYQP}Zf?V)f zD%Q1LCbDZmd2hxAMK|t&j#as>8aJpWu$J`N+Jq1W6vostxHa9X)a2y5{_Y+R55H)k z?)xErA>P!7uN^Yq2tl|rNHG_KhG`K`;$!S}PHxFM=@s04-j(z8o7qKV(mpyR*`(N| z->5zDPm7S0N;_w^Gov*3ZKdM3;V{KlRdLOP-75FX2HT2ybj4EM@QeK*Ld7ch@opy< zjpBK|jsns5lt~7jfn0WFb#-r>tvTAHh9!)UE1YCP#7UUYiM2caD+EF*FrHkQbi&=f zNr(a0-4MI+A^P@Mx}g&O#@o@B`Fm+zivE><{p7LywaIn&r=H}`bv2h}j|OCJE{-tf z7XLkX{f~{{|4;yVUGM-woAQ{bs@4J`jfL4(JEaGEEYh)ZV82X369j6v_|Tf{9gmcL zo-Rmnkx+4TI#a7e8xD6xq$4TEJ_%9j=E!?ixJ^}jTVZ|ir=M61xw?WD>UGM}&n2{zpZzs@^=c%%i4A{@$kOoW>+B49#b7xvXT3ZWx^ z9_E{f+dsC0Z$1{-!~Sgg-RLQ&km*t;a=%ZL7preB`R=9gTSs(`>s7S=G4*}@(KX)! zYrNG6Kf@t@@4M_z$w9VN{ee6E4d*Biu@nzKP-X)DCRq8Wqi-Yv$axKRC88WY5zeD} z1a$4UxeeVtf!LC_zu>CxHUEy8m5;I{B0ofrnIM5}2TcLNuFwXn!S7;F_J?Hfo~kokb1x!f$z`jO}+o{SD^Bg*epHNC-FskVBH36!e?GAo=mxP8tFTeiNbAL#U~8RQP(~t z(}F}@Rq$izKTHJE-$K+(j-z*&Yfq{0$VOl`+9hRd-R7mfydPqg0_hX8lmF~o|0V5h z{a=Gl*RjQu7eOQe@qwHJ{CEGAd;Ubc;8s%WusRe?xu~Y%g^nW$0=XXe5ktH)4DH-Q4OaWUwmM*{8Y%*G->zpPxTAmy5qYARrqxe_*s;~jFx2H5 zNjUbKvVPn1vFP?p{sjK}YhFQ0+AaDdjnQa}4;m&W)pf#GXiA(nk(yc4O8X1~B5CwF zYGPo9fKQ4$RY0_*{ima2yyK5VDDL9Ar&I#A@mz9g&<&pRnM3sVsj5aSP9#|i+Xfbi zFqn*FcK8MU`%_s9H+H5hrm}OAEW#a3Hh^E+s1CqM{2s<}y&&20{{D4$_WS-&7&WF^ zEw9W}&1vRtiSc!?W_FxENR)TOGVl1m5LwwAFeNcGneMbdJBJY#O|)2WH}WE#>Yr?| zD;v!iJhSkgo=hM{mriwU5@2MH6=GpTgw$`M;J%ph@To8SHmnJyggs z8evnWs8f7M!hNIp0Dg5vE}N3(9Vy7Z`c@1epe4nycv;#=g(01onTjy6?i~c7nVdWO}*ZB~w;%>A#^tXV56re)`u-D;(s69txRM8|8 zhj(ew`oTy0M5_2hSAqimFLiKaaQ~Z-U7eC?$nFgu+ph{kho@7D@uerykH!tA#2F9Bg+pZEX!W%CkI*&@Q3|l)wHjtnV4r<*c)^_d@oRy z7#|x}vDCJ%5F!D{nSPt^roUQ@R-k2MzVhsUUV!;Tu3**R4c*Gsg_-cBr<}8F@#g=5j|>wU4m74OCgai|&Dhl@GR43m1>3N-6@bTyF;zIS|Z# zLW1CBiZc+ZVVx1a8^AgvNPONPe|weorO+kMYme&*5ZvaGCXQb@1Je>{x^p=9<2P-d6rI(gl3fPk$!;^r+3gK7 zrM{M%Yr(ZLdXV&kj8r|nI=i`1brMo$=R0HxAMSqx1R9Hq0~@_9xIDB z{EYB?ZkYXw4x-m3EZ~%5ZJ|y$^cfr(-1mQjoLbUC?T$k}OU~U{?YMR`ZfEt;lWcbd zmE#5KS0)~<%>@6N@Wcn~D|=zhf7 z%i$p7)5|`GkP!}zA{?0WP3gO z!L;D>4%<`!jA?U>MLYNqg&mhrgXid{Y>471a7@K=kO2o#*MqPyr`s&8-cXi_-mGk( zhkap15g)@8hcZp zZfyqLD7HY3!!OOCVsS@b2D4U*A76fS6x-2k;d|5{X_VdBhTm2yGbx=vKwZcaKbP@U z33D`i`bDus&cZEfRFwlev3;QrCG@(Zel4MVr?XcBeEnDT0uLK1yVq@Vt5;qa3yj-> zkNJzy5;J?rVjW2~281H$O}`B(lr%7r>EZw<7Dh z-KNg{e%1&hfyNhdLw=~2l-i^*la&sn#fAIR`KUG$=_}VzZx#tkD$9aasMial;s`&7 zdtZahkZ40GZV1nw4Ou44q}P$^TybVzqM9@+1L|+RMU4=Eta&zL^Cb-!MVs3z zQ&c9iL5eaC>XlyNi_MOFF!ckBaV)#~Z69o=lk7(>mwn{;Gj|k`h5Sz3naYXM1!c4M_Cwpr&xLoq##orsW}|Y=i9qJ|AEr>0 zb#6VGxmb|blg6F~@r!cc67^@AFH6`nQ3c>7Umv$&zOR_=IM*_MG)IcJzvWa!s7(5% zn#%v~pZthg4~MTg*=lKtP*sQC`l=%|1hKv&&8JAz?<YsaBM4VT@py0;T*Ec_N>>GuV z(I5*_ef8Lm!@gtk{20Krl^xdwIn?otC1Ecp;w+pP6e27oGDJo*@W@NWO?Q-cD`V^h z?C`VCpo^vF@q_&=6h(=iD`tM9M$+^OhR}~C-I;3Su<+i#Tfa%e!9T8BBF-aTcSM5s zvXJU@CSp~7bG3>~nT!Z0C`wwmeev+9gWf86A|K_V)>u(yeYC=kTOG;&S2_jtX^G{< z?r60oVd-gsc#;S1IZWy1J%2^s!_&kq?ac*X_@`~}($||cfm?d!$EgChCnYdjmK^oU zd+@sL**Ne_rLl9|`(oI&*ENxIQ<{HzM zg`a;eDqm;FP{53jeks3cd*+dpx~}~5;6(7sRWp6a+TD~4p?7^2FV0vX)l~^IB-kr- zN5=X^)i-Qf7*Hn&D$&PrEqWkFH~wyQ{?`+~-yduU3V~QIJPFS2XPqbo#el${?bx+_ zRp}57O1xJaGhO8y`O8s`(%?a5}mU4p+AQPrAgmzERbaV zj@GDC4Kpb%pG?&ky~bY(oRzdRV_JHKs~h*!yd-YxzurwQ>+4jwHq4=$0#sLMwWqWn z+5DU>9z%$KOZ(?pGs`HTw7hgBGU!Vk_?++t+@8?HlG;zI9TwQu1GryyY*{}E9k1s{ z>uUniQbq3o))t`u)Gg43vwoJ~i-79H+1tG&9n)grE&j-d=~l(>_wyk>vL^y#9$*#% zQF!QEy?Sjt`%A@lMu>F>fbleLzS_>QtIpZ-%rzTBRH=|!U#^Iv9N=B-0kpq7`Lg>U zhr4<(Fem|{O@8y-?EWA?6RK&SIhjnrXZV$WeXwb%7oCQoQzimP16cSIho5luI@mSS zJBmIajHlW=0{!zI|N7Li^WRC;nnX_7;AuK%x*$Q2V-FXgg&a^N7$K^!4DNPwfqw1{YV+ zwRe7azdT7&MkQv<$le$Gv3P$zCG)AQIr-O#P!vb}Y0!OFB$U9~6tN=X(nNpMFq?@N z=FZ;muii<&ij(L)%HC*pI!n={?p;pi2g&Td#X=_9oZ^t{(HzOd9y1tG>K*it9abdz zHxylrlxIO`Lk(`oD?~f;Ko-YPUbJ*g+r4Km6Gab$*t0)$$L&tVfGw2$%#pe#)EG)@ z>udP6hKqphK3fNne2BlyRfgjEwC{jrY0*BAy1!Be{P0GvIRFn$m!q;Xb)b~g)C*G+ z*3n}(MsewNaUALwzi&$pCO6#i_9*d@f=&LlycCH)hdRv`0xZgoKbQrIt2%-PmD5f| z06qp&(f!NdZ+(4hvqudI_rU(?h#n|RyBpeXEf%JOk<*@25gx3G+#GJI6n4nm$<&9P z_Xg#6=$S|tl7z~YE61FHzJ)uN^Lm^nr4QVX3$t50ew)g7LqMC!@jci~#fP>1mee4^ zN-|1OX;N@)lZ1M!ox!H@ra+r*uCzkf@Tg6gd3osi{?&irVP*Tf`>y?zL8aVXC_%__{KG40;~>HD%!0ejpV;E>GRVZNq3^SQo3LZ2mfENl95_-1jcQ5YWxxDa zyA7S%mG*ky3<-cM>Y%qVeKbKphB+-lk5{kbfDtn6AWnL!OkHzGfgKKt3+Kbg3v@*o zd`yz6-d78UV><*@Ld3vykEv~kKU4;wB~y#PiZn_S?Oo3n4+&I6YyXs^N@lx4M$-dg zLid>mHV82#7Bu83`=79r==S(Hk}ZpK$T$*Fmo0t%U^Y2fp(d}%wC4r?XLc{PGOCmy z#k=AX6z_@|w1D4ls`1FwttUTEZBT|B>*KP@);51O8d-TepLda^;}WOT55?`uwkE21 zY6|J>-98+q&0QqLpBizUX*8}pSZ#fxBH9Yrv&l0W0#_Dynnvqf`{E8N0FCq_Mh z0PBNAgpr&q9Q27Zl-c&?8!;;{@fbgU0177H&kUaB|Cnnh*q4HFL$~71Q{63=zLGvs zC{B9{a8N^hv>D$n=uDbd5jaEJ^|;^TFv;(J#weKb>qu3Q!eia&A5T#DF6p+=DEZrW zaGJh{i$K*tgsCUbTKPrQvK&urBW3b za$j14D63W*(tzdz*GB9Y>_K5_jzQGJ4bUk}+zmTXhl;j-@=>+Drn~Ei0dZN*mP%^ZU$NM#UK-XnkvF_JJI}?9;H@C9XZ^8-l+i*QY zt7zSu@zhO?r?tVsR%YFjeZCUsCjl7dX+0zP9clo-rHqQP2|E2guW=qeDEY85|L)0U zKya0e_{R4)5JIafg~`($SEjaPRF~TxCOB}vTDyG-2s=uChm6VelX^BrUUV<=^M8a5 zCnoblR!4Mr1hksy3CckPy+!YKf8J&!_v_E1Yw%iyq{m-u>gVmf&x^bwC6rD?g{R@p?J^z|&Ny>Ej- zR3BuWwfG>f?<$iSl$y+6P;TpKOw$gHB?3v9M>@tGvzHY%7(vy8;9Twg-6`^7_fQ(y zH%au%p2!T7;|9aj`(_j75cRV!D?ctR6igEqGkq_WL*I6u*{yvpv$PJ*v+^?vS5OxD z?XHTKgWQH1)Pv8W0}wm4!#jW@>N0ZWyPM*yc(K}>Rar- zd~i=dGWevk*mS3MLdJ`yx-*$UuPk=^>f>urd-( z0E3S+^@(@$ermLb&)wVOded<38a44&|5nc6GM^SmW_oP!Jpy#5$a6Z@i64ZwCikTv zfp-IAA5c!3=n|a-8>xqzk?<%18yooP3faT%y3z%3FUIdJc0tH^xCWfcq%=+8!j4j> zjA3VIIn^dMVCNeNXhQ^{Wg-#{Di_|7iICVOk8bq4CEhtEBrwPHa0#ESdLD!u$ZmPK zMsXOB{c0*>75=j)C3rAew(x2@U6M(|pF%Og{A%axHcYdERmeY6qA8hIUkRDjSfTVt z8jl>lRo$F{8VLQKZ{iJu&T6ApN=MjrUO)O6@XKi9YOlWT6RcQ_+{kr>OWlJXrG%A( zWhotKWdVDGKSv?*`vmfWFp%!g=W#=GejmlvaM(>Vpud_OK!rcHC%{cZf^8=mSqB(d z-wIgD0eE)YMNju-ItDfU@+xl1TT+9Bihvthm}Bz$>S$IHt7CVtC6{CJ(az%~=|76O z-*a$j{6cOCJFS$q`|;wk294^JxcY_m2iU|~s~<~3a5tbQVTyc>-$P>=%MY~YZA#~y zUaFVh{lvrC^dM0}4kXd|ky6S?@oz`mts~{PSVc3NsQYYnWV;<&<=G;l_xWO_Bt?v= z@@^-jY9vOe=0wA299QRpxKf-W6W_6N796+Q@(T4vGI+e`hl7Hw*-lH2V5zD~sye zT)KV*wi5Lby?&HJ^rn-pkw^q9UOXx%zGm_MWrH_yTfyA9hac;n^>w9l7IPdSrMG$SjSrH3T5wZv9S~j~_ zoK=LgP`dt1qun9+0Yag>fXFSL`T^s|b~BG3RfL`FuMR7C$43t6=r4#o3}l3b!CG-_ z{x}=cr`x(?d5|%h2POIbu9EAp^|PwiTw0hE`7@GS%WuglhJAmu}_KFWy)>^S*VUTgC~%9uMeUdP391AMd? z+S|8uYm)d7rktV_d)MND+SoLBmAq5Vb8R>0M`y#=>0d~$Ec}l4!|i2h%%7=PpMJXW zXo@j*a7^mk{#X^oUD3v>4|9J&8J=_7n{796^}D2!5~XPh0tyd93V$7A?ff*h18ncz z=N{=tvly7mT|rV_d4fZqct+_QU5Yb+NYd1Urj`q9cx#c=J>_*`VzLauM9?qQYHYR zHjmX>Q95wm=k>-Np$swQLDyGO96RlA)W8AmB(XR;2peUI*lq>z2k z4Xa=`l+aBUO*3Ag@7Xpnh(|epJ^5~ywwtTy10QG)@XG>8hEi1&+2hAWt%1Z-b@TF6 zD@+?}@>C=QYloRgX55?bNOak=ZfOKoRpc(8i^Dh(P z8Qq~W`v(e5bY%TjTYra8Q5Tq0mL%DXXOF2+efYIdZq}FArD0uFQcf=N$6^~}EKBwM z>&XV!89<)a;G?lYDfnk1Wl-AYZdE(gDvQQQAV{pbLpB@SEcL&0a6gqUwg5@Oz2!cY zFu9fmyIJwdsoR$rD&Ne#aqTZ@fI3KIIid#)L6)o16~i`K?LPF=)$t zOtJa7(ChEbVt>lIsy%ZES_#3&D?gwBpf&yN>5q*f$PdcW!HAgsi#r!!iUIA?E0t_w zx7_CT-tQ^IWyu2k?90eLJ#M%T=#og$o+xGUyfvKG=^tfjzbG5^N-`1T7JU{#x0dQa zJ2??sYVf)J*R{5XVP_zZzUn70Rgcyy7GV!5{pqS6X2ys0v0@tB`V(CleD=%~j+^Lu zA{n&927dc6Wx{_i?Ao-)V7u==){+z-?Q(UUFSMowzPCG?_$GxEM@P#;hU>;CwJx>% zJ<=cBH|7|o#3OBTT4cfuUCy)nwElr}M?XHtcthfEaM~PK6wp<4b;aa8BH<*Ih-*Js z+A3?A4`M9w-JzOa5Wcoiba9Zjd)OoM>9hj}bqTV)u@m%CL_i}_N?9e;yf9{1=85f# zrBb5hr4$R7R=Jk5E1*$J^c`F%Ra=V8pghO?BPel|THx~l z5om&+#vYftwVti+dw<&&0I_51W}SZqUyV>ukPwd5akBb|+{L@tBtg3L{>HNZugB4d zS1BT?yw^A0-*ggjqTf;%$v|@RFeLE_T{cCm9#qp4LrdUIO88tE!s<6(ax;;A^K@r=QO&wV4W$nw3dUzH0O;4;M()-xWNU?+TQE zd#iJapfO8O!L=y{%O2UlB(ooRyFj+}EC9lRI|{>tX>k;uM|Ibgf8BX*b0sQ7a$vsW zdYQuR+mf+QATijF&z?Mmx_n!G2jD#SI5#N!<+e_lIA|z}>3Zff6t3^k;XIp!iEx{Y zcT0j9FQAg9Py=N>Vyt>&= z<}PK>p*Lw{%9i3vaU`KLeY(hHHgHf50g!RC^{^_;^ytCW?$7eBK!}VZ>!=yxuMzhP zeYeZomsO(bQ>5TU@%3;)aN(=??0yl&BMU~*qYis43wr4mv026PiNS-)r?%eSjHn|G zRLp}?lU8x~;|oR#lhN0I2?(>RT+eI9h|Qg^iRu}VdpxUynVP6WC1YYJmjWhi!h9~z zcNZp=2O+j@<`g9@dz8cz8R2T*Ql{(qda4J_>IZGeYD9(TzOX+wdv?A?T!m#_mjx)) zCk+l@mg}TTBmIwcAFYcxst@ZyMN^XT!E76vR^>X*_8z|Cl`lSvQiQ98oW_~DKAa=W zbJYF_cq~f)Ssyr<8QEIhZCPl;=D3zV#u*sdxi5vksH-H|?cHb*C^wYgkQ4pPndz83 z`8uj@263I#Nt)c=&4MBgwIiGxql((io~I5zt(V7=fH@cnV0@kJj6fLb(Hu&3zJOb7KElpDaV|J0#6*V-w+XYi)kJ?8{5NC9&A zhkvmSW=OZKNDR`!nlt-!aaJR{Eso2VvOP?uUnk~Kl}YE`FLRyDASqEr=~SXD{|#ZV z!z=#mvuo{J!F1go6d^lOfKI!w969~^L^)Fs^Kx0$YalMl+mv@>*Z2&#ZJwpI9qYf@ zOxUhms6F2F{hraq&ML7LF~L9N^UUi$BLx&w!A=N zmWlG8!tQE!HK-+RZU3( z)9%AXX5nAgNZ7J&*t<=6iEd3@hZ9yRo7o6UV05vPM4AOmttsSQ6C{$;XG#Q{YMuqh zf6t`i4051rW(y&>K_0!>W-$$#-IOvFv-fz({JdDODrhjc`Ji$P$)~N>Nq&F$37L#a?4!Tdv);Az(LPc0LzEC})U8`_NKe?amukvG$r z7R@3+{E?DVJnU&SeCUjN?G2o?FGg^dp01Iv1tPw;=+>tkXPaZv zy3uo=@`|yP(iig5K@=T%r*unGBo#+nq{`9le?hBy6T|TUQBoT(v^1Ig)7X5aNx7YE z4)Mg{P(O%tESN$smJg$44HCvHt-^Luo91N}HSbkbi>2PIfaW72+MI5(n^)zF!pyH? zM}_iYG{{S3n+i<(O081LqS*d8LU)D$m-X{n+g9Tu#+;62;VHmhI#U)6d~CA&Q0QGr zul~Ld`L34X^alw#EfV*mx}hxjRdd!j!OJ!+=1MgeklFK{veE1DS=Z_N+S}Un0wDx= zUS8@LYUWtjd9-%2cEW~ilos~>e7P~Eb^GRLH(QdxxuyMG+*v)CA9u#h3=@6RTK7Wq z=6ll;xgjf2?CRkw7Mw*&xL#>E3D;L@RV;p>iVU0m+fCdg)9c!&WoZGhjrV^>2~L%T zS?u^TYdl%S1jf1EHrB<{om`A|!f$0#;(Jcomtlna^3@@zyQzss%DmV({=;TeqCwM_ zhckTO2}Jy(Q_F?gWXtHc4F4o7Q3)B1aEVr--YEr@Bky?B1zBDskrlB}1g z_&)q>;hmVG`ymJDtGsSEa3p_^_!Bcrc3T4linZ|Bmh;?cP~et5A@n~V%uW;^;u<$N ziijpHN$M*x=`9(%&Rk+*Q2O8&+0aNl5W4Q52}OgHFH3QD#D^9yv7%xDzwZqc-9z$? zB+aA9E%T2F4Q(j^jdc0XkB`oAHUUQdD;P#M>BWX5U_W`&|J~4sgg`! zI+xXc*A@8f)kwRt|2H#z(ttT58>WxDC+gPgeRQ)BmZVcJCTJ7?>m^KHNjjp(`L(V=e5D1tdiu*BgZo#}Df~aRprjVWdJr;1 zChVCgS)Lo+8~t*KIe6md@S-k_m%)-PL3qV8@^WN(o6|Mg*c40%COpd}(W8?^<7Q=c+yf$!wbbt{Gwx!A( zPHG7@u&9`IneB&$js2Ks;*;ve8{wq)&yUm*LA1G&khfFx_ z4IK_Dl1x~i`59klsG`Bun{)IJh~;=DU{LmtAocjQ$gite-|hEos-!$mo=bhkzxZ|C z5!CH%!3*(JrGcSdxr#+_h3Ts`=9sEM6OllpiBjQd#AhL}X;?N!?!YBe6M17C4PvW{Cw3Bf{W^RZ7uEYrUE(=`GMf0v zo;C?3mFw5_J_Sc^DH-UEzOhHJF(!^&6Xo^LSq>A4js6J{dm}I6p!Nq*&O-%lznI*4 zS>*`EOek34{z%|%j_buOX|{G{INQ$F2oPXjeT;s+N9lU`UKa0VhSSy=eqCG3HKNfc{i>cWlm6DGq9GGwDX&k?+DZSKfbCe|~wV zMY{ueJzaBS=v|&aV(`wZIvbj7Dd7>D!ZmTDcD^F#Ts;aKR0uLs+u+**}BM z!()@FlN#3+5M^iri0>)9aZ3E)dZmNa)N!Nof z0iNwGFQ#VVIl{?=qza>jko+-55Iy0Xcyt-fNh2uq&V1PO?zZlKoa}(klyU~nnCFA+mSPbhSM_OuSh^rL{KbJm}QDKQ9!Cde*1(m`%j)`BmH%=wZ)Y+L6)^TkB^SG_iu>O zPu-<2PX2rl-*2qak3gBn%J=5&dwd}-YAG48kp}uhmB~l?>a3dE4l%7>>|4riq;j}D zmlpw#xlD9pAAuwzsBxD5Yy^yoTUd?v8#XJxyG=T#F3yL9ftD-*$ksfz-0R0#=YaP1^*f%I<`UR48QK zy4M*MuBFdNtvp?vI-;x_(9R3Z!PEniOE_NivCgS%$kA(xu`sK1>-C*_+|GMM`4N6t z(tV3&&TN}&QTo+>SZZ!_*hdF+?!dv9qS-gE8q>R&!?1cJ1H1tXHy```em_>~b~%=6 z|M;;0K&S(!=_CW}ILp1C_+eU{J@+rpcIN^5$f5@1KHUt`%IG=P~mSqt;m4yaCRl4be+9Dl-lO z!5!}IH!&QQaiixv`Ngl|x~qSI=W>)_srThSx4=Vb%4cnur&`(fpv+n+ppzJ4H+sV< z&rFXNBYEq+Ca~}da1rlTS3`8qYm5UO+7e%gX#$DCZ4amWZ43F>9p}@9TtOe(XD{GJ zOS~lydeba@h)uEuIqAN7f{q<*J6G4}_pFGe1}K^Bl(#KdP;)KC^9?`RavzaM${XBi zt%K3#OsbX6-20$N%*TgbZ9lvtjVUgLgz$I`Kev9%g}XQowMW!TMS?Ryn9bUNG+QH# zZ_;a_#!$ackZCsZXsxJ25pL6bY#$#0VS=s|?~fesKaYpBR5;(ufdsKGEkDzQ==w$b z>6Ru8@4gyqO>J}_`l}2%r95rgoffniF9%L1`m?=AK+tVw%%%gp_<=6l zDMrhQ_ImI6Y9c4o!h>~R^UgLTTPlJtsHGhpS0|AFlT18{;<6Q zwi_VO_=h7G-WC6w6?bn^Bl@XMZJWo*ElT`j1$*@UUaA@69@q3O7*=l09#Ix1tiahn zpRG+BFGmA!+W7hhehWJYdc{Ed!L75A&G~U^GDKU91*A>d5D9Rs#RbDQ3hdvbr4s=5 zX~B0uN3EWmUs2{H+w%Q1lwT+lJ$l}>*}lf}>vBb;+Z61Bl(ca>cwZ1dXNVar>x`Ia zBnmeS)UmCZ#Av7-Tva;%k^j_3Ap;)uQ(T;p9GvL_-S#EMz0BNGAiU-ICpeVLnr~xn z+ZIoSFA?*BzAW|0kwkzA3>a}a`+00Cb7LU8e5xWJj}!OJTv-$_FXzcjFfj;~33!Aw zXV6?@2y~RuuXu>3>%9^7q%hNP>ZJv%zqwz^T><%*`^eG|rF1Pyp%$BsgmBB@V^%j zdW(w0qC~RZ7hrvs>XH}G+KxXjPvK6U;#uC$qyhzkyzew&gy?-KOP_&ddHba<0LSzK zOn0{zTp4;%ztCVUNqtO?UvCO!!70XuiRmlFZngwF$9L6%gbJ~Sp!>;(*^u0Y`!Q71 zw%h%1X8W)Ebr+yD?*{m@2#rMy;E1#lk6IDq3=<#A+h{KRR>Ul;#>73(}n=G1u zg8Qe$LWx(;^+|{P_8p~5^@CsrMk-QGTh!docBj=~KFUXMm-8N2Nz$9NboTZk1Vg*M zk^IsZ*E^1GujVZJpels3!6m`^x!7=j|rAT7I+8yuP8# zY7%K^d+bFn;$Wx<8d`qE7Wf;_XV-=nJJUIp=Jk_1>q&;Ev=;=>jEx<7hZOV$Bj2Pm zORdV^;zO8le`6n!z!uY*Le%ZWXfX;`{|pueJJ;$Bp9D$8My~%5C&wC<135`7^+J$d=e!Ud))L9>q|eiryEcXdb(STQ5ejZ9;K67eL*7Id$PYzZdAX@0I2CJM})R`Nm&GhhPx z2dsq%r~I#CIkPXo+tz#DLKSQYckKs`;P)a)BqfzXZ&;t2Q0iAK*8i$TgN2lH!p4Uq zmQ$IWnDM&eJAO1rJg|%rM7&g=w=It_FAVk1XK^8m5`#3v(wV}1RptWLZ`klaptn}b zZn$si&UKkR$!cv69Bc(`njlYRzyUiUeSEXG%IQnrNC@zWc~r^p?9-yy_4dhrf2Yr% zJS0TM(oG0Nj^haxW({3s=&Ypjy2M(U!p7N+0J3PRziSC%H^|&RpT6cI7gkyiV{yC2Nx$9`c`smNrb*5&bFIq%P?RQLXD2Iea#x1a^ex+0N*^M0C z*5Wq%BmU#zC7llb3I$o{&)coabOc17rPF-&hOcrMsy!`l^lo95ai;7)RZIOpRV(vI z3z|04XPfyq<&gg!u+r-1hXgv!xTL=1^8o}GZb*{v_AC9~B6OAzB=8`W8KnhR*8)96 zt#pc6onCU6@ESqJDsO-25^q?^gVNvF_j2~n+9z@1=8SHqGpF+j`Zl3W0Vi$8mdS9T zd$ACa5)+X?MaDzjy zHfJVZ1#|Jt+Pb0iC2#BPSUiOQEkYlzxjcGP0l|@6$SbI`T-3?-CpR8?uS%lU&^SlN zX|&h(qZUt^>Rmp}$Ar!b9L4T!%eB1Tz5`Caa`R#rSp4YoGQe1}4A#xRmL z9q!&;?VM}%sgRo6k^<&kKcoLt)=VUu%QuPu>PBF~i>PYw7=TD#ycP#I#hv++OwQhR}R{kzp8e|YHsAStOjYrkgKyyQ-Czgqhx{J)DPLG>BWOUnZBI^?SN4MU7 zViuN`&fMOyCJAy>;~8F%@s^F_km@MJ=_D8xp|Tf3ZQGY;PV$%-Y^_k_G1Nfdc(0)_5I)U3;1^!~@^PCXTie`gHF1$0^;?54@DgFk z1s5*S%jBoGh4V?~FAS5Hc_5;o1=wR(Zzkxm4r}U_JY`~oRKbuOE%+*Ow|<3VXzUTs z_k=Q_O`>ZKx_+&;Z|}+a6rzv81nW0hcVtm!M08TLe^u?WtJ#q~k?s}Ie2bs2T*itL zbyfy*_wj^fG&mDVf*5+JG}paP=lS&J2e&3>+>NSc49eIAz{1dAh=k-^cL=y%p-@D; z-7~mB_qjE`#*lLY%M;z1*bjLgEsAVDD! z6@A2%LAE(?{$<`~+$QBJPNXGz31hs+1&jRVK&1 ztyDNof>w-63m=;DoXCxR9v~-U;dSpJ>pf!b~1ihs!Uoz7t!gYGP znJHog{qd5`XJLx&gq3n;E|#`mpy&QMgHE~fl_yp>*`(_-z~?OQ9{$w%e>L?ioXFH< zo_(mgJRUBTXH1y^8~?=c>(gg`^s3)}3fh|ubn0cg1gZhY6f~yLj@Tw<^ziW2>7(+> zg-lffRj&R`D&;pjZJ*U?5tYX8=?7JSL}EAXD+UbDtc$Zq4e$m242T>vr12jf7;r9} zTv%~bObP*-K3HiVlMe*>p;6n)N!f1~R3Z&{jm!(Dt6m*l{MIMfSPu)&AE~5h5oN{R zsTI9^prMJheV`rMk^YY3VRY2dxEq%e3`y)`C1+w z+k8}AH<$4PUd^|JcO4F5oG1MDj(+hqpMj0e&aEe{8np+zOTV|sez6U>1wUHoMFIHy zTLL0jYLiQ6>0P4vIWLZ_>CYSwt@iKMT9gAg3r4Nv>p%U#D*J4JnDW>4e?a92$Va2* zrKUYj1=uq)DSBL-npZnolvdyHHQ(2mM_aI_O^^;j(Poq3 zj4t(lRCbZ=vtUpHJ)lji_&=7{NP>m9rJoOo8;=LNl%7o%N5F?_4(`z+rOd>~#}rl| z1Yun_ROYp!v*%G}ouEk6!toQGCxvJ}2t5nHcE8a^+^$hi44IE?5PFWzfgfl7P@^hi zzrXuP$G+!pqPXadYhxDq>IsNbyvF)X6W}^?(Za$PmMFj~d&Hb--vjjVhq}BI9fAgb z8z`!M@BX{iio4VlnAU?Ghbb<2Sttd9Vvq~AH`Q%C{Ry|^g#?CT^~=2)Fo7b*BK;VO z4{J#~ssoXeH$~hFe^NP16o=^4;ylXDfpWEFc~wgGR#Nfwqz*X zwMkyQQI20t=o5}#{OAJOuK`lxfutTK(@bRg-e~W&{Wka&#(v1KYZs=>fF+vvWgqz= zK-wNAY9h&E=56`-XzKLN;i+vQ+TluN2Z?R;dfRTyS(PotI!l{m7v=?<$<3Bl>Zxb@ zZj33;cORMfT9G#2m|K0#N6|;Q;dq+^+?+o5E{}1QY}bsQc(3vBSYam^i_A!?T$(`b zmzyg8A5GWcPv!r5Ah4WEp9!SA5rEq z>5X5sA`tZ`ojWIMKg|Uoc=wAdO~0dD%p8AAe38xw;$bX4F)<^01JU?}HB@gxK(hxU z{+L(77qkRu)@i6jdo^_!nk8ARTr^y#|Rr# zVR0MD*} z7+R1chkV?+5_qaLMVw4x(+$ntq}Y9&nLWZ@Qd839RdRn?`6Ed*YU;KeBf7x4m5lrG zdlCB}v!*d8vxnk3yQNG5O497N;M5?soQT zaObe7G1ALv6nzzbnH}-5-5_`TIg!4-+Ldz>{Qa(SoX$3miz2P0cfL4hD*R8J5-a+0 zM>Y;@V$Dh}o;?tL`tRP}x*hCY72`VdTC8$oBF4Lbcjy_sllE?t{{ZNj{3t~)b05hS z*8h^E!(@(s$Drw=6LJavk|ZuFCCY$j`;|#ycke$X#Xl4K(?u=$wiIs-Y-f(zXZ=K(VQYtSN@xA3rX2ig4(^6)pd# z3eu93UVil4 zB*kkgStYxxLC=M?MqsZe!XMm3YCgJSvUUy*f~72dA8Gj!UMp4*Z?^xQxUkFmn*x_ky{{Q=XZz4PAyXcg4r*}INN}xoe(ynEFbzJ%~6|QLJLLzW=dHRjCg)ist z&pb|*df=H#c=m)Zt0cWlDmU349Fd0Z8a5^YrMbkiQ!zIhokO%r3%*ADJdT6ueW_9 zk>&XjKEO?+kocOxV;yc-QgvH=_>c}LRn&6cbx({!4}~A5x_ssP^B}c{yy@p-99Ihb zDCu|fS(bzz{7iCMQ}s4H6S6uQI%T&|g+y>ePj{L0q1-l89Ya#59G_BTgpmfUYEO&| zuabqj!#=&?lz(^-c%lT#6f!iANcvs zy#_9`*R6ZE6#q$iXqSElTePM#HPTA5^&t7-mq~WKV>J%SFKXu@?EbSFjo;t)%F>y} z7E4DCd_U7cW@a3F?1-h~@5cm*EFep8R^%t7)o}y;Gl-p>+HI@XOsTARheXhu^)mV& zH)m#M3q6qP?8<_pSv5@-h|rvg;PR$F+9>##TD+Jm7s)#{FCAp8{=op_S9Uss-qrxaL1s_ye~;T^}3G?5SYfnk4X zZLVwaQc7nW&rZ}k>AyibA{t%hZtYZt<^0y>fZ%I~QM5nS(ZLULbjj3buEm=)C#su= z(PKG?SjFr>7qJ`xp>0Jk_;=Z| z3gY%b?3-Yv0w9wnI3MIJ5gIwv2U1b*!ctut?=@dY1P9FR<^=mDY7!l;RksX&{T{z| zrJbtGrBHk(1k3!yxA5MACe3bFF zRq{S!8Yux#L>=w8@#-}$h|l;!PB=`<^GLA3LU^adi$dsPiyW`B5IknrYV~YBTUY3b z85m-ndS9gG3fBB#_7lUK?;yANBJy+93S;th6R?<`TI$>Lw4r;cB{PW zggU$2O5TRzOpYc8!7#3oG&Y3C0r?}Vd@#?{J@OCCp!)_cmRNdzf(`WsbS)bvflhEv zpyk4(@n;&o&iF4?5Nv+(SLca{@N$GktLsY;A*4T zoL{oK=d&$E4qnICw%)z-A8&?=|LpFV&D=8B6nvQpC)hBTbhxtMukS+d0lRXyZ11{! z^b+sYSZ=lXVL2tZaC$j@zU6y8x^8>Ba`46MfJ*I$FX(7(;xeZ^>1h?{B07N|JMQ#t!7PbD_&&Y*ygH}l$VtE z>#1Qf{7q2es;(P!@b>BP$Lyb9EEOJG#wuSBq_z0w06=fhP>8XAU?j*qZ{_R7WCT54 z4I(E$u{#tj2*qIxFe+)D(@$3>QQT|y?^3MIgg#LSC(^NO4sH|6``mD)(&g&O<8_$h zt|uo-?<(waLoQgBR0~09^SZ+j(W-Fbuoi@b*AL=yv^x}raB=**WFv}J4~-$l=#u?;<7c)}uQe;_0h_+05l{VJnE-O0?s-;SRfs`U?$^}XCe8B{Ow zaEFg;OKIlokE5PLWcIS;HFn$YrGyXjSkHKDQKpJW3DeR}shZb2=s3)s{JpeJ&vXBj zX&Db;cO=ufN3P=bMq8r-kcQO5_xvPeFA~EJYz{}KhtvcVA(sF-Yv-{+cerXMAl$u$ zImwblW}iWD1Euc66RRk{XSvm{HXJ0W~{xr=+mdh5YdSD4Uo#p|-0T$hup@$wu=sWDP5Dfm zmG5#r zVJ(yc3JmIi$&rTGo|KDe+;!irn&r}$i`r8!yKXQ`E~zt1z*w0D??+G4&9NIA8#_LS zjGJe3!W`wZJ&^4|^Nw4rkZkak!1lBE@?l+ka(*Ec@V%JXN_k9-GU0Ulz*xxpCsued zVMUrEgSH4iUB;aqDikaRD1RuthNk$|pJ2?lyYP25gO7OD(&@tQHV5%s`pq%V?wP{1 zOPgjiq(=%3gla#P1Vs7>^QKhtv@~=msmR|Ouai2Hdm2Q>3Pu~ut7B&5NbS0e%?Geq zk7@Z>(`L9ve*pB|bqeTE!*57vwMMx*K%4yo_g0dYNcQGARTft@>eaRX5bMiBIIi=lx>K1o)YP?g&6A#Dj4fQ+aGNH#gvHFLkqP0$=aUC~wMa;%ix zWltT1iNAv&5cP=?9Z{f5+6FQ7_%7syN)XC^gPQzg8FRmE8hzlYABjcrX~wI=k$mkb zp$UlL4*1n+K}daA5)$fmidNHy(&TQZ%unKBgoGeZ!R$ZO501%kkigduazC7`LfojJ z40qVjSNZ*Uf<;U;E`hB}2oLsp3Hat3h?)g8{P|wJlsL|;kSjJJKiKzxVO~J5ecI)H zsoy^0QJ|(K@mB4+sQ&^lSJN97$$KVN#CrWJb20ZH8#lD27V_kXVJpokftbu$c1aww zo3XqXM@Hdmc~r4*XtU$T>Ye8o4B<4`jG=&rp-)DJp{6h8l4zpuaGW8l{ zg7M}Z-Q0t0iyt2DPu`d{10*M~+?ZGPO=3561bB7?ZJcGQ;vLX3p;G=$o_SmkE|1r7 zNG0N_r#A0uufl{isc8ZP7u;wenjxWw=>e_}#xr|9?Yr!m;fhbtnehee@yAVaMJ%`! z!IZ9iT2eLFIpdBkrE@7@7=SP(kFOXTh{pG{l2j(f$yGyBvt>pI4;Gy1$0T1qJ9s(eH;v@VFCi8Bx!-5x%kD%e=BUr#M zZ*3AZ={jluR}XFsqvdIapkGv>p&8K75e7cUm-|Q~QNu8}n|~kZUZ=tSp*L9LZ6_`) zG++i7WYE6W%SsP-(jS}F&VoFHOO-MFuj@h!71KhpC!qH|=$6w6E`$qD6HdVaH6F%a zfnw!|5Bw3nd`N-!`y_w~FZYYdNS5$A`#$r1h-$rK2F!TaF)Qc%pxyoVSklgJZy@L9 zCdV{yRl;8kQ744g`V*_lhIPn?zI(WmrX*kkYBd&ipWcm}@wVbQ!F>Wa7-nGP->@~S z3=uF(t3xGQ%X#m1K?2>L`65Ljgj?vlIgZvp0oCT}t-aM)AK4*wY=ZF5jgbl^K&qD* zAm5PD^jBBkF+eKAreq}nQ4Ex&gGqxA;i&imcK5Ez4S?JCn~;2!o83n==@+?&5Fjo) z6`>o#w#xm>Kfb6Sm5IdP?Xz{ccIsPbPwYJn^-P%AR-;|Xq$lh^YZr(Tpm zrMTq1x(w|0Te$k8@`oD^g^Qn+*_=v`Y`>z#Kff|s04XfAZJJ{+C7eC-^mfqt98@dI ztvk=W)8%`S8sx8>ZE{-hilfE?#hnRw@A3r+^R>E@6XMEcr4sF|c%a;gyjIivU=W8# zDIXg8V%cgJo2#Z{AMG$u&W8j%!O^teY5^-0J`{2lB7-(~z4RWAya#^^v1CJ|ebdc= ztI#hfv^Woz+>M?1vk}Yt%I#(=u0XQXZUv@gJ=rUr>J)!hMJQav*Bq>ZZ>&H3@N`>0 ze!AGAj?rnfxGfdqe_fvoB}W$(>Z6LTstm0=FDWGBhrA?Gh58CWhQ!d6?R_@#v6|3o za<&;U^trWYrX+b6;|(maE1qJccm_F>;lD0A_7-L>MS(6{Cz&855;a_@cW4S~#ynQo zF~aX2G(-7-eX8;qh$e!>T{mQ*6{vEf79D}rT@u48i~MIA5&_>GLX0nZ`U=F^)OVG5 zwAzvclkekb%Fn}Hoz%U&T}Gmg)LS)kGq?*AR}VpQmd~Wj_m+7UdNF_Jd0Fy>9eK}@ zYka%@$U&GF2J^V{Syugyz|HxqBi95;L)6iBkHsspI(}{~&9!ICATIYKW^5OBW(|SS z@o%snKYeoLlQhOXvo2_Fl&V1pF`s#+r>kkfF97=7Z$a_Cv9bHWYLfW#DR`?VrPsC5 zX-tKD$g7wXn?Jw4cQ8d;LlnQ7P~lYuIfsfdBpWRo7esU_ORJX_#Fs(KBRV@=0<X2V^_7`MY42tgYr0lqkkHFZPaJkK8Dob@Rbpv76z zsy0=!vpYU(!8=%Cw=QmgHQo%Y@mzAX10BzW^%ebCGZ0iwBZo!S=}#a1Ry@WdQmqJ_ z=C4;jJFZQ_Ee2OqDadx~H|T)ELe){Jg*~ECG4x^v+%#pK3)|PAkyF@wNQ=Yvdpc&2 zeJGH4y+ERHIi%n}d%bGDNt5%l;x+G|A2NHn$5G5uytCguTDpOgd)(Xiuz@CUyvQ?j zyywQbUUUik7hj$8RCCrF{t7qhFRSIx9Lo~xb*n{UM{cy19hTMM^BRHH+t-W-IG2qi zX>kH`Ev*VXzVglOnZtk~-*z5#^SG0HW_>l*9sPj?J*PJ#+CiNL@%4D4#aIr9Ty&+g z1CT_+z0B$#(O)QWhaVB7{yHFBy!x#0Ia`?*sm;Rl?Jgm&st;qs&22f-PKZFiV}t&& zF%qKU0@P$>|HO2V=WXJyA2^xD24xm7Nr`WP)Yi(E`Hy3ECyK;8aLNgVEuozi z{jNBg)_DZ$x{>4aFYS*X`^=Rsr`VlmUx@1^@v@zqx#a0VBN1tTPsFieGJSSU^}377 z6nGP&y=|ToroHlBF(C#lMkD}E;FS&M;{kYNUoV*QKss#owV~C8ZSk-0hva$*Z06*?)b7st_ zJ;zpC#6Y@;KC>+1ZNRzB{F+Jps&he2PT<+K`n})RPo|cYBJO?Eyn2Uy|J9~3ecLF! z&zy(b3a1Bko(yM*X)5(<_2h_!^*+mmwfEN#5>46O@1!TZoN<*{?Iu0xp+;?pjsatz z70SniH5`d5=|z{ssgY2t%m zqB*)3If4jiZo}_mOUY|AcQw9h!>glk{Bzqa0~{(m-d*m#P;8$R9gLPfQXPP+BJc6- z^Irs5Pdi0GP7f?aLz&%Tc;G=ZoM#rb9PTcJcQp3_u`DepR;*2j$2E>Vz6;w(vZS^| z^K}h{j!cLr4qPmm*q@wnBee!Hit`@a?w=S5(iIg`oTIkB zQ%j7qGNw;kym_?oH$;=`HL&WL0lS2SQ?#6PR>W)P$LqHC4;jXp>bCETeQ({rZmH>{ z$>dyw*gpCcmdy9%+m=`ZV!@Ko<~a;rZtmVQewmwCj98G*V{T&TGb#qhxPRcT^gnQy zIiw5iTk#2kTdSam=+G&@p|43v0j*3}vx+eWh;7LPxMlCe^OEB}^IBWIU^IM3vU5gU zY<^s5E;_%tDZiUqLoV*HW>)QaMBjRTE3ZPHQsbW6(i`$pyZP4})3phN$f~NU+2Xpu zP*8S4CF$@-)y|H~-X{Mn5W<{<_AiUn6{YSfw=t>!V6iT0qh2eq2(XA(ZesgxeJRv_ ze7@K_^QNLFEz)2LPsA>R+m>5=?87tSz&%HK0T|zG7ziY0LIe@LMst%0LI8W(AvJ3O z(dG-!#IU+}(V<4GFIUYALo~R=cOC)drO%a!Vv)|T)$hhd0@60(8{&~b5OvfSb>8T8 z>Q(vix2Z$y-0)zWLTM700EL_P{VM~2`8fMk0Q_T$n%}xb@9qNI*@6(Y2|>~%x^O5M z{+x9EKBKnaz zZ`RaXnf$?G$k4^=a1!*4$*E7fl+;^#d__KBS*JlwxM_={2}bRvyU(|!T+1g&`51?mDZ5=5<4J3;=d&`Oo@> zpnG8-9LTKud0}>yl#~6lW5rg$2hPIv;@bcVVc-5wYjj&LE-B{%n$lRBd6YLa3@wUR z`7lFj_|sHoM}S*}cACXLxs}MDnG_rMoTgN3Jym3Gys~We!y_q^{AwA8C`h^W!!&$( znpJBeF7NV z7N3doy9un|alJ)Xm(-tRTSozp?Av;LZ;<6kkNKtl#XLC7VJX5jWTM@i$?c2TPAmVK zKbXlEnA-2ku^l;h2AKPy^o;wndOkE%khj^AsxQuLzTU?uB)4N2;f0J*%x%)1aq!P~wwU(B@TX)NzgxABQ=jv+U3()o7 z3lLxgBkj9?A2{Co%MYpl7W3{k+zArvWUg)KaMUyAumX<{zUG1$WzS8bDfJt<7dSBQ1VJp2!c(_Z!J zXSgr-WSuk}W8$b$CoO4mF05kvnJbYb)y=anxtb*dTpd4@tpNkG?|mRLW1s25wf z4bo$3*NdGkc9RYwN;_x0lN;oVpFMXU?L|f9T_l&?i7QpIQ4-R08YK}Ydk*nQ@)5rPIB z`Pna1k)F0kbYfhNe8ztsyQ+Mxd+V27kR?ZTdF+GvwPPb__)_y8{SP1SypNKUgHp2Z zP*p`gLr`sXf=7f!BbLXN&c8yAFJZ#;rMSz`dxExe3oQS@d#jz}w-Pl4d+XJ%qOz5+ z(Y~n>ePcpHv=f40v?GE(f25+A8k^j-c{IAR5%;Vm0Zv$aegWb+K05AyANWU$%zTh) zsSU+6VXdrN*)-fs9=QXwUpx7*?h6Fq%Ls6lf~0Tx5A^jNczok&%+o=sGN)}Y2eeFM ztky%UxYm~uaqOyUA{UccY=f7T6n9&3bAGfh_xm&S#$wJTUeNOOD!>22N3OQWS>CBE zzmglR6li(j(v?IYzkt&E5#wALv&dw)&5F3xs5JVieD)ynkNmTyzfaG4q+hfwcnHkq zi%n_Ak-^da>n~c@&aaNh0ENXW^y!R%CUhr?1!xj64-HdH{Y*!9rAhIIrfD}h`KfrW z0pkV!nD?tPl2dE$IdE!Zgud~fmx@Q$^sB~oH2Nd2S;sbX8BViN#pBJb1&_pK2M6ZA z$#A*oJia4%|KWWkHyfbTy?Z{N1bI?utrbK=2bg1?eH5n7rNEO16p|1~YubOsJPG+k zAw%`ei1zeIu~g@kGADM}#4;!cKYE-H*`D`>Ov*T9e$4UNI?_jud{F9YA>L1ofti{L zU$Gsb`a{zBNv))5nXRnlqq3>GM$@{} zjH=vwUWS*4!xVT3so_>rF^0J(5o&3E%MZ2c#U1NXFl7Rnxg^1Zt+@QPf7D$6^>zgi zq6Z|v4e5tos{-upAR8mguz-igD+*kzK5kOrra|ziV1a-wM=U2DB=@oc_fW-0F6OgX zN%K~~pX#%LeYdl*{>XMakZNMS=}(_=M&0_j$Vy`}Nb%sS%imfC&{RpilShpr8O+yL z3s8g6x1bA6r&%Am|A8nZ0TzQ_?xI(-XlSY^3MrBPFqulqt`V@LITqe&U)s|VZH{h> z*-3xg82VJKICoR%>4eQvUBZSkg|-N&H+mFiwopNCqY91pkvPa={7qIz4ZL)p)o0w~ z={PcSUjSg(XX7@=de#o&`<8r~Z{XcB(`~Q+)^yaRh%~m0%s;rW(qbPAOJzWk2C*`o zNAvj5Xf0WV%`6J;b2*&%evU9el(cQe*JN(YKukkZbt3x^c4ic!=S;_?RI+B@h zbAdm&BK}U}Q>G-wzFU+&Q%A=BOIM_!zysr;;#HxP-;U2*HAUb1T-1r9<(x-zT20E2 zrMvhyChM5uloXi${HcCU)kE1Iqtg6^l9G#LH;lloPe6YW|@!%_{amJ~Z)x z$^(_Vj7Mq6Q&I>V2m7+d1R#5VLhAnpLJco|>_h>-l#$=n0Tz>Tq5K$_hRW9m&A-0O z?-Zc^v}ZnZnBUvaw?)nfcsi7W|Cxh+PDp@!<=m#%b(<8OA2%+~mN7fc;c;m>@k*OxKs zH5(JY6Dd*7`&4`x2sMLSs{NjOx%f8aiue*oG603I#(VBukK}6gvS%VW3aSO1?cyhv8LF9@c7CMM=lf=rJn7&ww<6 z?KuKT0u6H|mms%B8GKP2R4Iv z2?#1?wBHutTE1R71$MY~z?d@Koa*~#mJp*(sdHCLECmG1Xv7Oz`^^PHhKnA~)qvr? z@3(_c|GMaB4%Snlcg1ZbK7sBZ6yS@mSu{P{d;Y`6tI5`wP;*@1gU!KE&m0!yT2ho0 z?omg|pET?p^d2p0!7gnE*mk(?@@c03caRwNSv~-FgYmTv)YnFd)NnHtApQVuu@PuPwtvP+jGH{?^Kj3QAn($D8w5RADh^5(u*{o7BLXBsDae z_cf2o?>)GNsQI($<Tz5DWupbP3ppb<8RIIA*G>czk9YaiZeT4%WMii{@#6HtPFff zx4t0tjPsl_92j#yn2OXiLUd=Oks|ioOB_rqG8sj-&&|Yb5uSSc2(~o2Q}%DBw ziOsb04*xTR*=L29#Fbb3eS{94!04$XhrSUZ)orE)cPdBUIsZtPZxk7q?@fe|!9Jur zxzBQywwDn7&{_M=Zef>hd^bufR^zM2tsH&;z_xhOKw$S;sA(V@ipMv2e7D0o^wCBqGvc2YCwjHsvabBy&_6U8IlS z&}%d;zc`a>^j=Q|&scG;x7_7Nr5ATrPp)%1#hnesf0y=l%%Rh$_3R)y@>c@-lGg5* z?OcsyycQpATzg-EQkc3zIFm_n%YB`P)>a;Dx?N;M7oWB`VJLydwPFnKkL9#e6AtzkFr&VU&SgYD{+-7M5fTzm2ZFJ(xg6Y+ ze96bB&y1+xM@+h~34MV*hYS~2(g&bd@fJ)6f;W?YvjhW+B~ zI3jNyrwgqQ`&|4?C|Mig0;=X|B}K+6$!%FoC zbo`xsg28?~$HTjR7k^u{>yGJ~^HkFl*p=r(gJ1@c7Sg*!&3yLvRp7M4p@n00?~wKg z9Lxi9aK$JnMLiN)setZYBYelLhyh3Ze8Au+fGrtQv1z1fQYPwux6FFFr3_9qv{xU3 zwRuWCzFmTygM;t(f3e8hHPr#p z{B$x-Ya$d}UUU=|Y6JIAdl&XjmhED8_SOzp^c}{@YF=N|IuQ{RN>hUt3hM}H^F=H8 zr48r#_`3EJB*=6{EqwWp*&Ivwm<-?94_=~GQ4aHcqNqJVRLM&8^OT6>ITcL@ha1h8 z2mJ^`dLNrSp_diF-upj4F$f;ORxUIV0(S1#M_pRCF8)+IEKMy_c}T!&|SA3PtN1Ah^kO_e!+% z$#N$Egl)>(wBnZAo@24Fu1f32jJCUJ)WYnq`*15*92B^7R+waib}MzL6tA z-6*6~9~gIi2la@YVZb(i{5C_We+8?f8AtT#X;=~|-&=XbfxFrHf{#extzAEWu^RMy z-s-@+S^&>Gv@TBmV3LE3pz)z3L#A?l5#vSeT-2?hm+mhbcvw*zWZBcfs}_{ zUvvaYZT7vpQA;yp9k>f%eW=FN=&-KD&r*F=0e7mE9c;Fqm?M>8sR3i;J9fAcj=E{u>cIur z;B?rI8Cbz+as0M}3AFsZVHWjfm0=)r2?h)=?=CI5_|7acS#PY+b}W)>Ie5s}v}zr& z$&k2~pkVS<&Yq8#s=F30{bmBve1EZ2A59$F?8INqz6~f0`@b7R2;H0jBnCqnDy-Wm zOe-n>mRmE+IZqzx64^$wAOgPYGv8$1=fo2e4n{HaJ==j?HU8PfyX2eadHl7suIwbk zk>?@mjQa;HWV!0KlO`I?XpD&d*rpwXstW5s3Sq1t-MR7dX~!NMxK!zAT8dlvlBgZy z+XF}ICX?-!%uN$t05k>fr|X2|sp8*{hRiteO9Grb@_`&=@ObJ+Vhu#W`M^6ZVB#06 zdSY=qE=P~In>Y4pbGO&WzE|iXwNWYm)0isUeojN@{Zo_NXROYXDmqSVa&?m8itkX~ zqd9M=-mzja&oX36QC!*na}w-hm>hz>FfdmJ?@7DK@$pwSncCn#hO!`!Gyj<_;loqY zvjJ@oGu7~glJHR@PGBlD7Ec9d^d2|$TLE~JYDD40xyNCYI%IO|zm|rU|6fZ}CU`3m zxV0>w%!f9yM8g4JwADMfA^sLF)&&yo;y2rrv=LM~Go5PD1L8 z+C01MJQ=i@#hv@CaMDtvNiV0KmZ>}a?c+wgasA1_^@H8VVeBu%HY1agpv|%558x