Skip to content

Commit 041dd34

Browse files
Added documenting comments
1 parent 5035e72 commit 041dd34

File tree

7 files changed

+54
-12
lines changed

7 files changed

+54
-12
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ add_executable(${APP_NAME} main.cpp
1818
glshift/GLManager.h
1919
glshift/GLShift.h
2020
glshift/definitions.h
21-
glshift/GLRenderer.h glshift/GLRenderer.cpp)
21+
glshift/GLRenderer.h
22+
glshift/GLRenderer.cpp)
2223

24+
# Linking libraries for windows/linux
25+
# TODO: add mac support
2326
if(WIN32)
2427
# Neccessary variables
2528
SET(LINK_GL_LIBS ${CMAKE_SOURCE_DIR}/lib/win/${ARCHITECTURE_TO_USE})

glshift/GLManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ void GLShift::GLManager::openWindow(int width, int height, const char* title,boo
4040

4141
void GLShift::GLManager::setRenderer(GLShift::GLRenderer *renderer) {
4242
this->renderer = renderer;
43+
// Call initialization function
4344
this->renderer->init();
4445
}
4546

glshift/GLManager.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,40 @@
99

1010
class GLShift::GLManager {
1111
public:
12+
/**
13+
* Initializes the GLFW environment
14+
*/
1215
GLManager();
13-
~GLManager();
16+
/**
17+
* Initializes the GLFW environment & sets the specific version
18+
* of OpenGL to use
19+
* @param major
20+
* @param minor
21+
*/
1422
GLManager(signed int major, signed int minor);
23+
/**
24+
* Terminated the GLFW environment
25+
*/
26+
~GLManager();
1527

28+
/**
29+
* Sets the version of OpenGL to use
30+
* @param major
31+
* @param minor
32+
*/
1633
void setVersion(signed int major, signed int minor);
34+
/**
35+
* Sets the renderer object to use for rendering on the window
36+
* @param renderer
37+
*/
1738
void setRenderer(GLRenderer * renderer);
39+
/**
40+
* Opens a window with GLFW context
41+
* @param width
42+
* @param height
43+
* @param title
44+
* @param isFullScreen Set true to make full screen app
45+
*/
1846
void openWindow(signed int width, signed int height, const char* title, bool isFullScreen = false);
1947
void run();
2048
private:

glshift/GLRenderer.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,4 @@
22
// Created by lesscomplex on 08/03/2020.
33
//
44

5-
#include "GLRenderer.h"
6-
7-
GLShift::GLRenderer::GLRenderer(GLShift::GLManager *context) {
8-
this->context = context;
9-
}
5+
#include "GLRenderer.h"

glshift/GLRenderer.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99

1010
class GLShift::GLRenderer {
1111
public:
12-
explicit GLRenderer(GLManager* context);
12+
/**
13+
* Override to provide code for the rendering loop
14+
*/
1315
virtual void render() = 0;
16+
/**
17+
* Override to provide code for the initialization loop
18+
*/
1419
virtual void init() = 0;
15-
private:
16-
GLManager * context;
1720
};
1821

1922
#endif //YOURAPPNAME_GLRENDERER_H

glshift/definitions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
#include <GLFW/glfw3.h>
1010

1111
namespace GLShift {
12+
/**
13+
* Helps manage a window with GLFW context
14+
*/
1215
class GLManager;
16+
/**
17+
* Defines the functionality for rendering the screen
18+
*/
1319
class GLRenderer;
1420
}
1521

main.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "glshift/GLShift.h"
22

3+
/**
4+
* Example for a renderer implementation
5+
*/
36
class MyRenderer : public GLShift::GLRenderer {
4-
using GLShift::GLRenderer::GLRenderer; // Import constructor
57
public:
68
void render() override {
79
glClearColor(1, 0, 0, 1);
@@ -11,9 +13,12 @@ class MyRenderer : public GLShift::GLRenderer {
1113
};
1214

1315
int main() {
16+
/**
17+
* Example for a GLManager implementation
18+
*/
1419
GLShift::GLManager glManager = GLShift::GLManager();
1520
glManager.openWindow(600, 300, "Yeahh!");
16-
glManager.setRenderer(new MyRenderer(&glManager));
21+
glManager.setRenderer(new MyRenderer());
1722
glManager.run();
1823
return 0;
1924
}

0 commit comments

Comments
 (0)