diff --git a/glfw/CONTRIBUTORS.md b/glfw/CONTRIBUTORS.md index 77295baa..1371aedb 100644 --- a/glfw/CONTRIBUTORS.md +++ b/glfw/CONTRIBUTORS.md @@ -294,7 +294,6 @@ video tutorials. - Jonas Ådahl - Lasse Öörni - Leonard König - - Grzesiek11 - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement diff --git a/glfw/deps/getopt.c b/glfw/deps/getopt.c index 9464f790..9743046f 100644 --- a/glfw/deps/getopt.c +++ b/glfw/deps/getopt.c @@ -24,8 +24,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BUILD_MONOLITHIC - #include "getopt.h" #include @@ -230,5 +228,3 @@ int getopt_long(int argc, char* const argv[], const char* optstring, ++optind; return retval; } - -#endif // BUILD_MONOLITHIC diff --git a/glfw/deps/getopt.h b/glfw/deps/getopt.h index 7d178918..e1eb540f 100644 --- a/glfw/deps/getopt.h +++ b/glfw/deps/getopt.h @@ -27,12 +27,6 @@ #ifndef INCLUDED_GETOPT_PORT_H #define INCLUDED_GETOPT_PORT_H - -#ifdef BUILD_MONOLITHIC -#error "Error: make sure to point an include search path to the libgetopt library BEFORE including the glfw/deps/ search path, for otherwise you'll include the DISABLED alternative getopt implementation in glfw/depts/ !" -#endif - - #if defined(__cplusplus) extern "C" { #endif diff --git a/glfw/deps/nuklear.h b/glfw/deps/nuklear.h index 419b129d..f2eb9dfa 100644 --- a/glfw/deps/nuklear.h +++ b/glfw/deps/nuklear.h @@ -5682,7 +5682,7 @@ template struct nk_alignof{struct Big {T x; char c;}; enum { #endif /* NK_NUKLEAR_H_ */ -//#ifdef NK_IMPLEMENTATION +#ifdef NK_IMPLEMENTATION #ifndef NK_INTERNAL_H #define NK_INTERNAL_H @@ -6018,7 +6018,7 @@ NK_LIB void nk_property(struct nk_context *ctx, const char *name, struct nk_prop -#ifdef NK_IMPLEMENTATION + /* =============================================================== * diff --git a/glfw/examples/boing.c b/glfw/examples/boing.c index 8a3f601d..ec118a3a 100644 --- a/glfw/examples/boing.c +++ b/glfw/examples/boing.c @@ -29,18 +29,14 @@ #if defined(_MSC_VER) // Make MS math.h define M_PI -#if !defined(_USE_MATH_DEFINES) -#define _USE_MATH_DEFINES -#endif + #define _USE_MATH_DEFINES #endif #include #include #include -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -53,16 +49,16 @@ *****************************************************************************/ /* Prototypes */ -static void init( void ); -static void display( void ); -static void reshape( GLFWwindow* window, int w, int h ); -static void key_callback( GLFWwindow* window, int key, int scancode, int action, int mods ); -static void mouse_button_callback( GLFWwindow* window, int button, int action, int mods ); -static void cursor_position_callback( GLFWwindow* window, double x, double y ); -static void DrawBoingBall( void ); -static void BounceBall( double dt ); -static void DrawBoingBallBand( GLfloat long_lo, GLfloat long_hi ); -static void DrawGrid( void ); +void init( void ); +void display( void ); +void reshape( GLFWwindow* window, int w, int h ); +void key_callback( GLFWwindow* window, int key, int scancode, int action, int mods ); +void mouse_button_callback( GLFWwindow* window, int button, int action, int mods ); +void cursor_position_callback( GLFWwindow* window, double x, double y ); +void DrawBoingBall( void ); +void BounceBall( double dt ); +void DrawBoingBallBand( GLfloat long_lo, GLfloat long_hi ); +void DrawGrid( void ); #define RADIUS 70.f #define STEP_LONGITUDE 22.5f /* 22.5 makes 8 bands like original Boing */ @@ -95,21 +91,21 @@ typedef enum { DRAW_BALL, DRAW_BALL_SHADOW } DRAW_BALL_ENUM; typedef struct {float x; float y; float z;} vertex_t; /* Global vars */ -static int windowed_xpos, windowed_ypos, windowed_width, windowed_height; -static int width, height; -static GLfloat deg_rot_y = 0.f; -static GLfloat deg_rot_y_inc = 2.f; -static int override_pos = GLFW_FALSE; -static GLfloat cursor_x = 0.f; -static GLfloat cursor_y = 0.f; -static GLfloat ball_x = -RADIUS; -static GLfloat ball_y = -RADIUS; -static GLfloat ball_x_inc = 1.f; -static GLfloat ball_y_inc = 2.f; -static DRAW_BALL_ENUM drawBallHow; -static double t; -static double t_old = 0.f; -static double dt; +int windowed_xpos, windowed_ypos, windowed_width, windowed_height; +int width, height; +GLfloat deg_rot_y = 0.f; +GLfloat deg_rot_y_inc = 2.f; +int override_pos = GLFW_FALSE; +GLfloat cursor_x = 0.f; +GLfloat cursor_y = 0.f; +GLfloat ball_x = -RADIUS; +GLfloat ball_y = -RADIUS; +GLfloat ball_x_inc = 1.f; +GLfloat ball_y_inc = 2.f; +DRAW_BALL_ENUM drawBallHow; +double t; +double t_old = 0.f; +double dt; /* Random number generator */ #ifndef RAND_MAX @@ -120,7 +116,7 @@ static double dt; /***************************************************************************** * Truncate a degree. *****************************************************************************/ -static GLfloat TruncateDeg( GLfloat deg ) +GLfloat TruncateDeg( GLfloat deg ) { if ( deg >= 360.f ) return (deg - 360.f); @@ -132,7 +128,7 @@ static GLfloat TruncateDeg( GLfloat deg ) * Convert a degree (360-based) into a radian. * 360' = 2 * PI *****************************************************************************/ -static double deg2rad( double deg ) +double deg2rad( double deg ) { return deg / 360 * (2 * M_PI); } @@ -140,7 +136,7 @@ static double deg2rad( double deg ) /***************************************************************************** * 360' sin(). *****************************************************************************/ -static double sin_deg( double deg ) +double sin_deg( double deg ) { return sin( deg2rad( deg ) ); } @@ -148,7 +144,7 @@ static double sin_deg( double deg ) /***************************************************************************** * 360' cos(). *****************************************************************************/ -static double cos_deg( double deg ) +double cos_deg( double deg ) { return cos( deg2rad( deg ) ); } @@ -158,7 +154,7 @@ static double cos_deg( double deg ) * * c = a x b *****************************************************************************/ -static void CrossProduct( vertex_t a, vertex_t b, vertex_t c, vertex_t *n ) +void CrossProduct( vertex_t a, vertex_t b, vertex_t c, vertex_t *n ) { GLfloat u1, u2, u3; GLfloat v1, v2, v3; @@ -183,7 +179,7 @@ static void CrossProduct( vertex_t a, vertex_t b, vertex_t c, vertex_t *n ) /***************************************************************************** * init() *****************************************************************************/ -static void init( void ) +void init( void ) { /* * Clear background. @@ -197,7 +193,7 @@ static void init( void ) /***************************************************************************** * display() *****************************************************************************/ -static void display(void) +void display(void) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glPushMatrix(); @@ -218,7 +214,7 @@ static void display(void) /***************************************************************************** * reshape() *****************************************************************************/ -static void reshape( GLFWwindow* window, int w, int h ) +void reshape( GLFWwindow* window, int w, int h ) { mat4x4 projection, view; @@ -241,7 +237,7 @@ static void reshape( GLFWwindow* window, int w, int h ) glLoadMatrixf((const GLfloat*) view); } -static void key_callback( GLFWwindow* window, int key, int scancode, int action, int mods ) +void key_callback( GLFWwindow* window, int key, int scancode, int action, int mods ) { if (action != GLFW_PRESS) return; @@ -277,7 +273,7 @@ static void set_ball_pos ( GLfloat x, GLfloat y ) ball_y = y - (height / 2); } -static void mouse_button_callback( GLFWwindow* window, int button, int action, int mods ) +void mouse_button_callback( GLFWwindow* window, int button, int action, int mods ) { if (button != GLFW_MOUSE_BUTTON_LEFT) return; @@ -293,7 +289,7 @@ static void mouse_button_callback( GLFWwindow* window, int button, int action, i } } -static void cursor_position_callback( GLFWwindow* window, double x, double y ) +void cursor_position_callback( GLFWwindow* window, double x, double y ) { cursor_x = (float) x; cursor_y = (float) y; @@ -310,7 +306,7 @@ static void cursor_position_callback( GLFWwindow* window, double x, double y ) * The ball is built by stacking latitudinal circles. Each circle is composed * of a widely-separated set of points, so that each facet is noticeably large. *****************************************************************************/ -static void DrawBoingBall( void ) +void DrawBoingBall( void ) { GLfloat lon_deg; /* degree of longitude */ double dt_total, dt2; @@ -387,7 +383,7 @@ static void DrawBoingBall( void ) /***************************************************************************** * Bounce the ball. *****************************************************************************/ -static void BounceBall( double delta_t ) +void BounceBall( double delta_t ) { GLfloat sign; GLfloat deg; @@ -440,7 +436,7 @@ static void BounceBall( double delta_t ) * Parms: long_lo, long_hi * Low and high longitudes of slice, resp. *****************************************************************************/ -static void DrawBoingBallBand( GLfloat long_lo, +void DrawBoingBallBand( GLfloat long_lo, GLfloat long_hi ) { vertex_t vert_ne; /* "ne" means south-east, so on */ @@ -544,7 +540,7 @@ static void DrawBoingBallBand( GLfloat long_lo, * Draw the purple grid of lines, behind the Boing ball. * When the Workbench is dropped to the bottom, Boing shows 12 rows. *****************************************************************************/ -static void DrawGrid( void ) +void DrawGrid( void ) { int row, col; const int rowTotal = 12; /* must be divisible by 2 */ @@ -625,11 +621,6 @@ static void DrawGrid( void ) * main() *======================================================================*/ - -#ifdef BUILD_MONOLITHIC -#define main glfw_boing_example_main -#endif - int main( void ) { GLFWwindow* window; diff --git a/glfw/examples/gears.c b/glfw/examples/gears.c index 737a7ac6..3d63013d 100644 --- a/glfw/examples/gears.c +++ b/glfw/examples/gears.c @@ -23,9 +23,7 @@ #if defined(_MSC_VER) // Make MS math.h define M_PI -#if !defined(_USE_MATH_DEFINES) -#define _USE_MATH_DEFINES -#endif + #define _USE_MATH_DEFINES #endif #include @@ -33,9 +31,7 @@ #include #include -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -167,6 +163,7 @@ gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, glVertex3f(r0 * (float) cos(angle), r0 * (float) sin(angle), width * 0.5f); } glEnd(); + } @@ -215,7 +212,7 @@ static void animate(void) /* change view angle, exit upon ESC */ -static void key( GLFWwindow* window, int k, int s, int action, int mods ) +void key( GLFWwindow* window, int k, int s, int action, int mods ) { if( action != GLFW_PRESS ) return; @@ -248,7 +245,7 @@ static void key( GLFWwindow* window, int k, int s, int action, int mods ) /* new window size */ -static void reshape( GLFWwindow* window, int width, int height ) +void reshape( GLFWwindow* window, int width, int height ) { GLfloat h = (GLfloat) height / (GLfloat) width; GLfloat xmax, znear, zfar; @@ -304,12 +301,8 @@ static void init(void) } -#ifdef BUILD_MONOLITHIC -#define main glfw_gears_example_main -#endif - /* program entry */ -int main(int argc, const char **argv) +int main(int argc, char *argv[]) { GLFWwindow* window; int width, height; diff --git a/glfw/examples/heightmap.c b/glfw/examples/heightmap.c index 380025cd..ad5d47c1 100644 --- a/glfw/examples/heightmap.c +++ b/glfw/examples/heightmap.c @@ -29,9 +29,7 @@ #include #include -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -400,12 +398,7 @@ static void error_callback(int error, const char* description) fprintf(stderr, "Error: %s\n", description); } - -#ifdef BUILD_MONOLITHIC -#define main glfw_heightmap_example_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { GLFWwindow* window; int iter; diff --git a/glfw/examples/offscreen.c b/glfw/examples/offscreen.c index 6c8d2c77..e2852860 100644 --- a/glfw/examples/offscreen.c +++ b/glfw/examples/offscreen.c @@ -23,9 +23,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -74,11 +72,6 @@ static void error_callback(int error, const char* description) fprintf(stderr, "Error: %s\n", description); } - -#ifdef BUILD_MONOLITHIC -#define main glfw_offscreen_example_main -#endif - int main(void) { GLFWwindow* window; diff --git a/glfw/examples/particles.c b/glfw/examples/particles.c index 9fe9096c..baafe826 100644 --- a/glfw/examples/particles.c +++ b/glfw/examples/particles.c @@ -26,9 +26,7 @@ #if defined(_MSC_VER) // Make MS math.h define M_PI -#if !defined(_USE_MATH_DEFINES) -#define _USE_MATH_DEFINES -#endif + #define _USE_MATH_DEFINES #endif #include @@ -41,9 +39,7 @@ #include #include -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -85,13 +81,13 @@ typedef struct //======================================================================== // Window dimensions -static float aspect_ratio; +float aspect_ratio; // "wireframe" flag (true if we use wireframe view) -static int wireframe; +int wireframe; // Thread synchronization -static struct { +struct { double t; // Time (s) float dt; // Time since last frame (s) int p_frame; // Particle physics frame number @@ -113,10 +109,10 @@ static struct { #define F_TEX_HEIGHT 16 // Texture object IDs -static GLuint particle_tex_id, floor_tex_id; +GLuint particle_tex_id, floor_tex_id; // Particle texture (a simple spot) -static const unsigned char particle_texture[ P_TEX_WIDTH * P_TEX_HEIGHT ] = { +const unsigned char particle_texture[ P_TEX_WIDTH * P_TEX_HEIGHT ] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x22, 0x11, 0x00, 0x00, 0x00, 0x11, 0x33, 0x88, 0x77, 0x33, 0x11, 0x00, @@ -128,7 +124,7 @@ static const unsigned char particle_texture[ P_TEX_WIDTH * P_TEX_HEIGHT ] = { }; // Floor texture (your basic checkered floor) -static const unsigned char floor_texture[ F_TEX_WIDTH * F_TEX_HEIGHT ] = { +const unsigned char floor_texture[ F_TEX_WIDTH * F_TEX_HEIGHT ] = { 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xff, 0xf0, 0xcc, 0xf0, 0xf0, 0xf0, 0xff, 0xf0, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0xcc, 0xee, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0x30, 0x66, 0x30, 0x30, 0x30, 0x20, 0x30, 0x30, @@ -215,13 +211,13 @@ static float glow_pos[4]; // Object material and fog configuration constants //======================================================================== -static const GLfloat fountain_diffuse[4] = { 0.7f, 1.f, 1.f, 1.f }; -static const GLfloat fountain_specular[4] = { 1.f, 1.f, 1.f, 1.f }; -static const GLfloat fountain_shininess = 12.f; -static const GLfloat floor_diffuse[4] = { 1.f, 0.6f, 0.6f, 1.f }; -static const GLfloat floor_specular[4] = { 0.6f, 0.6f, 0.6f, 1.f }; -static const GLfloat floor_shininess = 18.f; -static const GLfloat fog_color[4] = { 0.1f, 0.1f, 0.1f, 1.f }; +const GLfloat fountain_diffuse[4] = { 0.7f, 1.f, 1.f, 1.f }; +const GLfloat fountain_specular[4] = { 1.f, 1.f, 1.f, 1.f }; +const GLfloat fountain_shininess = 12.f; +const GLfloat floor_diffuse[4] = { 1.f, 0.6f, 0.6f, 1.f }; +const GLfloat floor_specular[4] = { 0.6f, 0.6f, 0.6f, 1.f }; +const GLfloat floor_shininess = 18.f; +const GLfloat fog_color[4] = { 0.1f, 0.1f, 0.1f, 1.f }; //======================================================================== @@ -944,12 +940,7 @@ static int physics_thread_main(void* arg) // main //======================================================================== - -#ifdef BUILD_MONOLITHIC -#define main glfw_particles_example_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { int ch, width, height; thrd_t physics_thread = 0; diff --git a/glfw/examples/sharing.c b/glfw/examples/sharing.c index ab465a8f..502f9eea 100644 --- a/glfw/examples/sharing.c +++ b/glfw/examples/sharing.c @@ -23,9 +23,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -75,12 +73,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, glfwSetWindowShouldClose(window, GLFW_TRUE); } - -#ifdef BUILD_MONOLITHIC -#define main glfw_sharing_example_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { GLFWwindow* windows[2]; GLuint texture, program, vertex_buffer; diff --git a/glfw/examples/splitview.c b/glfw/examples/splitview.c index 771585b9..990df12c 100644 --- a/glfw/examples/splitview.c +++ b/glfw/examples/splitview.c @@ -10,18 +10,14 @@ // because I am not a friend of orthogonal projections) //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include #if defined(_MSC_VER) // Make MS math.h define M_PI -#if !defined(_USE_MATH_DEFINES) -#define _USE_MATH_DEFINES -#endif + #define _USE_MATH_DEFINES #endif #include @@ -487,11 +483,6 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, // main //======================================================================== - -#ifdef BUILD_MONOLITHIC -#define main glfw_splitview_example_main -#endif - int main(void) { GLFWwindow* window; diff --git a/glfw/examples/triangle-opengl.c b/glfw/examples/triangle-opengl.c index 270f85a1..ff9e7d3b 100644 --- a/glfw/examples/triangle-opengl.c +++ b/glfw/examples/triangle-opengl.c @@ -24,9 +24,7 @@ //======================================================================== //! [code] -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -82,11 +80,6 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, glfwSetWindowShouldClose(window, GLFW_TRUE); } - -#ifdef BUILD_MONOLITHIC -#define main glfw_triangle_opengl_example_main -#endif - int main(void) { glfwSetErrorCallback(error_callback); diff --git a/glfw/examples/triangle-opengles.c b/glfw/examples/triangle-opengles.c index f3fa914a..03eb026f 100644 --- a/glfw/examples/triangle-opengles.c +++ b/glfw/examples/triangle-opengles.c @@ -23,12 +23,8 @@ // //======================================================================== -#ifdef BUILD_MONOLITHIC -#include -#else #define GLAD_GLES2_IMPLEMENTATION #include -#endif #define GLFW_INCLUDE_NONE #include @@ -84,11 +80,6 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, glfwSetWindowShouldClose(window, GLFW_TRUE); } - -#ifdef BUILD_MONOLITHIC -#define main glfw_triangle_opengles_example_main -#endif - int main(void) { glfwSetErrorCallback(error_callback); @@ -116,12 +107,8 @@ int main(void) glfwSetKeyCallback(window, key_callback); glfwMakeContextCurrent(window); -#ifdef BUILD_MONOLITHIC - gladLoadGL(glfwGetProcAddress); -#else - gladLoadGLES2(glfwGetProcAddress); -#endif - glfwSwapInterval(1); + gladLoadGLES2(glfwGetProcAddress); + glfwSwapInterval(1); GLuint vertex_buffer; glGenBuffers(1, &vertex_buffer); diff --git a/glfw/examples/wave.c b/glfw/examples/wave.c index 220becef..d7ead493 100644 --- a/glfw/examples/wave.c +++ b/glfw/examples/wave.c @@ -10,18 +10,14 @@ #if defined(_MSC_VER) // Make MS math.h define M_PI -#if !defined(_USE_MATH_DEFINES) -#define _USE_MATH_DEFINES -#endif + #define _USE_MATH_DEFINES #endif #include #include #include -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -34,11 +30,11 @@ // Animation speed (10.0 looks good) #define ANIMATION_SPEED 10.0 -static GLfloat alpha = 210.f, beta = -70.f; -static GLfloat zoom = 2.f; +GLfloat alpha = 210.f, beta = -70.f; +GLfloat zoom = 2.f; -static double cursorX; -static double cursorY; +double cursorX; +double cursorY; struct Vertex { @@ -54,8 +50,8 @@ struct Vertex #define QUADH (GRIDH - 1) #define QUADNUM (QUADW*QUADH) -static GLuint quad[4 * QUADNUM]; -static struct Vertex vertex[VERTEXNUM]; +GLuint quad[4 * QUADNUM]; +struct Vertex vertex[VERTEXNUM]; /* The grid will look like this: * @@ -72,7 +68,7 @@ static struct Vertex vertex[VERTEXNUM]; // Initialize grid geometry //======================================================================== -static void init_vertices(void) +void init_vertices(void) { int x, y, p; @@ -111,16 +107,16 @@ static void init_vertices(void) } } -static double dt; -static double p[GRIDW][GRIDH]; -static double vx[GRIDW][GRIDH], vy[GRIDW][GRIDH]; -static double ax[GRIDW][GRIDH], ay[GRIDW][GRIDH]; +double dt; +double p[GRIDW][GRIDH]; +double vx[GRIDW][GRIDH], vy[GRIDW][GRIDH]; +double ax[GRIDW][GRIDH], ay[GRIDW][GRIDH]; //======================================================================== // Initialize grid //======================================================================== -static void init_grid(void) +void init_grid(void) { int x, y; double dx, dy, d; @@ -151,7 +147,7 @@ static void init_grid(void) // Draw scene //======================================================================== -static void draw_scene(GLFWwindow* window) +void draw_scene(GLFWwindow* window) { // Clear the color and depth buffers glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -176,7 +172,7 @@ static void draw_scene(GLFWwindow* window) // Initialize Miscellaneous OpenGL state //======================================================================== -static void init_opengl(void) +void init_opengl(void) { // Use Gouraud (smooth) shading glShadeModel(GL_SMOOTH); @@ -200,7 +196,7 @@ static void init_opengl(void) // Modify the height of each vertex according to the pressure //======================================================================== -static void adjust_grid(void) +void adjust_grid(void) { int pos; int x, y; @@ -220,7 +216,7 @@ static void adjust_grid(void) // Calculate wave propagation //======================================================================== -static void calc_grid(void) +void calc_grid(void) { int x, y, x2, y2; double time_step = dt * ANIMATION_SPEED; @@ -277,7 +273,7 @@ static void error_callback(int error, const char* description) // Handle key strokes //======================================================================== -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) +void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (action != GLFW_PRESS) return; @@ -320,7 +316,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, // Callback function for mouse button events //======================================================================== -static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) +void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { if (button != GLFW_MOUSE_BUTTON_LEFT) return; @@ -339,7 +335,7 @@ static void mouse_button_callback(GLFWwindow* window, int button, int action, in // Callback function for cursor motion events //======================================================================== -static void cursor_position_callback(GLFWwindow* window, double x, double y) +void cursor_position_callback(GLFWwindow* window, double x, double y) { if (glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED) { @@ -356,7 +352,7 @@ static void cursor_position_callback(GLFWwindow* window, double x, double y) // Callback function for scroll events //======================================================================== -static void scroll_callback(GLFWwindow* window, double x, double y) +void scroll_callback(GLFWwindow* window, double x, double y) { zoom += (float) y / 4.f; if (zoom < 0) @@ -368,7 +364,7 @@ static void scroll_callback(GLFWwindow* window, double x, double y) // Callback function for framebuffer resize events //======================================================================== -static void framebuffer_size_callback(GLFWwindow* window, int width, int height) +void framebuffer_size_callback(GLFWwindow* window, int width, int height) { float ratio = 1.f; mat4x4 projection; @@ -393,12 +389,7 @@ static void framebuffer_size_callback(GLFWwindow* window, int width, int height) // main //======================================================================== - -#ifdef BUILD_MONOLITHIC -#define main glfw_wave_example_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char* argv[]) { GLFWwindow* window; double t, dt_total, t_old; diff --git a/glfw/examples/windows.c b/glfw/examples/windows.c index ab4352cf..1589ffbf 100644 --- a/glfw/examples/windows.c +++ b/glfw/examples/windows.c @@ -23,9 +23,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -33,12 +31,7 @@ #include #include - -#ifdef BUILD_MONOLITHIC -#define main glfw_windows_example_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { int xpos, ypos, height; const char* description; diff --git a/glfw/include/GLFW/glfw3.h b/glfw/include/GLFW/glfw3.h index 99e8a5a5..74eac460 100644 --- a/glfw/include/GLFW/glfw3.h +++ b/glfw/include/GLFW/glfw3.h @@ -118,9 +118,6 @@ extern "C" { /* It is customary to use APIENTRY for OpenGL function pointer declarations on * all platforms. Additionally, the Windows OpenGL header needs APIENTRY. */ -#if defined(_MSC_VER) -#include // --> minwindef.h --> APIENTRY defined. Prevent compiler (preprocessor) error about redefinition. -#endif #if !defined(APIENTRY) #if defined(_WIN32) #define APIENTRY __stdcall @@ -1872,7 +1869,7 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow* window, int entered); * * @ingroup input */ -typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffset); +typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffset, int mods); /*! @brief The function pointer type for keyboard key callbacks. * @@ -5209,6 +5206,8 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); */ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback); +GLFWAPI GLFWkeyfun glfwGetKeyCallback(GLFWwindow* handle); + /*! @brief Sets the Unicode character callback. * * This function sets the character callback of the specified window, which is @@ -5336,6 +5335,8 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods */ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback); +GLFWAPI GLFWmousebuttonfun glfwGetMouseButtonCallback(GLFWwindow* handle); + /*! @brief Sets the cursor position callback. * * This function sets the cursor position callback of the specified window, @@ -5368,6 +5369,8 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmo */ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback); +GLFWAPI GLFWcursorposfun glfwGetCursorPosCallback(GLFWwindow* handle); + /*! @brief Sets the cursor enter/leave callback. * * This function sets the cursor boundary crossing callback of the specified @@ -5433,6 +5436,7 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcu */ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback); +GLFWAPI GLFWscrollfun glfwGetScrollCallback(GLFWwindow* handle); /*! @brief Sets the path drop callback. * * This function sets the path drop callback of the specified window, which is @@ -6376,6 +6380,7 @@ GLFWAPI int glfwVulkanSupported(void); */ GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count); +GLFWAPI int getKeyMods(); #if defined(VK_VERSION_1_0) /*! @brief Returns the address of the specified Vulkan instance function. diff --git a/glfw/src/egl_context.c b/glfw/src/egl_context.c index 60e5d3fa..517c64cb 100644 --- a/glfw/src/egl_context.c +++ b/glfw/src/egl_context.c @@ -197,14 +197,6 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, u->samples = getEGLConfigAttrib(n, EGL_SAMPLES); u->doublebuffer = fbconfig->doublebuffer; -#if defined(_GLFW_WAYLAND) - // Avoid using transparent buffer on Wayland if transparency is not requested. - // Otherwise mutter will fail to properly screenshot OpenGL content. - if (u->alphaBits > 0 && !fbconfig->transparent) { - continue; - } -#endif // _GLFW_WAYLAND - u->handle = (uintptr_t) n; usableCount++; } @@ -759,45 +751,10 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (window->context.egl.surface == EGL_NO_SURFACE) { - // nvidia x11 GPU driver issue - - // Set up attributes for surface creation - index = 0; - - if (fbconfig->sRGB) - { - if (_glfw.egl.KHR_gl_colorspace) - SET_ATTRIB(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR); - } - - if (!fbconfig->doublebuffer) - SET_ATTRIB(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER); - - SET_ATTRIB(EGL_NONE, EGL_NONE); - - native = _glfw.platform.getEGLNativeWindow(window); - // HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT - // despite reporting EGL_EXT_platform_base - if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE) - { - window->context.egl.surface = - eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs); - } - else - { - window->context.egl.surface = - eglCreateWindowSurface(_glfw.egl.display, config, native, attribs); - } - - // nvidia x11 GPU driver issue end - - if (window->context.egl.surface == EGL_NO_SURFACE) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "EGL: Failed to create window surface: %s", - getEGLErrorString(eglGetError())); - return GLFW_FALSE; - } + _glfwInputError(GLFW_PLATFORM_ERROR, + "EGL: Failed to create window surface: %s", + getEGLErrorString(eglGetError())); + return GLFW_FALSE; } window->context.egl.config = config; diff --git a/glfw/src/input.c b/glfw/src/input.c index 9cfbc132..5b0430cb 100644 --- a/glfw/src/input.c +++ b/glfw/src/input.c @@ -330,7 +330,7 @@ void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool // Notifies shared code of a scroll event // -void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset) +void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int mods) { assert(window != NULL); assert(xoffset > -FLT_MAX); @@ -339,7 +339,7 @@ void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset) assert(yoffset < FLT_MAX); if (window->callbacks.scroll) - window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset); + window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset, mods); } // Notifies shared code of a mouse button click event @@ -493,7 +493,7 @@ void _glfwInitGamepadMappings(void) for (i = 0; i < count; i++) { - if (_glfwDefaultMappings[i] != NULL && parseMapping(&_glfw.mappings[_glfw.mappingCount], _glfwDefaultMappings[i])) + if (parseMapping(&_glfw.mappings[_glfw.mappingCount], _glfwDefaultMappings[i])) _glfw.mappingCount++; } } @@ -964,6 +964,14 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun) return cbfun; } +GLFWAPI GLFWkeyfun glfwGetKeyCallback(GLFWwindow* handle) { + _GLFWwindow* window = ((_GLFWwindow*) handle); + assert(window != NULL); + + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + return ((_GLFWwindow*) handle)->callbacks.key; +} + GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); @@ -998,6 +1006,12 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle, return cbfun; } +GLFWAPI GLFWmousebuttonfun glfwGetMouseButtonCallback(GLFWwindow* handle) { + assert(handle); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + return ((_GLFWwindow*) handle)->callbacks.mouseButton; +} + GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle, GLFWcursorposfun cbfun) { @@ -1010,6 +1024,13 @@ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle, return cbfun; } +GLFWAPI GLFWcursorposfun glfwGetCursorPosCallback(GLFWwindow* handle) { + assert(handle); + + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + return ((_GLFWwindow*) handle)->callbacks.cursorPos; +} + GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle, GLFWcursorenterfun cbfun) { @@ -1034,6 +1055,10 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle, return cbfun; } +GLFWAPI GLFWscrollfun glfwGetScrollCallback(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + return ((_GLFWwindow*) handle)->callbacks.scroll; +} GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); diff --git a/glfw/src/internal.h b/glfw/src/internal.h index 4f097aa8..bf94245b 100644 --- a/glfw/src/internal.h +++ b/glfw/src/internal.h @@ -60,7 +60,7 @@ #define _GLFW_MESSAGE_SIZE 1024 -typedef int GLFWbool; +typedef char GLFWbool; typedef void (*GLFWproc)(void); typedef struct _GLFWerror _GLFWerror; @@ -934,7 +934,7 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods); void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool plain); -void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset); +void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int mods); void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods); void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos); void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered); diff --git a/glfw/src/mappings.h b/glfw/src/mappings.h index b7fe0a4a..cd32e5d0 100644 --- a/glfw/src/mappings.h +++ b/glfw/src/mappings.h @@ -997,6 +997,5 @@ const char* _glfwDefaultMappings[] = "03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,", "03000000120c0000101e000011010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,", #endif // GLFW_BUILD_LINUX_JOYSTICK - NULL // sentinel }; diff --git a/glfw/src/platform.c b/glfw/src/platform.c index ca651b0b..9ca64963 100644 --- a/glfw/src/platform.c +++ b/glfw/src/platform.c @@ -56,12 +56,11 @@ static const struct #if defined(_GLFW_X11) { GLFW_PLATFORM_X11, _glfwConnectX11 }, #endif - {0} // sentinel }; GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform) { - const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]) - 1 /* discount sentinel */; + const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]); size_t i; if (desiredID != GLFW_ANY_PLATFORM && @@ -141,7 +140,7 @@ GLFWAPI int glfwGetPlatform(void) GLFWAPI int glfwPlatformSupported(int platformID) { - const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]) - 1 /* discount sentinel */; + const size_t count = sizeof(supportedPlatforms) / sizeof(supportedPlatforms[0]); size_t i; if (platformID != GLFW_PLATFORM_WIN32 && diff --git a/glfw/src/wgl_context.c b/glfw/src/wgl_context.c index 54dfce7f..1c9189fa 100644 --- a/glfw/src/wgl_context.c +++ b/glfw/src/wgl_context.c @@ -306,10 +306,9 @@ static void makeContextCurrentWGL(_GLFWwindow* window) _glfwPlatformSetTls(&_glfw.contextSlot, window); else { - // CAUSES A BUG ON INTEL DRIVERS - // _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, - // "WGL: Failed to make context current"); - // _glfwPlatformSetTls(&_glfw.contextSlot, NULL); + _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, + "WGL: Failed to make context current"); + _glfwPlatformSetTls(&_glfw.contextSlot, NULL); } } else diff --git a/glfw/src/win32_platform.h b/glfw/src/win32_platform.h index 5427e523..a2f86852 100644 --- a/glfw/src/win32_platform.h +++ b/glfw/src/win32_platform.h @@ -30,23 +30,19 @@ #define NOMINMAX #endif -//#ifndef VC_EXTRALEAN -// #define VC_EXTRALEAN -//#endif - -//#ifndef WIN32_LEAN_AND_MEAN -// #define WIN32_LEAN_AND_MEAN -//#endif +#ifndef VC_EXTRALEAN + #define VC_EXTRALEAN +#endif -#ifndef _WINDOWS_ // set when windows.h has already been included before. +#ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN +#endif // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for // example to allow applications to correctly declare a GL_KHR_debug callback) // but windows.h assumes no one will define APIENTRY before it does #undef APIENTRY -#endif // _WINDOWS_ - // GLFW on Windows is Unicode only and does not work in MBCS mode #ifndef UNICODE #define UNICODE @@ -63,100 +59,10 @@ #endif // GLFW uses DirectInput8 interfaces -#ifndef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0800 -#endif +#define DIRECTINPUT_VERSION 0x0800 // GLFW uses OEM cursor resources - -#ifdef OEMRESOURCE - - - -#ifndef OEMRESOURCE #define OEMRESOURCE -#endif -/* - * OEM Resource Ordinal Numbers - */ -#define OBM_CLOSE 32754 -#define OBM_UPARROW 32753 -#define OBM_DNARROW 32752 -#define OBM_RGARROW 32751 -#define OBM_LFARROW 32750 -#define OBM_REDUCE 32749 -#define OBM_ZOOM 32748 -#define OBM_RESTORE 32747 -#define OBM_REDUCED 32746 -#define OBM_ZOOMD 32745 -#define OBM_RESTORED 32744 -#define OBM_UPARROWD 32743 -#define OBM_DNARROWD 32742 -#define OBM_RGARROWD 32741 -#define OBM_LFARROWD 32740 -#define OBM_MNARROW 32739 -#define OBM_COMBO 32738 -#define OBM_UPARROWI 32737 -#define OBM_DNARROWI 32736 -#define OBM_RGARROWI 32735 -#define OBM_LFARROWI 32734 - -#define OBM_OLD_CLOSE 32767 -#define OBM_SIZE 32766 -#define OBM_OLD_UPARROW 32765 -#define OBM_OLD_DNARROW 32764 -#define OBM_OLD_RGARROW 32763 -#define OBM_OLD_LFARROW 32762 -#define OBM_BTSIZE 32761 -#define OBM_CHECK 32760 -#define OBM_CHECKBOXES 32759 -#define OBM_BTNCORNERS 32758 -#define OBM_OLD_REDUCE 32757 -#define OBM_OLD_ZOOM 32756 -#define OBM_OLD_RESTORE 32755 - - -#define OCR_NORMAL 32512 -#define OCR_IBEAM 32513 -#define OCR_WAIT 32514 -#define OCR_CROSS 32515 -#define OCR_UP 32516 -#define OCR_SIZE 32640 /* OBSOLETE: use OCR_SIZEALL */ -#define OCR_ICON 32641 /* OBSOLETE: use OCR_NORMAL */ -#define OCR_SIZENWSE 32642 -#define OCR_SIZENESW 32643 -#define OCR_SIZEWE 32644 -#define OCR_SIZENS 32645 -#define OCR_SIZEALL 32646 -#define OCR_ICOCUR 32647 /* OBSOLETE: use OIC_WINLOGO */ -#define OCR_NO 32648 -#if(WINVER >= 0x0500) -#define OCR_HAND 32649 -#endif /* WINVER >= 0x0500 */ -#if(WINVER >= 0x0400) -#define OCR_APPSTARTING 32650 -#endif /* WINVER >= 0x0400 */ - - -#define OIC_SAMPLE 32512 -#define OIC_HAND 32513 -#define OIC_QUES 32514 -#define OIC_BANG 32515 -#define OIC_NOTE 32516 -#if(WINVER >= 0x0400) -#define OIC_WINLOGO 32517 -#define OIC_WARNING OIC_BANG -#define OIC_ERROR OIC_HAND -#define OIC_INFORMATION OIC_NOTE -#endif /* WINVER >= 0x0400 */ -#if(WINVER >= 0x0600) -#define OIC_SHIELD 32518 -#endif /* WINVER >= 0x0600 */ - - - -#endif /* OEMRESOURCE */ - #include #include @@ -449,15 +355,6 @@ typedef struct VkWin32SurfaceCreateInfoKHR HWND hwnd; } VkWin32SurfaceCreateInfoKHR; -#if !defined(APIENTRY) -#if defined(_WIN32) -#define APIENTRY __stdcall -#else -#define APIENTRY -#endif -#define GLFW_APIENTRY_DEFINED -#endif /* APIENTRY */ - typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t); diff --git a/glfw/src/win32_window.c b/glfw/src/win32_window.c index 5106599b..a48c8971 100644 --- a/glfw/src/win32_window.c +++ b/glfw/src/win32_window.c @@ -406,7 +406,7 @@ static void updateFramebufferTransparency(const _GLFWwindow* window) // Retrieves and translates modifier keys // -static int getKeyMods(void) +int getKeyMods(void) { int mods = 0; @@ -714,11 +714,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l const int mods = getKeyMods(); scancode = (HIWORD(lParam) & (KF_EXTENDED | 0xff)); - if (scancode == 0x100) + if (!scancode) { - // NOTE: Some synthetic key messages have a scancode of extended zero + // NOTE: Some synthetic key messages have a scancode of zero // HACK: Map the virtual key back to a usable scancode - scancode = KF_EXTENDED | MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC); + scancode = MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC); } // HACK: Alt+PrtSc has a different scancode than just PrtSc @@ -977,7 +977,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l case WM_MOUSEWHEEL: { - _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA); + _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA, getKeyMods()); return 0; } @@ -985,7 +985,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l { // This message is only sent on Windows Vista and later // NOTE: The X-axis is inverted for consistency with macOS and X11 - _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0); + _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0, getKeyMods()); return 0; } diff --git a/glfw/src/wl_window.c b/glfw/src/wl_window.c index 1497472e..2e842aaa 100644 --- a/glfw/src/wl_window.c +++ b/glfw/src/wl_window.c @@ -2235,7 +2235,8 @@ void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title) void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images) { - fprintf(stderr, "!!! Ignoring Error: Wayland: Setting window icon not supported\n"); + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + "Wayland: The platform does not support setting the window icon"); } void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos) diff --git a/glfw/tests/allocator.c b/glfw/tests/allocator.c index 47fe8512..3fb004d2 100644 --- a/glfw/tests/allocator.c +++ b/glfw/tests/allocator.c @@ -23,9 +23,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -103,11 +101,6 @@ static void* reallocate(void* block, size_t size, void* user) return real_block + 1; } - -#ifdef BUILD_MONOLITHIC -#define main glfw_allocator_test_main -#endif - int main(void) { struct allocator_stats stats = {0}; diff --git a/glfw/tests/clipboard.c b/glfw/tests/clipboard.c index 4eb3bf60..eaad516d 100644 --- a/glfw/tests/clipboard.c +++ b/glfw/tests/clipboard.c @@ -27,9 +27,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -90,12 +88,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, } } - -#ifdef BUILD_MONOLITHIC -#define main glfw_clipboard_test_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { int ch; GLFWwindow* window; diff --git a/glfw/tests/cursor.c b/glfw/tests/cursor.c index b1af8a1e..37f3299c 100644 --- a/glfw/tests/cursor.c +++ b/glfw/tests/cursor.c @@ -30,18 +30,14 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include #if defined(_MSC_VER) // Make MS math.h define M_PI -#if !defined(_USE_MATH_DEFINES) -#define _USE_MATH_DEFINES -#endif + #define _USE_MATH_DEFINES #endif #include @@ -328,11 +324,6 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, } } - -#ifdef BUILD_MONOLITHIC -#define main glfw_cursor_test_main -#endif - int main(void) { int i; diff --git a/glfw/tests/empty.c b/glfw/tests/empty.c index b5ae8f15..72caccbd 100644 --- a/glfw/tests/empty.c +++ b/glfw/tests/empty.c @@ -29,9 +29,7 @@ #include "tinycthread.h" -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -74,11 +72,6 @@ static float nrand(void) return (float) rand() / (float) RAND_MAX; } - -#ifdef BUILD_MONOLITHIC -#define main glfw_empty_test_main -#endif - int main(void) { int result; diff --git a/glfw/tests/events.c b/glfw/tests/events.c index e12ebb40..ab3b99a7 100644 --- a/glfw/tests/events.c +++ b/glfw/tests/events.c @@ -31,9 +31,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -544,12 +542,7 @@ static void joystick_callback(int jid, int event) } } - -#ifdef BUILD_MONOLITHIC -#define main glfw_events_test_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { Slot* slots; GLFWmonitor* monitor = NULL; diff --git a/glfw/tests/gamma.c b/glfw/tests/gamma.c index 2576089a..d1f6dc27 100644 --- a/glfw/tests/gamma.c +++ b/glfw/tests/gamma.c @@ -28,18 +28,12 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include -#ifdef BUILD_MONOLITHIC -#define NK_LIB -#else #define NK_IMPLEMENTATION -#endif #define NK_INCLUDE_FIXED_TYPES #define NK_INCLUDE_FONT_BAKING #define NK_INCLUDE_DEFAULT_FONT @@ -49,9 +43,7 @@ #define NK_BUTTON_TRIGGER_ON_RELEASE #include -#ifndef BUILD_MONOLITHIC #define NK_GLFW_GL2_IMPLEMENTATION -#endif #include #include @@ -93,11 +85,6 @@ static void chart_ramp_array(struct nk_context* nk, } } - -#ifdef BUILD_MONOLITHIC -#define main glfw_gamma_test_main -#endif - int main(int argc, char** argv) { GLFWmonitor* monitor = NULL; diff --git a/glfw/tests/glfwinfo.c b/glfw/tests/glfwinfo.c index 3aff6d79..12acbccc 100644 --- a/glfw/tests/glfwinfo.c +++ b/glfw/tests/glfwinfo.c @@ -23,13 +23,9 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include -#ifndef BUILD_MONOLITHIC #define GLAD_VULKAN_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -352,12 +348,7 @@ static void print_platform(void) } } - -#ifdef BUILD_MONOLITHIC -#define main glfw_glfwinfo_test_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { int ch; bool list_extensions = false, list_layers = false; @@ -458,7 +449,7 @@ int main(int argc, const char** argv) else { usage(); - return EXIT_FAILURE; + exit(EXIT_FAILURE); } break; case 'a': @@ -470,7 +461,7 @@ int main(int argc, const char** argv) else { usage(); - return EXIT_FAILURE; + exit(EXIT_FAILURE); } break; case 'b': @@ -482,7 +473,7 @@ int main(int argc, const char** argv) else { usage(); - return EXIT_FAILURE; + exit(EXIT_FAILURE); } break; case 'c': @@ -496,7 +487,7 @@ int main(int argc, const char** argv) else { usage(); - return EXIT_FAILURE; + exit(EXIT_FAILURE); } break; case 'd': @@ -510,7 +501,7 @@ int main(int argc, const char** argv) case 'h': case HELP: usage(); - return EXIT_SUCCESS; + exit(EXIT_SUCCESS); case 'l': case EXTENSIONS: list_extensions = true; @@ -535,7 +526,7 @@ int main(int argc, const char** argv) else { usage(); - return EXIT_FAILURE; + exit(EXIT_FAILURE); } break; case 's': @@ -547,13 +538,13 @@ int main(int argc, const char** argv) else { usage(); - return EXIT_FAILURE; + exit(EXIT_FAILURE); } break; case 'v': case VERSION: print_version(); - return EXIT_SUCCESS; + exit(EXIT_SUCCESS); case REDBITS: if (strcmp(optarg, "-") == 0) fb_red_bits = GLFW_DONT_CARE; @@ -654,7 +645,7 @@ int main(int argc, const char** argv) else { usage(); - return EXIT_FAILURE; + exit(EXIT_FAILURE); } break; case GRAPHICS_SWITCHING: @@ -665,14 +656,14 @@ int main(int argc, const char** argv) break; default: usage(); - return EXIT_FAILURE; + exit(EXIT_FAILURE); } } // Initialize GLFW and create window if (!valid_version()) - return EXIT_FAILURE; + exit(EXIT_FAILURE); glfwSetErrorCallback(error_callback); @@ -684,7 +675,7 @@ int main(int argc, const char** argv) glfwInitHint(GLFW_X11_XCB_VULKAN_SURFACE, !disable_xcb_surface); if (!glfwInit()) - return EXIT_FAILURE; + exit(EXIT_FAILURE); print_version(); print_platform(); @@ -758,33 +749,26 @@ int main(int argc, const char** argv) printf("%s context flags (0x%08x):", get_api_name(client), flags); if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) - printf(" forward-compatible"), flags &= ~GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; + printf(" forward-compatible"); if (flags & 2/*GL_CONTEXT_FLAG_DEBUG_BIT*/) - printf(" debug"), flags &= ~2; + printf(" debug"); if (flags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB) - printf(" robustness"), flags &= ~GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB; + printf(" robustness"); if (flags & 8/*GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR*/) - printf(" no-error"), flags &= ~8; - if (flags == 0) - printf(" none"); - else - printf(" (0x%08x)", flags); - putchar('\n'); + printf(" no-error"); + putchar('\n'); printf("%s context flags parsed by GLFW:", get_api_name(client)); - int any = 0; if (glfwGetWindowAttrib(window, GLFW_OPENGL_FORWARD_COMPAT)) - printf(" forward-compatible"), any = 1; + printf(" forward-compatible"); if (glfwGetWindowAttrib(window, GLFW_CONTEXT_DEBUG)) - printf(" debug"), any = 1; + printf(" debug"); if (glfwGetWindowAttrib(window, GLFW_CONTEXT_ROBUSTNESS) == GLFW_LOSE_CONTEXT_ON_RESET) - printf(" robustness"), any = 1; + printf(" robustness"); if (glfwGetWindowAttrib(window, GLFW_CONTEXT_NO_ERROR)) - printf(" no-error"), any = 1; - if (!any) - printf(" none"); - putchar('\n'); + printf(" no-error"); + putchar('\n'); } if (major >= 4 || (major == 3 && minor >= 2)) @@ -915,7 +899,7 @@ int main(int argc, const char** argv) if (!window) { glfwTerminate(); - return EXIT_FAILURE; + exit(EXIT_FAILURE); } printf("Vulkan loader: %s\n", @@ -1011,7 +995,7 @@ int main(int argc, const char** argv) if (vkCreateInstance(&ici, NULL, &instance) != VK_SUCCESS) { glfwTerminate(); - return EXIT_FAILURE; + exit(EXIT_FAILURE); } free((void*) re); @@ -1111,6 +1095,6 @@ int main(int argc, const char** argv) glfwDestroyWindow(window); glfwTerminate(); - return EXIT_SUCCESS; + exit(EXIT_SUCCESS); } diff --git a/glfw/tests/icon.c b/glfw/tests/icon.c index f615a4f9..d5baf0a0 100644 --- a/glfw/tests/icon.c +++ b/glfw/tests/icon.c @@ -27,9 +27,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -39,7 +37,7 @@ #include // a simple glfw logo -static const char* const logo[] = +const char* const logo[] = { "................", "................", @@ -59,7 +57,7 @@ static const char* const logo[] = "................" }; -static const unsigned char icon_colors[5][4] = +const unsigned char icon_colors[5][4] = { { 0, 0, 0, 255 }, // black { 255, 0, 0, 255 }, // red @@ -113,12 +111,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, } } - -#ifdef BUILD_MONOLITHIC -#define main glfw_icon_test_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { GLFWwindow* window; diff --git a/glfw/tests/iconify.c b/glfw/tests/iconify.c index 5fcc0c8c..32fd44f2 100644 --- a/glfw/tests/iconify.c +++ b/glfw/tests/iconify.c @@ -28,9 +28,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -200,12 +198,7 @@ static GLFWwindow* create_window(GLFWmonitor* monitor) return window; } - -#ifdef BUILD_MONOLITHIC -#define main glfw_iconify_test_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { int ch, i, window_count; int fullscreen = GLFW_FALSE, all_monitors = GLFW_FALSE; diff --git a/glfw/tests/inputlag.c b/glfw/tests/inputlag.c index d9294415..12e693f0 100644 --- a/glfw/tests/inputlag.c +++ b/glfw/tests/inputlag.c @@ -28,18 +28,12 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include -#ifdef BUILD_MONOLITHIC -#define NK_LIB -#else #define NK_IMPLEMENTATION -#endif #define NK_INCLUDE_FIXED_TYPES #define NK_INCLUDE_FONT_BAKING #define NK_INCLUDE_DEFAULT_FONT @@ -48,9 +42,7 @@ #define NK_INCLUDE_STANDARD_VARARGS #include -#ifndef BUILD_MONOLITHIC #define NK_GLFW_GL2_IMPLEMENTATION -#endif #include #include @@ -59,7 +51,7 @@ #include "getopt.h" -static void usage(void) +void usage(void) { printf("Usage: inputlag [-h] [-f]\n"); printf("Options:\n"); @@ -67,10 +59,10 @@ static void usage(void) printf(" -h show this help\n"); } -static struct nk_vec2 cursor_new, cursor_pos, cursor_vel; -static enum { cursor_sync_query, cursor_input_message } cursor_method = cursor_sync_query; +struct nk_vec2 cursor_new, cursor_pos, cursor_vel; +enum { cursor_sync_query, cursor_input_message } cursor_method = cursor_sync_query; -static void sample_input(GLFWwindow* window) +void sample_input(GLFWwindow* window) { float a = .25; // exponential smoothing factor @@ -86,26 +78,26 @@ static void sample_input(GLFWwindow* window) cursor_pos = cursor_new; } -static void cursor_pos_callback(GLFWwindow* window, double xpos, double ypos) +void cursor_pos_callback(GLFWwindow* window, double xpos, double ypos) { cursor_new.x = (float) xpos; cursor_new.y = (float) ypos; } -static int enable_vsync = nk_true; +int enable_vsync = nk_true; -static void update_vsync(void) +void update_vsync() { glfwSwapInterval(enable_vsync == nk_true ? 1 : 0); } -static int swap_clear = nk_false; -static int swap_finish = nk_true; -static int swap_occlusion_query = nk_false; -static int swap_read_pixels = nk_false; -static GLuint occlusion_query; +int swap_clear = nk_false; +int swap_finish = nk_true; +int swap_occlusion_query = nk_false; +int swap_read_pixels = nk_false; +GLuint occlusion_query; -static void swap_buffers(GLFWwindow* window) +void swap_buffers(GLFWwindow* window) { glfwSwapBuffers(window); @@ -133,12 +125,12 @@ static void swap_buffers(GLFWwindow* window) } } -static void error_callback(int error, const char* description) +void error_callback(int error, const char* description) { fprintf(stderr, "Error: %s\n", description); } -static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) +void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (action != GLFW_PRESS) return; @@ -151,19 +143,14 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, } } -static void draw_marker(struct nk_command_buffer* canvas, int lead, struct nk_vec2 pos) +void draw_marker(struct nk_command_buffer* canvas, int lead, struct nk_vec2 pos) { struct nk_color colors[4] = { nk_rgb(255,0,0), nk_rgb(255,255,0), nk_rgb(0,255,0), nk_rgb(0,96,255) }; struct nk_rect rect = { -5 + pos.x, -5 + pos.y, 10, 10 }; nk_fill_circle(canvas, rect, colors[lead]); } - -#ifdef BUILD_MONOLITHIC -#define main glfw_inputlag_test_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { int ch, width, height; unsigned long frame_count = 0; diff --git a/glfw/tests/joysticks.c b/glfw/tests/joysticks.c index a97d9612..df000210 100644 --- a/glfw/tests/joysticks.c +++ b/glfw/tests/joysticks.c @@ -28,18 +28,12 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include -#ifdef BUILD_MONOLITHIC -#define NK_LIB -#else #define NK_IMPLEMENTATION -#endif #define NK_INCLUDE_FIXED_TYPES #define NK_INCLUDE_FONT_BAKING #define NK_INCLUDE_DEFAULT_FONT @@ -49,9 +43,7 @@ #define NK_BUTTON_TRIGGER_ON_RELEASE #include -#ifndef BUILD_MONOLITHIC #define NK_GLFW_GL2_IMPLEMENTATION -#endif #include #include @@ -177,11 +169,6 @@ static void hat_widget(struct nk_context* nk, unsigned char state) } } - -#ifdef BUILD_MONOLITHIC -#define main glfw_joysticks_test_main -#endif - int main(void) { int jid, hat_buttons = GLFW_FALSE; diff --git a/glfw/tests/monitors.c b/glfw/tests/monitors.c index 12c2e695..1043e66c 100644 --- a/glfw/tests/monitors.c +++ b/glfw/tests/monitors.c @@ -28,9 +28,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -221,12 +219,7 @@ static void test_modes(GLFWmonitor* monitor) } } - -#ifdef BUILD_MONOLITHIC -#define main glfw_monitors_test_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { int ch, i, count, mode = LIST_MODE; GLFWmonitor** monitors; diff --git a/glfw/tests/msaa.c b/glfw/tests/msaa.c index 1cc089db..10bfa3c6 100644 --- a/glfw/tests/msaa.c +++ b/glfw/tests/msaa.c @@ -29,18 +29,14 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include #if defined(_MSC_VER) // Make MS math.h define M_PI -#if !defined(_USE_MATH_DEFINES) -#define _USE_MATH_DEFINES -#endif + #define _USE_MATH_DEFINES #endif #include "linmath.h" @@ -100,12 +96,7 @@ static void usage(void) printf("Usage: msaa [-h] [-s SAMPLES]\n"); } - -#ifdef BUILD_MONOLITHIC -#define main glfw_msaa_test_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { int ch, samples = 4; GLFWwindow* window; diff --git a/glfw/tests/reopen.c b/glfw/tests/reopen.c index fc34dac5..b458755e 100644 --- a/glfw/tests/reopen.c +++ b/glfw/tests/reopen.c @@ -33,9 +33,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -101,12 +99,7 @@ static void close_window(GLFWwindow* window) printf("Closing window took %0.3f seconds\n", glfwGetTime() - base); } - -#ifdef BUILD_MONOLITHIC -#define main glfw_reopen_test_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { int count = 0; double base; diff --git a/glfw/tests/tearing.c b/glfw/tests/tearing.c index ce62c7b3..5c7893c2 100644 --- a/glfw/tests/tearing.c +++ b/glfw/tests/tearing.c @@ -28,9 +28,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -155,12 +153,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, } } - -#ifdef BUILD_MONOLITHIC -#define main glfw_tearing_test_main -#endif - -int main(int argc, const char** argv) +int main(int argc, char** argv) { unsigned long frame_count = 0; double last_time, current_time; diff --git a/glfw/tests/threads.c b/glfw/tests/threads.c index 8234ac3d..a2caea56 100644 --- a/glfw/tests/threads.c +++ b/glfw/tests/threads.c @@ -30,9 +30,7 @@ #include "tinycthread.h" -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -82,11 +80,6 @@ static int thread_main(void* data) return 0; } - -#ifdef BUILD_MONOLITHIC -#define main glfw_threads_test_main -#endif - int main(void) { int i, result; diff --git a/glfw/tests/timeout.c b/glfw/tests/timeout.c index 8ea1efd4..c2737462 100644 --- a/glfw/tests/timeout.c +++ b/glfw/tests/timeout.c @@ -27,9 +27,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -55,11 +53,6 @@ static float nrand(void) return (float) rand() / (float) RAND_MAX; } - -#ifdef BUILD_MONOLITHIC -#define main glfw_timeout_test_main -#endif - int main(void) { GLFWwindow* window; diff --git a/glfw/tests/title.c b/glfw/tests/title.c index 28647609..08a24e74 100644 --- a/glfw/tests/title.c +++ b/glfw/tests/title.c @@ -27,9 +27,7 @@ // //======================================================================== -#ifndef BUILD_MONOLITHIC #define GLAD_GL_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -42,11 +40,6 @@ static void error_callback(int error, const char* description) fprintf(stderr, "Error: %s\n", description); } - -#ifdef BUILD_MONOLITHIC -#define main glfw_title_test_main -#endif - int main(void) { GLFWwindow* window; diff --git a/glfw/tests/triangle-vulkan.c b/glfw/tests/triangle-vulkan.c index da0bcf67..b38ee139 100644 --- a/glfw/tests/triangle-vulkan.c +++ b/glfw/tests/triangle-vulkan.c @@ -41,9 +41,7 @@ #include #endif -#ifndef BUILD_MONOLITHIC #define GLAD_VULKAN_IMPLEMENTATION -#endif #include #define GLFW_INCLUDE_NONE #include @@ -2125,12 +2123,7 @@ static void demo_resize(struct demo *demo) { demo_prepare(demo); } - -#ifdef BUILD_MONOLITHIC -#define main glfw_triangle_vulkan_example_main -#endif - -int main(const int argc, const char **argv) { +int main(const int argc, const char *argv[]) { struct demo demo; demo_init(&demo, argc, argv);