-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/serializer #9
Conversation
…rms) added optional name field to textures added test target
|
||
class Uniform { | ||
protected: | ||
std::string name; | ||
UniformType type; | ||
UniformValueType value_type; | ||
bool changed; | ||
|
||
virtual ByteWriter& serialize(ByteWriter& writer) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make better serialization interface
move it to cpp file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix fast&furious
@@ -30,16 +49,25 @@ namespace GraphicsEngine { | |||
|
|||
[[nodiscard]] virtual Uniform* clone() noexcept = 0; | |||
virtual void set(const ShaderProgram& shader) = 0; | |||
|
|||
friend ByteWriter& operator<<(ByteWriter& writer, const Uniform& u) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate definition from declaration
UniformValue(const std::string& name, UniformType type, const T& value); | ||
|
||
ByteWriter& serializeFields(ByteWriter& writer) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider using more template/constexpr/compile-time language features
public: | ||
explicit UniformSampler(ByteReader& reader); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not want
@@ -5,21 +5,40 @@ | |||
#include <chrono> | |||
#include <core/texture_visitor.hpp> | |||
#include <core/context_debug.hpp> | |||
#include <util/bytewriter.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not want
@@ -59,6 +64,12 @@ namespace GraphicsEngine { | |||
|
|||
[[nodiscard]] virtual Material* clone() const noexcept; | |||
|
|||
static constexpr uint32_t serial_version = 0x1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h3h
try { | ||
sampler = assets.textures.at(path); | ||
} | ||
catch (const resource_container_error& err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not ... or resource_container_error ?
@@ -221,3 +263,30 @@ namespace GraphicsEngine { | |||
template class UniformValue<glm::mat3>; | |||
template class UniformValue<glm::mat4>; | |||
} | |||
|
|||
std::unique_ptr<Uniform> GraphicsEngine::deserializeUniformValue(ByteReader& reader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
want copy elission
for (size_t i = 0; i < size; ++i) { | ||
PropertyType ptype {reader}; | ||
auto uptr = deserializeUniform(reader); | ||
material_builder.add(ptype, std::move(uptr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a che ne material_builder.add(ptype,deserializeUniform(reader));
nah lishniy move
} | ||
} | ||
|
||
return material_builder.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a che esly material - custom ??????????////////
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
custom material eto drugaya cool story
@@ -192,3 +192,8 @@ MaterialType MaterialBuilder::getMaterialType() const noexcept { | |||
|
|||
return MaterialType{std::move(props), material->shading}; | |||
} | |||
|
|||
MaterialBuilder& MaterialBuilder::add(PropertyType type, std::unique_ptr<Uniform> uniform) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rip
|
||
enum class UniformType { Value, Sampler, Time }; | ||
enum class UniformValueType { Float, Int, Uint, Vec2, Vec3, Vec4, Mat3, Mat4 }; | ||
enum class UniformValueType { Invalid, Float, Int, Uint, Vec2, Vec3, Vec4, Mat3, Mat4 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
want valid state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
soryan need poison value
public: | ||
explicit Uniform(ByteReader& reader) : changed{false} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont want
public: | ||
explicit UniformValue(ByteReader& reader); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tresh
@@ -68,7 +100,15 @@ namespace GraphicsEngine { | |||
class UniformTime : public UniformValue<float> { | |||
private: | |||
std::chrono::time_point<std::chrono::steady_clock> start; | |||
protected: | |||
ByteWriter& serialize(ByteWriter& writer) const override { | |||
writer << UniformType::Time; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmmmm
implemented material serializer & deserializer