Trying something crazy --- maybe
This commit is contained in:
parent
ac0bd78485
commit
99dc2fc570
|
@ -57,7 +57,7 @@ internal void
|
||||||
#ifdef OS_LINUX
|
#ifdef OS_LINUX
|
||||||
gl__error_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char *message, const void *userParam){
|
gl__error_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char *message, const void *userParam){
|
||||||
#else
|
#else
|
||||||
gl__error_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, char *message, void *userParam){
|
gl__error_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, char *message, void *userParam){
|
||||||
#endif
|
#endif
|
||||||
switch (id){
|
switch (id){
|
||||||
case 131218:
|
case 131218:
|
||||||
|
@ -70,85 +70,85 @@ gl__error_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsiz
|
||||||
InvalidPath;
|
InvalidPath;
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *gl__header = R"foo(#version 150
|
char *gl__header = R"foo(#version 130
|
||||||
)foo";
|
)foo";
|
||||||
|
|
||||||
char *gl__vertex = R"foo(
|
char *gl__vertex = R"foo(
|
||||||
uniform vec2 view_t;
|
uniform vec2 view_t;
|
||||||
uniform mat2x2 view_m;
|
uniform mat2x2 view_m;
|
||||||
in vec2 vertex_p;
|
in vec2 vertex_p;
|
||||||
in vec3 vertex_t;
|
in vec3 vertex_t;
|
||||||
in uint vertex_c;
|
in uint vertex_c;
|
||||||
in float vertex_ht;
|
in float vertex_ht;
|
||||||
smooth out vec4 fragment_color;
|
smooth out vec4 fragment_color;
|
||||||
smooth out vec3 uvw;
|
smooth out vec3 uvw;
|
||||||
smooth out vec2 xy;
|
smooth out vec2 xy;
|
||||||
smooth out vec2 adjusted_half_dim;
|
smooth out vec2 adjusted_half_dim;
|
||||||
smooth out float half_thickness;
|
smooth out float half_thickness;
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
gl_Position = vec4(view_m*(vertex_p - view_t), 0.0, 1.0);
|
gl_Position = vec4(view_m*(vertex_p - view_t), 0.0, 1.0);
|
||||||
fragment_color.b = (float((vertex_c )&0xFFu))/255.0;
|
fragment_color.b = (float((vertex_c )&0xFFu))/255.0;
|
||||||
fragment_color.g = (float((vertex_c>> 8u)&0xFFu))/255.0;
|
fragment_color.g = (float((vertex_c>> 8u)&0xFFu))/255.0;
|
||||||
fragment_color.r = (float((vertex_c>>16u)&0xFFu))/255.0;
|
fragment_color.r = (float((vertex_c>>16u)&0xFFu))/255.0;
|
||||||
fragment_color.a = (float((vertex_c>>24u)&0xFFu))/255.0;
|
fragment_color.a = (float((vertex_c>>24u)&0xFFu))/255.0;
|
||||||
uvw = vertex_t;
|
uvw = vertex_t;
|
||||||
vec2 center = vertex_t.xy;
|
vec2 center = vertex_t.xy;
|
||||||
vec2 half_dim = abs(vertex_p - center);
|
vec2 half_dim = abs(vertex_p - center);
|
||||||
adjusted_half_dim = half_dim - vertex_t.zz + vec2(0.5, 0.5);
|
adjusted_half_dim = half_dim - vertex_t.zz + vec2(0.5, 0.5);
|
||||||
half_thickness = vertex_ht;
|
half_thickness = vertex_ht;
|
||||||
xy = vertex_p;
|
xy = vertex_p;
|
||||||
}
|
}
|
||||||
)foo";
|
)foo";
|
||||||
|
|
||||||
char *gl__fragment = R"foo(
|
char *gl__fragment = R"foo(
|
||||||
smooth in vec4 fragment_color;
|
smooth in vec4 fragment_color;
|
||||||
smooth in vec3 uvw;
|
smooth in vec3 uvw;
|
||||||
smooth in vec2 xy;
|
smooth in vec2 xy;
|
||||||
smooth in vec2 adjusted_half_dim;
|
smooth in vec2 adjusted_half_dim;
|
||||||
smooth in float half_thickness;
|
smooth in float half_thickness;
|
||||||
uniform sampler2DArray sampler;
|
uniform sampler2DArray sampler;
|
||||||
out vec4 out_color;
|
out vec4 out_color;
|
||||||
|
|
||||||
float rectangle_sd(vec2 p, vec2 b){
|
float rectangle_sd(vec2 p, vec2 b){
|
||||||
vec2 d = abs(p) - b;
|
vec2 d = abs(p) - b;
|
||||||
return(length(max(d, vec2(0.0, 0.0))) + min(max(d.x, d.y), 0.0));
|
return(length(max(d, vec2(0.0, 0.0))) + min(max(d.x, d.y), 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
float has_thickness = (step(0.49, half_thickness));
|
float has_thickness = (step(0.49, half_thickness));
|
||||||
float does_not_have_thickness = 1.0 - has_thickness;
|
float does_not_have_thickness = 1.0 - has_thickness;
|
||||||
|
|
||||||
float sample_value = texture(sampler, uvw).r;
|
float sample_value = texture(sampler, uvw).r;
|
||||||
sample_value *= does_not_have_thickness;
|
sample_value *= does_not_have_thickness;
|
||||||
|
|
||||||
vec2 center = uvw.xy;
|
vec2 center = uvw.xy;
|
||||||
float roundness = uvw.z;
|
float roundness = uvw.z;
|
||||||
float sd = rectangle_sd(xy - center, adjusted_half_dim);
|
float sd = rectangle_sd(xy - center, adjusted_half_dim);
|
||||||
sd = sd - roundness;
|
sd = sd - roundness;
|
||||||
sd = abs(sd + half_thickness) - half_thickness;
|
sd = abs(sd + half_thickness) - half_thickness;
|
||||||
float shape_value = 1.0 - smoothstep(-1.0, 0.0, sd);
|
float shape_value = 1.0 - smoothstep(-1.0, 0.0, sd);
|
||||||
shape_value *= has_thickness;
|
shape_value *= has_thickness;
|
||||||
|
|
||||||
out_color = vec4(fragment_color.xyz, fragment_color.a*(sample_value + shape_value));
|
out_color = vec4(fragment_color.xyz, fragment_color.a*(sample_value + shape_value));
|
||||||
}
|
}
|
||||||
)foo";
|
)foo";
|
||||||
|
|
||||||
#define AttributeList(X) \
|
#define AttributeList(X) \
|
||||||
X(vertex_p) \
|
X(vertex_p) \
|
||||||
X(vertex_t) \
|
X(vertex_t) \
|
||||||
X(vertex_c) \
|
X(vertex_c) \
|
||||||
X(vertex_ht)
|
X(vertex_ht)
|
||||||
|
|
||||||
#define UniformList(X) \
|
#define UniformList(X) \
|
||||||
X(view_t) \
|
X(view_t) \
|
||||||
X(view_m) \
|
X(view_m) \
|
||||||
X(sampler)
|
X(sampler)
|
||||||
|
|
||||||
struct GL_Program{
|
struct GL_Program{
|
||||||
u32 program;
|
u32 program;
|
||||||
#define GetAttributeLocation(N) i32 N;
|
#define GetAttributeLocation(N) i32 N;
|
||||||
AttributeList(GetAttributeLocation)
|
AttributeList(GetAttributeLocation)
|
||||||
|
@ -156,10 +156,10 @@ struct GL_Program{
|
||||||
#define GetUniformLocation(N) i32 N;
|
#define GetUniformLocation(N) i32 N;
|
||||||
UniformList(GetUniformLocation)
|
UniformList(GetUniformLocation)
|
||||||
#undef GetUniformLocation
|
#undef GetUniformLocation
|
||||||
};
|
};
|
||||||
|
|
||||||
internal GL_Program
|
internal GL_Program
|
||||||
gl__make_program(char *header, char *vertex, char *fragment){
|
gl__make_program(char *header, char *vertex, char *fragment){
|
||||||
if (header == 0){
|
if (header == 0){
|
||||||
header = "";
|
header = "";
|
||||||
}
|
}
|
||||||
|
@ -208,13 +208,13 @@ gl__make_program(char *header, char *vertex, char *fragment){
|
||||||
UniformList(GetUniformLocation)
|
UniformList(GetUniformLocation)
|
||||||
#undef GetUniformLocation
|
#undef GetUniformLocation
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GLOffsetStruct(p,m) ((void*)(OffsetOfMemberStruct(p,m)))
|
#define GLOffsetStruct(p,m) ((void*)(OffsetOfMemberStruct(p,m)))
|
||||||
#define GLOffset(S,m) ((void*)(OffsetOfMember(S,m)))
|
#define GLOffset(S,m) ((void*)(OffsetOfMember(S,m)))
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
gl_render(Render_Target *t){
|
gl_render(Render_Target *t){
|
||||||
Font_Set *font_set = (Font_Set*)t->font_set;
|
Font_Set *font_set = (Font_Set*)t->font_set;
|
||||||
|
|
||||||
local_persist b32 first_opengl_call = true;
|
local_persist b32 first_opengl_call = true;
|
||||||
|
@ -354,7 +354,8 @@ gl_render(Render_Target *t){
|
||||||
}
|
}
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BOTTOM
|
||||||
|
|
||||||
// BOTTOM
|
|
||||||
|
|
Loading…
Reference in New Issue