parent
71e2042967
commit
bcef33db10
@ -0,0 +1,10 @@
|
||||
// bool.h
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
@ -0,0 +1,27 @@
|
||||
// color.c
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
#include "color.h"
|
||||
#include "math.h"
|
||||
|
||||
#include <stdint.h>
|
||||
RGBA readHexColor(unsigned int color) {
|
||||
RGBA col;
|
||||
*(uint32_t*)&col = _byteswap_ulong(color);
|
||||
return col;
|
||||
}
|
||||
|
||||
RGBA_normalized normalizeHexColor(unsigned int color) {
|
||||
RGBA col = readHexColor(color);
|
||||
RGBA_normalized ncol;
|
||||
|
||||
ncol.R = normalize(col.R, 0xFF);
|
||||
ncol.G = normalize(col.G, 0xFF);
|
||||
ncol.B = normalize(col.B, 0xFF);
|
||||
ncol.A = normalize(col.A, 0xFF);
|
||||
return ncol;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
// color.h
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct RGBA {
|
||||
uint8_t R;
|
||||
uint8_t G;
|
||||
uint8_t B;
|
||||
uint8_t A;
|
||||
} RGBA;
|
||||
|
||||
typedef struct RGBA_normalized {
|
||||
float R;
|
||||
float G;
|
||||
float B;
|
||||
float A;
|
||||
} RGBA_normalized;
|
||||
|
||||
RGBA readHexColor(unsigned int color);
|
||||
RGBA_normalized normalizeHexColor(unsigned int color);
|
@ -0,0 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
const uint8_t default_frag[0x79] = {
|
||||
0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x20, 0x33, 0x33, 0x30, 0x20, 0x63, 0x6F, 0x72, 0x65, 0x0D, 0x0A, 0x0D, 0x0A, 0x6C, 0x61, 0x79, 0x6F, 0x75, 0x74, 0x28, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x3D, 0x20, 0x30, 0x29, 0x20, 0x6F, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x3B, 0x0D, 0x0A, 0x0D, 0x0A, 0x75, 0x6E, 0x69, 0x66, 0x6F, 0x72, 0x6D, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x75, 0x5F, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x3B, 0x0D, 0x0A, 0x0D, 0x0A, 0x76, 0x6F, 0x69, 0x64, 0x20, 0x6D, 0x61, 0x69, 0x6E, 0x28, 0x29, 0x7B, 0x0D, 0x0A, 0x09, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x20, 0x3D, 0x20, 0x75, 0x5F, 0x43, 0x6F, 0x6C, 0x6F, 0x72, 0x3B, 0x0D, 0x0A, 0x7D, 0x00
|
||||
};
|
||||
const uint64_t default_frag_len = 0x78;
|
@ -1,6 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
const uint8_t default_frg[0x71] = {
|
||||
0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x20, 0x33, 0x33, 0x30, 0x20, 0x63, 0x6F, 0x72, 0x65, 0x0D, 0x0A, 0x0D, 0x0A, 0x6C, 0x61, 0x79, 0x6F, 0x75, 0x74, 0x28, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x3D, 0x20, 0x30, 0x29, 0x20, 0x6F, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x3B, 0x0D, 0x0A, 0x0D, 0x0A, 0x76, 0x6F, 0x69, 0x64, 0x20, 0x6D, 0x61, 0x69, 0x6E, 0x28, 0x29, 0x7B, 0x0D, 0x0A, 0x09, 0x63, 0x6F, 0x6C, 0x6F, 0x72, 0x20, 0x3D, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x31, 0x2E, 0x30, 0x2C, 0x20, 0x30, 0x2E, 0x30, 0x2C, 0x20, 0x30, 0x2E, 0x30, 0x2C, 0x20, 0x31, 0x2E, 0x30, 0x29, 0x3B, 0x0D, 0x0A, 0x7D, 0x00
|
||||
};
|
||||
const uint64_t default_frg_len = 0x70;
|
@ -1,6 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
const uint8_t default_vrt[0x6a] = {
|
||||
const uint8_t default_vert[0x6a] = {
|
||||
0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x20, 0x33, 0x33, 0x30, 0x20, 0x63, 0x6F, 0x72, 0x65, 0x0D, 0x0A, 0x0D, 0x0A, 0x6C, 0x61, 0x79, 0x6F, 0x75, 0x74, 0x28, 0x6C, 0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x3D, 0x20, 0x30, 0x29, 0x20, 0x69, 0x6E, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x0D, 0x0A, 0x0D, 0x0A, 0x76, 0x6F, 0x69, 0x64, 0x20, 0x6D, 0x61, 0x69, 0x6E, 0x28, 0x29, 0x7B, 0x0D, 0x0A, 0x09, 0x67, 0x6C, 0x5F, 0x50, 0x6F, 0x73, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x3D, 0x20, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x20, 0x0D, 0x0A, 0x7D, 0x00
|
||||
};
|
||||
const uint64_t default_vrt_len = 0x69;
|
||||
const uint64_t default_vert_len = 0x69;
|
@ -0,0 +1,25 @@
|
||||
// errorhandling.c
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include "errorhandling.h"
|
||||
|
||||
void ClearError() {
|
||||
while (glGetError() != GL_NO_ERROR);
|
||||
}
|
||||
|
||||
int LogError(char* function, char* file, int line) {
|
||||
GLenum err = glGetError();
|
||||
if (err != GL_NO_ERROR) {
|
||||
printf("[OpenGL Error] 0x%x; in function %s on %s:%i\n", err, function, file, line);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
// errorhandling.h
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
|
||||
#define ASSERT(x) if (!(x)) __debugbreak();
|
||||
#ifdef _DEBUG
|
||||
#define GLCall(x) \
|
||||
ClearError(); \
|
||||
x; \
|
||||
ASSERT(LogError(#x, __FILE__, __LINE__) == 0);
|
||||
#else
|
||||
#define GLCall(x) x;
|
||||
#endif
|
||||
|
||||
void ClearError();
|
||||
int LogError(char* function, char* file, int line);
|
@ -0,0 +1,30 @@
|
||||
// indexbuffer.c
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
|
||||
#include <stdint.h>
|
||||
#include <GL/glew.h>
|
||||
#include "bool.h"
|
||||
#include "errorhandling.h"
|
||||
|
||||
int createIndexBuffer(void* indexBuffer, size_t indexBufferSz) {
|
||||
int indexBufferId = 0;
|
||||
GLCall(glGenBuffers(1, &indexBufferId));
|
||||
bindIndexBuffer(indexBufferId);
|
||||
GLCall(glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexBufferSz, indexBuffer, GL_STATIC_DRAW));
|
||||
return indexBufferId;
|
||||
}
|
||||
|
||||
int deleteIndexBuffer(int indexBufferId) {
|
||||
GLCall(glDeleteBuffers(1, &indexBufferId));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int bindIndexBuffer(int indexBuffer) {
|
||||
GLCall(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer));
|
||||
return TRUE;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
// indexbuffer.h
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
|
||||
int createIndexBuffer(void* indexBuffer, size_t indexBufferSz);
|
||||
int deleteIndexBuffer(int indexBufferId);
|
||||
int bindIndexBuffer(int indexBuffer);
|
@ -0,0 +1,12 @@
|
||||
// math.c
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
|
||||
|
||||
float normalize(int value, int max) {
|
||||
return ((float)value / max);
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
// math.h
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
|
||||
float normalize(int value, int max);
|
@ -0,0 +1,56 @@
|
||||
// shader.c
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include "errorhandling.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static unsigned int compileShader(const char* shaderSourceCode, unsigned int type) {
|
||||
GLCall(unsigned int shaderId = glCreateShader(type));
|
||||
|
||||
GLCall(glShaderSource(shaderId, 1, &shaderSourceCode, NULL));
|
||||
GLCall(glCompileShader(shaderId));
|
||||
|
||||
int shaderCompileStatus;
|
||||
GLCall(glGetShaderiv(shaderId, GL_COMPILE_STATUS, &shaderCompileStatus));
|
||||
if (shaderCompileStatus == GL_FALSE) {
|
||||
int len;
|
||||
GLCall(glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &len));
|
||||
|
||||
char* log = malloc(len * sizeof(char));
|
||||
GLCall(glGetShaderInfoLog(shaderId, len, &len, log));
|
||||
|
||||
printf("== %s SHADER COMPILATION FAILED ==\n%s\n", (type == GL_VERTEX_SHADER ? "VERTEX" : "FRAGMENT"), log);
|
||||
|
||||
free(log);
|
||||
|
||||
glDeleteShader(shaderId);
|
||||
|
||||
ASSERT(shaderCompileStatus == GL_FALSE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return shaderId;
|
||||
}
|
||||
unsigned int createProgram(const char* vertexShaderCode, const char* fragmentShaderCode) {
|
||||
unsigned int program = glCreateProgram();
|
||||
unsigned int vertexShader = compileShader(vertexShaderCode, GL_VERTEX_SHADER);
|
||||
unsigned int fragmentShader = compileShader(fragmentShaderCode, GL_FRAGMENT_SHADER);
|
||||
|
||||
GLCall(glAttachShader(program, vertexShader));
|
||||
GLCall(glAttachShader(program, fragmentShader));
|
||||
|
||||
GLCall(glLinkProgram(program));
|
||||
GLCall(glValidateProgram(program));
|
||||
|
||||
GLCall(glDeleteShader(vertexShader));
|
||||
GLCall(glDeleteShader(fragmentShader));
|
||||
|
||||
return program;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
// shader.h
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
|
||||
unsigned int createProgram(const char* vertexShaderCode, const char* fragmentShaderCode);
|
@ -0,0 +1,29 @@
|
||||
// vertexbuffer.c
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
|
||||
#include <stdint.h>
|
||||
#include <GL/glew.h>
|
||||
#include "bool.h"
|
||||
#include "errorhandling.h"
|
||||
|
||||
int createVertexBuffer(void* vertexBuffer, size_t vertexBufferSz) {
|
||||
int vertexBufferId = 0;
|
||||
GLCall(glGenBuffers(1, &vertexBufferId));
|
||||
bindVertexBuffer(vertexBufferId);
|
||||
GLCall(glBufferData(GL_ARRAY_BUFFER, vertexBufferSz, vertexBuffer, GL_STATIC_DRAW));
|
||||
return vertexBufferId;
|
||||
}
|
||||
|
||||
int deleteVertexBuffer(int vertexBufferId) {
|
||||
GLCall(glDeleteBuffers(1, &vertexBufferId));
|
||||
return TRUE;
|
||||
}
|
||||
int bindVertexBuffer(int vertexBufferId) {
|
||||
GLCall(glBindBuffer(GL_ARRAY_BUFFER, vertexBufferId));
|
||||
return TRUE;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
// vertexbuffer.c
|
||||
//
|
||||
// Li2D - Vita2d-like graphics API!
|
||||
//
|
||||
// Created by Li
|
||||
//
|
||||
// Trans rights are human rights
|
||||
|
||||
|
||||
int createVertexBuffer(void* vertexBuffer, size_t vertexBufferSz);
|
||||
int deleteVertexBuffer(int vertexBufferId);
|
||||
int bindVertexBuffer(int vertexBuffer);
|
@ -0,0 +1,13 @@
|
||||
c:\users\user\documents\git\li2d\tools\vc143.pdb
|
||||
c:\users\user\documents\git\li2d\tools\compileheaders.obj
|
||||
c:\users\user\documents\git\li2d\tools\compileheaders.ipdb
|
||||
c:\users\user\documents\git\li2d\tools\compileheaders.iobj
|
||||
c:\users\user\documents\git\li2d\tools\compileheaders.exe
|
||||
c:\users\user\documents\git\li2d\li2d\..\tools\compileheaders.vcxproj.filelistabsolute.txt
|
||||
c:\users\user\documents\git\li2d\tools\compileheaders.tlog\cl.command.1.tlog
|
||||
c:\users\user\documents\git\li2d\tools\compileheaders.tlog\cl.read.1.tlog
|
||||
c:\users\user\documents\git\li2d\tools\compileheaders.tlog\cl.write.1.tlog
|
||||
c:\users\user\documents\git\li2d\tools\compileheaders.tlog\compileheaders.write.1u.tlog
|
||||
c:\users\user\documents\git\li2d\tools\compileheaders.tlog\link.command.1.tlog
|
||||
c:\users\user\documents\git\li2d\tools\compileheaders.tlog\link.read.1.tlog
|
||||
c:\users\user\documents\git\li2d\tools\compileheaders.tlog\link.write.1.tlog
|
Binary file not shown.
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>C:\Users\User\Documents\git\Li2D\tools\compileHeaders.exe</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
<SatelliteDlls />
|
||||
<NonRecipeFileRefs />
|
||||
</Project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(520,5): warning MSB8004: Output Directory does not end with a trailing slash. This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
|
||||
compileHeaders.c
|
||||
compileHeaders.vcxproj -> C:\Users\User\Documents\git\Li2D\tools\compileHeaders.exe
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.33.31517:TargetPlatformVersion=10.0.22000.0:VcpkgTriplet=x64-windows:
|
||||
Debug|x64|C:\Users\User\Documents\git\Li2D\Li2D\|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
C:\Users\User\Documents\git\Li2D\tools\compileHeaders.exe
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
|
Loading…
Reference in new issue