From a3cd090fb8c9441f81bccc170fa4e2edd49ba9d3 Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 11 May 2020 22:50:44 +0200 Subject: [PATCH] add rendergl.hh --- src/engine/aa.cc | 1 + src/engine/blend.cc | 1 + src/engine/command.cc | 1 - src/engine/engine.hh | 78 +------------ src/engine/main.cc | 1 + src/engine/material.cc | 1 + src/engine/movie.cc | 1 + src/engine/octaedit.cc | 1 + src/engine/octarender.cc | 1 + src/engine/rendergl.cc | 203 +++++----------------------------- src/engine/rendergl.hh | 79 +++++++++++++ src/engine/renderlights.cc | 1 + src/engine/rendermodel.cc | 1 + src/engine/renderparticles.cc | 1 + src/engine/rendersky.cc | 1 + src/engine/renderva.cc | 1 + src/engine/shader.cc | 1 + src/engine/stain.cc | 1 + src/engine/texture.cc | 1 + src/engine/water.cc | 1 + src/engine/world.cc | 1 + src/game/game.cc | 10 -- src/shared/glemu.cc | 3 +- src/shared/igame.hh | 2 - 24 files changed, 127 insertions(+), 266 deletions(-) create mode 100644 src/engine/rendergl.hh diff --git a/src/engine/aa.cc b/src/engine/aa.cc index be7a507..27099be 100644 --- a/src/engine/aa.cc +++ b/src/engine/aa.cc @@ -1,4 +1,5 @@ #include "aa.hh" +#include "rendergl.hh" #include "texture.hh" #include "engine.hh" diff --git a/src/engine/blend.cc b/src/engine/blend.cc index 424fe6d..aed20dd 100644 --- a/src/engine/blend.cc +++ b/src/engine/blend.cc @@ -1,4 +1,5 @@ #include "blend.hh" +#include "rendergl.hh" /* has* */ #include "renderva.hh" #include "texture.hh" diff --git a/src/engine/command.cc b/src/engine/command.cc index 62f01ac..749f6db 100644 --- a/src/engine/command.cc +++ b/src/engine/command.cc @@ -3113,7 +3113,6 @@ void writecfg(const char *name) f->printf("// automatically written on exit, DO NOT MODIFY\n// delete this file to have %s overwrite these settings\n// modify settings in game, or put settings in %s to override anything\n\n", game::defaultconfig(), game::autoexec()); game::writeclientinfo(f); f->printf("\n"); - writecrosshairs(f); vector ids; enumerate(idents, ident, id, ids.add(&id)); ids.sortname(); diff --git a/src/engine/engine.hh b/src/engine/engine.hh index 244a2dc..21d3184 100644 --- a/src/engine/engine.hh +++ b/src/engine/engine.hh @@ -26,7 +26,7 @@ extern const uchar faceedgesidx[6][4]; extern bool inbetweenframes, renderedframe; extern SDL_Window *screen; -extern int screenw, screenh, renderw, renderh, hudw, hudh; +extern int screenw, screenh; // texture struct cubemapside; @@ -50,85 +50,14 @@ static inline bool pvsoccluded(const ivec &bborigin, int size) return pvsoccluded(bborigin, ivec(bborigin).add(size)); } -// rendergl -extern bool hasVAO, hasTR, hasTSW, hasPBO, hasFBO, hasAFBO, hasDS, hasTF, hasCBF, hasS3TC, hasFXT1, hasLATC, hasRGTC, hasAF, hasFBB, hasFBMS, hasTMS, hasMSS, hasFBMSBS, hasUBO, hasMBR, hasDB2, hasDBB, hasTG, hasTQ, hasPF, hasTRG, hasTI, hasHFV, hasHFP, hasDBT, hasDC, hasDBGO, hasEGPU4, hasGPU4, hasGPU5, hasBFE, hasEAL, hasCR, hasOQ2, hasES3, hasCB, hasCI; -extern int glversion, glslversion, glcompat; -extern int maxdrawbufs, maxdualdrawbufs; - -enum { DRAWTEX_NONE = 0, DRAWTEX_ENVMAP, DRAWTEX_MINIMAP, DRAWTEX_MODELPREVIEW }; - -extern int vieww, viewh; -extern int fov; -extern float curfov, fovy, aspect, forceaspect; -extern float nearplane; -extern int farplane; -extern bool hdrfloat; -extern float ldrscale, ldrscaleb; -extern int drawtex; -extern const matrix4 viewmatrix, invviewmatrix; -extern matrix4 cammatrix, projmatrix, camprojmatrix, invcammatrix, invcamprojmatrix, invprojmatrix; -extern int fog; -extern bvec fogcolour; -extern vec curfogcolor; -extern int wireframe; - -extern int glerr; -extern void glerror(const char *file, int line, GLenum error); - -#define GLERROR do { if(glerr) { GLenum error = glGetError(); if(error != GL_NO_ERROR) glerror(__FILE__, __LINE__, error); } } while(0) - -extern void gl_checkextensions(); -extern void gl_init(); -extern void gl_resize(); -extern void gl_drawview(); -extern void gl_drawmainmenu(); -extern void gl_drawhud(); -extern void gl_setupframe(bool force = false); -extern void gl_drawframe(); -extern void cleanupgl(); -extern void drawminimap(); -extern void enablepolygonoffset(GLenum type); -extern void disablepolygonoffset(GLenum type); -extern bool calcspherescissor(const vec ¢er, float size, float &sx1, float &sy1, float &sx2, float &sy2, float &sz1, float &sz2); -extern bool calcbbscissor(const ivec &bbmin, const ivec &bbmax, float &sx1, float &sy1, float &sx2, float &sy2); -extern bool calcspotscissor(const vec &origin, float radius, const vec &dir, int spot, const vec &spotx, const vec &spoty, float &sx1, float &sy1, float &sx2, float &sy2, float &sz1, float &sz2); -extern void screenquad(); -extern void screenquad(float sw, float sh); -extern void screenquadflipped(float sw, float sh); -extern void screenquad(float sw, float sh, float sw2, float sh2); -extern void screenquadoffset(float x, float y, float w, float h); -extern void screenquadoffset(float x, float y, float w, float h, float x2, float y2, float w2, float h2); -extern void hudquad(float x, float y, float w, float h, float tx = 0, float ty = 0, float tw = 1, float th = 1); -extern void debugquad(float x, float y, float w, float h, float tx = 0, float ty = 0, float tw = 1, float th = 1); -extern void recomputecamera(); -extern float calcfrustumboundsphere(float nearplane, float farplane, const vec &pos, const vec &view, vec ¢er); -extern void setfogcolor(const vec &v); -extern void zerofogcolor(); -extern void resetfogcolor(); -extern float calcfogdensity(float dist); -extern float calcfogcull(); -extern void writecrosshairs(stream *f); -extern void renderavatar(); - -namespace modelpreview -{ - extern void start(int x, int y, int w, int h, bool background = true, bool scissor = false); - extern void end(); -} - -struct timer; -extern timer *begintimer(const char *name, bool gpu = true); -extern void endtimer(timer *t); - -// renderextras -extern void render3dbox(vec &o, float tofloor, float toceil, float xradius, float yradius = 0); - // renderlights #include "renderlights.hh" extern int lighttilealignw, lighttilealignh, lighttilevieww, lighttileviewh, lighttilew, lighttileh; +extern int vieww, viewh; /* rendergl */ + template static inline void calctilebounds(float sx1, float sy1, float sx2, float sy2, T &bx1, T &by1, T &bx2, T &by2) { @@ -336,7 +265,6 @@ enum { TI_CONSOLE = 1<<0, TI_GUI = 1<<1 }; extern void textinput(bool on, int mask = ~0); // physics -extern void modifyorient(float yaw, float pitch); extern void mousemove(int dx, int dy); extern bool overlapsdynent(const vec &o, float radius); extern void rotatebb(vec ¢er, vec &radius, int yaw, int pitch, int roll = 0); diff --git a/src/engine/main.cc b/src/engine/main.cc index 2a37110..9b3ec64 100644 --- a/src/engine/main.cc +++ b/src/engine/main.cc @@ -1,6 +1,7 @@ // main.cpp: initialisation & main loop #include "blend.hh" +#include "rendergl.hh" #include "rendertext.hh" #include "renderva.hh" #include "shader.hh" diff --git a/src/engine/material.cc b/src/engine/material.cc index 4e98df6..ebc96de 100644 --- a/src/engine/material.cc +++ b/src/engine/material.cc @@ -1,4 +1,5 @@ #include "material.hh" +#include "rendergl.hh" #include "renderva.hh" #include "texture.hh" #include "water.hh" diff --git a/src/engine/movie.cc b/src/engine/movie.cc index aa1ebc7..5650710 100644 --- a/src/engine/movie.cc +++ b/src/engine/movie.cc @@ -7,6 +7,7 @@ // avidemux - ok - 3Apr09-RockKeyman:had to swap UV channels as it showed up blue // kino - ok +#include "rendergl.hh" #include "rendertext.hh" #include "texture.hh" diff --git a/src/engine/octaedit.cc b/src/engine/octaedit.cc index 0856ede..3369287 100644 --- a/src/engine/octaedit.cc +++ b/src/engine/octaedit.cc @@ -1,6 +1,7 @@ #include "blend.hh" #include "material.hh" #include "octa.hh" +#include "rendergl.hh" #include "renderva.hh" #include "texture.hh" #include "world.hh" diff --git a/src/engine/octarender.cc b/src/engine/octarender.cc index bb9a59e..ff4ec9b 100644 --- a/src/engine/octarender.cc +++ b/src/engine/octarender.cc @@ -2,6 +2,7 @@ #include "blend.hh" #include "material.hh" +#include "rendergl.hh" #include "renderva.hh" #include "texture.hh" #include "world.hh" diff --git a/src/engine/rendergl.cc b/src/engine/rendergl.cc index 4db620f..135b3f2 100644 --- a/src/engine/rendergl.cc +++ b/src/engine/rendergl.cc @@ -3,6 +3,7 @@ #include "aa.hh" #include "blend.hh" #include "material.hh" +#include "rendergl.hh" #include "rendertext.hh" #include "renderva.hh" #include "texture.hh" @@ -253,7 +254,7 @@ PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glBindFragDataLocationIndexed_ = NULL; // GL_ARB_copy_image PFNGLCOPYIMAGESUBDATAPROC glCopyImageSubData_ = NULL; -void *getprocaddress(const char *name) +static inline void *getprocaddress(const char *name) { return SDL_GL_GetProcAddress(name); } @@ -314,7 +315,7 @@ VAR(dbgexts, 0, 0, 1); hashset glexts; -void parseglexts() +static void parseglexts() { if(glversion >= 300) { @@ -340,12 +341,12 @@ void parseglexts() } } -bool hasext(const char *ext) +static inline bool hasext(const char *ext) { return glexts.access(ext)!=NULL; } -bool checkdepthtexstencilrb() +static bool checkdepthtexstencilrb() { int w = 256, h = 256; GLuint fbo = 0; @@ -1084,7 +1085,7 @@ static int timercycle = 0; extern int usetimers; -timer *findtimer(const char *name, bool gpu) +static timer *findtimer(const char *name, bool gpu) { loopv(timers) if(!strcmp(timers[i].name, name) && timers[i].gpu == gpu) { @@ -1130,7 +1131,7 @@ void endtimer(timer *t) else t->result = max(float(getclockmillis() - t->starttime), 0.0f); } -void synctimers() +static void synctimers() { timercycle = (timercycle + 1) % timer::MAXQUERY; @@ -1151,7 +1152,7 @@ void synctimers() } } -void cleanuptimers() +static void cleanuptimers() { loopv(timers) { @@ -1164,9 +1165,9 @@ void cleanuptimers() VARFN(timer, usetimers, 0, 0, 1, cleanuptimers()); VAR(frametimer, 0, 0, 1); -int framemillis = 0; // frame time (ie does not take into account the swap) +static int framemillis = 0; // frame time (ie does not take into account the swap) -void printtimers(int conw, int conh) +static void printtimers(int conw, int conh) { if(!frametimer && !usetimers) return; @@ -1238,7 +1239,7 @@ ICOMMAND(getcampos, "", (), vec worldpos, camdir, camright, camup; -void setcammatrix() +static void setcammatrix() { // move from RH to Z-up LH quake style worldspace cammatrix = viewmatrix; @@ -1258,7 +1259,7 @@ void setcammatrix() } } -void setcamprojmatrix(bool init = true, bool flush = false) +static void setcamprojmatrix(bool init = true, bool flush = false) { if(init) { @@ -1283,7 +1284,7 @@ void setcamprojmatrix(bool init = true, bool flush = false) } matrix4 hudmatrix, hudmatrixstack[64]; -int hudmatrixpos = 0; +static int hudmatrixpos = 0; void resethudmatrix() { @@ -1351,7 +1352,7 @@ void disablezoom() zoomprogress = 0; } -void computezoom() +static void computezoom() { if(!zoom) { zoomprogress = 0; curfov = fov; curavatarfov = avatarfov; return; } if(zoom > 0) zoomprogress = zoominvel ? min(zoomprogress + float(elapsedtime) / zoominvel, 1.0f) : 1; @@ -1377,10 +1378,10 @@ FVAR(thirdpersondistance, 0, 30, 50); FVAR(thirdpersonup, -25, 0, 25); FVAR(thirdpersonside, -25, 0, 25); physent *camera1 = NULL; -bool detachedcamera = false; +static bool detachedcamera = false; bool isthirdperson() { return player!=camera1 || detachedcamera; } -void fixcamerarange() +static void fixcamerarange() { const float MAXPITCH = 90.0f; if(camera1->pitch>MAXPITCH) camera1->pitch = MAXPITCH; @@ -1389,7 +1390,7 @@ void fixcamerarange() while(camera1->yaw>=360.0f) camera1->yaw -= 360.0f; } -void modifyorient(float yaw, float pitch) +static void modifyorient(float yaw, float pitch) { camera1->yaw += yaw; camera1->pitch += pitch; @@ -1554,7 +1555,7 @@ FVAR(polygonoffsetfactor, -1e4f, -3.0f, 1e4f); FVAR(polygonoffsetunits, -1e4f, -3.0f, 1e4f); FVAR(depthoffset, -1e4f, 0.01f, 1e4f); -matrix4 nooffsetmatrix; +static matrix4 nooffsetmatrix; void enablepolygonoffset(GLenum type) { @@ -1989,7 +1990,7 @@ static void blendfogoverlay(int fogmat, float below, float blend, vec &overlay) } } -void drawfogoverlay(int fogmat, float fogbelow, float fogblend, int abovemat) +static void drawfogoverlay(int fogmat, float fogbelow, float fogblend, int abovemat) { SETSHADER(fogoverlay); @@ -2007,10 +2008,10 @@ void drawfogoverlay(int fogmat, float fogbelow, float fogblend, int abovemat) int drawtex = 0; -GLuint minimaptex = 0; +static GLuint minimaptex = 0; vec minimapcenter(0, 0, 0), minimapradius(0, 0, 0), minimapscale(0, 0, 0); -void clearminimap() +static void clearminimap() { if(minimaptex) { glDeleteTextures(1, &minimaptex); minimaptex = 0; } } @@ -2027,7 +2028,7 @@ void bindminimap() glBindTexture(GL_TEXTURE_2D, minimaptex); } -void clipminimap(ivec &bbmin, ivec &bbmax, cube *c = worldroot, const ivec &co = ivec(0, 0, 0), int size = worldsize>>1) +static void clipminimap(ivec &bbmin, ivec &bbmax, cube *c = worldroot, const ivec &co = ivec(0, 0, 0), int size = worldsize>>1) { loopi(8) { @@ -2487,162 +2488,21 @@ void gl_drawmainmenu() renderbackground(NULL, NULL, NULL, NULL, true); } -VARNP(damagecompass, usedamagecompass, 0, 1, 1); -VARP(damagecompassfade, 1, 1000, 10000); -VARP(damagecompasssize, 1, 30, 100); -VARP(damagecompassalpha, 1, 25, 100); -VARP(damagecompassmin, 1, 25, 1000); -VARP(damagecompassmax, 1, 200, 1000); - -float damagedirs[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - -void damagecompass(int n, const vec &loc) -{ - if(!usedamagecompass || minimized) return; - vec delta(loc); - delta.sub(camera1->o); - float yaw = 0, pitch; - if(delta.magnitude() > 4) - { - vectoyawpitch(delta, yaw, pitch); - yaw -= camera1->yaw; - } - if(yaw >= 360) yaw = fmod(yaw, 360); - else if(yaw < 0) yaw = 360 - fmod(-yaw, 360); - int dir = (int(yaw+22.5f)%360)/45; - damagedirs[dir] += max(n, damagecompassmin)/float(damagecompassmax); - if(damagedirs[dir]>1) damagedirs[dir] = 1; - -} -void drawdamagecompass(int w, int h) -{ - hudnotextureshader->set(); - - int dirs = 0; - float size = damagecompasssize/100.0f*min(h, w)/2.0f; - loopi(8) if(damagedirs[i]>0) - { - if(!dirs) - { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gle::colorf(1, 0, 0, damagecompassalpha/100.0f); - gle::defvertex(); - gle::begin(GL_TRIANGLES); - } - dirs++; - - float logscale = 32, - scale = log(1 + (logscale - 1)*damagedirs[i]) / log(logscale), - offset = -size/2.0f-min(h, w)/4.0f; - matrix4x3 m; - m.identity(); - m.settranslation(w/2, h/2, 0); - m.rotate_around_z(i*45*RAD); - m.translate(0, offset, 0); - m.scale(size*scale); - - gle::attrib(m.transform(vec2(1, 1))); - gle::attrib(m.transform(vec2(-1, 1))); - gle::attrib(m.transform(vec2(0, 0))); - - // fade in log space so short blips don't disappear too quickly - scale -= float(curtime)/damagecompassfade; - damagedirs[i] = scale > 0 ? (pow(logscale, scale) - 1) / (logscale - 1) : 0; - } - if(dirs) gle::end(); -} - -int damageblendmillis = 0; - -VARFP(damagescreen, 0, 1, 1, { if(!damagescreen) damageblendmillis = 0; }); -VARP(damagescreenfactor, 1, 75, 100); -VARP(damagescreenalpha, 1, 45, 100); -VARP(damagescreenfade, 0, 1000, 1000); -VARP(damagescreenmin, 1, 10, 1000); -VARP(damagescreenmax, 1, 100, 1000); - -void damageblend(int n) -{ - if(!damagescreen || minimized) return; - if(lastmillis > damageblendmillis) damageblendmillis = lastmillis; - damageblendmillis += clamp(n, damagescreenmin, damagescreenmax)*damagescreenfactor; -} - -void drawdamagescreen(int w, int h) -{ - if(lastmillis >= damageblendmillis) return; - - hudshader->set(); - - static Texture *damagetex = NULL; - if(!damagetex) damagetex = textureload("media/interface/hud/damage.png", 3); - - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glBindTexture(GL_TEXTURE_2D, damagetex->id); - float fade = damagescreenalpha/100.0f; - if(damageblendmillis - lastmillis < damagescreenfade) - fade *= float(damageblendmillis - lastmillis)/damagescreenfade; - gle::colorf(fade, fade, fade, fade); - - hudquad(0, 0, w, h); -} - VAR(hidestats, 0, 0, 1); VAR(hidehud, 0, 0, 1); VARP(crosshairsize, 0, 15, 50); VARP(cursorsize, 0, 15, 30); -VARP(crosshairfx, 0, 1, 1); -VARP(crosshaircolors, 0, 1, 1); -#define MAXCROSSHAIRS 4 -static Texture *crosshairs[MAXCROSSHAIRS] = { NULL, NULL, NULL, NULL }; +static Texture *crosshair = NULL; -void loadcrosshair(const char *name, int i) -{ - if(i < 0 || i >= MAXCROSSHAIRS) return; - crosshairs[i] = name ? textureload(name, 3, true) : notexture; - if(crosshairs[i] == notexture) - { - name = game::defaultcrosshair(i); - if(!name) name = "media/interface/crosshair/default.png"; - crosshairs[i] = textureload(name, 3, true); - } -} - -void loadcrosshair_(const char *name, int *i) -{ - loadcrosshair(name, *i); -} - -COMMANDN(loadcrosshair, loadcrosshair_, "si"); - -ICOMMAND(getcrosshair, "i", (int *i), -{ - const char *name = ""; - if(*i >= 0 && *i < MAXCROSSHAIRS) - { - name = crosshairs[*i] ? crosshairs[*i]->name : game::defaultcrosshair(*i); - if(!name) name = "media/interface/crosshair/default.png"; - } - result(name); -}); - -void writecrosshairs(stream *f) -{ - loopi(MAXCROSSHAIRS) if(crosshairs[i] && crosshairs[i]!=notexture) - f->printf("loadcrosshair %s %d\n", escapestring(crosshairs[i]->name), i); - f->printf("\n"); -} - -void drawcrosshair(int w, int h) +static void drawcrosshair(int w, int h) { bool windowhit = /*UI::hascursor()*/ false; if(!windowhit && (hidehud || mainmenu)) return; //(hidehud || player->state==CS_SPECTATOR || player->state==CS_DEAD)) return; vec color(1, 1, 1); float cx = 0.5f, cy = 0.5f, chsize; - Texture *crosshair; if(windowhit) { static Texture *cursor = NULL; @@ -2653,15 +2513,10 @@ void drawcrosshair(int w, int h) } else { - int index = game::selectcrosshair(color); - if(index < 0) return; - if(!crosshairfx) index = 0; - if(!crosshairfx || !crosshaircolors) color = vec(1, 1, 1); - crosshair = crosshairs[index]; + color = vec(1, 1, 1); if(!crosshair) { - loadcrosshair(NULL, index); - crosshair = crosshairs[index]; + crosshair = textureload("media/interface/crosshair/default.png", 3, true); } chsize = crosshairsize*w/900.0f; } @@ -2714,12 +2569,6 @@ void gl_drawhud() debugparticles(); - if(!mainmenu) - { - drawdamagescreen(w, h); - drawdamagecompass(w, h); - } - float conw = w/conscale, conh = h/conscale, abovehud = conh - FONTH; if(!hidehud && !mainmenu) { diff --git a/src/engine/rendergl.hh b/src/engine/rendergl.hh new file mode 100644 index 0000000..b8ea5d8 --- /dev/null +++ b/src/engine/rendergl.hh @@ -0,0 +1,79 @@ +#ifndef ENGINE_RENDERGL_HH +#define ENGINE_RENDERGL_HH + +#include + +extern bool hasVAO, hasTR, hasTSW, hasPBO, hasFBO, hasAFBO, hasDS, hasTF, hasCBF, hasS3TC, hasFXT1, hasLATC, hasRGTC, hasAF, hasFBB, hasFBMS, hasTMS, hasMSS, hasFBMSBS, hasUBO, hasMBR, hasDB2, hasDBB, hasTG, hasTQ, hasPF, hasTRG, hasTI, hasHFV, hasHFP, hasDBT, hasDC, hasDBGO, hasEGPU4, hasGPU4, hasGPU5, hasBFE, hasEAL, hasCR, hasOQ2, hasES3, hasCB, hasCI; + +extern int renderw, renderh, hudw, hudh; + +extern int glversion, glslversion, glcompat; +extern int maxdrawbufs, maxdualdrawbufs; + +enum { DRAWTEX_NONE = 0, DRAWTEX_ENVMAP, DRAWTEX_MINIMAP, DRAWTEX_MODELPREVIEW }; + +extern int vieww, viewh; +extern float fovy, aspect, forceaspect; +extern float nearplane; +extern int farplane; +extern float ldrscale, ldrscaleb; +extern int drawtex; + +extern const matrix4 viewmatrix, invviewmatrix; +extern matrix4 cammatrix, projmatrix, camprojmatrix, invcammatrix, invcamprojmatrix, invprojmatrix; + +extern int fog; +extern bvec fogcolour; +extern vec curfogcolor; +extern int wireframe; + +extern int glerr; +extern void glerror(const char *file, int line, GLenum error); + +#define GLERROR do { if(glerr) { GLenum error = glGetError(); if(error != GL_NO_ERROR) glerror(__FILE__, __LINE__, error); } } while(0) + +void gl_checkextensions(); +void gl_init(); +void gl_resize(); +void gl_drawview(); +void gl_drawmainmenu(); +void gl_drawhud(); +void gl_setupframe(bool force = false); +void gl_drawframe(); +void cleanupgl(); +void drawminimap(); + +void enablepolygonoffset(GLenum type); +void disablepolygonoffset(GLenum type); +bool calcspherescissor(const vec ¢er, float size, float &sx1, float &sy1, float &sx2, float &sy2, float &sz1, float &sz2); +bool calcbbscissor(const ivec &bbmin, const ivec &bbmax, float &sx1, float &sy1, float &sx2, float &sy2); +bool calcspotscissor(const vec &origin, float radius, const vec &dir, int spot, const vec &spotx, const vec &spoty, float &sx1, float &sy1, float &sx2, float &sy2, float &sz1, float &sz2); +void screenquad(); +void screenquad(float sw, float sh); +void screenquadflipped(float sw, float sh); +void screenquad(float sw, float sh, float sw2, float sh2); +void screenquadoffset(float x, float y, float w, float h); +void screenquadoffset(float x, float y, float w, float h, float x2, float y2, float w2, float h2); +void hudquad(float x, float y, float w, float h, float tx = 0, float ty = 0, float tw = 1, float th = 1); +void debugquad(float x, float y, float w, float h, float tx = 0, float ty = 0, float tw = 1, float th = 1); + +void recomputecamera(); +float calcfrustumboundsphere(float nearplane, float farplane, const vec &pos, const vec &view, vec ¢er); +void setfogcolor(const vec &v); +void zerofogcolor(); +void resetfogcolor(); +float calcfogdensity(float dist); +float calcfogcull(); +void renderavatar(); + +namespace modelpreview +{ + void start(int x, int y, int w, int h, bool background = true, bool scissor = false); + void end(); +} + +struct timer; +timer *begintimer(const char *name, bool gpu = true); +void endtimer(timer *t); + +#endif diff --git a/src/engine/renderlights.cc b/src/engine/renderlights.cc index cc5c671..d91c054 100644 --- a/src/engine/renderlights.cc +++ b/src/engine/renderlights.cc @@ -2,6 +2,7 @@ #include "aa.hh" #include "material.hh" +#include "rendergl.hh" #include "renderva.hh" #include "texture.hh" #include "world.hh" diff --git a/src/engine/rendermodel.cc b/src/engine/rendermodel.cc index 5aae61f..45ae878 100644 --- a/src/engine/rendermodel.cc +++ b/src/engine/rendermodel.cc @@ -1,4 +1,5 @@ #include "aa.hh" +#include "rendergl.hh" #include "renderva.hh" #include "shader.hh" #include "texture.hh" diff --git a/src/engine/renderparticles.cc b/src/engine/renderparticles.cc index a30f814..d8a1bce 100644 --- a/src/engine/renderparticles.cc +++ b/src/engine/renderparticles.cc @@ -1,5 +1,6 @@ // renderparticles.cpp +#include "rendergl.hh" #include "rendertext.hh" #include "renderva.hh" #include "shader.hh" diff --git a/src/engine/rendersky.cc b/src/engine/rendersky.cc index 36e3dca..35d1021 100644 --- a/src/engine/rendersky.cc +++ b/src/engine/rendersky.cc @@ -1,3 +1,4 @@ +#include "rendergl.hh" #include "renderva.hh" #include "texture.hh" diff --git a/src/engine/renderva.cc b/src/engine/renderva.cc index cfef919..20a7974 100644 --- a/src/engine/renderva.cc +++ b/src/engine/renderva.cc @@ -1,5 +1,6 @@ // renderva.cpp: handles the occlusion and rendering of vertex arrays +#include "rendergl.hh" #include "renderva.hh" #include "blend.hh" diff --git a/src/engine/shader.cc b/src/engine/shader.cc index abc517f..f412178 100644 --- a/src/engine/shader.cc +++ b/src/engine/shader.cc @@ -1,5 +1,6 @@ // shader.cpp: OpenGL GLSL shader management +#include "rendergl.hh" #include "shader.hh" #include "texture.hh" diff --git a/src/engine/stain.cc b/src/engine/stain.cc index ef571a4..41e904d 100644 --- a/src/engine/stain.cc +++ b/src/engine/stain.cc @@ -1,4 +1,5 @@ #include "material.hh" +#include "rendergl.hh" #include "texture.hh" #include "engine.hh" diff --git a/src/engine/texture.cc b/src/engine/texture.cc index eced773..272e9bd 100644 --- a/src/engine/texture.cc +++ b/src/engine/texture.cc @@ -1,6 +1,7 @@ // texture.cpp: texture slot management #include "material.hh" +#include "rendergl.hh" #include "shader.hh" #include "texture.hh" diff --git a/src/engine/water.cc b/src/engine/water.cc index 14b1afd..a79028b 100644 --- a/src/engine/water.cc +++ b/src/engine/water.cc @@ -1,4 +1,5 @@ #include "material.hh" +#include "rendergl.hh" #include "texture.hh" #include "water.hh" diff --git a/src/engine/world.cc b/src/engine/world.cc index 9647b76..2432ffb 100644 --- a/src/engine/world.cc +++ b/src/engine/world.cc @@ -2,6 +2,7 @@ #include "blend.hh" #include "octa.hh" +#include "rendergl.hh" /* fovy */ #include "renderlights.hh" #include "texture.hh" #include "worldio.hh" diff --git a/src/game/game.cc b/src/game/game.cc index 06684d0..0c6d49f 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -181,16 +181,6 @@ namespace game return 0; } - const char *defaultcrosshair(int index) - { - return "media/interface/crosshair/default.png"; - } - - int selectcrosshair(vec &) - { - return 0; - } - // any data written into this vector will get saved with the map data. Must take care to do own versioning, and endianess if applicable. Will not get called when loading maps from other games, so provide defaults. void writegamedata(vector &extras) {} void readgamedata(vector &extras) {} diff --git a/src/shared/glemu.cc b/src/shared/glemu.cc index 4f153f2..fe57a44 100644 --- a/src/shared/glemu.cc +++ b/src/shared/glemu.cc @@ -1,6 +1,7 @@ #include "cube.hh" -extern int glversion; +#include + extern int intel_mapbufferrange_bug; namespace gle diff --git a/src/shared/igame.hh b/src/shared/igame.hh index 0ff3058..fb2351e 100644 --- a/src/shared/igame.hh +++ b/src/shared/igame.hh @@ -78,8 +78,6 @@ namespace game extern void writegamedata(vector &extras); extern void readgamedata(vector &extras); extern float clipconsole(float w, float h); - extern const char *defaultcrosshair(int index); - extern int selectcrosshair(vec &col); extern void setupcamera(); extern bool allowthirdperson(); extern bool detachcamera();