Commit 14a68c65 authored by Johannes Braun's avatar Johannes Braun
Browse files

Some renaming for consistency.

parent b69c076b
......@@ -15,7 +15,7 @@ include(${CMAKE_MODULE_PATH}/setup/macros.cmake)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest /MP")
endif()
if(SYS_WINDOWS)
......
......@@ -29,7 +29,7 @@ int main(int argc, char* argv[])
core::Context::createAsCurrent(files::asset("/preferences/default.xml"));
core::Context::current().callbacks().addScrollCallback("main", on_scroll);
auto texture_renderer = core::DefaultTextureRenderers::makeCenterTextureRenderer();
auto texture_renderer = core::DefaultTextureRenderers::makeCenterTexture();
texture_renderer->addPreDrawCallback([](const core::Program& program)
{
program.uniform("u_scale", zoom);
......@@ -133,7 +133,7 @@ int main(int argc, char* argv[])
heatmap_generator.uniform("u_second_image", heatmap_other_image->makeImageResident(gl::Access::eReadOnly));
heatmap_generator.uniform("u_result_heatmap", heatmap->makeImageResident(gl::Access::eWriteOnly));
heatmap_generator.dispatch2d(image->getSize().x, 24, image->getSize().y, 24);
heatmap_generator.dispatch2D(image->getSize().x, 24, image->getSize().y, 24);
}
zoom = 1.f;
}
......
......@@ -316,7 +316,7 @@ int main()
Texture texture(imf);
auto renderer = glare::core::DefaultTextureRenderers::makeSimpleRenderer();
auto renderer = glare::core::DefaultTextureRenderers::makeSimple();
glare::core::Context::current().loop([&renderer, &texture]() {
renderer->draw(texture);
});
......
......@@ -579,7 +579,7 @@ int main()
imageF.save(files::asset("/screenshots/bricky_output_float.png"));
imageF.save(files::asset("/screenshots/bricky_output_float.hdr"));
auto texrend = glare::core::DefaultTextureRenderers::makeSimpleRenderer();
auto texrend = glare::core::DefaultTextureRenderers::makeSimple();
glare::core::Context::current().loop([&](){
texrend->draw(texture.textureAddress());
});
......
#include "framebuffer.h"
#include <util/log.h>
namespace glare::core
{
......@@ -60,6 +61,7 @@ namespace glare::core
/**
* \brief Set the default framebuffer as active.
*/
// ReSharper disable once CppMemberFunctionMayBeStatic
void Framebuffer::deactivate() const
{
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, 0);
......
......@@ -6,7 +6,6 @@
#include <memory>
// --- EXTERN ---------------------------------------------
#include <util/log.h>
#include <util/opengl.h>
#include <core/base/texture.h>
......@@ -59,176 +58,6 @@ namespace glare::core
gl::handle::framebuffer m_handle;
};
/**
// * \brief A frame buffer object wrapper for varying types of attachment textures.
// * \tparam TTextureBase The base type of attachment textures. (Texture2D, Texture2DMultisample etc.)
// */
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//class FramebufferOLD
//{
//public:
// // The type of texture used for color attachments
// using texture_color_type = TTextureBase<gl::TextureFormat::eRGBA, gl::TextureInternalFormat::eRGBA32Float, gl::Type::eFloat>;
// static constexpr bool is_multisampled = texture_color_type::is_multisampled;
// // The type of texture used for the depth attachment
// using texture_depth_type = TTextureBase<gl::TextureFormat::eDepthComponent, gl::TextureInternalFormat::eDepthComponent32Float, gl::Type::eFloat>;
// /**
// * \param samples Only used when using a multisampled texture.
// */
// FramebufferOLD(unsigned width, unsigned height, unsigned samples = 1);
// FramebufferOLD(FramebufferOLD& other) = delete;
// FramebufferOLD& operator=(FramebufferOLD& other) = delete;
// FramebufferOLD(FramebufferOLD&& other) = default;
// FramebufferOLD& operator=(FramebufferOLD&& other) = default;
// ~FramebufferOLD();
// /**
// * \brief Resizes all attachments to the new resolution.
// * \param samples Only used when using a multisampled texture.
// */
// void resize(unsigned width, unsigned height, unsigned samples = 1);
// /**
// * \brief Set this framebuffer as active to receive rendered things.
// */
// void activate() const;
// /**
// * \brief Set the default framebuffer as active.
// */
// void deactivate() const;
// void attach(gl::Attachment attachment);
// const texture_color_type &colorAttachment(gl::Attachment attachment) const;
// const texture_depth_type &depthAttachment() const;
// unsigned attachments() const;
// unsigned samples() const;
//private:
// void putAttachment(gl::Attachment attachment, unsigned texture);
// gl::handle::framebuffer m_handle;
// unsigned m_width;
// unsigned m_height;
// unsigned m_samples;
// std::vector<gl::Attachment> m_draw_buffers;
// std::map<gl::Attachment, std::shared_ptr<core::TextureEXT>> m_color_attachments;
// std::shared_ptr<core::TextureEXT> m_depth_attachment;
//};
//// -------------------------------------------------------------------------------------------------------------------------
//// --- IMPLEMENTATIONS -----------------------------------------------------------------------------------------------------
//// -------------------------------------------------------------------------------------------------------------------------
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//FramebufferOLD<TTextureBase>::FramebufferOLD(unsigned width, unsigned height, unsigned samples)
// : m_width(width), m_height(height), m_samples(samples) {}
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//FramebufferOLD<TTextureBase>::~FramebufferOLD() {}
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//void FramebufferOLD<TTextureBase>::resize(unsigned width, unsigned height, unsigned samples)
//{
// if (width == m_width && height == m_height)
// return;
// m_width = width;
// m_height = height;
// m_samples = samples;
// for (auto &&texture : m_color_attachments) {
// is_multisampled ? texture.second->resize(width, height, m_samples) : texture.second->resize(width, height);
// }
// if (m_depth_attachment) {
// is_multisampled ? m_depth_attachment->resize(width, height, m_samples) : m_depth_attachment->resize(width, height);
// }
//}
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//void FramebufferOLD<TTextureBase>::activate() const
//{
// gl::bindFramebuffer(gl::FramebufferTarget::eDefault, m_handle);
//}
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//void FramebufferOLD<TTextureBase>::deactivate() const
//{
// gl::bindFramebuffer(gl::FramebufferTarget::eDefault, 0);
//}
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//void FramebufferOLD<TTextureBase>::attach(gl::Attachment attachment)
//{
// switch (attachment)
// {
// case gl::Attachment::eDepth:
// case gl::Attachment::eDepthStencil:
// if (is_multisampled)
// m_depth_attachment = std::make_shared<texture_depth_type>(m_width, m_height, m_samples);
// else
// m_depth_attachment = std::make_shared<texture_depth_type>(m_width, m_height);
// gl::namedFramebufferTexture(m_handle, attachment, m_depth_attachment->id(), 0);
// break;
// default:
// {
// std::shared_ptr<texture_color_type> new_attachment;
// if (is_multisampled)
// new_attachment = std::make_shared<texture_color_type>(m_width, m_height, m_samples);
// else
// new_attachment = std::make_shared<texture_color_type>(m_width, m_height);
// m_color_attachments.emplace(attachment, new_attachment);
// putAttachment(attachment, new_attachment->id());
// } break;
// }
//}
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//const typename FramebufferOLD<TTextureBase>::texture_color_type &Framebuffer<TTextureBase>::colorAttachment(gl::Attachment attachment) const
//{
// return *(m_color_attachments.at(attachment));
//}
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//const typename FramebufferOLD<TTextureBase>::texture_depth_type &Framebuffer<TTextureBase>::depthAttachment() const
//{
// return *m_depth_attachment;
//}
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//unsigned FramebufferOLD<TTextureBase>::attachments() const
//{
// return m_color_attachments.size() + unsigned(bool(m_depth_attachment));
//}
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//void FramebufferOLD<TTextureBase>::putAttachment(gl::Attachment attachment, unsigned texture)
//{
// gl::namedFramebufferTexture(m_handle, attachment, texture, 0);
// if (std::find(m_draw_buffers.begin(), m_draw_buffers.end(), attachment) == m_draw_buffers.end()) {
// m_draw_buffers.push_back(attachment);
// gl::namedFramebufferDrawBuffers(m_handle, m_draw_buffers);
// }
// if (auto status = gl::checkNamedFramebufferStatus(m_handle, gl::FramebufferTarget::eDraw) != gl::FramebufferStatus::eComplete)
// Log_Error << "An error occured when generating the framebuffer: " << static_cast<int>(status);
//}
//template<template<gl::TextureFormat, gl::TextureInternalFormat, gl::Type> typename TTextureBase>
//unsigned FramebufferOLD<TTextureBase>::samples() const
//{
// return m_samples;
//}
}
#endif //INCLUDE_FRAMEBUFFER_H
......@@ -4,18 +4,7 @@
namespace glare::core
{
void OpenGLState::capture()
{
getInstance().captureState();
}
void OpenGLState::reset()
{
getInstance().resetState();
}
void OpenGLState::captureState()
CaptureGlState::CaptureGlState()
{
// Capture the current OpenGL state
gl::getIntegerv(gl::GetParameter::eCurrentProgram, &m_last_program);
......@@ -36,7 +25,7 @@ namespace glare::core
m_last_enable_scissor_test = gl::isEnabled(gl::EnableParameter::eScissorTest);
}
void OpenGLState::resetState()
CaptureGlState::~CaptureGlState()
{
// Restore modified GL state
gl::useProgram(m_last_program);
......
#ifndef INCLUDE_GL_STATE_H
#define INCLUDE_GL_STATE_H
#include <util/singleton.h>
namespace glare::core
{
class OpenGLState : Singleton<OpenGLState>
class CaptureGlState
{
public:
static void capture();
static void reset();
void captureState();
void resetState();
CaptureGlState();
~CaptureGlState();
private:
int m_last_program = 0;
......
......@@ -18,11 +18,11 @@ namespace glare::core
if (success == false)
{
int logLength = 0;
gl::getProgramiv(m_handle, gl::ProgramParameter::eLogInfoLength, &logLength);
int log_length = 0;
gl::getProgramiv(m_handle, gl::ProgramParameter::eLogInfoLength, &log_length);
std::string log(logLength, ' ');
gl::getProgramInfoLog(m_handle, logLength, &logLength, &log[0]);
std::string log(log_length, ' ');
gl::getProgramInfoLog(m_handle, log_length, &log_length, &log[0]);
Log_Error << log;
Log_Error << "Shader compiled successfully.";
......@@ -56,9 +56,8 @@ namespace glare::core
for (int i = 0; i < num_uniforms; ++i) {
UniformInfo data;
int length = max_length;
char* name = new char[length];
gl::getActiveUniform(m_handle, i, length, &data.size, &data.type, name);
char* name = new char[max_length];
gl::getActiveUniform(m_handle, i, max_length, &data.size, &data.type, name);
data.name = name;
data.index = uniformLocation(name);
m_uniforms[data.name] = data;
......@@ -68,7 +67,7 @@ namespace glare::core
for (int j = 1; j < data.size; ++j)
{
std::string last_ending = "[" + std::to_string(j - 1) + "]";
std::string ending = "[" + std::to_string(j) + "]";
const std::string ending = "[" + std::to_string(j) + "]";
data.name = std::string(data.name.data(), data.name.data() + data.name.length() - last_ending.length()) + ending;
data.index = uniformLocation(data.name);
......@@ -108,20 +107,23 @@ namespace glare::core
}
}
void Program::dispatch1d(unsigned global_x, unsigned local_x)
void Program::dispatch1D(unsigned global_x, unsigned local_x) const
{
use();
gl::dispatchComputeGroupSize(invocations(global_x, local_x), 1, 1, local_x, 1, 1);
gl::memoryBarrier(gl::MemoryBarrierBit::eAll);
}
void Program::dispatch2d(unsigned global_x, unsigned local_x, unsigned global_y, unsigned local_y)
void Program::dispatch2D(unsigned global_x, unsigned local_x, unsigned global_y, unsigned local_y) const
{
use();
gl::dispatchComputeGroupSize(invocations(global_x, local_x), invocations(global_y, local_y), 1, local_x, local_y, 1);
gl::memoryBarrier(gl::MemoryBarrierBit::eAll);
}
void Program::dispatch3d(unsigned global_x, unsigned local_x, unsigned global_y, unsigned local_y, unsigned global_z, unsigned local_z)
void Program::dispatch3D(unsigned global_x, unsigned local_x, unsigned global_y, unsigned local_y, unsigned global_z, unsigned local_z) const
{
use();
gl::dispatchComputeGroupSize(invocations(global_x, local_x), invocations(global_y, local_y), invocations(global_y, local_z), local_x, local_y, local_z);
gl::memoryBarrier(gl::MemoryBarrierBit::eAll);
}
......@@ -165,7 +167,7 @@ namespace glare::core
void Program::bindSubroutine(gl::ShaderType stage, const std::string& uniform, const std::string& subroutine)
{
int location = gl::getSubroutineUniformLocation(m_handle, stage, uniform);
const int location = gl::getSubroutineUniformLocation(m_handle, stage, uniform);
if (location >= 0) {
auto &&list = m_subroutine_bindings[stage];
......
......@@ -76,9 +76,9 @@ namespace glare::core
explicit Program(const fs::path& shader_file);
// again, only usable for compute shaders.
void dispatch1d(unsigned global_x, unsigned local_x);
void dispatch2d(unsigned global_x, unsigned local_x, unsigned global_y, unsigned local_y);
void dispatch3d(unsigned global_x, unsigned local_x, unsigned global_y, unsigned local_y, unsigned global_z, unsigned local_z);
void dispatch1D(unsigned global_x, unsigned local_x) const;
void dispatch2D(unsigned global_x, unsigned local_x, unsigned global_y, unsigned local_y) const;
void dispatch3D(unsigned global_x, unsigned local_x, unsigned global_y, unsigned local_y, unsigned global_z, unsigned local_z) const;
private:
void collectUniforms();
......
......@@ -53,11 +53,11 @@ namespace glare::core
if (!success)
{
int logSize = 0;
gl::getShaderiv(m_handle, gl::GetShaderParameter::eLogInfoLength, &logSize);
int log_size = 0;
gl::getShaderiv(m_handle, gl::GetShaderParameter::eLogInfoLength, &log_size);
std::string log(logSize, ' ');
gl::getShaderInfoLog(m_handle, logSize, &logSize, &log[0]);
std::string log(log_size, ' ');
gl::getShaderInfoLog(m_handle, log_size, &log_size, &log[0]);
Log_Error << log;
throw std::runtime_error(log);
}
......
......@@ -43,18 +43,6 @@ namespace glare::core
}
}
void ShaderSystem::terminate()
{
/*for (const auto &name : m_named_strings) {
Log_Info << name;
if (gl::isNamedString(gl::NamedStringType::eShaderInclude, name)) {
Log_Info << "DELETED";
gl::deleteNamedString(gl::NamedStringType::eShaderInclude, name);
}
}
Log_Info << "Finnish finish";*/
}
void ShaderSystem::precompile(std::string &source)
{
checkExtensions(source);
......
......@@ -18,8 +18,6 @@ namespace glare::core
*/
static void initialize();
static void terminate();
/**
* \brief Reformats the code in a suitable way to be compiled. Also checks the extensions used in the source code.
*/
......
......@@ -4,7 +4,7 @@ namespace glare::core
{
Texture::Texture(Target target, StoreFormat store_format)
: m_target(target), m_handle(std::move(target)), m_format(store_format)
: m_target(target), m_format(store_format), m_handle(std::move(target))
{ }
const Texture::Parameters& Texture::parameters() const
......
......@@ -122,7 +122,7 @@ namespace glare::core
template<template<typename, glm::precision> typename T, typename TBase, glm::precision P> void clear(T<TBase, P> && value)
{
auto texture_type = type();
gl::TextureFormat texture_format = [](int components, gl::Type type)
const gl::TextureFormat texture_format = [](int components, gl::Type type)
{
switch (components)
{
......@@ -143,8 +143,8 @@ namespace glare::core
template<typename T> void clear(T value)
{
auto texture_type = type();
gl::TextureFormat texture_format = [](gl::Type type)
auto texture_type = type();
const gl::TextureFormat texture_format = [](gl::Type type)
{
return (type == gl::Type::eInt || type == gl::Type::eUInt) ? gl::TextureFormat::eRedInt : gl::TextureFormat::eRed;
}(texture_type);
......@@ -218,12 +218,12 @@ namespace glare::core
throw std::invalid_argument("You cannot download this texture.");
}
int texture_width = width();
int texture_height = height();
int components = m_components;
auto texture_type = type();
const int texture_width = width();
const int texture_height = height();
const int components = m_components;
const auto texture_type = type();
gl::TextureFormat texture_format = [](int components, gl::Type type)
const gl::TextureFormat texture_format = [](int components, gl::Type type)
{
switch (components)
{
......@@ -330,8 +330,8 @@ namespace glare::core
// Don't allow level parameter on MS textures.
// images are multisampled if sample count is not 0.
assert(image.samples() == 0);
gl::TextureFormat texture_format = [](int components, StoreFormat format)
const gl::TextureFormat texture_format = [](int components, StoreFormat format)
{
switch (components)
{
......
......@@ -44,8 +44,8 @@ namespace glare::core
{
if (m_id == 0)
{
static uint64_t m_current_id = 1ui64;
m_id = m_current_id++;
static uint64_t current_id = 1ui64;
m_id = current_id++;
}
return m_id;
}
......
......@@ -54,7 +54,13 @@ namespace glare::core
std::weak_ptr<SceneNode> m_owner;
uint64_t m_id = 0;
};
}
// include here, so m_owner is a shared_ptr to a complete type.
#include "scene_node.h"
namespace glare::core
{
template <typename T>
std::shared_ptr<T> SceneComponent::detachAs()
{
......@@ -64,6 +70,4 @@ namespace glare::core
}
}
#include "scene_node.h"
#endif //INCLUDE_COMPONENT_H
......@@ -152,11 +152,8 @@ namespace glare::core
{
return std::vector<std::shared_ptr<TComponent>>();
}
else
{
//const auto& components = m_components.at(typeid(T).name());
return m_components.at(typeid(T).name());
}
return m_components.at(typeid(T).name());
}
}
......
#ifndef INCLUDE_INTERACTABLE_H
#define INCLUDE_INTERACTABLE_H
#include <string>
namespace glare::core
{
enum class DrawMode
......@@ -14,6 +12,7 @@ namespace glare::core
class Entity
{
public:
virtual ~Entity() = default;
void start();
void end();
......@@ -26,7 +25,7 @@ namespace glare::core
void destroy();
void notifyTransform();
private:
protected:
virtual void onDestroy() = 0;
virtual void onStart() {}
virtual void onEnd() {}
......
......@@ -30,7 +30,6 @@ namespace glare::core
void SceneNode::onDestroy()
{
//callAndTraverse(&Entity::destroy);
detachSelf();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment