mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
Get rid of GFX_NULL, just use 0
This commit is contained in:
parent
cb908ad026
commit
01d94cd3d8
@ -221,10 +221,8 @@ typedef struct TextureRec_ { float U1, V1, U2, V2; } TextureRec;
|
||||
|
||||
#ifdef CC_BUILD_D3D9
|
||||
typedef void* GfxResourceID;
|
||||
#define GFX_NULL NULL
|
||||
#else
|
||||
typedef cc_uintptr GfxResourceID;
|
||||
#define GFX_NULL 0
|
||||
#endif
|
||||
|
||||
/* Contains the information to describe a 2D textured quad. */
|
||||
|
@ -319,7 +319,7 @@ void Drawer2D_Clear(Bitmap* bmp, BitmapCol col, int x, int y, int width, int hei
|
||||
|
||||
|
||||
void Drawer2D_MakeTextTexture(struct Texture* tex, struct DrawTextArgs* args) {
|
||||
static struct Texture empty = { GFX_NULL, Tex_Rect(0,0, 0,0), Tex_UV(0,0, 1,1) };
|
||||
static struct Texture empty = { 0, Tex_Rect(0,0, 0,0), Tex_UV(0,0, 1,1) };
|
||||
Size2D size;
|
||||
Bitmap bmp;
|
||||
/* pointless to draw anything when context is lost */
|
||||
|
10
src/Entity.c
10
src/Entity.c
@ -145,7 +145,7 @@ void Entity_SetModel(struct Entity* e, const String* model) {
|
||||
|
||||
e->ModelBlock = BLOCK_AIR;
|
||||
e->Model = Model_Get(&name);
|
||||
e->MobTextureId = GFX_NULL;
|
||||
e->MobTextureId = 0;
|
||||
if (!e->Model) Entity_SetBlockModel(e, &name);
|
||||
|
||||
Entity_ParseScale(e, &scale);
|
||||
@ -247,7 +247,7 @@ static void Entity_MakeNameTexture(struct Entity* e) {
|
||||
size = Drawer2D_MeasureText(&args);
|
||||
|
||||
if (size.Width == 0) {
|
||||
e->NameTex.ID = GFX_NULL;
|
||||
e->NameTex.ID = 0;
|
||||
e->NameTex.X = NAME_IS_EMPTY;
|
||||
} else {
|
||||
String_InitArray(colorlessName, colorlessBuffer);
|
||||
@ -346,7 +346,7 @@ static void Entity_CopySkin(struct Entity* dst, struct Entity* src) {
|
||||
dst->vScale = src->vScale;
|
||||
|
||||
/* Custom mob textures */
|
||||
dst->MobTextureId = GFX_NULL;
|
||||
dst->MobTextureId = 0;
|
||||
skin = String_FromRawArray(dst->SkinNameRaw);
|
||||
if (Utils_IsUrlPrefix(&skin)) dst->MobTextureId = dst->TextureId;
|
||||
}
|
||||
@ -354,8 +354,8 @@ static void Entity_CopySkin(struct Entity* dst, struct Entity* src) {
|
||||
/* Resets skin data for the given entity */
|
||||
static void Entity_ResetSkin(struct Entity* e) {
|
||||
e->uScale = 1.0f; e->vScale = 1.0f;
|
||||
e->MobTextureId = GFX_NULL;
|
||||
e->TextureId = GFX_NULL;
|
||||
e->MobTextureId = 0;
|
||||
e->TextureId = 0;
|
||||
e->SkinType = SKIN_64x32;
|
||||
}
|
||||
|
||||
|
@ -298,10 +298,10 @@ static void D3D9_RestoreRenderStates(void);
|
||||
static void D3D9_FreeResource(GfxResourceID* resource) {
|
||||
IUnknown* unk;
|
||||
ULONG refCount;
|
||||
|
||||
if (*resource == GFX_NULL) return;
|
||||
|
||||
unk = (IUnknown*)(*resource);
|
||||
*resource = GFX_NULL;
|
||||
if (!unk) return;
|
||||
*resource = 0;
|
||||
|
||||
#ifdef __cplusplus
|
||||
refCount = unk->Release();
|
||||
@ -508,7 +508,7 @@ GfxResourceID Gfx_CreateTexture(Bitmap* bmp, cc_bool managedPool, cc_bool mipmap
|
||||
if (!Math_IsPowOf2(bmp->Width) || !Math_IsPowOf2(bmp->Height)) {
|
||||
Logger_Abort("Textures must have power of two dimensions");
|
||||
}
|
||||
if (Gfx.LostContext) return GFX_NULL;
|
||||
if (Gfx.LostContext) return 0;
|
||||
|
||||
if (managedPool) {
|
||||
res = IDirect3DDevice9_CreateTexture(device, bmp->Width, bmp->Height, levels,
|
||||
@ -1086,7 +1086,7 @@ GfxResourceID Gfx_CreateTexture(Bitmap* bmp, cc_bool managedPool, cc_bool mipmap
|
||||
if (!Math_IsPowOf2(bmp->Width) || !Math_IsPowOf2(bmp->Height)) {
|
||||
Logger_Abort("Textures must have power of two dimensions");
|
||||
}
|
||||
if (Gfx.LostContext) return GFX_NULL;
|
||||
if (Gfx.LostContext) return 0;
|
||||
|
||||
if (mipmaps) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
|
||||
@ -1115,10 +1115,10 @@ void Gfx_BindTexture(GfxResourceID texId) {
|
||||
}
|
||||
|
||||
void Gfx_DeleteTexture(GfxResourceID* texId) {
|
||||
if (*texId == GFX_NULL) return;
|
||||
GLuint id = (GLuint)(*texId);
|
||||
if (!id) return;
|
||||
glDeleteTextures(1, &id);
|
||||
*texId = GFX_NULL;
|
||||
*texId = 0;
|
||||
}
|
||||
|
||||
void Gfx_EnableMipmaps(void) { }
|
||||
@ -1194,17 +1194,17 @@ void Gfx_BindVb(GfxResourceID vb) { _glBindBuffer(GL_ARRAY_BUFFER, (GLuint)vb);
|
||||
void Gfx_BindIb(GfxResourceID ib) { _glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, (GLuint)ib); }
|
||||
|
||||
void Gfx_DeleteVb(GfxResourceID* vb) {
|
||||
if (*vb == GFX_NULL) return;
|
||||
GLuint id = (GLuint)(*vb);
|
||||
if (!id) return;
|
||||
_glDeleteBuffers(1, &id);
|
||||
*vb = GFX_NULL;
|
||||
*vb = 0;
|
||||
}
|
||||
|
||||
void Gfx_DeleteIb(GfxResourceID* ib) {
|
||||
if (*ib == GFX_NULL) return;
|
||||
GLuint id = (GLuint)(*ib);
|
||||
if (!id) return;
|
||||
_glDeleteBuffers(1, &id);
|
||||
*ib = GFX_NULL;
|
||||
*ib = 0;
|
||||
}
|
||||
|
||||
void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, int vCount) {
|
||||
@ -1910,15 +1910,16 @@ GfxResourceID Gfx_CreateVb(void* vertices, VertexFormat fmt, int count) {
|
||||
return list;
|
||||
}
|
||||
|
||||
GfxResourceID Gfx_CreateIb(void* indices, int indicesCount) { return GFX_NULL; }
|
||||
GfxResourceID Gfx_CreateIb(void* indices, int indicesCount) { return 0; }
|
||||
void Gfx_BindVb(GfxResourceID vb) { gfx_activeList = (GLuint)vb; }
|
||||
void Gfx_BindIb(GfxResourceID ib) { }
|
||||
void Gfx_DeleteIb(GfxResourceID* ib) { }
|
||||
|
||||
void Gfx_DeleteVb(GfxResourceID* vb) {
|
||||
if (*vb == GFX_NULL) return;
|
||||
if (*vb != gl_DYNAMICLISTID) glDeleteLists((GLuint)(*vb), 1);
|
||||
*vb = GFX_NULL;
|
||||
GLuint id = (GLuint)(*vb);
|
||||
if (!id) return;
|
||||
if (id != gl_DYNAMICLISTID) glDeleteLists(id, 1);
|
||||
*vb = 0;
|
||||
}
|
||||
|
||||
void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, int vCount) {
|
||||
|
@ -55,7 +55,7 @@ CC_API GfxResourceID Gfx_CreateTexture(Bitmap* bmp, cc_bool managedPool, cc_bool
|
||||
CC_API void Gfx_UpdateTexturePart(GfxResourceID texId, int x, int y, Bitmap* part, cc_bool mipmaps);
|
||||
/* Sets the currently active texture. */
|
||||
CC_API void Gfx_BindTexture(GfxResourceID texId);
|
||||
/* Deletes the given texture, then sets it to GFX_NULL. */
|
||||
/* Deletes the given texture, then sets it to 0. */
|
||||
CC_API void Gfx_DeleteTexture(GfxResourceID* texId);
|
||||
/* Sets whether texture colour is used when rendering vertices. */
|
||||
CC_API void Gfx_SetTexturing(cc_bool enabled);
|
||||
@ -109,9 +109,9 @@ CC_API GfxResourceID Gfx_CreateIb(void* indices, int indicesCount);
|
||||
CC_API void Gfx_BindVb(GfxResourceID vb);
|
||||
/* Sets the currently active index buffer. */
|
||||
CC_API void Gfx_BindIb(GfxResourceID ib);
|
||||
/* Deletes the given vertex buffer, then sets it to GFX_NULL. */
|
||||
/* Deletes the given vertex buffer, then sets it to 0. */
|
||||
CC_API void Gfx_DeleteVb(GfxResourceID* vb);
|
||||
/* Deletes the given index buffer, then sets it to GFX_NULL. */
|
||||
/* Deletes the given index buffer, then sets it to 0. */
|
||||
CC_API void Gfx_DeleteIb(GfxResourceID* ib);
|
||||
|
||||
/* Sets the format of the rendered vertices. */
|
||||
|
@ -485,7 +485,7 @@ static void ChatScreen_ChatReceived(void* screen, const String* msg, int type) {
|
||||
}
|
||||
|
||||
static void ChatScreen_DrawCrosshairs(void) {
|
||||
static struct Texture tex = { GFX_NULL, Tex_Rect(0,0,0,0), Tex_UV(0.0f,0.0f, 15/256.0f,15/256.0f) };
|
||||
static struct Texture tex = { 0, Tex_Rect(0,0,0,0), Tex_UV(0.0f,0.0f, 15/256.0f,15/256.0f) };
|
||||
int extent;
|
||||
if (!Gui_IconsTex) return;
|
||||
|
||||
@ -1095,7 +1095,7 @@ static void LoadingScreen_DrawBackground(void) {
|
||||
cc_bool bound = false;
|
||||
|
||||
loc = Block_Tex(BLOCK_DIRT, FACE_YMAX);
|
||||
tex.ID = GFX_NULL;
|
||||
tex.ID = 0;
|
||||
Tex_SetRect(tex, 0,0, Window_Width,LOADING_TILE_SIZE);
|
||||
tex.uv = Atlas1D_TexRec(loc, 1, &atlasIndex);
|
||||
tex.uv.U2 = (float)Window_Width / LOADING_TILE_SIZE;
|
||||
|
@ -477,7 +477,7 @@ void Atlas_Update(Bitmap* bmp) {
|
||||
static GfxResourceID Atlas_LoadTile_Raw(TextureLoc texLoc, Bitmap* element) {
|
||||
int size = Atlas2D.TileSize;
|
||||
int x = Atlas2D_TileX(texLoc), y = Atlas2D_TileY(texLoc);
|
||||
if (y >= Atlas2D.RowsCount) return GFX_NULL;
|
||||
if (y >= Atlas2D.RowsCount) return 0;
|
||||
|
||||
Bitmap_UNSAFE_CopyBlock(x * size, y * size, 0, 0, &Atlas2D.Bmp, element, size);
|
||||
return Gfx_CreateTexture(element, false, Gfx.Mipmaps);
|
||||
|
@ -50,10 +50,9 @@ static const struct WidgetVTABLE TextWidget_VTABLE = {
|
||||
Widget_Pointer, Widget_Pointer, Widget_PointerMove
|
||||
};
|
||||
void TextWidget_Make(struct TextWidget* w, cc_uint8 horAnchor, cc_uint8 verAnchor, int xOffset, int yOffset) {
|
||||
PackedCol col = PACKEDCOL_WHITE;
|
||||
Widget_Reset(w);
|
||||
w->VTABLE = &TextWidget_VTABLE;
|
||||
w->col = col;
|
||||
w->col = PACKEDCOL_WHITE;
|
||||
Widget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset);
|
||||
}
|
||||
|
||||
@ -84,9 +83,9 @@ void TextWidget_SetConst(struct TextWidget* w, const char* text, struct FontDesc
|
||||
*#########################################################################################################################*/
|
||||
#define BUTTON_uWIDTH (200.0f / 256.0f)
|
||||
|
||||
static struct Texture btnShadowTex = { GFX_NULL, Tex_Rect(0,0, 0,0), Widget_UV(0,66, 200,86) };
|
||||
static struct Texture btnSelectedTex = { GFX_NULL, Tex_Rect(0,0, 0,0), Widget_UV(0,86, 200,106) };
|
||||
static struct Texture btnDisabledTex = { GFX_NULL, Tex_Rect(0,0, 0,0), Widget_UV(0,46, 200,66) };
|
||||
static struct Texture btnShadowTex = { 0, Tex_Rect(0,0, 0,0), Widget_UV(0,66, 200,86) };
|
||||
static struct Texture btnSelectedTex = { 0, Tex_Rect(0,0, 0,0), Widget_UV(0,86, 200,106) };
|
||||
static struct Texture btnDisabledTex = { 0, Tex_Rect(0,0, 0,0), Widget_UV(0,46, 200,66) };
|
||||
static int btnMinHeight;
|
||||
|
||||
static void ButtonWidget_Free(void* widget) {
|
||||
@ -1846,7 +1845,7 @@ static void PlayerListWidget_DeleteAt(struct PlayerListWidget* w, int i) {
|
||||
|
||||
w->namesCount--;
|
||||
w->ids[w->namesCount] = 0;
|
||||
w->textures[w->namesCount].ID = GFX_NULL;
|
||||
w->textures[w->namesCount].ID = 0;
|
||||
}
|
||||
|
||||
static void PlayerListWidget_AddGroup(struct PlayerListWidget* w, int id, int* index) {
|
||||
@ -2077,7 +2076,7 @@ void TextGroupWidget_ShiftUp(struct TextGroupWidget* w) {
|
||||
for (i = 0; i < last; i++) {
|
||||
w->textures[i] = w->textures[i + 1];
|
||||
}
|
||||
w->textures[last].ID = GFX_NULL; /* Delete() called by TextGroupWidget_Redraw otherwise */
|
||||
w->textures[last].ID = 0; /* Gfx_DeleteTexture() called by TextGroupWidget_Redraw otherwise */
|
||||
TextGroupWidget_Redraw(w, last);
|
||||
}
|
||||
|
||||
@ -2089,7 +2088,7 @@ void TextGroupWidget_ShiftDown(struct TextGroupWidget* w) {
|
||||
for (i = last; i > 0; i--) {
|
||||
w->textures[i] = w->textures[i - 1];
|
||||
}
|
||||
w->textures[0].ID = GFX_NULL; /* Delete() called by TextGroupWidget_Redraw otherwise */
|
||||
w->textures[0].ID = 0; /* Gfx_DeleteTexture() called by TextGroupWidget_Redraw otherwise */
|
||||
TextGroupWidget_Redraw(w, 0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user