mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 17:17:09 -04:00
Unify texture creation checking, and defer dynamic vertex buffer allocation for rain/snow until actually needed
This commit is contained in:
parent
4bb4f89781
commit
3fa4ef6d44
@ -451,7 +451,11 @@ void EnvRenderer_RenderWeather(double deltaTime) {
|
|||||||
|
|
||||||
weather = Env.Weather;
|
weather = Env.Weather;
|
||||||
if (weather == WEATHER_SUNNY) return;
|
if (weather == WEATHER_SUNNY) return;
|
||||||
if (!Weather_Heightmap) InitWeatherHeightmap();
|
|
||||||
|
if (!Weather_Heightmap)
|
||||||
|
InitWeatherHeightmap();
|
||||||
|
if (!weather_vb)
|
||||||
|
weather_vb = Gfx_CreateDynamicVb(VERTEX_FORMAT_TEXTURED, WEATHER_VERTS_COUNT);
|
||||||
|
|
||||||
IVec3_Floor(&pos, &Camera.CurrentPos);
|
IVec3_Floor(&pos, &Camera.CurrentPos);
|
||||||
moved = pos.X != lastPos.X || pos.Y != lastPos.Y || pos.Z != lastPos.Z;
|
moved = pos.X != lastPos.X || pos.Y != lastPos.Y || pos.Z != lastPos.Z;
|
||||||
@ -834,9 +838,8 @@ static void UpdateAll(void) {
|
|||||||
EnvRenderer_UpdateFog();
|
EnvRenderer_UpdateFog();
|
||||||
|
|
||||||
Gfx_DeleteDynamicVb(&weather_vb);
|
Gfx_DeleteDynamicVb(&weather_vb);
|
||||||
|
/* TODO: Unnecessary to delete the weather VB? */
|
||||||
if (Gfx.LostContext) return;
|
if (Gfx.LostContext) return;
|
||||||
/* TODO: Don't allocate unless used? */
|
|
||||||
Gfx_RecreateDynamicVb(&weather_vb, VERTEX_FORMAT_TEXTURED, WEATHER_VERTS_COUNT);
|
|
||||||
/* TODO: Don't need to do this on every new map */
|
/* TODO: Don't need to do this on every new map */
|
||||||
UpdateBorderTextures();
|
UpdateBorderTextures();
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ static void ToMortonTexture(C3D_Tex* tex, int originX, int originY,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
C3D_Tex* tex = Mem_Alloc(1, sizeof(C3D_Tex), "GPU texture desc");
|
C3D_Tex* tex = Mem_Alloc(1, sizeof(C3D_Tex), "GPU texture desc");
|
||||||
bool success = C3D_TexInit(tex, bmp->width, bmp->height, GPU_RGBA8);
|
bool success = C3D_TexInit(tex, bmp->width, bmp->height, GPU_RGBA8);
|
||||||
//if (!success) Logger_Abort("Failed to create 3DS texture");
|
//if (!success) Logger_Abort("Failed to create 3DS texture");
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#ifdef CC_BUILD_D3D11
|
#ifdef CC_BUILD_D3D11
|
||||||
#include "_GraphicsBase.h"
|
#include "_GraphicsBase.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "Logger.h"
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "_D3D11Shaders.h"
|
#include "_D3D11Shaders.h"
|
||||||
|
|
||||||
@ -202,16 +201,11 @@ static void D3D11_DoMipmaps(ID3D11Resource* texture, int x, int y, struct Bitmap
|
|||||||
if (prev != bmp->scan0) Mem_Free(prev);
|
if (prev != bmp->scan0) Mem_Free(prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
ID3D11Texture2D* tex = NULL;
|
ID3D11Texture2D* tex = NULL;
|
||||||
ID3D11ShaderResourceView* view = NULL;
|
ID3D11ShaderResourceView* view = NULL;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
if (!Math_IsPowOf2(bmp->width) || !Math_IsPowOf2(bmp->height)) {
|
|
||||||
Logger_Abort("Textures must have power of two dimensions");
|
|
||||||
}
|
|
||||||
if (Gfx.LostContext) return 0;
|
|
||||||
|
|
||||||
D3D11_TEXTURE2D_DESC desc = { 0 };
|
D3D11_TEXTURE2D_DESC desc = { 0 };
|
||||||
desc.Width = bmp->width;
|
desc.Width = bmp->width;
|
||||||
desc.Height = bmp->height;
|
desc.Height = bmp->height;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#ifdef CC_BUILD_D3D9
|
#ifdef CC_BUILD_D3D9
|
||||||
#include "_GraphicsBase.h"
|
#include "_GraphicsBase.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "Logger.h"
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
/* Avoid pointless includes */
|
/* Avoid pointless includes */
|
||||||
@ -19,7 +18,7 @@
|
|||||||
/* https://docs.microsoft.com/en-us/windows/win32/dxtecharts/the-direct3d-transformation-pipeline */
|
/* https://docs.microsoft.com/en-us/windows/win32/dxtecharts/the-direct3d-transformation-pipeline */
|
||||||
|
|
||||||
/* https://docs.microsoft.com/en-us/windows/win32/direct3d9/d3dfvf-texcoordsizen */
|
/* https://docs.microsoft.com/en-us/windows/win32/direct3d9/d3dfvf-texcoordsizen */
|
||||||
static DWORD d3d9_formatMappings[2] = { D3DFVF_XYZ | D3DFVF_DIFFUSE, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 };
|
static DWORD d3d9_formatMappings[] = { D3DFVF_XYZ | D3DFVF_DIFFUSE, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 };
|
||||||
/* Current format and size of vertices */
|
/* Current format and size of vertices */
|
||||||
static int gfx_stride, gfx_format = -1;
|
static int gfx_stride, gfx_format = -1;
|
||||||
|
|
||||||
@ -332,18 +331,13 @@ static IDirect3DTexture9* DoCreateTexture(struct Bitmap* bmp, int levels, int po
|
|||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
IDirect3DTexture9* tex;
|
IDirect3DTexture9* tex;
|
||||||
IDirect3DTexture9* sys;
|
IDirect3DTexture9* sys;
|
||||||
cc_result res;
|
cc_result res;
|
||||||
|
|
||||||
int mipmapsLevels = CalcMipmapsLevels(bmp->width, bmp->height);
|
int mipmapsLevels = CalcMipmapsLevels(bmp->width, bmp->height);
|
||||||
int levels = 1 + (mipmaps ? mipmapsLevels : 0);
|
int levels = 1 + (mipmaps ? mipmapsLevels : 0);
|
||||||
|
|
||||||
if (!Math_IsPowOf2(bmp->width) || !Math_IsPowOf2(bmp->height)) {
|
|
||||||
Logger_Abort("Textures must have power of two dimensions");
|
|
||||||
}
|
|
||||||
if (Gfx.LostContext) return 0;
|
|
||||||
|
|
||||||
if (flags & TEXTURE_FLAG_MANAGED) {
|
if (flags & TEXTURE_FLAG_MANAGED) {
|
||||||
while ((res = IDirect3DDevice9_CreateTexture(device, bmp->width, bmp->height, levels,
|
while ((res = IDirect3DDevice9_CreateTexture(device, bmp->width, bmp->height, levels,
|
||||||
|
@ -319,12 +319,9 @@ static void ConvertTexture(cc_uint16* dst, struct Bitmap* bmp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
GLuint texId = gldcGenTexture();
|
GLuint texId = gldcGenTexture();
|
||||||
gldcBindTexture(texId);
|
gldcBindTexture(texId);
|
||||||
if (!Math_IsPowOf2(bmp->width) || !Math_IsPowOf2(bmp->height)) {
|
|
||||||
Logger_Abort("Textures must have power of two dimensions");
|
|
||||||
}
|
|
||||||
|
|
||||||
gldcAllocTexture(bmp->width, bmp->height, GL_RGBA,
|
gldcAllocTexture(bmp->width, bmp->height, GL_RGBA,
|
||||||
GL_UNSIGNED_SHORT_4_4_4_4_REV_TWID_KOS);
|
GL_UNSIGNED_SHORT_4_4_4_4_REV_TWID_KOS);
|
||||||
@ -335,6 +332,7 @@ GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipm
|
|||||||
ConvertTexture(pixels, bmp);
|
ConvertTexture(pixels, bmp);
|
||||||
return texId;
|
return texId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: struct GPUTexture ??
|
// TODO: struct GPUTexture ??
|
||||||
static void ConvertSubTexture(cc_uint16* dst, int texWidth, int texHeight,
|
static void ConvertSubTexture(cc_uint16* dst, int texWidth, int texHeight,
|
||||||
int originX, int originY,
|
int originX, int originY,
|
||||||
|
@ -136,7 +136,7 @@ static void ReorderPixels(CCTexture* tex, struct Bitmap* bmp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
if (bmp->width < 4 || bmp->height < 4) {
|
if (bmp->width < 4 || bmp->height < 4) {
|
||||||
Platform_LogConst("ERROR: Tried to create texture smaller than 4x4");
|
Platform_LogConst("ERROR: Tried to create texture smaller than 4x4");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#if defined CC_BUILD_GL && !defined CC_BUILD_GLMODERN
|
#if defined CC_BUILD_GL && !defined CC_BUILD_GLMODERN
|
||||||
#include "_GraphicsBase.h"
|
#include "_GraphicsBase.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "Logger.h"
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
/* The OpenGL backend is a bit of a mess, since it's really 2 backends in one:
|
/* The OpenGL backend is a bit of a mess, since it's really 2 backends in one:
|
||||||
* - OpenGL 1.1 (completely lacking GPU, fallbacks to say Windows built-in software rasteriser)
|
* - OpenGL 1.1 (completely lacking GPU, fallbacks to say Windows built-in software rasteriser)
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#if defined CC_BUILD_GL && defined CC_BUILD_GLMODERN
|
#if defined CC_BUILD_GL && defined CC_BUILD_GLMODERN
|
||||||
#include "_GraphicsBase.h"
|
#include "_GraphicsBase.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "Logger.h"
|
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
/* OpenGL 2.0 backend (alternative modern-ish backend) */
|
/* OpenGL 2.0 backend (alternative modern-ish backend) */
|
||||||
|
|
||||||
|
@ -568,7 +568,7 @@ typedef struct CCTexture_ {
|
|||||||
cc_uint32 pixels[];
|
cc_uint32 pixels[];
|
||||||
} CCTexture;
|
} CCTexture;
|
||||||
|
|
||||||
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
int size = bmp->width * bmp->height * 4;
|
int size = bmp->width * bmp->height * 4;
|
||||||
CCTexture* tex = (CCTexture*)rsxMemalign(128, 128 + size);
|
CCTexture* tex = (CCTexture*)rsxMemalign(128, 128 + size);
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ typedef struct CCTexture_ {
|
|||||||
cc_uint32 pixels[];
|
cc_uint32 pixels[];
|
||||||
} CCTexture;
|
} CCTexture;
|
||||||
|
|
||||||
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
int size = bmp->width * bmp->height * 4;
|
int size = bmp->width * bmp->height * 4;
|
||||||
CCTexture* tex = (CCTexture*)memalign(16, 16 + size);
|
CCTexture* tex = (CCTexture*)memalign(16, 16 + size);
|
||||||
|
|
||||||
|
@ -661,7 +661,7 @@ static void GPUTextures_DeleteUnreferenced(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Textures--------------------------------------------------------*
|
*---------------------------------------------------------Textures--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
int size = bmp->width * bmp->height * 4;
|
int size = bmp->width * bmp->height * 4;
|
||||||
struct GPUTexture* tex = GPUTexture_Alloc(size);
|
struct GPUTexture* tex = GPUTexture_Alloc(size);
|
||||||
Mem_Copy(tex->data, bmp->scan0, size);
|
Mem_Copy(tex->data, bmp->scan0, size);
|
||||||
|
@ -198,7 +198,7 @@ static void ConvertTexture(cc_uint32* dst, struct Bitmap* bmp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
int size = 16 + bmp->width * bmp->height * 4;
|
int size = 16 + bmp->width * bmp->height * 4;
|
||||||
CCTexture* tex = MmAllocateContiguousMemoryEx(size, 0, MAX_RAM_ADDR, 0, 0x404);
|
CCTexture* tex = MmAllocateContiguousMemoryEx(size, 0, MAX_RAM_ADDR, 0, 0x404);
|
||||||
|
|
||||||
|
@ -108,7 +108,6 @@ static int selections_count;
|
|||||||
static struct SelectionBox selections_list[SELECTIONS_MAX];
|
static struct SelectionBox selections_list[SELECTIONS_MAX];
|
||||||
static cc_uint8 selections_ids[SELECTIONS_MAX];
|
static cc_uint8 selections_ids[SELECTIONS_MAX];
|
||||||
static GfxResourceID selections_VB, selections_LineVB;
|
static GfxResourceID selections_VB, selections_LineVB;
|
||||||
static cc_bool selections_used;
|
|
||||||
|
|
||||||
void Selections_Add(cc_uint8 id, const IVec3* p1, const IVec3* p2, PackedCol color) {
|
void Selections_Add(cc_uint8 id, const IVec3* p1, const IVec3* p2, PackedCol color) {
|
||||||
struct SelectionBox sel;
|
struct SelectionBox sel;
|
||||||
@ -142,10 +141,9 @@ static void Selections_ContextLost(void* obj) {
|
|||||||
Gfx_DeleteDynamicVb(&selections_LineVB);
|
Gfx_DeleteDynamicVb(&selections_LineVB);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Selections_ContextRecreated(void* obj) {
|
static void AllocateVertexBuffers(void) {
|
||||||
if (!selections_used) return;
|
selections_VB = Gfx_CreateDynamicVb(VERTEX_FORMAT_COLOURED, SELECTIONS_MAX_VERTICES);
|
||||||
Gfx_RecreateDynamicVb(&selections_VB, VERTEX_FORMAT_COLOURED, SELECTIONS_MAX_VERTICES);
|
selections_LineVB = Gfx_CreateDynamicVb(VERTEX_FORMAT_COLOURED, SELECTIONS_MAX_VERTICES);
|
||||||
Gfx_RecreateDynamicVb(&selections_LineVB, VERTEX_FORMAT_COLOURED, SELECTIONS_MAX_VERTICES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Selections_QuickSort(int left, int right) {
|
static void Selections_QuickSort(int left, int right) {
|
||||||
@ -181,10 +179,9 @@ void Selections_Render(void) {
|
|||||||
}
|
}
|
||||||
Selections_QuickSort(0, selections_count - 1);
|
Selections_QuickSort(0, selections_count - 1);
|
||||||
|
|
||||||
if (!selections_VB) { /* lazy init as most servers don't use this */
|
/* lazy init as most servers don't use this */
|
||||||
selections_used = true;
|
if (!selections_VB) AllocateVertexBuffers();
|
||||||
Selections_ContextRecreated(NULL);
|
|
||||||
}
|
|
||||||
count = selections_count * SELECTIONS_VERTICES;
|
count = selections_count * SELECTIONS_VERTICES;
|
||||||
Gfx_SetVertexFormat(VERTEX_FORMAT_COLOURED);
|
Gfx_SetVertexFormat(VERTEX_FORMAT_COLOURED);
|
||||||
|
|
||||||
@ -215,8 +212,7 @@ void Selections_Render(void) {
|
|||||||
*--------------------------------------------------Selections component---------------------------------------------------*
|
*--------------------------------------------------Selections component---------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static void OnInit(void) {
|
static void OnInit(void) {
|
||||||
Event_Register_(&GfxEvents.ContextLost, NULL, Selections_ContextLost);
|
Event_Register_(&GfxEvents.ContextLost, NULL, Selections_ContextLost);
|
||||||
Event_Register_(&GfxEvents.ContextRecreated, NULL, Selections_ContextRecreated);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OnReset(void) { selections_count = 0; }
|
static void OnReset(void) { selections_count = 0; }
|
||||||
|
@ -102,17 +102,12 @@ static void Gfx_DoMipmaps(int x, int y, struct Bitmap* bmp, int rowWidth, cc_boo
|
|||||||
if (prev != bmp->scan0) Mem_Free(prev);
|
if (prev != bmp->scan0) Mem_Free(prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
GLuint texId;
|
GLuint texId;
|
||||||
glGenTextures(1, &texId);
|
glGenTextures(1, &texId);
|
||||||
glBindTexture(GL_TEXTURE_2D, texId);
|
glBindTexture(GL_TEXTURE_2D, texId);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
if (!Math_IsPowOf2(bmp->width) || !Math_IsPowOf2(bmp->height)) {
|
|
||||||
Logger_Abort("Textures must have power of two dimensions");
|
|
||||||
}
|
|
||||||
if (Gfx.LostContext) return 0;
|
|
||||||
|
|
||||||
if (mipmaps) {
|
if (mipmaps) {
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
|
||||||
if (customMipmapsLevels) {
|
if (customMipmapsLevels) {
|
||||||
|
@ -9,13 +9,14 @@
|
|||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
#include "Bitmap.h"
|
#include "Bitmap.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
struct _GfxData Gfx;
|
struct _GfxData Gfx;
|
||||||
GfxResourceID Gfx_defaultIb;
|
GfxResourceID Gfx_defaultIb;
|
||||||
GfxResourceID Gfx_quadVb, Gfx_texVb;
|
GfxResourceID Gfx_quadVb, Gfx_texVb;
|
||||||
const cc_string Gfx_LowPerfMessage = String_FromConst("&eRunning in reduced performance mode (game minimised or hidden)");
|
const cc_string Gfx_LowPerfMessage = String_FromConst("&eRunning in reduced performance mode (game minimised or hidden)");
|
||||||
|
|
||||||
static const int strideSizes[2] = { SIZEOF_VERTEX_COLOURED, SIZEOF_VERTEX_TEXTURED };
|
static const int strideSizes[] = { SIZEOF_VERTEX_COLOURED, SIZEOF_VERTEX_TEXTURED };
|
||||||
/* Whether mipmaps must be created for all dimensions down to 1x1 or not */
|
/* Whether mipmaps must be created for all dimensions down to 1x1 or not */
|
||||||
static cc_bool customMipmapsLevels;
|
static cc_bool customMipmapsLevels;
|
||||||
|
|
||||||
@ -336,6 +337,17 @@ static CC_NOINLINE int CalcMipmapsLevels(int width, int height) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps);
|
||||||
|
|
||||||
|
GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) {
|
||||||
|
if (!Math_IsPowOf2(bmp->width) || !Math_IsPowOf2(bmp->height)) {
|
||||||
|
Logger_Abort("Textures must have power of two dimensions");
|
||||||
|
}
|
||||||
|
if (Gfx.LostContext) return 0;
|
||||||
|
|
||||||
|
return Gfx_AllocTexture(bmp, flags, mipmaps);
|
||||||
|
}
|
||||||
|
|
||||||
void Texture_Render(const struct Texture* tex) {
|
void Texture_Render(const struct Texture* tex) {
|
||||||
Gfx_BindTexture(tex->ID);
|
Gfx_BindTexture(tex->ID);
|
||||||
Gfx_Draw2DTexture(tex, PACKEDCOL_WHITE);
|
Gfx_Draw2DTexture(tex, PACKEDCOL_WHITE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user