Code archives/Graphics/gfxMode

This code has been declared by its author to be Public Domain code.

Download source code

gfxMode by Doclar12002
Set requested mode and color bit if possible, if not it will check the highest mode for that color bit(16 or 32) and set your graphics card.

Also, an option to display a bitmap after the mode is set, with delay and window modes available!

Thanks
Lawrence (doclar1)
you can get it here: http://directillusions.8k.com/gfxmode.zip (a small 575k download)



Thanks
Lawrence (doclar1)

Comments

Linaxys2007
The link is dead and this crappy piece of **** PcCleaner spyware...


Doclar12011
Sorry guys....


Doclar12011
;*********************************************
; Set graphics mode requested or sets the
; highest 2D/3D graphics mode available
; for your graphics card. Hope you all can
; find a use for this.
;
; Have fun!
;
;
; Ver. 0.2
; Copyright(c) 2002 Direct Illusions Inc.
; Coded by Lawrence (doclar1)
; Blitz-3D Ver. 1.74
;**********************************************
AppTitle "gfxMode v0.2"
;Check available display modes and display them
;Set to 1 to print 0 to turn off.
Global SHOWMODES = 1
;Set to a bitmap to display or "" not to display
Global GFXPICTURE$ = "cs.jpg"
;**********************************************
;DO NOT MODIFY BELOW THIS LINE! OR AT OWN RISK!
;**********************************************
;Number of graphics modes available
Global NUMMODES = CountGfxModes()
;Total number of 16 and 32 bit modes we have available
Global NUM16MODES = 0
Global NUM32MODES = 0
;Our array to hold cards 16 & 32 bit graphics modes
;51,5 gives us plenty of room! We start the array
;at 1 instead of 0.
Dim MODEINFO_16(51,5)
Dim MODEINFO_32(51,5)



; Get all modes including width, height, and color depth
For gm = 1 To NUMMODES

If GfxModeDepth(gm) = 16

MODEINFO_16(gm,1) = gm
MODEINFO_16(gm,2) = GfxModeWidth(gm)
MODEINFO_16(gm,3) = GfxModeHeight(gm)
MODEINFO_16(gm,4) = GfxModeDepth(gm)

NUM16MODES = (NUM16MODES + 1)

Print("Mode: "+MODEINFO_16(gm,1)+" - "+MODEINFO_16(gm,2)+"x"+MODEINFO_16(gm,3)+"x"+MODEINFO_16(gm,4))
Else

MODEINFO_32(gm,1) = gm
MODEINFO_32(gm,2) = GfxModeWidth(gm)
MODEINFO_32(gm,3) = GfxModeHeight(gm)
MODEINFO_32(gm,4) = GfxModeDepth(gm)

NUM32MODES = (NUM32MODES + 1)

Print("Mode: "+MODEINFO_32(gm,1)+" - "+MODEINFO_32(gm,2)+"x"+MODEINFO_32(gm,3)+"x"+MODEINFO_32(gm,4))

EndIf

Next

;If showmodes is set to 1 then display ALL possible modes
If SHOWMODES
Print(" ")
Print("Press Any Key To Continue!")
WaitKey()
EndIf



; Function to setup requested graphics modes
;
;*******************************************
; Sets graphis mode that you request, if available
; if NOT it will look through (highest to lowest)
; to find the highest mode available, and set your
; cards highest 2D or 3D which ever dimension you
; have requested!
; Does error checking so not to frustrate your users!
; or you!!
;
;
; SetGfxMode(gfxWidth = 800,
; gfxHeight = 600,
; gfxRequest = 2,
; gfxWinMode = 0,
; gfxPrint = 1,
; gfxDelay = 5000)
;
; gfxWidth = Width of requested graphics mode (default = 800)
; 800: (default)

; gfxHeight = Height of requested graphics mode (default = 600)
; 600: (default)
;
; gfxRequest = Request 2D or 3D (default 2 for 2D)
; 2: 2D mode
; 3: 3D mode

; gfxWinMode = Mode of window display. Defaults To 0
; 0: windowed (If possible) in debug mode, fullscreen in non-debug mode
; 1: fullscreen always
; 2. windowed always
; 3: windowed/scaled always
;
; gfxPrint = Print selected mode on screen after setting (default 1)
; 1: ON
; 0: OFF
;
; gfxDelay = Delay time to wait before proceeding after mode / graphics are set
; 5000: 5 seconds (default)
;
;
; Bitmap Displaying:
;******************
; You can set the GLOBAL GFXPICTURE$ value to a string$ (picture file in same directory)
; the routine checks to see if there is a picture file set if so, it will
; display the selected picture file on screen after setting graphics mode.
; See above GFXPICTURE$ valule for an example of this, if you leave blank
; like this: "" then no picture will be displayed.
;************************************************************************
;
; Show ALL modes:
;****************
; Set the GLOBAL SHOWMODES value to 1 if you would like ALL graphics modes
; displayed just before it goes and sets the graphics mode, you have to
; press any key to continue, or you can set this up as a delay also.
;
;**************************************************************************
;

Function SetGfxMode(gfxWidth = 800,gfxHeight = 600,gfxRequest = 2,gfxDepth = 16,gfxWinMode = 0,gfxPrint = 1,gfxDelay = 5000)


;What mode 2D or 3D?
Select(gfxRequest)

;Selected 2D
Case(2)

Select(gfxDepth)

;16 Bit Color Modes - 2D
Case(16)

If GfxModeExists(gfxWidth,gfxHeight,gfxDepth)

Graphics(gfxWidth,gfxHeight,gfxDepth,gfxWinMode)

If gfxPrint
SetBuffer FrontBuffer()
Text(GraphicsWidth()/2,GraphicsHeight()/2,"16-Bit 2D Mode: "+gfxWidth+"x"+gfxHeight+"x"+gfxDepth+" - "+gfxWinMode,True,True)
EndIf

If GFXPICTURE$ > ""
SetBuffer BackBuffer()
Pic = LoadImage(GFXPICTURE$)
DrawImage(Pic,0,0)
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"16-Bit 2D Mode: "+gfxWidth+"x"+gfxHeight+"x"+gfxDepth+" - "+gfxWinMode,True,True)
EndIf
Flip()
EndIf

If gfxDelay Then Delay(gfxDelay)

Else

total_16 = NUM16MODES

For check_16 = 1 To NUM16MODES

If GfxModeExists(MODEINFO_16(total_16,2),MODEINFO_16(total_16,3),MODEINFO_16(total_16,4))
Graphics(MODEINFO_16(total_16,2),MODEINFO_16(total_16,3),MODEINFO_16(total_16,4),gfxWinMode)
SetBuffer FrontBuffer()
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"Computer Selected 16-Bit 2D Mode: "+MODEINFO_16(total_16,2)+"x"+MODEINFO_16(total_16,3)+"x"+MODEINFO_16(total_16,4)+" - "+gfxWinMode,True,True)
EndIf
Exit
Else

total_16 = (total_16 - 1)

EndIf

Next

If GFXPICTURE$ > ""
SetBuffer BackBuffer()
Pic = LoadImage(GFXPICTURE$)
DrawImage(Pic,0,0)
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"Computer Selected 16-Bit 2D Mode: "+MODEINFO_16(total_16,2)+"x"+MODEINFO_16(total_16,3)+"x"+MODEINFO_16(total_16,4)+" - "+gfxWinMode,True,True)
EndIf
Flip()
EndIf

If gfxDelay Then Delay(gfxDelay)

EndIf

;32 Bit Color Modes - 2D
Case(32)

If GfxModeExists(gfxWidth,gfxHeight,gfxDepth)

Graphics(gfxWidth,gfxHeight,gfxDepth,gfxWinMode)

If gfxPrint
SetBuffer FrontBuffer()
Text(GraphicsWidth()/2,GraphicsHeight()/2,"32-Bit 2D Mode: "+gfxWidth+"x"+gfxHeight+"x"+gfxDepth+" - "+gfxWinMode,True,True)
EndIf

If GFXPICTURE$ > ""
SetBuffer BackBuffer()
Pic = LoadImage(GFXPICTURE$)
DrawImage(Pic,0,0)
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"32-Bit 2D Mode: "+gfxWidth+"x"+gfxHeight+"x"+gfxDepth+" - "+gfxWinMode,True,True)
EndIf
Flip()
EndIf


If gfxDelay Then Delay(gfxDelay)
Else

total_32 = NUMMODES

For check_32 = 1 To NUMMODES

If GfxModeExists(MODEINFO_32(total_32,2),MODEINFO_32(total_32,3),MODEINFO_32(total_32,4))
Graphics(MODEINFO_32(total_32,2),MODEINFO_32(total_32,3),MODEINFO_32(total_32,4),gfxWinMode)
SetBuffer FrontBuffer()
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"Computer Selected 32-Bit 2D Mode: "+MODEINFO_32(total_32,2)+"x"+MODEINFO_32(total_32,3)+"x"+MODEINFO_32(total_32,4)+" - "+gfxWinMode,True,True)
EndIf
Exit
Else

total_32 = (total_32 - 1)

EndIf

Next

If GFXPICTURE$ > ""
SetBuffer BackBuffer()
Pic = LoadImage(GFXPICTURE$)
DrawImage(Pic,0,0)
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"Computer Selected 32-Bit 2D Mode: "+MODEINFO_32(total_32,2)+"x"+MODEINFO_32(total_16,3)+"x"+MODEINFO_32(total_32,4)+" - "+gfxWinMode,True,True)
EndIf
Flip()
EndIf

If gfxDelay Then Delay(gfxDelay)

EndIf


Default

RuntimeError("Please Set Proper Color Bit Depth To: 16 or 32 Bit!")

End Select

Case(3)

Select(gfxDepth)

;16 Bit Color Modes - 3D
Case(16)

If GfxMode3DExists(gfxWidth,gfxHeight,gfxDepth)

Graphics3D(gfxWidth,gfxHeight,gfxDepth,gfxWinMode)

If gfxPrint
SetBuffer FrontBuffer()
Text(GraphicsWidth()/2,GraphicsHeight()/2,"16-Bit 3D Mode: "+gfxWidth+"x"+gfxHeight+"x"+gfxDepth+" - "+gfxWinMode,True,True)
EndIf

If GFXPICTURE$ > ""
SetBuffer BackBuffer()
Pic = LoadImage(GFXPICTURE$)
DrawImage(Pic,0,0)
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"16-Bit 3D Mode: "+gfxWidth+"x"+gfxHeight+"x"+gfxDepth+" - "+gfxWinMode,True,True)
EndIf
Flip()
EndIf

If gfxDelay Then Delay(gfxDelay)

Else

total_16 = NUM16MODES

For check_16 = 1 To NUM16MODES

If GfxMode3DExists(MODEINFO_16(total_16,2),MODEINFO_16(total_16,3),MODEINFO_16(total_16,4))
Graphics3D(MODEINFO_16(total_16,2),MODEINFO_16(total_16,3),MODEINFO_16(total_16,4),gfxWinMode)
SetBuffer FrontBuffer()
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"Computer Selected 16-Bit 3D Mode: "+MODEINFO_16(total_16,2)+"x"+MODEINFO_16(total_16,3)+"x"+MODEINFO_16(total_16,4)+" - "+gfxWinMode,True,True)
EndIf
Exit
Else

total_16 = (total_16 - 1)

EndIf

Next

If GFXPICTURE$ > ""
SetBuffer BackBuffer()
Pic = LoadImage(GFXPICTURE$)
DrawImage(Pic,0,0)
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"Computer Selected 16-Bit 3D Mode: "+MODEINFO_16(total_16,2)+"x"+MODEINFO_16(total_16,3)+"x"+MODEINFO_16(total_16,4)+" - "+gfxWinMode,True,True)
EndIf
Flip()
EndIf

If gfxDelay Then Delay(gfxDelay)

EndIf

;32 Bit Color Modes - 3D
Case(32)

If GfxMode3DExists(gfxWidth,gfxHeight,gfxDepth)

Graphics3D(gfxWidth,gfxHeight,gfxDepth,gfxWinMode)

If gfxPrint
SetBuffer FrontBuffer()
Text(GraphicsWidth()/2,GraphicsHeight()/2,"32-Bit 3D Mode: "+gfxWidth+"x"+gfxHeight+"x"+gfxDepth+" - "+gfxWinMode,True,True)
EndIf

If GFXPICTURE$ > ""
SetBuffer BackBuffer()
Pic = LoadImage(GFXPICTURE$)
DrawImage(Pic,0,0)
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"32-Bit 3D Mode: "+gfxWidth+"x"+gfxHeight+"x"+gfxDepth+" - "+gfxWinMode,True,True)
EndIf
Flip()
EndIf

If gfxDelay Then Delay(gfxDelay)

Else

total_32 = NUMMODES

For check_32 = 1 To NUMMODES

If GfxMode3DExists(MODEINFO_32(total_32,2),MODEINFO_32(total_32,3),MODEINFO_32(total_32,4))
Graphics3D(MODEINFO_32(total_32,2),MODEINFO_32(total_32,3),MODEINFO_32(total_32,4),gfxWinMode)
SetBuffer FrontBuffer()
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"Computer Selected 32-Bit 3D Mode: "+MODEINFO_32(total_32,2)+"x"+MODEINFO_32(total_32,3)+"x"+MODEINFO_32(total_32,4)+" - "+gfxWinMode,True,True)
EndIf
Exit
Else

total_32 = (total_32 - 1)

EndIf

Next

If GFXPICTURE$ > ""
SetBuffer BackBuffer()
Pic = LoadImage(GFXPICTURE$)
DrawImage(Pic,0,0)
If gfxPrint
Text(GraphicsWidth()/2,GraphicsHeight()/2,"Computer Selected 32-Bit 3D Mode: "+MODEINFO_32(total_32,2)+"x"+MODEINFO_32(total_32,3)+"x"+MODEINFO_32(total_32,4)+" - "+gfxWinMode,True,True)
EndIf
Flip()
EndIf

If gfxDelay Then Delay(gfxDelay)

EndIf

Default

RuntimeError("Please Set Proper Color Bit Depth To: 16 or 32 Bit!")

End Select

End Select

End Function


;End of gfxMode.bb file
;***********************


Doclar12011
;As simple as they get!
;
;Tests the gfxMode file
;
;
Include "gfxmode.bb"

;800=width,600=height,3=3D request mode,32=bit color,0=full screen mode,1=print mode,5000=5 sec delay
SetGfxMode(1280,1024,3,32,0,1,20000)

End()


Doclar12011
Hope that makes up for the dead link all this time...


Sorry again...

I have not been coding or paying attention for a
awhile....


Yan2011
Why put your code in the comments?

You can edit your entry and put the code up top where it belongs. This enables people to use the download link to get it.


Code Archives Forum