[sdl] Formatting pass.

This commit is contained in:
Mario Zechner 2022-08-02 10:46:28 +02:00
parent 2b69bb2af5
commit f3e03467b5
4 changed files with 199 additions and 198 deletions

View File

@ -53,7 +53,8 @@ int main() {
spAnimationStateData *animationStateData = spAnimationStateData_create(skeletonData); spAnimationStateData *animationStateData = spAnimationStateData_create(skeletonData);
spSkeletonDrawable *drawable = spSkeletonDrawable_create(skeletonData, animationStateData); spSkeletonDrawable *drawable = spSkeletonDrawable_create(skeletonData, animationStateData);
drawable->skeleton->x = 400; drawable->skeleton->y = 500; drawable->skeleton->x = 400;
drawable->skeleton->y = 500;
spSkeleton_setToSetupPose(drawable->skeleton); spSkeleton_setToSetupPose(drawable->skeleton);
spSkeletonDrawable_update(drawable, 0); spSkeletonDrawable_update(drawable, 0);
spAnimationState_setAnimationByName(drawable->animationState, 0, "run", -1); spAnimationState_setAnimationByName(drawable->animationState, 0, "run", -1);

View File

@ -67,7 +67,7 @@ void spSkeletonDrawable_update(spSkeletonDrawable *self, float delta) {
} }
void spSkeletonDrawable_draw(spSkeletonDrawable *self, struct SDL_Renderer *renderer) { void spSkeletonDrawable_draw(spSkeletonDrawable *self, struct SDL_Renderer *renderer) {
static unsigned short quadIndices[] = { 0, 1, 2, 2, 3, 0 }; static unsigned short quadIndices[] = {0, 1, 2, 2, 3, 0};
spSkeleton *skeleton = self->skeleton; spSkeleton *skeleton = self->skeleton;
spSkeletonClipping *clipper = self->clipper; spSkeletonClipping *clipper = self->clipper;
SDL_Texture *texture; SDL_Texture *texture;
@ -106,7 +106,7 @@ void spSkeletonDrawable_draw(spSkeletonDrawable *self, struct SDL_Renderer *rend
uvs = region->uvs; uvs = region->uvs;
indices = quadIndices; indices = quadIndices;
indicesCount = 6; indicesCount = 6;
texture = (SDL_Texture *) ((spAtlasRegion*)region->rendererObject)->page->rendererObject; texture = (SDL_Texture *) ((spAtlasRegion *) region->rendererObject)->page->rendererObject;
} else if (attachment->type == SP_ATTACHMENT_MESH) { } else if (attachment->type == SP_ATTACHMENT_MESH) {
spMeshAttachment *mesh = (spMeshAttachment *) attachment; spMeshAttachment *mesh = (spMeshAttachment *) attachment;
attachmentColor = &mesh->color; attachmentColor = &mesh->color;
@ -123,7 +123,7 @@ void spSkeletonDrawable_draw(spSkeletonDrawable *self, struct SDL_Renderer *rend
uvs = mesh->uvs; uvs = mesh->uvs;
indices = mesh->triangles; indices = mesh->triangles;
indicesCount = mesh->trianglesCount; indicesCount = mesh->trianglesCount;
texture = (SDL_Texture *) ((spAtlasRegion*)mesh->rendererObject)->page->rendererObject; texture = (SDL_Texture *) ((spAtlasRegion *) mesh->rendererObject)->page->rendererObject;
} else if (attachment->type == SP_ATTACHMENT_CLIPPING) { } else if (attachment->type == SP_ATTACHMENT_CLIPPING) {
spClippingAttachment *clip = (spClippingAttachment *) slot->attachment; spClippingAttachment *clip = (spClippingAttachment *) slot->attachment;
spSkeletonClipping_clipStart(clipper, slot, clip); spSkeletonClipping_clipStart(clipper, slot, clip);
@ -131,10 +131,10 @@ void spSkeletonDrawable_draw(spSkeletonDrawable *self, struct SDL_Renderer *rend
} else } else
continue; continue;
Uint8 r = (Uint8)(skeleton->color.r * slot->color.r * attachmentColor->r * 255); Uint8 r = (Uint8) (skeleton->color.r * slot->color.r * attachmentColor->r * 255);
Uint8 g = (Uint8)(skeleton->color.g * slot->color.g * attachmentColor->g * 255); Uint8 g = (Uint8) (skeleton->color.g * slot->color.g * attachmentColor->g * 255);
Uint8 b = (Uint8)(skeleton->color.b * slot->color.b * attachmentColor->b * 255); Uint8 b = (Uint8) (skeleton->color.b * slot->color.b * attachmentColor->b * 255);
Uint8 a = (Uint8)(skeleton->color.a * slot->color.a * attachmentColor->a * 255); Uint8 a = (Uint8) (skeleton->color.a * slot->color.a * attachmentColor->a * 255);
sdlVertex.color.r = r; sdlVertex.color.r = r;
sdlVertex.color.g = g; sdlVertex.color.g = g;
sdlVertex.color.b = b; sdlVertex.color.b = b;
@ -187,7 +187,7 @@ void _spAtlasPage_createTexture(spAtlasPage *self, const char *path) {
int width, height, components; int width, height, components;
stbi_uc *imageData = stbi_load(path, &width, &height, &components, 4); stbi_uc *imageData = stbi_load(path, &width, &height, &components, 4);
if (!imageData) return; if (!imageData) return;
SDL_Texture *texture = SDL_CreateTexture((SDL_Renderer*)self->atlas->rendererObject, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, width, SDL_Texture *texture = SDL_CreateTexture((SDL_Renderer *) self->atlas->rendererObject, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, width,
height); height);
if (!texture) { if (!texture) {
stbi_image_free(imageData); stbi_image_free(imageData);