From b7697e89f0ecfe54dce05e0ffef441588af16be3 Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 13 May 2020 00:40:14 +0200 Subject: [PATCH] headers for grass, movie --- src/engine/engine.hh | 15 --------------- src/engine/grass.cc | 4 ++-- src/engine/grass.hh | 9 +++++++++ src/engine/main.cc | 1 + src/engine/movie.cc | 22 ++++++++++++---------- src/engine/movie.hh | 11 +++++++++++ src/engine/octarender.cc | 1 + src/engine/rendergl.cc | 1 + src/engine/renderva.cc | 1 + 9 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 src/engine/grass.hh create mode 100644 src/engine/movie.hh diff --git a/src/engine/engine.hh b/src/engine/engine.hh index 5a7c74b..0678d4c 100644 --- a/src/engine/engine.hh +++ b/src/engine/engine.hh @@ -339,21 +339,6 @@ extern bool hasskybox(); extern bool limitsky(); extern void cleanupsky(); -// grass -extern void loadgrassshaders(); -extern void generategrass(); -extern void rendergrass(); -extern void cleanupgrass(); - -// recorder - -namespace recorder -{ - extern void stop(); - extern void capture(bool overlay = true); - extern void cleanup(); -} - #endif #endif diff --git a/src/engine/grass.cc b/src/engine/grass.cc index 8b6ed53..c2a2276 100644 --- a/src/engine/grass.cc +++ b/src/engine/grass.cc @@ -254,7 +254,7 @@ void generategrass() static Shader *grassshader = NULL; -Shader *loadgrassshader() +static Shader *loadgrassshader() { string opts; int optslen = 0; @@ -271,7 +271,7 @@ void loadgrassshaders() grassshader = loadgrassshader(); } -void cleargrassshaders() +static void cleargrassshaders() { grassshader = NULL; } diff --git a/src/engine/grass.hh b/src/engine/grass.hh new file mode 100644 index 0000000..1492db9 --- /dev/null +++ b/src/engine/grass.hh @@ -0,0 +1,9 @@ +#ifndef ENGINE_GRASS_HH +#define ENGINE_GRASS_HH + +void generategrass(); +void loadgrassshaders(); +void rendergrass(); +void cleanupgrass(); + +#endif diff --git a/src/engine/main.cc b/src/engine/main.cc index 8193c30..a2eabae 100644 --- a/src/engine/main.cc +++ b/src/engine/main.cc @@ -1,6 +1,7 @@ // main.cpp: initialisation & main loop #include "blend.hh" +#include "movie.hh" #include "rendergl.hh" #include "rendertext.hh" #include "renderva.hh" diff --git a/src/engine/movie.cc b/src/engine/movie.cc index 5650710..a0be841 100644 --- a/src/engine/movie.cc +++ b/src/engine/movie.cc @@ -835,19 +835,19 @@ namespace recorder static SDL_mutex *videolock = NULL; static SDL_cond *shouldencode = NULL, *shouldread = NULL; - bool isrecording() { return file != NULL; } + static inline bool isrecording() { return file != NULL; } - float calcquality() + static inline float calcquality() { return 1.0f - float(dps)/float(dps+file->videofps); // strictly speaking should lock to read dps - 1.0=perfect, 0.5=half of frames are beingdropped } - int gettime() + static inline int gettime() { return inbetweenframes ? getclockmillis() : totalmillis; } - int videoencoder(void *data) // runs on a separate thread + static int videoencoder(void *data) // runs on a separate thread { for(int numvid = 0, numsound = 0;;) { @@ -896,7 +896,8 @@ namespace recorder return 0; } - void soundencoder(void *udata, Uint8 *stream, int len) // callback occurs on a separate thread +#if 0 + static void soundencoder(void *udata, Uint8 *stream, int len) // callback occurs on a separate thread { SDL_LockMutex(soundlock); if(soundbuffers.full()) @@ -911,8 +912,9 @@ namespace recorder } SDL_UnlockMutex(soundlock); } +#endif - void start(const char *filename, int videofps, int videow, int videoh, bool sound) + static void start(const char *filename, int videofps, int videow, int videoh, bool sound) { if(file) return; @@ -1004,7 +1006,7 @@ namespace recorder state = REC_OK; } - void readbuffer(videobuffer &m, uint nextframe) + static void readbuffer(videobuffer &m, uint nextframe) { bool accelyuv = movieaccelyuv && !(m.w%8), usefbo = movieaccel && file->videow <= (uint)screenw && file->videoh <= (uint)screenh && (accelyuv || file->videow < (uint)screenw || file->videoh < (uint)screenh); @@ -1101,7 +1103,7 @@ namespace recorder else glReadPixels(0, 0, m.w, m.h, GL_BGRA, GL_UNSIGNED_BYTE, m.video); } - bool readbuffer() + static bool readbuffer() { if(!file) return false; if(state != REC_OK) @@ -1126,7 +1128,7 @@ namespace recorder return true; } - void drawhud() + static void drawhud() { int w = hudw, h = hudh; if(forceaspect) w = int(ceil(h*forceaspect)); @@ -1160,7 +1162,7 @@ VARP(movieh, 0, 240, 10000); VARP(moviefps, 1, 24, 1000); VARP(moviesound, 0, 1, 1); -void movie(char *name) +static void movie(char *name) { if(name[0] == '\0') recorder::stop(); else if(!recorder::isrecording()) recorder::start(name, moviefps, moview ? moview : screenw, movieh ? movieh : screenh, moviesound!=0); diff --git a/src/engine/movie.hh b/src/engine/movie.hh new file mode 100644 index 0000000..67e2b3a --- /dev/null +++ b/src/engine/movie.hh @@ -0,0 +1,11 @@ +#ifndef ENGINE_MOVIE_HH +#define ENGINE_MOVIE_HH + +namespace recorder +{ + void stop(); + void capture(bool overlay = true); + void cleanup(); +} + +#endif diff --git a/src/engine/octarender.cc b/src/engine/octarender.cc index ff4ec9b..4050bfa 100644 --- a/src/engine/octarender.cc +++ b/src/engine/octarender.cc @@ -1,6 +1,7 @@ // octarender.cpp: fill vertex arrays with different cube surfaces. #include "blend.hh" +#include "grass.hh" #include "material.hh" #include "rendergl.hh" #include "renderva.hh" diff --git a/src/engine/rendergl.cc b/src/engine/rendergl.cc index 135b3f2..b477cc9 100644 --- a/src/engine/rendergl.cc +++ b/src/engine/rendergl.cc @@ -2,6 +2,7 @@ #include "aa.hh" #include "blend.hh" +#include "grass.hh" #include "material.hh" #include "rendergl.hh" #include "rendertext.hh" diff --git a/src/engine/renderva.cc b/src/engine/renderva.cc index 20a7974..f292e64 100644 --- a/src/engine/renderva.cc +++ b/src/engine/renderva.cc @@ -4,6 +4,7 @@ #include "renderva.hh" #include "blend.hh" +#include "grass.hh" #include "texture.hh" #include "engine.hh"