commit d29c4c1e8a72089f0a4bdaf9a6caa1a2e64b34a1 Author: oneechanhax Date: Fri Jun 22 19:09:09 2018 -0500 Example working diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..482b3ec --- /dev/null +++ b/.gitignore @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..fa5c97d --- /dev/null +++ b/CMakeLists.txt @@ -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 diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..7ba0812 --- /dev/null +++ b/README.MD @@ -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: diff --git a/build-gui.sh b/build-gui.sh new file mode 100644 index 0000000..e69de29 diff --git a/clean.sh b/clean.sh new file mode 100755 index 0000000..4a3e9cb --- /dev/null +++ b/clean.sh @@ -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 diff --git a/example-src/example.cpp b/example-src/example.cpp new file mode 100644 index 0000000..f3eaafb --- /dev/null +++ b/example-src/example.cpp @@ -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; +} diff --git a/example-src/input.hpp b/example-src/input.hpp new file mode 100644 index 0000000..e69de29 diff --git a/example-src/lib/glez.h b/example-src/lib/glez.h new file mode 100644 index 0000000..0b33773 --- /dev/null +++ b/example-src/lib/glez.h @@ -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 diff --git a/example-src/lib/libfreetype.a b/example-src/lib/libfreetype.a new file mode 100644 index 0000000..0d35da2 Binary files /dev/null and b/example-src/lib/libfreetype.a differ diff --git a/example-src/lib/libglez.a b/example-src/lib/libglez.a new file mode 100644 index 0000000..35985cd Binary files /dev/null and b/example-src/lib/libglez.a differ diff --git a/example-src/lib/libxoverlay.a b/example-src/lib/libxoverlay.a new file mode 100644 index 0000000..5f60414 Binary files /dev/null and b/example-src/lib/libxoverlay.a differ diff --git a/example-src/lib/xoverlay.h b/example-src/lib/xoverlay.h new file mode 100644 index 0000000..365cf22 --- /dev/null +++ b/example-src/lib/xoverlay.h @@ -0,0 +1,58 @@ +/* + * overlay.hpp + * + * Created on: Nov 8, 2017 + * Author: nullifiedcat + */ + +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +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 diff --git a/gui-mate/gui-mate.cpp b/gui-mate/gui-mate.cpp new file mode 100644 index 0000000..9800810 --- /dev/null +++ b/gui-mate/gui-mate.cpp @@ -0,0 +1 @@ +// We need a file sadly diff --git a/gui-mate/nekohook/README.MD b/gui-mate/nekohook/README.MD new file mode 100644 index 0000000..e119cd0 --- /dev/null +++ b/gui-mate/nekohook/README.MD @@ -0,0 +1,2 @@ +# Note +This area is for headers used in nekohook for easy pusing to it. diff --git a/gui-mate/root.hpp b/gui-mate/root.hpp new file mode 100644 index 0000000..e69de29 diff --git a/res/opensans.ttf b/res/opensans.ttf new file mode 100644 index 0000000..fd79d43 Binary files /dev/null and b/res/opensans.ttf differ