Floor the pixel positions of the text to the nearest integer.

Seems like multisampling, which appears to be enabled by default for some people even if disabled in glfw, does weird stuff when the positions are not pixel aligned.
Should fix #177
This commit is contained in:
IntegratedQuantum 2023-11-22 21:39:53 +01:00
parent e6b08081b2
commit 0c4f705082
3 changed files with 3 additions and 4 deletions

View File

@ -21,7 +21,7 @@ vec2 convert2Proportional(vec2 original, vec2 full){
void main() {
vec4 texture_rect_percentage = vec4(convert2Proportional(texture_rect.xy, fontSize), convert2Proportional(texture_rect.zw, fontSize));
vec4 texture_rect_percentage = vec4(convert2Proportional(texture_rect.xy, fontSize), convert2Proportional(texture_rect.zw, fontSize));
vec2 texture_position = vec2(
texture_rect_percentage.x+
frag_face_pos.x*texture_rect_percentage.z

View File

@ -23,8 +23,8 @@ vec2 convert2Proportional(vec2 original, vec2 full) {
void main() {
vec2 vertex_pos = face_pos*vec2(1, -1);
vec2 position_percentage = convert2Proportional(offset, scene);
vec2 size_percentage = convert2Proportional(vec2(texture_rect.z, texture_rect.w)*ratio, scene);
vec2 position_percentage = convert2Proportional(floor(offset), scene);
vec2 size_percentage = convert2Proportional(floor(vec2(texture_rect.z, texture_rect.w)*ratio), scene);
if ((fontEffects & 0x02000000) != 0) { // italic
vertex_pos.x += vertex_pos.y/texture_rect.z;
}

View File

@ -604,7 +604,6 @@ pub const Window = struct {
}
c.glfwWindowHint(c.GLFW_CONTEXT_VERSION_MAJOR, 4);
c.glfwWindowHint(c.GLFW_CONTEXT_VERSION_MINOR, 5);
c.glfwWindowHint(c.GLFW_SAMPLES, 0);
window = c.glfwCreateWindow(width, height, "Cubyz", null, null) orelse return error.GLFWFailed;