From ff68228a6ff1f5a297ac204487f1112ff5c9f667 Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 13 May 2020 00:48:09 +0200 Subject: [PATCH] rendersky header --- src/engine/engine.hh | 8 -------- src/engine/main.cc | 1 + src/engine/octarender.cc | 1 + src/engine/rendergl.cc | 1 + src/engine/renderlights.cc | 1 + src/engine/rendersky.cc | 36 ++++++++++++++++++------------------ src/engine/rendersky.hh | 11 +++++++++++ src/engine/renderva.cc | 4 ++-- src/engine/texture.cc | 1 + 9 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 src/engine/rendersky.hh diff --git a/src/engine/engine.hh b/src/engine/engine.hh index 0678d4c..e5b7886 100644 --- a/src/engine/engine.hh +++ b/src/engine/engine.hh @@ -331,14 +331,6 @@ extern bool renderstains(int sbuf, bool gbuf, int layer = 0); extern void cleanupstains(); extern void genstainmmtri(stainrenderer *s, const vec v[3]); -// rendersky -extern int skytexture, skyshadow, explicitsky; - -extern void drawskybox(bool clear = false); -extern bool hasskybox(); -extern bool limitsky(); -extern void cleanupsky(); - #endif #endif diff --git a/src/engine/main.cc b/src/engine/main.cc index a2eabae..d20a3d5 100644 --- a/src/engine/main.cc +++ b/src/engine/main.cc @@ -3,6 +3,7 @@ #include "blend.hh" #include "movie.hh" #include "rendergl.hh" +#include "rendersky.hh" #include "rendertext.hh" #include "renderva.hh" #include "shader.hh" diff --git a/src/engine/octarender.cc b/src/engine/octarender.cc index 4050bfa..85da46d 100644 --- a/src/engine/octarender.cc +++ b/src/engine/octarender.cc @@ -4,6 +4,7 @@ #include "grass.hh" #include "material.hh" #include "rendergl.hh" +#include "rendersky.hh" #include "renderva.hh" #include "texture.hh" #include "world.hh" diff --git a/src/engine/rendergl.cc b/src/engine/rendergl.cc index b477cc9..c7c64e4 100644 --- a/src/engine/rendergl.cc +++ b/src/engine/rendergl.cc @@ -5,6 +5,7 @@ #include "grass.hh" #include "material.hh" #include "rendergl.hh" +#include "rendersky.hh" #include "rendertext.hh" #include "renderva.hh" #include "texture.hh" diff --git a/src/engine/renderlights.cc b/src/engine/renderlights.cc index eca8196..a531b83 100644 --- a/src/engine/renderlights.cc +++ b/src/engine/renderlights.cc @@ -3,6 +3,7 @@ #include "aa.hh" #include "material.hh" #include "rendergl.hh" +#include "rendersky.hh" #include "renderva.hh" #include "texture.hh" #include "world.hh" diff --git a/src/engine/rendersky.cc b/src/engine/rendersky.cc index 35d1021..3dfd171 100644 --- a/src/engine/rendersky.cc +++ b/src/engine/rendersky.cc @@ -4,9 +4,9 @@ #include "engine.hh" -Texture *sky[6] = { 0, 0, 0, 0, 0, 0 }, *clouds[6] = { 0, 0, 0, 0, 0, 0 }; +static Texture *sky[6] = { 0, 0, 0, 0, 0, 0 }, *clouds[6] = { 0, 0, 0, 0, 0, 0 }; -void loadsky(const char *basename, Texture *texs[6]) +static void loadsky(const char *basename, Texture *texs[6]) { const char *wildcard = strchr(basename, '*'); loopi(6) @@ -34,9 +34,9 @@ void loadsky(const char *basename, Texture *texs[6]) } } -Texture *cloudoverlay = NULL; +static Texture *cloudoverlay = NULL; -Texture *loadskyoverlay(const char *basename) +static Texture *loadskyoverlay(const char *basename) { const char *ext = strrchr(basename, '.'); string name; @@ -83,7 +83,7 @@ FVARR(cloudalpha, 0, 1, 1); VARR(cloudsubdiv, 4, 16, 64); CVARR(cloudcolour, 0xFFFFFF); -void drawenvboxface(float s0, float t0, int x0, int y0, int z0, +static void drawenvboxface(float s0, float t0, int x0, int y0, int z0, float s1, float t1, int x1, int y1, int z1, float s2, float t2, int x2, int y2, int z2, float s3, float t3, int x3, int y3, int z3, @@ -98,7 +98,7 @@ void drawenvboxface(float s0, float t0, int x0, int y0, int z0, xtraverts += gle::end(); } -void drawenvbox(Texture **sky = NULL, float z1clip = 0.0f, float z2clip = 1.0f, int faces = 0x3F) +static void drawenvbox(Texture **sky = NULL, float z1clip = 0.0f, float z2clip = 1.0f, int faces = 0x3F) { if(z1clip >= z2clip) return; @@ -145,7 +145,7 @@ void drawenvbox(Texture **sky = NULL, float z1clip = 0.0f, float z2clip = 1.0f, 0.0f, 1.0f, w, -w, w, sky[5]); } -void drawenvoverlay(Texture *overlay = NULL, float tx = 0, float ty = 0) +static void drawenvoverlay(Texture *overlay = NULL, float tx = 0, float ty = 0) { int w = farplane/2; float z = w*cloudheight, tsz = 0.5f*(1-cloudfade)/cloudscale, psz = w*(1-cloudfade); @@ -192,7 +192,7 @@ VARR(fogdomeclouds, 0, 1, 1); namespace fogdome { - struct vert + static struct vert { vec pos; bvec4 color; @@ -206,15 +206,15 @@ namespace fogdome if(v0.pos.z != v1.pos.z) color.a += uchar((v1.color.a - v0.color.a) * (pos.z - v0.pos.z) / (v1.pos.z - v0.pos.z)); } } *verts = NULL; - GLushort *indices = NULL; - int numverts = 0, numindices = 0, capindices = 0; - GLuint vbuf = 0, ebuf = 0; - bvec lastcolor(0, 0, 0); - float lastminalpha = 0, lastmaxalpha = 0, lastcapsize = -1, lastclipz = 1; + static GLushort *indices = NULL; + static int numverts = 0, numindices = 0, capindices = 0; + static GLuint vbuf = 0, ebuf = 0; + static bvec lastcolor(0, 0, 0); + static float lastminalpha = 0, lastmaxalpha = 0, lastcapsize = -1, lastclipz = 1; - void subdivide(int depth, int face); + static void subdivide(int depth, int face); - void genface(int depth, int i1, int i2, int i3) + static void genface(int depth, int i1, int i2, int i3) { int face = numindices; numindices += 3; indices[face] = i3; @@ -223,7 +223,7 @@ namespace fogdome subdivide(depth, face); } - void subdivide(int depth, int face) + static void subdivide(int depth, int face) { if(depth-- <= 0) return; int idx[6]; @@ -308,14 +308,14 @@ namespace fogdome DELETEA(indices); } - void cleanup() + static void cleanup() { numverts = numindices = 0; if(vbuf) { glDeleteBuffers_(1, &vbuf); vbuf = 0; } if(ebuf) { glDeleteBuffers_(1, &ebuf); ebuf = 0; } } - void draw() + static void draw() { float capsize = fogdomecap && fogdomeheight < 1 ? (1 + fogdomeheight) / (1 - fogdomeheight) : -1; bvec color = !fogdomecolour.iszero() ? fogdomecolour : fogcolour; diff --git a/src/engine/rendersky.hh b/src/engine/rendersky.hh new file mode 100644 index 0000000..6ad1b20 --- /dev/null +++ b/src/engine/rendersky.hh @@ -0,0 +1,11 @@ +#ifndef ENGINE_RENDERSKY_HH +#define ENGINE_RENDERSKY_HH + +extern int skyshadow, explicitsky; + +void cleanupsky(); +bool limitsky(); +void drawskybox(bool clear = false); +bool hasskybox(); + +#endif diff --git a/src/engine/renderva.cc b/src/engine/renderva.cc index f292e64..58216fc 100644 --- a/src/engine/renderva.cc +++ b/src/engine/renderva.cc @@ -1,10 +1,10 @@ // renderva.cpp: handles the occlusion and rendering of vertex arrays -#include "rendergl.hh" #include "renderva.hh" - #include "blend.hh" #include "grass.hh" +#include "rendergl.hh" +#include "rendersky.hh" #include "texture.hh" #include "engine.hh" diff --git a/src/engine/texture.cc b/src/engine/texture.cc index 272e9bd..87e5a9c 100644 --- a/src/engine/texture.cc +++ b/src/engine/texture.cc @@ -2,6 +2,7 @@ #include "material.hh" #include "rendergl.hh" +#include "rendersky.hh" #include "shader.hh" #include "texture.hh"