Oxygen Basic
Programming => Example Code => General => Topic started by: Charles Pegge on May 23, 2011, 07:41:03 AM
-
Two new keywords to support this feature: switch and break
'==============
'C STYLE SWITCH
'==============
for i=0 to 4
switch i
case 0
case 1
case 2
print "A"
break
case 4
print "B"
break
case else
print "C"
end switch
next
'RESULTS: 0:A 1:A 2:A 3:C 4:B
Charles
-
Hi Charles,
Do we have no longer "SELECT CASE" ?
Here is another case, which makes me headache. :-[
/* OxygenBasic version o34 */
Long a=10,b=10,size,j
size = a*a*2
Dim Alpha(size) As Long '<- What ??
For j=0 To size
Alpha(j)=255
Next
Print Alpha(10)
-
Hi Peter,
Switch and break are extras to aid porting C programs into Oxygen :).
Standard Arrays have a fixed memory allocation at compile time so must be sized with a constant, not a variable. There are several ways of creating dynamic arrays. If you need them I can show you the best way depending on the needs of the program.
Long j
% a 10
% b 10
% size a*b*2
Dim Alpha(size) As Long
indexbase 0
For j=0 To size
Alpha(j)=255
Next
Print Alpha(10)
Charles
-
Thanks Charles.
There are two thing ,which I find important for me.
How can I rotate an object to its centre point ? OpenGl is in a 2D mode.
I got always 60 Frames , Why ? I mean, Opengl is hardware!
Are "single's" so slow in OxygenBasic ? Is there a horsefly ?
[attachment deleted by admin]
-
Peter,
I would rotate individual objects about their z axis, assuming your 2D objects are defined in x y coordinates.
glpushmatrix
glTranslatef tra_x, tra_y, tra_z
glRotatef rot_z, 0.0, 0.0, 1.0 'apply self rotation after any translation
'plot object..
glpopmatrix
I think the OS may be restricting your frame rate - this behaviour will not be the same on all platforms.
Charles
-
Check your opengl settings for your video card Peter. Vertical Sync is probably check marked on and it limits it to around 60 frames per second.
In my case it is in advanced 3d settings for my nvidia card.
[attachment deleted by admin]
-
Thanks Charles, K9
I forgot that we have for our graphics card 3D settings .
My frame rates are now 500! For the beginning quite good.
My graphics card is an old relict by Nvidia. If I become 60 years old then will my wife buy a newer card for me. She is so nice to me ! :D