Skip to content

Commit b29205e

Browse files
authored
Merge pull request #100 from tapir2342/query-max-texture-size
Add function to query max texture size
2 parents 41938fe + cfbe9ca commit b29205e

File tree

6 files changed

+19
-3
lines changed

6 files changed

+19
-3
lines changed

Framework/Graphics/Graphics.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ public static class Graphics
3737
internal static void Initialize()
3838
{
3939
Renderer = Platform.FosterGetRenderer();
40-
41-
// TODO: actually query the graphics device for this
42-
MaxTextureSize = 8192;
40+
MaxTextureSize = Platform.FosterGetMaxTextureSize();
4341
}
4442

4543
/// <summary>

Framework/Platform.cs

+2
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ static unsafe Platform()
229229
[LibraryImport(DLL)]
230230
public static partial void FosterGetDisplaySize(out int width, out int height);
231231
[LibraryImport(DLL)]
232+
public static partial int FosterGetMaxTextureSize();
233+
[LibraryImport(DLL)]
232234
public static partial void FosterSetFlags(FosterFlags flags);
233235
[LibraryImport(DLL)]
234236
public static partial void FosterSetCentered();

Platform/include/foster_platform.h

+2
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ FOSTER_API void FosterGetSizeInPixels(int* width, int* height);
618618

619619
FOSTER_API void FosterGetDisplaySize(int* width, int* height);
620620

621+
FOSTER_API int FosterGetMaxTextureSize();
622+
621623
FOSTER_API void FosterSetFlags(FosterFlags flags);
622624

623625
FOSTER_API void FosterSetCentered();

Platform/src/foster_platform.c

+6
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,12 @@ void FosterGetDisplaySize(int* width, int* height)
416416
*height = mode.h;
417417
}
418418

419+
int FosterGetMaxTextureSize()
420+
{
421+
FOSTER_ASSERT_RUNNING_RET(FosterGetMaxTextureSize, -1);
422+
return fstate.device.getMaxTextureSize();
423+
}
424+
419425
void FosterSetFlags(FosterFlags flags)
420426
{
421427
FOSTER_ASSERT_RUNNING(FosterSetFlags);

Platform/src/foster_renderer.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ typedef struct FosterRenderDevice
1313
void (*shutdown)();
1414
void (*frameBegin)();
1515
void (*frameEnd)();
16+
17+
int (*getMaxTextureSize)();
1618

1719
FosterTexture* (*textureCreate)(int width, int height, FosterTextureFormat format);
1820
void (*textureSetData)(FosterTexture* texture, void* data, int length);

Platform/src/foster_renderer_opengl.c

+6
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,11 @@ void FosterFrameEnd_OpenGL()
10981098
SDL_GL_SwapWindow(state->window);
10991099
}
11001100

1101+
int FosterGetMaxTextureSize_OpenGL()
1102+
{
1103+
return fgl.max_texture_size;
1104+
}
1105+
11011106
FosterTexture* FosterTextureCreate_OpenGL(int width, int height, FosterTextureFormat format)
11021107
{
11031108
FosterTexture_OpenGL result;
@@ -1820,6 +1825,7 @@ bool FosterGetDevice_OpenGL(FosterRenderDevice* device)
18201825
device->shutdown = FosterShutdown_OpenGL;
18211826
device->frameBegin = FosterFrameBegin_OpenGL;
18221827
device->frameEnd = FosterFrameEnd_OpenGL;
1828+
device->getMaxTextureSize = FosterGetMaxTextureSize_OpenGL;
18231829
device->textureCreate = FosterTextureCreate_OpenGL;
18241830
device->textureSetData = FosterTextureSetData_OpenGL;
18251831
device->textureGetData = FosterTextureGetData_OpenGL;

0 commit comments

Comments
 (0)