diff dmrender.h @ 62:baccf2044289

Move the OpenGL rendering, setup etc. into a separate module/class, perhaps facilitating other types of renderers in future .. maybe.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 14 Dec 2019 16:39:20 +0200
parents
children d6ffc59bb84d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dmrender.h	Sat Dec 14 16:39:20 2019 +0200
@@ -0,0 +1,116 @@
+//
+// GLDragon - OpenGL PLY model viewer / simple benchmark
+// -- Basic renderer template
+// Programmed and designed by Matti 'ccr' Hämäläinen <ccr@tnsp.org>
+// (C) Copyright 2019 Tecnic Software productions (TNSP)
+//
+// See file "COPYING" for license information.
+//
+#ifndef DMRENDER_H
+#define DMRENDER_H 1
+
+#include "dmscene.h"
+#include <SDL.h>
+
+
+struct DMSimpleRenderer
+{
+    bool useShaders;
+
+    DMSimpleRenderer()
+    {
+        useShaders = false;
+    }
+
+    virtual bool checkErrors(void)
+    {
+        return true;
+    }
+
+    virtual bool initRender1(void)
+    {
+        return false;
+    }
+
+    virtual bool initRender2(SDL_Window *window)
+    {
+        (void) window;
+        return false;
+    }
+
+    virtual bool initRender3(const int width, const int height)
+    {
+        (void) width;
+        (void) height;
+
+        return false;
+    }
+
+    virtual void shutdownRenderer(void)
+    {
+    }
+
+    virtual void drawModel(const DMSimpleScene &scene, const DMModel &model, const float time)
+    {
+        (void) scene;
+        (void) model;
+        (void) time;
+    }
+
+    virtual void drawScene(const DMSimpleScene &scene, const float time)
+    {
+        (void) scene;
+        (void) time;
+    }
+
+    virtual bool compileModelShaders(DMModel &model)
+    {
+        (void) model;
+        return false;
+    }
+
+    virtual bool compileSceneShaders(DMSimpleScene &scene)
+    {
+        if (useShaders)
+        {
+            for (DMModel &model : scene.models)
+            {
+                if (!compileModelShaders(model))
+                    return false;
+            }
+        }
+        return true;
+    }
+
+    virtual bool setupLight(const int n, DMLight &light)
+    {
+        (void) n;
+        (void) light;
+        return true;
+    }
+
+    virtual bool setupLights(DMSimpleScene &scene)
+    {
+        for (size_t n = 0; n < scene.lights.size(); n++)
+        {
+            if (!setupLight(n, scene.lights[n]))
+                return false;
+        }
+        return true;
+    }
+
+    virtual bool setupCamera(DMCamera &camera)
+    {
+        (void) camera;
+        return true;
+    }
+
+    virtual bool animate(DMSimpleScene &scene, const float time)
+    {
+        (void) scene;
+        (void) time;
+        return true;
+    }
+};
+
+#endif