Fix other renderers

This commit is contained in:
Clownacy 2020-09-17 18:26:32 +01:00
parent 5c6b71e3a1
commit 83e8320d84
3 changed files with 6 additions and 7 deletions

View file

@ -207,14 +207,13 @@ void RenderBackend_DestroyGlyphAtlas(RenderBackend_GlyphAtlas *atlas)
free(atlas); free(atlas);
} }
void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t y, const unsigned char *pixels, size_t width, size_t height) void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t y, const unsigned char *pixels, size_t width, size_t height, size_t pitch)
{ {
SDL_LockSurface(atlas->sdlsurface); SDL_LockSurface(atlas->sdlsurface);
const unsigned char *source_pointer = pixels;
for (size_t iy = 0; iy < height; ++iy) for (size_t iy = 0; iy < height; ++iy)
{ {
const unsigned char *source_pointer = &pixels[iy * pitch];
unsigned char *destination_pointer = &((unsigned char*)atlas->sdlsurface->pixels)[(y + iy) * atlas->sdlsurface->pitch + x * 4]; unsigned char *destination_pointer = &((unsigned char*)atlas->sdlsurface->pixels)[(y + iy) * atlas->sdlsurface->pitch + x * 4];
for (size_t ix = 0; ix < width; ++ix) for (size_t ix = 0; ix < width; ++ix)

View file

@ -265,10 +265,10 @@ void RenderBackend_DestroyGlyphAtlas(RenderBackend_GlyphAtlas *atlas)
free(atlas); free(atlas);
} }
void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t y, const unsigned char *pixels, size_t width, size_t height) void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t y, const unsigned char *pixels, size_t width, size_t height, size_t pitch)
{ {
for (size_t i = 0; i < height; ++i) for (size_t i = 0; i < height; ++i)
memcpy(&atlas->pixels[(y + i) * atlas->width + x], &pixels[i * width], width); memcpy(&atlas->pixels[(y + i) * atlas->width + x], &pixels[i * pitch], width);
} }
void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue) void RenderBackend_PrepareToDrawGlyphs(RenderBackend_GlyphAtlas *atlas, RenderBackend_Surface *destination_surface, unsigned char red, unsigned char green, unsigned char blue)

View file

@ -754,7 +754,7 @@ void RenderBackend_DestroyGlyphAtlas(RenderBackend_GlyphAtlas *atlas)
free(atlas); free(atlas);
} }
void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t y, const unsigned char *pixels, size_t width, size_t height) void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t y, const unsigned char *pixels, size_t width, size_t height, size_t pitch)
{ {
unsigned char *buffer = (unsigned char*)GX2RLockSurfaceEx(&atlas->texture.surface, 0, (GX2RResourceFlags)0); unsigned char *buffer = (unsigned char*)GX2RLockSurfaceEx(&atlas->texture.surface, 0, (GX2RResourceFlags)0);
@ -765,7 +765,7 @@ void RenderBackend_UploadGlyph(RenderBackend_GlyphAtlas *atlas, size_t x, size_t
{ {
memcpy(out_pointer, in_pointer, width); memcpy(out_pointer, in_pointer, width);
in_pointer += width; in_pointer += pitch;
out_pointer += atlas->texture.surface.pitch; out_pointer += atlas->texture.surface.pitch;
} }