<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://thechange.wiki/index.php?action=history&amp;feed=atom&amp;title=Code%3Afullscreen_main.h</id>
	<title>Code:fullscreen main.h - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://thechange.wiki/index.php?action=history&amp;feed=atom&amp;title=Code%3Afullscreen_main.h"/>
	<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:fullscreen_main.h&amp;action=history"/>
	<updated>2026-04-28T22:56:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://thechange.wiki/index.php?title=Code:fullscreen_main.h&amp;diff=524&amp;oldid=prev</id>
		<title>Elie at 14:32, 30 November 2022</title>
		<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:fullscreen_main.h&amp;diff=524&amp;oldid=prev"/>
		<updated>2022-11-30T14:32:05Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:32, 30 November 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;C header for easy OpenGL programming. Gets rid of most boilerplate code.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;C header for easy OpenGL programming.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Gets rid of most boilerplate code. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;With this, you don't even implement &amp;lt;code&amp;gt;main()&amp;lt;/code&amp;gt; - you implement 3 functions &amp;lt;code&amp;gt;init()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;draw()&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;done()&amp;lt;/code&amp;gt;. For more info and examples of how to use it, check out https://github.com/Elie9001/opengl-starter-kit&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Code==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Code==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Elie</name></author>
	</entry>
	<entry>
		<id>https://thechange.wiki/index.php?title=Code:fullscreen_main.h&amp;diff=522&amp;oldid=prev</id>
		<title>Elie: Created page with &quot;C header for easy OpenGL programming. Gets rid of most boilerplate code.  ==Code== &lt;syntaxhighlight lang=&quot;c&quot;&gt; /***  Elie's OpenGL wrapper  Creates a fullscreen vsync'd context with game-style access to keyboard &amp; mouse.  Version 1.1 ***/ #pragma once  // This header file implements main(). // Here are the functions you must define in your own code: void init(); void draw(); void done();   /** Notes:  *  * The init() function is called once at startup.  This is the place...&quot;</title>
		<link rel="alternate" type="text/html" href="https://thechange.wiki/index.php?title=Code:fullscreen_main.h&amp;diff=522&amp;oldid=prev"/>
		<updated>2022-11-30T13:51:25Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;C header for easy OpenGL programming. Gets rid of most boilerplate code.  ==Code== &amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt; &lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;**  Elie&amp;#039;s OpenGL wrapper  Creates a fullscreen vsync&amp;#039;d context with game-style access to keyboard &amp;amp; mouse.  Version 1.1 **: &lt;/span&gt; #pragma once  // This header file implements main(). // Here are the functions you must define in your own code: void init(); void draw(); void done();   /** Notes:  *  * The init() function is called once at startup.  This is the place...&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;C header for easy OpenGL programming. Gets rid of most boilerplate code.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
/***&lt;br /&gt;
 Elie's OpenGL wrapper&lt;br /&gt;
 Creates a fullscreen vsync'd context with game-style access to keyboard &amp;amp; mouse.&lt;br /&gt;
 Version 1.1&lt;br /&gt;
***/&lt;br /&gt;
#pragma once&lt;br /&gt;
&lt;br /&gt;
// This header file implements main().&lt;br /&gt;
// Here are the functions you must define in your own code:&lt;br /&gt;
void init();&lt;br /&gt;
void draw();&lt;br /&gt;
void done();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/** Notes:&lt;br /&gt;
 *&lt;br /&gt;
 * The init() function is called once at startup.  This is the place to set up your shaders, textures, display lists, etc.&lt;br /&gt;
 * The draw() function is called at every frame.   This is the place for your OpenGL drawing code, such as calling your lists etc.&lt;br /&gt;
 * The done() function is called once at shutdown. This is the place to delete your shaders, textures, display lists, etc.&lt;br /&gt;
 *&lt;br /&gt;
 * The program keeps running until the user presses ESC.    (This can be overridden; see below)&lt;br /&gt;
 *&lt;br /&gt;
 * To access keyboard and mouse within your draw() function, read the following globals:&lt;br /&gt;
 *  keymap[] : ascii keys - For example, to check if the 'W' key is held down: code:  if (keymap['W']) { ... }  Note that you must use uppercase letters here.  Also, if you want to respond to a keypress only once when it's pressed (instead of on every frame the key is held down): code:  if (keymap['W']==KEY_FRESHLY_PRESSED) { ... }&lt;br /&gt;
 *  special_keymap[] : non-ascii keys, as defined by GLUT constants.&lt;br /&gt;
 *  _mouse_dx: mouse pointer motion (as fraction of window size) per frame&lt;br /&gt;
 *  _mouse_dy: mouse pointer motion (as fraction of window size) per frame&lt;br /&gt;
 * Or,&lt;br /&gt;
 * if you like standard controls (W,A,S,D + arrow keys), you can use these macros:&lt;br /&gt;
 *  keyboard_dz() : forward / backward&lt;br /&gt;
 *  keyboard_dy() :    jump / duck&lt;br /&gt;
 *  keyboard_dx() :      strafe&lt;br /&gt;
 * &lt;br /&gt;
 * Other globals:&lt;br /&gt;
 *  _screen_x, _screen_y      : The screen width &amp;amp; height, in pixels&lt;br /&gt;
 *  _screen_size              : Geometric average of width &amp;amp; height. Useful as a general &amp;quot;screen size&amp;quot; no matter the aspect ratio. Think of it as &amp;quot;if all the screen's pixels were rearranged in a square, it would be how many pixels across&amp;quot; = sqrt(_screen_x * _screen_y)&lt;br /&gt;
 *  _global_argc, _global_argv: Same as argc &amp;amp; argv from main().&lt;br /&gt;
 *&lt;br /&gt;
 * Compiler flags needed when you use this header file:&lt;br /&gt;
 *      -ffast-math -O -lGL -lglut -lm&lt;br /&gt;
 *&lt;br /&gt;
 * defines available:&lt;br /&gt;
 *  #define NO_ESCAPE           : Disable the default 'ESC to quit' functionality. And then you'll need the line '_exit_the_program = GL_TRUE;' somewhere in your draw() code. Otherwise your program will never quit, and you'll be stuck in fullscreen mode forever.&lt;br /&gt;
 *                                Proceed with caution. Beware of accidentally making a program that never exits!&lt;br /&gt;
 *&lt;br /&gt;
 *  #define VIEWPORT_SCALE 2.0  : This will effectively double your &amp;quot;viewport&amp;quot; size. In other words, the edges of your screen will be at coordinates -0.5 to 0.5, instead of -1.0 to 1.0.&lt;br /&gt;
 *                                You might need this feature is you're using a lot of GL_POINTS with point sprites, to prevent them from popping (appearing/disappearing when they are near the screen edges). This is a workaround for OpenGL's badly-designed standard for point-sprites.&lt;br /&gt;
 *                                Hopefully this won't actually render extra pixels that you never see. I benchmarked it on an old Radeon graphics card and there was no performance loss. No wasted computations as far as I know. But it should probably be tested on more hardware just to make sure.&lt;br /&gt;
 *                                P.S. You can also use other values for VIEWPORT_SCALE, such as 1.2 or 1.5. Just beware of scales too big - you don't want your viewport to exceed GL_MAX_VIEWPORT_DIMS.&lt;br /&gt;
 *&lt;br /&gt;
 *  #define USE_PRE_INIT        : You get to define an extra function 'pre_init()' which gets called BEFORE the fullscreen window/context gets created. This gives you a chance to quit before the program starts, by setting _exit_the_program = GL_TRUE;&lt;br /&gt;
 *                                One use-case might be: Your program requires command-line arguments, and if the args are missing, you want to only display a message in the terminal (no OpenGL).&lt;br /&gt;
 *                                                       argc &amp;amp; argv are available as globals: _global_argc, _global_argv&lt;br /&gt;
 *&lt;br /&gt;
 *  #define USE_MULTISAMPLING   : Basic anti-aliasing mode. Good for triangles/quads/polygons, but useless for GL_POINTS sprites, usually.&lt;br /&gt;
 *&lt;br /&gt;
 *  #define SHOW_ERROR_LOG      : Report OpenGL errors in the terminal.&lt;br /&gt;
 *&lt;br /&gt;
 *  #define SHOW_FRAME_RATE     : Report the number of frames-per-second in the terminal.&lt;br /&gt;
 *&lt;br /&gt;
 *&lt;br /&gt;
 * Author: Elie Goldman Smith&lt;br /&gt;
 * This file is too trivial to copyright (since it's mostly boilerplate code),&lt;br /&gt;
 * so it's in the public domain.&lt;br /&gt;
 *&lt;br /&gt;
 * Feel free to copy this file into any project.&lt;br /&gt;
**/&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;ctype.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#ifdef USE_GLEW&lt;br /&gt;
 #include &amp;lt;GL/glew.h&amp;gt;&lt;br /&gt;
#else&lt;br /&gt;
 #define GL_GLEXT_PROTOTYPES&lt;br /&gt;
 #include &amp;lt;GL/gl.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;GL/glext.h&amp;gt;&lt;br /&gt;
#endif&lt;br /&gt;
#include &amp;lt;GL/glut.h&amp;gt;&lt;br /&gt;
#define RND()   (rand()*(2.0f/RAND_MAX)-1.0f) // random number from -1 to 1&lt;br /&gt;
#define RND01() (rand()*(1.0f/RAND_MAX))      // random number from  0 to 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int _screen_x = 8;&lt;br /&gt;
int _screen_y = 8;&lt;br /&gt;
GLfloat _screen_size = 8;&lt;br /&gt;
&lt;br /&gt;
#define KEY_FRESHLY_PRESSED 3&lt;br /&gt;
&lt;br /&gt;
char keymap[256] = {0};&lt;br /&gt;
#ifdef NO_ESCAPE&lt;br /&gt;
void gcb_key_down(unsigned char key, int x, int y) { keymap[toupper(key)] = keymap[tolower(key)] = KEY_FRESHLY_PRESSED; }&lt;br /&gt;
#else&lt;br /&gt;
void gcb_key_down(unsigned char key, int x, int y) { keymap[toupper(key)] = keymap[tolower(key)] = KEY_FRESHLY_PRESSED; if (key == 27) exit(0); }&lt;br /&gt;
#endif&lt;br /&gt;
void gcb_key_up  (unsigned char key, int x, int y) { keymap[toupper(key)] = keymap[tolower(key)] = 0;} // XXX: toupper only works for letters, not numbers or punctuation. We should really do something more universal like keymap[shiftless(key)] and i would have to define the shiftless() function.&lt;br /&gt;
&lt;br /&gt;
char special_keymap[256] = {0};&lt;br /&gt;
void gcb_special_key_down(int key, int x, int y) { special_keymap[(unsigned char)key] = KEY_FRESHLY_PRESSED; }&lt;br /&gt;
void gcb_special_key_up  (int key, int x, int y) { special_keymap[(unsigned char)key] = 0; }&lt;br /&gt;
&lt;br /&gt;
#define keyboard_dz()     (!!keymap['W']-!!keymap['S']+!!special_keymap[GLUT_KEY_UP     ]-!!special_keymap[GLUT_KEY_DOWN     ]                            ) // forward/backward&lt;br /&gt;
#define keyboard_dy()     (!!keymap['Q']-!!keymap['Z']+!!special_keymap[GLUT_KEY_PAGE_UP]-!!special_keymap[GLUT_KEY_PAGE_DOWN]+!!keymap['E']-!!keymap['C']) // jump/duck&lt;br /&gt;
#define keyboard_dx()     (!!keymap['D']-!!keymap['A']+!!special_keymap[GLUT_KEY_RIGHT  ]-!!special_keymap[GLUT_KEY_LEFT     ]                            ) // strafe&lt;br /&gt;
&lt;br /&gt;
int _exit_the_program = GL_FALSE;&lt;br /&gt;
&lt;br /&gt;
GLfloat _mouse_x = 0; // mouse pointer position is&lt;br /&gt;
GLfloat _mouse_y = 0; // normalized to _screen_size&lt;br /&gt;
GLfloat _mouse_dx = 0;&lt;br /&gt;
GLfloat _mouse_dy = 0;&lt;br /&gt;
char _mouse_button_map[8] = {0};&lt;br /&gt;
&lt;br /&gt;
void gcb_mouse_motion_with_pointer(int x, int y) {&lt;br /&gt;
 _mouse_dx = -_mouse_x;&lt;br /&gt;
 _mouse_dy = -_mouse_y;&lt;br /&gt;
 _mouse_x = (x - _screen_x/2) * 2.0f/_screen_size;&lt;br /&gt;
 _mouse_y = (y - _screen_y/2) *-2.0f/_screen_size;&lt;br /&gt;
 _mouse_dx += _mouse_x;&lt;br /&gt;
 _mouse_dy += _mouse_y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void gcb_mouse_motion_pointerless(int x, int y) {&lt;br /&gt;
 int center_x = _screen_x/2;&lt;br /&gt;
 int center_y = _screen_y/2;&lt;br /&gt;
 x -= center_x;&lt;br /&gt;
 y -= center_y;&lt;br /&gt;
 if (x != 0 || y != 0) {&lt;br /&gt;
  _mouse_dx = x *-2.0f/_screen_size;&lt;br /&gt;
  _mouse_dy = y * 2.0f/_screen_size;&lt;br /&gt;
  glutWarpPointer(center_x, center_y);&lt;br /&gt;
 }&lt;br /&gt;
 _mouse_x = _mouse_y = 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void gcb_mouse_click(int button, int state, int x, int y) {&lt;br /&gt;
 if (button &amp;gt;= 0 &amp;amp;&amp;amp; button &amp;lt; 8) _mouse_button_map[button] = (state==GLUT_DOWN)*KEY_FRESHLY_PRESSED;&lt;br /&gt;
 _mouse_x = (x - _screen_x/2) * 2.0f/_screen_size;&lt;br /&gt;
 _mouse_y = (y - _screen_y/2) *-2.0f/_screen_size;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void show_mouse() {&lt;br /&gt;
 glutMotionFunc       (gcb_mouse_motion_with_pointer);&lt;br /&gt;
 glutPassiveMotionFunc(gcb_mouse_motion_with_pointer);&lt;br /&gt;
 glutSetCursor(GLUT_CURSOR_INHERIT);&lt;br /&gt;
}&lt;br /&gt;
void hide_mouse() {&lt;br /&gt;
 glutMotionFunc       (gcb_mouse_motion_pointerless);&lt;br /&gt;
 glutPassiveMotionFunc(gcb_mouse_motion_pointerless);&lt;br /&gt;
 glutSetCursor(GLUT_CURSOR_NONE);&lt;br /&gt;
 _mouse_x = _mouse_y = 0; glutWarpPointer(_screen_x/2, _screen_y/2);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// btw, my 'gcb' prefix just stands for &amp;quot;glut call-back function&amp;quot;&lt;br /&gt;
void gcb_draw_frame()&lt;br /&gt;
{&lt;br /&gt;
 draw();&lt;br /&gt;
 if (_exit_the_program) exit(0);&lt;br /&gt;
&lt;br /&gt;
 // remove the KEY_FRESHLY_PRESSED&lt;br /&gt;
 for (int i=0; i&amp;lt;256; i++) {&lt;br /&gt;
  keymap[i]         &amp;amp;= 1;&lt;br /&gt;
  special_keymap[i] &amp;amp;= 1;&lt;br /&gt;
 }&lt;br /&gt;
 for (int i=0; i&amp;lt;8; i++) {&lt;br /&gt;
  _mouse_button_map[i] &amp;amp;= 1;&lt;br /&gt;
 }&lt;br /&gt;
 // smooth out the times when mouse dx &amp;amp; dy don't get updated&lt;br /&gt;
 _mouse_dx *= 0.875f;&lt;br /&gt;
 _mouse_dy *= 0.875f;&lt;br /&gt;
 &lt;br /&gt;
 #ifdef SHOW_FRAME_RATE&lt;br /&gt;
 static int frame=0;&lt;br /&gt;
 if (++frame &amp;gt;= 64) {&lt;br /&gt;
  static int prev=0;&lt;br /&gt;
  int t = glutGet(GLUT_ELAPSED_TIME);&lt;br /&gt;
  if (prev) {&lt;br /&gt;
   printf(&amp;quot; %d FPS &amp;quot;, (int)(frame*1000.0/(t-prev)));&lt;br /&gt;
   fflush(stdout);&lt;br /&gt;
  }&lt;br /&gt;
  prev=t; frame=0;&lt;br /&gt;
 }&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
 glutSwapBuffers();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void gcb_reshape_window(int width, int height)&lt;br /&gt;
{&lt;br /&gt;
 #ifdef VIEWPORT_SCALE&lt;br /&gt;
 glViewport((GLint)( width*0.5*(1.0-VIEWPORT_SCALE)),&lt;br /&gt;
            (GLint)(height*0.5*(1.0-VIEWPORT_SCALE)),&lt;br /&gt;
            (GLint)( width*VIEWPORT_SCALE),&lt;br /&gt;
            (GLint)(height*VIEWPORT_SCALE));&lt;br /&gt;
 #else&lt;br /&gt;
 glViewport(0, 0, (GLint)width, (GLint)height); // default behavior&lt;br /&gt;
 #endif&lt;br /&gt;
 _screen_x = width;&lt;br /&gt;
 _screen_y = height;&lt;br /&gt;
 _screen_size = sqrtf((float)_screen_x*_screen_y);&lt;br /&gt;
 _mouse_x = _mouse_y = 0; glutWarpPointer(_screen_x/2, _screen_y/2);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#ifdef SHOW_ERROR_LOG&lt;br /&gt;
void gcb_errors(GLenum source, GLenum type, GLuint id, GLenum severity,&lt;br /&gt;
                GLsizei length, const GLchar* message, const void* userParam) {&lt;br /&gt;
 fprintf(stderr,&amp;quot;GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n&amp;quot;,&lt;br /&gt;
           (type == GL_DEBUG_TYPE_ERROR ? &amp;quot;** GL ERROR **&amp;quot; : &amp;quot;&amp;quot;),&lt;br /&gt;
            type, severity, message);&lt;br /&gt;
}&lt;br /&gt;
#endif&lt;br /&gt;
#ifdef USE_PRE_INIT&lt;br /&gt;
void pre_init();&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int    _global_argc;&lt;br /&gt;
char **_global_argv;&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv) {&lt;br /&gt;
 _global_argc = argc;&lt;br /&gt;
 _global_argv = argv;&lt;br /&gt;
 #ifdef USE_PRE_INIT&lt;br /&gt;
 pre_init();  if (_exit_the_program) return 1;&lt;br /&gt;
 #endif&lt;br /&gt;
 #ifdef USE_MULTISAMPLING&lt;br /&gt;
 glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE);&lt;br /&gt;
 #else&lt;br /&gt;
 glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);&lt;br /&gt;
 #endif&lt;br /&gt;
 glutInitWindowSize(256,144);&lt;br /&gt;
 glutInit(&amp;amp;argc, argv);&lt;br /&gt;
 glutCreateWindow(&amp;quot;view&amp;quot;);&lt;br /&gt;
 #ifdef USE_GLEW&lt;br /&gt;
 glewInit();&lt;br /&gt;
 #endif&lt;br /&gt;
 glutReshapeFunc(gcb_reshape_window);&lt;br /&gt;
 glutKeyboardFunc(gcb_key_down);&lt;br /&gt;
 glutKeyboardUpFunc(gcb_key_up);&lt;br /&gt;
 glutSpecialFunc(gcb_special_key_down);&lt;br /&gt;
 glutSpecialUpFunc(gcb_special_key_up);&lt;br /&gt;
 glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF);&lt;br /&gt;
 glutMouseFunc(gcb_mouse_click);&lt;br /&gt;
 glutMotionFunc(gcb_mouse_motion_pointerless);&lt;br /&gt;
 glutPassiveMotionFunc(gcb_mouse_motion_pointerless);&lt;br /&gt;
 glutSetCursor(GLUT_CURSOR_NONE);&lt;br /&gt;
 glutDisplayFunc(gcb_draw_frame);&lt;br /&gt;
 glutIdleFunc(gcb_draw_frame);&lt;br /&gt;
 glutFullScreen();&lt;br /&gt;
&lt;br /&gt;
 #ifdef SHOW_ERROR_LOG&lt;br /&gt;
 glEnable(GL_DEBUG_OUTPUT);&lt;br /&gt;
 glDebugMessageCallback(gcb_errors, 0);&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
 init();&lt;br /&gt;
 atexit(done);&lt;br /&gt;
 glutMainLoop();&lt;br /&gt;
 return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 // other input code that might be needed somewhere:&lt;br /&gt;
 int mod = glutGetModifiers();&lt;br /&gt;
 if (mod &amp;amp; GLUT_ACTIVE_SHIFT) {}&lt;br /&gt;
 if (mod &amp;amp; GLUT_ACTIVE_CTRL)  {}&lt;br /&gt;
 if (mod &amp;amp; GLUT_ACTIVE_ALT)   {}&lt;br /&gt;
*/&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elie</name></author>
	</entry>
</feed>