Mercurial > hg > forks > gldragon
view dmrender.h @ 103:f88859a8fa4b
Add note about code origins to COPYING.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 06 Oct 2022 05:02:07 +0300 |
parents | 28dd29f3a65f |
children | f8880b75524b |
line wrap: on
line source
// // 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-2020 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; int windowWidth, windowHeight; SDL_Window *sdlWindow; DMSimpleRenderer() { useShaders = false; sdlWindow = NULL; } virtual bool checkErrors(void) { return true; } virtual bool initRenderer1(const char *title, const int width, const int height, const int sdlWindowHPos, const int sdlWindowVPos, const int sdlFlags) { windowWidth = width; windowHeight = height; if ((sdlWindow = SDL_CreateWindow(title, sdlWindowHPos, sdlWindowVPos, windowWidth, windowHeight, sdlFlags)) == NULL) { dmError("Could not create SDL window: %s", SDL_GetError()); return false; } else return true; } virtual bool initRenderer2(void) { return false; } virtual void shutdownRenderer(void) { if (sdlWindow != NULL) SDL_DestroyWindow(sdlWindow); } virtual void swapWindow(void) { SDL_GL_SwapWindow(sdlWindow); } 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 deleteModelShaders(DMModel &model) { (void) model; return false; } virtual bool deleteSceneShaders(DMSimpleScene &scene) { if (useShaders) { for (DMModel &model : scene.models) { if (!deleteModelShaders(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; } }; #endif