-
Notifications
You must be signed in to change notification settings - Fork 7
/
glwrappers.h
58 lines (40 loc) · 1.15 KB
/
glwrappers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2015 Red Blob Games <[email protected]>
// License: Apache v2.0 <http://www.apache.org/licenses/LICENSE-2.0.html>
/** Convenience functions, plus RAII wrappers for SDL and GL objects that
* come in construct/destroy pairs.
*/
#ifndef GLWRAPPERS_H
#define GLWRAPPERS_H
#define GL_GLEXT_PROTOTYPES
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_opengl_glext.h>
#include "common.h"
// Check for any OpenGL errors and print them
void GLERRORS(const char* label);
SDL_Surface* CreateRGBASurface(int width, int height);
struct ShaderProgram: nocopy {
GLuint id;
ShaderProgram(const char* vertex_shader, const char* fragment_shader);
~ShaderProgram();
private:
void AttachShader(GLenum type, const GLchar* source);
};
struct Texture: nocopy {
GLuint id;
Texture(SDL_Surface* surface = nullptr);
~Texture();
void CopyFromPixels(int width, int height, GLenum format, void* pixels);
void CopyFromSurface(SDL_Surface* surface);
};
struct VertexBuffer: nocopy {
GLuint id;
VertexBuffer();
~VertexBuffer();
};
struct GlContext: nocopy {
SDL_GLContext id;
GlContext(SDL_Window* window);
~GlContext();
};
#endif