C client: eliminate a few warnings, simplify 2D to 1D array atlas conversion

This commit is contained in:
UnknownShadow200 2018-09-19 12:04:05 +10:00
parent 10863b830c
commit 9ac3e5c302
5 changed files with 33 additions and 40 deletions

View file

@ -204,7 +204,6 @@ static void Animations_ReadDescription(struct Stream* stream, STRING_PURE String
}
}
/* TODO: should we use 128 size here? */
#define ANIMS_FAST_SIZE 64
static void Animations_Draw(struct AnimationData* data, TextureLoc texLoc, Int32 size) {
UInt8 buffer[Bitmap_DataSize(ANIMS_FAST_SIZE, ANIMS_FAST_SIZE)];
@ -216,7 +215,7 @@ static void Animations_Draw(struct AnimationData* data, TextureLoc texLoc, Int32
Int32 index_1D = Atlas1D_Index(texLoc);
Int32 rowId_1D = Atlas1D_RowId(texLoc);
Bitmap animPart; Bitmap_Create(&animPart, size, size, buffer);
Bitmap animPart; Bitmap_Create(&animPart, size, size, ptr);
if (!data) {
if (texLoc == 30) {

View file

@ -2116,8 +2116,8 @@ static void MenuOptionsScreen_Enum(void* screen, void* widget) {
MenuOptionsScreen_SelectExtHelp(s, index);
struct MenuInputValidator* v = &s->Validators[index];
const char** names = (const char**)v->Meta_Ptr[0];
UInt32 count = (UInt32)v->Meta_Ptr[1];
const char** names = v->Meta_Enum.Names;
UInt32 count = v->Meta_Enum.Count;
char valueBuffer[STRING_SIZE];
String value = String_FromArray(valueBuffer);

View file

@ -50,7 +50,7 @@ TextureRec Atlas1D_TexRec(TextureLoc texLoc, Int32 uCount, Int32* index) {
*index = Atlas1D_Index(texLoc);
Int32 y = Atlas1D_RowId(texLoc);
/* Adjust coords to be slightly inside - fixes issues with AMD/ATI cards. */
/* Adjust coords to be slightly inside - fixes issues with AMD/ATI cards */
TextureRec rec;
rec.U1 = 0.0f;
rec.V1 = y * Atlas1D_InvTileSize;
@ -59,33 +59,26 @@ TextureRec Atlas1D_TexRec(TextureLoc texLoc, Int32 uCount, Int32* index) {
return rec;
}
static void Atlas1D_Make1DTexture(Int32 i, Int32 atlas1DHeight, Int32* index) {
Int32 tileSize = Atlas2D_TileSize;
Bitmap atlas1D;
Bitmap_Allocate(&atlas1D, tileSize, atlas1DHeight);
Int32 index1D;
for (index1D = 0; index1D < Atlas1D_TilesPerAtlas; index1D++) {
Int32 atlasX = Atlas2D_TileX(*index) * tileSize;
Int32 atlasY = Atlas2D_TileY(*index) * tileSize;
Bitmap_CopyBlock(atlasX, atlasY, 0, index1D * tileSize,
&Atlas2D_Bitmap, &atlas1D, tileSize);
(*index)++;
}
Atlas1D_TexIds[i] = Gfx_CreateTexture(&atlas1D, true, Gfx_Mipmaps);
Mem_Free(atlas1D.Scan0);
}
static void Atlas1D_Convert2DTo1D(Int32 atlasesCount, Int32 atlas1DHeight) {
Atlas1D_Count = atlasesCount;
Platform_Log2("Loaded new atlas: %i bmps, %i per bmp", &atlasesCount, &Atlas1D_TilesPerAtlas);
Int32 index = 0, i;
Int32 tileSize = Atlas2D_TileSize;
Bitmap atlas1D;
Bitmap_Allocate(&atlas1D, tileSize, atlas1DHeight);
Int32 tile = 0, i, y;
for (i = 0; i < atlasesCount; i++) {
Atlas1D_Make1DTexture(i, atlas1DHeight, &index);
for (y = 0; y < Atlas1D_TilesPerAtlas; y++, tile++) {
Int32 atlasX = Atlas2D_TileX(tile) * tileSize;
Int32 atlasY = Atlas2D_TileY(tile) * tileSize;
Bitmap_CopyBlock(atlasX, atlasY, 0, y * tileSize,
&Atlas2D_Bitmap, &atlas1D, tileSize);
}
Atlas1D_TexIds[i] = Gfx_CreateTexture(&atlas1D, true, Gfx_Mipmaps);
}
Mem_Free(atlas1D.Scan0);
}
void Atlas1D_UpdateState(void) {

View file

@ -1302,7 +1302,7 @@ struct MenuInputValidator MenuInputValidator_Hex(void) {
}
static void Integer_Range(struct MenuInputValidator* v, STRING_TRANSIENT String* range) {
String_Format2(range, "&7(%i - %i)", &v->Meta_Int[0], &v->Meta_Int[1]);
String_Format2(range, "&7(%i - %i)", &v->Meta_Int.Min, &v->Meta_Int.Max);
}
static bool Integer_ValidChar(struct MenuInputValidator* v, char c) {
@ -1319,7 +1319,7 @@ static bool Integer_ValidValue(struct MenuInputValidator* v, STRING_PURE String*
Int32 value;
if (!Convert_TryParseInt32(s, &value)) return false;
Int32 min = v->Meta_Int[0], max = v->Meta_Int[1];
Int32 min = v->Meta_Int.Min, max = v->Meta_Int.Max;
return min <= value && value <= max;
}
@ -1329,8 +1329,8 @@ struct MenuInputValidatorVTABLE IntegerInputValidator_VTABLE = {
struct MenuInputValidator MenuInputValidator_Integer(Int32 min, Int32 max) {
struct MenuInputValidator v;
v.VTABLE = &IntegerInputValidator_VTABLE;
v.Meta_Int[0] = min;
v.Meta_Int[1] = max;
v.Meta_Int.Min = min;
v.Meta_Int.Max = max;
return v;
}
@ -1348,7 +1348,7 @@ struct MenuInputValidator MenuInputValidator_Seed(void) {
}
static void Real_Range(struct MenuInputValidator* v, STRING_TRANSIENT String* range) {
String_Format2(range, "&7(%f2 - %f2)", &v->Meta_Real[0], &v->Meta_Real[1]);
String_Format2(range, "&7(%f2 - %f2)", &v->Meta_Real.Min, &v->Meta_Real.Max);
}
static bool Real_ValidChar(struct MenuInputValidator* v, char c) {
@ -1364,7 +1364,7 @@ static bool Real_ValidString(struct MenuInputValidator* v, STRING_PURE String* s
static bool Real_ValidValue(struct MenuInputValidator* v, STRING_PURE String* s) {
Real32 value;
if (!Convert_TryParseReal32(s, &value)) return false;
Real32 min = v->Meta_Real[0], max = v->Meta_Real[1];
Real32 min = v->Meta_Real.Min, max = v->Meta_Real.Max;
return min <= value && value <= max;
}
@ -1374,8 +1374,8 @@ struct MenuInputValidatorVTABLE RealInputValidator_VTABLE = {
struct MenuInputValidator MenuInputValidator_Real(Real32 min, Real32 max) {
struct MenuInputValidator v;
v.VTABLE = &RealInputValidator_VTABLE;
v.Meta_Real[0] = min;
v.Meta_Real[1] = max;
v.Meta_Real.Min = min;
v.Meta_Real.Max = max;
return v;
}
@ -1399,9 +1399,10 @@ struct MenuInputValidator MenuInputValidator_Path(void) {
}
struct MenuInputValidator MenuInputValidator_Enum(const char** names, UInt32 namesCount) {
struct MenuInputValidator v = { 0 };
v.Meta_Ptr[0] = names;
v.Meta_Ptr[1] = (void*)namesCount; /* TODO: Need to handle void* size < 32 bits?? */
struct MenuInputValidator v;
v.VTABLE = NULL;
v.Meta_Enum.Names = names;
v.Meta_Enum.Count = namesCount;
return v;
}

View file

@ -122,9 +122,9 @@ struct MenuInputValidatorVTABLE {
struct MenuInputValidator {
struct MenuInputValidatorVTABLE* VTABLE;
union {
void* Meta_Ptr[2];
Int32 Meta_Int[2];
Real32 Meta_Real[2];
struct { const char** Names; UInt32 Count; } Meta_Enum;
struct { Int32 Min, Max; } Meta_Int;
struct { Real32 Min, Max; } Meta_Real;
};
};