Merge: crisel -> main
This commit is contained in:
42
src/window.c
42
src/window.c
@@ -1,24 +1,24 @@
|
||||
#include "main.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
void __window_callback( GLFWwindow * window, int w, int h )
|
||||
{
|
||||
int m = ( w<h )? w: h;
|
||||
glViewport( (w-m)/2, (h-m)/2, m, m );
|
||||
}
|
||||
void __window_callback(GLFWwindow *, int, int);
|
||||
void __mouse_callback(GLFWwindow *, int, int, int);
|
||||
void __scroll_callback(GLFWwindow *, double, double);
|
||||
|
||||
window_t init_window( unsigned int w, unsigned int h, const char * name )
|
||||
window_t init_window(unsigned int w, unsigned int h, const char * name)
|
||||
{
|
||||
void * window;
|
||||
void __mouse_callback(GLFWwindow *window, int button, int action, int mods);
|
||||
void __scroll_callback(GLFWwindow *window, double xoffset, double yoffset);
|
||||
|
||||
if( !glfwInit() )
|
||||
return NULL;
|
||||
|
||||
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 3 );
|
||||
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 3 );
|
||||
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
|
||||
window = glfwCreateWindow( w, h, name, NULL, NULL );
|
||||
window = glfwCreateWindow(w, h, name, NULL, NULL);
|
||||
|
||||
if( !window )
|
||||
{
|
||||
@@ -26,24 +26,30 @@ window_t init_window( unsigned int w, unsigned int h, const char * name )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
glfwSetWindowSizeCallback( window, __window_callback );
|
||||
glfwSetWindowSizeCallback(window, __window_callback);
|
||||
glfwSetMouseButtonCallback((GLFWwindow*)window, __mouse_callback);
|
||||
glfwSetScrollCallback((GLFWwindow*)window, __scroll_callback);
|
||||
|
||||
__window_callback( window, w, h );
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
void use_window( window_t window )
|
||||
void use_window(window_t window)
|
||||
{
|
||||
glfwMakeContextCurrent( (void*)window );
|
||||
glfwMakeContextCurrent((void*)window);
|
||||
}
|
||||
|
||||
int is_open_window( window_t window )
|
||||
int is_open_window(window_t window)
|
||||
{
|
||||
glfwSwapBuffers( (void*)window );
|
||||
glfwSwapBuffers((void*)window);
|
||||
glfwPollEvents();
|
||||
return !glfwWindowShouldClose( (void*)window );
|
||||
|
||||
return !glfwWindowShouldClose((void*)window);
|
||||
}
|
||||
|
||||
void close_window( window_t window )
|
||||
void close_window(window_t window)
|
||||
{
|
||||
glfwDestroyWindow( (void*)window );
|
||||
glfwDestroyWindow((void*)window);
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user