Merge branch 'kichikuou-mac-opengl' into master

This commit is contained in:
Nunuhara Cabbage
2020-09-03 10:39:31 -07:00
11 changed files with 24 additions and 20 deletions
+1
View File
@@ -29,6 +29,7 @@ struct sdl_private {
SDL_PixelFormat *format;
struct {
SDL_GLContext context;
GLuint vao;
GLuint vbo;
GLuint ibo;
} gl;
+2 -2
View File
@@ -16,14 +16,14 @@
#version 140
uniform sampler2D texture;
uniform sampler2D tex;
uniform float threshold;
in vec2 tex_coord;
out vec4 frag_color;
void main() {
vec4 texel = texture2D(texture, tex_coord);
vec4 texel = texture(tex, tex_coord);
texel.a *= threshold;
frag_color = texel;
}
+2 -2
View File
@@ -16,11 +16,11 @@
#version 140
uniform sampler2D texture;
uniform sampler2D tex;
in vec2 tex_coord;
out vec4 frag_color;
void main() {
frag_color = texture2D(texture, tex_coord);
frag_color = texture(tex, tex_coord);
}
+2 -2
View File
@@ -16,14 +16,14 @@
#version 140
uniform sampler2D texture;
uniform sampler2D tex;
uniform vec4 color;
in vec2 tex_coord;
out vec4 frag_color;
void main() {
vec4 texel = texture2D(texture, tex_coord);
vec4 texel = texture(tex, tex_coord);
if (texel.rgb == color.rgb)
discard;
frag_color = texel;
+2 -2
View File
@@ -16,14 +16,14 @@
#version 140
uniform sampler2D texture;
uniform sampler2D tex;
uniform float threshold;
in vec2 tex_coord;
out vec4 frag_color;
void main() {
vec4 texel = texture2D(texture, tex_coord);
vec4 texel = texture(tex, tex_coord);
if (texel.a < threshold)
discard;
frag_color = texel;
+2 -2
View File
@@ -16,14 +16,14 @@
#version 140
uniform sampler2D texture;
uniform sampler2D tex;
uniform float threshold;
in vec2 tex_coord;
out vec4 frag_color;
void main() {
vec4 texel = texture2D(texture, tex_coord);
vec4 texel = texture(tex, tex_coord);
if (texel.w > threshold)
discard;
frag_color = texel;
+3 -3
View File
@@ -16,7 +16,7 @@
#version 140
uniform sampler2D texture;
uniform sampler2D tex;
uniform vec2 bot_left;
uniform vec2 top_right;
@@ -29,11 +29,11 @@ float point_in_rect(vec2 p, vec2 bot_left, vec2 top_right) {
}
void main() {
ivec2 size = textureSize(texture, 0);
ivec2 size = textureSize(tex, 0);
vec2 tex_bot_left = bot_left / size;
vec2 tex_top_right = top_right / size;
vec4 texel = texture2D(texture, tex_coord);
vec4 texel = texture(tex, tex_coord);
float t = point_in_rect(tex_coord, tex_bot_left, tex_top_right);
frag_color = t * texel + (1 - t) * vec4(0, 0, 0, 0);
}
+3 -3
View File
@@ -16,7 +16,7 @@
#version 140
uniform sampler2D texture;
uniform sampler2D tex;
uniform vec2 bot_left;
uniform vec2 top_right;
@@ -29,11 +29,11 @@ float point_in_rect(vec2 p, vec2 bot_left, vec2 top_right) {
}
void main() {
ivec2 size = textureSize(texture, 0);
ivec2 size = textureSize(tex, 0);
vec2 tex_bot_left = bot_left / size;
vec2 tex_top_right = top_right / size;
vec4 texel = texture2D(texture, tex_coord);
vec4 texel = texture(tex, tex_coord);
texel.a = 1;
float t = point_in_rect(tex_coord, tex_bot_left, tex_top_right);
frag_color = t * texel + (1 - t) * vec4(0, 0, 0, 0);
+2 -2
View File
@@ -16,13 +16,13 @@
#version 140
uniform sampler2D texture;
uniform sampler2D tex;
uniform float alpha_mod;
in vec2 tex_coord;
out vec4 frag_color;
void main() {
frag_color = texture2D(texture, tex_coord);
frag_color = texture(tex, tex_coord);
frag_color.a *= alpha_mod;
}
+4 -1
View File
@@ -105,7 +105,7 @@ void gfx_load_shader(struct shader *dst, const char *vertex_shader_path, const c
dst->program = program;
dst->world_transform = glGetUniformLocation(program, "world_transform");
dst->view_transform = glGetUniformLocation(program, "view_transform");
dst->texture = glGetUniformLocation(program, "texture");
dst->texture = glGetUniformLocation(program, "tex");
dst->vertex = glGetAttribLocation(program, "vertex_pos");
dst->alpha_mod = glGetAttribLocation(program, "alpha_mod");
dst->prepare = NULL;
@@ -128,6 +128,9 @@ static int gl_initialize(void)
GLuint index_data[] = { 0, 1, 2, 3 };
glGenVertexArrays(1, &sdl.gl.vao);
glBindVertexArray(sdl.gl.vao);
glGenBuffers(1, &sdl.gl.vbo);
glBindBuffer(GL_ARRAY_BUFFER, sdl.gl.vbo);
glBufferData(GL_ARRAY_BUFFER, 4 * 4 * sizeof(GLfloat), vertex_data, GL_STATIC_DRAW);