Test array texture

This commit is contained in:
Troispoils 2024-03-01 14:03:04 +01:00
parent 2b62d3b9e4
commit 51325d8650
4 changed files with 80 additions and 22 deletions

View file

@ -16,7 +16,6 @@ namespace Map3DRendering {
private Shader _shader;
private Texture _texture;
private Texture _texture2;
private Camera _camera;
@ -55,20 +54,13 @@ namespace Map3DRendering {
mapRender.OnLoad(_shader);
_texture = Texture.LoadFromFile("terrains/0.jpg");
var file = Directory.EnumerateFiles(@"./terrains");
_texture = Texture.LoadFromArray(file.ToArray());
// Texture units are explained in Texture.cs, at the Use function.
// First texture goes in texture unit 0.
_texture.Use(TextureUnit.Texture0);
_texture.UseArray(TextureUnit.Texture0);
// This is helpful because System.Drawing reads the pixels differently than OpenGL expects.
_texture2 = Texture.LoadFromFile("terrains/1.jpg");
// Then, the second goes in texture unit 1.
_texture2.Use(TextureUnit.Texture1);
// Next, we must setup the samplers in the shaders to use the right textures.
// The int we send to the uniform indicates which texture unit the sampler should use.
_shader.SetInt("texture0", 0);
_shader.SetInt("texture1", 1);
axesGizmo = new AxesGizmo();
@ -87,8 +79,7 @@ namespace Map3DRendering {
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
_texture.Use(TextureUnit.Texture0);
_texture2.Use(TextureUnit.Texture1);
_texture.UseArray(TextureUnit.Texture0);
_shader.Use();
_shader.SetMatrix4("view", _camera.GetViewMatrix());