started working on graphics config
This commit is contained in:
parent
585768f33d
commit
13ef683164
5 changed files with 69 additions and 67 deletions
|
|
@ -1,68 +1,45 @@
|
|||
#include "arc/graphics/config.h"
|
||||
|
||||
//#include <SDL_image.h>
|
||||
//#include <stdio.h>
|
||||
//#include "renderer.h"
|
||||
//#include "sprite.h"
|
||||
//#include "spritesheet.h"
|
||||
//#include "arc/std/array.h"
|
||||
//#include "arc/std/string.h"
|
||||
//#include "arc/std/errno.h"
|
||||
//#include "arc/graphics/sprite.h"
|
||||
//#include "arc/graphics/spritesheet.h"
|
||||
//#include "arc/math/config.h"
|
||||
//#include "arc/math/point.h"
|
||||
//#include "arc/math/rectangle.h"
|
||||
#include <SDL_image.h>
|
||||
#include <stdio.h>
|
||||
#include "renderer.h"
|
||||
#include "sprite.h"
|
||||
#include "spritesheet.h"
|
||||
#include "arc/std/array.h"
|
||||
#include "arc/std/string.h"
|
||||
#include "arc/std/errno.h"
|
||||
#include "arc/graphics/sprite.h"
|
||||
#include "arc/graphics/spritesheet.h"
|
||||
#include "arc/math/config.h"
|
||||
#include "arc/math/point.h"
|
||||
#include "arc/math/rectangle.h"
|
||||
|
||||
// #define ARC_DEFAULT_CONFIG
|
||||
//#include "arc/std/defaults/config.h"
|
||||
|
||||
//SDL_Renderer *global_renderer;
|
||||
//
|
||||
//uint8_t ARC_SDL_Texture_Read(ARC_Config *config, ARC_String *string, void **value);
|
||||
//uint8_t ARC_Spritesheet_Read(ARC_Config *config, ARC_String *string, void **value);
|
||||
//uint8_t ARC_Sprite_Read (ARC_Config *config, ARC_String *string, void **value);
|
||||
//
|
||||
//void ARC_SDL_Texture_Delete(ARC_Config *config, ARC_String *string, void *value);
|
||||
//void ARC_Spritesheet_Delete(ARC_Config *config, ARC_String *string, void *value);
|
||||
//void ARC_Sprite_Delete (ARC_Config *config, ARC_String *string, void *value);
|
||||
//
|
||||
//void ARC_GraphicsConfig_Init(ARC_Config *config, ARC_Renderer *renderer){
|
||||
// global_renderer = (SDL_Renderer *)renderer;
|
||||
// ARC_Config_AddKeyCString(config, (char *)"SDL_Texture" , 11, ARC_SDL_Texture_Read, ARC_SDL_Texture_Delete);
|
||||
// ARC_Config_AddKeyCString(config, (char *)"ARC_Spritesheet", 15, ARC_Spritesheet_Read, ARC_Spritesheet_Delete);
|
||||
// ARC_Config_AddKeyCString(config, (char *)"ARC_Sprite" , 10, ARC_Sprite_Read , ARC_Sprite_Delete );
|
||||
//}
|
||||
//
|
||||
//uint64_t ARC_GraphicsConfig_GetIndexAndErrorCheck(ARC_String *string, char *search, uint64_t searchLength){
|
||||
// uint64_t separator = ARC_String_FindCString(string, ",", 1);
|
||||
//
|
||||
// if(separator == ~(uint64_t)0){
|
||||
// arc_errno = ARC_ERRNO_DATA;
|
||||
// }
|
||||
//
|
||||
// return separator;
|
||||
//}
|
||||
//
|
||||
//int32_t ARC_SDL_Texture_Load(const char *path, SDL_Texture **texture){
|
||||
// IMG_Init(IMG_INIT_PNG);
|
||||
// SDL_Surface *surface = IMG_Load(path);
|
||||
// if(!surface){
|
||||
// printf("Error: reading png '%s'\nSDL_Image Error: %s", path, IMG_GetError());
|
||||
// return 1; // GE_SDL_ERRNO_
|
||||
// }
|
||||
//
|
||||
// SDL_BlendMode tempMode;
|
||||
// SDL_GetSurfaceBlendMode(surface, &tempMode);
|
||||
// *texture = SDL_CreateTextureFromSurface(global_renderer, surface);
|
||||
// SDL_GetTextureBlendMode(*texture, &tempMode);
|
||||
//
|
||||
// SDL_FreeSurface(surface);
|
||||
// IMG_Quit();
|
||||
//
|
||||
// return 0;
|
||||
//}
|
||||
//
|
||||
void ARC_Config_InitGraphics(ARC_Config *config, ARC_Renderer *renderer){
|
||||
//ARC_Config_AddKeyCString(config, (char *)"SDL_Texture" , 11, ARC_SDL_Texture_Read, ARC_SDL_Texture_Delete);
|
||||
ARC_Config_RegisterTypeWithCStr(config, "ARC_Spritesheet", (ARC_ConfigType){ ARC_ConfigType_SpritesheetCopyFn, ARC_ConfigType_SpritesheetDestroyFn, renderer});
|
||||
ARC_Config_RegisterTypeWithCStr(config, "ARC_Sprite" , (ARC_ConfigType){ ARC_ConfigType_SpriteCopyFn , ARC_ConfigType_SpriteDestroyFn , renderer});
|
||||
}
|
||||
|
||||
int32_t ARC_SDL_Texture_Load(SDL_Texture **texture, ARC_Renderer *renderer, const char *path){
|
||||
IMG_Init(IMG_INIT_PNG);
|
||||
SDL_Surface *surface = IMG_Load(path);
|
||||
if(!surface){
|
||||
printf("Error: reading png '%s'\nSDL_Image Error: %s", path, IMG_GetError());
|
||||
return 1; // GE_SDL_ERRNO_
|
||||
}
|
||||
|
||||
SDL_BlendMode tempMode;
|
||||
SDL_GetSurfaceBlendMode(surface, &tempMode);
|
||||
*texture = SDL_CreateTextureFromSurface((SDL_Renderer *)renderer, surface);
|
||||
SDL_GetTextureBlendMode(*texture, &tempMode);
|
||||
|
||||
SDL_FreeSurface(surface);
|
||||
IMG_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//uint8_t ARC_SDL_Texture_Read(ARC_Config* config, ARC_String *string, void **value){
|
||||
// ARC_Config_Get(config, string, value);
|
||||
// if(*value){
|
||||
|
|
@ -80,7 +57,7 @@
|
|||
// ARC_String_Destroy(textureStr);
|
||||
// return 0;
|
||||
//}
|
||||
//
|
||||
|
||||
//void ARC_Spritesheet_ReadTexture(ARC_Config *config, ARC_String *string, uint32_t *size, void **value){
|
||||
// SDL_Texture *texture;
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue