From: outfrost Date: Thu, 24 Jan 2019 02:37:37 +0000 (+0100) Subject: Reorder, move and rename things X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=ac5679f040165c0c35adc03f78dc50e9938c9dcb;p=shadowclad.git Reorder, move and rename things * Reorder header includes alphabetically * Move initRender() to render.c * Rename glut_janitor to ui --- diff --git a/debugutil.c b/debugutil.c index ca6dba1..80f5caa 100644 --- a/debugutil.c +++ b/debugutil.c @@ -1,7 +1,7 @@ #include -#include -#include #include +#include +#include #include "assimp_types.h" diff --git a/debugutil.h b/debugutil.h index bc5d346..4d66e3d 100644 --- a/debugutil.h +++ b/debugutil.h @@ -5,7 +5,7 @@ #include "assimp_types.h" -char* getGlInfoString(); +char* getGlInfoString(void); void dumpScene(FILE* stream, const AiScene* scene); void dumpNode(FILE* stream, const AiNode* node); diff --git a/glut_janitor.c b/glut_janitor.c deleted file mode 100644 index db71091..0000000 --- a/glut_janitor.c +++ /dev/null @@ -1,41 +0,0 @@ -#include - -void initRender() { - // Set the clear colour to black - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - - GLfloat light0_ambient[] = {0.1f, 0.1f, 0.1f, 1.0f}; - GLfloat light0_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; - GLfloat light0_specular[] = {1.0f, 1.0f, 1.0f, 1.0f}; - GLfloat light0_position[] = {5.0f, 10.0f, 10.0f, 1.0f}; - - glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); - glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); - glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); - glLightfv(GL_LIGHT0, GL_POSITION, light0_position); - - glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1.0f); - glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05f); - glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.001f); -} - -void resizeStage(GLsizei width, GLsizei height) { - if (height == 0) - height = 1; - - // Set device viewport dimensions - glViewport(0, 0, width, height); - // Switch to projection matrix - glMatrixMode(GL_PROJECTION); - // Reset the projection matrix - glLoadIdentity(); - - GLfloat aspectRatio = (GLfloat) width / (GLfloat) height; - - glOrtho(-8.0, 8.0, -8.0/aspectRatio, 8.0/aspectRatio, 128.0, -128.0); - - glRotatef(45.0f, 1.0f, 0.0f, 0.0f); - glRotatef(45.0f, 0.0f, 1.0f, 0.0f); - - glMatrixMode(GL_MODELVIEW); -} diff --git a/glut_janitor.h b/glut_janitor.h deleted file mode 100644 index 42080c1..0000000 --- a/glut_janitor.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef GLUT_JANITOR_H_ -#define GLUT_JANITOR_H_ - -#include - -void initRender(); -void resizeStage(GLsizei width, GLsizei height); - -#endif diff --git a/level.c b/level.c index 5e1cd6f..1388a92 100644 --- a/level.c +++ b/level.c @@ -1,6 +1,5 @@ #include #include - #include // TODO remove #include "level.h" diff --git a/level.h b/level.h index b36c2bb..387df43 100644 --- a/level.h +++ b/level.h @@ -11,7 +11,7 @@ typedef uint32_t Block; const AiScene* levelScene; -void initLevel(); +void initLevel(void); void setImage(TgaImage* image); const AiScene* importScene(const char* path); diff --git a/main.c b/main.c index 28b3c4d..cf8dcdf 100644 --- a/main.c +++ b/main.c @@ -3,10 +3,10 @@ #include #include "debugutil.h" -#include "glut_janitor.h" -#include "render.h" #include "level.h" #include "performance.h" +#include "render.h" +#include "ui.h" int main(int argc, char** argv) { glutInit(&argc, argv); diff --git a/performance.c b/performance.c index cb3709f..2a1d13a 100644 --- a/performance.c +++ b/performance.c @@ -1,6 +1,6 @@ -#include -#include // TODO remove #include +#include // TODO remove +#include typedef struct timespec Timepoint; diff --git a/performance.h b/performance.h index b4ded6b..70724d1 100644 --- a/performance.h +++ b/performance.h @@ -1,7 +1,7 @@ #ifndef PERFORMANCE_H_ #define PERFORMANCE_H_ -void initPerformanceMetering(); -void frameRendered(); +void initPerformanceMetering(void); +void frameRendered(void); #endif diff --git a/render.c b/render.c index 63578df..18f0827 100644 --- a/render.c +++ b/render.c @@ -1,12 +1,30 @@ #include #include "level.h" -#include "typedefs.h" #include "performance.h" #include "render.h" +#include "typedefs.h" const float AXIS_RADIUS = 5.0f; +void initRender() { + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + + GLfloat light0_ambient[] = {0.1f, 0.1f, 0.1f, 1.0f}; + GLfloat light0_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; + GLfloat light0_specular[] = {1.0f, 1.0f, 1.0f, 1.0f}; + GLfloat light0_position[] = {5.0f, 10.0f, 10.0f, 1.0f}; + + glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient); + glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, light0_specular); + glLightfv(GL_LIGHT0, GL_POSITION, light0_position); + + glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1.0f); + glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05f); + glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.001f); +} + void renderScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); diff --git a/render.h b/render.h index c65e491..a0be88f 100644 --- a/render.h +++ b/render.h @@ -3,8 +3,9 @@ #include "assimp_types.h" -void renderScene(); -void drawAxes(); +void initRender(void); +void renderScene(void); +void drawAxes(void); void drawSceneRecursive(const AiScene* scene, const AiNode* node); #endif diff --git a/tga.c b/tga.c index 7ca9ef6..7e13d90 100644 --- a/tga.c +++ b/tga.c @@ -1,5 +1,5 @@ -#include #include +#include #include "tga.h" diff --git a/ui.c b/ui.c new file mode 100644 index 0000000..5010a81 --- /dev/null +++ b/ui.c @@ -0,0 +1,22 @@ +#include + +void resizeStage(GLsizei width, GLsizei height) { + if (height == 0) + height = 1; + + // Set device viewport dimensions + glViewport(0, 0, width, height); + // Switch to projection matrix + glMatrixMode(GL_PROJECTION); + // Reset the projection matrix + glLoadIdentity(); + + GLfloat aspectRatio = (GLfloat) width / (GLfloat) height; + + glOrtho(-8.0, 8.0, -8.0/aspectRatio, 8.0/aspectRatio, 128.0, -128.0); + + glRotatef(45.0f, 1.0f, 0.0f, 0.0f); + glRotatef(45.0f, 0.0f, 1.0f, 0.0f); + + glMatrixMode(GL_MODELVIEW); +} diff --git a/ui.h b/ui.h new file mode 100644 index 0000000..5d3117a --- /dev/null +++ b/ui.h @@ -0,0 +1,8 @@ +#ifndef GLUT_JANITOR_H_ +#define GLUT_JANITOR_H_ + +#include + +void resizeStage(GLsizei width, GLsizei height); + +#endif