load basic 3d model

This commit is contained in:
2023-06-28 21:23:42 +02:00
parent 385626d42b
commit 385dcf11d0
12 changed files with 298 additions and 102 deletions

View File

@@ -29,7 +29,8 @@ public:
static constexpr float m_MouseSensitivity = 200.0f;
struct Model {
GL::VertexArray* vao;
std::unique_ptr<GL::VertexArray> vao;
std::unique_ptr<GL::Texture> texture;
Vec3f positon;
Vec3f color = { 1, 1, 1 };
};

View File

@@ -28,7 +28,8 @@ private:
client::ClientGame* m_Client;
Renderer* m_Renderer;
game::World* m_World;
std::unique_ptr<GL::VertexArray> m_WorldVao, m_MobVao, m_SelectTileVao;
std::unique_ptr<GL::VertexArray> m_WorldVao;
std::unique_ptr<Renderer::Model> m_MobModel, m_SelectTileModel;
Vec2f m_CamPos;
Vec2f m_CursorPos;
Vec2f m_HoldCursorPos;

View File

@@ -70,5 +70,24 @@ public:
void Unbind() const;
};
class Texture {
private:
unsigned int m_ID;
public:
REMOVE_COPY(Texture);
Texture(Texture&& other) {
m_ID = other.m_ID;
other.m_ID = 0;
}
Texture(const char* textureData, int width, int height, int comp);
~Texture();
unsigned int GetTextureID() const { return m_ID; }
void Bind() const;
static void Unbind();
};
}

View File

@@ -0,0 +1,11 @@
#pragma once
#include "GLLoader.h"
namespace td {
namespace MobLoader {
GL::VertexArray LoadMobModel();
} // namespace loader
} // namespace td

View File

@@ -8,9 +8,12 @@
#ifndef RENDER_LOADER_TEXTURELOADER_H_
#define RENDER_LOADER_TEXTURELOADER_H_
#include "render/loader/GLLoader.h"
#include <string>
namespace TextureLoader {
unsigned int LoadGLTexture(const char* fileName);
GL::Texture LoadTexture(const std::string& fileName);
}