summaryrefslogtreecommitdiff
path: root/src/boring_parts.cpp
blob: 447ae605eb6cde09e90c8376ee1ee2db64f54e0e (plain)
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
#include "boring_parts.hpp"

// TODO : only need OpenGL things, not GTK ones for now
//#include "gtk_includes.hpp"

/* From http://stackoverflow.com/questions/4317062/opengl-how-to-check-if-the-user-supports-glgenbuffers
#ifdef WIN32
  #include <windows.h>
  #define glGetProcAddress(a) wglGetProcAddress(a)
#endif
#ifdef X11
  #define glGetProcAddress(a) glXGetProcAddress ( \
    reinterpret_cast<const unsigned char*>(a)     \
  )
#endif

#ifndef GetExtension
  #define GetExtension(Type, ExtenName)     \
    ExtenName = (Type)                      \
    glGetProcAddress(STRINGIFY(ExtenName)); \
    if(!ExtenName)                          \
    {                                       \
      std:cout << "Your Computer Does Not " \
               << "Support GL Extension: "  \
               << STRINGIFY(ExtenName)      \
               << std::endl;                \
      exit(1);                              \
    }                                       \
    else                                    \
    {                                       \
      std::cout << "Loaded Extension: "     \
                << STRINGIFY(ExtenName)     \
                << std::endl;               \
    }
#endif
*/

bool updateGLProjectionMatrix(Glib::RefPtr<Gdk::GL::Context> glCtx, Glib::RefPtr<Gdk::GL::Window> glWin, int width, int height) {

	GLdouble aspect = (GLdouble) width/height;

	// *** OpenGL BEGIN ***
	if (!glWin->gl_begin(glCtx)) return false;

	glViewport(0, 0, width, height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60.0, aspect, 0.1, 10.0);
	glMatrixMode(GL_MODELVIEW);

	glWin->gl_end();
	// *** OpenGL END ***

	return true;

}