Created
January 4, 2014 19:23
-
-
Save fkaa/8259544 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef __SHTEST_BATCH_H__ | |
| #define __SHTEST_BATCH_H__ | |
| #include <stdarg.h> | |
| #include <glm/glm.hpp> | |
| #include <glm/gtc/matrix_transform.hpp> | |
| #include "glutil.h" | |
| class SpriteBatch { | |
| public: | |
| SpriteBatch(GLsizei width, GLsizei height, size_t capacity); | |
| ~SpriteBatch(); | |
| void begin(); | |
| void end(); | |
| void update_matrices(); | |
| void set_color(const GLfloat red, const GLfloat green, const GLfloat blue); | |
| void set_color(const GLfloat red, const GLfloat green, const GLfloat blue, const GLfloat alpha); | |
| void draw(GLuint texture, GLfloat x, GLfloat y, GLfloat width, GLfloat height); | |
| void draw(GLuint texture, GLfloat src_x, GLfloat src_y, GLfloat src_width, GLfloat src_height, GLfloat x, GLfloat y, GLfloat width, GLfloat height); | |
| private: | |
| GLuint u_proj_view, u_tex, a_pos, a_uv, a_col; | |
| GLfloat r, g, b, a; | |
| glm::mat4 proj; | |
| glm::mat4 view; | |
| glm::mat4 proj_view; | |
| float* data; | |
| GLuint current_texture; | |
| GLuint shader; | |
| GLuint vao; | |
| bool active; | |
| size_t size; | |
| size_t idx; | |
| GLsizei v_idx; | |
| void render(); | |
| void flush(); | |
| void put(size_t indices, size_t count, const GLfloat* vertices); | |
| }; | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment