Update code and models

This commit is contained in:
Mario Hüttel 2020-04-02 00:55:18 +02:00
parent b9a007dd51
commit d85c6073ec
10 changed files with 51 additions and 7 deletions

View File

@ -9,6 +9,10 @@ pkg_check_modules(EPOXY REQUIRED epoxy)
pkg_check_modules(SDL2 REQUIRED sdl2) pkg_check_modules(SDL2 REQUIRED sdl2)
pkg_check_modules(ASSIMP REQUIRED assimp) pkg_check_modules(ASSIMP REQUIRED assimp)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
#find_package(OpenCL REQUIRED) #find_package(OpenCL REQUIRED)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/imgui-submodule/imgui/examples" "${CMAKE_CURRENT_SOURCE_DIR}/imgui-submodule/imgui" ${EPOXY_INCLUDE_DIRS} ${ASSIMP_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}) include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/imgui-submodule/imgui/examples" "${CMAKE_CURRENT_SOURCE_DIR}/imgui-submodule/imgui" ${EPOXY_INCLUDE_DIRS} ${ASSIMP_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS})
@ -45,3 +49,10 @@ add_compile_options(-Wall)
add_executable(${PROJECT_NAME} ${SOURCES} ${IMGUI_SOURCES}) add_executable(${PROJECT_NAME} ${SOURCES} ${IMGUI_SOURCES})
target_link_libraries(${PROJECT_NAME} m pthread ${EPOXY_LIBRARIES} ${SDL2_LIBRARIES} ${ASSIMP_LIBRARIES} glm) target_link_libraries(${PROJECT_NAME} m pthread ${EPOXY_LIBRARIES} ${SDL2_LIBRARIES} ${ASSIMP_LIBRARIES} glm)
install (TARGETS ${PROJECT_NAME} DESTINATION bin) install (TARGETS ${PROJECT_NAME} DESTINATION bin)
target_precompile_headers(${PROJECT_NAME}
PUBLIC
"$<$<COMPILE_LANGUAGE:CXX>:stb/stb_image.h>"
"$<$<COMPILE_LANGUAGE:CXX>:glm/glm.hpp>"
PRIVATE
)

View File

@ -1,7 +1,7 @@
#ifndef GLOBALCANVASSETTINGS_H #ifndef GLOBALCANVASSETTINGS_H
#define GLOBALCANVASSETTINGS_H #define GLOBALCANVASSETTINGS_H
#include <glm/glm.hpp> //#include <glm/glm.hpp>
class GlobalCanvasSettings class GlobalCanvasSettings
{ {

View File

@ -4,8 +4,8 @@
#include <opengl-playground/opengltexture.hpp> #include <opengl-playground/opengltexture.hpp>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <glm/glm.hpp> //#include <glm/glm.hpp>
#include <iostream>
class Material class Material
{ {
@ -42,6 +42,8 @@ class Material
glm::vec3 diff_color; glm::vec3 diff_color;
glm::vec3 ambient_color; glm::vec3 ambient_color;
glm::vec3 specular_color; glm::vec3 specular_color;
friend std::ostream &operator<<(std::ostream &os, Material const &material);
}; };
#endif // MATERIAL_H #endif // MATERIAL_H

View File

@ -4,7 +4,7 @@
#include <string> #include <string>
#include <epoxy/gl.h> #include <epoxy/gl.h>
#include <opengl-playground/openglshader.hpp> #include <opengl-playground/openglshader.hpp>
#include <glm/glm.hpp> //#include <glm/glm.hpp>
#include <memory> #include <memory>
class OpenGlGraphics class OpenGlGraphics

View File

@ -3,7 +3,7 @@
#include <string> #include <string>
#include <epoxy/gl.h> #include <epoxy/gl.h>
#include <glm/glm.hpp> //#include <glm/glm.hpp>
class OpenGlShaderProgram class OpenGlShaderProgram
{ {

2
models/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.blend1
*.blend*

View File

@ -1,6 +1,18 @@
#include <opengl-playground/material.hpp> #include <opengl-playground/material.hpp>
std::ostream &operator<<(std::ostream &os, glm::vec3 const &vec3)
{
return os << "(" << vec3.r << "|" << vec3.g << "|" << vec3.b << ")";
}
std::ostream &operator<<(std::ostream &os, Material const &material)
{
return os << "Diffuse Color: " << material.diff_color << ", "
<< "Ambient Color: " << material.ambient_color << ", "
<< "Specular Color: " << material.specular_color << ", "
<< "Texture counts (diff, amb, spec): " << material.diffuse_textures.size()
<< ", " << material.ambient_textures.size() << ", " << material.specular_textures.size();
}
Material::Material() Material::Material()
{ {

View File

@ -135,6 +135,7 @@ Mesh Model::processMesh(aiMesh *mesh, const aiScene *scene)
material->Get(AI_MATKEY_SHININESS, mesh_material.shininess); material->Get(AI_MATKEY_SHININESS, mesh_material.shininess);
material->Get(AI_MATKEY_SHININESS_STRENGTH, mesh_material.shininess_strength); material->Get(AI_MATKEY_SHININESS_STRENGTH, mesh_material.shininess_strength);
std::cout << "Material: " << mesh_material << std::endl;
} }

View File

@ -3,6 +3,7 @@
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include <stb/stb_image.h> #include <stb/stb_image.h>
#include <iostream> #include <iostream>
#include <filesystem>
OpenGlTexture::OpenGlTexture(const std::string &texture_path) OpenGlTexture::OpenGlTexture(const std::string &texture_path)
{ {
@ -36,8 +37,14 @@ void OpenGlTexture::setRGBDataFromBytes(unsigned int width, unsigned int height,
void OpenGlTexture::loadFromImagePath(const std::string &base_directory) void OpenGlTexture::loadFromImagePath(const std::string &base_directory)
{ {
int width, height, nrChannels; int width, height, nrChannels;
std::string filename = this->texture_path; std::filesystem::path base_path(base_directory);
filename = base_directory + '/' + filename; std::filesystem::path tex_path(this->texture_path);
std::string filename;
if (tex_path.is_relative())
filename = base_path / tex_path;
else
filename = tex_path;
unsigned char *data = stbi_load(filename.c_str(), &width, &height, &nrChannels, 0); unsigned char *data = stbi_load(filename.c_str(), &width, &height, &nrChannels, 0);
if (data) { if (data) {

View File

@ -1 +1,10 @@
#include <opengl-playground/vertex.hpp> #include <opengl-playground/vertex.hpp>
Vertex operator+(Vertex const &a, Vertex const &b)
{
Vertex out = a;
out.Position + b.Position;
return out;
}