1 /* 2 Rendering Subsystem 3 4 Copyright © 2020, Luna Nielsen 5 Distributed under the 2-Clause BSD License, see LICENSE file. 6 7 Authors: Luna Nielsen 8 */ 9 module engine.render; 10 public import bindbc.opengl; 11 public import engine.render.shader; 12 public import engine.render.tile; 13 public import engine.render.texture; 14 public import engine.render.batcher; 15 public import engine.render.fbo; 16 17 void initRender() { 18 19 // OpenGL prep stuff 20 glEnable(GL_BLEND); 21 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 22 23 glEnable(GL_CULL_FACE); 24 glEnable(GL_DEPTH_TEST); 25 glDepthFunc(GL_LESS); 26 27 GameBatch = new SpriteBatch(); 28 } 29 30 private int viewportX; 31 private int viewportY; 32 private int viewportW; 33 private int viewportH; 34 35 /** 36 Sets the viewport 37 */ 38 void kmViewport(int x, int y, int width, int height) { 39 import engine.math.camera : kmSetCameraTargetSize; 40 41 viewportX = x; 42 viewportY = y; 43 viewportW = width; 44 viewportH = height; 45 glViewport(x, y, width, height); 46 kmSetCameraTargetSize(width, height); 47 } 48 49 /** 50 Returns the viewport X 51 */ 52 int kmViewportX() { 53 return viewportX; 54 } 55 56 /** 57 Returns the viewport Y 58 */ 59 int kmViewportY() { 60 return viewportY; 61 } 62 63 /** 64 Returns the viewport width 65 */ 66 int kmViewportWidth() { 67 return viewportW; 68 } 69 70 /** 71 Returns the viewport height 72 */ 73 int kmViewportHeight() { 74 return viewportH; 75 }