-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change vertex format for 2d rendering
- Loading branch information
Showing
10 changed files
with
262 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#version 450 | ||
|
||
layout(location = 0) in vec3 fragColor; | ||
layout(location = 1) in vec2 fragTexCoord; | ||
|
||
layout(set = 0, binding = 1) uniform sampler2D texSampler; | ||
|
||
layout(location = 0) out vec4 outColor; | ||
|
||
void main() { | ||
// outColor = vec4(fragColor, 1.0) * texture(texSampler, fragTexCoord); | ||
// outColor = vec4(fragColor, 1.0) * texture(texSampler, fragTexCoord / 200); | ||
outColor = vec4(fragColor, 1.0) * texture(texSampler, fragTexCoord / textureSize(texSampler, 0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#version 450 | ||
|
||
layout(row_major) layout(set = 0, binding = 0) uniform UniformBufferObject { | ||
vec2 screenSize; | ||
} ubo; | ||
|
||
layout(location = 0) in vec2 inPosition; | ||
layout(location = 1) in vec2 inTexCoord; | ||
layout(location = 2) in vec3 inColor; | ||
|
||
layout(location = 0) out vec3 fragColor; | ||
layout(location = 1) out vec2 fragTexCoord; | ||
|
||
void main() { | ||
// gl_Position = vec4(inPosition, 0.0, 1.0); | ||
gl_Position = vec4((inPosition / ubo.screenSize) * 2 - 1, 0.0, 1.0); | ||
fragColor = inColor; | ||
fragTexCoord = inTexCoord; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module hello_triangle.image; | ||
|
||
import core.utils; | ||
import core.vector; | ||
import core.mimalloc; | ||
|
||
// 4 channels, u8u8u8u8 rgba | ||
struct ImageData { | ||
u8* ptr; | ||
uvec2 size; | ||
|
||
u32 byteLength() { return size.x * size.y * 4; } | ||
|
||
void free() { | ||
mi_free(ptr); | ||
ptr = null; | ||
size = uvec2(0, 0); | ||
} | ||
} |
Oops, something went wrong.