fix missing texture sizing, fix bordered repeated texture upload, make quads default to repeating for now
This commit is contained in:
@ -208,7 +208,7 @@ void delete_gpu_texture(GPUTexture texture) {
|
||||
}
|
||||
|
||||
|
||||
void upload_gpu_texture(GPUTexture texture, void *pixels, int channels, int width, int height) {
|
||||
void upload_gpu_texture(GPUTexture texture, void *pixels, int channels, int width, int height, int xoffset, int yoffset) {
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
int format;
|
||||
@ -223,6 +223,12 @@ void upload_gpu_texture(GPUTexture texture, void *pixels, int channels, int widt
|
||||
return;
|
||||
}
|
||||
|
||||
if (xoffset != 0 || yoffset != 0)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, width + xoffset * 2);
|
||||
|
||||
void *start = xoffset != 0 || yoffset != 0
|
||||
? &(((uint8_t *)pixels)[xoffset * channels + yoffset * (width + xoffset * 2) * channels]) : pixels;
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
0,
|
||||
@ -231,7 +237,10 @@ void upload_gpu_texture(GPUTexture texture, void *pixels, int channels, int widt
|
||||
height,
|
||||
format,
|
||||
GL_UNSIGNED_BYTE,
|
||||
pixels);
|
||||
start);
|
||||
|
||||
if (xoffset != 0 || yoffset != 0)
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ GPUTexture create_gpu_texture(TextureFilter filter, bool generate_mipmaps, int c
|
||||
|
||||
void delete_gpu_texture(GPUTexture texture);
|
||||
|
||||
void upload_gpu_texture(GPUTexture texture, void *pixels, int channels, int width, int height);
|
||||
void upload_gpu_texture(GPUTexture texture, void *pixels, int channels, int width, int height, int xoffset, int yoffset);
|
||||
|
||||
void bind_gpu_texture(GPUTexture texture);
|
||||
|
||||
|
@ -239,10 +239,15 @@ void finally_draw_space_quads_batch(const MeshBatch *batch,
|
||||
const Rect srcrect = textures_get_srcrect(&ctx.texture_cache, texture_key);
|
||||
const Rect dims = textures_get_dims(&ctx.texture_cache, texture_key);
|
||||
|
||||
const float wr = srcrect.w / dims.w;
|
||||
const float hr = srcrect.h / dims.h;
|
||||
const float xr = srcrect.x / dims.w;
|
||||
const float yr = srcrect.y / dims.h;
|
||||
// const float wr = srcrect.w / dims.w;
|
||||
// const float hr = srcrect.h / dims.h;
|
||||
// const float xr = srcrect.x / dims.w;
|
||||
// const float yr = srcrect.y / dims.h;
|
||||
|
||||
const float wr = 1;
|
||||
const float hr = 1;
|
||||
const float xr = 1;
|
||||
const float yr = 1;
|
||||
|
||||
/* update pixel-based uvs to correspond with texture atlases */
|
||||
for (size_t i = 0; i < primitives_len; ++i) {
|
||||
@ -293,6 +298,7 @@ void finally_draw_space_quads_batch(const MeshBatch *batch,
|
||||
};
|
||||
|
||||
command.texture_key = texture_key;
|
||||
command.texture_repeat = true;
|
||||
command.textured = true;
|
||||
|
||||
command.element_buffer = get_quad_element_buffer();
|
||||
|
@ -174,7 +174,8 @@ static FontData *text_load_font_data(const char *path, int height_px) {
|
||||
bitmap,
|
||||
1,
|
||||
(int)ctx.font_texture_size,
|
||||
(int)ctx.font_texture_size
|
||||
(int)ctx.font_texture_size,
|
||||
0, 0
|
||||
);
|
||||
SDL_free(bitmap);
|
||||
|
||||
|
Reference in New Issue
Block a user