multisampling
parent
82f8bdb081
commit
cd7c34cb16
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
|
|
||||||
set(BLT_GRAPHICS_VERSION 0.9.10)
|
set(BLT_GRAPHICS_VERSION 0.9.11)
|
||||||
set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
|
set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
|
||||||
|
|
||||||
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})
|
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})
|
||||||
|
|
|
@ -12,6 +12,8 @@ uniform sampler2D tex;
|
||||||
uniform vec4 color;
|
uniform vec4 color;
|
||||||
uniform vec4 use_texture;
|
uniform vec4 use_texture;
|
||||||
|
|
||||||
|
const float offset = 1.0 / 32.0;
|
||||||
|
|
||||||
vec4 linear_iter(vec4 i, vec4 p, float factor){
|
vec4 linear_iter(vec4 i, vec4 p, float factor){
|
||||||
return (i + p) * factor;
|
return (i + p) * factor;
|
||||||
}
|
}
|
||||||
|
@ -19,9 +21,14 @@ vec4 linear_iter(vec4 i, vec4 p, float factor){
|
||||||
void main() {
|
void main() {
|
||||||
float xs = pos.x * pos.x;
|
float xs = pos.x * pos.x;
|
||||||
float ys = pos.y * pos.y;
|
float ys = pos.y * pos.y;
|
||||||
if (xs + ys > 0.5 * 0.5)
|
float ts = xs + ys;
|
||||||
|
const float sq = 0.5 * 0.5;
|
||||||
|
if (ts > sq)
|
||||||
discard;
|
discard;
|
||||||
FragColor = (texture(tex, uv) * use_texture) + color;
|
if (ts + offset > sq)
|
||||||
|
FragColor = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
|
else
|
||||||
|
FragColor = (texture(tex, uv) * use_texture) + color;
|
||||||
}
|
}
|
||||||
|
|
||||||
")";
|
")";
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace blt::gfx
|
||||||
std::int32_t GL_MINOR = 6;
|
std::int32_t GL_MINOR = 6;
|
||||||
std::int32_t DOUBLE_BUFFER = GLFW_TRUE;
|
std::int32_t DOUBLE_BUFFER = GLFW_TRUE;
|
||||||
std::int32_t GL_PROFILE = GLFW_OPENGL_CORE_PROFILE;
|
std::int32_t GL_PROFILE = GLFW_OPENGL_CORE_PROFILE;
|
||||||
|
std::int32_t SAMPLES = 8;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct window_data
|
struct window_data
|
||||||
|
|
|
@ -186,6 +186,7 @@ namespace blt::gfx
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, data.context.GL_MINOR);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, data.context.GL_MINOR);
|
||||||
glfwWindowHint(GLFW_DOUBLEBUFFER, data.context.DOUBLE_BUFFER);
|
glfwWindowHint(GLFW_DOUBLEBUFFER, data.context.DOUBLE_BUFFER);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, data.context.GL_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, data.context.GL_PROFILE);
|
||||||
|
glfwWindowHint(GLFW_SAMPLES, data.context.SAMPLES);
|
||||||
|
|
||||||
/* -- Create the Window -- */
|
/* -- Create the Window -- */
|
||||||
window_state.window = glfwCreateWindow(data.width, data.height, data.title.c_str(), nullptr, nullptr);
|
window_state.window = glfwCreateWindow(data.width, data.height, data.title.c_str(), nullptr, nullptr);
|
||||||
|
@ -204,6 +205,9 @@ namespace blt::gfx
|
||||||
/* -- Set up ImGUI -- */
|
/* -- Set up ImGUI -- */
|
||||||
setup_ImGUI();
|
setup_ImGUI();
|
||||||
|
|
||||||
|
if (data.context.SAMPLES > 0)
|
||||||
|
glEnable(GL_MULTISAMPLE);
|
||||||
|
|
||||||
/* -- Call User Provided post-window-init function -- */
|
/* -- Call User Provided post-window-init function -- */
|
||||||
data.init();
|
data.init();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue