diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2016-05-06 07:59:33 -0400 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2016-05-06 07:59:33 -0400 |
commit | aaf7a6bd286b0d200356ef54148791e2e91ff253 (patch) | |
tree | 5ec367130cfa6c6827d2d965ea17b3556b6a8a75 /include | |
parent | 1a1640760502081c2dcded90cff351163fabce76 (diff) |
MODERN
Diffstat (limited to 'include')
-rw-r--r-- | include/common.hpp | 93 | ||||
-rw-r--r-- | include/entities.hpp | 3 | ||||
-rw-r--r-- | include/ui_menu.hpp | 1 |
3 files changed, 80 insertions, 17 deletions
diff --git a/include/common.hpp b/include/common.hpp index 92318d9..bbe852f 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -16,6 +16,8 @@ #include <cmath> #include <algorithm> +#include <shader_utils.hpp> + #define GLEW_STATIC #include <GL/glew.h> @@ -24,6 +26,12 @@ #include <SDL2/SDL_image.h> #include <SDL2/SDL_mixer.h> +#define GLM_FORCE_RADIANS +#include <glm/glm.hpp> +#include <glm/gtc/matrix_transform.hpp> +#include <glm/gtc/type_ptr.hpp> +#include <glm/gtc/noise.hpp> + #include <config.hpp> #ifdef __WIN32__ @@ -52,6 +60,11 @@ const float MSEC_PER_TICK = 1000.0f / TICKS_PER_SEC; extern GLuint colorIndex; // Texture.cpp? /** + * This separates xml strings with + */ +std::vector<std::string> StringTokenizer(const std::string& str, char delim); + +/** * This structure contains a set of coordinates for ease of coding. */ @@ -62,30 +75,62 @@ typedef struct { typedef ivec2 dim2; -struct _vec2 { +class vec2 { +public: float x; float y; - bool operator==(const _vec2 &v) { + vec2 () + { + x = y = 0.0f; + } + + vec2 (float _x, float _y) + { + x = _x; + y = _y; + } + + bool operator==(const vec2 &v) { return (x == v.x) && (y == v.y); } template<typename T> - const _vec2 operator=(const T &n) { + const vec2 operator=(const T &n) { x = y = n; return *this; } template<typename T> - const _vec2 operator+(const T &n) { - return _vec2 {x + n, y + n}; + const vec2 operator+(const T &n) { + return vec2 (x + n, y + n); } }; -typedef struct _vec2 vec2; -typedef struct { +class vec3{ +public: float x; float y; float z; -} vec3; + + vec3 () + { + x = y = z = 0.0f; + } + + vec3 (float _x, float _y, float _z) + { + x = _x; + y = _y; + z = _z; + } + + vec3 (float _x, float _y) + { + x = _x; + y = _y; + z = 1.0f; + } + +}; /** * This structure contains two sets of coordinates for ray drawing. @@ -96,26 +141,35 @@ typedef struct { vec2 end; } Ray; -struct _color { +class Color{ +public: float red; float green; float blue; - _color operator-=(float a) { + Color() + { + red = green = blue = 0; + } + Color(float r, float g ,float b) + { + red = r; + green = g; + blue = b; + } + Color operator-=(float a) { red-=a; green-=a; blue-=a; return{red+a,green+a,blue+a}; } - _color operator+=(float a) { + Color operator+=(float a) { return{red+a,green+a,blue+a}; } - _color operator=(float a) { + Color operator=(float a) { return{red=a,green=a,blue=a}; } }; -typedef struct _color Color; - // gets the length of `n` HLINEs template<typename T> inline T HLINES(const T &n) @@ -138,8 +192,15 @@ extern vec2 offset; // the shader program created in main.cpp extern GLuint shaderProgram; -// splits a string into tokens -std::vector<std::string> StringTokenizer(const std::string& str, char delim); +extern GLuint textShader; +extern GLint textShader_attribute_coord; +extern GLint textShader_attribute_tex; +extern GLint textShader_uniform_texture; + +extern GLuint worldShader; +extern GLint worldShader_attribute_coord; +extern GLint worldShader_attribute_tex; +extern GLint worldShader_uniform_texture; /** * Prints a formatted debug message to the console, along with the callee's file and line diff --git a/include/entities.hpp b/include/entities.hpp index 5417dac..3e78687 100644 --- a/include/entities.hpp +++ b/include/entities.hpp @@ -149,7 +149,7 @@ public: ~Particles(void){} // draws the particle - void draw(void) const; + std::vector<std::pair<vec2, vec3>> draw(void) const; // updates a particle void update(float _gravity, float ground_y); @@ -183,6 +183,7 @@ protected: public: // contains the entity's coordinates, in pixels vec2 loc; + float z; // contains the entity's velocity, in pixels vec2 vel; diff --git a/include/ui_menu.hpp b/include/ui_menu.hpp index 1ec7ff3..f7b665e 100644 --- a/include/ui_menu.hpp +++ b/include/ui_menu.hpp @@ -32,6 +32,7 @@ public: float *var; } slider; }; + menuItem(){} ~menuItem(){ //button.text = NULL; //slider.text = NULL; |