How to get a cards texture limit?

BlitzMax Forums/BlitzMax Programming/How to get a cards texture limit?

In B3d is fairly easy to find out the whether a video card supports a certain texture size. You can create a new texture and then check its dimentions to see if it was what you told it to be. But how can you deterimine is a texture size is supported in Bmax/Ogl?

See if it crashes. Or something.

Try this:

Framework BRL.Blitz

Import BRL.Max2D
Import BRL.GLMax2D
Import BRL.StandardIO

Graphics 800,600,0

Print texSizeSupported(640,480)
Print texSizeSupported(800,600)
Print texSizeSupported(2096,2096)

Function texSizeSupported(w,h)

	Local supported=True
	
	Try
		CreateImage(w,h)
	Catch o:Object
		supported=False
	End Try

	FlushMem
	
	Return supported
	
End Function


Edit: On my laptop, the above code prints:

1
1
0

Local maxTexSize:Int
glGetIntegerv(GL_MAX_TEXTURE_SIZE, Varptr maxTexSize)


Robert:
try changing your number 2096 to 2048..

I don't trust people who can't use OpenGL without a wrapper of some sort ;)

Thanks Robert, Noel!

Robert:
try changing your number 2096 to 2048..


I was just proving that it returns False when the size is invalid.

In any case, Noel's suggested method is clearly much better. The only advantage of doing it the way I suggested is that it doesn't matter what back-end is currently being used (either OpenGL or DirectX)

The only advantage of doing it the way I suggested is that it doesn't matter what back-end is currently being used (either OpenGL or DirectX)

Your code returns 1 for me for all three sizes, not sure if my card simply steps the texture size up to the next power of 2 or if the drivers simply lie.

Print texSizeSupported(4096,4096)
Adding this as 4th testline displays 1 1 1 0 here

4x4=16mb
16x3=48mb + more vram for backbuffer, fonts etc...
if you have 64-mb-gfx-card - you can only allocate max. 64 mb vram