mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 04:21:50 +00:00
type-update
This commit is contained in:
parent
e7e2c16ee6
commit
3c7f46987a
32 changed files with 161 additions and 153 deletions
|
|
@ -23,7 +23,7 @@ Batch3D::Batch3D(size_t capacity)
|
|||
mesh = new Mesh(buffer, 0, attrs);
|
||||
index = 0;
|
||||
|
||||
ubyte pixels[] = {
|
||||
u_char8 pixels[] = {
|
||||
255, 255, 255, 255,
|
||||
};
|
||||
blank = new Texture(pixels, 1, 1, GL_RGBA);
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ void BlocksRenderer::blockXSprite(int x, int y, int z,
|
|||
/* AABB blocks render method */
|
||||
void BlocksRenderer::blockAABB(const ivec3& icoord,
|
||||
const UVRegion(&texfaces)[6],
|
||||
const Block* block, ubyte rotation,
|
||||
const Block* block, u_char8 rotation,
|
||||
bool lights) {
|
||||
AABB hitbox = block->hitbox;
|
||||
vec3 size = hitbox.size();
|
||||
|
|
@ -221,9 +221,9 @@ void BlocksRenderer::blockAABB(const ivec3& icoord,
|
|||
void BlocksRenderer::blockCube(int x, int y, int z,
|
||||
const UVRegion(&texfaces)[6],
|
||||
const Block* block,
|
||||
ubyte states,
|
||||
u_char8 states,
|
||||
bool lights) {
|
||||
ubyte group = block->drawGroup;
|
||||
u_char8 group = block->drawGroup;
|
||||
|
||||
vec3 X(1, 0, 0);
|
||||
vec3 Y(0, 1, 0);
|
||||
|
|
@ -258,7 +258,7 @@ void BlocksRenderer::blockCube(int x, int y, int z,
|
|||
}
|
||||
|
||||
// Does block allow to see other blocks sides (is it transparent)
|
||||
bool BlocksRenderer::isOpen(int x, int y, int z, ubyte group) const {
|
||||
bool BlocksRenderer::isOpen(int x, int y, int z, u_char8 group) const {
|
||||
blockid_t id = voxelsBuffer->pickBlockId(chunk->x * CHUNK_W + x,
|
||||
y,
|
||||
chunk->z * CHUNK_D + z);
|
||||
|
|
|
|||
|
|
@ -60,16 +60,16 @@ class BlocksRenderer {
|
|||
const UVRegion& region,
|
||||
bool lights);
|
||||
|
||||
void blockCube(int x, int y, int z, const UVRegion(&faces)[6], const Block* block, ubyte states, bool lights);
|
||||
void blockCube(int x, int y, int z, const UVRegion(&faces)[6], const Block* block, u_char8 states, bool lights);
|
||||
void blockAABB(const glm::ivec3& coord,
|
||||
const UVRegion(&faces)[6],
|
||||
const Block* block,
|
||||
ubyte rotation,
|
||||
u_char8 rotation,
|
||||
bool lights);
|
||||
void blockXSprite(int x, int y, int z, const glm::vec3& size, const UVRegion& face1, const UVRegion& face2, float spread);
|
||||
|
||||
bool isOpenForLight(int x, int y, int z) const;
|
||||
bool isOpen(int x, int y, int z, ubyte group) const;
|
||||
bool isOpen(int x, int y, int z, u_char8 group) const;
|
||||
|
||||
glm::vec4 pickLight(int x, int y, int z) const;
|
||||
glm::vec4 pickLight(const glm::ivec3& coord) const;
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ inline int max(int a, int b) {
|
|||
ImageData::ImageData(ImageFormat format, uint width, uint height)
|
||||
: format(format), width(width), height(height) {
|
||||
switch (format) {
|
||||
case ImageFormat::rgb888: data = new ubyte[width*height*3]{}; break;
|
||||
case ImageFormat::rgba8888: data = new ubyte[width*height*4]{}; break;
|
||||
case ImageFormat::rgb888: data = new u_char8[width*height*3]{}; break;
|
||||
case ImageFormat::rgba8888: data = new u_char8[width*height*4]{}; break;
|
||||
default:
|
||||
throw std::runtime_error("format is not supported");
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ ImageData::~ImageData() {
|
|||
switch (format) {
|
||||
case ImageFormat::rgb888:
|
||||
case ImageFormat::rgba8888:
|
||||
delete[] (ubyte*)data;
|
||||
delete[] (u_char8*)data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -40,11 +40,11 @@ void ImageData::flipX() {
|
|||
case ImageFormat::rgb888:
|
||||
case ImageFormat::rgba8888: {
|
||||
size = (format == ImageFormat::rgba8888) ? 4 : 3;
|
||||
ubyte* pixels = (ubyte*)data;
|
||||
u_char8* pixels = (u_char8*)data;
|
||||
for (uint y = 0; y < height; y++) {
|
||||
for (uint x = 0; x < width/2; x++) {
|
||||
for (uint c = 0; c < size; c++) {
|
||||
ubyte temp = pixels[(y * width + x) * size + c];
|
||||
u_char8 temp = pixels[(y * width + x) * size + c];
|
||||
pixels[(y * width + x) * size + c] = pixels[(y * width + (width - x - 1)) * size + c];
|
||||
pixels[(y * width + (width - x - 1)) * size + c] = temp;
|
||||
}
|
||||
|
|
@ -63,11 +63,11 @@ void ImageData::flipY() {
|
|||
case ImageFormat::rgb888:
|
||||
case ImageFormat::rgba8888: {
|
||||
size = (format == ImageFormat::rgba8888) ? 4 : 3;
|
||||
ubyte* pixels = (ubyte*)data;
|
||||
u_char8* pixels = (u_char8*)data;
|
||||
for (uint y = 0; y < height/2; y++) {
|
||||
for (uint x = 0; x < width; x++) {
|
||||
for (uint c = 0; c < size; c++) {
|
||||
ubyte temp = pixels[(y * width + x) * size + c];
|
||||
u_char8 temp = pixels[(y * width + x) * size + c];
|
||||
pixels[(y * width + x) * size + c] =
|
||||
pixels[((height-y-1) * width + x) * size + c];
|
||||
pixels[((height-y-1) * width + x) * size + c] = temp;
|
||||
|
|
@ -92,8 +92,8 @@ void ImageData::blit(const ImageData* image, int x, int y) {
|
|||
default:
|
||||
throw std::runtime_error("only unsigned byte formats supported");
|
||||
}
|
||||
ubyte* pixels = static_cast<ubyte*>(data);
|
||||
ubyte* source = static_cast<ubyte*>(image->getData());
|
||||
u_char8* pixels = static_cast<u_char8*>(data);
|
||||
u_char8* source = static_cast<u_char8*>(image->getData());
|
||||
uint srcwidth = image->getWidth();
|
||||
uint srcheight = image->getHeight();
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ void ImageData::extrude(int x, int y, int w, int h) {
|
|||
default:
|
||||
throw std::runtime_error("only unsigned byte formats supported");
|
||||
}
|
||||
ubyte* pixels = static_cast<ubyte*>(data);
|
||||
u_char8* pixels = static_cast<u_char8*>(data);
|
||||
|
||||
int rx = x + w - 1;
|
||||
int ry = y + h - 1;
|
||||
|
|
@ -207,7 +207,7 @@ void ImageData::extrude(int x, int y, int w, int h) {
|
|||
}
|
||||
|
||||
void ImageData::fixAlphaColor() {
|
||||
ubyte* pixels = static_cast<ubyte*>(data);
|
||||
u_char8* pixels = static_cast<u_char8*>(data);
|
||||
|
||||
// Fixing black transparent pixels for Mip-Mapping
|
||||
for (uint ly = 0; ly < height-1; ly++) {
|
||||
|
|
@ -235,8 +235,8 @@ ImageData* add_atlas_margins(ImageData* image, int grid_size) {
|
|||
int dstwidth = srcwidth + grid_size * 2;
|
||||
int dstheight = srcheight + grid_size * 2;
|
||||
|
||||
const ubyte* srcdata = (const ubyte*)image->getData();
|
||||
ubyte* dstdata = new ubyte[dstwidth*dstheight * 4];
|
||||
const u_char8* srcdata = (const u_char8*)image->getData();
|
||||
u_char8* dstdata = new u_char8[dstwidth*dstheight * 4];
|
||||
|
||||
int imgres = image->getWidth() / grid_size;
|
||||
for (int row = 0; row < grid_size; row++) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "../typedefs.h"
|
||||
|
||||
struct vattr {
|
||||
ubyte size;
|
||||
u_char8 size;
|
||||
};
|
||||
|
||||
class Mesh {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Texture::Texture(uint id, int width, int height)
|
|||
: id(id), width(width), height(height) {
|
||||
}
|
||||
|
||||
Texture::Texture(ubyte* data, int width, int height, uint format)
|
||||
Texture::Texture(u_char8* data, int width, int height, uint format)
|
||||
: width(width), height(height) {
|
||||
glGenTextures(1, &id);
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
|
|
@ -30,7 +30,7 @@ void Texture::bind(){
|
|||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
}
|
||||
|
||||
void Texture::reload(ubyte* data){
|
||||
void Texture::reload(u_char8* data){
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid *) data);
|
||||
|
|
@ -48,5 +48,5 @@ Texture* Texture::from(const ImageData* image) {
|
|||
default:
|
||||
throw std::runtime_error("unsupported image data format");
|
||||
}
|
||||
return new Texture((ubyte*)data, width, height, format);
|
||||
return new Texture((u_char8*)data, width, height, format);
|
||||
}
|
||||
|
|
@ -12,11 +12,11 @@ public:
|
|||
int width;
|
||||
int height;
|
||||
Texture(uint id, int width, int height);
|
||||
Texture(ubyte* data, int width, int height, uint format);
|
||||
Texture(u_char8* data, int width, int height, uint format);
|
||||
~Texture();
|
||||
|
||||
void bind();
|
||||
void reload(ubyte* data);
|
||||
void reload(u_char8* data);
|
||||
|
||||
static Texture* from(const ImageData* image);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue