Browse Source

use modern opengl

master
Alexandros Theodotou 2 years ago
parent
commit
4cab8cc54f
Signed by: alex GPG Key ID: 022EAE42313D70F3
  1. 12
      data/glsl/rotate_by_angle.frag
  2. 17
      data/glsl/rotate_by_angle.vert
  3. 16
      data/glsl/unchanged.frag
  4. 52
      data/glsl/unchanged.vert
  5. 23
      data/meson.build
  6. 290
      inc/KHR/khrplatform.h
  7. 17
      inc/game/ion_world.h
  8. 3202
      inc/glad/glad.h
  9. 434
      inc/glad/glad_glx.h
  10. 17
      inc/gui/cursor.h
  11. 119
      inc/gui/drawable.h
  12. 7
      inc/gui/gsl/unchanged.frag
  13. 8
      inc/gui/gsl/unchanged.vert
  14. 46
      inc/gui/main_menu.h
  15. 13
      inc/gui/shader.h
  16. 9
      inc/gui/shader_manager.h
  17. 7
      inc/gui/skin.h
  18. 0
      inc/gui/skin_manager.h
  19. 7
      inc/gui/texture.h
  20. 55
      inc/math/vector.h
  21. 58
      inc/utils/math.h
  22. 62
      meson.build
  23. 70
      src/game/ion_world.c
  24. 2
      src/game/meson.build
  25. 2
      src/game/skinning/meson.build
  26. 1545
      src/glad.c
  27. 337
      src/glad_glx.c
  28. 35
      src/gui/cursor.c
  29. 176
      src/gui/drawable.c
  30. 31
      src/gui/gl.c
  31. 76
      src/gui/main_menu.c
  32. 4
      src/gui/meson.build
  33. 69
      src/gui/shader.c
  34. 10
      src/gui/shader_manager.c
  35. 133
      src/gui/skin.c
  36. 4
      src/gui/skin_manager.c
  37. 27
      src/gui/texture.c
  38. 67
      src/main.c
  39. 5
      src/meson.build
  40. 24
      src/utils/math.c
  41. 1
      src/utils/meson.build

12
data/glsl/rotate_by_angle.frag

@ -0,0 +1,12 @@
#version 120
uniform sampler2D sampler;
varying vec2 tex_coord0;
void main()
{
gl_FragColor =
texture2D (sampler, tex_coord0);
gl_FragColor = vec4 (1.0, 0.0, 0.0, 1.0);
}

17
inc/gui/gsl/rotate_by_angle.vert → data/glsl/rotate_by_angle.vert

@ -1,8 +1,12 @@
#version 130
attribute vec2 position;
attribute vec2 tex_coord;
/* angle to rotate with */
uniform float _angle;
varying vec2 mypos;
varying vec2 tex_coord0;
mat2 rotation2d(float angle) {
float s = sin(angle);
@ -20,8 +24,15 @@ vec2 rotate(vec2 v, float angle) {
void main()
{
mypos = gl_Vertex.xy - vec2(-0.5f,-0.5f);
vec4 vertex_pos =
gl_ModelViewProjectionMatrix *
vec4 (position, 0.0, 1.0);
vec2 mypos = vertex_pos.xy;
mypos = mypos - vec2(-0.5f,-0.5f);
mypos = rotate (mypos, _angle);
mypos = mypos + vec2(0.5f,0.5f);
gl_Position = vec4 (mypos, gl_Vertex.z, 1.0);
tex_coord0 = tex_coord;
gl_Position = vec4 (mypos, 0.0, 1.0);
}

16
data/glsl/unchanged.frag

@ -0,0 +1,16 @@
#version 430
/* this is the currently bound texture */
uniform sampler2D sampler;
/* tex coordinate passed from vertex shader */
varying vec2 tex_coord0;
/* equivalent to gl_FragColor */
out vec4 out_color;
void main()
{
out_color =
texture2D (sampler, tex_coord0);
}

52
data/glsl/unchanged.vert

@ -0,0 +1,52 @@
#version 430
/* screen size we can use to convert the coordinates
* from screen space to [-1...1] */
uniform vec2 screen;
/* angle to rotate by, or 0 to not rotate */
uniform float angle;
/* vertex position in screen coordinates */
attribute vec2 position;
/* texture coordinate in ([0...1],[0...1]) */
attribute vec2 tex_coord;
/* tex coordinate to pass to fragment shader */
varying vec2 tex_coord0;
mat2 rotation2d(float angle) {
float s = sin(angle);
float c = cos(angle);
return mat2(
c, -s,
s, c
);
}
vec2 rotate(vec2 v, float angle) {
return rotation2d(angle) * v;
}
void main()
{
tex_coord0 = tex_coord;
/* rotate if necessary */
vec2 mypos = position.xy;
if (angle > 0.1 || angle < -0.1)
{
mypos = rotate (vec2 (0, 0), angle);
mypos = mypos + position.xy;
}
/* convert to shader coordinates [-1...1] on each
* axis */
gl_Position =
vec4 (
(mypos.x / screen.x) * 2 - 1.0,
(mypos.y / screen.y) * 2 - 1.0,
0.0, 1.0);;
}

23
data/meson.build

@ -0,0 +1,23 @@
# Copyright (C) 2019 Alexandros Theodotou <alex at zrythm dot org>
#
# This file is part of Ion
#
# Ion is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ion is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Ion. If not, see <https://www.gnu.org/licenses/>.
install_data (
join_paths ('glsl', 'unchanged.vert'),
install_dir: glsldir)
install_data (
join_paths ('glsl', 'unchanged.frag'),
install_dir: glsldir)

290
inc/KHR/khrplatform.h

@ -0,0 +1,290 @@
#ifndef __khrplatform_h_
#define __khrplatform_h_
/*
** Copyright (c) 2008-2018 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
/* Khronos platform-specific types and definitions.
*
* The master copy of khrplatform.h is maintained in the Khronos EGL
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
* The last semantic modification to khrplatform.h was at commit ID:
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
*
* Adopters may modify this file to suit their platform. Adopters are
* encouraged to submit platform specific modifications to the Khronos
* group so that they can be included in future versions of this file.
* Please submit changes by filing pull requests or issues on
* the EGL Registry repository linked above.
*
*
* See the Implementer's Guidelines for information about where this file
* should be located on your system and for more details of its use:
* http://www.khronos.org/registry/implementers_guide.pdf
*
* This file should be included as
* #include <KHR/khrplatform.h>
* by Khronos client API header files that use its types and defines.
*
* The types in khrplatform.h should only be used to define API-specific types.
*
* Types defined in khrplatform.h:
* khronos_int8_t signed 8 bit
* khronos_uint8_t unsigned 8 bit
* khronos_int16_t signed 16 bit
* khronos_uint16_t unsigned 16 bit
* khronos_int32_t signed 32 bit
* khronos_uint32_t unsigned 32 bit
* khronos_int64_t signed 64 bit
* khronos_uint64_t unsigned 64 bit
* khronos_intptr_t signed same number of bits as a pointer
* khronos_uintptr_t unsigned same number of bits as a pointer
* khronos_ssize_t signed size
* khronos_usize_t unsigned size
* khronos_float_t signed 32 bit floating point
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
* nanoseconds
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
* khronos_boolean_enum_t enumerated boolean type. This should
* only be used as a base type when a client API's boolean type is
* an enum. Client APIs which use an integer or other type for
* booleans cannot use this as the base type for their boolean.
*
* Tokens defined in khrplatform.h:
*
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
*
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
*
* Calling convention macros defined in this file:
* KHRONOS_APICALL
* KHRONOS_APIENTRY
* KHRONOS_APIATTRIBUTES
*
* These may be used in function prototypes as:
*
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
* int arg1,
* int arg2) KHRONOS_APIATTRIBUTES;
*/
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
# define KHRONOS_STATIC 1
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APICALL
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if defined(KHRONOS_STATIC)
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
* header compatible with static linking. */
# define KHRONOS_APICALL
#elif defined(_WIN32)
# define KHRONOS_APICALL __declspec(dllimport)
#elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C
#elif defined(__ANDROID__)
# define KHRONOS_APICALL __attribute__((visibility("default")))
#else
# define KHRONOS_APICALL
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIENTRY
*-------------------------------------------------------------------------
* This follows the return type of the function and precedes the function
* name in the function prototype.
*/
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(KHRONOS_STATIC)
/* Win32 but not WinCE */
# define KHRONOS_APIENTRY __stdcall
#else
# define KHRONOS_APIENTRY
#endif
/*-------------------------------------------------------------------------
* Definition of KHRONOS_APIATTRIBUTES
*-------------------------------------------------------------------------
* This follows the closing parenthesis of the function prototype arguments.
*/
#if defined (__ARMCC_2__)
#define KHRONOS_APIATTRIBUTES __softfp
#else
#define KHRONOS_APIATTRIBUTES
#endif
/*-------------------------------------------------------------------------
* basic type definitions
*-----------------------------------------------------------------------*/
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
/*
* Using <stdint.h>
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__VMS ) || defined(__sgi)
/*
* Using <inttypes.h>
*/
#include <inttypes.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
/*
* Win32
*/
typedef __int32 khronos_int32_t;
typedef unsigned __int32 khronos_uint32_t;
typedef __int64 khronos_int64_t;
typedef unsigned __int64 khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif defined(__sun__) || defined(__digital__)
/*
* Sun or Digital
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#if defined(__arch64__) || defined(_LP64)
typedef long int khronos_int64_t;
typedef unsigned long int khronos_uint64_t;
#else
typedef long long int khronos_int64_t;
typedef unsigned long long int khronos_uint64_t;
#endif /* __arch64__ */
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#elif 0
/*
* Hypothetical platform with no float or int64 support
*/
typedef int khronos_int32_t;
typedef unsigned int khronos_uint32_t;
#define KHRONOS_SUPPORT_INT64 0
#define KHRONOS_SUPPORT_FLOAT 0
#else
/*
* Generic fallback
*/
#include <stdint.h>
typedef int32_t khronos_int32_t;
typedef uint32_t khronos_uint32_t;
typedef int64_t khronos_int64_t;
typedef uint64_t khronos_uint64_t;
#define KHRONOS_SUPPORT_INT64 1
#define KHRONOS_SUPPORT_FLOAT 1
#endif
/*
* Types that are (so far) the same on all platforms
*/
typedef signed char khronos_int8_t;
typedef unsigned char khronos_uint8_t;
typedef signed short int khronos_int16_t;
typedef unsigned short int khronos_uint16_t;
/*
* Types that differ between LLP64 and LP64 architectures - in LLP64,
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
* to be the only LLP64 architecture in current use.
*/
#ifdef _WIN64
typedef signed long long int khronos_intptr_t;
typedef unsigned long long int khronos_uintptr_t;
typedef signed long long int khronos_ssize_t;
typedef unsigned long long int khronos_usize_t;
#else
typedef signed long int khronos_intptr_t;
typedef unsigned long int khronos_uintptr_t;
typedef signed long int khronos_ssize_t;
typedef unsigned long int khronos_usize_t;
#endif
#if KHRONOS_SUPPORT_FLOAT
/*
* Float type
*/
typedef float khronos_float_t;
#endif
#if KHRONOS_SUPPORT_INT64
/* Time types
*
* These types can be used to represent a time interval in nanoseconds or
* an absolute Unadjusted System Time. Unadjusted System Time is the number
* of nanoseconds since some arbitrary system event (e.g. since the last
* time the system booted). The Unadjusted System Time is an unsigned
* 64 bit value that wraps back to 0 every 584 years. Time intervals
* may be either signed or unsigned.
*/
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
typedef khronos_int64_t khronos_stime_nanoseconds_t;
#endif
/*
* Dummy value used to pad enum types to 32 bits.
*/
#ifndef KHRONOS_MAX_ENUM
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
#endif
/*
* Enumerated boolean type
*
* Values other than zero should be considered to be true. Therefore
* comparisons should not be made against KHRONOS_TRUE.
*/
typedef enum {
KHRONOS_FALSE = 0,
KHRONOS_TRUE = 1,
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
} khronos_boolean_enum_t;
#endif /* __khrplatform_h_ */

17
inc/game/ion_world.h

@ -30,6 +30,7 @@ typedef struct GLFWwindow GLFWwindow;
typedef struct SkinManager SkinManager;
typedef struct Texture Texture;
typedef struct ShaderManager ShaderManager;
typedef struct MainMenu MainMenu;
/**
* @addtogroup game
@ -75,6 +76,12 @@ typedef struct IonWorld
/** The game GLFW window. */
GLFWwindow * window;
int viewport_width;
int viewport_height;
int monitor_width;
int monitor_height;
char * skins_dir;
char * beatmaps_dir;
@ -87,6 +94,8 @@ typedef struct IonWorld
/* FIXME delete */
Texture * test_texture;
MainMenu * main_menu;
ShaderManager * shader_manager;
} IonWorld;
@ -98,7 +107,13 @@ IonWorld * ion_world;
*/
IonWorld *
ion_world_new (
GLFWwindow * window);
GLFWwindow * window,
int monitor_width,
int monitor_height);
void
ion_world_load_skin (
IonWorld * self);
/**
* To be called when the framebuffer size changes.

3202
inc/glad/glad.h
File diff suppressed because it is too large
View File

434
inc/glad/glad_glx.h

@ -0,0 +1,434 @@
/*
GLX loader generated by glad 0.1.33 on Fri Nov 29 01:47:21 2019.
Language/Generator: C/C++
Specification: glx
APIs: glx=1.4
Profile: -
Extensions:
Loader: True
Local files: False
Omit khrplatform: False
Reproducible: False
Commandline:
--api="glx=1.4" --generator="c" --spec="glx" --extensions=""
Online:
https://glad.dav1d.de/#language=c&specification=glx&loader=on&api=glx%3D1.4
*/
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <glad/glad.h>
#ifndef __glad_glxext_h_
#ifdef __glxext_h_
#error GLX header already included, remove this include, glad already provides it
#endif
#define __glad_glxext_h_
#define __glxext_h_
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef void* (* GLADloadproc)(const char *name);
#ifndef GLAPI
# if defined(GLAD_GLAPI_EXPORT)
# if defined(_WIN32) || defined(__CYGWIN__)
# if defined(GLAD_GLAPI_EXPORT_BUILD)
# if defined(__GNUC__)
# define GLAPI __attribute__ ((dllexport)) extern
# else
# define GLAPI __declspec(dllexport) extern
# endif
# else
# if defined(__GNUC__)
# define GLAPI __attribute__ ((dllimport)) extern
# else
# define GLAPI __declspec(dllimport) extern
# endif
# endif
# elif defined(__GNUC__) && defined(GLAD_GLAPI_EXPORT_BUILD)
# define GLAPI __attribute__ ((visibility ("default"))) extern
# else
# define GLAPI extern
# endif
# else
# define GLAPI extern
# endif
#endif
GLAPI int gladLoadGLX(Display *dpy, int screen);
GLAPI int gladLoadGLXLoader(GLADloadproc, Display *dpy, int screen);
#ifndef GLEXT_64_TYPES_DEFINED
/* This code block is duplicated in glext.h, so must be protected */
#define GLEXT_64_TYPES_DEFINED
/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
/* (as used in the GLX_OML_sync_control extension). */
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#include <inttypes.h>
#elif defined(__sun__) || defined(__digital__)
#include <inttypes.h>
#if defined(__STDC__)
#if defined(__arch64__) || defined(_LP64)
typedef long int int64_t;
typedef unsigned long int uint64_t;
#else
typedef long long int int64_t;
typedef unsigned long long int uint64_t;
#endif /* __arch64__ */
#endif /* __STDC__ */
#elif defined( __VMS ) || defined(__sgi)
#include <inttypes.h>
#elif defined(__SCO__) || defined(__USLC__)
#include <stdint.h>
#elif defined(__UNIXOS2__) || defined(__SOL64__)
typedef long int int32_t;
typedef long long int int64_t;
typedef unsigned long long int uint64_t;
#elif defined(_WIN32) && defined(__GNUC__)
#include <stdint.h>
#elif defined(_WIN32)
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
/* Fallback if nothing above works */
#include <inttypes.h>
#endif
#endif
typedef XID GLXFBConfigID;
typedef struct __GLXFBConfigRec *GLXFBConfig;
typedef XID GLXContextID;
typedef struct __GLXcontextRec *GLXContext;
typedef XID GLXPixmap;
typedef XID GLXDrawable;
typedef XID GLXWindow;
typedef XID GLXPbuffer;
typedef void (APIENTRY *__GLXextFuncPtr)(void);
typedef XID GLXVideoCaptureDeviceNV;
typedef unsigned int GLXVideoDeviceNV;
typedef XID GLXVideoSourceSGIX;
typedef XID GLXFBConfigIDSGIX;
typedef struct __GLXFBConfigRec *GLXFBConfigSGIX;
typedef XID GLXPbufferSGIX;
typedef struct {
int event_type; /* GLX_DAMAGED or GLX_SAVED */
int draw_type; /* GLX_WINDOW or GLX_PBUFFER */
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came for SendEvent request */
Display *display; /* display the event was read from */
GLXDrawable drawable; /* XID of Drawable */
unsigned int buffer_mask; /* mask indicating which buffers are affected */
unsigned int aux_buffer; /* which aux buffer was affected */
int x, y;
int width, height;
int count; /* if nonzero, at least this many more */
} GLXPbufferClobberEvent;
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came from a SendEvent request */
Display *display; /* Display the event was read from */
GLXDrawable drawable; /* drawable on which event was requested in event mask */
int event_type;
int64_t ust;
int64_t msc;
int64_t sbc;
} GLXBufferSwapComplete;
typedef union __GLXEvent {
GLXPbufferClobberEvent glxpbufferclobber;
GLXBufferSwapComplete glxbufferswapcomplete;
long pad[24];
} GLXEvent;
typedef struct {
int type;
unsigned long serial;
Bool send_event;
Display *display;
int extension;
int evtype;
GLXDrawable window;
Bool stereo_tree;
} GLXStereoNotifyEventEXT;
typedef struct {
int type;
unsigned long serial; /* # of last request processed by server */
Bool send_event; /* true if this came for SendEvent request */
Display *display; /* display the event was read from */
GLXDrawable drawable; /* i.d. of Drawable */
int event_type; /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */
int draw_type; /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */
unsigned int mask; /* mask indicating which buffers are affected*/
int x, y;
int width, height;
int count; /* if nonzero, at least this many more */
} GLXBufferClobberEventSGIX;
typedef struct {
char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */
int networkId;
} GLXHyperpipeNetworkSGIX;
typedef struct {
char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */
int channel;
unsigned int participationType;
int timeSlice;
} GLXHyperpipeConfigSGIX;
typedef struct {
char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */
int srcXOrigin, srcYOrigin, srcWidth, srcHeight;
int destXOrigin, destYOrigin, destWidth, destHeight;
} GLXPipeRect;
typedef struct {
char pipeName[80]; /* Should be [GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX] */
int XOrigin, YOrigin, maxHeight, maxWidth;
} GLXPipeRectLimits;
#define GLX_EXTENSION_NAME "GLX"
#define GLX_PbufferClobber 0
#define GLX_BufferSwapComplete 1
#define __GLX_NUMBER_EVENTS 17
#define GLX_BAD_SCREEN 1
#define GLX_BAD_ATTRIBUTE 2
#define GLX_NO_EXTENSION 3
#define GLX_BAD_VISUAL 4
#define GLX_BAD_CONTEXT 5
#define GLX_BAD_VALUE 6
#define GLX_BAD_ENUM 7
#define GLX_USE_GL 1
#define GLX_BUFFER_SIZE 2
#define GLX_LEVEL 3
#define GLX_RGBA 4
#define GLX_DOUBLEBUFFER 5
#define GLX_STEREO 6
#define GLX_AUX_BUFFERS 7
#define GLX_RED_SIZE 8
#define GLX_GREEN_SIZE 9
#define GLX_BLUE_SIZE 10
#define GLX_ALPHA_SIZE 11
#define GLX_DEPTH_SIZE 12
#define GLX_STENCIL_SIZE 13
#define GLX_ACCUM_RED_SIZE 14
#define GLX_ACCUM_GREEN_SIZE 15
#define GLX_ACCUM_BLUE_SIZE 16
#define GLX_ACCUM_ALPHA_SIZE 17
#define GLX_VENDOR 0x1
#define GLX_VERSION 0x2
#define GLX_EXTENSIONS 0x3
#define GLX_WINDOW_BIT 0x00000001
#define GLX_PIXMAP_BIT 0x00000002
#define GLX_PBUFFER_BIT 0x00000004
#define GLX_RGBA_BIT 0x00000001
#define GLX_COLOR_INDEX_BIT 0x00000002
#define GLX_PBUFFER_CLOBBER_MASK 0x08000000
#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
#define GLX_AUX_BUFFERS_BIT 0x00000010
#define GLX_DEPTH_BUFFER_BIT 0x00000020
#define GLX_STENCIL_BUFFER_BIT 0x00000040
#define GLX_ACCUM_BUFFER_BIT 0x00000080
#define GLX_CONFIG_CAVEAT 0x20
#define GLX_X_VISUAL_TYPE 0x22
#define GLX_TRANSPARENT_TYPE 0x23
#define GLX_TRANSPARENT_INDEX_VALUE 0x24
#define GLX_TRANSPARENT_RED_VALUE 0x25
#define GLX_TRANSPARENT_GREEN_VALUE 0x26
#define GLX_TRANSPARENT_BLUE_VALUE 0x27
#define GLX_TRANSPARENT_ALPHA_VALUE 0x28
#define GLX_DONT_CARE 0xFFFFFFFF
#define GLX_NONE 0x8000
#define GLX_SLOW_CONFIG 0x8001
#define GLX_TRUE_COLOR 0x8002
#define GLX_DIRECT_COLOR 0x8003
#define GLX_PSEUDO_COLOR 0x8004
#define GLX_STATIC_COLOR 0x8005
#define GLX_GRAY_SCALE 0x8006
#define GLX_STATIC_GRAY 0x8007
#define GLX_TRANSPARENT_RGB 0x8008
#define GLX_TRANSPARENT_INDEX 0x8009
#define GLX_VISUAL_ID 0x800B
#define GLX_SCREEN 0x800C
#define GLX_NON_CONFORMANT_CONFIG 0x800D
#define GLX_DRAWABLE_TYPE 0x8010
#define GLX_RENDER_TYPE 0x8011
#define GLX_X_RENDERABLE 0x8012
#define GLX_FBCONFIG_ID 0x8013
#define GLX_RGBA_TYPE 0x8014
#define GLX_COLOR_INDEX_TYPE 0x8015
#define GLX_MAX_PBUFFER_WIDTH 0x8016
#define GLX_MAX_PBUFFER_HEIGHT 0x8017
#define GLX_MAX_PBUFFER_PIXELS 0x8018
#define GLX_PRESERVED_CONTENTS 0x801B
#define GLX_LARGEST_PBUFFER 0x801C
#define GLX_WIDTH 0x801D
#define GLX_HEIGHT 0x801E
#define GLX_EVENT_MASK 0x801F
#define GLX_DAMAGED 0x8020
#define GLX_SAVED 0x8021
#define GLX_WINDOW 0x8022
#define GLX_PBUFFER 0x8023
#define GLX_PBUFFER_HEIGHT 0x8040
#define GLX_PBUFFER_WIDTH 0x8041
#define GLX_SAMPLE_BUFFERS 100000
#define GLX_SAMPLES 100001
#ifndef GLX_VERSION_1_0
#define GLX_VERSION_1_0 1
GLAPI int GLAD_GLX_VERSION_1_0;
typedef XVisualInfo * (APIENTRYP PFNGLXCHOOSEVISUALPROC)(Display *dpy, int screen, int *attribList);
GLAPI PFNGLXCHOOSEVISUALPROC glad_glXChooseVisual;
#define glXChooseVisual glad_glXChooseVisual
typedef GLXContext (APIENTRYP PFNGLXCREATECONTEXTPROC)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct);
GLAPI PFNGLXCREATECONTEXTPROC glad_glXCreateContext;
#define glXCreateContext glad_glXCreateContext
typedef void (APIENTRYP PFNGLXDESTROYCONTEXTPROC)(Display *dpy, GLXContext ctx);
GLAPI PFNGLXDESTROYCONTEXTPROC glad_glXDestroyContext;
#define glXDestroyContext glad_glXDestroyContext
typedef Bool (APIENTRYP PFNGLXMAKECURRENTPROC)(Display *dpy, GLXDrawable drawable, GLXContext ctx);
GLAPI PFNGLXMAKECURRENTPROC glad_glXMakeCurrent;
#define glXMakeCurrent glad_glXMakeCurrent
typedef void (APIENTRYP PFNGLXCOPYCONTEXTPROC)(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
GLAPI PFNGLXCOPYCONTEXTPROC glad_glXCopyContext;
#define glXCopyContext glad_glXCopyContext
typedef void (APIENTRYP PFNGLXSWAPBUFFERSPROC)(Display *dpy, GLXDrawable drawable);
GLAPI PFNGLXSWAPBUFFERSPROC glad_glXSwapBuffers;
#define glXSwapBuffers glad_glXSwapBuffers
typedef GLXPixmap (APIENTRYP PFNGLXCREATEGLXPIXMAPPROC)(Display *dpy, XVisualInfo *visual, Pixmap pixmap);
GLAPI PFNGLXCREATEGLXPIXMAPPROC glad_glXCreateGLXPixmap;
#define glXCreateGLXPixmap glad_glXCreateGLXPixmap
typedef void (APIENTRYP PFNGLXDESTROYGLXPIXMAPPROC)(Display *dpy, GLXPixmap pixmap);
GLAPI PFNGLXDESTROYGLXPIXMAPPROC glad_glXDestroyGLXPixmap;
#define glXDestroyGLXPixmap glad_glXDestroyGLXPixmap
typedef Bool (APIENTRYP PFNGLXQUERYEXTENSIONPROC)(Display *dpy, int *errorb, int *event);
GLAPI PFNGLXQUERYEXTENSIONPROC glad_glXQueryExtension;
#define glXQueryExtension glad_glXQueryExtension
typedef Bool (APIENTRYP PFNGLXQUERYVERSIONPROC)(Display *dpy, int *maj, int *min);
GLAPI PFNGLXQUERYVERSIONPROC glad_glXQueryVersion;
#define glXQueryVersion glad_glXQueryVersion
typedef Bool (APIENTRYP PFNGLXISDIRECTPROC)(Display *dpy, GLXContext ctx);
GLAPI PFNGLXISDIRECTPROC glad_glXIsDirect;
#define glXIsDirect glad_glXIsDirect
typedef int (APIENTRYP PFNGLXGETCONFIGPROC)(Display *dpy, XVisualInfo *visual, int attrib, int *value);
GLAPI PFNGLXGETCONFIGPROC glad_glXGetConfig;
#define glXGetConfig glad_glXGetConfig
typedef GLXContext (APIENTRYP PFNGLXGETCURRENTCONTEXTPROC)(void);
GLAPI PFNGLXGETCURRENTCONTEXTPROC glad_glXGetCurrentContext;
#define glXGetCurrentContext glad_glXGetCurrentContext
typedef GLXDrawable (APIENTRYP PFNGLXGETCURRENTDRAWABLEPROC)(void);
GLAPI PFNGLXGETCURRENTDRAWABLEPROC glad_glXGetCurrentDrawable;
#define glXGetCurrentDrawable glad_glXGetCurrentDrawable
typedef void (APIENTRYP PFNGLXWAITGLPROC)(void);
GLAPI PFNGLXWAITGLPROC glad_glXWaitGL;
#define glXWaitGL glad_glXWaitGL
typedef void (APIENTRYP PFNGLXWAITXPROC)(void);
GLAPI PFNGLXWAITXPROC glad_glXWaitX;
#define glXWaitX glad_glXWaitX
typedef void (APIENTRYP PFNGLXUSEXFONTPROC)(Font font, int first, int count, int list);
GLAPI PFNGLXUSEXFONTPROC glad_glXUseXFont;
#define glXUseXFont glad_glXUseXFont
#endif
#ifndef GLX_VERSION_1_1
#define GLX_VERSION_1_1 1
GLAPI int GLAD_GLX_VERSION_1_1;
typedef const char * (APIENTRYP PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display *dpy, int screen);
GLAPI PFNGLXQUERYEXTENSIONSSTRINGPROC glad_glXQueryExtensionsString;
#define glXQueryExtensionsString glad_glXQueryExtensionsString
typedef const char * (APIENTRYP PFNGLXQUERYSERVERSTRINGPROC)(Display *dpy, int screen, int name);
GLAPI PFNGLXQUERYSERVERSTRINGPROC glad_glXQueryServerString;
#define glXQueryServerString glad_glXQueryServerString
typedef const char * (APIENTRYP PFNGLXGETCLIENTSTRINGPROC)(Display *dpy, int name);
GLAPI PFNGLXGETCLIENTSTRINGPROC glad_glXGetClientString;
#define glXGetClientString glad_glXGetClientString
#endif
#ifndef GLX_VERSION_1_2
#define GLX_VERSION_1_2 1
GLAPI int GLAD_GLX_VERSION_1_2;
typedef Display * (APIENTRYP PFNGLXGETCURRENTDISPLAYPROC)(void);
GLAPI PFNGLXGETCURRENTDISPLAYPROC glad_glXGetCurrentDisplay;
#define glXGetCurrentDisplay glad_glXGetCurrentDisplay
#endif
#ifndef GLX_VERSION_1_3
#define GLX_VERSION_1_3 1
GLAPI int GLAD_GLX_VERSION_1_3;
typedef GLXFBConfig * (APIENTRYP PFNGLXGETFBCONFIGSPROC)(Display *dpy, int screen, int *nelements);
GLAPI PFNGLXGETFBCONFIGSPROC glad_glXGetFBConfigs;
#define glXGetFBConfigs glad_glXGetFBConfigs
typedef GLXFBConfig * (APIENTRYP PFNGLXCHOOSEFBCONFIGPROC)(Display *dpy, int screen, const int *attrib_list, int *nelements);
GLAPI PFNGLXCHOOSEFBCONFIGPROC glad_glXChooseFBConfig;
#define glXChooseFBConfig glad_glXChooseFBConfig
typedef int (APIENTRYP PFNGLXGETFBCONFIGATTRIBPROC)(Display *dpy, GLXFBConfig config, int attribute, int *value);
GLAPI PFNGLXGETFBCONFIGATTRIBPROC glad_glXGetFBConfigAttrib;
#define glXGetFBConfigAttrib glad_glXGetFBConfigAttrib
typedef XVisualInfo * (APIENTRYP PFNGLXGETVISUALFROMFBCONFIGPROC)(Display *dpy, GLXFBConfig config);
GLAPI PFNGLXGETVISUALFROMFBCONFIGPROC glad_glXGetVisualFromFBConfig;
#define glXGetVisualFromFBConfig glad_glXGetVisualFromFBConfig
typedef GLXWindow (APIENTRYP PFNGLXCREATEWINDOWPROC)(Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
GLAPI PFNGLXCREATEWINDOWPROC glad_glXCreateWindow;
#define glXCreateWindow glad_glXCreateWindow
typedef void (APIENTRYP PFNGLXDESTROYWINDOWPROC)(Display *dpy, GLXWindow win);
GLAPI PFNGLXDESTROYWINDOWPROC glad_glXDestroyWindow;
#define glXDestroyWindow glad_glXDestroyWindow
typedef GLXPixmap (APIENTRYP PFNGLXCREATEPIXMAPPROC)(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
GLAPI PFNGLXCREATEPIXMAPPROC glad_glXCreatePixmap;
#define glXCreatePixmap glad_glXCreatePixmap
typedef void (APIENTRYP PFNGLXDESTROYPIXMAPPROC)(Display *dpy, GLXPixmap pixmap);
GLAPI PFNGLXDESTROYPIXMAPPROC glad_glXDestroyPixmap;
#define glXDestroyPixmap glad_glXDestroyPixmap
typedef GLXPbuffer (APIENTRYP PFNGLXCREATEPBUFFERPROC)(Display *dpy, GLXFBConfig config, const int *attrib_list);
GLAPI PFNGLXCREATEPBUFFERPROC glad_glXCreatePbuffer;
#define glXCreatePbuffer glad_glXCreatePbuffer
typedef void (APIENTRYP PFNGLXDESTROYPBUFFERPROC)(Display *dpy, GLXPbuffer pbuf);
GLAPI PFNGLXDESTROYPBUFFERPROC glad_glXDestroyPbuffer;
#define glXDestroyPbuffer glad_glXDestroyPbuffer
typedef void (APIENTRYP PFNGLXQUERYDRAWABLEPROC)(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
GLAPI PFNGLXQUERYDRAWABLEPROC glad_glXQueryDrawable;
#define glXQueryDrawable glad_glXQueryDrawable
typedef GLXContext (APIENTRYP PFNGLXCREATENEWCONTEXTPROC)(Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
GLAPI PFNGLXCREATENEWCONTEXTPROC glad_glXCreateNewContext;
#define glXCreateNewContext glad_glXCreateNewContext
typedef Bool (APIENTRYP PFNGLXMAKECONTEXTCURRENTPROC)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
GLAPI PFNGLXMAKECONTEXTCURRENTPROC glad_glXMakeContextCurrent;
#define glXMakeContextCurrent glad_glXMakeContextCurrent
typedef GLXDrawable (APIENTRYP PFNGLXGETCURRENTREADDRAWABLEPROC)(void);
GLAPI PFNGLXGETCURRENTREADDRAWABLEPROC glad_glXGetCurrentReadDrawable;
#define glXGetCurrentReadDrawable glad_glXGetCurrentReadDrawable
typedef int (APIENTRYP PFNGLXQUERYCONTEXTPROC)(Display *dpy, GLXContext ctx, int attribute, int *value);
GLAPI PFNGLXQUERYCONTEXTPROC glad_glXQueryContext;
#define glXQueryContext glad_glXQueryContext
typedef void (APIENTRYP PFNGLXSELECTEVENTPROC)(Display *dpy, GLXDrawable draw, unsigned long event_mask);
GLAPI PFNGLXSELECTEVENTPROC glad_glXSelectEvent;
#define glXSelectEvent glad_glXSelectEvent
typedef void (APIENTRYP PFNGLXGETSELECTEDEVENTPROC)(Display *dpy, GLXDrawable draw, unsigned long *event_mask);
GLAPI PFNGLXGETSELECTEDEVENTPROC glad_glXGetSelectedEvent;
#define glXGetSelectedEvent glad_glXGetSelectedEvent
#endif
#ifndef GLX_VERSION_1_4
#define GLX_VERSION_1_4 1
GLAPI int GLAD_GLX_VERSION_1_4;
typedef __GLXextFuncPtr (APIENTRYP PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName);
GLAPI PFNGLXGETPROCADDRESSPROC glad_glXGetProcAddress;
#define glXGetProcAddress glad_glXGetProcAddress
#endif
#ifdef __cplusplus
}
#endif
#endif

17
inc/gui/cursor.h

@ -21,6 +21,7 @@
#define __GUI_CURSOR_H__
typedef struct Texture Texture;
typedef struct IonDrawable IonDrawable;
/**
* @addtogroup gui
@ -29,12 +30,12 @@ typedef struct Texture Texture;
*/
/** Times to rotate per second, if rotate is on. */
#define CURSOR_RPM 80
#define CURSOR_RPM 2
/**
* A drawable cursor, as part of a Skin.
*/
typedef struct Cursor
typedef struct IonCursor
{
/** Whether the cursor should expand when clicked. */
int expand;
@ -45,15 +46,15 @@ typedef struct Cursor
/** Last rotation angle. */
float last_angle;
Texture * cursor;
Texture * cursor_middle;
Texture * cursor_smoke;
Texture * cursor_trail;
} Cursor;
IonDrawable * cursor;
IonDrawable * cursor_middle;
IonDrawable * cursor_smoke;
IonDrawable * cursor_trail;
} IonCursor;
void
cursor_draw (
Cursor * self);
IonCursor * self);
/**
* @}

119
inc/gui/drawable.h

@ -0,0 +1,119 @@
/*
* Copyright (C) 2019 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Ion
*
* Ion is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Ion is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Affero Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file
*
* Drawable object.
*/
#ifndef __GUI_DRAWABLE_H__
#define __GUI_DRAWABLE_H__
#include "gui/shader_manager.h"
#include "math/vector.h"
typedef struct Texture Texture;
/**
* @addtogroup gui
*
* @{
*/
/**
* Drawable element.
*/
typedef struct IonDrawable
{
/** Shader to use. */
ShaderType shader_type;
/** Texture to use. */
Texture * texture;
/**
* Size of the drawable, independent of the
* texture.
*
* The texture will be stretched to this.
*/
Vector2f size;
/** GL vertex array object. */
unsigned int vao;
/** Vertices. */
unsigned int vbo;
/** Texture coordinates. */
unsigned int tbo;
/** Indices (elements). */
unsigned int ebo;
/** How many vertices we need to draw. */
unsigned int draw_count;
/** Set to 1 if the position is expected to
* change often. */
int dynamic_positions;
/** Angle to rotate by or 0. */
float angle;
/** Position to start drawing at. */
Vector2f position;
/** Quad. */
Vector2f vectors[4];
/** Texture coordinates for each vector. */
Vector2f tex_coords[4];
/** Indices. */
unsigned int indices[6];
} IonDrawable;
IonDrawable *
drawable_new_with_texture (
ShaderType shader_type,
Texture * texture,
Vector2f * position,
Vector2f * size);
void
drawable_update_position (
IonDrawable * self,
Vector2f * position,
Vector2f * size);
void
drawable_draw (
IonDrawable * self);
void
drawable_free (
IonDrawable * self);
/**
* @}
*/
#endif

7
inc/gui/gsl/unchanged.frag

@ -1,7 +0,0 @@
#version 130
void main()
{
//gl_FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);
gl_FragColor = gl_Color;
}

8
inc/gui/gsl/unchanged.vert

@ -1,8 +0,0 @@
#version 130
void main()
{
gl_Position = ftransform();
gl_FrontColor = gl_Color;
//gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

46
inc/gui/main_menu.h

@ -0,0 +1,46 @@
/*
* Copyright (C) 2019 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Ion
*
* Ion is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Ion is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Affero Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __GUI_MAIN_MENU_H__
#define __GUI_MAIN_MENU_H__
typedef struct Texture Texture;
/**
* @addtogroup gui
*
* @{
*/
/**
* A drawable logo, as part of a Skin.
*/
typedef struct MainMenu
{
} MainMenu;
void
main_menu_draw (
MainMenu * self);
/**
* @}
*/
#endif

13
inc/gui/shader.h

@ -34,10 +34,13 @@
typedef struct Shader
{
unsigned int vertex_shader_id;
unsigned int fragment_shader_id;
/**
* OpenGL shader program ID.
*
* For now, each program has 1 vertex shader and 1
* Each program has 1 vertex shader and 1
* fragment shader.
*/
unsigned int program_id;
@ -47,6 +50,14 @@ Shader *
shader_new (
const char * filepath);
void
shader_bind (
Shader * self);
void
shader_free (
Shader * self);
/**
* @}
*/

9
inc/gui/shader_manager.h

@ -34,10 +34,15 @@ typedef struct Shader Shader;
* @{
*/
typedef enum ShaderType
{
SHADER_TYPE_UNCHANGED,
NUM_SHADER_TYPES,
} ShaderType;
typedef struct ShaderManager
{
Shader * rotate_2d_shader;
Shader * unchanged_shader;
Shader * shaders[NUM_SHADER_TYPES];
} ShaderManager;
ShaderManager *

7
inc/game/skinning/skin.h → inc/gui/skin.h

@ -31,6 +31,7 @@
typedef struct AudioClip AudioClip;
typedef struct Texture Texture;
typedef struct IonDrawable IonDrawable;
/**
* @addtogroup skinning
@ -61,10 +62,10 @@ typedef struct Skin
IonRGBA combo_colors[16];
int num_combo_colors;
Cursor cursor;
IonCursor cursor;
Texture * logo;
Texture * menu_bg;
IonDrawable * logo;
IonDrawable * menu_bg;
Texture * selection_mod_autoplay;
Texture * selection_mod_cinema;
Texture * selection_mod_doubletime;

0
inc/game/skinning/skin_manager.h → inc/gui/skin_manager.h

7
inc/gui/texture.h

@ -84,6 +84,13 @@ texture_new_from_raw_data (
unsigned int height,
unsigned char * pixels);
/**
* Binds the texture to be used.
*/
void
texture_bind (
Texture * self);
/**
* Generate a texture in the backend for the given
* file.

55
inc/math/vector.h

@ -0,0 +1,55 @@
/*
* Copyright (C) 2019 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Ion
*
* Ion is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Ion is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Affero Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file
*
* Vectors.
*/
#ifndef __MATH_VECTOR_H__
#define __MATH_VECTOR_H__
/**
* @addtogroup math
*
* @{
*/
/**
* Vector.
*/
typedef struct Vector2f
{
float x;
float y;
} Vector2f;
typedef struct Vector3f
{
float x;
float y;
float z;
} Vector3f;
/**
* @}
*/
#endif

58
inc/utils/math.h

@ -0,0 +1,58 @@
/*
* Copyright (C) 2018-2019 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Zrythm
*
* Zrythm is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Zrythm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __UTILS_MATH_H__
#define __UTILS_MATH_H__
#include <float.h>
#include <math.h>
#include <stdint.h>
#define MATH_FLOATS_EQUAL(a,b,epsilon) \
(fabsf (a - b) < epsilon)
/**
* Checks if 2 floating points are equal.
*
* @param epsilon The allowed differene.
*/
static inline int
math_floats_equal (
const float a,
const float b,
const float epsilon)
{
return fabsf (a - b) < epsilon;
}
/**
* Checks if 2 doubles are equal.
*
* @param epsilon The allowed differene.
*/
static inline int
math_doubles_equal (
const double a,
const double b,
const double epsilon)
{
return fabs (a - b) < epsilon;
}
#endif

62
meson.build

@ -26,6 +26,36 @@ project(
],
)
prefix = get_option ('prefix')
bindir = join_paths (prefix, get_option('bindir'))
datadir = join_paths (prefix, get_option('datadir'))
iondatadir = join_paths (datadir, 'ion')
glsldir = join_paths (datadir, 'glsl')
cdata = configuration_data ()
cdata.set_quoted (
'PACKAGE_VERSION',
'@VCS_TAG@')
cdata.set_quoted (
'COMPILER',
meson.get_compiler('c').get_id())
cdata.set_quoted (
'PREFIX', prefix)
cdata.set_quoted (
'COMPILER_VERSION',
meson.get_compiler('c').version())
cdata.set_quoted (
'CONFIGURE_DATADIR',
datadir)
cdata.set_quoted (
'GLSL_DIR', glsldir)
cdata.set (
'MESON_SOURCE_ROOT',
meson.source_root ())
cdata.set (
'MESON_BUILD_ROOT',
meson.build_root ())
cc = meson.get_compiler ('c')
root_inc = include_directories ('.')
@ -54,9 +84,39 @@ ion_deps = [
dependency('glfw3'),
dependency('gl'),
dependency('pangocairo'),
dependency('glew'),
dependency('x11'),
cc.find_library('dl', required: false),
cc.find_library('SOIL'),
]
# create config.h
tmp_h = configure_file (
output: 'tmp.h',
configuration: cdata,
)
config_h_vcs = vcs_tag (
input: tmp_h,
output: 'config.h',
)
config_h_dep = declare_dependency (
sources: config_h_vcs,
)
ion_deps += config_h_dep
subdir ('data')
subdir ('src')
summary = [
'',
'------',
'Ion @0@'.format(meson.project_version()),
'',
' Build type: @0@'.format(
get_option('buildtype')),
' Directories:',
' prefix: @0@'.format(prefix),
' datadir: @0@'.format(datadir),
'------',
''
]
message('\n'.join(summary))

70
src/game/ion_world.c

@ -23,10 +23,12 @@
#include <glib.h>
#include "game/ion_world.h"
#include "game/skinning/skin_manager.h"
#include "game/skinning/skin.h"
#include "gui/drawable.h"
#include "gui/gl.h"
#include "gui/main_menu.h"
#include "gui/shader_manager.h"
#include "gui/skin_manager.h"
#include "gui/skin.h"
#include "gui/texture.h"
#include "utils/pango.h"
@ -35,13 +37,17 @@
*/
IonWorld *
ion_world_new (
GLFWwindow * window)
GLFWwindow * window,
int monitor_width,
int monitor_height)
{
IonWorld * self = calloc (1, sizeof (IonWorld));
ION_WORLD = self;
self->window = window;
self->monitor_width = monitor_width;
self->monitor_height = monitor_height;
self->screen = ION_WORLD_SCREEN_MAIN_MENU;
self->skins_dir =
g_build_filename (
@ -52,9 +58,6 @@ ion_world_new (
g_get_home_dir (), ".config", "ion",
"beatmaps", NULL);
self->skin_manager =
skin_manager_new (self->skins_dir);
self->shader_manager =
shader_manager_new ();
@ -66,6 +69,15 @@ ion_world_new (
return self;
}
void
ion_world_load_skin (
IonWorld * self)
{
self->skin_manager =
skin_manager_new (self->skins_dir);
}
#if 0
/**
* To be called when the framebuffer size changes.
*/
@ -83,6 +95,7 @@ ion_world_update_texture_sizes (
self->skin_manager->current_skin, fb_width,
fb_height);
}
#endif
/**
* Renders the current scene.
@ -101,9 +114,12 @@ ion_world_render_scene (
double xpos, ypos;
glfwGetCursorPos (self->window, &xpos, &ypos);
xpos =
(xpos * (double) fb_width) / (double) win_width;
(xpos * (double) fb_width) /
(double) win_width;
ypos =
(ypos * (double) fb_height) / (double) win_height;
(ypos * (double) fb_height) /
(double) win_height;
ypos = fb_height - ypos;
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode (GL_MODELVIEW);
@ -115,39 +131,23 @@ ion_world_render_scene (
switch (self->screen)
{
case ION_WORLD_SCREEN_WELCOME:
texture_draw (
self->test_texture, 0.f, 0.f, 0.f, 1.f);
/*texture_draw (*/
/*self->test_texture, 0.f, 0.f, 0.f, 1.f);*/
ion_gl_draw_test_rectangle (
40.f, 40.f, 1000.f, 20.f);
break;
case ION_WORLD_SCREEN_MAIN_MENU:
{
/* draw bg stretched */
texture =
self->skin_manager->current_skin->menu_bg;
glPushMatrix ();
glBindTexture (GL_TEXTURE_2D, texture->id);
glColor3f (1.f, 1.0f, 1.0f);
glBegin (GL_QUADS);
glTexCoord2f (0.0f, 0.0f);
glVertex2f (0.f, 0.f);
glTexCoord2f (1.0f, 0.0f);
glVertex2f (fb_width, 0.f);
glTexCoord2f (1.0f, 1.0f);
glVertex2f (fb_width, fb_height);
glTexCoord2f (0.0f, 1.0f);
glVertex2f (0.f, fb_height);
glEnd ();
glPopMatrix ();
/* draw logo */
texture =
self->skin_manager->current_skin->logo;
texture_draw (
texture,
fb_width / 2 - texture->width / 2,
fb_height / 2 - texture->height / 2,
0.f, 1.f);
drawable_draw (
self->skin_manager->current_skin->
menu_bg);
drawable_draw (
self->skin_manager->current_skin->
logo);
main_menu_draw (self->main_menu);
/* draw cursor */
cursor_draw (

2
src/game/meson.build

@ -18,5 +18,3 @@