GLBasic

Miscellaneous Forums/General Discussion/GLBasic

has anyone purchased and used this? My biggest interest in it is that it appears to compile for pocketpc and smartphones... Including 3D stuff.

Just had a look at the source for the Mandlebrot test

+ The GLBasic version of the MandleBrot demo is certainly the fastest. The Blitz3D version is there too.

** Maybe someone will do a Max version to see how it compares

(EDIT ** See Below)

+ The Exe sizes are small too.

- Only thing that puts me off is the use of integers for objects (rather than handles like Blitz) and all those X_Whatever commands.

Quick snippet from the Cell Shading example:

	// Bild-Daten / Image data
	LOADSPRITE      "image.bmp", 0

	// Hauptschleife / main loop
	WHILE TRUE
		FILLRECT 0,0,640,480,RGB(0,0,200)
		phi=phi+GETTIMER()/30
		X_MAKE3D 1, 250, 45
		X_CAMERA 0, 10, 100, 0,0,0
		// Licht Nr. -2 is Cel-Shading Postition / Light no -1 is cel shading position
		X_SPOT_LT -2, 0, 0,0,100, 0,0,0,90
		X_CULLMODE 1 // niemals 0 verwenden bei toons / Never use 0 with toon shading
		X_SETTEXTURE 0, -1 // 0=Tex
		X_ROTATION 90, 1,0,0
		X_ROTATION phi, 0, 1, 0.1
		X_DRAWOBJ 1, 0
		SHOWSCREEN
	WEND


It looks quite interesting.

The first thing GLBasic attracts me is the speed, but everyone has his language prefer and I tend to stick with Blitz.

GLBasic may be an option for OpenGL developer, the example game at least shows it can be used to write game....

The author of the language is very approachable so I'm sure if you have any suggestions he will give them some thought.

He is entering a game into the Retro Remakes Competition 2006 which closes in a couple of days, that he has written in GLBasic... Maybe that will be another showcase for the language.

Maybe if some of you have entered the comp you will win a copy of GLBasic too, because it's in the prize list.

Brice informs me that it's compiler is horrid on larger projects. He stated something along the lines of an 11000 line program taking 16 minutes to compile on a 1.2ghz machine. That's scary.

Converted the Mandlebot test to BlitzMax.

As it stands, from the tests in the zip I found the GLBasic basic to be fastest.
(Well, the Darkbasic ones crashed!)

Anyhow, here's the BlitzMax version which positively trounces the GLBasic version:

' Mandelbrot - Speedtest
' Complied under BlitzMax v1.22

SuperStrict
Framework BRL.GLMax2D
Import BRL.Pixmap

Const MaxI%	= 128   	' max iterations
Const SX#		= -2.025 	' start value real
Const SY#		= -1.125 	' start value imaginary
Const EX#		= 0.6    	' end value real
Const EY#		= 1.125  	' end value imaginary

Const x1%		= 640    	' ScreenX
Const y1%		= 480    	' ScreenY
Const xy# 		= Float(x1)/Float(y1)	' x/y-ratio

Global xstart:Double = SX
Global ystart:Double = SY
Global xende:Double = EX
Global yende:Double = EY

Global xzoom:Double = (xende - xstart) / x1
Global yzoom:Double = (yende - ystart) / y1

AppTitle$="BlitzMax Mandlebrot test"
Graphics x1,y1
Global pm:TPixmap=CreatePixmap(x1,y1,PF_RGB888)

While Not KeyHit(KEY_ESCAPE)
	Const fac#=0.99
	Global thistime%, lasttime%
	xende = xende*fac
	xstart:*fac
	ystart:*fac
	yende:*fac
	xzoom = (xende - xstart) / x1
	yzoom = (yende - ystart) / y1
	MandelBrot
	thistime = MilliSecs()
	DrawPixmap pm,0,0
	DrawText "Speed: " + String(Int(x1*y1 / (1+(thistime-lasttime)))) + " Kpix/sec", 0, 0
	lasttime=thistime
	Flip False
Wend

End

' ------------------------------------------------------------- '
' -=#  Mandelbrot  #=-
' ------------------------------------------------------------- '
Function MandelBrot() ' calculate all points
	Global old#
	Local col%
	For Local x% = 0 Until x1
		For Local y% = 0 Until y1
			Local h# = DotsColor(xstart + xzoom * Double(x), ystart + yzoom * Double(y))
			If h <> old
				' Local b# = 1.0 - h * h ' brightness
				col = HSB2RGB(h, 0.8, 1.0 - h * h)
				old = h
			EndIf
			WritePixel pm,x,y,col
		Next
	Next
End Function

' ------------------------------------------------------------- '
' -=#  DotsColor  #=-
' ------------------------------------------------------------- '
Function DotsColor:Float(xval:Double, yval:Double) ' color value from 0.0 to 1.0 by iterations
	Local r:Double, i:Double, m:Double
	Local j:Int
	While (j < MaxI) And (m < 4.0)
		j:+1
		m = r * r - i * i
		i = 2.0 * r * i + yval
		r = m + xval
	Wend
	Return Float(j) / Float(MaxI)
End Function

' ------------------------------------------------------------- ;
' -=#  RGB-Function - Come on, that's an important one...  #=-
' ------------------------------------------------------------- ;
Function RGB%(red%, green%, blue%)
   Return (red Shl 16) + (green Shl 8) + blue
End Function

' ------------------------------------------------------------- '
' -=#  HSB2RGB  #=-
' ------------------------------------------------------------- '
Function HSB2RGB%(hue:Double, saturation:Double, brightness:Double)
	Local red#, green:Double, blue:Double, domainOffset:Double ' hue mod 1/6
	If brightness = 0 Return 0
	If saturation = 0 Return RGB(brightness*255.0, brightness*255.0, brightness*255.0)

	If hue < 1.0/6.0
		' red domain; green ascends
		domainOffset = hue
		red   = brightness
		blue  = brightness * (1.0 - saturation)
		green = blue + (brightness - blue) * domainOffset * 6.0
	ElseIf hue < 2.0/6.0
		' yellow domain; red descends
		domainOffset = hue - 1.0/6
		green = brightness
		blue  = brightness * (1.0 - saturation)
		red   = green - (brightness - blue) * domainOffset * 6.0
	ElseIf hue < 3.0/6.0
		' green domain; blue ascends
		domainOffset = hue - 2.0/6
		green = brightness
		red   = brightness * (1.0 - saturation)
		blue  = red + (brightness - red) * domainOffset * 6.0
	ElseIf hue < 4.0/6.0
		' cyan domain; green descends
		domainOffset = hue - 3.0/6
		blue  = brightness
		red   = brightness * (1.0 - saturation)
		green = blue - (brightness - red) * domainOffset * 6.0
	ElseIf hue < 5.0/6.0
		' blue domain; red ascends
		domainOffset = hue - 4.0/6.0
		blue  = brightness
		green = brightness * (1.0 - saturation)
		red   = green + (brightness - green) * domainOffset * 6.0
	Else
		' magenta domain; blue descends
		domainOffset = hue - 5.0/6.0
		red   = brightness
		green = brightness * (1.0 - saturation)
		blue  = red - (brightness - green) * domainOffset * 6.0
	EndIf
	Return RGB(red*255.0, green*255.0, blue*255.0)
EndFunction


On my rig early into execution:
Version   Kpix/sec
_________ _________
BlitzMax  960
GLBasic   275
Blitz3D   272
VC.Net    233
VB6       202


Hats off to Mark and co once again!

ASM rulez all, it is so fast... Assembler forever! ;)

Can't do the ASM anymore... I learned it in the late 1970's when it was still 8 bit going on to 16 bit. 16 bit added a large chunk into new instruction code... I am afraid to look at the new stuff for 64 bit!

Original MS Basic and GW Basic you could drop down to ASM if BASIC could not do what you wanted... Hmmm how about that as a feature for BMAX or B3D???

I learned it in the late 1970's


Wow....that was before nintendo! :)