Oxygen Basic
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Latest OxygenBasic.zip at GitHub
(Click on the Wizard)
Home
Help
Search
Login
Register
Oxygen Basic
»
Programming
»
Example Code
»
General
»
% Customising Syntax
« previous
next »
Print
Pages: [
1
]
Author
Topic: % Customising Syntax (Read 2084 times)
0 Members and 1 Guest are viewing this topic.
Charles Pegge
Guest
% Customising Syntax
«
on:
November 03, 2014, 12:15:35 PM »
%
line
glBegin GL_LINES : glVertex3f (
%1
) : glVertex3f (
%3
) : glEnd
line
(0,0,-1) to (0,1,-1)
expands to:
glBegin GL_LINES : glVertex3f (0,0,-1) : glVertex3f (0,1,-1) : glEnd
Logged
Mike Lobanovsky
Guest
Re: % Customising Syntax
«
Reply #1 on:
November 03, 2014, 02:23:45 PM »
Can the same be done for Polygon, Circle, Arc, Point, etc. to obtain a standard set of BASIC-like graphics primitives? Noobs will be happy...
Logged
Charles Pegge
Guest
Re: % Customising Syntax
«
Reply #2 on:
November 03, 2014, 11:14:02 PM »
Possibly, Mike.
The underlying functions can be made poymorphic for additional flexibility:
for instance arcs (and fans) can be used for all arcs, circles and symmetrical polygons:
optional Radius, startAng, EndAng, step
Code: OxygenBasic
sub
arc(optional
float
r,a,b,s)
===============================
float
ar,br,c
if
not
r
then
r=1.0
if
a=0.
and
b=0.
then
b=360
if
not
s
then
s=5.0
if
s<0.
then
s=-s
if
b<a
then
c=a : a=b : b=c
'swap
glBegin GL_LINE_STRIP
do
ar=
rad
(a)
br=
rad
(b)
glVertex2f r*
cos
(ar),r*
sin
(ar)
a+=s
if
a>=b
glVertex2f r*
cos
(br),r*
sin
(br)
exit
do
end
if
end
do
glEnd
end
sub
Logged
Print
Pages: [
1
]
« previous
next »
Oxygen Basic
»
Programming
»
Example Code
»
General
»
% Customising Syntax