GLCV is a small canvas/event handling library that provides a thin layer abstracting the details of configuring the canvas and handling input. Sort of a simple GLUT/SDL. No API is provided for sound/fonts/widgets, there are good solutions out there for those and freedom of choice is a good thing.
The following command should build the library and the examples and install them in the IOS simulator directory.
./mk-ios
The following command should build the library and the examples and install them in the Android emulator. The emulator must be running.
./mk-android
The following command should build the library and the examples and install them in the user’s plugins directory.
./mk-npapi
After building, try opening file:testplugin.html
To compile the test application, use this command
./mk-xlib
To compile the test application, use this command
./mk-cocoa
Or if you prefer to test the ARC version
./mk-cocoa-arc
To compile the test application, use this command
mk-win
intptr_t event(const ev * e);
This is the event handling routine implemented by your application.
void cvQuit();
Call this to terminate your application.
unsigned cvWidth();
Current canvas width
unsigned cvHeight();
Current canvas height
void cvFullscreen();
On platforms that support it, put the canvas in fullscreen mode.
void cvWindowed();
On platforms that support it, put the canvas in windowed mode.
int cvMouseX();
Current X mouse position
int cvMouseY();
Current Y mouse position
void cvSetCursor(const uint8_t * rgba, int hotx, int hoty);
On platforms that support it, set the mouse cursor bitmap. The rgba argument is a pointer to a 32*32*4 bytes array containing 32x32 RGBA pixels.
void cvHideCursor();
On platforms that support it, hide the mouse cursor.
void cvDefaultCursor();
On platforms that support it, establish the default mouse cursor.
int cvPressed(cvkey key);
True if key is currently pressed
int cvReleased(cvkey key);
True if key has just been released
void cvShowKeyboard();
On platforms that support it, show the on-screen keyboard
void cvHideKeyboard();
On platforms that support it, hide the on-screen keyboard
void cvReportV(const char * fmt, va_list ap);
Report a message (depending on the platform, it might go to a file).
void cvReport(const char * fmt, ...);
Report a message (depending on the platform, it might go to a file).
int evType(const ev *);
Event type.
const char * evName(const ev *);
Event name.
int evWidth(const ev *);
Width for CVE_RESIZE events.
int evHeight(const ev *);
Width for CVE_RESIZE events.
cvkey evWhich(const ev *);
Keycode associated to CVE_DOWN/CVE_UP events.
int evX(const ev *);
Mouse X position for CVE_DOWN/CVE_UP events.
int evY(const ev *);
Mouse Y position for CVE_DOWN/CVE_UP events.
int evArgC(const ev *);
Argument count for CVE_INIT events.
char ** evArgV(const ev *);
Argument array for CVE_INIT events.
intptr_t evArg0(const ev *);
First event argument, mostly internal.
intptr_t evArg1(const ev *);
Second event argument, mostly internal.
intptr_t cvInject(cveventtype, intptr_t, intptr_t);
Inject an event, mostly internal.
const char * keyName(cvkey);
Key name for CVE_DOWN/CVE_UP events.
Null event, must be ignored.
Called upon initialization, no GL operations should be performed at this stage.
Called before terminating the application.
The OpenGL context has been established. Might be called several times.
The OpenGL context is going to be destroyed. Might be called several times.
This is your update routine, should be called at ~60Hz.
Called when the canvas is resized. Might be called several times.
A key/button has been pressed.
A key/button has been released.
Called when the user enters text.
The mouse moved.
The application is about to close.
Invoke method. The argument is available as evMethod().
Return the desired application name.
Function to be used for logging. The returned function prototype should be:
void report(const char * appname, const char * string);
Return the desired X position. This is just a hint and can be ignored on some platforms.
Return the desired Y position. This is just a hint and can be ignored on some platforms.
Return the desired width. Note that this is a hint and can be ignored on some platforms. Your code should use the width reported via CVE_RESIZE or ask explicitly with cvWidth().
Return the desired height. Note that this is a hint and can be ignored on some platforms. Your code should use the height reported via CVE_RESIZE or ask explicitly with cvHeight().
Copyright (c) 2011-2012, Jorge Acereda Maciá All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.