Example working
This commit is contained in:
commit
d29c4c1e8a
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Visual Studio 2015 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
|
||||||
|
# Cmake Build files
|
||||||
|
CMakeFiles/*
|
||||||
|
CMakeCache.txt
|
||||||
|
cmake_install.cmake
|
||||||
|
Makefile
|
||||||
|
|
||||||
|
# Binaries
|
||||||
|
libgui-mate.a
|
||||||
|
example
|
30
CMakeLists.txt
Normal file
30
CMakeLists.txt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
# gui mate
|
||||||
|
cmake_minimum_required (VERSION 2.6)
|
||||||
|
project (gui-mate)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/gui-mate/*.c*")
|
||||||
|
add_library(gui-mate STATIC ${sources})
|
||||||
|
|
||||||
|
|
||||||
|
# Example using xoverlay
|
||||||
|
set(OpenGL_GL_PREFERENCE "GLVND")
|
||||||
|
find_package(PNG) # We need to link all this again since we prebuilt them staticly
|
||||||
|
find_package(GLEW)
|
||||||
|
find_package(OpenGL)
|
||||||
|
find_package(X11)
|
||||||
|
find_package(Freetype)
|
||||||
|
if(PNG_FOUND AND GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND FREETYPE_FOUND)
|
||||||
|
project (example)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/example-src/*.c*")
|
||||||
|
add_executable(example ${sources})
|
||||||
|
|
||||||
|
# is longe
|
||||||
|
target_link_libraries(example gui-mate
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/example-src/lib/libxoverlay.a"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/example-src/lib/libglez.a"
|
||||||
|
${PNG_LIBRARIES} ${GLEW_LIBRARIES} ${OPENGL_gl_LIBRARY} ${FREETYPE_LIBRARIES}
|
||||||
|
${X11_X11_LIB} ${X11_Xext_LIB} ${X11_Xfixes_LIB})
|
||||||
|
endif()
|
||||||
|
# Wow ez
|
7
README.MD
Normal file
7
README.MD
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Gui Mate
|
||||||
|
A simple primitive graphical user interface api for the big brained...
|
||||||
|
Written in C++
|
||||||
|
|
||||||
|
## Note~
|
||||||
|
This application and api is only for making and getting a gui working and running for nekohook, sorry if you cant port it easily to your platform.
|
||||||
|
Also, should this even be called an api :thinking:
|
0
build-gui.sh
Normal file
0
build-gui.sh
Normal file
11
clean.sh
Executable file
11
clean.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
rm -fr CMakeFiles/
|
||||||
|
rm -f CMakeCache.txt
|
||||||
|
rm -f cmake_install.cmake
|
||||||
|
rm -f Makefile
|
||||||
|
|
||||||
|
# Binaries
|
||||||
|
rm -f libgui-mate.a
|
||||||
|
rm -f example
|
19
example-src/example.cpp
Normal file
19
example-src/example.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
#include "lib/xoverlay.h"
|
||||||
|
#include "lib/glez.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
xoverlay_init();
|
||||||
|
glez_init(xoverlay_library.width, xoverlay_library.height);
|
||||||
|
|
||||||
|
xoverlay_show();
|
||||||
|
while (1) {
|
||||||
|
// Must be called in that order.
|
||||||
|
xoverlay_draw_begin();
|
||||||
|
glez_begin();
|
||||||
|
glez_rect(100, 300, 200, 100, glez_rgba(255, 0, 128, 255));
|
||||||
|
glez_end();
|
||||||
|
xoverlay_draw_end();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
0
example-src/input.hpp
Normal file
0
example-src/input.hpp
Normal file
116
example-src/lib/glez.h
Normal file
116
example-src/lib/glez.h
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* glez.h
|
||||||
|
*
|
||||||
|
* Created on: Dec 7, 2017
|
||||||
|
* Author: nullifiedcat
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Types */
|
||||||
|
|
||||||
|
typedef struct glez_vec4_s
|
||||||
|
{
|
||||||
|
union {
|
||||||
|
float data[4];
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
float r;
|
||||||
|
float g;
|
||||||
|
float b;
|
||||||
|
float a;
|
||||||
|
};
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float w;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} glez_vec4_t, glez_rgba_t;
|
||||||
|
|
||||||
|
typedef unsigned int glez_texture_t;
|
||||||
|
typedef unsigned int glez_font_t;
|
||||||
|
|
||||||
|
/* State functions */
|
||||||
|
|
||||||
|
void glez_init(int width, int height);
|
||||||
|
|
||||||
|
void glez_shutdown();
|
||||||
|
|
||||||
|
void glez_begin();
|
||||||
|
|
||||||
|
void glez_end();
|
||||||
|
|
||||||
|
void glez_resize(int width, int height);
|
||||||
|
|
||||||
|
/* Helper functions */
|
||||||
|
|
||||||
|
static inline glez_rgba_t glez_rgba(unsigned char r, unsigned char g,
|
||||||
|
unsigned char b, unsigned char a)
|
||||||
|
{
|
||||||
|
glez_rgba_t result;
|
||||||
|
result.r = (float) r / 255.0f;
|
||||||
|
result.g = (float) g / 255.0f;
|
||||||
|
result.b = (float) b / 255.0f;
|
||||||
|
result.a = (float) a / 255.0f;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Font-related functions */
|
||||||
|
|
||||||
|
#define GLEZ_FONT_COUNT 64
|
||||||
|
#define GLEZ_FONT_INVALID ((glez_font_t) 0xFFFFFFFF)
|
||||||
|
|
||||||
|
glez_font_t glez_font_load(const char *path, float size);
|
||||||
|
|
||||||
|
void glez_font_unload(glez_font_t handle);
|
||||||
|
|
||||||
|
void glez_font_string_size(glez_font_t font, const char *string, float *out_x,
|
||||||
|
float *out_y);
|
||||||
|
|
||||||
|
/* Texture-related functions */
|
||||||
|
|
||||||
|
#define GLEZ_TEXTURE_INVALID ((glez_texture_t) 0xFFFFFFFF)
|
||||||
|
|
||||||
|
glez_texture_t glez_texture_load_png_rgba(const char *path);
|
||||||
|
|
||||||
|
void glez_texture_unload(glez_texture_t handle);
|
||||||
|
|
||||||
|
void glez_texture_size(glez_texture_t handle, int *width, int *height);
|
||||||
|
|
||||||
|
/* Drawing functions */
|
||||||
|
|
||||||
|
void glez_line(float x, float y, float dx, float dy, glez_rgba_t color,
|
||||||
|
float thickness);
|
||||||
|
|
||||||
|
void glez_rect(float x, float y, float w, float h, glez_rgba_t color);
|
||||||
|
|
||||||
|
void glez_rect_outline(float x, float y, float w, float h, glez_rgba_t color,
|
||||||
|
float thickness);
|
||||||
|
|
||||||
|
void glez_rect_textured(float x, float y, float w, float h, glez_rgba_t color,
|
||||||
|
glez_texture_t texture, float tx, float ty, float tw,
|
||||||
|
float th, float angle);
|
||||||
|
|
||||||
|
void glez_string(float x, float y, const char *string, glez_font_t font,
|
||||||
|
glez_rgba_t color, float *out_x, float *out_y);
|
||||||
|
|
||||||
|
void glez_string_with_outline(float x, float y, const char *string,
|
||||||
|
glez_font_t font, glez_rgba_t color,
|
||||||
|
glez_rgba_t outline_color, float outline_width,
|
||||||
|
int adjust_outline_alpha, float *out_x,
|
||||||
|
float *out_y);
|
||||||
|
|
||||||
|
void glez_circle(float x, float y, float radius, glez_rgba_t color,
|
||||||
|
float thickness, int steps);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
BIN
example-src/lib/libfreetype.a
Normal file
BIN
example-src/lib/libfreetype.a
Normal file
Binary file not shown.
BIN
example-src/lib/libglez.a
Normal file
BIN
example-src/lib/libglez.a
Normal file
Binary file not shown.
BIN
example-src/lib/libxoverlay.a
Normal file
BIN
example-src/lib/libxoverlay.a
Normal file
Binary file not shown.
58
example-src/lib/xoverlay.h
Normal file
58
example-src/lib/xoverlay.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* overlay.hpp
|
||||||
|
*
|
||||||
|
* Created on: Nov 8, 2017
|
||||||
|
* Author: nullifiedcat
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/XKBlib.h>
|
||||||
|
|
||||||
|
struct xoverlay_library
|
||||||
|
{
|
||||||
|
Display *display;
|
||||||
|
Window window;
|
||||||
|
Colormap colormap;
|
||||||
|
GC gc;
|
||||||
|
XGCValues gcvalues;
|
||||||
|
XFontStruct font;
|
||||||
|
int screen;
|
||||||
|
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
} mouse;
|
||||||
|
|
||||||
|
char init;
|
||||||
|
char drawing;
|
||||||
|
char mapped;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct xoverlay_library xoverlay_library;
|
||||||
|
|
||||||
|
int xoverlay_init();
|
||||||
|
|
||||||
|
void xoverlay_destroy();
|
||||||
|
|
||||||
|
void xoverlay_show();
|
||||||
|
|
||||||
|
void xoverlay_hide();
|
||||||
|
|
||||||
|
void xoverlay_draw_begin();
|
||||||
|
|
||||||
|
void xoverlay_draw_end();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
1
gui-mate/gui-mate.cpp
Normal file
1
gui-mate/gui-mate.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
// We need a file sadly
|
2
gui-mate/nekohook/README.MD
Normal file
2
gui-mate/nekohook/README.MD
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Note
|
||||||
|
This area is for headers used in nekohook for easy pusing to it.
|
0
gui-mate/root.hpp
Normal file
0
gui-mate/root.hpp
Normal file
BIN
res/opensans.ttf
Normal file
BIN
res/opensans.ttf
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user