Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/gleqPublic

Simple event queue for GLFW 3

License

NotificationsYou must be signed in to change notification settings

glfw/gleq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GLEQ is a basic, header-only event queue library for GLFW 3. It adds GLFWevents for monitors, joysticks and windows to a single global queue. Nothingmore.

GLEQ is inspired bySDL andGLWT, and is writtenas an example forpeople requesting that GLFW provide an event queue API, to show how easy it isto implement on top of GLFW callbacks.

GLEQ is written in C and depends only on GLFW 3.0 or later.

GLEQ is a work in progress and the interface may change but it works as intendedand covers nearly all events up to and including GLFW 3.3. Just drop it intoyour project and include it after the GLFW header.

GLEQ is licensed under thezlib/libpnglicense.

Using GLEQ

To use GLEQ, includegleq.h after the GLFW header. To add the implementationof GLEQ, defineGLEQ_IMPLEMENTATION before including the GLEQ header inexactly one source file.

#include<GLFW/glfw3.h>#defineGLEQ_IMPLEMENTATION#include"gleq.h"

If you will only be using GLEQ in a single source file, you can makeall itsfunctions static by definingGLEQ_STATIC as well.

#include<GLFW/glfw3.h>#defineGLEQ_IMPLEMENTATION#defineGLEQ_STATIC#include"gleq.h"

After GLFW has been successfully initialized, callgleqInit. This willreplace the monitor and joystick callbacks.

if (!glfwInit())return false;gleqInit();

Once a GLFW window is created, you can track it withgleqTrackWindow. Thisreplaces all callbacks on that window.

gleqTrackWindow(window);

Event processing is done as usual withglfwPollEvents,glfwWaitEvents orglfwWaitEventsTimeout. Events for monitors, joysticks and tracked windows areadded to the queue as GLFW reports them.

Event retrieval is done withgleqNextEvent and each event is then freed withgleqFreeEvent.

GLEQeventevent;while (gleqNextEvent(&event)){switch (event.type)    {caseGLEQ_WINDOW_RESIZED:printf("Window resized to %ix%i\n",event.size.width,event.size.height);break;    }gleqFreeEvent(&event);}

The call togleqFreeEvent frees any memory allocated for the event and clearsthe event struct. Currently only the file drop event allocates memory, but it'srecommended to call it for every event once it has been processed.

FAQ

Does GLEQ use the GLFW window user pointer?

No, only GLFW callbacks.

Does GLEQ allocate memory?

Only to save a deep copy of the path list provided to the file drop callback.The event queue itself is a global static array.

Aren't static arrays bad?

It depends. Also, the size of the queue can be controlled withGLEQ_CAPACITY.

Isn't global data bad?

It depends. The native event queue wrapped by GLFW is global, too.

Why doesn't GLEQ provide one queue per window?

GLEQ is intended to be a simple example event queue. Having a queue per windowwould make it more complicated than it needs to be.

Why isn't GLEQ thread safe?

GLEQ is intended to be a simple example event queue. Making it thread safewould make it more complicated than it needs to be.


[8]ページ先頭

©2009-2025 Movatter.jp