Fix syntax on Linux; drop GL version to 3.3
This commit is contained in:
parent
2f181f23aa
commit
30daf10cdd
|
@ -32,7 +32,7 @@ const SHELF_HEIGHT: u32 = 32;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut glfw = glfw::init(glfw::LOG_ERRORS).unwrap();
|
let mut glfw = glfw::init(glfw::LOG_ERRORS).unwrap();
|
||||||
glfw.window_hint(WindowHint::ContextVersion(4, 1));
|
glfw.window_hint(WindowHint::ContextVersion(3, 3));
|
||||||
glfw.window_hint(WindowHint::OpenGlForwardCompat(true));
|
glfw.window_hint(WindowHint::OpenGlForwardCompat(true));
|
||||||
glfw.window_hint(WindowHint::OpenGlProfile(OpenGlProfileHint::Core));
|
glfw.window_hint(WindowHint::OpenGlProfile(OpenGlProfileHint::Core));
|
||||||
let context = glfw.create_window(WIDTH, HEIGHT, "generate-atlas", WindowMode::Windowed);
|
let context = glfw.create_window(WIDTH, HEIGHT, "generate-atlas", WindowMode::Windowed);
|
||||||
|
|
|
@ -17,9 +17,12 @@
|
||||||
#version 330
|
#version 330
|
||||||
#extension GL_ARB_compute_shader : require
|
#extension GL_ARB_compute_shader : require
|
||||||
#extension GL_ARB_explicit_uniform_location : require
|
#extension GL_ARB_explicit_uniform_location : require
|
||||||
|
#extension GL_ARB_shader_image_load_store : require
|
||||||
#extension GL_ARB_shader_storage_buffer_object : require
|
#extension GL_ARB_shader_storage_buffer_object : require
|
||||||
|
|
||||||
uniform uimage2DRect uTexture;
|
layout(local_size_x = 1024) in;
|
||||||
|
|
||||||
|
uniform restrict writeonly uimage2DRect uTexture;
|
||||||
uniform sampler2DRect uCoverage;
|
uniform sampler2DRect uCoverage;
|
||||||
uniform uvec4 uAtlasRect;
|
uniform uvec4 uAtlasRect;
|
||||||
uniform uint uAtlasShelfHeight;
|
uniform uint uAtlasShelfHeight;
|
||||||
|
@ -29,13 +32,14 @@ void main() {
|
||||||
uint atlasWidth = uAtlasRect.z - uAtlasRect.x;
|
uint atlasWidth = uAtlasRect.z - uAtlasRect.x;
|
||||||
uint column = gl_GlobalInvocationID.x % atlasWidth;
|
uint column = gl_GlobalInvocationID.x % atlasWidth;
|
||||||
uint shelfIndex = gl_GlobalInvocationID.x / atlasWidth;
|
uint shelfIndex = gl_GlobalInvocationID.x / atlasWidth;
|
||||||
uint firstRow = shelfIndex * uAtlasShelfHeight, lastRow = (shelfIndex + 1) * uAtlasShelfHeight;
|
uint firstRow = shelfIndex * uAtlasShelfHeight;
|
||||||
|
uint lastRow = (shelfIndex + 1u) * uAtlasShelfHeight;
|
||||||
|
|
||||||
// Sweep down the column, accumulating coverage as we go.
|
// Sweep down the column, accumulating coverage as we go.
|
||||||
float coverage = 0.0f;
|
float coverage = 0.0f;
|
||||||
for (uint row = firstRow; row < lastRow; row++) {
|
for (uint row = firstRow; row < lastRow; row++) {
|
||||||
ivec2 coord = ivec2(column, row);
|
ivec2 coord = ivec2(column, row);
|
||||||
coverage += texelFetch(uCoverage, coord);
|
coverage += texelFetch(uCoverage, coord).r;
|
||||||
|
|
||||||
uint gray = uint(clamp(coverage, 0.0f, 1.0f) * 255.0f);
|
uint gray = uint(clamp(coverage, 0.0f, 1.0f) * 255.0f);
|
||||||
imageStore(uTexture, coord + ivec2(uAtlasRect.xy), uvec4(gray, 255, 255, 255));
|
imageStore(uTexture, coord + ivec2(uAtlasRect.xy), uvec4(gray, 255, 255, 255));
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#version 410
|
#version 330
|
||||||
|
|
||||||
// The size of the atlas in pixels.
|
// The size of the atlas in pixels.
|
||||||
uniform uvec2 uAtlasSize;
|
uniform uvec2 uAtlasSize;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
// To use this shader, set `RasterizerOptions::force_geometry_shader` to true or set the
|
// To use this shader, set `RasterizerOptions::force_geometry_shader` to true or set the
|
||||||
// environment variable `PATHFINDER_FORCE_GEOMETRY_SHADER` to 1.
|
// environment variable `PATHFINDER_FORCE_GEOMETRY_SHADER` to 1.
|
||||||
|
|
||||||
#version 410
|
#version 330
|
||||||
|
|
||||||
#define CURVE_THRESHOLD 0.333f
|
#define CURVE_THRESHOLD 0.333f
|
||||||
#define CURVE_TOLERANCE 3.0f
|
#define CURVE_TOLERANCE 3.0f
|
||||||
|
@ -39,7 +39,7 @@ layout(triangle_strip, max_vertices = 256) out;
|
||||||
uniform uvec2 uAtlasSize;
|
uniform uvec2 uAtlasSize;
|
||||||
|
|
||||||
// The vertex ID, passed into this shader.
|
// The vertex ID, passed into this shader.
|
||||||
flat in uint vVertexID[];
|
flat in int vVertexID[];
|
||||||
|
|
||||||
// The starting point of the segment.
|
// The starting point of the segment.
|
||||||
flat out vec2 vP0;
|
flat out vec2 vP0;
|
||||||
|
@ -69,7 +69,7 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine how many lines to divide into.
|
// Determine how many lines to divide into.
|
||||||
uint lineCount = 1;
|
uint lineCount = 1u;
|
||||||
if (vVertexID[1] > 0) {
|
if (vVertexID[1] > 0) {
|
||||||
// Quadratic curve.
|
// Quadratic curve.
|
||||||
vec2 dev = p0 - 2.0f * p1 + p2;
|
vec2 dev = p0 - 2.0f * p1 + p2;
|
||||||
|
@ -82,16 +82,16 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Divide into lines.
|
// Divide into lines.
|
||||||
for (uint lineIndex = 0; lineIndex < lineCount; lineIndex++) {
|
for (uint lineIndex = 0u; lineIndex < lineCount; lineIndex++) {
|
||||||
// Compute our endpoints (trivial if this is part of a line, less trivial if this is part
|
// Compute our endpoints (trivial if this is part of a line, less trivial if this is part
|
||||||
// of a curve).
|
// of a curve).
|
||||||
vec2 lP0, lP1;
|
vec2 lP0, lP1;
|
||||||
if (lineCount == 1) {
|
if (lineCount == 1u) {
|
||||||
lP0 = p0;
|
lP0 = p0;
|
||||||
lP1 = p2;
|
lP1 = p2;
|
||||||
} else {
|
} else {
|
||||||
float t0 = float(lineIndex + 0) / float(lineCount);
|
float t0 = float(lineIndex + 0u) / float(lineCount);
|
||||||
float t1 = float(lineIndex + 1) / float(lineCount);
|
float t1 = float(lineIndex + 1u) / float(lineCount);
|
||||||
lP0 = mix(mix(p0, p1, t0), mix(p1, p2, t0), t0);
|
lP0 = mix(mix(p0, p1, t0), mix(p1, p2, t0), t0);
|
||||||
lP1 = mix(mix(p0, p1, t1), mix(p1, p2, t1), t1);
|
lP1 = mix(mix(p0, p1, t1), mix(p1, p2, t1), t1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
layout(vertices = 1) out;
|
layout(vertices = 1) out;
|
||||||
|
|
||||||
// The vertex ID, passed into this shader.
|
// The vertex ID, passed into this shader.
|
||||||
flat in uint vVertexID[];
|
flat in int vVertexID[];
|
||||||
|
|
||||||
// The starting point of the segment.
|
// The starting point of the segment.
|
||||||
patch out vec2 vpP0;
|
patch out vec2 vpP0;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#version 410
|
#version 330
|
||||||
|
|
||||||
#define MAX_GLYPHS 2048
|
#define MAX_GLYPHS 2048
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ in ivec2 aPosition;
|
||||||
in uint aGlyphIndex;
|
in uint aGlyphIndex;
|
||||||
|
|
||||||
// The vertex ID, passed along onto the TCS.
|
// The vertex ID, passed along onto the TCS.
|
||||||
flat out uint vVertexID;
|
flat out int vVertexID;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vVertexID = gl_VertexID;
|
vVertexID = gl_VertexID;
|
||||||
|
|
Loading…
Reference in New Issue