FreeBASIC Screensaver Kit

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
jofers
Posts: 1525
Joined: May 27, 2005 17:18

Post by jofers »

You actually don't get a GDI context, you have to make one. All you're given is an HWND that is either screen-sized or about 150x120.

Turns out I don't know anything about opengl, but if you can get something in a tiny child window, you'll be set.

EDIT: Okay, apparently there are some Win32 OpenGL functions that go by the prefix monaker "wgl", that let you set up OpenGL into Window:
http://msdn.microsoft.com/library/defau ... o_4v3m.asp

This would allow you set up OpenGL into a screensaver child window, but you would probably be cut off from GfxLib unless you figure out a way to map OpenGL commands to a GfxLib surface (ARGB memory buffer). If there was a way to get OpenGL to that surface, and then use OpenGL to copy it to the DC, then you'd be set.

But if you don't care about GfxLib, then it would be a much simpler matter to convert the kit.

EDIT AGAIN: It looks like OpenGl can play nice with GfxLib and draw to ScreenPtr. I'll try and port the library next chance I get, but it may take awhile for me to find the time.

EDIT ONCE AGAIN: Apparently, I was mistaken. OpenGL can copy to a screenbuffer with any pixel format, much like GDI can, but it can't draw to that buffer using that buffer's pixel format.... unless I wanted to forego hardware accelleration. So you couldn't PUT a pixel down and then slap a polygon on it without doing two screen copies per frame.

Soo... I can write an OpenGL driver, but much like GfxLib's openGL driver, it won't be able to use PUT/LINE/PSET.
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Post by relsoft »

Actually you got the OpenGL kit part right. I mean a screensaver kit for OpenGL. No GFXlib, GDI etc. Just OpenGL. :*)
Sisophon2001
Posts: 1706
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.
Contact:

Post by Sisophon2001 »

Hi:

I looked at this code to see how it works and I am no wiser for my efforts. Actually I started out looking at the screen saver code (which I understand), but got distracted by the graphics (which I don’t understand). What logic is this based on? References? How could anybody possibly dream this up unless it was based on some mathematical principal or some such?

This is the only screensaver I ever liked.

Garvan
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Post by Imortis »

I tried to use the screensaver kit yesterday, and it would display the screen saver like normal, but when the screensaver was ended, it would have an GPF on me. I'm using windows XP SP2 and fb 0.15b.
jofers
Posts: 1525
Joined: May 27, 2005 17:18

Post by jofers »

What does GPF mean? I suck at acronyms.

If you post the source code, I could try and help you more. The screensaver kit was a weekend project for me, so there probably are a lot of little bugs.
v1ctor
Site Admin
Posts: 3804
Joined: May 27, 2005 8:08
Location: SP / Bra[s]il
Contact:

Post by v1ctor »

General Protection Fault aka some exception that Windows has no clue how to handle, from the Win 3.x days :)
marinedalek
Posts: 124
Joined: Aug 24, 2005 1:55
Contact:

Post by marinedalek »

jofers wrote:What does GPF mean? I suck at acronyms.
General Protection Fault - A program tried to write in an area of memory that was reserved (protected). The operation is refused (I believe) but Windows gets confused because it has no idea what to do next, so it just forces the program responsible to close and comes up with a <sarcasm>lovely, easy-to understand </sarcasm> error message.

I really shouldn't have ordered those Intel manuals!
Sisophon2001
Posts: 1706
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.
Contact:

Post by Sisophon2001 »

Hi jofers

The screensaver kit runs well with the “Mambazo Doodle.bas” sample, but for some reason it crashes on exit if you comment out the lines starting with

StartScreenSaver

And compile it as a stand alone app.

I spent 20 minutes looking for the reason, and could not find any.

I have WinXP SP2

Garvan

Correction:
“Mambazo Doodle.bas” also crashes on exit when I recompile it. The original scr file does not crash.

Garvan
jofers
Posts: 1525
Joined: May 27, 2005 17:18

Post by jofers »

Well, StartScreenSaver is necessary, it sets everything up and rolling so your screensaver will work. Don't take that one out.

Does this crash?

Code: Select all

#include "FB_ScreenSaverKit.bas"

Dim As Integer sw, sh

'Start the Screen Saver
StartScreenSaver

ScreenInfo sw, sh

Do Until SaverInfo.IsClosing = TRUE
   Pset (Rnd * sw, Rnd * sh), Rgb(Rnd * 255, Rnd * 255, Rnd * 255)
Loop
Sisophon2001
Posts: 1706
Joined: May 27, 2005 6:34
Location: Cambodia, Thailand, Lao, Ireland etc.
Contact:

Post by Sisophon2001 »

Hi jofers

Yes this code crashes on exit.

My apologies for the wording error in my original post, I typed “comment out” instead of “un comment”.

Thank you for this code, it is very informative

Garvan
blahboybang
Posts: 385
Joined: Oct 16, 2005 0:15
Location: USA
Contact:

Post by blahboybang »

But where do I get the "windows.bi" file? I can't find it.
jofers
Posts: 1525
Joined: May 27, 2005 17:18

Post by jofers »

"windows.bi" (and about 10 other files) are a direct translation of the Windows API headers from C. They wil be packaged with FreeBASIC 0.15b, but you can grab 'em here or off the CVS:

http://www.betterwebber.com/stuff/win32headers.zip

Remember, they can only be used with the testing versions of FreeBASIC 0.15b, available in the download section, because they use some new features.
lintphishx
Posts: 58
Joined: Nov 02, 2005 19:49

Post by lintphishx »

I'm getting a suspisious pointer warning on line 102 when I use FBIDE.
jofers
Posts: 1525
Joined: May 27, 2005 17:18

Post by jofers »

Yeah, the kit isn't much of a formal project. If it's working for you, you can probably CPtr the warning away.
darxide
Posts: 4
Joined: Jan 03, 2006 18:56

Post by darxide »

Only bad thing is that this screensaver wants 100% of processor time. I think it rises "idle"-temperature pretty high.
Post Reply