Login or Signup

Unable to Set Graphics Mode

Blitz3D Forums/Blitz3D Beginners Area/Unable to Set Graphics Mode

Jamie1+ years ago #1

I have been working on a project for some time now and periodically I will receive the Unable to Set Graphics Mode message when starting my project (but only if compiled). This happens on 3 or 4 PCs and appears to be somewhat random. Below is sample specs for one of the PCs (the development PC):

nVidia GeForce 6200A 512MB
P4 3.2 GHz
1.5 GB RAM
Windows XP Pro SP2

Project/Development Specs
Blitz3D IDE V1.90 Linker V1.84 Runtime V1.90
Protean IDE V 1.4 Build 1884 Revision 26595
Project Running at 1024 x 768 32-bit color

I have not tried the newest GeForce drivers, but at least two of the PCs that exhibit this are using different driver versions. All PCs that I have tried this on are running Windows XP Pro SP2

I realize that no one can "tell me whats wrong", but I was hoping for some direction to begin troubleshooting. Obviously this is very frustrating and limits my ability to distribute my project. Any help would be greatly appreciated.



Gabriel1+ years ago #2
Well posting the code you use to set a graphics mode would help.

Jamie1+ years ago #3
Sorry about that.... here are the lines that I use for setting the graphics mode:

Graphics3D 1024,768,32

Before these lines I have a number of types, variables, and functions defined, but this is the only Graphics or Graphics3d call in the entire project.


Gabriel1+ years ago #4
I'm not sure if ClearWorld should be called before Graphics3d is called.

Anyway, try changing to Graphics3d 1024,768,0

That should pick the bit depth automatically, according to what is available.

The only other thing I can think of which might cause a problem is if you're already running a program which has a D3D window open. They don't seem to like having two open at once.

Jamie1+ years ago #5
I will remove the ClearWorld call and change the Graphics3D line to let it choose the highest available.

It does appear that this problem occurs usually after I have ran the project numerous times. I wonder if something is not truely getting unloaded and there is a D3D window open somewhere, eventhough it is not visible?!? Right now when I want to exit my program I make the following calls after freeing all of the sounds, textures, etc:


I am going through and making sure I have freed all items before I make these calls; but if any ideas while I check through that would be appreciated.



Graythe1+ years ago #6

A shot in the dark...

If you are using writepixelfast or readpixelfast then examine these routines for possible bounds errors. If there is doubt then construct another set of almost identical routines but using readpixel and writepixel which will not write out of bounds even if instructed to. Naturally, if the problem endures then it's not an out of frame write.

A good tool to check running processes is Winsonar (do a google search) which is free.

I hope it helps...

jfk EO-111101+ years ago #7
I'd try:
Remove the Clearworld, especially if you really didn't call Graphics3D before!

Then: explicitely define if it should be windowed or fullscreen. Your command
Graphics3D 1024,768,32
will run windowed in debug mode and fullscreen in non-debug mode. So use
Graphics3D 1024,768,32,1 ; (or 2, of course)

Fernhout1+ years ago #8
I am a beginner in Blitz 3D but i know a bit more about Windows. and for me the problem is not Blitz but windows. Specialy Combination windows and Graphics card. You say this wil happens after you opend you program a couple of times. Windows don't like to reserve and free up memory to the same program again and again. There will be a memory fragmentation between windows and the graphics card. Normaly you get a warning can't created memblock. But if the fragmentation is to high your color depth wil not work anymore. Your program gets a error back and reports that it cant create the graphics mode you requested. You can test this by simple restart windows. Its clear out the memory. If you application starts after a restart windows then this is the problem. If the problem stil exist after a restart then the problem is not windows, and i can't help you either.

Jamie1+ years ago #9
Thanks to all that have posted. I have performed some of the fixes/tests described above. Before making the code changes, I found that if my program gets the unable to set graphics mode error, I can either restart and it works fine or I can re-reun the program and it appears to work fine. I will let you know if the aobve code changes have made any differences.


Brownie1+ years ago #10
This is my code and it is saying that it cannot set graphics mode??????????

Can someone help me out please!

Graphics 1920, 1080, 16, 1
AutoMidHandle True
SetBuffer BackBuffer()

playerimage = LoadImage("player.bmp") ;Images
close = LoadImage("stars.bmp")
far = LoadImage("starsfarther.bmp")
blasterimage = LoadImage("Blast.bmp")

Dim blasterx(10000)
Dim blastery(10000)
blast = 0
blasts = 0
scrolly = 0

While Not KeyDown(1)
; blasts = blast - 1

TileImage far, 0, scrolly
TileImage close, 0, scrolly * 2
scrolly = scrolly + 1
If scrolly >= ImageHeight(close)
scrolly = 0

If KeyDown(203) ;when player is holding left key moves ship to left
x = x - 3
If x <= 0 ;if ship is off
x = 1920; - playerimage x
End If
; Text 0, 0, x
End If

If KeyDown(205);right
x = x + 3
If x >= 1920; - playerimage x
x = 0
End If
; Text 0, 0, x
End If

If KeyDown(200);up
y = y - 10
If y <= 0
y = 1080; - playerimage y
End If
; Text 0, 20, y
End If

If KeyDown(208);down
y = y + 5
If y >= 1080; - playerimage y
y = 0
End If
; Text 0, 20, y
End If

Text 0, 0, x + ", " + y

If KeyDown(30)
RotateImage playerimage, -90
ElseIf KeyDown(32)
RotateImage playerimage, 90

; If KeyHit(57);space
; If ammo > 0 ;if you have ammo, lower ammo amount and shoot, set blaster x and y at ship's x and y
; blasterx(ammo) = x
; blastery(ammo) = y
; ammo = ammo - 1
; blasts = blasts + 1
; End If
; End If

If KeyDown(57) ;Spacebar

blasterx(blast) = x
blastery(blast) = y
blast = blast + 1

End If

;Text 0, 40, "Ammo: " + ammo

; For loop = 100 To 100 - blasts Step 1
; If loop < 101
; If blastery(loop) > 0
; blastery(loop) = blastery(loop) - 10
; End If
; DrawImage blasterimage, blasterx(loop), blastery(loop)
; End If
; Text 0, 80, "Loop: " + loop + ", Blast: " + blasts
; Next
For l = 0 To blast

DrawImage blasterimage, blasterx(l), blastery(l)
Text 0, l * 20, "Blasts: " + blasts + ", Blaster X and Y: " + blasterx(l) + ", " + blastery(l)
blastery(l) = blastery(l) - 10

DrawImage playerimage, x, y




_PJ_1+ years ago #11
The error typically refers to trying to set a graphics mode which is unsupported by the driver, or, that is incompatible with the display hardware.

Graphics 1920, 1080, 16, 1]

I suspect it may be the 16-bit colour depth that is unsupported, however, to be certain and to identify a display mode that is definitely supported, use the following to check first:

SetGfxDriver 1

Const GW=1920
Const GH=1080
Const GD=16

If (GfxModeExists(GW,GH,GD))
DebugLog("Mode is supported")
DebugLog("Mode is not supported. Change values!")
End If

Graphics gw,gh,gd,1

RemiD1+ years ago #12
It seems that you can use any width height in windowed mode but you have to use one of the available resolution in fullscreen mode.
Here is an example on how to get the available resolutions where the width is superior to the height and height/width >= 0.5 and width/height <=2 and the colors depth is 32bits

Rick Nasher1+ years ago #13
Perhaps you need to edit/reference your post here ;-)

RemiD1+ years ago #14
Or create another code archives entry, why not, it can be useful for somebody else someday...

Rick Nasher1+ years ago #15

RemiD1+ years ago #16
https://www.youtube.com/watch?v=R16wgQLmqxE :D

Blitz Social Club