mirror of
https://github.com/UOH-CS-Level5/551455-graphics-programming-2526-the-repo-Zyb3rWolfi.git
synced 2025-11-29 00:43:08 +00:00
start work on the shader
This commit is contained in:
parent
7ab6868f19
commit
4b66f524d0
@ -15,9 +15,9 @@ namespace TheLabs
|
|||||||
// OpenGL only supports rendering in 3D, so to create a flat triangle, the Z coordinate will be kept as 0.
|
// OpenGL only supports rendering in 3D, so to create a flat triangle, the Z coordinate will be kept as 0.
|
||||||
private readonly float[] _vertices =
|
private readonly float[] _vertices =
|
||||||
{
|
{
|
||||||
-0.5f, -0.5f, 0.0f, // Bottom-left vertex
|
-0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, // Bottom-left vertex
|
||||||
0.5f, -0.5f, 0.0f, // Bottom-right vertex
|
0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, // Bottom-right vertex
|
||||||
0.0f, 0.5f, 0.0f // Top vertex
|
0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, // Top vertex
|
||||||
};
|
};
|
||||||
|
|
||||||
// These are the handles to OpenGL objects. A handle is an integer representing where the object lives on the
|
// These are the handles to OpenGL objects. A handle is an integer representing where the object lives on the
|
||||||
@ -101,10 +101,12 @@ namespace TheLabs
|
|||||||
// The stride; this is how many bytes are between the last element of one vertex and the first element of the next. 3 * sizeof(float) in this case.
|
// The stride; this is how many bytes are between the last element of one vertex and the first element of the next. 3 * sizeof(float) in this case.
|
||||||
// The offset; this is how many bytes it should skip to find the first element of the first vertex. 0 as of right now.
|
// The offset; this is how many bytes it should skip to find the first element of the first vertex. 0 as of right now.
|
||||||
// Stride and Offset are just sort of glossed over for now, but when we get into texture coordinates they'll be shown in better detail.
|
// Stride and Offset are just sort of glossed over for now, but when we get into texture coordinates they'll be shown in better detail.
|
||||||
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), 0);
|
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 7 * sizeof(float), 0);
|
||||||
|
GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, 7 * sizeof(float), 4);
|
||||||
|
|
||||||
// Enable variable 0 in the shader.
|
// Enable variable 0 in the shader.
|
||||||
GL.EnableVertexAttribArray(0);
|
GL.EnableVertexAttribArray(0);
|
||||||
|
GL.EnableVertexAttribArray(1);
|
||||||
|
|
||||||
// We've got the vertices done, but how exactly should this be converted to pixels for the final image?
|
// We've got the vertices done, but how exactly should this be converted to pixels for the final image?
|
||||||
// Modern OpenGL makes this pipeline very free, giving us a lot of freedom on how vertices are turned to pixels.
|
// Modern OpenGL makes this pipeline very free, giving us a lot of freedom on how vertices are turned to pixels.
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
|
in vec4 outColour;
|
||||||
out vec4 outputColor;
|
out vec4 outputColor;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
outputColor = vec4(1.0, 1.0, 0.0, 1.0);
|
outputColor = outColour;
|
||||||
}
|
}
|
||||||
@ -26,6 +26,8 @@
|
|||||||
// Then, the keyword "vec3" means this is a vector with 3 floats inside.
|
// Then, the keyword "vec3" means this is a vector with 3 floats inside.
|
||||||
|
|
||||||
layout(location = 0) in vec3 aPosition;
|
layout(location = 0) in vec3 aPosition;
|
||||||
|
layout(location = 1) in vec4 aColour;
|
||||||
|
out vec4 outColour;
|
||||||
|
|
||||||
|
|
||||||
// Like C, we have an entrypoint function. In this case, it takes void and returns void, and must be named main.
|
// Like C, we have an entrypoint function. In this case, it takes void and returns void, and must be named main.
|
||||||
@ -37,5 +39,6 @@ layout(location = 0) in vec3 aPosition;
|
|||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
|
outColour = aColour;
|
||||||
gl_Position = vec4(aPosition, 1.0);
|
gl_Position = vec4(aPosition, 1.0);
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user