Skip to content

Commit

Permalink
Merge pull request #1 from dark-tree/next
Browse files Browse the repository at this point in the history
WINX 1.1.0
  • Loading branch information
magistermaks authored Sep 7, 2022
2 parents 31a95ff + e853556 commit b5350e5
Show file tree
Hide file tree
Showing 10 changed files with 471 additions and 254 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
WINX is a simple to use, minimal, cross-platform and single-header window management C library designed to easily create an OpenGL 3.0+ compatible window on both Windows and Linux (as well as on MacOS through X11).

#### Usage
To use WINX compile the single source file `winx.c` with the `-lGL -lX11` options on Linux and `-lopengl32 -lgdi32` on Windows, after that include the `winx.h`
To use WINX compile the single source file `winx.c` with the `-lGL -lX11 -lXcursor` options on Linux and `-lopengl32 -lgdi32` on Windows, after that include the `winx.h`
header anywhere you need access to WINX functions, and link the object files. For small single-file programs you can also directly include the `winx.c` source file -
but note that this is not recommended as it sometimes causes issues with other libraries such as GLAD if done incorrectly. If you plan on using both GLAD and WINX
together consider the combined library [WXGL](wxgl/).
but note that this is not recommended as it sometimes causes issues with other libraries such as GLAD if done incorrectly.

#### Example
To see WINX in action run the `build.sh` (or `./build.bat` on Windows) script to compile and execute a simple OpenGL program using a WINX created context and window.
Expand All @@ -14,4 +13,4 @@ To see WINX in action run the `build.sh` (or `./build.bat` on Windows) script to
Documentation describing the basics of using WINX can be found at the beginning of the `winx.h` header file, just under the license.

#### License
Boost Software License - Version 1.0 - August 17th, 2003
This project is licensed under the MIT license.
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
gcc -g -O0 winx.c example/main.c example/glad/glad.c -I. -lopengl32 -lgdi32 -o main.exe && main.exe
gcc -g -Wall -Wextra -Wno-unused-parameter -Wno-cast-function-type -O0 winx.c example/main.c example/glad/glad.c -I. -lopengl32 -lgdi32 -o main.exe && main.exe
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
set -x
gcc -g -O0 winx.c example/main.c example/glad/glad.c -I. -ldl -lGL -lX11 -o main && ./main
gcc -g -Wall -Wextra -Wno-unused-parameter -O0 winx.c example/main.c example/glad/glad.c -I. -ldl -lGL -lX11 -lXcursor -o main && ./main
29 changes: 1 addition & 28 deletions example/main.c
Original file line number Diff line number Diff line change
@@ -1,35 +1,9 @@

#include "glad/glad.h"
#include <winx.h>

#include <stdio.h>
#include <sys/time.h>

#include "render.h"

// for printing fps every 5s
void watch() {
static int t0 = -1;
static int frames = 0;

struct timeval tv;
struct timezone tz;
gettimeofday(&tv, &tz);
int t = (int) tv.tv_sec;

if (t0 < 0) t0 = t;

frames++;

if (t - t0 >= 5.0) {
float seconds = t - t0;
float fps = frames / seconds;
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
t0 = t;
frames = 0;
}
}

void closeEventHandle() {
winxClose();
exit(0);
Expand All @@ -41,7 +15,7 @@ void resizeEventHandle(int w, int h) {

int main() {

if (!winxOpen(500, 300, "WINX OpenGL 3.0 Example")) {
if (!winxOpen(400, 300, "WINX OpenGL 3.0 Example")) {
printf("Error occured! %s\n", winxGetError());
exit(1);
}
Expand All @@ -60,7 +34,6 @@ int main() {

winxSwapBuffers();
winxPollEvents();
watch();
}

}
Expand Down
Loading

0 comments on commit b5350e5

Please sign in to comment.