daily update on 20231104 by nitload youmu

This commit is contained in:
Nitload
2023-11-04 07:28:34 +08:00
parent 588a61d514
commit 9933ced8f4
368 changed files with 171636 additions and 109434 deletions
@@ -0,0 +1,253 @@
#ifndef SSG
#define SSG
#define SSG_Api
#ifdef _WIN32
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#include "ssgc_framework.h"
#include "ssgc_internal.h"
#include "glad_gl.h"
#include "glad_wgl.h"
#include "glfw3.h"
#include <immintrin.h>
#pragma region debug
SSCAPI void printShaderCode(char* const* code);
#pragma endregion
#pragma region Internal
extern __m128* defaultVecPtr;
#define ALIGN(simdVec) _mm_loadu_ps(&simdVec)
extern GladGLContext* currentContext;
typedef struct glfwContext
{
int(SSCDECL* Init)(void);
void(SSCDECL* Terminate)(void);
void(SSCDECL* InitHint)(int hint, int value);
void(SSCDECL* GetVersion)(int* major, int* minor, int* rev);
char* (SSCDECL* GetVersionString)(void);
int(SSCDECL* GetError)(char** description);
GLFWerrorfun(SSCDECL* SetErrorCallback)(GLFWerrorfun callback);
GLFWmonitor** (SSCDECL* GetMonitors)(int* count);
GLFWmonitor* (SSCDECL* GetPrimaryMonitor)(void);
void(SSCDECL* GetMonitorPos)(GLFWmonitor* monitor, int* xpos, int* ypos);
void(SSCDECL* GetMonitorWorkarea)(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
void(SSCDECL* GetMonitorPhysicalSize)(GLFWmonitor* monitor, int* widthMM, int* heightMM);
void(SSCDECL* GetMonitorContentScale)(GLFWmonitor* monitor, float* xscale, float* yscale);
char* (SSCDECL* GetMonitorName)(GLFWmonitor* monitor);
void(SSCDECL* SetMonitorUserPointer)(GLFWmonitor* monitor, void* pointer);
void* (SSCDECL* GetMonitorUserPointer)(GLFWmonitor* monitor);
GLFWmonitorfun(SSCDECL* SetMonitorCallback)(GLFWmonitorfun callback);
GLFWvidmode* (SSCDECL* GetVideoModes)(GLFWmonitor* monitor, int* count);
GLFWvidmode* (SSCDECL* GetVideoMode)(GLFWmonitor* monitor);
void(SSCDECL* SetGamma)(GLFWmonitor* monitor, float gamma);
GLFWgammaramp* (SSCDECL* GetGammaRamp)(GLFWmonitor* monitor);
void(SSCDECL* SetGammaRamp)(GLFWmonitor* monitor, GLFWgammaramp* ramp);
void(SSCDECL* DefaultWindowHints)(void);
void(SSCDECL* WindowHint)(int hint, int value);
void(SSCDECL* WindowHintString)(int hint, char* value);
GLFWwindow* (SSCDECL* CreateWindowProc)(int width, int height, char* title, GLFWmonitor* monitor, GLFWwindow* share);
void(SSCDECL* DestroyWindow)(GLFWwindow* window);
int(SSCDECL* WindowShouldClose)(GLFWwindow* window);
void(SSCDECL* SetWindowShouldClose)(GLFWwindow* window, int value);
void(SSCDECL* SetWindowTitle)(GLFWwindow* window, char* title);
void(SSCDECL* SetWindowIcon)(GLFWwindow* window, int count, GLFWimage* images);
void(SSCDECL* GetWindowPos)(GLFWwindow* window, int* xpos, int* ypos);
void(SSCDECL* SetWindowPos)(GLFWwindow* window, int xpos, int ypos);
void(SSCDECL* GetWindowSize)(GLFWwindow* window, int* width, int* height);
void(SSCDECL* SetWindowSizeLimits)(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
void(SSCDECL* SetWindowAspectRatio)(GLFWwindow* window, int numer, int denom);
void(SSCDECL* SetWindowSize)(GLFWwindow* window, int width, int height);
void(SSCDECL* GetFramebufferSize)(GLFWwindow* window, int* width, int* height);
void(SSCDECL* GetWindowFrameSize)(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
void(SSCDECL* GetWindowContentScale)(GLFWwindow* window, float* xscale, float* yscale);
float(SSCDECL* GetWindowOpacity)(GLFWwindow* window);
void(SSCDECL* SetWindowOpacity)(GLFWwindow* window, float opacity);
void(SSCDECL* IconifyWindow)(GLFWwindow* window);
void(SSCDECL* RestoreWindow)(GLFWwindow* window);
void(SSCDECL* MaximizeWindow)(GLFWwindow* window);
void(SSCDECL* ShowWindow)(GLFWwindow* window);
void(SSCDECL* HideWindow)(GLFWwindow* window);
void(SSCDECL* FocusWindow)(GLFWwindow* window);
void(SSCDECL* RequestWindowAttention)(GLFWwindow* window);
GLFWmonitor* (SSCDECL* GetWindowMonitor)(GLFWwindow* window);
void(SSCDECL* SetWindowMonitor)(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
int(SSCDECL* GetWindowAttrib)(GLFWwindow* window, int attrib);
void(SSCDECL* SetWindowAttrib)(GLFWwindow* window, int attrib, int value);
void(SSCDECL* SetWindowUserPointer)(GLFWwindow* window, void* pointer);
void* (SSCDECL* GetWindowUserPointer)(GLFWwindow* window);
GLFWwindowposfun(SSCDECL* SetWindowPosCallback)(GLFWwindow* window, GLFWwindowposfun callback);
GLFWwindowsizefun(SSCDECL* SetWindowSizeCallback)(GLFWwindow* window, GLFWwindowsizefun callback);
GLFWwindowclosefun(SSCDECL* SetWindowCloseCallback)(GLFWwindow* window, GLFWwindowclosefun callback);
GLFWwindowrefreshfun(SSCDECL* SetWindowRefreshCallback)(GLFWwindow* window, GLFWwindowrefreshfun callback);
GLFWwindowfocusfun(SSCDECL* SetWindowFocusCallback)(GLFWwindow* window, GLFWwindowfocusfun callback);
GLFWwindowiconifyfun(SSCDECL* SetWindowIconifyCallback)(GLFWwindow* window, GLFWwindowiconifyfun callback);
GLFWwindowmaximizefun(SSCDECL* SetWindowMaximizeCallback)(GLFWwindow* window, GLFWwindowmaximizefun callback);
GLFWframebuffersizefun(SSCDECL* SetFramebufferSizeCallback)(GLFWwindow* window, GLFWframebuffersizefun callback);
GLFWwindowcontentscalefun(SSCDECL* SetWindowContentScaleCallback)(GLFWwindow* window, GLFWwindowcontentscalefun callback);
void(SSCDECL* PollEvents)(void);
void(SSCDECL* WaitEvents)(void);
void(SSCDECL* WaitEventsTimeout)(double timeout);
void(SSCDECL* PostEmptyEvent)(void);
int(SSCDECL* GetInputMode)(GLFWwindow* window, int mode);
void(SSCDECL* SetInputMode)(GLFWwindow* window, int mode, int value);
int(SSCDECL* RawMouseMotionSupported)(void);
char* (SSCDECL* GetKeyName)(int key, int scancode);
int(SSCDECL* GetKeyScancode)(int key);
int(SSCDECL* GetKey)(GLFWwindow* window, int key);
int(SSCDECL* GetMouseButton)(GLFWwindow* window, int button);
void(SSCDECL* GetCursorPos)(GLFWwindow* window, double* xpos, double* ypos);
void(SSCDECL* SetCursorPos)(GLFWwindow* window, double xpos, double ypos);
GLFWcursor* (SSCDECL* CreateCursor)(GLFWimage* image, int xhot, int yhot);
GLFWcursor* (SSCDECL* CreateStandardCursor)(int shape);
void(SSCDECL* DestroyCursor)(GLFWcursor* cursor);
void(SSCDECL* SetCursor)(GLFWwindow* window, GLFWcursor* cursor);
GLFWkeyfun(SSCDECL* SetKeyCallback)(GLFWwindow* window, GLFWkeyfun callback);
GLFWcharfun(SSCDECL* SetCharCallback)(GLFWwindow* window, GLFWcharfun callback);
GLFWcharmodsfun(SSCDECL* SetCharModsCallback)(GLFWwindow* window, GLFWcharmodsfun callback);
GLFWmousebuttonfun(SSCDECL* SetMouseButtonCallback)(GLFWwindow* window, GLFWmousebuttonfun callback);
GLFWcursorposfun(SSCDECL* SetCursorPosCallback)(GLFWwindow* window, GLFWcursorposfun callback);
GLFWcursorenterfun(SSCDECL* SetCursorEnterCallback)(GLFWwindow* window, GLFWcursorenterfun callback);
GLFWscrollfun(SSCDECL* SetScrollCallback)(GLFWwindow* window, GLFWscrollfun callback);
GLFWdropfun(SSCDECL* SetDropCallback)(GLFWwindow* window, GLFWdropfun callback);
int(SSCDECL* JoystickPresent)(int jid);
float* (SSCDECL* GetJoystickAxes)(int jid, int* count);
unsigned char* (SSCDECL* GetJoystickButtons)(int jid, int* count);
unsigned char* (SSCDECL* GetJoystickHats)(int jid, int* count);
char* (SSCDECL* GetJoystickName)(int jid);
char* (SSCDECL* GetJoystickGUID)(int jid);
void(SSCDECL* SetJoystickUserPointer)(int jid, void* pointer);
void* (SSCDECL* GetJoystickUserPointer)(int jid);
int(SSCDECL* JoystickIsGamepad)(int jid);
GLFWjoystickfun(SSCDECL* SetJoystickCallback)(GLFWjoystickfun callback);
int(SSCDECL* UpdateGamepadMappings)(char* string);
char* (SSCDECL* GetGamepadName)(int jid);
int(SSCDECL* GetGamepadState)(int jid, GLFWgamepadstate* state);
void(SSCDECL* SetClipboardString)(GLFWwindow* window, char* string);
char* (SSCDECL* GetClipboardString)(GLFWwindow* window);
double(SSCDECL* GetTime)(void);
void(SSCDECL* SetTime)(double time);
uint64_t* (SSCDECL* GetTimerValue)(void);
uint64_t* (SSCDECL* GetTimerFrequency)(void);
void(SSCDECL* MakeContextCurrent)(GLFWwindow* window);
GLFWwindow* (SSCDECL* GetCurrentContext)(void);
void(SSCDECL* SwapBuffers)(GLFWwindow* window);
void(SSCDECL* SwapInterval)(int interval);
int(SSCDECL* ExtensionSupported)(char* extension);
GLFWglproc(SSCDECL* GetProcAddress)(char* procname);
int(SSCDECL* VulkanSupported)(void);
char** (SSCDECL* GetRequiredInstanceExtensions)(uint32_t* count);
#if defined(VK_VERSION_1_0)
GLFWvkproc(SSCDECL* GetInstanceProcAddress)(VkInstance instance, char* procname);
int(SSCDECL* GetPhysicalDevicePresentationSupport)(VkInstance instance, VkPhysicalDevice device, uint32_t* queuefamily);
VkResult(SSCDECL* CreateWindowSurface)(VkInstance instance, GLFWwindow* window, VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
#endif
}glfwContext;
extern glfwContext* glfw;
#pragma endregion
SSCAPI char* infolog[512];
SSCAPI void _cdecl initGL(int majorVersion, int minorVersion);
SSCAPI int _cdecl initGLAD(void);
SSCAPI unsigned int _cdecl loadShaderCode(char* const shaderCode, GLint shadertype);
SSCAPI unsigned int _cdecl linkShaderProgram(GLuint shadertype);
SSCAPI char* _cdecl readLog(void);
//linear related function
SSCAPI __m128* __cdecl set_m128ptr_default();
#pragma region mat define
typedef union matrix2map
{
__m128 colum[2];
float m[4][2];
}matrix2map;
typedef struct matrix3map
{
__m128 colum[3];
float m[4][3];
}matrix3map;
typedef union matrix4map {
__m128 colum[4];
float m[4][4];
}matrix4map;
#pragma endregion
#pragma region mat2
SSCAPI _inline void __cdecl transpose2to3(matrix2map* source, matrix3map* target);
SSCAPI _inline void __cdecl transpose2to4(matrix2map* source, matrix4map* target);
SSCAPI _inline void __cdecl deinit_mat2(matrix2map* mat);
#pragma endregion
#pragma region mat3
SSCAPI __inline void _cdecl transpose3to2(matrix3map* source, matrix2map* target);
SSCAPI __inline void _cdecl transpose3to3(matrix3map* source, matrix3map* target);
SSCAPI __inline void _cdecl transpose3to4(matrix3map* source, matrix4map* target);
SSCAPI _inline float _cdecl det_mat3(matrix3map* mat);
SSCAPI __inline float det_mat3_internal(__m128 const c1, __m128 const c2, __m128 const c3);
#pragma endregion
#pragma region mat4
//type and function for 4 colum matrix
SSCAPI __inline void __cdecl transpose4to2(matrix4map* source, matrix4map* target);
SSCAPI __inline void __cdecl transpose4to4(matrix4map* matrix, matrix4map* target);
SSCAPI __inline float __cdecl det_mat4(matrix4map* matPtr, matrix4map* transpose);
SSCAPI __inline void __cdecl deinit_mat4(matrix4map* matPtr);
#pragma endregion
#endif // !SSG