Skip to content
Snippets Groups Projects
Commit b622c4b8 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

cleanup unused structs

parent 0c7b878b
No related branches found
No related tags found
No related merge requests found
......@@ -152,40 +152,51 @@ namespace fggl::gfx {
static void splat_checkerboard(GLuint* memory) {
for (int i = 0; i < 128 * 128; ++i) {
GLubyte* colours = (GLubyte*)&memory[i];
if( i / 128 & 16 ^ i % 128 & 16 )
{
//Set pixel to white
colours[ 0 ] = 0xFF;
colours[ 1 ] = 0xFF;
colours[ 2 ] = 0xFF;
colours[ 3 ] = 0xFF;
}
else
{
//Set pixel to red
colours[ 0 ] = 0xFF;
colours[ 1 ] = 0x00;
colours[ 2 ] = 0xFF;
colours[ 3 ] = 0xFF;
if( i / 128 & 16 ^ i % 128 & 16 ) {
memory[i] = ogl4::TEX_WHITE;
} else {
memory[i] = ogl4::TEX_CHECKER;
}
}
}
static void setup_fallback_texture(assets::AssetManager* assets) {
auto* fallback2D = new ogl::Texture(ogl::TextureType::Tex2D);
static ogl::Image make_solid(uint8_t width, uint8_t height, GLuint colour) {
GLuint myData[128 * 128];
splat_checkerboard(myData);
GLuint *texData = new GLuint[width * height];
for (int i = 0; i < width * height; ++i) {
texData[i] = colour;
}
ogl::Image image{
return {
.type = ogl::PixelFormat::UNSIGNED_BYTE,
.format = ogl::ImageFormat::RGBA,
.size = {128, 128},
.data = myData
.size = {width, height},
.data = texData
};
fallback2D->setData(ogl::InternalImageFormat::RedGreenBlueAlpha, image);
assets->set(ogl4::FALLBACK_TEX, fallback2D);
}
static void setup_fallback_texture(assets::AssetManager* assets) {
{
auto *fallback2D = new ogl::Texture(ogl::TextureType::Tex2D);
GLuint myData[128 * 128];
splat_checkerboard(myData);
ogl::Image image{
.type = ogl::PixelFormat::UNSIGNED_BYTE,
.format = ogl::ImageFormat::RGBA,
.size = {128, 128},
.data = myData
};
fallback2D->setData(ogl::InternalImageFormat::RedGreenBlueAlpha, image);
assets->set(ogl4::FALLBACK_TEX, fallback2D);
}
{
ogl::Image image = make_solid(128, 128, ogl4::TEX_WHITE);
auto *solid2D = new ogl::Texture(ogl::TextureType::Tex2D);
solid2D->setData(ogl::InternalImageFormat::RedGreenBlueAlpha, image);
assets->set(ogl4::SOLID_TEX, solid2D);
}
}
OpenGL4Backend::OpenGL4Backend(data::Storage *storage, gui::FontLibrary *fonts, assets::AssetManager *assets, GlFunctionLoader loader)
......
......@@ -27,6 +27,7 @@ namespace fggl::data {
constexpr math::vec3 ILLEGAL_NORMAL{0.0F, 0.0F, 0.F};
constexpr math::vec3 DEFAULT_COLOUR{1.0F, 1.0F, 1.0F};
struct Vertex {
math::vec3 posititon;
math::vec3 normal = ILLEGAL_NORMAL;
......@@ -43,6 +44,22 @@ namespace fggl::data {
}
};
// comparison operators
inline bool operator<(const Vertex &lhs, const Vertex &rhs) {
return std::tie(lhs.posititon, lhs.normal, lhs.colour)
< std::tie(rhs.posititon, rhs.normal, rhs.colour);
}
inline bool operator==(const Vertex &lhs, const Vertex &rhs) {
return lhs.posititon == rhs.posititon
&& lhs.colour == rhs.colour
&& lhs.normal == rhs.normal;
}
inline bool operator!=(const Vertex &lhs, const Vertex &rhs) {
return !(lhs == rhs);
}
struct Vertex2D {
fggl::math::vec2 position;
fggl::math::vec3 colour;
......@@ -64,23 +81,6 @@ namespace fggl::data {
};
// comparison operators
inline bool operator<(const Vertex &lhs, const Vertex &rhs) {
return std::tie(lhs.posititon, lhs.normal, lhs.colour)
< std::tie(rhs.posititon, rhs.normal, rhs.colour);
}
inline bool operator==(const Vertex &lhs, const Vertex &rhs) {
return lhs.posititon == rhs.posititon
&& lhs.colour == rhs.colour
&& lhs.normal == rhs.normal;
}
inline bool operator!=(const Vertex &lhs, const Vertex &rhs) {
return !(lhs == rhs);
}
class Mesh {
public:
using IndexType = unsigned int;
......@@ -172,19 +172,6 @@ namespace fggl::data {
mesh(aMesh), pipeline(std::move(aPipeline)) {}
};
class Model {
public:
Model() = default;
~Model() = default;
inline void append(const Mesh &mesh) {
m_meshes.push_back(mesh);
}
private:
std::vector<Mesh> m_meshes;
};
}
#endif
......@@ -32,22 +32,6 @@ namespace fggl::gfx {
using GlFunctionLoader = GLADloadproc;
enum GlRenderType {
triangles = GL_TRIANGLES,
triangle_strip = GL_TRIANGLE_STRIP
};
struct GlRenderToken {
constexpr static const char name[] = "RenderToken";
GLuint vao;
GLuint buffs[2];
GLuint idxOffset;
GLsizei idxSize;
GLuint pipeline;
GLuint restartVertex;
GlRenderType renderType = triangles;
};
/**
* Class responsible for managing the OpenGL context.
*
......
......@@ -58,10 +58,12 @@ namespace fggl::gfx::ogl4 {
fragColour = vec4(colour.xyz, texture(tex, texPos).r);
})glsl";
constexpr const std::array<uint32_t, 4> TEX_WHITE{ 0xFF, 0xFF, 0xFF, 0xFF };
constexpr const std::array<uint32_t, 4> TEX_CHECKER{ 0xFF, 0x00, 0x00, 0xFF };
constexpr const GLuint TEX_WHITE = 0xFFFFFFFF;
constexpr const GLuint TEX_CHECKER = 0x00FF00FF; //FIXME pixel order is reversed?!
constexpr const char* FALLBACK_TEX = "FALLBACK_TEX";
constexpr const char* FALLBACK_MAT = "FALLBACK_MAT";
constexpr const char* SOLID_TEX = "SOLID_TEX";
} // namespace fggl::gfx::ogl4
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment