Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Plz help - Sgn() function? Saving bitmaps? Advanced DBPro book?

Author
Message
Syme
20
Years of Service
User Offline
Joined: 22nd Jul 2004
Location: Aylesbury, UK
Posted: 16th Nov 2004 11:31
Hi all - I've searched through as many forum threads and tutorials as I could find, but I can't find the answers to these three questions:

1. Is there a simple DBPro replacement for the BASIC "Sgn()" function? I'm writing a Martin fractal program which (in my previous versions using other languages) contains the line:

X2 = Y-Sgn(X)*Sqr((Abs(B*X-C))

I've converted almost all of this line to DBPro (e.g. replacing "Sqr" with "Sqrt", and converting the variables to floats using the "#" sign), but I can't find an efficient way to convert the "Sgn(X)" function. For those who haven't seen this function before, "Sgn(X)" should return 1 if X is positive, zero if X is exactly zero, and -1 if X is negative. This function has been part of all the other versions of BASIC that I've ever used, including BBC Basic, GFA Basic on the Atari ST, etc. The only solution I can see at the moment is to write my own multi-line function, using select/case or maybe if/else, but that doesn't seem to be very efficient to me.

2. As every DBPro user probably knows, the "save bitmap" command was deleted from the language "to make way for future enhancements providing much better support for all types of media exporting". Does anyone know where these enhancements are? When I create a nice-looking graphic on my monitor screen, I can manually press ALT+PRINT SCREEN, then ALT+TAB to Paint Shop Pro and save it as a new image. Does anyone know how I can execute a procedure to save a simple bitmap (BMP format or any other recognised format, I'm not fussy) using program code? IMHO the removal of the "save bitmap" command from DBPro was a mistake.

3. I've purchased the "Beginners Guide to Dark Basic Game Programming", but as has been mentioned in other threads, this does a very poor job of covering 3D graphics which is where Dark Basic really shines. Does anyone know of a more advanced book which really opens the horizons of Dark Basics' 3D capabilities? I don't just mean that it should list the 3D object and camera functions, but it should also go a little way into the background mathematics of creating 3D worlds on screen, including discussion of Dark Basics' vector variables and functions (e.g. cross products and dot products of vectors, the catmullrom functions etc.) An excellent book which first got me hooked on 3D graphics is "Microcomputer Graphics" by Roy Myers, published by Addison-Wesley. However, that was written in 1982, and the example code is written for Applesoft BASIC on the Apple II 48k micro! I need something a little more up-to-date now!

If anyone can help me to push the darkness back, and help me to stretch the superb Dark Basic Pro language even further, I would be very grateful.


Why do so many people lose the ability to spell the word "lose"?
DeepBlue
21
Years of Service
User Offline
Joined: 17th May 2003
Location: A little box in the UK
Posted: 16th Nov 2004 14:01
Heres a sgn function that should do for question 1



Heres a function for saving a screenshot, call it by
saveScreenShot("bmp")
or whatever your file preference is & it will sequentially create screenshots in the current director.



Sorry can't answer question 3.

DeepBlue

The coder formerly known as Twynklet.
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 16th Nov 2004 17:32
As you are doing a fractal proggy, you might want to look at my Mandelbrot one on my website.

Boo!
Syme
20
Years of Service
User Offline
Joined: 22nd Jul 2004
Location: Aylesbury, UK
Posted: 16th Nov 2004 22:39
Thanks for the help guys. Even though the Sgn() function is multi-line, the compiler seems to optimise it pretty well. I can't believe I missed the "save image" command in the help files!
Your Mandelbrot program is excellent spooky, it's given me a few good tips.
Thanks again.


Why do so many people lose the ability to spell the word "lose"?

Login to post a reply

Server time is: 2024-11-27 14:40:19
Your offset time is: 2024-11-27 14:40:19