made some adaptations and fixed some bugs

This commit is contained in:
2025-12-29 14:36:19 +01:00
parent 36a88b280c
commit 73cbac0f66
4 changed files with 6 additions and 6 deletions

View File

@@ -67,7 +67,7 @@ public class Entity
internal void RenderComponents(GL gl, Matrix4X4<float> projectionMatrix, Matrix4X4<float> viewMatrix)
{
// TODO: retrieve the data component "Transform" which every Entity must have (although currently there is no transform component)
var modelMatrix = Matrix4X4.CreateTranslation(0, 0, -10f);
var modelMatrix = Matrix4X4<float>.Identity * Matrix4X4.CreateFromQuaternion(Quaternion<float>.Identity) * Matrix4X4.CreateScale(2.0f) * Matrix4X4.CreateTranslation(0, 0, 0f);
foreach (var components in _renderComponents)
{

View File

@@ -96,7 +96,7 @@ internal class OpenGLEngine : Engine
_gl.ClearColor(Color.Black);
_gl.Enable(EnableCap.DepthTest);
_camera = new PerspectiveCamera(Vector3D<float>.Zero, _window.FramebufferSize);
_camera = new PerspectiveCamera(new Vector3D<float>(0.0f, 0.0f, 3.0f), _window.FramebufferSize);
InitialiseShaders(Directory.GetFiles("./assets/shaders", "*.vert"));
SetCurrentScene(_defaultSceneName);

View File

@@ -14,6 +14,7 @@ public class MeshRenderer : RenderComponent
internal override void Render(GL gl, Matrix4X4<float> projectionMatrix, Matrix4X4<float> viewMatrix, Matrix4X4<float> modelMatrix)
{
GenerateRenderableMesh(gl, projectionMatrix, viewMatrix, modelMatrix);
Mesh.PrepareForRendering(projectionMatrix, viewMatrix, modelMatrix);
gl.DrawElements(PrimitiveType.Triangles, (uint)Mesh.Indices.Length, DrawElementsType.UnsignedInt, 0);
}
@@ -25,8 +26,7 @@ public class MeshRenderer : RenderComponent
if(vbo == 0) { vbo = gl.GenBuffer(); }
if(ebo == 0) { ebo = gl.GenBuffer(); }
Mesh.PrepareForRendering(projectionMatrix, viewMatrix, modelMatrix);
var meshData = new float[Mesh.Vertices.Length * 3 + Mesh.Indices.Length * 3];
var meshData = new float[Mesh.Vertices.Length * 3 + Mesh.Normals.Length * 3];
for (int i = 0, insert = 0; i < Mesh.Vertices.Length; i++, insert += 6)
{
meshData[insert] = Mesh.Vertices[i].X;

View File

@@ -1,6 +1,6 @@
#version 330 core
out vec4 FragColour;
out vec4 FragColor;
in vec3 FragPos;
in vec3 Normal;
@@ -9,5 +9,5 @@ in vec3 Normal;
void main()
{
vec3 col = vec3(1.0, 0.5, 0.2) * FragPos;
FragColour = vec4(col, 1);
FragColor = vec4(1);
}