Added Gorrilla-Audio and Tinygltf Library
Started laying out a assetManager / ModelImporter
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
#include <glad/glad.h>
|
||||
#include <MyGraphicsEngine/Shader.h>
|
||||
#include <MyGraphicsEngine/Window.h>
|
||||
#include <MyGraphicsEngine/Camera.h>
|
||||
#include <MyGraphicsEngine/Mesh.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
/*
|
||||
@ -13,16 +12,26 @@
|
||||
#include "lualib.h"
|
||||
}
|
||||
*/
|
||||
//#include <include/AssetManager/ModelImporter.h>
|
||||
|
||||
#include <gorilla/gau.h>
|
||||
#include <gorilla/ga.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
spdlog::info("Working directory: {}", argv[0]);
|
||||
|
||||
//ModelImporter::Test();
|
||||
|
||||
|
||||
int main (int argc, char *argv[] ){
|
||||
|
||||
Mesh mesh;
|
||||
|
||||
mesh.vertices = {
|
||||
0.5f, 0.5f, 0.0f, // top, right
|
||||
0.5f, -0.5f, 0.0f, // bottom right
|
||||
-0.5f, -0.5f, 0.0f, // bottom left
|
||||
-0.5f, 0.5f, 0.0f // top left
|
||||
glm::vec3( 0.5f, 0.5f, 0.0f), // top, right
|
||||
glm::vec3( 0.5f, -0.5f, 0.0f), // bottom right
|
||||
glm::vec3(-0.5f, -0.5f, 0.0f), // bottom left
|
||||
glm::vec3(-0.5f, 0.5f, 0.0f) // top left
|
||||
};
|
||||
|
||||
|
||||
@ -30,15 +39,15 @@ int main (int argc, char *argv[] ){
|
||||
0,1,3,
|
||||
1,2,3
|
||||
};
|
||||
Camera cam(glm::vec3(2.0f, 0.0f, 0.0f), glm::vec3(0.0f,0.0f,0.0f), 90.0f);
|
||||
|
||||
|
||||
BarinkWindow GameWindow(800, 600);
|
||||
|
||||
std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs";
|
||||
std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs";
|
||||
Shader shader (vertexShaderSource, fragmentShaderSource);
|
||||
|
||||
spdlog::info("Working directory: {}", argv[0]);
|
||||
|
||||
/*
|
||||
* lua_State* L = luaL_newstate();
|
||||
luaL_openlibs(L);
|
||||
@ -46,8 +55,8 @@ int main (int argc, char *argv[] ){
|
||||
luaL_dofile(L,"./script.lua");
|
||||
*/
|
||||
|
||||
|
||||
|
||||
spdlog::info("Vertices: {}, {} bytes", mesh.vertices.size(), sizeof(glm::vec3));
|
||||
spdlog::info("Elements: {}, {} bytes", mesh.elements.size(), sizeof(GLushort));
|
||||
|
||||
unsigned int VBO, VAO, EBO;
|
||||
|
||||
@ -55,35 +64,69 @@ int main (int argc, char *argv[] ){
|
||||
glGenBuffers(1, &VBO);
|
||||
glGenBuffers(1, &EBO);
|
||||
|
||||
spdlog::info("Vertices: {}", mesh.vertices.size());
|
||||
glBindVertexArray(VAO);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * mesh.vertices.size() , &mesh.vertices[0], GL_STATIC_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, mesh.vertices.size() * sizeof(glm::vec3), &mesh.vertices[0], GL_STATIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(int) * mesh.elements.size(), &mesh.elements[0], GL_STATIC_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, mesh.elements.size() * sizeof(GLushort), &mesh.elements[0], GL_STATIC_DRAW);
|
||||
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
glEnableVertexAttribArray(0);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
||||
glm::vec3 rotation = glm::vec3(0.0f , 90.0f, 0.0f);
|
||||
|
||||
|
||||
glm::mat4 tran = glm::translate(glm::mat4(),glm::vec3(0.0f, 0.0f, 0.0f));
|
||||
glm::mat4 scale = glm::scale(glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f));
|
||||
glm::mat4 rot =
|
||||
glm::rotate(glm::mat4(), glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f)) *
|
||||
glm::rotate(glm::mat4(), glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f)) *
|
||||
glm::rotate(glm::mat4(), glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
|
||||
glm::mat4 model = tran * rot * scale;
|
||||
|
||||
|
||||
glm::mat4 projection = glm::perspective(cam.Zoom, (800.0f / 600.0f), 0.001f, 100.0f);
|
||||
|
||||
gau_Manager* mgr;
|
||||
ga_Mixer* mixer;
|
||||
ga_Sound sound;
|
||||
ga_Handle handle;
|
||||
gau_SampleSourceLoop* loopSrc = 0;
|
||||
gau_SampleSourceLoop** pLoopSrc = &loopSrc;
|
||||
gc_int32 loop = 0;
|
||||
gc_int32 quit = 0;
|
||||
|
||||
|
||||
gc_initialize(0);
|
||||
mgr = gau_manager_create();
|
||||
mixer = gau_manager_mixer(mgr);
|
||||
|
||||
|
||||
|
||||
|
||||
while (!GameWindow.WindowShouldClose()) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) ;
|
||||
|
||||
|
||||
shader.Use();
|
||||
shader.setUniformMat4("P", projection);
|
||||
shader.setUniformMat4("M", model);
|
||||
shader.setUniformMat4("V", cam.GetViewMatrix());
|
||||
glBindVertexArray(VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, NULL);
|
||||
glBindVertexArray(0);
|
||||
|
||||
GameWindow.Poll();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
8573
SandboxApplication/sponza.gltf
Normal file
8573
SandboxApplication/sponza.gltf
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user