Compare commits

..

No commits in common. "4b66f524d06aca987b842fd321f11bf6cf4b32b5" and "315273e0ec1f8ad16922c775a6afb15e9175d37d" have entirely different histories.

4 changed files with 11 additions and 67 deletions

View File

@ -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.
private readonly float[] _vertices =
{
-0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, // Bottom-left vertex
0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, // Bottom-right vertex
0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, // Top vertex
-0.5f, -0.5f, 0.0f, // Bottom-left vertex
0.5f, -0.5f, 0.0f, // Bottom-right vertex
0.0f, 0.5f, 0.0f // Top vertex
};
// These are the handles to OpenGL objects. A handle is an integer representing where the object lives on the
@ -101,12 +101,10 @@ 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 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.
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 7 * sizeof(float), 0);
GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, false, 7 * sizeof(float), 4);
GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), 0);
// Enable variable 0 in the shader.
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?
// Modern OpenGL makes this pipeline very free, giving us a lot of freedom on how vertices are turned to pixels.

View File

@ -80,82 +80,32 @@ public class MyMatrix
public static MyMatrix CreateScale(MyVector pScale)
{
return new MyMatrix(1f * pScale.X, 0f, 0f, 0f,
0f, 1f * pScale.Y, 0f, 0f,
0f, 0f, 1f * pScale.Z, 0f,
0f, 0f, 0f, 1f * pScale.W);
return null;
}
public static MyMatrix CreateRotationX(float pAngle)
{
float cos = MathF.Cos(pAngle);
float sin = MathF.Sin(pAngle);
return new MyMatrix(1f, 0f, 0f, 0f,
0f, cos, sin, 0f,
0f, -sin, cos, 0f,
0f, 0f, 0f, 1f);
return null;
}
public static MyMatrix CreateRotationY(float pAngle)
{
float cos = MathF.Cos(pAngle);
float sin = MathF.Sin(pAngle);
return new MyMatrix(
cos, 0f, -sin, 0f,
0f, 1f, 0f, 0f,
sin, 0f, cos, 0f,
0f, 0f, 0f, 1f
);
return null;
}
public static MyMatrix CreateRotationZ(float pAngle)
{
float cos = MathF.Cos(pAngle);
float sin = MathF.Sin(pAngle);
return new MyMatrix(
cos, sin, 0f, 0f,
-sin, cos, 0f, 0f,
0, 0f, 1f, 0f,
0f, 0f, 0f, 1f
);
return null;
}
public MyVector Multiply(MyVector pVector)
{
float x = GetElement(0,0) * pVector.X + GetElement(0,1) * pVector.Y + GetElement(0,2) * pVector.Z + GetElement(0,3) * pVector.W;
float y = GetElement(1,0) * pVector.X + GetElement(1,1) * pVector.Y + GetElement(1,2) * pVector.Z + GetElement(1,3) * pVector.W;
float z = GetElement(2,0) * pVector.X + GetElement(2,1) * pVector.Y + GetElement(2,2) * pVector.Z + GetElement(2,3) * pVector.W;
float w = GetElement(3,0) * pVector.X + GetElement(3,1) * pVector.Y + GetElement(3,2) * pVector.Z + GetElement(3,3) * pVector.W;
return new MyVector(x, y, z, w);
return null;
}
public MyMatrix Multiply(MyMatrix pMatrix)
{
MyMatrix result = new MyMatrix(
0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0
);
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
{
float sum = 0f;
for (int k = 0; k < 4; k++)
{
sum += GetElement(row, k) * pMatrix.GetElement(k, col);
}
result.SetElement(row, col, sum);
}
}
return result;
return null;
}
public MyMatrix Inverse()

View File

@ -1,9 +1,8 @@
#version 330
in vec4 outColour;
out vec4 outputColor;
void main()
{
outputColor = outColour;
outputColor = vec4(1.0, 1.0, 0.0, 1.0);
}

View File

@ -26,8 +26,6 @@
// Then, the keyword "vec3" means this is a vector with 3 floats inside.
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.
@ -39,6 +37,5 @@ out vec4 outColour;
void main(void)
{
outColour = aColour;
gl_Position = vec4(aPosition, 1.0);
}