Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/Core/ByteStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Vortex {

WriteStream::WriteStream()
{
buffer_ = (uchar*)malloc(128);
buffer_ = (uint8_t*)malloc(128);
current_size_ = 0;
capacity_ = 128;
is_external_buffer_ = false;
Expand All @@ -22,7 +22,7 @@ WriteStream::WriteStream()

WriteStream::WriteStream(void* out, int bytes)
{
buffer_ = (uchar*)out;
buffer_ = (uint8_t*)out;
current_size_ = 0;
capacity_ = bytes;
is_external_buffer_ = true;
Expand All @@ -45,7 +45,7 @@ void WriteStream::write(const void* in, int bytes)
else if(!is_external_buffer_)
{
capacity_ = max(capacity_ << 1, newSize);
buffer_ = (uchar*)realloc(buffer_, capacity_);
buffer_ = (uint8_t*)realloc(buffer_, capacity_);
memcpy(buffer_ + current_size_, in, bytes);
current_size_ = newSize;
}
Expand All @@ -65,7 +65,7 @@ void WriteStream::write8(const void* val)
else if(!is_external_buffer_)
{
capacity_ <<= 1;
buffer_ = (uchar*)realloc(buffer_, capacity_);
buffer_ = (uint8_t*)realloc(buffer_, capacity_);
buffer_[current_size_] = *(const uint8_t*)val;
++current_size_;
}
Expand All @@ -86,7 +86,7 @@ void WriteStream::write16(const void* val)
else if(!is_external_buffer_)
{
capacity_ <<= 1;
buffer_ = (uchar*)realloc(buffer_, capacity_);
buffer_ = (uint8_t*)realloc(buffer_, capacity_);
*(uint16_t*)(buffer_ + current_size_) = *(const uint16_t*)val;
current_size_ = newSize;
}
Expand All @@ -107,7 +107,7 @@ void WriteStream::write32(const void* val)
else if(!is_external_buffer_)
{
capacity_ <<= 1;
buffer_ = (uchar*)realloc(buffer_, capacity_);
buffer_ = (uint8_t*)realloc(buffer_, capacity_);
*(uint32_t*)(buffer_ + current_size_) = *(const uint32_t*)val;
current_size_ = newSize;
}
Expand All @@ -128,7 +128,7 @@ void WriteStream::write64(const void* val)
else if(!is_external_buffer_)
{
capacity_ <<= 1;
buffer_ = (uchar*)realloc(buffer_, capacity_);
buffer_ = (uint8_t*)realloc(buffer_, capacity_);
*(uint64_t*)(buffer_ + current_size_) = *(const uint64_t*)val;
current_size_ = newSize;
}
Expand All @@ -138,16 +138,16 @@ void WriteStream::write64(const void* val)
}
}

void WriteStream::writeNum(uint num)
void WriteStream::writeNum(uint32_t num)
{
if(num < 0x80)
{
write8(&num);
}
else
{
uchar buf[8];
uint index = 0;
uint8_t buf[8];
uint32_t index = 0;
while(num >= 0x80)
{
buf[index] = (num & 0x7F) | 0x80;
Expand All @@ -170,7 +170,7 @@ void WriteStream::writeStr(StringRef str)

ReadStream::ReadStream(const void* in, int bytes)
{
read_position_ = (const uchar*)in;
read_position_ = (const uint8_t*)in;
end_position_ = read_position_ + bytes;
is_read_successful_ = true;
}
Expand Down Expand Up @@ -270,7 +270,7 @@ void ReadStream::read64(void* out)
}
}

uint ReadStream::readNum()
uint32_t ReadStream::readNum()
{
uint32_t out;
if(read_position_ != end_position_)
Expand All @@ -283,7 +283,7 @@ uint ReadStream::readNum()
else
{
out = *read_position_ & 0x7F;
uint shift = 7;
uint32_t shift = 7;
while(true)
{
if(++read_position_ == end_position_)
Expand All @@ -292,7 +292,7 @@ uint ReadStream::readNum()
is_read_successful_ = false;
break;
}
uint byte = *read_position_;
uint32_t byte = *read_position_;
if((byte & 0x80) == 0)
{
out |= byte << shift;
Expand All @@ -315,7 +315,7 @@ uint ReadStream::readNum()
String ReadStream::readStr()
{
String out;
uint len = readNum();
uint32_t len = readNum();
auto newPos = read_position_ + len;
if(newPos <= end_position_)
{
Expand All @@ -328,7 +328,7 @@ String ReadStream::readStr()
return String();
}

void ReadStream::readNum(uint& num)
void ReadStream::readNum(uint32_t& num)
{
num = readNum();
}
Expand Down
14 changes: 7 additions & 7 deletions src/Core/ByteStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct WriteStream
void write32(const void* val);
void write64(const void* val);

void writeNum(uint num);
void writeNum(uint32_t num);
void writeStr(StringRef str);

template <unsigned int S>
Expand Down Expand Up @@ -65,10 +65,10 @@ struct WriteStream
int size() const { return current_size_; }

// Returns a pointer to the start of the written data.
const uchar* data() const { return buffer_; }
const uint8_t* data() const { return buffer_; }

private:
uchar* buffer_;
uint8_t* buffer_;
int current_size_, capacity_;
bool is_external_buffer_, is_write_successful_;
};
Expand All @@ -88,10 +88,10 @@ struct ReadStream
void read32(void* out);
void read64(void* out);

uint readNum();
uint32_t readNum();
String readStr();

void readNum(uint& num);
void readNum(uint32_t& num);
void readStr(String& str);

template <size_t S>
Expand Down Expand Up @@ -148,10 +148,10 @@ struct ReadStream
size_t bytesleft() const { return end_position_ - read_position_; }

// Returns the current read position.
const uchar* pos() const { return read_position_; }
const uint8_t* pos() const { return read_position_; }

private:
const uchar* read_position_, *end_position_;
const uint8_t* read_position_, *end_position_;
bool is_read_successful_;
};

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void Canvas::polygon(const float* x, const float* y, int vertexCount)

Texture Canvas::createTexture(bool mipmap) const
{
uchar* dst = (uchar*)malloc(canvas_width_*canvas_height_ * 4 * sizeof(uchar));
uint8_t* dst = (uint8_t*)malloc(canvas_width_*canvas_height_ * 4 * sizeof(uint8_t));
for(int i = 0; i < canvas_width_ * canvas_height_ * 4; ++i)
{
int v = (int)(canvas_data_[i] * 255.f + 0.5f);
Expand Down
6 changes: 0 additions & 6 deletions src/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@

namespace Vortex {

typedef uint64_t ulong;
typedef uint32_t uint;
typedef uint16_t ushort;
typedef uint8_t uchar;
typedef uint32_t color32;

template <typename T> struct vec2t { T x, y; };
template <typename T> struct vec3t { T x, y, z; };
template <typename T> struct rectt { T x, y, w, h; };
Expand Down
46 changes: 23 additions & 23 deletions src/Core/Draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const colorf Colorsf::white = {1, 1, 1, 1};
const colorf Colorsf::black = {0, 0, 0, 1};
const colorf Colorsf::blank = {0, 0, 0, 0};

const color32 Colors::white = RGBAtoColor32(255, 255, 255, 255);
const color32 Colors::black = RGBAtoColor32(0, 0, 0, 255);
const color32 Colors::blank = RGBAtoColor32(0, 0, 0, 0);
const uint32_t Colors::white = RGBAtoColor32(255, 255, 255, 255);
const uint32_t Colors::black = RGBAtoColor32(0, 0, 0, 255);
const uint32_t Colors::blank = RGBAtoColor32(0, 0, 0, 0);

// ================================================================================================
// TileBar.
Expand Down Expand Up @@ -99,7 +99,7 @@ TileBar::TileBar()
{
}

void TileBar::draw(recti rect, color32 color, int flags) const
void TileBar::draw(recti rect, uint32_t color, int flags) const
{
int vp[24];
float vt[24];
Expand All @@ -111,11 +111,11 @@ void TileBar::draw(recti rect, color32 color, int flags) const
Renderer::drawQuads(3, vp, vt);
}

void TileBar::draw(QuadBatchTC* out, recti rect, color32 color, int flags) const
void TileBar::draw(QuadBatchTC* out, recti rect, uint32_t color, int flags) const
{
out->push(3);

color32* vc = out->col, *end = vc + 12;
uint32_t* vc = out->col, *end = vc + 12;
while(vc != end) { QCOL(color); }

TB_setVerts(*this, out->pos, out->uvs, rect, uvs, flags);
Expand Down Expand Up @@ -190,7 +190,7 @@ TileRect::TileRect()
{
}

void TileRect::draw(recti rect, color32 color, int flags) const
void TileRect::draw(recti rect, uint32_t color, int flags) const
{
int vp[72];
float vt[72];
Expand All @@ -202,11 +202,11 @@ void TileRect::draw(recti rect, color32 color, int flags) const
Renderer::drawQuads(9, vp, vt);
}

void TileRect::draw(QuadBatchTC* out, recti rect, color32 color, int flags) const
void TileRect::draw(QuadBatchTC* out, recti rect, uint32_t color, int flags) const
{
out->push(9);

color32* vc = out->col, *end = vc + 36;
uint32_t* vc = out->col, *end = vc + 36;
while(vc != end) { QCOL(color); }

TR_setVerts(*this, out->pos, out->uvs, rect, uvs, flags);
Expand Down Expand Up @@ -262,7 +262,7 @@ static void TR2_setVerts(const TileRect2& rect, int* vp, float* vt, recti r, int
QUVS(s + bl, y, t + bl, z); QUVS(t, y, u, z); QUVS(u + br, y, v + br, z);
}

void TileRect2::draw(recti rect, int rounding, color32 color, int flags) const
void TileRect2::draw(recti rect, int rounding, uint32_t color, int flags) const
{
int vp[72];
float vt[72];
Expand All @@ -274,11 +274,11 @@ void TileRect2::draw(recti rect, int rounding, color32 color, int flags) const
Renderer::drawQuads(9, vp, vt);
}

void TileRect2::draw(QuadBatchTC* out, recti rect, int rounding, color32 color, int flags) const
void TileRect2::draw(QuadBatchTC* out, recti rect, int rounding, uint32_t color, int flags) const
{
out->push(9);

color32* vc = out->col, *end = vc + 36;
uint32_t* vc = out->col, *end = vc + 36;
while(vc != end) { QCOL(color); }

TR2_setVerts(*this, out->pos, out->uvs, rect, rounding, flags);
Expand All @@ -287,7 +287,7 @@ void TileRect2::draw(QuadBatchTC* out, recti rect, int rounding, color32 color,
// ================================================================================================
// Rectangle drawing.

void Draw::fill(recti r, color32 col)
void Draw::fill(recti r, uint32_t col)
{
// Vertex positions.
int pos[8], *vp = pos;
Expand All @@ -300,7 +300,7 @@ void Draw::fill(recti r, color32 col)
Renderer::drawQuads(1, pos);
}

void Draw::fill(QuadBatchC* out, recti r, color32 color)
void Draw::fill(QuadBatchC* out, recti r, uint32_t color)
{
out->push();

Expand All @@ -309,26 +309,26 @@ void Draw::fill(QuadBatchC* out, recti r, color32 color)
QPOS(r.x, r.y, r.x + r.w, r.y + r.h);

// Vertex colors.
color32* vc = out->col;
uint32_t* vc = out->col;
QCOL(color);
}

void Draw::fill(recti r, color32 tl, color32 tr, color32 bl, color32 br, bool hsv)
void Draw::fill(recti r, uint32_t tl, uint32_t tr, uint32_t bl, uint32_t br, bool hsv)
{
// Vertex positions.
int pos[8], *vp = pos;
QPOS(r.x, r.y, r.x + r.w, r.y + r.h);

// Vertex colors.
color32 col[4], *vc = col;
uint32_t col[4], *vc = col;
QCOL4(tl, tr, bl, br);

// Render quad.
Renderer::bindShader(hsv ? Renderer::SH_COLOR_HSV : Renderer::SH_COLOR);
Renderer::drawQuads(1, pos, col);
}

void Draw::fill(recti r, color32 col, TextureHandle tex, Texture::Format fmt)
void Draw::fill(recti r, uint32_t col, TextureHandle tex, Texture::Format fmt)
{
// Vertex positions.
int pos[8], *vp = pos;
Expand All @@ -345,7 +345,7 @@ void Draw::fill(recti r, color32 col, TextureHandle tex, Texture::Format fmt)
Renderer::drawQuads(1, pos, uvs);
}

void Draw::fill(recti r, color32 col, TextureHandle tex, areaf uva, Texture::Format fmt)
void Draw::fill(recti r, uint32_t col, TextureHandle tex, areaf uva, Texture::Format fmt)
{
// Vertex positions.
int pos[8], *vp = pos;
Expand All @@ -362,9 +362,9 @@ void Draw::fill(recti r, color32 col, TextureHandle tex, areaf uva, Texture::For
Renderer::drawQuads(1, pos, uvs);
}

void Draw::outline(recti r, color32 col)
void Draw::outline(recti r, uint32_t col)
{
static const uint indices[24] =
static const uint32_t indices[24] =
{
0, 3, 1, 0, 2, 3, 4, 7, 5, 4, 6, 7, 0, 4, 2, 0, 6, 4, 3, 7, 1, 3, 5, 7
};
Expand All @@ -387,7 +387,7 @@ void Draw::outline(recti r, color32 col)
Renderer::drawTris(8, indices, vp);
}

void Draw::roundedBox(recti r, color32 c)
void Draw::roundedBox(recti r, uint32_t c)
{
Renderer::getRoundedBox().draw(r, c);
}
Expand All @@ -400,7 +400,7 @@ void Draw::sprite(const Texture& tex, vec2i pos, int flags)
Draw::sprite(tex, pos, Colors::white, flags);
}

void Draw::sprite(const Texture& tex, vec2i pos, color32 col, int flags)
void Draw::sprite(const Texture& tex, vec2i pos, uint32_t col, int flags)
{
vec2i size = tex.size();
int w = size.x, x = pos.x - w / 2;
Expand Down
Loading