PNG compression, crosshair, beginnings of builder gun code

master
Dorian Wouters 2015-03-10 21:28:24 +01:00
parent 3ece2545cf
commit a22eb07488
99 changed files with 6462 additions and 6390 deletions

View File

@ -12,7 +12,7 @@ AtlasCreator::AtlasCreator(int w, int h, int uw, int uh) : atlasWidth(w), atlasH
if (fmod((1 << (sizeof(Coord::x)*8))/(float)atlasWidth, 1) != 0 ||
fmod((1 << (sizeof(Coord::y)*8))/(float)atlasHeight, 1) != 0)
throw std::invalid_argument("Atlas W/H is not divisor of Coord's type");
atlasData = new uint8[w * h * 4];
std::fill_n(atlasData, w * h * 4, static_cast<uint8>(0));
}
@ -43,9 +43,9 @@ AtlasCreator::Coord AtlasCreator::add(const std::string& path) {
stbi_image_free(ptr);
return Coord { 0, 0, 0, 0 };
}
Coord result = add(width, height, channels, ptr);
// Free the image buffer
stbi_image_free(ptr);
return result;
@ -61,7 +61,7 @@ AtlasCreator::Coord AtlasCreator::add(int width, int height, int channels, const
targetX = lastX;
targetY = lastY;
}
//auto t1 = std::chrono::high_resolution_clock::now();
// Blit the texture onto the atlas
for(int sourceY = 0; sourceY < height; ++sourceY) {
@ -82,21 +82,18 @@ AtlasCreator::Coord AtlasCreator::add(int width, int height, int channels, const
}
//auto t2 = std::chrono::high_resolution_clock::now();
//getDebugStream() << std::chrono::duration_cast<std::chrono::microseconds>(t2-t1).count() << std::endl;
lastX = targetX + unitWidth;
lastY = targetY;
uint glScaleX = (1 << (sizeof(Coord::x)*8))/atlasWidth,
glScaleY = (1 << (sizeof(Coord::y)*8))/atlasHeight;
//getDebugStream() << width << 'x' << height << '@' << targetX << ',' << targetY << " * " << glScaleX << ',' << glScaleY << std::endl;
Coord c = {
targetX*glScaleX,
targetY*glScaleY,
(targetX + width)*glScaleX-1,
(targetY + height)*glScaleY-1,
};
//getDebugStream() << '{' << c.x << ',' << c.y << ';' << c.u << ',' << c.v << '}' << std::endl;
//getDebugStream() << '{' << targetX << ',' << targetY << "→" << (targetX + width) << ',' << (targetY + height) << '}' << std::endl;
return c;
}
@ -108,5 +105,4 @@ AtlasCreator::~AtlasCreator() {
delete[] atlasData;
}
}

View File

@ -12,11 +12,14 @@
#define CXY (CX*CY)
#define I(x,y,z) (x+y*CX+z*CXY)
#define SHOW_CHUNK_UPDATES 0
namespace Diggler {
const Program *Chunk::RenderProgram = nullptr;
Texture *Chunk::TextureAtlas = nullptr;
Blocks *Chunk::BlkInf = nullptr;
GLint Chunk::RenderProgram_uni_unicolor = -1;
GLint Chunk::RenderProgram_attrib_texcoord = -1;
GLint Chunk::RenderProgram_attrib_coord = -1;
GLint Chunk::RenderProgram_attrib_color = -1;
@ -25,18 +28,19 @@ GLint Chunk::RenderProgram_uni_mvp = -1;
constexpr float Chunk::CullSphereRadius;
constexpr float Chunk::MidX, Chunk::MidY, Chunk::MidZ;
Chunk::Chunk(bool buffer, int scx, int scy, int scz, Game *G) : blk2(nullptr),
Chunk::Chunk(int scx, int scy, int scz, Game *G) : blk2(nullptr),
scx(scx), scy(scy), scz(scz), G(G), vbo(nullptr), lavaCount(0) {
changed = true;
blk = new BlockType[CX*CY*CZ];
for (int i=0; i < CX*CY*CZ; ++i)
blk[i] = BlockType::Air;
if (!buffer && GlobalProperties::IsClient) {
if (GlobalProperties::IsClient) {
vbo = new VBO;
ibo = new VBO;
if (RenderProgram == nullptr) {
RenderProgram = G->PM->getProgram(PM_3D | PM_TEXTURED | PM_COLORED | PM_FOG);
RenderProgram_uni_unicolor = RenderProgram->uni("unicolor");
RenderProgram_attrib_coord = RenderProgram->att("coord");
RenderProgram_attrib_color = RenderProgram->att("color");
RenderProgram_attrib_texcoord = RenderProgram->att("texcoord");
@ -88,8 +92,22 @@ void Chunk::set(int x, int y, int z, BlockType type) {
if (type == BlockType::Lava)
lavaCount++;
*b = type;
if (G && G->CCH)
G->CCH->add(scx * CX + x, scy * CY + y, scz * CZ + z, type);
if (G) {
if (G->CCH)
G->CCH->add(scx * CX + x, scy * CY + y, scz * CZ + z, type);
if (GlobalProperties::IsClient) {
int u = x==CX-1?1:(x==0)?-1:0,
v = y==CY-1?1:(y==0)?-1:0,
w = z==CZ-1?1:(z==0)?-1:0;
Chunk *nc;
if (u && (nc = G->SC->getChunk(scx+u, scy, scz)))
nc->changed = true;
if (v && (nc = G->SC->getChunk(scx, scy+v, scz)))
nc->changed = true;
if (w && (nc = G->SC->getChunk(scx, scy, scz+w)))
nc->changed = true;
}
}
changed = true;
mut.unlock();
}
@ -250,6 +268,9 @@ void Chunk::render(const glm::mat4 &transform) {
}
void Chunk::renderBatched(const glm::mat4& transform) {
#if SHOW_CHUNK_UPDATES
glUniform4f(RenderProgram_uni_unicolor, 1.f, changed ? 0.f : 1.f, changed ? 0.f : 1.f, 1.f);
#endif
if (changed)
updateClient();
if (!indices)

View File

@ -38,7 +38,8 @@ public:
static const Program *RenderProgram;
static Texture *TextureAtlas;
static Blocks *BlkInf;
static GLint RenderProgram_attrib_coord, RenderProgram_attrib_color, RenderProgram_attrib_texcoord, RenderProgram_uni_mvp;
static GLint RenderProgram_uni_unicolor, RenderProgram_attrib_coord, RenderProgram_attrib_color,
RenderProgram_attrib_texcoord, RenderProgram_uni_mvp;
BlockType *blk;
int scx, scy, scz;
Game *G;
@ -48,7 +49,7 @@ public:
int lavaCount;
/// @param buffer Wether the chunk is just a buffer chunk
Chunk(bool buffer = false, int scx = -1, int scy = -1, int scz = -1, Game *G = nullptr);
Chunk(int scx = -1, int scy = -1, int scz = -1, Game *G = nullptr);
~Chunk();
BlockType get(int x, int y, int z);
void set(int x, int y, int z, BlockType type);

View File

@ -118,6 +118,8 @@ GameState::GameState(GameWindow *W, const std::string &servHost, int servPort)
};
m_3dRenderVBO->setData(renderQuad, 6*sizeof(Coord2DTex));
m_crossHair.tex = new Texture(getAssetPath("crosshair.png"), Texture::PixelFormat::RGBA);
//"\f0H\f1e\f2l\f3l\f4l\f5o \f6d\f7e\f8m\f9b\faa\fbz\fcz\fde\fes\ff,\n\f0ye see,it werks purrfektly :D\n(and also; it's optimized)"
m_mouseLocked = false;
@ -126,6 +128,21 @@ GameState::GameState(GameWindow *W, const std::string &servHost, int servPort)
enableExtractor = true;
}
GameState::BuilderGun::BuilderGun() {
tex = new Texture(getAssetPath("tools", "tex_tool_build.png"), Texture::PixelFormat::RGBA);
blockTexs.emplace(BlockType::Metal, new Texture(getAssetPath("icons", "tex_icon_metal.png")));
currentBlock = BlockType::Metal;
currentBlockTex = blockTexs.at(BlockType::Metal);
index = 0;
deconstruct = false;
}
GameState::BuilderGun::~BuilderGun() {
delete tex;
for (auto it : blockTexs)
delete it.second;
}
void GameState::setupUI() {
UI.Ore = G->UIM->add<UI::Text>(G->F); UI.Ore->setScale(2, 2);
UI.Loot = G->UIM->add<UI::Text>(G->F); UI.Loot->setScale(2, 2);
@ -146,6 +163,7 @@ void GameState::setupUI() {
GameState::~GameState() {
delete UI.EM;
delete m_3dFbo; delete m_3dRenderVBO; delete m_extractorFbo; delete m_clouds; delete m_bloomFbo;
delete m_crossHair.tex;
delete m_chatBox;
//delete m_sky;
}
@ -232,7 +250,6 @@ void GameState::onKey(int key, int scancode, int action, int mods) {
} else if (key == GLFW_KEY_B) {
G->LP->setHasNoclip(false);
}
// TODO remove me G->LP->special1();
}
}
}
@ -259,7 +276,6 @@ void GameState::onMouseButton(int key, int action, int mods) {
if (action == GLFW_PRESS) {
glm::ivec3 pointed, face;
if (G->LP->raytracePointed(32, &pointed, &face, .1f)) {
//G->SC->set(pointed.x, pointed.y, pointed.z, BlockType::Air);
Net::OutMessage msg(Net::MessageType::MapUpdate);
if (key == GLFW_MOUSE_BUTTON_LEFT) {
msg.writeU16(pointed.x);
@ -322,6 +338,10 @@ void GameState::updateViewport() {
//m_extractorFbo->tex->setFiltering(Texture::Filter::Linear, Texture::Filter::Linear);
m_bloomFbo->resize(w/BloomScale, h/BloomScale);
//m_bloomFbo->tex->setFiltering(Texture::Filter::Linear, Texture::Filter::Linear);
m_crossHair.mat = glm::scale(glm::translate(*G->UIM->PM,
glm::vec3(w/2-5, h/2-5, 0)),
glm::vec3(5*2, 5*2, 0));
char str[15]; std::snprintf(str, 15, "Loot: %d/%d", 0/*G->LP->ore*/, Player::getMaxOre(G->LP->playerclass));
UI.Ore->setText(std::string(str));
@ -513,7 +533,7 @@ void GameState::gameLoop() {
// TODO: move
glm::ivec3 pointed, face;
// TODO: replace harcoded 32 viewdistance
if (G->LP->raytracePointed(32, &pointed, &face, .1f)) {
if (G->LP->raytracePointed(32, &pointed, &face, .05f)) {
m_highlightBox.program->bind();
glEnableVertexAttribArray(m_highlightBox.att_coord);
m_highlightBox.vbo.bind();
@ -655,8 +675,11 @@ void GameState::drawUI() {
G->UIM->render();
m_chatBox->render();
static _<Texture> tex(getAssetPath("tools", "tex_tool_build.png"), Texture::PixelFormat::RGBA);
G->UIM->drawTexRect(UI::Element::Area {20, 0, 120, 126}, *tex);
G->UIM->drawTex(m_crossHair.mat, *m_crossHair.tex);
// TODO render weapon
//G->UIM->drawTexRect(UI::Element::Area {20, -20*3, 120*3, 126*3}, *m_builderGun.tex);
//G->UIM->drawTexRect(UI::Element::Area {20+37*3, 35*3, 117, 63}, *m_builderGun.currentBlockTex);
}
bool GameState::processNetwork() {

View File

@ -2,10 +2,12 @@
#define GAME_STATE_HPP
#include "State.hpp"
#include <thread>
#include <map>
#include <glm/detail/type_vec2.hpp>
#include <glm/detail/type_vec.hpp>
#include "GameWindow.hpp"
#include "VBO.hpp"
#include "Blocks.hpp"
#include "network/Network.hpp"
namespace Diggler {
@ -51,12 +53,28 @@ private:
Clouds *m_clouds;
Skybox *m_sky;
struct CrossHair {
Texture *tex;
glm::mat4 mat;
} m_crossHair;
struct {
VBO vbo;
const Program *program;
GLuint att_coord, uni_unicolor, uni_mvp;
} m_highlightBox;
struct BuilderGun {
Texture *tex;
std::map<BlockType, Texture*> blockTexs;
int index;
bool deconstruct;
BlockType currentBlock;
Texture *currentBlockTex;
BuilderGun();
~BuilderGun();
} m_builderGun;
KeyBindings *m_keybinds;
Chatbox *m_chatBox;

View File

@ -8,7 +8,7 @@ using std::fopen; using std::fwrite; using std::fread; using std::fclose;
namespace Diggler {
Superchunk::Superchunk(Diggler::Game *G) : G(G), c(nullptr),
Superchunk::Superchunk(Game *G) : G(G), c(nullptr),
chunksX(0), chunksY(0), chunksZ(0) {
}
@ -78,7 +78,7 @@ void Superchunk::set(int x, int y, int z, BlockType type) {
z %= CZ;
if(!c[cx][cy][cz])
c[cx][cy][cz] = new Chunk(false, cx, cy, cz, G);
c[cx][cy][cz] = new Chunk(cx, cy, cz, G);
c[cx][cy][cz]->set(x, y, z, type);
}
@ -95,7 +95,7 @@ void Superchunk::set2(int x, int y, int z, BlockType type) {
z %= CZ;
if(!c[cx][cy][cz])
c[cx][cy][cz] = new Chunk(false, cx, cy, cz, G);
c[cx][cy][cz] = new Chunk(cx, cy, cz, G);
c[cx][cy][cz]->set2(x, y, z, type);
}
@ -111,10 +111,11 @@ BlockType Superchunk::get(float x, float y, float z) {
}
Chunk* Superchunk::getChunk(int cx, int cy, int cz) {
if (cx >= chunksX || cy >= chunksY || cz >= chunksZ)
if (cx < 0 || cy < 0 || cz < 0 ||
cx >= chunksX || cy >= chunksY || cz >= chunksZ)
return nullptr;
if(!c[cx][cy][cz])
c[cx][cy][cz] = new Chunk(false, cx, cy, cz, G);
c[cx][cy][cz] = new Chunk(cx, cy, cz, G);
return c[cx][cy][cz];
}
@ -208,7 +209,7 @@ void Superchunk::load(const std::string &path) {
if (size == -1) { // Chunk is empty
c[sx][sy][sz] = nullptr;
} else {
c[sx][sy][sz] = new Chunk(false, sx, sy, sz, G);
c[sx][sy][sz] = new Chunk(sx, sy, sz, G);
byte *compressedData = (byte*)malloc(size);
fread(compressedData, size, 1, f);
uncompressedDataSize = CX * CY * CZ;
@ -280,7 +281,7 @@ void Superchunk::readMsg(Net::InMessage &M) {
if (size == -1) { // Chunk is empty
c[sx][sy][sz] = nullptr; // Keep out
} else {
c[sx][sy][sz] = new Chunk(false, sx, sy, sz, G);
c[sx][sy][sz] = new Chunk(sx, sy, sz, G);
byte *compressedData = (byte*)malloc(size);
M.readData(compressedData, size);
bytesRead += size;

View File

@ -14,35 +14,34 @@ class OutMessage;
class Superchunk {
private:
friend class Chunk;
Game *G;
Chunk ****c;
int chunksX, chunksY, chunksZ;
void set2(int x, int y, int z, BlockType type);
void free();
public:
Superchunk(Game *G = nullptr);
~Superchunk();
void save(const std::string &path) const;
void load(const std::string &path);
void writeMsg(Net::OutMessage&) const;
void readMsg(Net::InMessage&);
void setSize(int x, int y, int z);
int getChunksX() const;
int getChunksY() const;
int getChunksZ() const;
BlockType get(int x, int y, int z);
BlockType get(float x, float y, float z);
void set(int x, int y, int z, BlockType type);
Chunk* getChunk(int cx, int cy, int cz);
void render(const glm::mat4 &transform);
};
}

View File

@ -14,9 +14,7 @@ namespace Diggler {
Texture::Texture(int w, int h, Texture::PixelFormat format, bool makeXor) : w(w), h(h), m_format(format) {
PushBoundTex();
create();
//if (makeXor) { // Actually it's damn expensive to do this
setPlaceholder(makeXor);
//}
setPlaceholder(makeXor);
PopBoundTex();
}
@ -27,7 +25,8 @@ Texture::Texture(int w, int h, uint8_t* data, Texture::PixelFormat format) {
PopBoundTex();
}
Texture::Texture(const std::string& path, Texture::PixelFormat format) {
static GLenum getGlTexFormat(Texture::PixelFormat fmt);
Texture::Texture(const std::string& path, PixelFormat format) {
PushBoundTex();
create();
int stbiFormat;
@ -53,7 +52,8 @@ Texture::Texture(const std::string& path, Texture::PixelFormat format) {
setTexture(w, h, ptr, format);
stbi_image_free(ptr);
#if TEXTURE_LOAD_DEBUG
getDebugStream() << "Loaded image " << path << std::endl;
getDebugStream() << "Loaded image \"" << path << "\" w=" << w << " h=" << h <<
" c=" << channels << " pf=" << (int)format << " glPf=" << (int)getGlTexFormat(format) << std::endl;
#endif
} else {
w = 64; h = 64;
@ -90,7 +90,7 @@ void Texture::setFiltering(Filter min, Filter mag) {
PopBoundTex();
}
GLenum getWrapGlConstant(Texture::Wrapping wrap) {
static GLenum getWrapGlConstant(Texture::Wrapping wrap) {
switch (wrap) {
case Texture::Wrapping::Clamp:
return GL_CLAMP;
@ -135,21 +135,26 @@ void Texture::setPlaceholder(bool makeXor) {
delete[] white;
}
void Texture::setTexture(int w, int h, uint8_t *data, Texture::PixelFormat format) {
this->w = w; this->h = h;
this->m_format = format;
GLenum glFormat;
switch (format) {
case PixelFormat::RGB:
glFormat = GL_RGB;
static GLenum getGlTexFormat(Texture::PixelFormat fmt) {
switch (fmt) {
case Texture::PixelFormat::RGB:
return GL_RGB;
break;
case PixelFormat::RGBA:
glFormat = GL_RGBA;
case Texture::PixelFormat::RGBA:
return GL_RGBA;
break;
case PixelFormat::Monochrome8:
glFormat = GL_LUMINANCE8;
case Texture::PixelFormat::Monochrome8:
return GL_R8;
break;
}
return 0;
}
void Texture::setTexture(int w, int h, uint8_t *data, PixelFormat format) {
this->w = w; this->h = h;
this->m_format = format;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // This. GL = state machine
GLenum glFormat = getGlTexFormat(format);
glTexImage2D(GL_TEXTURE_2D, // target
0, // level, 0 = base, no minimap
glFormat, // internalformat
@ -170,18 +175,7 @@ void Texture::resize(int w, int h) {
return;
PushBoundTex();
bind();
GLenum glFormat;
switch (m_format) {
case PixelFormat::RGB:
glFormat = GL_RGB;
break;
case PixelFormat::RGBA:
glFormat = GL_RGBA;
break;
case PixelFormat::Monochrome8:
glFormat = GL_LUMINANCE8;
break;
}
GLenum glFormat = getGlTexFormat(m_format);
glTexImage2D(GL_TEXTURE_2D, // target
0, // level, 0 = base, no minimap,
glFormat, // internalformat

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 944 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 799 B

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 350 B

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 354 B

After

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 464 B

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 B

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 B

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 893 B

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1006 B

After

Width:  |  Height:  |  Size: 969 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 B

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

BIN
assets/crosshair.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 938 B

After

Width:  |  Height:  |  Size: 936 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 958 B

After

Width:  |  Height:  |  Size: 921 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 870 B

After

Width:  |  Height:  |  Size: 833 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 870 B

After

Width:  |  Height:  |  Size: 833 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 896 B

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 896 B

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 899 B

After

Width:  |  Height:  |  Size: 862 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 B

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 B

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 899 B

After

Width:  |  Height:  |  Size: 862 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 B

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

After

Width:  |  Height:  |  Size: 364 B

File diff suppressed because it is too large Load Diff

6326
stb_image_src.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -66,6 +66,22 @@ void Manager::setProjMat(const glm::mat4 &mat) {
m_projMatrix = mat;
}
void Manager::drawTex(const glm::mat4 &mat, const Texture &t) {
RP_Rect->bind();
glEnableVertexAttribArray(RP_Rect_att_coord);
glEnableVertexAttribArray(RP_Rect_att_texcoord);
t.bind();
m_rectVbo->bind();
glUniformMatrix4fv(RP_Rect_uni_mvp, 1, GL_FALSE, glm::value_ptr(mat));
glVertexAttribPointer(RP_Rect_att_coord, 2, GL_UNSIGNED_BYTE, GL_FALSE, 4*sizeof(uint8), 0);
glVertexAttribPointer(RP_Rect_att_texcoord, 2, GL_UNSIGNED_BYTE, GL_FALSE, 4*sizeof(uint8), (void*)(2*sizeof(uint8)));
glDrawArrays(GL_TRIANGLES, 0, 6);
glDisableVertexAttribArray(RP_Rect_att_texcoord);
glDisableVertexAttribArray(RP_Rect_att_coord);
}
void Manager::drawTexRect(const Element::Area &a, const Texture &t) const {
RP_Rect->bind();
glEnableVertexAttribArray(RP_Rect_att_coord);

View File

@ -49,6 +49,7 @@ public:
// Utility
void drawTex(const glm::mat4&, const Texture&);
//void drawRect(const Element::Area&, const glm::vec3 &color) const;
void drawTexRect(const Element::Area&, const Texture&) const;
void drawFullTexV(const Texture&);