OpenXcom  1.0
Open-source clone of the original X-Com
OpenGL.h
1 // This file was copied from the bsnes project.
2 
3 // This is the license info, from ruby.hpp:
4 
5 /*
6  ruby
7  version: 0.08 (2011-11-25)
8  license: public domain
9  */
10 #pragma once
11 
12 #ifndef __NO_OPENGL
13 
14 #include <SDL_opengl.h>
15 #include <string>
16 
17 namespace OpenXcom
18 {
19 
20 class Surface;
21 
22 std::string strGLError(GLenum glErr);
23 
24 #define glErrorCheck() {\
25  static bool reported = false;\
26  GLenum glErr;\
27  if (OpenGL::checkErrors && !reported && (glErr = glGetError()) != GL_NO_ERROR)\
28  {\
29  reported = true;\
30  \
31  do \
32  { \
33  Log(LOG_WARNING) << __FILE__ << ":" << __LINE__ << ": glGetError() complaint: " << strGLError(glErr);\
34  } while (((glErr = glGetError()) != GL_NO_ERROR));\
35  }\
36 }
37 
38 
39 class OpenGL {
40 public:
41  GLuint gltexture;
42  GLuint glprogram;
43  bool linear;
44  bool shader_support;
45 
46  uint32_t *buffer;
47  Surface *buffer_surface;
48  unsigned iwidth, iheight, iformat, ibpp;
49 
50  static bool checkErrors;
51 
53  void resize(unsigned width, unsigned height);
55  bool lock(uint32_t *&data, unsigned &pitch);
57  void clear();
59  void refresh(bool smooth, unsigned inwidth, unsigned inheight, unsigned outwidth, unsigned outheight, int topBlackBand, int bottomBlackBand, int leftBlackBand, int rightBlackBand);
61  bool set_shader(const char *source);
63  void set_fragment_shader(const char *source);
65  void set_vertex_shader(const char *source);
67  void init(int width, int height);
69  void term();
71  void setVSync(bool sync);
73  OpenGL();
74  ~OpenGL();
75 };
76 
77 }
78 
79 #else
80 
81 namespace OpenXcom { class OpenGL {}; }
82 
83 #endif
bool set_shader(const char *source)
set a shader! but what kind?
Definition: OpenGL.cpp:246
void set_vertex_shader(const char *source)
and vertex?
Definition: OpenGL.cpp:378
void set_fragment_shader(const char *source)
same but for fragment shader?
Definition: OpenGL.cpp:367
OpenGL()
constructor – like we said, we&#39;re too cool to actually construct things
Definition: OpenGL.cpp:504
void resize(unsigned width, unsigned height)
call to resize internal buffer; internal use
Definition: OpenGL.cpp:112
void init(int width, int height)
init(), because we&#39;re too cool to initialize everything in the constructor
Definition: OpenGL.cpp:389
void term()
more like exit, because destructors are for uncool people
Definition: OpenGL.cpp:482
bool lock(uint32_t *&data, unsigned &pitch)
actually returns pointer to data buffer where one is to write the image
Definition: OpenGL.cpp:138
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
void setVSync(bool sync)
Try to set VSync!
Definition: OpenGL.cpp:459
Definition: OpenGL.h:39
void clear()
make all the pixels go away
Definition: OpenGL.cpp:144
void refresh(bool smooth, unsigned inwidth, unsigned inheight, unsigned outwidth, unsigned outheight, int topBlackBand, int bottomBlackBand, int leftBlackBand, int rightBlackBand)
make the buffer show up on screen
Definition: OpenGL.cpp:152
Definition: BaseInfoState.cpp:40