SetResolution(width,height,bit,freq)

Blitz3D Forums/Blitz3D Userlibs/SetResolution(width,height,bit,freq)

chi(Posted 2008) [#1]
hi all,

normally within blitz3d there is no native way setting the monitor-frequency
to a user defined value. so i wrote a little dll to get rid of that...

---
the main function -> b3dx2_SetResolution(width,height,bit,freq) ;self-explanatory

( only allows hardware-supported resolutions... if it´s not supported you´ll get an
error message without setting it. also switches back to desktop resolution when you use
alt-tab,alt-esc,... )
---
the gui function -> b3dx2_ScreenSelector()

( get a list of all supported display settings and launch... not much more to say )
---

2 samples, the decls and the dll are in the zip...
now please try it and give me a little feedback if everything works fine... or maybe
to add something. just tell me ;) it´s still beta and i want to include much more
useful functions.

download b3dx2.zip

thx a lot, chi



edit_1: bugfix - desktop icons save/restore fixed


QuickSilva(Posted 2008) [#2]
Hi chi, I`m going to download this in a moment, sounds really useful. Will let you know what I think.

(Off topic)
Just also wanted to quickly ask you about a B3D_WindowHack that you once updated from the original authors code, Bot Builder I think. Is it possible that you could post the source and maybe an updated version that works with B3D version 1.99? I would be most greatful :)

Thread link :
http://www.blitzmax.com/Community/posts.php?topic=70024#810172

(Sorry for going off topic)

Jason.


chi(Posted 2008) [#3]
hi silva, not off topic at all! b3dx2 actually fixes the alt-tab bug with this modification...

i checked B3D_WindowHack and it still works with the actual blitz version... maybe the howto is a little bit outdated ?!?

anyway, i found the code - so here it is ;)


Graphics 640,480,0,2

CopyFile "runtime.dll","runtime_backup.dll" ;dont run it twice or your backup is gone...
fil=OpenFile("runtime.dll")
siz=FileSize("runtime.dll")

For i=0 To siz
	byt=ReadByte(fil)
	If Frst=True
		If scnd=True
			If byt=$8B
				pos=i-1
				Exit
			Else
				scnd=False
				If byt<>$CA Then frst=False
			EndIf
		ElseIf byt=$10
			scnd=True
		Else
			If byt<>$CA Then Frst=False
		EndIf
	ElseIf byt=$CA
		Frst=True
	EndIf	
Next

SeekFile fil,pos
WriteByte fil,$00
CloseFile fil

Print ""
Print "Changing byte "+pos+" (value $10) to $00"
Print "Done. Press any key to continue."
WaitKey()




QuickSilva(Posted 2008) [#4]
Thanks for that :)

BTW, where can I get the userlib mentioned in the instructions? Sorry if this sounds obvious but I`m a little lost when it comes to userlibs and .dlls

"you´ll need user32.decls in \Blitz3D\userlibs with api_ShowWindow"

With regards to your original post everything seems to work fine. I`m interested to see what other features that you have planned.

Jason.


chi(Posted 2008) [#5]
.decls are renamed textfiles... so, if you dont have a user32.decls - just create it ;)

paste:

.lib "user32.dll"
api_ShowWindow% (hwnd%, nCmdShow%) : "ShowWindow"

and save it into \Blitz3D\userlibs, restart your ide...

Global hWnd=SystemProperty("ApphWnd")
Graphics3D 800,600,0,6
api_ShowWindow hWnd,5

thats all


full user32.decls here .> http://www.blitzbasic.com/Community/posts.php?topic=27586


QuickSilva(Posted 2008) [#6]
Thanks for the info :)

What does the 6 mean in the Graphics 800,600,0,6 line?

Jason.


chi(Posted 2008) [#7]
800,600,0,x

x=1 start fullscreen, freezes when not active (no cpu usage)
x=2 start windowed, always cpu usage
x=3 start windowed + resize, always cpu usage
x=6 start windowed, freezes when not active (no cpu usage)
x=7 start windowed + resize, freezes when not active (no cpu usage)


QuickSilva(Posted 2008) [#8]
Thanks again :) Are these listed in the docs somewhere because I couldn`t find modes 6 and 7.

Jason.


chi(Posted 2008) [#9]
ANYONE???


@quicksilva: it was in a post from mark about beta runtime.dll...
http://www.blitzbasic.com/Community/posts.php?topic=71312#827528

cheers


Barton(Posted 2008) [#10]
The monitor-frequency is on flat-screens not of importance when it greater as 60.


chi(Posted 2008) [#11]
with b3dx2_SetResolution you have the ability to set the right frequency for tft´s AND cft´s... on cft´s it´s sometimes necessary to changing to different freq.s

freq=fps -> if your hardware is strong enough then 75fps on a tft runs nicer/smoother then 60fps... (maybe it´s only my opinion ;)