sure?
This commit is contained in:
@@ -9,9 +9,9 @@
|
|||||||
using namespace Dawn;
|
using namespace Dawn;
|
||||||
|
|
||||||
MeshVertex vertices[3] = {
|
MeshVertex vertices[3] = {
|
||||||
{ Color4B::RED, glm::vec2(0.0f, 0.0f), glm::vec3(-0.5f, -0.5f, 0.0f) },
|
{ {255, 0, 0, 255}, glm::vec2(0.5f, 1.0f), glm::vec3(0.0f, 0.5f, 0.0f) },
|
||||||
{ Color4B::GREEN, glm::vec2(1.0f, 0.0f), glm::vec3(0.5f, -0.5f, 0.0f) },
|
{ {0, 255, 0, 255}, glm::vec2(0.0f, 0.0f), glm::vec3(-0.5f, -0.5f, 0.0f) },
|
||||||
{ Color4B::BLUE, glm::vec2(0.5f, 1.0f), glm::vec3(0.0f, 0.5f, 0.0f) }
|
{ {0, 0, 255, 255}, glm::vec2(1.0f, 0.0f), glm::vec3(0.5f, -0.5f, 0.0f) }
|
||||||
};
|
};
|
||||||
|
|
||||||
Display::Display(Engine &engine) :
|
Display::Display(Engine &engine) :
|
||||||
@@ -20,8 +20,9 @@ Display::Display(Engine &engine) :
|
|||||||
window(nullptr),
|
window(nullptr),
|
||||||
#endif
|
#endif
|
||||||
engine(engine),
|
engine(engine),
|
||||||
mesh(3, PrimitiveType::Triangles, vertices)
|
mesh(3, PrimitiveType::TRIANGLES, vertices)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if DAWN_SDL2
|
#if DAWN_SDL2
|
||||||
uint32_t flags = SDL_INIT_VIDEO;
|
uint32_t flags = SDL_INIT_VIDEO;
|
||||||
#if DAWN_SDL2_GAMEPAD
|
#if DAWN_SDL2_GAMEPAD
|
||||||
@@ -104,7 +105,7 @@ void Display::update(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GL_MakeCurrent(this->window, this->glContext);
|
// SDL_GL_MakeCurrent(this->window, this->glContext);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glClearColor(
|
glClearColor(
|
||||||
@@ -118,6 +119,11 @@ void Display::update(void) {
|
|||||||
|
|
||||||
// glViewport(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
// glViewport(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||||
|
|
||||||
|
GLenum err = glGetError();
|
||||||
|
if (err != GL_NO_ERROR) {
|
||||||
|
printf("OpenGL error: %d\n", err);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_GL_SwapWindow(this->window);
|
SDL_GL_SwapWindow(this->window);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "IColor.hpp"
|
|
||||||
#include "Color3B.hpp"
|
#include "Color3B.hpp"
|
||||||
#include "Color3F.hpp"
|
#include "Color3F.hpp"
|
||||||
#include "Color4B.hpp"
|
#include "Color4B.hpp"
|
||||||
|
|||||||
@@ -4,14 +4,25 @@
|
|||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "IColor.hpp"
|
#include "dawn.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
struct Color3B : public Color {
|
struct Color4B;
|
||||||
|
struct Color3F;
|
||||||
|
struct Color4F;
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct Color3B {
|
||||||
public:
|
public:
|
||||||
const uint8_t r;
|
union {
|
||||||
const uint8_t g;
|
struct {
|
||||||
const uint8_t b;
|
uint8_t r;
|
||||||
|
uint8_t g;
|
||||||
|
uint8_t b;
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t rgb[3];
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color (RGB, byte) constructor
|
* Color (RGB, byte) constructor
|
||||||
@@ -22,25 +33,33 @@ namespace Dawn {
|
|||||||
*/
|
*/
|
||||||
Color3B(const uint8_t r, const uint8_t g, const uint8_t b);
|
Color3B(const uint8_t r, const uint8_t g, const uint8_t b);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Color (RGB, byte) constructor from array
|
||||||
|
*
|
||||||
|
* @param rgb Array of 3 bytes: {r, g, b}
|
||||||
|
*/
|
||||||
|
Color3B(const uint8_t rgb[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this color as a 3-channel byte color.
|
* Gets this color as a 3-channel byte color.
|
||||||
*/
|
*/
|
||||||
Color3B toColor3B(void) const override;
|
Color3B toColor3B(void) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this color as a 4-channel byte color. Alpha is set to 255.
|
* Gets this color as a 4-channel byte color. Alpha is set to 255.
|
||||||
*/
|
*/
|
||||||
Color4B toColor4B(void) const override;
|
Color4B toColor4B(void) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this color as a 3-channel float color. (0-1 range)
|
* Gets this color as a 3-channel float color. (0-1 range)
|
||||||
*/
|
*/
|
||||||
Color3F toColor3F(void) const override;
|
Color3F toColor3F(void) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this color as a 4-channel float color. (0-1 range), Alpha is set
|
* Gets this color as a 4-channel float color. (0-1 range), Alpha is set
|
||||||
* to 1.0f
|
* to 1.0f
|
||||||
*/
|
*/
|
||||||
Color4F toColor4F(void) const override;
|
Color4F toColor4F(void) const;
|
||||||
};
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,11 @@ Color3F::Color3F(
|
|||||||
) : r(r), g(g), b(b) {
|
) : r(r), g(g), b(b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color3F::Color3F(
|
||||||
|
const float_t rgb[3]
|
||||||
|
) : r(rgb[0]), g(rgb[1]), b(rgb[2]) {
|
||||||
|
}
|
||||||
|
|
||||||
Color3B Color3F::toColor3B(void) const {
|
Color3B Color3F::toColor3B(void) const {
|
||||||
return Color3B(
|
return Color3B(
|
||||||
static_cast<uint8_t>(r * 255.0f),
|
static_cast<uint8_t>(r * 255.0f),
|
||||||
|
|||||||
@@ -4,14 +4,25 @@
|
|||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "IColor.hpp"
|
#include "dawn.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
struct Color3F : public Color {
|
struct Color3B;
|
||||||
|
struct Color4B;
|
||||||
|
struct Color4F;
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct Color3F {
|
||||||
public:
|
public:
|
||||||
const float_t r;
|
union {
|
||||||
const float_t g;
|
struct {
|
||||||
const float_t b;
|
float_t r;
|
||||||
|
float_t g;
|
||||||
|
float_t b;
|
||||||
|
};
|
||||||
|
|
||||||
|
float_t rgb[3];
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color (RGB, float) constructor
|
* Color (RGB, float) constructor
|
||||||
@@ -22,24 +33,32 @@ namespace Dawn {
|
|||||||
*/
|
*/
|
||||||
Color3F(const float_t r, const float_t g, const float_t b);
|
Color3F(const float_t r, const float_t g, const float_t b);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Color (RGB, float) constructor from array
|
||||||
|
*
|
||||||
|
* @param rgb Array of 3 float_t: {r, g, b}
|
||||||
|
*/
|
||||||
|
Color3F(const float_t rgb[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this color as a 3-channel byte color.
|
* Gets this color as a 3-channel byte color.
|
||||||
*/
|
*/
|
||||||
Color3B toColor3B(void) const override;
|
Color3B toColor3B(void) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this color as a 4-channel byte color. Alpha is set to 255.
|
* Gets this color as a 4-channel byte color. Alpha is set to 255.
|
||||||
*/
|
*/
|
||||||
Color4B toColor4B(void) const override;
|
Color4B toColor4B(void) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this color as a 3-channel float_t color.
|
* Gets this color as a 3-channel float_t color.
|
||||||
*/
|
*/
|
||||||
Color3F toColor3F(void) const override;
|
Color3F toColor3F(void) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this color as a 4-channel float_t color. Alpha is set to 1.0f
|
* Gets this color as a 4-channel float_t color. Alpha is set to 1.0f
|
||||||
*/
|
*/
|
||||||
Color4F toColor4F(void) const override;
|
Color4F toColor4F(void) const;
|
||||||
};
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
}
|
}
|
||||||
@@ -7,30 +7,28 @@
|
|||||||
|
|
||||||
using namespace Dawn;
|
using namespace Dawn;
|
||||||
|
|
||||||
const Color4B Color4B::WHITE = Color4B(255, 255, 255, 255);
|
const Color4B Color4B::WHITE = Color4B(0xFF, 0xFF, 0xFF, 0xFF);
|
||||||
const Color4B Color4B::BLACK = Color4B(0, 0, 0, 255);
|
const Color4B Color4B::BLACK = Color4B(0x00, 0x00, 0x00, 0xFF);
|
||||||
const Color4B Color4B::RED = Color4B(255, 0, 0, 255);
|
const Color4B Color4B::RED = Color4B(0xFF, 0x00, 0x00, 0xFF);
|
||||||
const Color4B Color4B::GREEN = Color4B(0, 255, 0, 255);
|
const Color4B Color4B::GREEN = Color4B(0x00, 0xFF, 0x00, 0xFF);
|
||||||
const Color4B Color4B::BLUE = Color4B(0, 0, 255, 255);
|
const Color4B Color4B::BLUE = Color4B(0x00, 0x00, 0xFF, 0xFF);
|
||||||
const Color4B Color4B::YELLOW = Color4B(255, 255, 0, 255);
|
const Color4B Color4B::YELLOW = Color4B(0xFF, 0xFF, 0x00, 0xFF);
|
||||||
const Color4B Color4B::CYAN = Color4B(0, 255, 255, 255);
|
const Color4B Color4B::CYAN = Color4B(0x00, 0xFF, 0xFF, 0xFF);
|
||||||
const Color4B Color4B::MAGENTA = Color4B(255, 0, 255, 255);
|
const Color4B Color4B::MAGENTA = Color4B(0xFF, 0x00, 0xFF, 0xFF);
|
||||||
const Color4B Color4B::TRANSPARENT = Color4B(0, 0, 0, 0);
|
const Color4B Color4B::TRANSPARENT = Color4B(0x00, 0x00, 0x00, 0x00);
|
||||||
const Color4B Color4B::CORNFLOWER_BLUE = Color4B(100, 149, 237, 255);
|
const Color4B Color4B::CORNFLOWER_BLUE = Color4B(0x64, 0x95, 0xED, 0xFF);
|
||||||
|
|
||||||
Color4B::Color4B(
|
Color4B::Color4B(
|
||||||
const uint8_t r,
|
const uint8_t r,
|
||||||
const uint8_t g,
|
const uint8_t g,
|
||||||
const uint8_t b,
|
const uint8_t b,
|
||||||
const uint8_t a
|
const uint8_t a
|
||||||
) : Color3B(r, g, b), a(a) {
|
) : r(r), g(g), b(b), a(a) {
|
||||||
// Constructor body (if needed)
|
// Constructor body (if needed)
|
||||||
}
|
}
|
||||||
|
|
||||||
Color4B Color4B::toColor4B(void) const {
|
Color4B::Color4B(
|
||||||
return Color4B(r, g, b, a);
|
const uint8_t rgba[4]
|
||||||
}
|
) : r(rgba[0]), g(rgba[1]), b(rgba[2]), a(rgba[3]) {
|
||||||
|
// Constructor body (if needed)
|
||||||
Color4F Color4B::toColor4F(void) const {
|
|
||||||
return Color4F(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
|
||||||
}
|
}
|
||||||
@@ -4,47 +4,58 @@
|
|||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Color3B.hpp"
|
#include "dawn.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
struct Color4B : public Color3B {
|
struct Color3B;
|
||||||
public:
|
struct Color3F;
|
||||||
static const Color4B WHITE;
|
struct Color4F;
|
||||||
static const Color4B BLACK;
|
|
||||||
static const Color4B RED;
|
|
||||||
static const Color4B GREEN;
|
|
||||||
static const Color4B BLUE;
|
|
||||||
static const Color4B YELLOW;
|
|
||||||
static const Color4B CYAN;
|
|
||||||
static const Color4B MAGENTA;
|
|
||||||
static const Color4B TRANSPARENT;
|
|
||||||
static const Color4B CORNFLOWER_BLUE;
|
|
||||||
|
|
||||||
const uint8_t a;
|
#pragma pack(push, 1)
|
||||||
|
struct Color4B {
|
||||||
|
static const Color4B WHITE;
|
||||||
|
static const Color4B BLACK;
|
||||||
|
static const Color4B RED;
|
||||||
|
static const Color4B GREEN;
|
||||||
|
static const Color4B BLUE;
|
||||||
|
static const Color4B YELLOW;
|
||||||
|
static const Color4B CYAN;
|
||||||
|
static const Color4B MAGENTA;
|
||||||
|
static const Color4B TRANSPARENT;
|
||||||
|
static const Color4B CORNFLOWER_BLUE;
|
||||||
|
|
||||||
/**
|
union {
|
||||||
* Color (RGBA, byte) constructor
|
struct {
|
||||||
*
|
uint8_t r;
|
||||||
* @param r Red channel (0-255)
|
uint8_t g;
|
||||||
* @param g Green channel (0-255)
|
uint8_t b;
|
||||||
* @param b Blue channel (0-255)
|
uint8_t a;
|
||||||
* @param a Alpha channel (0-255)
|
};
|
||||||
*/
|
|
||||||
Color4B(
|
|
||||||
const uint8_t r,
|
|
||||||
const uint8_t g,
|
|
||||||
const uint8_t b,
|
|
||||||
const uint8_t a
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
uint8_t rgba[4];
|
||||||
* Gets this color as a 4-channel byte color.
|
};
|
||||||
*/
|
|
||||||
Color4B toColor4B(void) const override;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this color as a 4-channel float color. (0-1 range)
|
* Color (RGBA, byte) constructor
|
||||||
*/
|
*
|
||||||
Color4F toColor4F(void) const override;
|
* @param r Red channel (0-255)
|
||||||
|
* @param g Green channel (0-255)
|
||||||
|
* @param b Blue channel (0-255)
|
||||||
|
* @param a Alpha channel (0-255)
|
||||||
|
*/
|
||||||
|
Color4B(
|
||||||
|
const uint8_t r,
|
||||||
|
const uint8_t g,
|
||||||
|
const uint8_t b,
|
||||||
|
const uint8_t a
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Color (RGBA, byte) constructor from array
|
||||||
|
*
|
||||||
|
* @param rgba Array of 4 bytes: {r, g, b, a}
|
||||||
|
*/
|
||||||
|
Color4B(const uint8_t rgba[4]);
|
||||||
};
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,24 @@ Color4F::Color4F(
|
|||||||
const float_t g,
|
const float_t g,
|
||||||
const float_t b,
|
const float_t b,
|
||||||
const float_t a
|
const float_t a
|
||||||
) : Color3F(r, g, b), a(a) {
|
) : r(r), g(g), b(b), a(a) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Color4F::Color4F(
|
||||||
|
const float_t rgba[4]
|
||||||
|
) : r(rgba[0]), g(rgba[1]), b(rgba[2]), a(rgba[3]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Color3B Color4F::toColor3B(void) const {
|
||||||
|
return Color3B(
|
||||||
|
static_cast<uint8_t>(r * 255.0f),
|
||||||
|
static_cast<uint8_t>(g * 255.0f),
|
||||||
|
static_cast<uint8_t>(b * 255.0f)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color3F Color4F::toColor3F(void) const {
|
||||||
|
return Color3F(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color4B Color4F::toColor4B(void) const {
|
Color4B Color4F::toColor4B(void) const {
|
||||||
|
|||||||
@@ -7,7 +7,12 @@
|
|||||||
#include "Color3F.hpp"
|
#include "Color3F.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
struct Color4F : public Color3F {
|
struct Color3B;
|
||||||
|
struct Color3F;
|
||||||
|
struct Color4B;
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct Color4F {
|
||||||
public:
|
public:
|
||||||
static const Color4F WHITE;
|
static const Color4F WHITE;
|
||||||
static const Color4F BLACK;
|
static const Color4F BLACK;
|
||||||
@@ -20,7 +25,16 @@ namespace Dawn {
|
|||||||
static const Color4F TRANSPARENT;
|
static const Color4F TRANSPARENT;
|
||||||
static const Color4F CORNFLOWER_BLUE;
|
static const Color4F CORNFLOWER_BLUE;
|
||||||
|
|
||||||
const float_t a;
|
union {
|
||||||
|
struct {
|
||||||
|
float_t r;
|
||||||
|
float_t g;
|
||||||
|
float_t b;
|
||||||
|
float_t a;
|
||||||
|
};
|
||||||
|
|
||||||
|
float_t rgba[4];
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color (RGBA, float) constructor
|
* Color (RGBA, float) constructor
|
||||||
@@ -37,14 +51,34 @@ namespace Dawn {
|
|||||||
const float_t a
|
const float_t a
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Color (RGBA, float) constructor from array
|
||||||
|
*
|
||||||
|
* @param rgba Array of 4 float_t: {r, g, b, a}
|
||||||
|
*/
|
||||||
|
Color4F(const float_t rgba[4]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets this color as a 3-channel byte color.
|
||||||
|
*
|
||||||
|
* @return Color3B representation of this color (alpha is discarded)
|
||||||
|
*/
|
||||||
|
Color3B toColor3B(void) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets this color as a 3-channel float color. (alpha is discarded)
|
||||||
|
*/
|
||||||
|
Color3F toColor3F(void) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this color as a 4-channel byte color.
|
* Gets this color as a 4-channel byte color.
|
||||||
*/
|
*/
|
||||||
Color4B toColor4B(void) const override;
|
Color4B toColor4B(void) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this color as a 4-channel float_t color.
|
* Gets this color as a 4-channel float_t color.
|
||||||
*/
|
*/
|
||||||
Color4F toColor4F(void) const override;
|
Color4F toColor4F(void) const;
|
||||||
};
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
}
|
}
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
// Copyright (c) 2025 Dominic Masters
|
|
||||||
//
|
|
||||||
// This software is released under the MIT License.
|
|
||||||
// https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "dawn.hpp"
|
|
||||||
|
|
||||||
namespace Dawn {
|
|
||||||
struct Color3B;
|
|
||||||
struct Color4B;
|
|
||||||
struct Color3F;
|
|
||||||
struct Color4F;
|
|
||||||
|
|
||||||
struct Color {
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Gets this color as a 3-channel byte color.
|
|
||||||
*/
|
|
||||||
virtual Color3B toColor3B(void) const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets this color as a 4-channel byte color.
|
|
||||||
*/
|
|
||||||
virtual Color4B toColor4B(void) const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets this color as a 3-channel float color. (0-1 range)
|
|
||||||
*/
|
|
||||||
virtual Color3F toColor3F(void) const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets this color as a 4-channel float color. (0-1 range)
|
|
||||||
*/
|
|
||||||
virtual Color4F toColor4F(void) const = 0;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -35,33 +35,33 @@ void Mesh::draw(
|
|||||||
"Vertex offset + count must not exceed vertex count"
|
"Vertex offset + count must not exceed vertex count"
|
||||||
);
|
);
|
||||||
|
|
||||||
#if DISPLAY_SDL2
|
#if DAWN_SDL2
|
||||||
// PSP style pointer legacy OpenGL
|
// PSP style pointer legacy OpenGL
|
||||||
const GLsizei stride = sizeof(MeshVertex);
|
const GLsizei stride = sizeof(MeshVertex);
|
||||||
|
|
||||||
glColorPointer(
|
glColorPointer(
|
||||||
MESH_VERTEX_COLOR_SIZE,
|
4,
|
||||||
GL_UNSIGNED_BYTE,
|
GL_UNSIGNED_BYTE,
|
||||||
stride,
|
stride,
|
||||||
(const GLvoid*)&this->vertices[offset].color[0]
|
(const GLvoid*)&this->vertices[offset].color[0]
|
||||||
);
|
);
|
||||||
|
|
||||||
glTexCoordPointer(
|
glTexCoordPointer(
|
||||||
MESH_VERTEX_UV_SIZE,
|
2,
|
||||||
GL_FLOAT,
|
GL_FLOAT,
|
||||||
stride,
|
stride,
|
||||||
(const GLvoid*)&this->vertices[offset].uv[0]
|
(const GLvoid*)&this->vertices[offset].uv[0]
|
||||||
);
|
);
|
||||||
|
|
||||||
glVertexPointer(
|
glVertexPointer(
|
||||||
MESH_VERTEX_POS_SIZE,
|
3,
|
||||||
GL_FLOAT,
|
GL_FLOAT,
|
||||||
stride,
|
stride,
|
||||||
(const GLvoid*)&this->vertices[offset].pos[0]
|
(const GLvoid*)&this->vertices[offset].position[0]
|
||||||
);
|
);
|
||||||
|
|
||||||
glDrawArrays(
|
glDrawArrays(
|
||||||
this->primitiveType,
|
static_cast<GLenum>(this->primitiveType),
|
||||||
0,
|
0,
|
||||||
count
|
count
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,14 +8,15 @@
|
|||||||
#include "display/color/Color.hpp"
|
#include "display/color/Color.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
|
#pragma pack(push, 1)
|
||||||
struct MeshVertex {
|
struct MeshVertex {
|
||||||
public:
|
#if DAWN_SDL2
|
||||||
#if DAWN_SDL2
|
uint8_t color[4];
|
||||||
Color4B color;
|
glm::vec2 uv;
|
||||||
glm::vec2 uv;
|
glm::vec3 position;
|
||||||
glm::vec3 position;
|
#endif
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
struct Mesh {
|
struct Mesh {
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
enum class PrimitiveType {
|
enum class PrimitiveType {
|
||||||
#if DAWN_SDL2
|
#if DAWN_SDL2
|
||||||
Triangles = GL_TRIANGLES,
|
TRIANGLES = GL_TRIANGLES,
|
||||||
Lines = GL_LINES,
|
LINES = GL_LINES,
|
||||||
Points = GL_POINTS,
|
POINTS = GL_POINTS,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user