Control: tags -1 pending

On Sun, 2016-06-19 at 17:33 +0100, James Cowgill wrote:
> Source: pink-pony
> Version: 1.4.1-1
> Severity: wishlist
> Tags: sid stretch patch
> 
> Hi,
> 
> At some point I would like to remove the old version of glfw which is
> no longer maintained upstream. The last release was in 2013.
> 
> To do this I've ported pink-pony to glfw3. Most of the porting was
> straightforward although I had to make some large changes to pass the
> new GLFWwindow pointer to the various classes and ensure the keycodes
> from the old config file work with GLFW3.

I'm going to upload this now. I found a small regression in my patch
where the game used the incorrect video mode on the first run. If any
more are found I'll happily take a look at them.

The revised glfw3.patch which will be uploaded is attached.

Thanks,
James
Description: Port to GLFW 3
 The most significant changes here are:
 - Having to pass a GLFWwindow* around to various classes.
 - The key_to_glfw3 function which is needed to allow key ids from old config
   files to work with GLFW 3.
Author: James Cowgill <jcowg...@debian.org>
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/external/flextGL/flextGL.c
+++ b/external/flextGL/flextGL.c
@@ -2,7 +2,7 @@
 /* Do not edit. */
 
 #include "flextGL.h"
-#include "GL/glfw.h"
+#include "GLFW/glfw3.h"
 
 #include <stdio.h>
 
@@ -14,11 +14,11 @@ extern "C" {
 
 void flextLoadOpenGLFunctions(void);
 
-int flextInit(void)
+int flextInit(GLFWwindow* window)
 {
   
-    int major = glfwGetWindowParam(GLFW_OPENGL_VERSION_MAJOR);
-    int minor = glfwGetWindowParam(GLFW_OPENGL_VERSION_MINOR);
+    int major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
+    int minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
 
     flextLoadOpenGLFunctions();
     
--- a/external/flextGL/flextGL.h
+++ b/external/flextGL/flextGL.h
@@ -6677,7 +6677,10 @@ extern int FLEXT_ARB_geometry_shader4;
 extern int FLEXT_EXT_transform_feedback;
 extern int FLEXT_EXT_texture_filter_anisotropic;
 
-int flextInit(void);
+struct GLFWwindow;
+typedef struct GLFWwindow GLFWwindow;
+
+int flextInit(GLFWwindow* window);
 
 #define FLEXT_MAJOR_VERSION 2
 #define FLEXT_MINOR_VERSION 0
--- a/src/Config.cc
+++ b/src/Config.cc
@@ -4,7 +4,7 @@
 Config::Config()
     : width(800),
       height(600),
-      window_mode(GLFW_FULLSCREEN),
+      window_fullscreen(true),
       fsaa_samples(4),
       swap_interval(1),
       polygon_mode(GL_FILL),
@@ -108,7 +108,7 @@ void Config::set_value(string name, stri
     
     int ival = 0;
     float fval = 0.0f;
-    int winmodeval = GLFW_WINDOW;
+    bool winmodeval = false;
     GLenum polymodeval = GL_FILL;
     string sval = "";
     V2f vec2val;
@@ -153,9 +153,9 @@ void Config::set_value(string name, stri
 
     if (value.find("window") != string::npos &&
         value.find("window") < value.find(';')) {
-        winmodeval = GLFW_WINDOW;
+        winmodeval = false;
     } else {
-        winmodeval = GLFW_FULLSCREEN;
+        winmodeval = true;
     }
 
     if (value.find("fill") != string::npos &&
@@ -177,7 +177,7 @@ void Config::set_value(string name, stri
     
     if (name == "width") width = ival;        
     else if (name == "height") height = ival;
-    else if (name == "window_mode") window_mode = winmodeval;
+    else if (name == "window_mode") window_fullscreen = winmodeval;
     else if (name == "fsaa_samples") fsaa_samples = ival;
     else if (name == "swap_interval") swap_interval = ival;
     else if (name == "polygon_mode") polygon_mode = polymodeval;
@@ -321,7 +321,7 @@ bool Config::write_file(string filename)
     os << "height = " << height << ";" << endl;
     os << "swap_interval = " << swap_interval <<  ";" << endl;
     os << "window_mode = ";
-    if (window_mode == GLFW_WINDOW)
+    if (!window_fullscreen)
         os << "window;" << endl;
     else
         os << "fullscreen;" << endl;
--- a/src/Config.hh
+++ b/src/Config.hh
@@ -10,7 +10,7 @@ class Config
     
     // Window properties:
     int width, height;
-    int window_mode;
+    bool window_fullscreen;
     int fsaa_samples;
     int swap_interval;
     GLenum polygon_mode;
--- a/src/Menu.cc
+++ b/src/Menu.cc
@@ -7,21 +7,21 @@
 
 Menu* Menu::callback_menu = NULL;
 
-void GLFWCALL menu_mouse_callback(int button, int action)
+void menu_mouse_callback(GLFWwindow* window, int button, int action, int mods)
 {
     if (Menu::callback_menu != NULL)
         Menu::callback_menu->mouse_callback(button, action);
 }
 
-void GLFWCALL menu_resize_callback(int width, int height)
+void menu_resize_callback(GLFWwindow* window, int width, int height)
 {
     if (Menu::callback_menu != NULL)
         Menu::callback_menu->resize_callback(width, height);
 }
 
-void GLFWCALL menu_key_callback(int key, int state)
+void menu_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
 {
-    if (state != GLFW_PRESS || Menu::callback_menu == NULL ) 
+    if (action != GLFW_PRESS || Menu::callback_menu == NULL )
         return;
 
     if (key == GLFW_KEY_SPACE)
@@ -34,7 +34,7 @@ void GLFWCALL menu_key_callback(int key,
 
 void Menu::toggle_fullscreen(void)
 {
-    config->window_mode = (config->window_mode == GLFW_WINDOW)?GLFW_FULLSCREEN:GLFW_WINDOW;
+    config->window_fullscreen = !config->window_fullscreen;
     status = RESET;
     running = false;    
 }
@@ -48,9 +48,9 @@ void Menu::toggle_music(void)
 
 void Menu::mouse_callback(int button, int action)
 {
-    int x,y;
+    double x,y;
 
-    glfwGetMousePos(&x, &y);
+    glfwGetCursorPos(window, &x, &y);
 
     if (action == GLFW_PRESS) {
         V2f pos(x,screen_size.y - y);
@@ -84,10 +84,12 @@ void Menu::resize_callback(int width, in
 #define TEXT_COLOR Color4f(1,1,1,0.5)
 
 Menu::Menu (Config* config, 
-            Skydome* skydome)
+            Skydome* skydome,
+            GLFWwindow* window)
     : active_screen(MAIN_SCREEN),
       config(config),
       skydome(skydome),
+      window(window),
       heightmap(NULL),
       logo_button(config->resource_dir + "textures/logo.png"),
       start_button("Start", config),
@@ -136,7 +138,7 @@ Menu::Menu (Config* config,
     load_levels(config->resource_dir + config->levels_file);
 
     int w,h;
-    glfwGetWindowSize(&w,&h);
+    glfwGetWindowSize(window, &w, &h);
     resize_callback(w,h);
 
     next_level(0);
@@ -151,15 +153,14 @@ Menu::Menu (Config* config,
 
 void Menu::setup_settings(void)
 {
-    GLFWvidmode vidmodes[100];
-
-    int modes_found = glfwGetVideoModes(vidmodes, 100);
+    int modes_found;
+    const GLFWvidmode* vidmodes = glfwGetVideoModes(glfwGetPrimaryMonitor(), &modes_found);
     
     resolutions.resize(modes_found);
 
     for (int i = 0; i < modes_found; ++i) {
-        resolutions[i] = V2i(vidmodes[i].Width,
-                             vidmodes[i].Height);
+        resolutions[i] = V2i(vidmodes[i].width,
+                             vidmodes[i].height);
     }
 
     // resolutions.push_back(V2i( 640, 480));
@@ -187,7 +188,7 @@ void Menu::setup_settings(void)
         particle_setting = 3;
     }
 
-    if (config->window_mode == GLFW_WINDOW) {
+    if (!config->window_fullscreen) {
         fullscreen_setting = 0;
     } else {
         fullscreen_setting = 1;
@@ -242,10 +243,10 @@ void Menu::load_settings(void)
 
     if (fullscreen_setting == 0) {
         fullscreen_text.set_text("Window");
-        config->window_mode = GLFW_WINDOW;
+        config->window_fullscreen = false;
     } else {
         fullscreen_text.set_text("Fullscreen");
-        config->window_mode = GLFW_FULLSCREEN;
+        config->window_fullscreen = true;
     }
 
     if (minimap_setting == 0) {
@@ -693,16 +694,16 @@ void Menu::reload_level(string level)
 
 Menu::MenuStatus Menu::run(void)
 {
-    if (config->window_mode == GLFW_FULLSCREEN)
-        glfwEnable(GLFW_MOUSE_CURSOR);
+    if (config->window_fullscreen)
+        glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
 
     status = START;
     running = true;
 
     callback_menu = this;
-    glfwSetMouseButtonCallback(menu_mouse_callback);
-    glfwSetWindowSizeCallback(menu_resize_callback);
-    glfwSetKeyCallback(menu_key_callback);
+    glfwSetMouseButtonCallback(window, menu_mouse_callback);
+    glfwSetWindowSizeCallback(window, menu_resize_callback);
+    glfwSetKeyCallback(window, menu_key_callback);
 
 
     while (running) {
@@ -713,25 +714,26 @@ Menu::MenuStatus Menu::run(void)
 
         draw();
         
-        glfwSwapBuffers();
+        glfwSwapBuffers(window);
+        glfwPollEvents();
 
-        if (glfwGetKey( GLFW_KEY_ESC ) || 
-            !glfwGetWindowParam( GLFW_OPENED )) {
+        if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS ||
+            glfwWindowShouldClose(window)) {
             status = QUIT;
             running = false;
-        } else if (glfwGetKey(GLFW_KEY_ENTER)) {
+        } else if (glfwGetKey(window, GLFW_KEY_ENTER) == GLFW_PRESS) {
             status = START;
             running = false;
         }
     }
 
-    glfwSetMouseButtonCallback(NULL);
-    glfwSetWindowSizeCallback(NULL);
-    glfwSetKeyCallback(NULL);
+    glfwSetMouseButtonCallback(window, NULL);
+    glfwSetWindowSizeCallback(window, NULL);
+    glfwSetKeyCallback(window, NULL);
     callback_menu = NULL;
 
-    if (config->window_mode == GLFW_FULLSCREEN)
-        glfwDisable(GLFW_MOUSE_CURSOR);
+    if (config->window_fullscreen)
+        glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
 
     return status;
 }
--- a/src/Menu.hh
+++ b/src/Menu.hh
@@ -27,6 +27,7 @@ class Menu
 
     Config* config;
     Skydome* skydome;
+    GLFWwindow* window;
 
     auto_ptr<Heightmap> heightmap;
 
@@ -137,7 +138,8 @@ class Menu
     void toggle_music(void);
 
     Menu(Config* config, 
-         Skydome* skydome);
+         Skydome* skydome,
+         GLFWwindow* window);
 
     MenuStatus run(void);
 
--- a/src/Pony.cc
+++ b/src/Pony.cc
@@ -97,16 +97,116 @@ Color4f rgbColor(const Color4f& hsvColor
     return rgbColor;
 }
 
+// Converts a glfw2 keycode from the config file to a glfw3 keycode
+static int key_to_glfw3(int encoded_key)
+{
+    static const int keymap[] =
+    {
+        GLFW_KEY_ESCAPE,
+        GLFW_KEY_F1,
+        GLFW_KEY_F2,
+        GLFW_KEY_F3,
+        GLFW_KEY_F4,
+        GLFW_KEY_F5,
+        GLFW_KEY_F6,
+        GLFW_KEY_F7,
+        GLFW_KEY_F8,
+        GLFW_KEY_F9,
+        GLFW_KEY_F10,
+        GLFW_KEY_F11,
+        GLFW_KEY_F12,
+        GLFW_KEY_F13,
+        GLFW_KEY_F14,
+        GLFW_KEY_F15,
+        GLFW_KEY_F16,
+        GLFW_KEY_F17,
+        GLFW_KEY_F18,
+        GLFW_KEY_F19,
+        GLFW_KEY_F20,
+        GLFW_KEY_F21,
+        GLFW_KEY_F22,
+        GLFW_KEY_F23,
+        GLFW_KEY_F24,
+        GLFW_KEY_F25,
+        GLFW_KEY_UP,
+        GLFW_KEY_DOWN,
+        GLFW_KEY_LEFT,
+        GLFW_KEY_RIGHT,
+        GLFW_KEY_LEFT_SHIFT,
+        GLFW_KEY_RIGHT_SHIFT,
+        GLFW_KEY_LEFT_CONTROL,
+        GLFW_KEY_RIGHT_CONTROL,
+        GLFW_KEY_LEFT_ALT,
+        GLFW_KEY_RIGHT_ALT,
+        GLFW_KEY_TAB,
+        GLFW_KEY_ENTER,
+        GLFW_KEY_BACKSPACE,
+        GLFW_KEY_INSERT,
+        GLFW_KEY_DELETE,
+        GLFW_KEY_PAGE_UP,
+        GLFW_KEY_PAGE_DOWN,
+        GLFW_KEY_HOME,
+        GLFW_KEY_END,
+        GLFW_KEY_KP_0,
+        GLFW_KEY_KP_1,
+        GLFW_KEY_KP_2,
+        GLFW_KEY_KP_3,
+        GLFW_KEY_KP_4,
+        GLFW_KEY_KP_5,
+        GLFW_KEY_KP_6,
+        GLFW_KEY_KP_7,
+        GLFW_KEY_KP_8,
+        GLFW_KEY_KP_9,
+        GLFW_KEY_KP_DIVIDE,
+        GLFW_KEY_KP_MULTIPLY,
+        GLFW_KEY_KP_SUBTRACT,
+        GLFW_KEY_KP_ADD,
+        GLFW_KEY_KP_DECIMAL,
+        GLFW_KEY_KP_EQUAL,
+        GLFW_KEY_KP_ENTER,
+        GLFW_KEY_NUM_LOCK,
+        GLFW_KEY_CAPS_LOCK,
+        GLFW_KEY_SCROLL_LOCK,
+        GLFW_KEY_PAUSE,
+        GLFW_KEY_LEFT_SUPER,
+        GLFW_KEY_RIGHT_SUPER,
+        GLFW_KEY_MENU,
+    };
+
+    const int keymap_size = sizeof(keymap) / sizeof(int);
+
+    if (encoded_key >= 'a' && encoded_key <= 'z')
+    {
+        // Convert lowercase to uppercase
+        return encoded_key - 'a' + 'A';
+    }
+    else if (encoded_key >= ' ' && encoded_key <= '~')
+    {
+        // Other printable ASCII characters are left as is
+        return encoded_key;
+    }
+    else if (encoded_key >= 0x101 && encoded_key < 0x101 + keymap_size)
+    {
+        // Transform using mapping array
+        return keymap[encoded_key - 0x101];
+    }
+    else
+    {
+        // Invalid key
+        return 0;
+    }
+}
+
 Pony::Pony(int i, Config* config, ParticleSystem* particle_system)
     : pos(config->pony_start[i]),
       angle(config->pony_start_angle[i]),
       speed(config->pony_start_speed),
       slope_angle(0),
       camera_pos(pos-V2f(sin(angle), cos(angle))),
-      up(config->pony_up[i]),
-      down(config->pony_down[i]),
-      left(config->pony_left[i]),
-      right(config->pony_right[i]),
+      up(key_to_glfw3(config->pony_up[i])),
+      down(key_to_glfw3(config->pony_down[i])),
+      left(key_to_glfw3(config->pony_left[i])),
+      right(key_to_glfw3(config->pony_right[i])),
       shader(config->resource_dir + config->pony_shader),
       mesh(),
       animation(config->resource_dir + "models/Pony-animated.pskeleton"),
@@ -154,36 +254,35 @@ Pony::Pony(int i, Config* config, Partic
 
 Pony::Decision PlayerPony::decide(PonyGame* game, int i)
 {
+    GLFWwindow* window = game->screen()->get_window();
     Decision decision = {0.0f, 0.0f};
     float& accel = decision.acceleration;
     float& steer = decision.steer;
 
-    if (glfwGetKey(up) == GLFW_PRESS)
+    if (glfwGetKey(window, up) == GLFW_PRESS)
         accel += 1.0;
-    if (glfwGetKey(down) == GLFW_PRESS)
+    if (glfwGetKey(window, down) == GLFW_PRESS)
         accel -= 1.0;
 
-    if (glfwGetKey(left) == GLFW_PRESS)
+    if (glfwGetKey(window, left) == GLFW_PRESS)
         steer += 1.0;
-    if (glfwGetKey(right) == GLFW_PRESS)
+    if (glfwGetKey(window, right) == GLFW_PRESS)
         steer -= 1.0;
 
-    if (glfwGetJoystickParam(i,GLFW_PRESENT) == GL_TRUE) {
+    if (glfwJoystickPresent(i) == GL_TRUE) {
 
-        float axes[10];
-
-        int n = glfwGetJoystickPos(i,axes,10);
+        int n;
+        const float* axes = glfwGetJoystickAxes(i, &n);
 
         if (n >= 2) {
 
-            if (fabs(axes[0]) < 0.2) axes[0] = 0.0;
+            if (fabs(axes[0]) >= 0.2)
+                steer -= axes[0] * 2;
             //accel += axes[1];
-            steer -= axes[0]*2;
         }
 
-        unsigned char buttons[20];
-
-        int button_count = glfwGetJoystickButtons(i, buttons, 20);
+        int button_count;
+        const unsigned char* buttons = glfwGetJoystickButtons(i, &button_count);
 
         if (button_count >= 2) {
             if (buttons[0] == GLFW_PRESS)
--- a/src/PonyGame.cc
+++ b/src/PonyGame.cc
@@ -156,7 +156,7 @@ bool PonyGame::start(PonyPoints& points)
 
     cout << m_config->player_count << " ponies." << endl;
 
-    GLboolean f1_pressed = glfwGetKey(GLFW_KEY_F1);
+    GLboolean f1_pressed = glfwGetKey(m_screen->get_window(), GLFW_KEY_F1);
 
     ParticleExplosionSource explosion_source(particle_system);
 
@@ -376,25 +376,26 @@ bool PonyGame::start(PonyPoints& points)
 
         getErrors();
         calc_fps();
-        glfwSwapBuffers();
+        glfwSwapBuffers(m_screen->get_window());
+        glfwPollEvents();
 
         // Check if still running
         
-        if(glfwGetKey( GLFW_KEY_ESC ) ||
-           !glfwGetWindowParam( GLFW_OPENED )) {
+        if(glfwGetKey(m_screen->get_window(), GLFW_KEY_ESCAPE) ||
+           glfwWindowShouldClose(m_screen->get_window())) {
             running = false;
             run_game = false;
             delay = 0.0;
         }
 
 
-        if (glfwGetKey(GLFW_KEY_F1) && !f1_pressed) {
+        if (glfwGetKey(m_screen->get_window(), GLFW_KEY_F1) && !f1_pressed) {
             int current_volume = Mix_VolumeMusic(-1);
             Mix_VolumeMusic(std::min(128, current_volume + 63) % 128);
             m_config->music_volume = Mix_VolumeMusic(-1);
         }
 
-        f1_pressed = glfwGetKey(GLFW_KEY_F1);
+        f1_pressed = glfwGetKey(m_screen->get_window(), GLFW_KEY_F1);
     }
 
     return run_game;
--- a/src/SplitScreen.cc
+++ b/src/SplitScreen.cc
@@ -2,14 +2,15 @@
 
 SplitScreen* active_screen = NULL;
 
-void GLFWCALL screen_size_callback(int width, int height)
+void screen_size_callback(GLFWwindow* window, int width, int height)
 {
     if (active_screen != NULL)
         active_screen->resize(width, height);
 }
 
-SplitScreen::SplitScreen(int width, int height, int subscreens)
-    : size(width, height),
+SplitScreen::SplitScreen(GLFWwindow* window, int width, int height, int subscreens)
+    : window(window),
+      size(width, height),
       subscreen_count(subscreens),
       current(0)
 {
@@ -20,14 +21,19 @@ SplitScreen::~SplitScreen()
 {
     if (active_screen == this) {
         active_screen = NULL;
-        glfwSetWindowSizeCallback(NULL);
+        glfwSetWindowSizeCallback(window, NULL);
     }
 }
 
 void SplitScreen::set_glfw_callback()
 {
     active_screen = this;
-    glfwSetWindowSizeCallback(screen_size_callback);
+    glfwSetWindowSizeCallback(window, screen_size_callback);
+
+    // Update window size immediately
+    int width, height;
+    glfwGetWindowSize(window, &width, &height);
+    resize(width, height);
 }
 
 void SplitScreen::split(int subscreens)
--- a/src/SplitScreen.hh
+++ b/src/SplitScreen.hh
@@ -6,6 +6,7 @@
 
 class SplitScreen
 {
+    GLFWwindow* window;
     V2i size;
 
     int subscreen_count;
@@ -17,9 +18,14 @@ class SplitScreen
     
     public:
 
-    SplitScreen(int width, int height, int subscreens);
+    SplitScreen(GLFWwindow* window, int width, int height, int subscreens);
     ~SplitScreen();
 
+    GLFWwindow* get_window()
+    {
+        return window;
+    }
+
     V2i get_size()
     {
         return size;
--- a/src/cinquo.hh
+++ b/src/cinquo.hh
@@ -1,9 +1,10 @@
 #pragma once
 
 #define ILUT_USE_OPENGL
+#define GLFW_INCLUDE_GLU
 
 #include "flextGL.h"
-#include <GL/glfw.h>
+#include <GLFW/glfw3.h>
 #include <string>
 #include <iostream>
 #include <vector>
--- a/src/main.cc
+++ b/src/main.cc
@@ -33,21 +33,13 @@ int main(int argc, char** argv)
     }
     
     glfwInit();
-    glfwOpenWindowHint(GLFW_FSAA_SAMPLES, config.fsaa_samples);
-
-    glfwOpenWindow(config.width, config.height, // width, height
-                   0, 0, 0, 0,                  // R, G, B, A
-                   24, 8,                       // depth, stencil
-                   config.window_mode);         // GLFW_WINDOW | GLFW_FULLSCREEN
-
-    glfwSetWindowTitle("Pink Pony <3");
-    glfwSwapInterval(config.swap_interval);
-
-    if (!flextInit()) {
-        return 1;
-    }
-    
-    bool reset_video = false;
+    glfwWindowHint(GLFW_SAMPLES, config.fsaa_samples);
+    glfwWindowHint(GLFW_DEPTH_BITS, 24);
+    glfwWindowHint(GLFW_STENCIL_BITS, 8);
+
+    bool done_flext_init = false;
+    bool reset_video = true;
+    GLFWwindow* window = NULL;
 
     Mix_Music* music = NULL;
     start_music(&music, config.resource_dir + config.background_music);
@@ -55,26 +47,32 @@ int main(int argc, char** argv)
     while (running) {
 
         if (reset_video) {
+            if (window != NULL)
+                glfwDestroyWindow(window);
 
-            glfwTerminate();
-
-            glfwInit();
-            glfwOpenWindowHint(GLFW_FSAA_SAMPLES, config.fsaa_samples);
-            
-            glfwOpenWindow(config.width, config.height, // width, height
-                           0, 0, 0, 0,                  // R, G, B, A
-                           24, 8,                       // depth, stencil
-                           config.window_mode);         // GLFW_WINDOW | GLFW_FULLSCREEN
-
-            glfwSetWindowTitle("Pink Pony <3");
+            GLFWmonitor* fullscreen_monitor = NULL;
+            if (config.window_fullscreen)
+                fullscreen_monitor = glfwGetPrimaryMonitor();
+
+            window = glfwCreateWindow(config.width, config.height,
+                                      "Pink Pony <3",
+                                      fullscreen_monitor, NULL);
             glfwSwapInterval(config.swap_interval);
+            glfwMakeContextCurrent(window);
+
+            if (window == NULL || (!done_flext_init && !flextInit(window))) {
+                cerr << "Error initializing GLFW / OpenGL" << endl;
+                glfwTerminate();
+                return 1;
+            }
 
             reset_video = false;
+            done_flext_init = true;
 
             getErrors();
         }
 
-        // We put everything between glfwOpenWindow & glfwTerminate
+        // We put everything between glfwCreateWindow & glfwTerminate
         // between braces, so that stack variables that need a GL context
         // are destructed, while the context still exists.
         {
@@ -85,7 +83,7 @@ int main(int argc, char** argv)
             Menu::MenuStatus menu_status;
         
             {
-                Menu menu(&config, &skydome);
+                Menu menu(&config, &skydome, window);
 
                 menu_status = menu.run();
             }
@@ -124,7 +122,7 @@ int main(int argc, char** argv)
                     int human_count = config.player_count - config.ai_count;
                     if (human_count == 0) human_count = config.player_count;
 
-                    SplitScreen screen(config.width, config.height, human_count);
+                    SplitScreen screen(window, config.width, config.height, human_count);
                     screen.set_glfw_callback();
 
                     PonyGame game(&screen,
@@ -139,7 +137,7 @@ int main(int argc, char** argv)
                 running = false;
             }
         
-            if (!glfwGetWindowParam(GLFW_OPENED)) {
+            if (glfwWindowShouldClose(window)) {
                 running = false;
             }
         }

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to