WIP: Graphics Overhaul #2
@ -1,14 +1,24 @@
|
|||||||
find_package(OpenGL)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
add_subdirectory(${GLFW_PATH} ${GLFW_PATH}/build)
|
project(NBGraphics VERSION 0.1)
|
||||||
|
|
||||||
include_directories(
|
set(GLAD_PATH ${NBENGINE_ROOT}/../glad/)
|
||||||
${GLFW_PATH}/include
|
set(STBIMAGE_PATH ${NBENGINE_ROOT}/../stbi_image)
|
||||||
${GLAD_PATH}/include
|
get_filename_component(GLAD_PATH ${GLAD_PATH} ABSOLUTE)
|
||||||
${STBIMAGE_PATH}
|
get_filename_component(STBIMAGE_PATH ${STBIMAGE_PATH} ABSOLUTE)
|
||||||
|
|
||||||
|
set(CMAKE_PREFIX_PATH
|
||||||
|
"${CMAKE_PREFIX_PATH}"
|
||||||
|
"C:/Program Files (x86)/GLFW/lib/cmake/glfw3/"
|
||||||
)
|
)
|
||||||
|
find_package(OpenGL REQUIRED)
|
||||||
|
find_package(glfw3 REQUIRED)
|
||||||
|
|
||||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
if (NB_BUILD_TESTS)
|
||||||
|
set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE)
|
||||||
|
else()
|
||||||
|
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||||
|
endif()
|
||||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
toAbsolutePath(NB_GRAPHICS_SOURCE
|
toAbsolutePath(NB_GRAPHICS_SOURCE
|
||||||
@ -21,19 +31,18 @@ toAbsolutePath(NB_GRAPHICS_SOURCE
|
|||||||
./src/VertexArray.cpp
|
./src/VertexArray.cpp
|
||||||
./src/Window.cpp
|
./src/Window.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
toAbsolutePath(NB_GRAPHICS_INCLUDE
|
toAbsolutePath(NB_GRAPHICS_INCLUDE
|
||||||
./Buffers.hpp
|
./include/NBGraphics/Buffers.hpp
|
||||||
./Camera.hpp
|
./include/NBGraphics/Camera.hpp
|
||||||
./Draw.hpp
|
./include/NBGraphics/Draw.hpp
|
||||||
./FrameBuffers.hpp
|
./include/NBGraphics/FrameBuffers.hpp
|
||||||
./GLLoad.hpp
|
./include/NBGraphics/GLLoad.hpp
|
||||||
./Image.hpp
|
./include/NBGraphics/Image.hpp
|
||||||
./OGLObjects.hpp
|
./include/NBGraphics/OGLObjects.hpp
|
||||||
./ProgramPipeline.hpp
|
./include/NBGraphics/ProgramPipeline.hpp
|
||||||
./Textures.hpp
|
./include/NBGraphics/Textures.hpp
|
||||||
./VertexArray.hpp
|
./include/NBGraphics/VertexArray.hpp
|
||||||
./Window.hpp
|
./include/NBGraphics/Window.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(NB_GRAPHICS_SOURCE ${NB_GRAPHICS_SOURCE} PARENT_SCOPE)
|
set(NB_GRAPHICS_SOURCE ${NB_GRAPHICS_SOURCE} PARENT_SCOPE)
|
||||||
@ -43,9 +52,54 @@ add_library(NBGraphics
|
|||||||
${NB_GRAPHICS_SOURCE}
|
${NB_GRAPHICS_SOURCE}
|
||||||
${GLAD_PATH}/src/glad.c
|
${GLAD_PATH}/src/glad.c
|
||||||
)
|
)
|
||||||
target_link_libraries(NBGraphics glfw)
|
add_library(NBEngine::Graphics ALIAS NBGraphics)
|
||||||
|
target_link_libraries(NBGraphics
|
||||||
|
PUBLIC glfw
|
||||||
|
PUBLIC NBCore
|
||||||
|
)
|
||||||
|
get_target_property(GLFW_INTERFACE_INCLUDES glfw INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
#include_directories(${GLFW_INTERFACE_INCLUDES})
|
||||||
|
target_include_directories(NBGraphics
|
||||||
|
PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
|
||||||
|
PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
|
PUBLIC "${STBIMAGE_PATH}"
|
||||||
|
PUBLIC "${GLAD_PATH}/include"
|
||||||
|
)
|
||||||
|
|
||||||
target_include_directories(NBGraphics PUBLIC ./.)
|
if (NBENGINE_INSTALL)
|
||||||
|
message("Installing NBGraphics to ${CMAKE_INSTALL_PREFIX}")
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
install(
|
||||||
|
TARGETS NBGraphics
|
||||||
|
EXPORT NBGraphicsTargets
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
DIRECTORY "${PROJECT_SOURCE_DIR}/include/NBGraphics"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
|
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
EXPORT NBGraphicsTargets
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake
|
||||||
|
NAMESPACE NBEngine::
|
||||||
|
)
|
||||||
|
configure_package_config_file(
|
||||||
|
"NBGraphicsConfig.cmake.in"
|
||||||
|
"NBGraphicsConfig.cmake"
|
||||||
|
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake
|
||||||
|
PATH_VARS CMAKE_INSTALL_LIBDIR
|
||||||
|
)
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/NBGraphicsConfigVersion.cmake"
|
||||||
|
COMPATIBILITY AnyNewerVersion
|
||||||
|
)
|
||||||
|
install(FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/NBGraphicsConfig.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/NBGraphicsConfigVersion.cmake"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_PREFIX}/cmake"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (NB_BUILD_TESTS)
|
if (NB_BUILD_TESTS)
|
||||||
add_subdirectory(./tests)
|
add_subdirectory(./tests)
|
||||||
|
|||||||
2
engine/NBGraphics/NBGraphicsConfig.cmake.in
Normal file
2
engine/NBGraphics/NBGraphicsConfig.cmake.in
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/NBGraphicsTargets.cmake")
|
||||||
@ -2,7 +2,7 @@
|
|||||||
#ifndef _NB_BUFFER
|
#ifndef _NB_BUFFER
|
||||||
#define _NB_BUFFER
|
#define _NB_BUFFER
|
||||||
|
|
||||||
#include "GLLoad.hpp"
|
#include <NBGraphics/GLLoad.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#include <NBCore/Logger.hpp>
|
#include <NBCore/Logger.hpp>
|
||||||
#include <NBCore/Utils.hpp>
|
#include <NBCore/Utils.hpp>
|
||||||
|
|
||||||
#include "OGLObjects.hpp"
|
#include <NBGraphics/OGLObjects.hpp>
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
#ifndef _NB_CAMERA
|
#ifndef _NB_CAMERA
|
||||||
#define _NB_CAMERA
|
#define _NB_CAMERA
|
||||||
|
|
||||||
#include "GLLoad.hpp"
|
#include <NBGraphics/GLLoad.hpp>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_inverse.hpp>
|
#include <glm/gtc/matrix_inverse.hpp>
|
||||||
@ -2,16 +2,16 @@
|
|||||||
#ifndef _NB_DRAW
|
#ifndef _NB_DRAW
|
||||||
#define _NB_DRAW
|
#define _NB_DRAW
|
||||||
|
|
||||||
#include <GLLoad.h>
|
#include <NBGraphics/GLLoad.hpp>
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Buffers.h"
|
#include <NBGraphics/Buffers.h>
|
||||||
#include "Shader.h"
|
#include <NBGraphics/Shader.h>
|
||||||
#include "VAOManager.hpp"
|
#include <NBGraphics/VAOManager.hpp>
|
||||||
|
|
||||||
#define THROW_DRAW_ERROR(msg) throw DrawError(msg, __FILE__, __LINE__);
|
#define THROW_DRAW_ERROR(msg) throw DrawError(msg, __FILE__, __LINE__);
|
||||||
|
|
||||||
@ -2,13 +2,13 @@
|
|||||||
#ifndef _NB_FRAMEBUFFER
|
#ifndef _NB_FRAMEBUFFER
|
||||||
#define _NB_FRAMEBUFFER
|
#define _NB_FRAMEBUFFER
|
||||||
|
|
||||||
#include "GLLoad.hpp"
|
#include <NBGraphics/GLLoad.hpp>
|
||||||
|
|
||||||
#include <NBCore/Errors.hpp>
|
#include <NBCore/Errors.hpp>
|
||||||
|
|
||||||
#include "Image.hpp"
|
#include <NBGraphics/Image.hpp>
|
||||||
#include "OGLObjects.hpp"
|
#include <NBGraphics/OGLObjects.hpp>
|
||||||
#include "Textures.hpp"
|
#include <NBGraphics/Textures.hpp>
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
#ifndef _NB_OGL_OBJECTS
|
#ifndef _NB_OGL_OBJECTS
|
||||||
#define _NB_OGL_OBJECTS
|
#define _NB_OGL_OBJECTS
|
||||||
|
|
||||||
#include "GLLoad.hpp"
|
#include <NBGraphics/GLLoad.hpp>
|
||||||
|
|
||||||
#include <NBCore/Errors.hpp>
|
#include <NBCore/Errors.hpp>
|
||||||
|
|
||||||
@ -2,14 +2,14 @@
|
|||||||
#ifndef _NB_SHADER
|
#ifndef _NB_SHADER
|
||||||
#define _NB_SHADER
|
#define _NB_SHADER
|
||||||
|
|
||||||
#include "GLLoad.hpp"
|
#include <NBGraphics/GLLoad.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <NBCore/Errors.hpp>
|
#include <NBCore/Errors.hpp>
|
||||||
#include <NBCore/Utils.hpp>
|
#include <NBCore/Utils.hpp>
|
||||||
|
|
||||||
#include "OGLObjects.hpp"
|
#include <NBGraphics/OGLObjects.hpp>
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
|
|
||||||
@ -2,9 +2,9 @@
|
|||||||
#ifndef _NB_TEXTURES
|
#ifndef _NB_TEXTURES
|
||||||
#define _NB_TEXTURES
|
#define _NB_TEXTURES
|
||||||
|
|
||||||
#include "Buffers.hpp"
|
#include <NBGraphics/Buffers.hpp>
|
||||||
#include "Image.hpp"
|
#include <NBGraphics/Image.hpp>
|
||||||
#include "OGLObjects.hpp"
|
#include <NBGraphics/OGLObjects.hpp>
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
|
|
||||||
@ -2,12 +2,12 @@
|
|||||||
#ifndef _NB_VERTEX_ARRAY
|
#ifndef _NB_VERTEX_ARRAY
|
||||||
#define _NB_VERTEX_ARRAY
|
#define _NB_VERTEX_ARRAY
|
||||||
|
|
||||||
#include "GLLoad.hpp"
|
#include <NBGraphics/GLLoad.hpp>
|
||||||
|
|
||||||
#include <NBCore/Errors.hpp>
|
#include <NBCore/Errors.hpp>
|
||||||
|
|
||||||
#include "Buffers.hpp"
|
#include <NBGraphics/Buffers.hpp>
|
||||||
#include "OGLObjects.hpp"
|
#include <NBGraphics/OGLObjects.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
@ -2,11 +2,10 @@
|
|||||||
#ifndef _NB_WINDOW
|
#ifndef _NB_WINDOW
|
||||||
#define _NB_WINDOW
|
#define _NB_WINDOW
|
||||||
|
|
||||||
#include "GLLoad.hpp"
|
#include <NBGraphics/GLLoad.hpp>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <NBCore/Errors.hpp>
|
#include <NBCore/Errors.hpp>
|
||||||
@ -1,4 +1,4 @@
|
|||||||
#include "Buffers.hpp"
|
#include <NBGraphics/Buffers.hpp>
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "Camera.hpp"
|
#include <NBGraphics/Camera.hpp>
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "Draw.h"
|
#include <NBGraphics/Draw.hpp>
|
||||||
|
|
||||||
namespace NB{
|
namespace NB{
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "FrameBuffers.hpp"
|
#include <NBGraphics/FrameBuffers.hpp>
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "Image.hpp"
|
#include <NBGraphics/Image.hpp>
|
||||||
|
|
||||||
using ImageErrorCodes = nb::ImageError::Codes;
|
using ImageErrorCodes = nb::ImageError::Codes;
|
||||||
const std::string nb::ImageError::type = "nb::ImageError";
|
const std::string nb::ImageError::type = "nb::ImageError";
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "OGLObjects.hpp"
|
#include <NBGraphics/OGLObjects.hpp>
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "ProgramPipeline.hpp"
|
#include <NBGraphics/ProgramPipeline.hpp>
|
||||||
|
|
||||||
namespace nb{
|
namespace nb{
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "Textures.hpp"
|
#include <NBGraphics/Textures.hpp>
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "VertexArray.hpp"
|
#include <NBGraphics/VertexArray.hpp>
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ VertexDataVec VertexGroup::dropBuffers() {
|
|||||||
|
|
||||||
VertexData VertexGroup::dropBuffer(size_t idx) {
|
VertexData VertexGroup::dropBuffer(size_t idx) {
|
||||||
if (idx >= _vertex_data.size()) {
|
if (idx >= _vertex_data.size()) {
|
||||||
THROW(NBError(NBError::INDEX_ERROR));
|
THROW(Error(Error<>::INDEX_ERROR));
|
||||||
}
|
}
|
||||||
VertexDataVec tmp;
|
VertexDataVec tmp;
|
||||||
VertexData ret;
|
VertexData ret;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include "Window.hpp"
|
#include <NBGraphics/Window.hpp>
|
||||||
|
|
||||||
namespace nb {
|
namespace nb {
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@ if (NB_BUILD_TESTS)
|
|||||||
./TestWindow.cpp
|
./TestWindow.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(TestWindow
|
target_link_libraries(TestWindow
|
||||||
NBCore
|
|
||||||
NBGraphics
|
NBGraphics
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
#include "GLLoad.hpp"
|
#include <NBGraphics/GLLoad.hpp>
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
|
|
||||||
#include "Image.hpp"
|
#include <NBGraphics/Image.hpp>
|
||||||
#include "ProgramPipeline.hpp"
|
#include <NBGraphics/ProgramPipeline.hpp>
|
||||||
#include "VertexArray.hpp"
|
#include <NBGraphics/VertexArray.hpp>
|
||||||
#include "Window.hpp"
|
#include <NBGraphics/Window.hpp>
|
||||||
#include "Textures.hpp"
|
#include <NBGraphics/Textures.hpp>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
nb::logger.log("Howdy!");
|
nb::logger.log("Howdy!");
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
|
|
||||||
#include "Image.hpp"
|
#include <NBGraphics/Image.hpp>
|
||||||
|
|
||||||
TEST(TestImage, SinglePixel) {
|
TEST(TestImage, SinglePixel) {
|
||||||
using RGB = nb::Pixel<uint8_t, nb::Red, nb::Green, nb::Blue>;
|
using RGB = nb::Pixel<uint8_t, nb::Red, nb::Green, nb::Blue>;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user