Lowercase namespaces; move states to state/; cmd-based render groundwork
This commit is contained in:
parent
85cb2a8623
commit
8f02acdf09
@ -1,6 +1,6 @@
|
|||||||
#include "AABB.hpp"
|
#include "AABB.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
template class AABB<>;
|
template class AABB<>;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "platform/types/vec3.hpp"
|
#include "platform/types/vec3.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
///
|
///
|
||||||
/// @brief Axis-Aligned Bounding Box.
|
/// @brief Axis-Aligned Bounding Box.
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#define AUDIO_GC_DEBUG 0
|
#define AUDIO_GC_DEBUG 0
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
using Util::Log;
|
using Util::Log;
|
||||||
using namespace Util::Logging::LogLevels;
|
using namespace Util::Logging::LogLevels;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "Sound.hpp"
|
#include "Sound.hpp"
|
||||||
#include "SoundBuffer.hpp"
|
#include "SoundBuffer.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
|
|
||||||
|
@ -17,11 +17,9 @@ diggler_add_sources(
|
|||||||
${CSD}/Chunk.cpp
|
${CSD}/Chunk.cpp
|
||||||
${CSD}/Clouds.cpp
|
${CSD}/Clouds.cpp
|
||||||
${CSD}/Config.cpp
|
${CSD}/Config.cpp
|
||||||
${CSD}/ConnectingState.cpp
|
|
||||||
${CSD}/EscMenu.cpp
|
${CSD}/EscMenu.cpp
|
||||||
${CSD}/Frustum.cpp
|
${CSD}/Frustum.cpp
|
||||||
${CSD}/Game.cpp
|
${CSD}/Game.cpp
|
||||||
${CSD}/GameState.cpp
|
|
||||||
${CSD}/GameWindow.cpp
|
${CSD}/GameWindow.cpp
|
||||||
${CSD}/GLFWHandler.cpp
|
${CSD}/GLFWHandler.cpp
|
||||||
${CSD}/GlobalProperties.cpp
|
${CSD}/GlobalProperties.cpp
|
||||||
@ -31,7 +29,6 @@ diggler_add_sources(
|
|||||||
${CSD}/KeyBinds.cpp
|
${CSD}/KeyBinds.cpp
|
||||||
${CSD}/LocalPlayer.cpp
|
${CSD}/LocalPlayer.cpp
|
||||||
${CSD}/main.cpp
|
${CSD}/main.cpp
|
||||||
${CSD}/MessageState.cpp
|
|
||||||
${CSD}/network/client/BlockUpdateHandler.cpp
|
${CSD}/network/client/BlockUpdateHandler.cpp
|
||||||
${CSD}/network/client/ChatHandler.cpp
|
${CSD}/network/client/ChatHandler.cpp
|
||||||
${CSD}/network/client/ChunkTransferHandler.cpp
|
${CSD}/network/client/ChunkTransferHandler.cpp
|
||||||
@ -60,13 +57,16 @@ diggler_add_sources(
|
|||||||
${CSD}/Skybox.cpp
|
${CSD}/Skybox.cpp
|
||||||
${CSD}/SoundBuffer.cpp
|
${CSD}/SoundBuffer.cpp
|
||||||
${CSD}/Sound.cpp
|
${CSD}/Sound.cpp
|
||||||
|
${CSD}/states/ConnectingState.cpp
|
||||||
|
${CSD}/states/GameState.cpp
|
||||||
|
${CSD}/states/MessageState.cpp
|
||||||
|
${CSD}/states/UITestState.cpp
|
||||||
${CSD}/Texture.cpp
|
${CSD}/Texture.cpp
|
||||||
${CSD}/ui/Button.cpp
|
${CSD}/ui/Button.cpp
|
||||||
${CSD}/ui/Element.cpp
|
${CSD}/ui/Element.cpp
|
||||||
${CSD}/ui/Font.cpp
|
${CSD}/ui/Font.cpp
|
||||||
${CSD}/ui/FontManager.cpp
|
${CSD}/ui/FontManager.cpp
|
||||||
${CSD}/ui/Manager.cpp
|
${CSD}/ui/Manager.cpp
|
||||||
${CSD}/UITestState.cpp
|
|
||||||
${CSD}/ui/Text.cpp
|
${CSD}/ui/Text.cpp
|
||||||
${CSD}/Universe.cpp
|
${CSD}/Universe.cpp
|
||||||
${CSD}/World.cpp
|
${CSD}/World.cpp
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtx/rotate_vector.hpp>
|
#include <glm/gtx/rotate_vector.hpp>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
Camera::Camera() {
|
Camera::Camera() {
|
||||||
m_worldUp = vec3(0, 1, 0);
|
m_worldUp = vec3(0, 1, 0);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "Frustum.hpp"
|
#include "Frustum.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Camera {
|
class Camera {
|
||||||
friend class LocalPlayer;
|
friend class LocalPlayer;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "Platform.hpp"
|
#include "Platform.hpp"
|
||||||
#include <simplexnoise.h>
|
#include <simplexnoise.h>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
CaveGenerator::GenConf::GenConf() :
|
CaveGenerator::GenConf::GenConf() :
|
||||||
groundLevel(0.9), oreFactor(0.5) {
|
groundLevel(0.9), oreFactor(0.5) {
|
||||||
@ -62,11 +62,11 @@ void CaveGenerator::Generate(WorldRef wr, const GenConf &gc, ChunkRef cr) {
|
|||||||
for (int y = 0; y < CY; ++y)
|
for (int y = 0; y < CY; ++y)
|
||||||
for (int x = 0; x < CX; ++x)
|
for (int x = 0; x < CX; ++x)
|
||||||
for (int z = 0; z < CZ; ++z)
|
for (int z = 0; z < CZ; ++z)
|
||||||
c.setBlock(x, y, z, y < 8 ? Content::BlockUnknownId : Content::BlockAirId);
|
c.setBlock(x, y, z, y < 8 ? content::BlockUnknownId : content::BlockAirId);
|
||||||
for (int y = CY; y > 8; --y)
|
for (int y = CY; y > 8; --y)
|
||||||
for (int x = 0; x < CX; ++x) {
|
for (int x = 0; x < CX; ++x) {
|
||||||
c.setBlock(x, y, 0, Content::BlockUnknownId);
|
c.setBlock(x, y, 0, content::BlockUnknownId);
|
||||||
c.setBlock(x, y, CZ-1, Content::BlockUnknownId);
|
c.setBlock(x, y, CZ-1, content::BlockUnknownId);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
constexpr auto CX = Chunk::CX, CY = Chunk::CY, CZ = Chunk::CZ;
|
constexpr auto CX = Chunk::CX, CY = Chunk::CY, CZ = Chunk::CZ;
|
||||||
@ -78,9 +78,9 @@ void CaveGenerator::Generate(WorldRef wr, const GenConf &gc, ChunkRef cr) {
|
|||||||
for (int lz = 0; lz < CZ; ++lz) {
|
for (int lz = 0; lz < CZ; ++lz) {
|
||||||
int z = cp.z + lz;
|
int z = cp.z + lz;
|
||||||
if (y >= -8) {
|
if (y >= -8) {
|
||||||
c.setBlock(lx, ly, lz, y < raw_noise_3d(x/16.f, 0, z/16.f)*8 ? Content::BlockUnknownId : Content::BlockAirId);
|
c.setBlock(lx, ly, lz, y < raw_noise_3d(x/16.f, 0, z/16.f)*8 ? content::BlockUnknownId : content::BlockAirId);
|
||||||
} else {
|
} else {
|
||||||
c.setBlock(lx, ly, lz, raw_noise_3d(x/16.f, y/16.f, z/16.f) > 0.7 ? Content::BlockAirId : Content::BlockUnknownId);
|
c.setBlock(lx, ly, lz, raw_noise_3d(x/16.f, y/16.f, z/16.f) > 0.7 ? content::BlockAirId : content::BlockUnknownId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "World.hpp"
|
#include "World.hpp"
|
||||||
#include "WorldGenerator.hpp"
|
#include "WorldGenerator.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class CaveGenerator : public WorldGenerator {
|
class CaveGenerator : public WorldGenerator {
|
||||||
private:
|
private:
|
||||||
|
@ -9,16 +9,16 @@
|
|||||||
#include "render/gl/ProgramManager.hpp"
|
#include "render/gl/ProgramManager.hpp"
|
||||||
#include "ui/Manager.hpp"
|
#include "ui/Manager.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
const Render::gl::Program *Chatbox::RenderProgram = nullptr;
|
const render::gl::Program *Chatbox::RenderProgram = nullptr;
|
||||||
GLint Chatbox::RenderProgram_coord = -1;
|
GLint Chatbox::RenderProgram_coord = -1;
|
||||||
GLint Chatbox::RenderProgram_color = -1;
|
GLint Chatbox::RenderProgram_color = -1;
|
||||||
GLint Chatbox::RenderProgram_mvp = -1;
|
GLint Chatbox::RenderProgram_mvp = -1;
|
||||||
|
|
||||||
Chatbox::Chatbox(Game *G) : m_isChatting(false), G(G),
|
Chatbox::Chatbox(Game *G) : m_isChatting(false), G(G),
|
||||||
m_posX(0), m_posY(0) {
|
m_posX(0), m_posY(0) {
|
||||||
m_chatText = G->UIM->addManual<UI::Text>("", 2, 2);
|
m_chatText = G->UIM->addManual<ui::Text>("", 2, 2);
|
||||||
m_chatText->setPos(0, 0);
|
m_chatText->setPos(0, 0);
|
||||||
if (RenderProgram == nullptr) {
|
if (RenderProgram == nullptr) {
|
||||||
RenderProgram = G->PM->getProgram("2d", "color0");
|
RenderProgram = G->PM->getProgram("2d", "color0");
|
||||||
@ -35,7 +35,7 @@ Chatbox::Chatbox(Game *G) : m_isChatting(false), G(G),
|
|||||||
{0.f, 100.f, 0.f, 0.f, 0.f, .5f}
|
{0.f, 100.f, 0.f, 0.f, 0.f, .5f}
|
||||||
};
|
};
|
||||||
m_vbo.setData(verts, 6);
|
m_vbo.setData(verts, 6);
|
||||||
{ Render::gl::VAO::Config cfg = m_vao.configure();
|
{ render::gl::VAO::Config cfg = m_vao.configure();
|
||||||
cfg.vertexAttrib(m_vbo, RenderProgram_coord, 2, GL_FLOAT, sizeof(Vertex), 0);
|
cfg.vertexAttrib(m_vbo, RenderProgram_coord, 2, GL_FLOAT, sizeof(Vertex), 0);
|
||||||
cfg.vertexAttrib(m_vbo, RenderProgram_color, 4, GL_FLOAT, sizeof(Vertex), offsetof(Vertex, r));
|
cfg.vertexAttrib(m_vbo, RenderProgram_color, 4, GL_FLOAT, sizeof(Vertex), offsetof(Vertex, r));
|
||||||
cfg.commit();
|
cfg.commit();
|
||||||
@ -64,7 +64,7 @@ void Chatbox::addChatEntry(const std::string &text) {
|
|||||||
m_chatEntries.emplace_back();
|
m_chatEntries.emplace_back();
|
||||||
ChatEntry &entry = m_chatEntries.back();
|
ChatEntry &entry = m_chatEntries.back();
|
||||||
entry.date = system_clock::now();
|
entry.date = system_clock::now();
|
||||||
entry.text = G->UIM->addManual<UI::Text>(text);
|
entry.text = G->UIM->addManual<ui::Text>(text);
|
||||||
entry.height = entry.text->getSize().y;
|
entry.height = entry.text->getSize().y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@
|
|||||||
#include "render/gl/VBO.hpp"
|
#include "render/gl/VBO.hpp"
|
||||||
#include "ui/Text.hpp"
|
#include "ui/Text.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
namespace Render {
|
namespace render {
|
||||||
namespace gl {
|
namespace gl {
|
||||||
class Program;
|
class Program;
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ public:
|
|||||||
using time_point = std::chrono::time_point<system_clock>;
|
using time_point = std::chrono::time_point<system_clock>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const Render::gl::Program *RenderProgram;
|
static const render::gl::Program *RenderProgram;
|
||||||
static GLint RenderProgram_coord, RenderProgram_color, RenderProgram_mvp;
|
static GLint RenderProgram_coord, RenderProgram_color, RenderProgram_mvp;
|
||||||
|
|
||||||
bool m_isChatting;
|
bool m_isChatting;
|
||||||
@ -36,7 +36,7 @@ private:
|
|||||||
struct ChatEntry {
|
struct ChatEntry {
|
||||||
time_point date;
|
time_point date;
|
||||||
int height;
|
int height;
|
||||||
std::shared_ptr<UI::Text> text;
|
std::shared_ptr<ui::Text> text;
|
||||||
|
|
||||||
~ChatEntry();
|
~ChatEntry();
|
||||||
};
|
};
|
||||||
@ -44,12 +44,12 @@ private:
|
|||||||
// TODO: Update when libstdc++ supports locale codecvt facets
|
// TODO: Update when libstdc++ supports locale codecvt facets
|
||||||
//std::u32string m_chatString;
|
//std::u32string m_chatString;
|
||||||
std::string m_chatString;
|
std::string m_chatString;
|
||||||
std::shared_ptr<UI::Text> m_chatText;
|
std::shared_ptr<ui::Text> m_chatText;
|
||||||
struct Vertex {
|
struct Vertex {
|
||||||
float x, y, r, g, b, a;
|
float x, y, r, g, b, a;
|
||||||
};
|
};
|
||||||
Render::gl::VBO m_vbo;
|
render::gl::VBO m_vbo;
|
||||||
Render::gl::VAO m_vao;
|
render::gl::VAO m_vao;
|
||||||
int m_posX, m_posY;
|
int m_posX, m_posY;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#define SHOW_CHUNK_UPDATES 1
|
#define SHOW_CHUNK_UPDATES 1
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
using Util::Log;
|
using Util::Log;
|
||||||
using namespace Util::Logging::LogLevels;
|
using namespace Util::Logging::LogLevels;
|
||||||
@ -52,7 +52,7 @@ void Chunk::ChangeHelper::add(int x, int y, int z) {
|
|||||||
m_changes.emplace_back(x, y, z);
|
m_changes.emplace_back(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
using Net::MsgTypes::BlockUpdateNotify;
|
using net::MsgTypes::BlockUpdateNotify;
|
||||||
void Chunk::ChangeHelper::flush(BlockUpdateNotify &bun) {
|
void Chunk::ChangeHelper::flush(BlockUpdateNotify &bun) {
|
||||||
for (glm::ivec3 &c : m_changes) {
|
for (glm::ivec3 &c : m_changes) {
|
||||||
bun.updates.emplace_back();
|
bun.updates.emplace_back();
|
||||||
@ -284,7 +284,7 @@ void Chunk::updateClient() {
|
|||||||
imcUncompress();
|
imcUncompress();
|
||||||
#endif
|
#endif
|
||||||
mut.lock();
|
mut.lock();
|
||||||
Content::Registry &CR = *G->CR;
|
content::Registry &CR = *G->CR;
|
||||||
Vertex vertex[CX * CY * CZ * 6 /* faces */ * 4 /* vertices */ / 2 /* face removing (HSR) makes a lower vert max */];
|
Vertex vertex[CX * CY * CZ * 6 /* faces */ * 4 /* vertices */ / 2 /* face removing (HSR) makes a lower vert max */];
|
||||||
ushort idxOpaque[CX * CY * CZ * 6 /* faces */ * 6 /* indices */ / 2 /* HSR */],
|
ushort idxOpaque[CX * CY * CZ * 6 /* faces */ * 6 /* indices */ / 2 /* HSR */],
|
||||||
idxTransp[CX*CY*CZ*6*6/2];
|
idxTransp[CX*CY*CZ*6*6/2];
|
||||||
@ -299,8 +299,8 @@ void Chunk::updateClient() {
|
|||||||
bt = data->id[I(x,y,z)];
|
bt = data->id[I(x,y,z)];
|
||||||
|
|
||||||
// Empty block?
|
// Empty block?
|
||||||
if (bt == Content::BlockAirId ||
|
if (bt == content::BlockAirId ||
|
||||||
bt == Content::BlockIgnoreId)
|
bt == content::BlockIgnoreId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -429,7 +429,7 @@ void Chunk::updateClient() {
|
|||||||
mut.unlock();
|
mut.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chunk::write(IO::OutStream &os) const {
|
void Chunk::write(io::OutStream &os) const {
|
||||||
const uint dataSize = Chunk::AllocaSize;
|
const uint dataSize = Chunk::AllocaSize;
|
||||||
uint compressedSize;
|
uint compressedSize;
|
||||||
byte *compressed = new byte[dataSize];
|
byte *compressed = new byte[dataSize];
|
||||||
@ -448,7 +448,7 @@ void Chunk::write(IO::OutStream &os) const {
|
|||||||
delete[] compressed;
|
delete[] compressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chunk::read(IO::InStream &is) {
|
void Chunk::read(io::InStream &is) {
|
||||||
uint compressedSize = is.readU16();
|
uint compressedSize = is.readU16();
|
||||||
const uint targetDataSize = Chunk::AllocaSize;
|
const uint targetDataSize = Chunk::AllocaSize;
|
||||||
byte *compressedData = new byte[compressedSize];
|
byte *compressedData = new byte[compressedSize];
|
||||||
|
@ -13,18 +13,18 @@
|
|||||||
#define CHUNK_INMEM_COMPRESS 1
|
#define CHUNK_INMEM_COMPRESS 1
|
||||||
#define CHUNK_INMEM_COMPRESS_DELAY 2000 /* ms */
|
#define CHUNK_INMEM_COMPRESS_DELAY 2000 /* ms */
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class CaveGenerator;
|
class CaveGenerator;
|
||||||
class Game;
|
class Game;
|
||||||
class World;
|
class World;
|
||||||
using WorldRef = std::shared_ptr<World>;
|
using WorldRef = std::shared_ptr<World>;
|
||||||
|
|
||||||
namespace Render {
|
namespace render {
|
||||||
class WorldRenderer;
|
class WorldRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Net {
|
namespace net {
|
||||||
namespace MsgTypes {
|
namespace MsgTypes {
|
||||||
struct BlockUpdateNotify;
|
struct BlockUpdateNotify;
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ class Chunk {
|
|||||||
private:
|
private:
|
||||||
friend World;
|
friend World;
|
||||||
friend CaveGenerator;
|
friend CaveGenerator;
|
||||||
friend class Render::WorldRenderer;
|
friend class render::WorldRenderer;
|
||||||
uintptr_t rendererData;
|
uintptr_t rendererData;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
void add(int x, int y, int z);
|
void add(int x, int y, int z);
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
int count() const;
|
int count() const;
|
||||||
void flush(Net::MsgTypes::BlockUpdateNotify&);
|
void flush(net::MsgTypes::BlockUpdateNotify&);
|
||||||
void discard();
|
void discard();
|
||||||
} CH;
|
} CH;
|
||||||
|
|
||||||
@ -240,8 +240,8 @@ public:
|
|||||||
|
|
||||||
/* ============ Serialization ============ */
|
/* ============ Serialization ============ */
|
||||||
|
|
||||||
void write(IO::OutStream&) const;
|
void write(io::OutStream&) const;
|
||||||
void read(IO::InStream&);
|
void read(io::InStream&);
|
||||||
};
|
};
|
||||||
|
|
||||||
using ChunkRef = std::shared_ptr<Chunk>;
|
using ChunkRef = std::shared_ptr<Chunk>;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "render/Renderer.hpp"
|
#include "render/Renderer.hpp"
|
||||||
#include "Texture.hpp"
|
#include "Texture.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
Clouds::Renderer Clouds::R = {0};
|
Clouds::Renderer Clouds::R = {0};
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@
|
|||||||
#include "platform/Types.hpp"
|
#include "platform/Types.hpp"
|
||||||
#include "render/gl/VBO.hpp"
|
#include "render/gl/VBO.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
class Texture;
|
class Texture;
|
||||||
|
|
||||||
namespace Render {
|
namespace render {
|
||||||
namespace gl {
|
namespace gl {
|
||||||
class Program;
|
class Program;
|
||||||
}
|
}
|
||||||
@ -23,11 +23,11 @@ class Program;
|
|||||||
class Clouds {
|
class Clouds {
|
||||||
private:
|
private:
|
||||||
static struct Renderer {
|
static struct Renderer {
|
||||||
const Render::gl::Program *prog;
|
const render::gl::Program *prog;
|
||||||
GLint att_coord, att_texcoord, uni_mvp, uni_texshift;
|
GLint att_coord, att_texcoord, uni_mvp, uni_texshift;
|
||||||
} R;
|
} R;
|
||||||
std::vector<std::shared_ptr<Texture>> m_tex;
|
std::vector<std::shared_ptr<Texture>> m_tex;
|
||||||
Render::gl::VBO m_vbo;
|
render::gl::VBO m_vbo;
|
||||||
int m_layers;
|
int m_layers;
|
||||||
Game *G;
|
Game *G;
|
||||||
struct Coord { uint8 x, y, z, u, v; };
|
struct Coord { uint8 x, y, z, u, v; };
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "Config.hpp"
|
#include "Config.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
Config::Config() {
|
Config::Config() {
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define SETTINGS_HPP
|
#define SETTINGS_HPP
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
private:
|
private:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define ENTITY_HPP
|
#define ENTITY_HPP
|
||||||
#include "Platform.hpp"
|
#include "Platform.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Entity {
|
class Entity {
|
||||||
public:
|
public:
|
||||||
|
@ -10,17 +10,17 @@
|
|||||||
#include "ui/Manager.hpp"
|
#include "ui/Manager.hpp"
|
||||||
#include "ui/Text.hpp"
|
#include "ui/Text.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
struct EscMenu::MenuEntryImpl {
|
struct EscMenu::MenuEntryImpl {
|
||||||
Area inputArea;
|
Area inputArea;
|
||||||
std::shared_ptr<UI::Text> txtText;
|
std::shared_ptr<ui::Text> txtText;
|
||||||
};
|
};
|
||||||
|
|
||||||
EscMenu::EscMenu(UI::Manager *UIM) :
|
EscMenu::EscMenu(ui::Manager *UIM) :
|
||||||
UI::Element(UIM),
|
ui::Element(UIM),
|
||||||
G(UIM->G) {
|
G(UIM->G) {
|
||||||
txtMenuTitle = G->UIM->addManual<UI::Text>(" Menu", 3, 3);
|
txtMenuTitle = G->UIM->addManual<ui::Text>(" Menu", 3, 3);
|
||||||
//m_button = new UIButton(G, glm::mat);
|
//m_button = new UIButton(G, glm::mat);
|
||||||
for (int i=0;i<10;++i)
|
for (int i=0;i<10;++i)
|
||||||
addMenuEntry("hello " + std::to_string(i));
|
addMenuEntry("hello " + std::to_string(i));
|
||||||
@ -43,7 +43,7 @@ void EscMenu::refresh() {
|
|||||||
|
|
||||||
void EscMenu::addMenuEntry(const std::string &text) {
|
void EscMenu::addMenuEntry(const std::string &text) {
|
||||||
entries.emplace_back(MenuEntry { text, std::make_unique<MenuEntryImpl>() });
|
entries.emplace_back(MenuEntry { text, std::make_unique<MenuEntryImpl>() });
|
||||||
entries.back().impl->txtText = G->UIM->addManual<UI::Text>(text, 2, 2);
|
entries.back().impl->txtText = G->UIM->addManual<ui::Text>(text, 2, 2);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ void EscMenu::onInputAreaChanged() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EscMenu::setVisible(bool v) {
|
void EscMenu::setVisible(bool v) {
|
||||||
UI::Element::setVisible(v);
|
ui::Element::setVisible(v);
|
||||||
if (v) {
|
if (v) {
|
||||||
m_transition.start = G->Time;
|
m_transition.start = G->Time;
|
||||||
m_transition.duration = .3;
|
m_transition.duration = .3;
|
||||||
@ -89,7 +89,7 @@ void EscMenu::render(const glm::mat4 &baseMatrix) const {
|
|||||||
|
|
||||||
const int width = renderArea().w;
|
const int width = renderArea().w;
|
||||||
const int pxScroll = (1 - scroll) * width;
|
const int pxScroll = (1 - scroll) * width;
|
||||||
G->UIM->drawRect(baseMatrix, UI::Element::Area { pxScroll, 0, width, renderArea().h },
|
G->UIM->drawRect(baseMatrix, ui::Element::Area { pxScroll, 0, width, renderArea().h },
|
||||||
glm::vec4(0.f, 0.f, 0.f, 0.8f));
|
glm::vec4(0.f, 0.f, 0.f, 0.8f));
|
||||||
|
|
||||||
int y = renderArea().h;
|
int y = renderArea().h;
|
||||||
|
@ -8,23 +8,23 @@
|
|||||||
#include "render/gl/Program.hpp"
|
#include "render/gl/Program.hpp"
|
||||||
#include "ui/Element.hpp"
|
#include "ui/Element.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
namespace UI {
|
namespace ui {
|
||||||
class Button;
|
class Button;
|
||||||
class Text;
|
class Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
class EscMenu : public UI::Element {
|
class EscMenu : public ui::Element {
|
||||||
private:
|
private:
|
||||||
Game *G;
|
Game *G;
|
||||||
mutable struct {
|
mutable struct {
|
||||||
double start, duration;
|
double start, duration;
|
||||||
bool active;
|
bool active;
|
||||||
} m_transition;
|
} m_transition;
|
||||||
std::shared_ptr<UI::Text> txtMenuTitle;
|
std::shared_ptr<ui::Text> txtMenuTitle;
|
||||||
std::shared_ptr<UI::Button> m_button;
|
std::shared_ptr<ui::Button> m_button;
|
||||||
struct MenuEntryImpl;
|
struct MenuEntryImpl;
|
||||||
struct MenuEntry {
|
struct MenuEntry {
|
||||||
std::string text;
|
std::string text;
|
||||||
@ -35,7 +35,7 @@ private:
|
|||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EscMenu(UI::Manager*);
|
EscMenu(ui::Manager*);
|
||||||
~EscMenu();
|
~EscMenu();
|
||||||
|
|
||||||
void addMenuEntry(const std::string &text);
|
void addMenuEntry(const std::string &text);
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
void setVisible(bool) override;
|
void setVisible(bool) override;
|
||||||
|
|
||||||
void render(const glm::mat4&) const override;
|
void render(const glm::mat4&) const override;
|
||||||
using UI::Element::render;
|
using ui::Element::render;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
void Frustum::setCamInternals(vec3vt rad, vec3vt ratio, vec3vt nearD, vec3vt farD) {
|
void Frustum::setCamInternals(vec3vt rad, vec3vt ratio, vec3vt nearD, vec3vt farD) {
|
||||||
this->ratio = ratio;
|
this->ratio = ratio;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#undef NEAR
|
#undef NEAR
|
||||||
#undef FAR
|
#undef FAR
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Frustum {
|
class Frustum {
|
||||||
private:
|
private:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "GLFWHandler.hpp"
|
#include "GLFWHandler.hpp"
|
||||||
#include "GameWindow.hpp"
|
#include "GameWindow.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
void GLFWHandler::mouseButtonImpl(GLFWwindow *window, int key, int action, int mods) {
|
void GLFWHandler::mouseButtonImpl(GLFWwindow *window, int key, int action, int mods) {
|
||||||
(void)window;
|
(void)window;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class GameWindow;
|
class GameWindow;
|
||||||
|
|
||||||
|
27
src/Game.cpp
27
src/Game.cpp
@ -1,18 +1,19 @@
|
|||||||
#include "Game.hpp"
|
#include "Game.hpp"
|
||||||
|
|
||||||
#include "Audio.hpp"
|
|
||||||
#include "content/AssetManager.hpp"
|
#include "content/AssetManager.hpp"
|
||||||
#include "content/ModManager.hpp"
|
#include "content/ModManager.hpp"
|
||||||
#include "content/Registry.hpp"
|
#include "content/Registry.hpp"
|
||||||
#include "GlobalProperties.hpp"
|
#include "gfx/Device.hpp"
|
||||||
#include "KeyBinds.hpp"
|
|
||||||
#include "LocalPlayer.hpp"
|
|
||||||
#include "render/gl/ProgramManager.hpp"
|
#include "render/gl/ProgramManager.hpp"
|
||||||
#include "render/gl/Renderer.hpp"
|
#include "render/gl/Renderer.hpp"
|
||||||
#include "scripting/lua/State.hpp"
|
#include "scripting/lua/State.hpp"
|
||||||
#include "ui/FontManager.hpp"
|
#include "ui/FontManager.hpp"
|
||||||
|
#include "Audio.hpp"
|
||||||
|
#include "GlobalProperties.hpp"
|
||||||
|
#include "KeyBinds.hpp"
|
||||||
|
#include "LocalPlayer.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
Game::Game() :
|
Game::Game() :
|
||||||
C(nullptr),
|
C(nullptr),
|
||||||
@ -35,9 +36,9 @@ Game::Game() :
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::init() {
|
void Game::init() {
|
||||||
AM = std::make_unique<Content::AssetManager>(this);
|
AM = std::make_unique<content::AssetManager>(this);
|
||||||
MM = std::make_unique<Content::ModManager>(this);
|
MM = std::make_unique<content::ModManager>(this);
|
||||||
LS = new Scripting::Lua::State(this);
|
LS = new scripting::lua::State(this);
|
||||||
if (GlobalProperties::IsClient) {
|
if (GlobalProperties::IsClient) {
|
||||||
initClient();
|
initClient();
|
||||||
}
|
}
|
||||||
@ -47,7 +48,7 @@ void Game::init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::initClient() {
|
void Game::initClient() {
|
||||||
PM = new Render::gl::ProgramManager(*this);
|
PM = new render::gl::ProgramManager(*this);
|
||||||
LP = new LocalPlayer(this);
|
LP = new LocalPlayer(this);
|
||||||
RP = new RenderProperties; { // TODO move somewhere else?
|
RP = new RenderProperties; { // TODO move somewhere else?
|
||||||
RP->bloom = true;
|
RP->bloom = true;
|
||||||
@ -55,9 +56,9 @@ void Game::initClient() {
|
|||||||
RP->fogStart = 16;
|
RP->fogStart = 16;
|
||||||
RP->fogEnd = 24;
|
RP->fogEnd = 24;
|
||||||
}
|
}
|
||||||
R = new Render::gl::GLRenderer(this);
|
R = new render::gl::GLRenderer(this);
|
||||||
CR = new Content::Registry(*this);
|
CR = new content::Registry(*this);
|
||||||
FM = std::make_unique<UI::FontManager>(*this);
|
FM = std::make_unique<ui::FontManager>(*this);
|
||||||
A = new Audio(*this);
|
A = new Audio(*this);
|
||||||
KB = new KeyBinds;
|
KB = new KeyBinds;
|
||||||
LP = new LocalPlayer(this);
|
LP = new LocalPlayer(this);
|
||||||
@ -65,7 +66,7 @@ void Game::initClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::initServer() {
|
void Game::initServer() {
|
||||||
CR = new Content::Registry(*this);
|
CR = new content::Registry(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::finalize() {
|
void Game::finalize() {
|
||||||
|
37
src/Game.hpp
37
src/Game.hpp
@ -8,28 +8,32 @@
|
|||||||
|
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
namespace Content {
|
namespace content {
|
||||||
class AssetManager;
|
class AssetManager;
|
||||||
class ModManager;
|
class ModManager;
|
||||||
class Registry;
|
class Registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Render {
|
namespace gfx {
|
||||||
|
class Device;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace render {
|
||||||
class Renderer;
|
class Renderer;
|
||||||
namespace gl {
|
namespace gl {
|
||||||
class ProgramManager;
|
class ProgramManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Scripting {
|
namespace scripting {
|
||||||
namespace Lua {
|
namespace lua {
|
||||||
class State;
|
class State;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace UI {
|
namespace ui {
|
||||||
class FontManager;
|
class FontManager;
|
||||||
class Manager;
|
class Manager;
|
||||||
}
|
}
|
||||||
@ -50,30 +54,31 @@ public:
|
|||||||
// Shared
|
// Shared
|
||||||
Config *C;
|
Config *C;
|
||||||
double Time; uint64 TimeMs;
|
double Time; uint64 TimeMs;
|
||||||
Net::Host H;
|
net::Host H;
|
||||||
Universe *U;
|
Universe *U;
|
||||||
PlayerList players;
|
PlayerList players;
|
||||||
Content::Registry *CR;
|
content::Registry *CR;
|
||||||
ptr<Content::AssetManager> AM;
|
ptr<content::AssetManager> AM;
|
||||||
ptr<Content::ModManager> MM;
|
ptr<content::ModManager> MM;
|
||||||
Scripting::Lua::State *LS;
|
scripting::lua::State *LS;
|
||||||
|
|
||||||
// Server
|
// Server
|
||||||
Server *S;
|
Server *S;
|
||||||
|
|
||||||
// Client
|
// Client
|
||||||
|
ptr<gfx::Device> GD;
|
||||||
GameWindow *GW;
|
GameWindow *GW;
|
||||||
UI::Manager *UIM;
|
ui::Manager *UIM;
|
||||||
LocalPlayer *LP;
|
LocalPlayer *LP;
|
||||||
Render::gl::ProgramManager *PM;
|
render::gl::ProgramManager *PM;
|
||||||
Render::Renderer *R;
|
render::Renderer *R;
|
||||||
ptr<UI::FontManager> FM;
|
ptr<ui::FontManager> FM;
|
||||||
struct RenderProperties {
|
struct RenderProperties {
|
||||||
bool bloom, wavingLiquids;
|
bool bloom, wavingLiquids;
|
||||||
float fogStart, fogEnd;
|
float fogStart, fogEnd;
|
||||||
} *RP;
|
} *RP;
|
||||||
Audio *A;
|
Audio *A;
|
||||||
Net::Peer *NS;
|
net::Peer *NS;
|
||||||
KeyBinds *KB;
|
KeyBinds *KB;
|
||||||
int PlayerPosUpdateFreq;
|
int PlayerPosUpdateFreq;
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
#include "Game.hpp"
|
#include "Game.hpp"
|
||||||
#include "GlobalProperties.hpp"
|
#include "GlobalProperties.hpp"
|
||||||
#include "GLFWHandler.hpp"
|
#include "GLFWHandler.hpp"
|
||||||
#include "GameState.hpp"
|
#include "states/GameState.hpp"
|
||||||
#include "MessageState.hpp"
|
#include "states/MessageState.hpp"
|
||||||
#include "Audio.hpp"
|
#include "Audio.hpp"
|
||||||
#include "ui/FontManager.hpp"
|
#include "ui/FontManager.hpp"
|
||||||
#include "ui/Manager.hpp"
|
#include "ui/Manager.hpp"
|
||||||
@ -19,7 +19,7 @@
|
|||||||
#include "util/Log.hpp"
|
#include "util/Log.hpp"
|
||||||
#include "util/MemoryTracker.hpp"
|
#include "util/MemoryTracker.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
using Util::Log;
|
using Util::Log;
|
||||||
using namespace Util::Logging::LogLevels;
|
using namespace Util::Logging::LogLevels;
|
||||||
@ -50,10 +50,10 @@ GameWindow::GameWindow(Game *G) : G(G) {
|
|||||||
|
|
||||||
m_w = 640; m_h = 480;
|
m_w = 640; m_h = 480;
|
||||||
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API /*GLFW_OPENGL_ES_API*/);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API /*GLFW_OPENGL_ES_API*/);
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||||
glfwWindowHint(GLFW_SAMPLES, 0); // Gimme aliasing everywhere
|
glfwWindowHint(GLFW_SAMPLES, 0); // Gimme aliasing everywhere
|
||||||
//glfwWindowHint(GLFW_STENCIL_BITS, 8);
|
//glfwWindowHint(GLFW_STENCIL_BITS, 8);
|
||||||
|
|
||||||
@ -68,10 +68,10 @@ GameWindow::GameWindow(Game *G) : G(G) {
|
|||||||
}
|
}
|
||||||
glfwMakeContextCurrent(m_window);
|
glfwMakeContextCurrent(m_window);
|
||||||
|
|
||||||
Render::gl::OpenGL::init();
|
render::gl::OpenGL::init();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Render::gl::Debug::enable();
|
render::gl::Debug::enable();
|
||||||
#endif
|
#endif
|
||||||
glfwSetFramebufferSizeCallback(m_window, GLFWHandler::resize);
|
glfwSetFramebufferSizeCallback(m_window, GLFWHandler::resize);
|
||||||
glfwSetCursorPosCallback(m_window, GLFWHandler::cursorPos);
|
glfwSetCursorPosCallback(m_window, GLFWHandler::cursorPos);
|
||||||
@ -111,9 +111,9 @@ GameWindow::GameWindow(Game *G) : G(G) {
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
auto glver = Render::gl::OpenGL::version();
|
auto glver = render::gl::OpenGL::version();
|
||||||
Log(Info, TAG) << Render::gl::OpenGL::loaderName() << ' ' <<
|
Log(Info, TAG) << render::gl::OpenGL::loaderName() << ' ' <<
|
||||||
Render::gl::OpenGL::loaderVersion() << " -- GL" <<
|
render::gl::OpenGL::loaderVersion() << " -- GL" <<
|
||||||
(glver.isGLES ? "ES" : "") << ' ' <<
|
(glver.isGLES ? "ES" : "") << ' ' <<
|
||||||
glver.major << '.' << glver.minor <<
|
glver.major << '.' << glver.minor <<
|
||||||
(glver.isCore ? " Core" : "") <<
|
(glver.isCore ? " Core" : "") <<
|
||||||
@ -127,7 +127,7 @@ GameWindow::GameWindow(Game *G) : G(G) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ Util::MemoryTracker::ScopedCategory sc(nullptr);
|
{ Util::MemoryTracker::ScopedCategory sc(nullptr);
|
||||||
UIM = new UI::Manager;
|
UIM = new ui::Manager;
|
||||||
UIM->onResize(m_w, m_h);
|
UIM->onResize(m_w, m_h);
|
||||||
|
|
||||||
G->init();
|
G->init();
|
||||||
@ -203,7 +203,11 @@ void GameWindow::cbResize(int w, int h) {
|
|||||||
m_currentState->onResize(w, h);
|
m_currentState->onResize(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameWindow::setNextState(std::unique_ptr<State> &&next) {
|
states::State& GameWindow::state() const {
|
||||||
|
return *m_currentState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameWindow::setNextState(std::unique_ptr<states::State> &&next) {
|
||||||
m_nextState = std::move(next);
|
m_nextState = std::move(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +234,7 @@ void GameWindow::run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameWindow::showMessage(const std::string &msg, const std::string &submsg) {
|
void GameWindow::showMessage(const std::string &msg, const std::string &submsg) {
|
||||||
setNextState(std::make_unique<MessageState>(this, msg, submsg));
|
setNextState(std::make_unique<states::MessageState>(this, msg, submsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
|
|
||||||
#include "StateMachine.hpp"
|
#include "StateMachine.hpp"
|
||||||
#include "Platform.hpp"
|
#include "Platform.hpp"
|
||||||
|
#include "platform/Types.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
class State;
|
|
||||||
|
|
||||||
namespace UI {
|
namespace ui {
|
||||||
class Manager;
|
class Manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,15 +30,15 @@ private:
|
|||||||
GLFWwindow *m_window;
|
GLFWwindow *m_window;
|
||||||
int m_w, m_h;
|
int m_w, m_h;
|
||||||
|
|
||||||
std::unique_ptr<State> m_currentState, m_nextState;
|
std::unique_ptr<states::State> m_currentState, m_nextState;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UI::Manager *UIM;
|
ui::Manager *UIM;
|
||||||
|
|
||||||
Game *G;
|
Game *G;
|
||||||
|
|
||||||
GameWindow(Game*);
|
GameWindow(Game*);
|
||||||
~GameWindow();
|
~GameWindow() override;
|
||||||
|
|
||||||
operator GLFWwindow&() const { return *m_window; }
|
operator GLFWwindow&() const { return *m_window; }
|
||||||
operator GLFWwindow*() const { return m_window; }
|
operator GLFWwindow*() const { return m_window; }
|
||||||
@ -60,7 +60,9 @@ public:
|
|||||||
|
|
||||||
void updateViewport();
|
void updateViewport();
|
||||||
|
|
||||||
void setNextState(std::unique_ptr<State> &&next) override;
|
states::State& state() const override;
|
||||||
|
void setNextState(std::unique_ptr<states::State> &&next) override;
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
void showMessage(const std::string &msg, const std::string &submsg = "");
|
void showMessage(const std::string &msg, const std::string &submsg = "");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "GlobalProperties.hpp"
|
#include "GlobalProperties.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
bool GlobalProperties::IsClient = true;
|
bool GlobalProperties::IsClient = true;
|
||||||
bool GlobalProperties::IsServer = false;
|
bool GlobalProperties::IsServer = false;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef GLOBAL_PROPERTIES_HPP
|
#ifndef GLOBAL_PROPERTIES_HPP
|
||||||
#define GLOBAL_PROPERTIES_HPP
|
#define GLOBAL_PROPERTIES_HPP
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
namespace GlobalProperties {
|
namespace GlobalProperties {
|
||||||
extern bool IsClient;
|
extern bool IsClient;
|
||||||
|
@ -7,7 +7,7 @@ using std::fwrite;
|
|||||||
using std::fread;
|
using std::fread;
|
||||||
using std::fclose;
|
using std::fclose;
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
KeyBinds::KeyBinds() {
|
KeyBinds::KeyBinds() {
|
||||||
loadDefaults();
|
loadDefaults();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define KEY_BINDS_HPP
|
#define KEY_BINDS_HPP
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class KeyBinds {
|
class KeyBinds {
|
||||||
public:
|
public:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include "render/gl/ProgramManager.hpp"
|
#include "render/gl/ProgramManager.hpp"
|
||||||
#include "util/Log.hpp"
|
#include "util/Log.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
using Util::Log;
|
using Util::Log;
|
||||||
using namespace Util::Logging::LogLevels;
|
using namespace Util::Logging::LogLevels;
|
||||||
@ -148,7 +148,7 @@ void LocalPlayer::update(float delta) {
|
|||||||
for (int cz = min.z; cz < max.z; ++cz) {
|
for (int cz = min.z; cz < max.z; ++cz) {
|
||||||
blockBox.v1.z = cz; blockBox.v2.z = cz + 1;
|
blockBox.v1.z = cz; blockBox.v2.z = cz + 1;
|
||||||
BlockId id = W->getBlockId(cx, cy, cz);
|
BlockId id = W->getBlockId(cx, cy, cz);
|
||||||
if (id != Content::BlockAirId) {
|
if (id != content::BlockAirId) {
|
||||||
glm::vec3 normal;
|
glm::vec3 normal;
|
||||||
float d = plrBox.sweptCollision(blockBox, dtvel.x, dtvel.y, dtvel.z, normal.x, normal.y, normal.z);
|
float d = plrBox.sweptCollision(blockBox, dtvel.x, dtvel.y, dtvel.z, normal.x, normal.y, normal.z);
|
||||||
if (d < pdelta) {
|
if (d < pdelta) {
|
||||||
@ -210,10 +210,10 @@ void LocalPlayer::render(const glm::mat4 &transform) const {
|
|||||||
{ min.x, min.y, max.z, 0, 1, 0 },
|
{ min.x, min.y, max.z, 0, 1, 0 },
|
||||||
};
|
};
|
||||||
vbo.setDataGrow(pts, sizeof(pts)/sizeof(Coord), GL_STREAM_DRAW);
|
vbo.setDataGrow(pts, sizeof(pts)/sizeof(Coord), GL_STREAM_DRAW);
|
||||||
const Render::gl::Program &P = *G->PM->getProgram("3d", "color0");
|
const render::gl::Program &P = *G->PM->getProgram("3d", "color0");
|
||||||
if (!vaoConfigured) {
|
if (!vaoConfigured) {
|
||||||
vaoConfigured = true;
|
vaoConfigured = true;
|
||||||
Render::gl::VAO::Config cfg = vao.configure();
|
render::gl::VAO::Config cfg = vao.configure();
|
||||||
cfg.vertexAttrib(vbo, P.att("coord"), 3, GL_FLOAT, sizeof(Coord), 0);
|
cfg.vertexAttrib(vbo, P.att("coord"), 3, GL_FLOAT, sizeof(Coord), 0);
|
||||||
cfg.vertexAttrib(vbo, P.att("color"), 3, GL_UNSIGNED_BYTE, sizeof(Coord), offsetof(Coord, r));
|
cfg.vertexAttrib(vbo, P.att("color"), 3, GL_UNSIGNED_BYTE, sizeof(Coord), offsetof(Coord, r));
|
||||||
cfg.commit();
|
cfg.commit();
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "render/gl/VAO.hpp"
|
#include "render/gl/VAO.hpp"
|
||||||
#include "render/gl/VBO.hpp"
|
#include "render/gl/VBO.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
|
|
||||||
@ -20,8 +20,8 @@ private:
|
|||||||
bool hasGravity, hasNoclip, onGround, onRoad;
|
bool hasGravity, hasNoclip, onGround, onRoad;
|
||||||
|
|
||||||
// debugging
|
// debugging
|
||||||
mutable Render::gl::VBO vbo;
|
mutable render::gl::VBO vbo;
|
||||||
mutable Render::gl::VAO vao;
|
mutable render::gl::VAO vao;
|
||||||
mutable bool vaoConfigured = false;
|
mutable bool vaoConfigured = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "Game.hpp"
|
#include "Game.hpp"
|
||||||
#include "render/Renderer.hpp"
|
#include "render/Renderer.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
ParticleEmitter::ParticleEmitter(Game *G) :
|
ParticleEmitter::ParticleEmitter(Game *G) :
|
||||||
G(G) {
|
G(G) {
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
#include <glm/vec4.hpp>
|
#include <glm/vec4.hpp>
|
||||||
#include <glm/mat4x4.hpp>
|
#include <glm/mat4x4.hpp>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
namespace Render {
|
namespace render {
|
||||||
class ParticlesRenderer;
|
class ParticlesRenderer;
|
||||||
}
|
}
|
||||||
class Game;
|
class Game;
|
||||||
@ -22,7 +22,7 @@ struct Particle {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class ParticleEmitter {
|
class ParticleEmitter {
|
||||||
friend class Render::ParticlesRenderer;
|
friend class render::ParticlesRenderer;
|
||||||
uintptr_t rendererData;
|
uintptr_t rendererData;
|
||||||
|
|
||||||
Game *G;
|
Game *G;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "platform/Types.hpp"
|
#include "platform/Types.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
enum class PixelFormat : uint8 {
|
enum class PixelFormat : uint8 {
|
||||||
RGB,
|
RGB,
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
#include "util/Log.hpp"
|
#include "util/Log.hpp"
|
||||||
|
|
||||||
using Diggler::Util::Log;
|
using diggler::Util::Log;
|
||||||
using namespace Diggler::Util::Logging::LogLevels;
|
using namespace diggler::Util::Logging::LogLevels;
|
||||||
|
|
||||||
static const char *TAG = "Platform";
|
static const char *TAG = "Platform";
|
||||||
|
|
||||||
const char *Diggler::UserdataDirsName = "Diggler";
|
const char *diggler::UserdataDirsName = "Diggler";
|
||||||
|
|
||||||
static struct PathCache {
|
static struct PathCache {
|
||||||
std::string
|
std::string
|
||||||
@ -27,7 +27,7 @@ static struct PathCache {
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "platform/Fixes.hpp"
|
#include "platform/Fixes.hpp"
|
||||||
|
|
||||||
std::string Diggler::proc::getExecutablePath() {
|
std::string diggler::proc::getExecutablePath() {
|
||||||
if (pathCache.executableBin.length() == 0) {
|
if (pathCache.executableBin.length() == 0) {
|
||||||
HMODULE hModule = GetModuleHandleW(NULL);
|
HMODULE hModule = GetModuleHandleW(NULL);
|
||||||
WCHAR path[MAX_PATH];
|
WCHAR path[MAX_PATH];
|
||||||
@ -39,7 +39,7 @@ std::string Diggler::proc::getExecutablePath() {
|
|||||||
return pathCache.executableBin;
|
return pathCache.executableBin;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Diggler::proc::getExecutableDirectory() {
|
std::string diggler::proc::getExecutableDirectory() {
|
||||||
if (pathCache.executableDir.length() == 0) {
|
if (pathCache.executableDir.length() == 0) {
|
||||||
std::string filename(getExecutablePath());
|
std::string filename(getExecutablePath());
|
||||||
const size_t last_sep_idx = filename.rfind('\\');
|
const size_t last_sep_idx = filename.rfind('\\');
|
||||||
@ -53,7 +53,7 @@ std::string Diggler::proc::getExecutableDirectory() {
|
|||||||
return pathCache.executableDir;
|
return pathCache.executableDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Diggler::getCacheDirectory() {
|
std::string diggler::getCacheDirectory() {
|
||||||
if (pathCache.cacheDir.length() == 0) {
|
if (pathCache.cacheDir.length() == 0) {
|
||||||
WCHAR ucs2Path[MAX_PATH];
|
WCHAR ucs2Path[MAX_PATH];
|
||||||
SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, 0, ucs2Path);
|
SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, 0, ucs2Path);
|
||||||
@ -64,7 +64,7 @@ std::string Diggler::getCacheDirectory() {
|
|||||||
return pathCache.cacheDir;
|
return pathCache.cacheDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Diggler::getConfigDirectory() {
|
std::string diggler::getConfigDirectory() {
|
||||||
if (pathCache.cacheDir.length() == 0) {
|
if (pathCache.cacheDir.length() == 0) {
|
||||||
WCHAR ucs2Path[MAX_PATH];
|
WCHAR ucs2Path[MAX_PATH];
|
||||||
SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, 0, ucs2Path);
|
SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, 0, ucs2Path);
|
||||||
@ -86,7 +86,7 @@ std::string do_readlink(const char *path);
|
|||||||
std::string do_readlink(const std::string &path);
|
std::string do_readlink(const std::string &path);
|
||||||
|
|
||||||
#if defined(BUILDINFO_PLATFORM_LINUX)
|
#if defined(BUILDINFO_PLATFORM_LINUX)
|
||||||
std::string Diggler::proc::getExecutablePath() {
|
std::string diggler::proc::getExecutablePath() {
|
||||||
if (pathCache.executableBin.length() == 0) {
|
if (pathCache.executableBin.length() == 0) {
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
// Assuming 32-bit pid -> max of 10 digits, we need only "/proc/xxxxxxxxxx/exe" space
|
// Assuming 32-bit pid -> max of 10 digits, we need only "/proc/xxxxxxxxxx/exe" space
|
||||||
@ -100,7 +100,7 @@ std::string Diggler::proc::getExecutablePath() {
|
|||||||
// TODO: getExecutablePath for those without procfs
|
// TODO: getExecutablePath for those without procfs
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string Diggler::proc::getExecutableDirectory() {
|
std::string diggler::proc::getExecutableDirectory() {
|
||||||
if (pathCache.executableDir.length() == 0) {
|
if (pathCache.executableDir.length() == 0) {
|
||||||
std::string filename(getExecutablePath());
|
std::string filename(getExecutablePath());
|
||||||
const size_t last_slash_idx = filename.rfind('/');
|
const size_t last_slash_idx = filename.rfind('/');
|
||||||
@ -114,7 +114,7 @@ std::string Diggler::proc::getExecutableDirectory() {
|
|||||||
return pathCache.executableDir;
|
return pathCache.executableDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Diggler::getCacheDirectory() {
|
std::string diggler::getCacheDirectory() {
|
||||||
if (pathCache.cacheDir.length() == 0) {
|
if (pathCache.cacheDir.length() == 0) {
|
||||||
const char *xdgCache = std::getenv("XDG_CACHE_HOME");
|
const char *xdgCache = std::getenv("XDG_CACHE_HOME");
|
||||||
if (xdgCache) {
|
if (xdgCache) {
|
||||||
@ -126,7 +126,7 @@ std::string Diggler::getCacheDirectory() {
|
|||||||
return pathCache.cacheDir;
|
return pathCache.cacheDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Diggler::getConfigDirectory() {
|
std::string diggler::getConfigDirectory() {
|
||||||
if (pathCache.configDir.length() == 0) {
|
if (pathCache.configDir.length() == 0) {
|
||||||
const char *xdgCache = std::getenv("XDG_CONFIG_HOME");
|
const char *xdgCache = std::getenv("XDG_CONFIG_HOME");
|
||||||
if (xdgCache) {
|
if (xdgCache) {
|
||||||
@ -148,7 +148,7 @@ std::string Diggler::getConfigDirectory() {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
std::string getAssetsDirectory() {
|
std::string getAssetsDirectory() {
|
||||||
return proc::getExecutableDirectory() + "/assets";
|
return proc::getExecutableDirectory() + "/assets";
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "platform/Math.hpp"
|
#include "platform/Math.hpp"
|
||||||
#include "platform/Types.hpp"
|
#include "platform/Types.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
namespace proc {
|
namespace proc {
|
||||||
/// @returns The executable's absolute path
|
/// @returns The executable's absolute path
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "render/gl/ProgramManager.hpp"
|
#include "render/gl/ProgramManager.hpp"
|
||||||
#include "render/gl/VBO.hpp"
|
#include "render/gl/VBO.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
Player::Renderer Player::R = {};
|
Player::Renderer Player::R = {};
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ Player::Player(Game *G) :
|
|||||||
-sz, .0f, 0.0f,
|
-sz, .0f, 0.0f,
|
||||||
sz, szH, 0.0f,
|
sz, szH, 0.0f,
|
||||||
};
|
};
|
||||||
R.vbo = std::make_unique<Render::gl::VBO>();
|
R.vbo = std::make_unique<render::gl::VBO>();
|
||||||
R.vbo->setData(coords, 6*3);
|
R.vbo->setData(coords, 6*3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
#include "network/Network.hpp"
|
#include "network/Network.hpp"
|
||||||
#include "World.hpp"
|
#include "World.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
namespace Render {
|
namespace render {
|
||||||
class PlayerRenderer;
|
class PlayerRenderer;
|
||||||
namespace gl {
|
namespace gl {
|
||||||
class Program;
|
class Program;
|
||||||
@ -29,17 +29,17 @@ using PlayerGameID = uint32;
|
|||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
protected:
|
protected:
|
||||||
friend class Render::PlayerRenderer;
|
friend class render::PlayerRenderer;
|
||||||
uintptr_t rendererData;
|
uintptr_t rendererData;
|
||||||
|
|
||||||
static struct Renderer {
|
static struct Renderer {
|
||||||
const Render::gl::Program *prog;
|
const render::gl::Program *prog;
|
||||||
GLint att_coord,
|
GLint att_coord,
|
||||||
uni_mvp,
|
uni_mvp,
|
||||||
uni_unicolor,
|
uni_unicolor,
|
||||||
uni_fogStart,
|
uni_fogStart,
|
||||||
uni_fogEnd;
|
uni_fogEnd;
|
||||||
std::unique_ptr<Render::gl::VBO> vbo;
|
std::unique_ptr<render::gl::VBO> vbo;
|
||||||
} R;
|
} R;
|
||||||
double m_lastPosTime;
|
double m_lastPosTime;
|
||||||
glm::vec3 m_predictPos;
|
glm::vec3 m_predictPos;
|
||||||
@ -60,7 +60,7 @@ public:
|
|||||||
using SessionID = uint32;
|
using SessionID = uint32;
|
||||||
SessionID sessId;
|
SessionID sessId;
|
||||||
bool isAlive;
|
bool isAlive;
|
||||||
Net::Peer *peer;
|
net::Peer *peer;
|
||||||
std::list<ChunkRef> pendingChunks;
|
std::list<ChunkRef> pendingChunks;
|
||||||
|
|
||||||
Player(Game *G = nullptr);
|
Player(Game *G = nullptr);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "Game.hpp"
|
#include "Game.hpp"
|
||||||
#include "LocalPlayer.hpp"
|
#include "LocalPlayer.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
PlayerList::PlayerList(Game *G) : G(G) {
|
PlayerList::PlayerList(Game *G) : G(G) {
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ Player* PlayerList::getByName(const std::string &name) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* PlayerList::getByPeer(const Net::Peer &peer) {
|
Player* PlayerList::getByPeer(const net::Peer &peer) {
|
||||||
for (auto it = begin();
|
for (auto it = begin();
|
||||||
it != end(); ++it) {
|
it != end(); ++it) {
|
||||||
if (*it->peer == peer) {
|
if (*it->peer == peer) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "Player.hpp"
|
#include "Player.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public:
|
|||||||
* @brief Gets a Player using its network peer object
|
* @brief Gets a Player using its network peer object
|
||||||
* @return Pointer to Player, may be nullptr if not found
|
* @return Pointer to Player, may be nullptr if not found
|
||||||
*/
|
*/
|
||||||
Player* getByPeer(const Net::Peer&);
|
Player* getByPeer(const net::Peer&);
|
||||||
|
|
||||||
Player& add();
|
Player& add();
|
||||||
void remove(const Player&);
|
void remove(const Player&);
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
using namespace Diggler::Net;
|
using namespace diggler::net;
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
using Util::Log;
|
using Util::Log;
|
||||||
using namespace Util::Logging::LogLevels;
|
using namespace Util::Logging::LogLevels;
|
||||||
@ -135,8 +135,8 @@ void Server::handleDisconnect(Peer &peer) {
|
|||||||
handlePlayerQuit(peer, QuitReason::Timeout);
|
handlePlayerQuit(peer, QuitReason::Timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::handleContentMessage(Net::InMessage &msg, Net::Peer &peer) {
|
void Server::handleContentMessage(net::InMessage &msg, net::Peer &peer) {
|
||||||
using namespace Net::MsgTypes;
|
using namespace net::MsgTypes;
|
||||||
using S = ContentSubtype;
|
using S = ContentSubtype;
|
||||||
switch (msg.getSubtype<MsgTypes::ContentSubtype>()) {
|
switch (msg.getSubtype<MsgTypes::ContentSubtype>()) {
|
||||||
case S::ModListRequest: {
|
case S::ModListRequest: {
|
||||||
@ -152,7 +152,7 @@ void Server::handleContentMessage(Net::InMessage &msg, Net::Peer &peer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Server::handleChat(InMessage &msg, Player *plr) {
|
void Server::handleChat(InMessage &msg, Player *plr) {
|
||||||
using namespace Net::MsgTypes;
|
using namespace net::MsgTypes;
|
||||||
using S = ChatSubtype;
|
using S = ChatSubtype;
|
||||||
switch (msg.getSubtype<S>()) {
|
switch (msg.getSubtype<S>()) {
|
||||||
case S::Send: {
|
case S::Send: {
|
||||||
@ -178,7 +178,7 @@ void Server::handleCommand(Player *plr, const std::string &command, const std::v
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Server::handlePlayerUpdate(InMessage &msg, Player &plr) {
|
void Server::handlePlayerUpdate(InMessage &msg, Player &plr) {
|
||||||
using namespace Net::MsgTypes;
|
using namespace net::MsgTypes;
|
||||||
using S = PlayerUpdateSubtype;
|
using S = PlayerUpdateSubtype;
|
||||||
switch (msg.getSubtype<S>()) {
|
switch (msg.getSubtype<S>()) {
|
||||||
case S::Move: {
|
case S::Move: {
|
||||||
@ -207,9 +207,9 @@ void Server::schedSendChunk(ChunkRef C, Player &P) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Server::sendChunks(const std::list<ChunkRef> &cs, Player &P) {
|
void Server::sendChunks(const std::list<ChunkRef> &cs, Player &P) {
|
||||||
using namespace Net::MsgTypes;
|
using namespace net::MsgTypes;
|
||||||
ChunkTransferResponse ctr;
|
ChunkTransferResponse ctr;
|
||||||
std::vector<IO::OutMemoryStream> chunkBufs(cs.size());
|
std::vector<io::OutMemoryStream> chunkBufs(cs.size());
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (const ChunkRef &cr : cs) {
|
for (const ChunkRef &cr : cs) {
|
||||||
ctr.chunks.emplace_back();
|
ctr.chunks.emplace_back();
|
||||||
@ -228,7 +228,7 @@ void Server::sendChunks(const std::list<ChunkRef> &cs, Player &P) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Server::handlePlayerChunkRequest(InMessage &msg, Player &plr) {
|
void Server::handlePlayerChunkRequest(InMessage &msg, Player &plr) {
|
||||||
using namespace Net::MsgTypes;
|
using namespace net::MsgTypes;
|
||||||
using S = ChunkTransferSubtype;
|
using S = ChunkTransferSubtype;
|
||||||
switch (msg.getSubtype<S>()) {
|
switch (msg.getSubtype<S>()) {
|
||||||
case S::Request: {
|
case S::Request: {
|
||||||
@ -251,7 +251,7 @@ void Server::handlePlayerChunkRequest(InMessage &msg, Player &plr) {
|
|||||||
|
|
||||||
void Server::handlePlayerMapUpdate(InMessage &msg, Player &plr) {
|
void Server::handlePlayerMapUpdate(InMessage &msg, Player &plr) {
|
||||||
// TODO: distance & tool check, i.e. legitimate update
|
// TODO: distance & tool check, i.e. legitimate update
|
||||||
using namespace Net::MsgTypes;
|
using namespace net::MsgTypes;
|
||||||
using S = BlockUpdateSubtype;
|
using S = BlockUpdateSubtype;
|
||||||
constexpr auto CX = Chunk::CX, CY = Chunk::CY, CZ = Chunk::CZ;
|
constexpr auto CX = Chunk::CX, CY = Chunk::CY, CZ = Chunk::CZ;
|
||||||
switch (msg.getSubtype<S>()) {
|
switch (msg.getSubtype<S>()) {
|
||||||
@ -285,7 +285,7 @@ void Server::handlePlayerMapUpdate(InMessage &msg, Player &plr) {
|
|||||||
ChunkRef c = w->getChunkAtCoords(bub.pos);
|
ChunkRef c = w->getChunkAtCoords(bub.pos);
|
||||||
if (c) {
|
if (c) {
|
||||||
c->setBlock(rmod(bub.pos.x, CX), rmod(bub.pos.y, CY), rmod(bub.pos.z, CZ),
|
c->setBlock(rmod(bub.pos.x, CX), rmod(bub.pos.y, CY), rmod(bub.pos.z, CZ),
|
||||||
Content::BlockAirId, 0);
|
content::BlockAirId, 0);
|
||||||
if (!c->CH.empty()) {
|
if (!c->CH.empty()) {
|
||||||
BlockUpdateNotify bun;
|
BlockUpdateNotify bun;
|
||||||
c->CH.flush(bun);
|
c->CH.flush(bun);
|
||||||
@ -300,7 +300,7 @@ void Server::handlePlayerMapUpdate(InMessage &msg, Player &plr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Server::handlePlayerDeath(InMessage &msg, Player &plr) {
|
void Server::handlePlayerDeath(InMessage &msg, Player &plr) {
|
||||||
using namespace Net::MsgTypes;
|
using namespace net::MsgTypes;
|
||||||
PlayerUpdateDie pud;
|
PlayerUpdateDie pud;
|
||||||
pud.readFromMsg(msg);
|
pud.readFromMsg(msg);
|
||||||
pud.plrSessId = plr.sessId;
|
pud.plrSessId = plr.sessId;
|
||||||
@ -340,7 +340,7 @@ Server::Server(Game &G, uint16 port) : G(G) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
H.create(port);
|
H.create(port);
|
||||||
} catch (Net::Exception &e) {
|
} catch (net::Exception &e) {
|
||||||
Log(Error, TAG) << "Couldn't open port " << port << " for listening\n" <<
|
Log(Error, TAG) << "Couldn't open port " << port << " for listening\n" <<
|
||||||
"Make sure no other server instance is running";
|
"Make sure no other server instance is running";
|
||||||
if (port <= 1024) {
|
if (port <= 1024) {
|
||||||
@ -392,7 +392,7 @@ void Server::chunkUpdater(WorldRef WR, bool &continueUpdate) {
|
|||||||
for (auto pair : W) {
|
for (auto pair : W) {
|
||||||
if ((c = pair.second.lock()) && !c->CH.empty()) {
|
if ((c = pair.second.lock()) && !c->CH.empty()) {
|
||||||
// TODO: view range
|
// TODO: view range
|
||||||
Net::MsgTypes::BlockUpdateNotify bun;
|
net::MsgTypes::BlockUpdateNotify bun;
|
||||||
c->CH.flush(bun);
|
c->CH.flush(bun);
|
||||||
OutMessage msg;
|
OutMessage msg;
|
||||||
bun.writeToMsg(msg);
|
bun.writeToMsg(msg);
|
||||||
@ -481,7 +481,7 @@ bool Server::isPlayerOnline(const std::string &playername) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::kick(Player &p, Net::QuitReason r, const std::string &message) {
|
void Server::kick(Player &p, net::QuitReason r, const std::string &message) {
|
||||||
OutMessage msg(MessageType::PlayerQuit, r);
|
OutMessage msg(MessageType::PlayerQuit, r);
|
||||||
msg.writeU32(p.sessId);
|
msg.writeU32(p.sessId);
|
||||||
msg.writeString(message);
|
msg.writeString(message);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
|
|
||||||
@ -21,18 +21,18 @@ private:
|
|||||||
|
|
||||||
void handleCommand(Player*, const std::string &command, const std::vector<std::string> &args);
|
void handleCommand(Player*, const std::string &command, const std::vector<std::string> &args);
|
||||||
|
|
||||||
void handlePlayerJoin(Net::InMessage&, Net::Peer&);
|
void handlePlayerJoin(net::InMessage&, net::Peer&);
|
||||||
void handlePlayerQuit(Net::Peer&, Net::QuitReason reason = Net::QuitReason::Quit);
|
void handlePlayerQuit(net::Peer&, net::QuitReason reason = net::QuitReason::Quit);
|
||||||
void handleDisconnect(Net::Peer&);
|
void handleDisconnect(net::Peer&);
|
||||||
|
|
||||||
void handleContentMessage(Net::InMessage&, Net::Peer&);
|
void handleContentMessage(net::InMessage&, net::Peer&);
|
||||||
|
|
||||||
void handleChat(Net::InMessage&, Player*);
|
void handleChat(net::InMessage&, Player*);
|
||||||
|
|
||||||
void handlePlayerUpdate(Net::InMessage&, Player&);
|
void handlePlayerUpdate(net::InMessage&, Player&);
|
||||||
void handlePlayerDeath(Net::InMessage&, Player&);
|
void handlePlayerDeath(net::InMessage&, Player&);
|
||||||
void handlePlayerChunkRequest(Net::InMessage&, Player&);
|
void handlePlayerChunkRequest(net::InMessage&, Player&);
|
||||||
void handlePlayerMapUpdate(Net::InMessage&, Player&);
|
void handlePlayerMapUpdate(net::InMessage&, Player&);
|
||||||
|
|
||||||
void schedSendChunk(ChunkRef, Player&);
|
void schedSendChunk(ChunkRef, Player&);
|
||||||
void sendChunks(const std::list<ChunkRef>&, Player&);
|
void sendChunks(const std::list<ChunkRef>&, Player&);
|
||||||
@ -40,7 +40,7 @@ private:
|
|||||||
void chunkUpdater(WorldRef WR, bool &continueUpdate);
|
void chunkUpdater(WorldRef WR, bool &continueUpdate);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Net::Host H;
|
net::Host H;
|
||||||
|
|
||||||
Server(Game &G, uint16 port);
|
Server(Game &G, uint16 port);
|
||||||
~Server();
|
~Server();
|
||||||
@ -53,9 +53,9 @@ public:
|
|||||||
bool isPlayerOnline(const std::string &playername) const;
|
bool isPlayerOnline(const std::string &playername) const;
|
||||||
bool isIPOnline(const std::string &ip) const;
|
bool isIPOnline(const std::string &ip) const;
|
||||||
Player* getPlayerBySessId(uint32 id);
|
Player* getPlayerBySessId(uint32 id);
|
||||||
Player* getPlayerByPeer(const Net::Peer &peer);
|
Player* getPlayerByPeer(const net::Peer &peer);
|
||||||
Player* getPlayerByName(const std::string &name);
|
Player* getPlayerByName(const std::string &name);
|
||||||
void kick(Player &p, Net::QuitReason r = Net::QuitReason::Kicked, const std::string& message = "");
|
void kick(Player &p, net::QuitReason r = net::QuitReason::Kicked, const std::string& message = "");
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
#include "render/gl/ProgramManager.hpp"
|
#include "render/gl/ProgramManager.hpp"
|
||||||
#include "Texture.hpp"
|
#include "Texture.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
const Render::gl::Program *Skybox::RenderProgram = nullptr;
|
const render::gl::Program *Skybox::RenderProgram = nullptr;
|
||||||
GLint Skybox::RenderProgram_attrib_texcoord = -1;
|
GLint Skybox::RenderProgram_attrib_texcoord = -1;
|
||||||
GLint Skybox::RenderProgram_attrib_coord = -1;
|
GLint Skybox::RenderProgram_attrib_coord = -1;
|
||||||
GLint Skybox::RenderProgram_uni_mvp = -1;
|
GLint Skybox::RenderProgram_uni_mvp = -1;
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
#include "render/gl/VBO.hpp"
|
#include "render/gl/VBO.hpp"
|
||||||
#include "Game.hpp"
|
#include "Game.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
namespace Render {
|
namespace render {
|
||||||
namespace gl {
|
namespace gl {
|
||||||
class Program;
|
class Program;
|
||||||
}
|
}
|
||||||
@ -18,9 +18,9 @@ class Texture;
|
|||||||
|
|
||||||
class Skybox {
|
class Skybox {
|
||||||
private:
|
private:
|
||||||
static const Render::gl::Program *RenderProgram;
|
static const render::gl::Program *RenderProgram;
|
||||||
static GLint RenderProgram_attrib_coord, RenderProgram_attrib_texcoord, RenderProgram_uni_mvp;
|
static GLint RenderProgram_attrib_coord, RenderProgram_attrib_texcoord, RenderProgram_uni_mvp;
|
||||||
Render::gl::VBO m_vbo;
|
render::gl::VBO m_vbo;
|
||||||
Texture *m_top, *m_w, *m_e, *m_n, *m_s, *m_bottom;
|
Texture *m_top, *m_w, *m_e, *m_n, *m_s, *m_bottom;
|
||||||
Game *G;
|
Game *G;
|
||||||
struct Coord { int8 x, y, z, u, v; };
|
struct Coord { int8 x, y, z, u, v; };
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "Sound.hpp"
|
#include "Sound.hpp"
|
||||||
#include "Platform.hpp"
|
#include "Platform.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
Sound::Sound(const SoundBuffer *buffer) : buffer(buffer), createdRelative(true) {
|
Sound::Sound(const SoundBuffer *buffer) : buffer(buffer), createdRelative(true) {
|
||||||
alGenSources(1, &id);
|
alGenSources(1, &id);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "SoundBuffer.hpp"
|
#include "SoundBuffer.hpp"
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Sound {
|
class Sound {
|
||||||
private:
|
private:
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "platform/Types.hpp"
|
#include "platform/Types.hpp"
|
||||||
#include "util/Log.hpp"
|
#include "util/Log.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
using Util::Log;
|
using Util::Log;
|
||||||
using namespace Util::Logging::LogLevels;
|
using namespace Util::Logging::LogLevels;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <AL/al.h>
|
#include <AL/al.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class SoundBuffer {
|
class SoundBuffer {
|
||||||
private:
|
private:
|
||||||
|
@ -3,13 +3,16 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "State.hpp"
|
#include "states/State.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class StateMachine {
|
class StateMachine {
|
||||||
public:
|
public:
|
||||||
virtual void setNextState(std::unique_ptr<State> &&next) = 0;
|
virtual ~StateMachine() {}
|
||||||
|
|
||||||
|
virtual states::State& state() const = 0;
|
||||||
|
virtual void setNextState(std::unique_ptr<states::State> &&next) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "Texture.hpp"
|
#include "Texture.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
uint Texture::requiredBufferSize() {
|
uint Texture::requiredBufferSize() {
|
||||||
uint texelSize;
|
uint texelSize;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
// TODO: remove me
|
// TODO: remove me
|
||||||
#include "render/gl/OpenGL.hpp"
|
#include "render/gl/OpenGL.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Texture {
|
class Texture {
|
||||||
public:
|
public:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "Universe.hpp"
|
#include "Universe.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
Universe::Universe(Game *G, bool remote) :
|
Universe::Universe(Game *G, bool remote) :
|
||||||
G(G), isRemote(remote) {
|
G(G), isRemote(remote) {
|
||||||
@ -33,7 +33,7 @@ WorldRef Universe::createWorld(WorldId id) {
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Universe::recv(Net::InMessage &msg) {
|
void Universe::recv(net::InMessage &msg) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include "World.hpp"
|
#include "World.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
using UniverseWorldMap = std::map<WorldId, WorldWeakRef>;
|
using UniverseWorldMap = std::map<WorldId, WorldWeakRef>;
|
||||||
|
|
||||||
@ -47,10 +47,10 @@ public:
|
|||||||
|
|
||||||
/* ============ Serialization ============ */
|
/* ============ Serialization ============ */
|
||||||
|
|
||||||
void write(IO::OutStream&) const;
|
void write(io::OutStream&) const;
|
||||||
void read(IO::InStream&);
|
void read(io::InStream&);
|
||||||
|
|
||||||
void recv(Net::InMessage&);
|
void recv(net::InMessage&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef DIGGLER_VERSION_INFO_HPP
|
#ifndef DIGGLER_VERSION_INFO_HPP
|
||||||
#define DIGGLER_VERSION_INFO_HPP
|
#define DIGGLER_VERSION_INFO_HPP
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
const char* VersionString = "0.1.0";
|
const char* VersionString = "0.1.0";
|
||||||
int VersionMajor = 0;
|
int VersionMajor = 0;
|
||||||
int VersionMinor = 1;
|
int VersionMinor = 1;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "Universe.hpp"
|
#include "Universe.hpp"
|
||||||
#include "util/Log.hpp"
|
#include "util/Log.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
using Util::Log;
|
using Util::Log;
|
||||||
using namespace Util::Logging::LogLevels;
|
using namespace Util::Logging::LogLevels;
|
||||||
@ -156,7 +156,7 @@ BlockId World::getBlockId(int x, int y, int z) {
|
|||||||
return cr->getBlockId(rmod(x, CX), rmod(y, CY), rmod(z, CZ));
|
return cr->getBlockId(rmod(x, CX), rmod(y, CY), rmod(z, CZ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Content::BlockIgnoreId;
|
return content::BlockIgnoreId;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockData World::getBlockData(int x, int y, int z) {
|
BlockData World::getBlockData(int x, int y, int z) {
|
||||||
@ -191,7 +191,7 @@ bool World::raytrace(glm::vec3 pos, glm::vec3 dir, float range, glm::ivec3 *poin
|
|||||||
do {
|
do {
|
||||||
BlockId testBlock = getBlockId(xPos, yPos, zPos);
|
BlockId testBlock = getBlockId(xPos, yPos, zPos);
|
||||||
/// @todo Actual block non-solidity (cursorwise) check
|
/// @todo Actual block non-solidity (cursorwise) check
|
||||||
if (testBlock != Content::BlockAirId) {
|
if (testBlock != content::BlockAirId) {
|
||||||
if (pointed)
|
if (pointed)
|
||||||
*pointed = glm::ivec3(xPos, yPos, zPos);
|
*pointed = glm::ivec3(xPos, yPos, zPos);
|
||||||
if (facing)
|
if (facing)
|
||||||
@ -308,7 +308,7 @@ void World::refresh() {
|
|||||||
c->markAsDirty();
|
c->markAsDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::write(IO::OutStream &msg) const {
|
void World::write(io::OutStream &msg) const {
|
||||||
const void *chunkData = nullptr;
|
const void *chunkData = nullptr;
|
||||||
const uint dataSize = Chunk::AllocaSize;
|
const uint dataSize = Chunk::AllocaSize;
|
||||||
uint compressedSize;
|
uint compressedSize;
|
||||||
@ -336,7 +336,7 @@ void World::write(IO::OutStream &msg) const {
|
|||||||
delete[] compressed;
|
delete[] compressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::read(IO::InStream &M) {
|
void World::read(io::InStream &M) {
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
uint size = M.readU16();
|
uint size = M.readU16();
|
||||||
for (uint n=0; n < size; ++n) {
|
for (uint n=0; n < size; ++n) {
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
#include "network/Network.hpp"
|
#include "network/Network.hpp"
|
||||||
#include "Particles.hpp"
|
#include "Particles.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
namespace Net {
|
namespace net {
|
||||||
class InMessage;
|
class InMessage;
|
||||||
class OutMessage;
|
class OutMessage;
|
||||||
}
|
}
|
||||||
@ -165,10 +165,10 @@ public:
|
|||||||
|
|
||||||
/* ============ Serialization ============ */
|
/* ============ Serialization ============ */
|
||||||
|
|
||||||
void write(IO::OutStream&) const;
|
void write(io::OutStream&) const;
|
||||||
void read(IO::InStream&);
|
void read(io::InStream&);
|
||||||
void send(Net::OutMessage&) const;
|
void send(net::OutMessage&) const;
|
||||||
void recv(Net::InMessage&);
|
void recv(net::InMessage&);
|
||||||
};
|
};
|
||||||
|
|
||||||
using WorldRef = std::shared_ptr<World>;
|
using WorldRef = std::shared_ptr<World>;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <glm/vec3.hpp>
|
#include <glm/vec3.hpp>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class World;
|
class World;
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#include "AssetManager.hpp"
|
#include "AssetManager.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
Asset::Asset(const std::shared_ptr<AssetContentMetadata> &acm) :
|
Asset::Asset(const std::shared_ptr<AssetContentMetadata> &acm) :
|
||||||
m_contentMetadata(acm) {
|
m_contentMetadata(acm) {
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
#include "../crypto/SHA256.hpp"
|
#include "../crypto/SHA256.hpp"
|
||||||
#include "AssetContentMetadata.hpp"
|
#include "AssetContentMetadata.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
class AssetManager;
|
class AssetManager;
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#include <goodform/variant.hpp>
|
#include <goodform/variant.hpp>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
AssetContentMetadata::AssetContentMetadata(AssetManager &am) :
|
AssetContentMetadata::AssetContentMetadata(AssetManager &am) :
|
||||||
m_assetManager(am) {
|
m_assetManager(am) {
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
#include "../crypto/SHA256.hpp"
|
#include "../crypto/SHA256.hpp"
|
||||||
#include "../platform/Types.hpp"
|
#include "../platform/Types.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
class AssetManager;
|
class AssetManager;
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include "../Game.hpp"
|
#include "../Game.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
AssetManager::AssetManager(Game *G) :
|
AssetManager::AssetManager(Game *G) :
|
||||||
G(G) {
|
G(G) {
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
#include "Asset.hpp"
|
#include "Asset.hpp"
|
||||||
#include "Mod.hpp"
|
#include "Mod.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
|
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
class AssetManager final {
|
class AssetManager final {
|
||||||
private:
|
private:
|
||||||
|
@ -8,15 +8,15 @@
|
|||||||
#include "../util/TexturePacker.hpp"
|
#include "../util/TexturePacker.hpp"
|
||||||
//#include "../AABB.hpp"
|
//#include "../AABB.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
class BlockDef : public ObjectDef {
|
class BlockDef : public ObjectDef {
|
||||||
public:
|
public:
|
||||||
struct Appearance {
|
struct Appearance {
|
||||||
Variability variability;
|
Variability variability;
|
||||||
struct Texture {
|
struct Texture {
|
||||||
Diggler::Texture *tex;
|
diggler::Texture *tex;
|
||||||
Util::TexturePacker::Coord coord;
|
Util::TexturePacker::Coord coord;
|
||||||
std::vector<Util::TexturePacker::Coord> divCoords;
|
std::vector<Util::TexturePacker::Coord> divCoords;
|
||||||
struct Repeat {
|
struct Repeat {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
using BlockId = uint16;
|
using BlockId = uint16;
|
||||||
using BlockData = uint16;
|
using BlockData = uint16;
|
||||||
@ -36,7 +36,7 @@ struct LightData {
|
|||||||
static_assert(sizeof(LightData) == 2, "LightData has extra padding");
|
static_assert(sizeof(LightData) == 2, "LightData has extra padding");
|
||||||
static_assert(std::is_pod<LightData>::value, "LightData is not POD");
|
static_assert(std::is_pod<LightData>::value, "LightData is not POD");
|
||||||
|
|
||||||
namespace Content {
|
namespace content {
|
||||||
const BlockId BlockAirId = 0;
|
const BlockId BlockAirId = 0;
|
||||||
const BlockId BlockIgnoreId = std::numeric_limits<BlockData>::max();
|
const BlockId BlockIgnoreId = std::numeric_limits<BlockData>::max();
|
||||||
const BlockId BlockUnknownId = 1;
|
const BlockId BlockUnknownId = 1;
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
#include "../Platform.hpp"
|
#include "../Platform.hpp"
|
||||||
#include "../crypto/Sign.hpp"
|
#include "../crypto/Sign.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
union ModId {
|
union ModId {
|
||||||
struct Parts {
|
struct Parts {
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include "../Game.hpp"
|
#include "../Game.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
ModManager::ModManager(Game *G) :
|
ModManager::ModManager(Game *G) :
|
||||||
G(G) {
|
G(G) {
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
#include "Mod.hpp"
|
#include "Mod.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
|
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
class ModManager final {
|
class ModManager final {
|
||||||
private:
|
private:
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
#define DIGGLER_CONTENT_OBJECT_DEF_HPP
|
#define DIGGLER_CONTENT_OBJECT_DEF_HPP
|
||||||
#include "../Platform.hpp"
|
#include "../Platform.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
class ObjectDef {
|
class ObjectDef {
|
||||||
public:
|
public:
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#define PRINT_BLOCK_REGISTRATIONS 1
|
#define PRINT_BLOCK_REGISTRATIONS 1
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
using Util::Log;
|
using Util::Log;
|
||||||
using namespace Util::Logging::LogLevels;
|
using namespace Util::Logging::LogLevels;
|
||||||
@ -82,7 +82,7 @@ static const DefBlocksInfo DefBlocksInfos[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool Registry::isTransparent(BlockId id) const {
|
bool Registry::isTransparent(BlockId id) const {
|
||||||
if (id == Content::BlockAirId)
|
if (id == content::BlockAirId)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
// TODO return getBlockDef(id).isTransparent;
|
// TODO return getBlockDef(id).isTransparent;
|
||||||
@ -98,7 +98,7 @@ bool Registry::isFaceVisible(BlockId id1, BlockId id2) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Registry::canEntityGoThrough(BlockId id/* , Entity& ent*/) const {
|
bool Registry::canEntityGoThrough(BlockId id/* , Entity& ent*/) const {
|
||||||
if (id == Content::BlockAirId)
|
if (id == content::BlockAirId)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
/*return (t == BlockType::TransRed && team == Player::Team::Red) ||
|
/*return (t == BlockType::TransRed && team == Player::Team::Red) ||
|
||||||
@ -110,13 +110,13 @@ static Coord unk1, unk2, unk3, unk4, unk5, unk6, unk7, unk8;
|
|||||||
#define AddTex(b, t) Coord b = m_texturePacker->add(getAssetPath("blocks", t));
|
#define AddTex(b, t) Coord b = m_texturePacker->add(getAssetPath("blocks", t));
|
||||||
Registry::Registry(Game &G) :
|
Registry::Registry(Game &G) :
|
||||||
m_atlas(nullptr),
|
m_atlas(nullptr),
|
||||||
m_nextMaxBlockId(Content::BlockUnknownId + 1) {
|
m_nextMaxBlockId(content::BlockUnknownId + 1) {
|
||||||
{ Registry::BlockRegistration br(registerBlock(Content::BlockAirId, "air"));
|
{ Registry::BlockRegistration br(registerBlock(content::BlockAirId, "air"));
|
||||||
br.def.appearance.look.type = BlockDef::Appearance::Look::Type::Hidden;
|
br.def.appearance.look.type = BlockDef::Appearance::Look::Type::Hidden;
|
||||||
br.def.phys.hasCollision = false;
|
br.def.phys.hasCollision = false;
|
||||||
br.commit();
|
br.commit();
|
||||||
}
|
}
|
||||||
{ Registry::BlockRegistration br(registerBlock(Content::BlockUnknownId, "unknown"));
|
{ Registry::BlockRegistration br(registerBlock(content::BlockUnknownId, "unknown"));
|
||||||
br.def.appearance.look.type = BlockDef::Appearance::Look::Type::Hidden;
|
br.def.appearance.look.type = BlockDef::Appearance::Look::Type::Hidden;
|
||||||
br.def.phys.hasCollision = true;
|
br.def.phys.hasCollision = true;
|
||||||
br.commit();
|
br.commit();
|
||||||
@ -158,7 +158,7 @@ Util::TexturePacker::Coord Registry::addTexture(const std::string &texName,
|
|||||||
|
|
||||||
const Util::TexturePacker::Coord* Registry::blockTexCoord(BlockId t, FaceDirection d,
|
const Util::TexturePacker::Coord* Registry::blockTexCoord(BlockId t, FaceDirection d,
|
||||||
const glm::ivec3 &pos) const {
|
const glm::ivec3 &pos) const {
|
||||||
if (t == Content::BlockUnknownId) {
|
if (t == content::BlockUnknownId) {
|
||||||
const Coord *unk[] = {
|
const Coord *unk[] = {
|
||||||
&unk1, &unk2, &unk3, &unk4, &unk5, &unk6, &unk7, &unk8
|
&unk1, &unk2, &unk3, &unk4, &unk5, &unk6, &unk7, &unk8
|
||||||
};
|
};
|
||||||
@ -226,7 +226,7 @@ Registry::BlockRegistration Registry::registerBlock(BlockId id, const char *name
|
|||||||
}
|
}
|
||||||
|
|
||||||
Registry::BlockRegistration Registry::registerBlock(const char *name) {
|
Registry::BlockRegistration Registry::registerBlock(const char *name) {
|
||||||
BlockId id = Content::BlockUnknownId;
|
BlockId id = content::BlockUnknownId;
|
||||||
if (m_freedBlockIds.empty()) {
|
if (m_freedBlockIds.empty()) {
|
||||||
id = m_nextMaxBlockId;
|
id = m_nextMaxBlockId;
|
||||||
++m_nextMaxBlockId;
|
++m_nextMaxBlockId;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "../Texture.hpp"
|
#include "../Texture.hpp"
|
||||||
#include "../util/TexturePacker.hpp"
|
#include "../util/TexturePacker.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
enum class FaceDirection : uint8_t {
|
enum class FaceDirection : uint8_t {
|
||||||
XInc = 0,
|
XInc = 0,
|
||||||
@ -24,7 +24,7 @@ enum class FaceDirection : uint8_t {
|
|||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
|
|
||||||
namespace Content {
|
namespace content {
|
||||||
|
|
||||||
class Registry {
|
class Registry {
|
||||||
public:
|
public:
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#include "../../../../util/StringUtil.hpp"
|
#include "../../../../util/StringUtil.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Font {
|
namespace Font {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
namespace BDF {
|
namespace BDF {
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "../../platform/FourCC.hpp"
|
#include "../../platform/FourCC.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
|
|
||||||
using Format = FourCC;
|
using Format = FourCC;
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
#include "formats/png/PNGLoader.hpp"
|
#include "formats/png/PNGLoader.hpp"
|
||||||
#include "formats/ImageLoader.hpp"
|
#include "formats/ImageLoader.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
|
|
||||||
ImageLoader::Loading::Loading(std::unique_ptr<IO::InStream> &&stream, const LoadParams &lp) :
|
ImageLoader::Loading::Loading(std::unique_ptr<io::InStream> &&stream, const LoadParams &lp) :
|
||||||
stream(std::move(stream)),
|
stream(std::move(stream)),
|
||||||
loadParams(lp),
|
loadParams(lp),
|
||||||
w(0),
|
w(0),
|
||||||
@ -40,7 +40,7 @@ std::shared_ptr<ImageLoader::Loading> ImageLoader::load(Format format, const std
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ImageLoader::Loading> ImageLoader::load(Format format,
|
std::shared_ptr<ImageLoader::Loading> ImageLoader::load(Format format,
|
||||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) {
|
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) {
|
||||||
return getFormatLoader(format)->load(format, std::move(stream), pixFormat, lp);
|
return getFormatLoader(format)->load(format, std::move(stream), pixFormat, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
#include "../../PixelFormat.hpp"
|
#include "../../PixelFormat.hpp"
|
||||||
#include "ImageFormat.hpp"
|
#include "ImageFormat.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
|
|
||||||
class ImageLoader final {
|
class ImageLoader final {
|
||||||
@ -60,12 +60,12 @@ public:
|
|||||||
|
|
||||||
class Loading {
|
class Loading {
|
||||||
protected:
|
protected:
|
||||||
Loading(std::unique_ptr<IO::InStream>&&, const LoadParams&);
|
Loading(std::unique_ptr<io::InStream>&&, const LoadParams&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~Loading();
|
virtual ~Loading();
|
||||||
|
|
||||||
std::unique_ptr<IO::InStream> stream;
|
std::unique_ptr<io::InStream> stream;
|
||||||
LoadParams loadParams;
|
LoadParams loadParams;
|
||||||
uint w, h;
|
uint w, h;
|
||||||
byte *pixels;
|
byte *pixels;
|
||||||
@ -74,7 +74,7 @@ public:
|
|||||||
static std::shared_ptr<Loading> load(Format, const std::string &path, PixelFormat pixFormat,
|
static std::shared_ptr<Loading> load(Format, const std::string &path, PixelFormat pixFormat,
|
||||||
const LoadParams&);
|
const LoadParams&);
|
||||||
|
|
||||||
static std::shared_ptr<Loading> load(Format, std::unique_ptr<IO::InStream> &&stream,
|
static std::shared_ptr<Loading> load(Format, std::unique_ptr<io::InStream> &&stream,
|
||||||
PixelFormat pixFormat, const LoadParams&);
|
PixelFormat pixFormat, const LoadParams&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "ImageLoader.hpp"
|
#include "ImageLoader.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include "../../../PixelFormat.hpp"
|
#include "../../../PixelFormat.hpp"
|
||||||
#include "../ImageLoader.hpp"
|
#include "../ImageLoader.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ public:
|
|||||||
virtual std::shared_ptr<Loading> load(Format, const std::string &path, PixelFormat pixFormat,
|
virtual std::shared_ptr<Loading> load(Format, const std::string &path, PixelFormat pixFormat,
|
||||||
const LoadParams&) const = 0;
|
const LoadParams&) const = 0;
|
||||||
|
|
||||||
virtual std::shared_ptr<Loading> load(Format, std::unique_ptr<IO::InStream> &&stream,
|
virtual std::shared_ptr<Loading> load(Format, std::unique_ptr<io::InStream> &&stream,
|
||||||
PixelFormat pixFormat, const LoadParams&) const = 0;
|
PixelFormat pixFormat, const LoadParams&) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,30 +4,30 @@
|
|||||||
|
|
||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
|
|
||||||
static int stream_read(void *user, char *data, int size) {
|
static int stream_read(void *user, char *data, int size) {
|
||||||
IO::InStream &stream = *reinterpret_cast<IO::InStream*>(user);
|
io::InStream &stream = *reinterpret_cast<io::InStream*>(user);
|
||||||
stream.readData(data, size);
|
stream.readData(data, size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stream_skip(void *user, int n) {
|
static void stream_skip(void *user, int n) {
|
||||||
IO::InStream &stream = *reinterpret_cast<IO::InStream*>(user);
|
io::InStream &stream = *reinterpret_cast<io::InStream*>(user);
|
||||||
stream.skip(n);
|
stream.skip(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stream_eof(void *user) {
|
static int stream_eof(void *user) {
|
||||||
IO::InStream &stream = *reinterpret_cast<IO::InStream*>(user);
|
io::InStream &stream = *reinterpret_cast<io::InStream*>(user);
|
||||||
return stream.eos();
|
return stream.eos();
|
||||||
}
|
}
|
||||||
|
|
||||||
class STBILoading final : public STBImageLoader::Loading {
|
class STBILoading final : public STBImageLoader::Loading {
|
||||||
public:
|
public:
|
||||||
STBILoading(std::unique_ptr<IO::InStream> &&stream, const ImageLoader::LoadParams &lp) :
|
STBILoading(std::unique_ptr<io::InStream> &&stream, const ImageLoader::LoadParams &lp) :
|
||||||
Loading(std::move(stream), lp) {
|
Loading(std::move(stream), lp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ STBILoading::~STBILoading() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<STBImageLoader::Loading> STBImageLoader::load(Format format,
|
std::shared_ptr<STBImageLoader::Loading> STBImageLoader::load(Format format,
|
||||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||||
auto loading = std::make_shared<STBILoading>(std::move(stream), lp);
|
auto loading = std::make_shared<STBILoading>(std::move(stream), lp);
|
||||||
loading->thread = std::thread([pixFormat, loading]() {
|
loading->thread = std::thread([pixFormat, loading]() {
|
||||||
stbi_io_callbacks cbs;
|
stbi_io_callbacks cbs;
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
#include "../../../io/FileStream.hpp"
|
#include "../../../io/FileStream.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
|
|
||||||
@ -17,10 +17,10 @@ class STBImageLoader final : public ImageLoader {
|
|||||||
public:
|
public:
|
||||||
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
||||||
const LoadParams &lp) const override {
|
const LoadParams &lp) const override {
|
||||||
return load(format, std::make_unique<IO::InFileStream>(path), pixFormat, lp);
|
return load(format, std::make_unique<io::InFileStream>(path), pixFormat, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Loading> load(Format, std::unique_ptr<IO::InStream> &&stream, PixelFormat format,
|
std::shared_ptr<Loading> load(Format, std::unique_ptr<io::InStream> &&stream, PixelFormat format,
|
||||||
const LoadParams&) const override;
|
const LoadParams&) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#include "FLIFLoader.hpp"
|
#include "FLIFLoader.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
namespace FLIF {
|
namespace FLIF {
|
||||||
|
|
||||||
std::shared_ptr<FLIFLoader::Loading> FLIFLoader::load(Format format,
|
std::shared_ptr<FLIFLoader::Loading> FLIFLoader::load(Format format,
|
||||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
#include "../../../../io/FileStream.hpp"
|
#include "../../../../io/FileStream.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
namespace FLIF {
|
namespace FLIF {
|
||||||
@ -15,10 +15,10 @@ class FLIFLoader final : public ImageLoader {
|
|||||||
public:
|
public:
|
||||||
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
||||||
const LoadParams &lp) const override {
|
const LoadParams &lp) const override {
|
||||||
return load(format, std::make_unique<IO::InFileStream>(path), pixFormat, lp);
|
return load(format, std::make_unique<io::InFileStream>(path), pixFormat, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Loading> load(Format, std::unique_ptr<IO::InStream> &&stream,
|
std::shared_ptr<Loading> load(Format, std::unique_ptr<io::InStream> &&stream,
|
||||||
PixelFormat pixFormat, const LoadParams&) const override;
|
PixelFormat pixFormat, const LoadParams&) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "JPEGLoader.hpp"
|
#include "JPEGLoader.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
namespace JPEG {
|
namespace JPEG {
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
#include "../../../../io/FileStream.hpp"
|
#include "../../../../io/FileStream.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
namespace JPEG {
|
namespace JPEG {
|
||||||
@ -15,10 +15,10 @@ class JPEGLoader final : public ImageLoader {
|
|||||||
public:
|
public:
|
||||||
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
||||||
const LoadParams &lp) const override {
|
const LoadParams &lp) const override {
|
||||||
return load(format, std::make_unique<IO::InFileStream>(path), pixFormat, lp);
|
return load(format, std::make_unique<io::InFileStream>(path), pixFormat, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Loading> load(Format, std::unique_ptr<IO::InStream> &&stream,
|
std::shared_ptr<Loading> load(Format, std::unique_ptr<io::InStream> &&stream,
|
||||||
PixelFormat pixFormat, const LoadParams&) const override;
|
PixelFormat pixFormat, const LoadParams&) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
#include "../STBImageLoader.hpp"
|
#include "../STBImageLoader.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
namespace JPEG {
|
namespace JPEG {
|
||||||
|
|
||||||
std::shared_ptr<JPEGLoader::Loading> JPEGLoader::load(Format format,
|
std::shared_ptr<JPEGLoader::Loading> JPEGLoader::load(Format format,
|
||||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||||
return STBImageLoader().load(format, std::move(stream), pixFormat, lp);
|
return STBImageLoader().load(format, std::move(stream), pixFormat, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "PNGLoader.hpp"
|
#include "PNGLoader.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
namespace PNG {
|
namespace PNG {
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
#include "../../../../io/FileStream.hpp"
|
#include "../../../../io/FileStream.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
namespace PNG {
|
namespace PNG {
|
||||||
@ -15,10 +15,10 @@ class PNGLoader final : public ImageLoader {
|
|||||||
public:
|
public:
|
||||||
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
std::shared_ptr<Loading> load(Format format, const std::string &path, PixelFormat pixFormat,
|
||||||
const LoadParams &lp) const override {
|
const LoadParams &lp) const override {
|
||||||
return load(format, std::make_unique<IO::InFileStream>(path), pixFormat, lp);
|
return load(format, std::make_unique<io::InFileStream>(path), pixFormat, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Loading> load(Format format, std::unique_ptr<IO::InStream> &&stream,
|
std::shared_ptr<Loading> load(Format format, std::unique_ptr<io::InStream> &&stream,
|
||||||
PixelFormat pixFormat, const LoadParams&) const override;
|
PixelFormat pixFormat, const LoadParams&) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
#include "../STBImageLoader.hpp"
|
#include "../STBImageLoader.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Image {
|
namespace Image {
|
||||||
namespace Formats {
|
namespace Formats {
|
||||||
namespace PNG {
|
namespace PNG {
|
||||||
|
|
||||||
std::shared_ptr<PNGLoader::Loading> PNGLoader::load(Format format,
|
std::shared_ptr<PNGLoader::Loading> PNGLoader::load(Format format,
|
||||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat, const LoadParams &lp) const {
|
||||||
return STBImageLoader().load(format, std::move(stream), pixFormat, lp);
|
return STBImageLoader().load(format, std::move(stream), pixFormat, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include "../../render/Renderer.hpp"
|
#include "../../render/Renderer.hpp"
|
||||||
#include "../../util/ColorUtil.hpp"
|
#include "../../util/ColorUtil.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Texture {
|
namespace Texture {
|
||||||
|
|
||||||
using Loading = TextureLoader::Loading;
|
using Loading = TextureLoader::Loading;
|
||||||
@ -57,7 +57,7 @@ std::shared_ptr<Loading> TextureLoader::load(Game &G, Image::Format format, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Loading> TextureLoader::load(Game &G, Image::Format format,
|
std::shared_ptr<Loading> TextureLoader::load(Game &G, Image::Format format,
|
||||||
std::unique_ptr<IO::InStream> &&stream, PixelFormat pixFormat) {
|
std::unique_ptr<io::InStream> &&stream, PixelFormat pixFormat) {
|
||||||
LoadParams lp = getLoadParams(pixFormat);
|
LoadParams lp = getLoadParams(pixFormat);
|
||||||
std::shared_ptr<Loading> l = std::make_shared<Loading>();
|
std::shared_ptr<Loading> l = std::make_shared<Loading>();
|
||||||
lp.userdata = l;
|
lp.userdata = l;
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
#include "../../Texture.hpp"
|
#include "../../Texture.hpp"
|
||||||
#include "../image/ImageLoader.hpp"
|
#include "../image/ImageLoader.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
|
|
||||||
namespace Content {
|
namespace content {
|
||||||
namespace Texture {
|
namespace Texture {
|
||||||
|
|
||||||
class TextureLoader {
|
class TextureLoader {
|
||||||
@ -20,13 +20,13 @@ public:
|
|||||||
using LoadParams = Image::ImageLoader::LoadParams;
|
using LoadParams = Image::ImageLoader::LoadParams;
|
||||||
|
|
||||||
std::shared_ptr<Image::ImageLoader::Loading> imageLoading;
|
std::shared_ptr<Image::ImageLoader::Loading> imageLoading;
|
||||||
std::shared_ptr<Diggler::Texture> texture;
|
std::shared_ptr<diggler::Texture> texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::shared_ptr<Loading> load(Game&, Image::Format, const std::string &path,
|
static std::shared_ptr<Loading> load(Game&, Image::Format, const std::string &path,
|
||||||
PixelFormat pixFormat);
|
PixelFormat pixFormat);
|
||||||
|
|
||||||
static std::shared_ptr<Loading> load(Game&, Image::Format, std::unique_ptr<IO::InStream> &&stream,
|
static std::shared_ptr<Loading> load(Game&, Image::Format, std::unique_ptr<io::InStream> &&stream,
|
||||||
PixelFormat pixFormat);
|
PixelFormat pixFormat);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Crypto {
|
namespace Crypto {
|
||||||
|
|
||||||
template<size_t B>
|
template<size_t B>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "CryptoData.hpp"
|
#include "CryptoData.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Crypto {
|
namespace Crypto {
|
||||||
namespace DiffieHellman {
|
namespace DiffieHellman {
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "CryptoData.hpp"
|
#include "CryptoData.hpp"
|
||||||
#include "../platform/Types.hpp"
|
#include "../platform/Types.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Crypto {
|
namespace Crypto {
|
||||||
namespace Random {
|
namespace Random {
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "CryptoData.hpp"
|
#include "CryptoData.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Crypto {
|
namespace Crypto {
|
||||||
|
|
||||||
struct SHA256 {
|
struct SHA256 {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "CryptoData.hpp"
|
#include "CryptoData.hpp"
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Crypto {
|
namespace Crypto {
|
||||||
namespace Sign {
|
namespace Sign {
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef DIGGLER_CRYPTO_SODIUM_HPP
|
#ifndef DIGGLER_CRYPTO_SODIUM_HPP
|
||||||
#define DIGGLER_CRYPTO_SODIUM_HPP
|
#define DIGGLER_CRYPTO_SODIUM_HPP
|
||||||
|
|
||||||
namespace Diggler {
|
namespace diggler {
|
||||||
namespace Crypto {
|
namespace Crypto {
|
||||||
|
|
||||||
class Sodium {
|
class Sodium {
|
||||||
|
45
src/gfx/Command.hpp
Normal file
45
src/gfx/Command.hpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#ifndef DIGGLER_GFX_COMMAND_HPP
|
||||||
|
#define DIGGLER_GFX_COMMAND_HPP
|
||||||
|
|
||||||
|
#include <future>
|
||||||
|
|
||||||
|
#include "../platform/Types.hpp"
|
||||||
|
|
||||||
|
namespace diggler {
|
||||||
|
namespace gfx {
|
||||||
|
|
||||||
|
struct Command {
|
||||||
|
enum class Class : uint8 {
|
||||||
|
CommandBuffer,
|
||||||
|
RenderPass,
|
||||||
|
Framebuffer,
|
||||||
|
ShaderModule,
|
||||||
|
Pipeline,
|
||||||
|
Buffer,
|
||||||
|
Texture,
|
||||||
|
Clear,
|
||||||
|
Draw,
|
||||||
|
} klass;
|
||||||
|
uint8 cmd;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct ReturnCommand : public Command {
|
||||||
|
std::promise<T> returnValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace cmd {
|
||||||
|
struct Draw : public Command {
|
||||||
|
enum class Opacity {
|
||||||
|
Opaque,
|
||||||
|
Translucent,
|
||||||
|
Transparent
|
||||||
|
} opacity = Opacity::Opaque; // Reorderability
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* DIGGLER_GFX_COMMAND_HPP */
|
19
src/gfx/Device.hpp
Normal file
19
src/gfx/Device.hpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef DIGGLER_GFX_DEVICE_HPP
|
||||||
|
#define DIGGLER_GFX_DEVICE_HPP
|
||||||
|
|
||||||
|
#include "Command.hpp"
|
||||||
|
|
||||||
|
namespace diggler {
|
||||||
|
namespace gfx {
|
||||||
|
|
||||||
|
class Device {
|
||||||
|
public:
|
||||||
|
virtual ~Device() = 0;
|
||||||
|
|
||||||
|
virtual void queue(Command&&);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* DIGGLER_GFX_DEVICE_HPP */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user