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.h>
15 #include <SDL_opengl.h>
16 #include <string>
17 
18 namespace OpenXcom
19 {
20 
21 class Surface;
22 
23 std::string strGLError(GLenum glErr);
24 
25 #define glErrorCheck() {\
26  static bool reported = false;\
27  GLenum glErr;\
28  if (OpenGL::checkErrors && !reported && (glErr = glGetError()) != GL_NO_ERROR)\
29  {\
30  reported = true;\
31  \
32  do \
33  { \
34  Log(LOG_WARNING) << __FILE__ << ":" << __LINE__ << ": glGetError() complaint: " << strGLError(glErr);\
35  } while (((glErr = glGetError()) != GL_NO_ERROR));\
36  }\
37 }
38 
39 
40 class OpenGL {
41 public:
42  GLuint gltexture;
43  GLuint glprogram;
44  bool linear;
45  bool shader_support;
46 
47  uint32_t *buffer;
48  Surface *buffer_surface;
49  unsigned iwidth, iheight, iformat, ibpp;
50 
51  static bool checkErrors;
52 
54  void resize(unsigned width, unsigned height);
56  bool lock(uint32_t *&data, unsigned &pitch);
58  void clear();
60  void refresh(bool smooth, unsigned inwidth, unsigned inheight, unsigned outwidth, unsigned outheight, int topBlackBand, int bottomBlackBand, int leftBlackBand, int rightBlackBand);
62  bool set_shader(const char *source);
64  void set_fragment_shader(const char *source);
66  void set_vertex_shader(const char *source);
68  void init(int width, int height);
70  void term();
72  void setVSync(bool sync);
74  OpenGL();
75  ~OpenGL();
76 };
77 
78 }
79 
80 #else
81 
82 namespace OpenXcom { class OpenGL {}; }
83 
84 #endif
bool set_shader(const char *source)
set a shader! but what kind?
Definition: OpenGL.cpp:228
void set_vertex_shader(const char *source)
and vertex?
Definition: OpenGL.cpp:360
void set_fragment_shader(const char *source)
same but for fragment shader?
Definition: OpenGL.cpp:349
OpenGL()
constructor – like we said, we&#39;re too cool to actually construct things
Definition: OpenGL.cpp:486
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:371
void term()
more like exit, because destructors are for uncool people
Definition: OpenGL.cpp:464
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:36
void setVSync(bool sync)
Try to set VSync!
Definition: OpenGL.cpp:441
Definition: OpenGL.h:40
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