Recent posts

#1
OxygenBasic Examples / OpenGl NeHe 5 and Fonts (rotat...
Last post by Frank Brübach - Yesterday at 10:30:05 PM


Here's a little oxygen Basic openGL example Like NeHe 5 basically example but included Fonts with Rotation too


'
' -- openGL example pyramid + cube, nehe 5 by frank bruebach, 22-10-2023, 14-07-2024
  ' -- oxygenbasic, with fonts
  '
  'includepath "$\inc\"
  $ FileName "testOpglNehe5.exe"
  'include  "RTL32.inc"
  'include  "RTL64.inc"
  $ title    "Rotating cube + pyramid (nehe 5) + fonts"
  $ fontA =  "Arial",FW_SEMIBOLD

  int width=640
  int height=480
  uses OpenglSceneFrame.inc

  sub Initialize(sys hWnd)
  '=======================
  end sub
  '

  procedure drawPyramid() 'test
  =======================
  static single ang1,angi1
  static single framecounter

  framecounter++
  gltranslatef -0.5,0.5,-1
  glrotatef angi1,0.0,1.0,0.0
  'glscalef    0.01,0.01,0.01
  glscalef    1.5,1.5,1.5
  glBegin GL_TRIANGLE_FAN
    glColor3f  0, 128, 255 : glVertex3i  0.0,  1.0,  0.0
    glColor3f 255,  0,  0 : glVertex3i -1.0, -1.0,  1.0
    glColor3f 255, 255, 255 : glVertex3i  1.0, -1.0,  1.0
    glColor3f  0,  0, 255 : glVertex3i  1.0, -1.0, -1.0
    glColor3f  0, 255,  0 : glVertex3i -1.0, -1.0, -1.0
    glColor3f 255,  0,  0 : glVertex3i -1.0, -1.0,  1.0
  glEnd
  angi1 += 180.0/framecounter
end procedure

  sub Scene(sys hWnd)
  '==================
  '
  static single ang1,angi1=1
  '
  NewFrame
  glClearColor 0.5, 0.5, 0.7, 0.0
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
  Fog          0.5, 0.5, 0.7, 0.05 'rgb and density
 
  glLoadIdentity
  gltranslatef    -1.0, -1.0, -8.0 '-6.0
  glrotatef ang1, 0.0, 0.0,  1.0
  '
  ''glBegin GL_TRIANGLES
  ''glColor3f  1.0, 0.0, 0.0 : glVertex3f  0.0,  1.0, 0.0
  ''glColor3f  0.0, 1.0, 0.0 : glVertex3f  -1.0, -1.0, 0.0
  ''glColor3f  0.0, 0.0, 1.0 : glVertex3f  1.0, -1.0, 0.0
  ''glEnd

    glLoadIdentity
    gltranslatef    2.0, 0.0, -6.0
    glscalef 0.75,0.75,0.75
    glrotatef ang1, 0.0, 1.0,  1.0
   
  glBegin GL_QUADS          ' Drawing using Quads
    ' Top Quad
    glColor3f 0, 255, 0          ' Green   
    glVertex3f  1.0,  1.0, -1.0  ' Top Right
    glVertex3f -1.0,  1.0, -1.0  ' Top Left
    glVertex3f -1.0,  1.0,  1.0  ' Bottom Left
    glVertex3f  1.0,  1.0,  1.0  ' Bottom Right

    ' Bottom Quad
    glColor3f 255, 127, 0        ' Orange   
    glVertex3f  1.0, -1.0,  1.0  ' Top Right
    glVertex3f -1.0, -1.0,  1.0  ' Top left
    glVertex3f -1.0, -1.0, -1.0  ' Bottom Left
    glVertex3f  1.0, -1.0, -1.0  ' Bottom Right

    ' Front Quad
    glColor3f 255, 0, 0          ' Red   
    glVertex3f  1.0,  1.0,  1.0  ' Top Right
    glVertex3f -1.0,  1.0,  1.0  ' Top Left
    glVertex3f -1.0, -1.0,  1.0  ' Bottom Left
    glVertex3f  1.0, -1.0,  1.0  ' Bottom Right

    ' Back Quad
    glColor3f 255, 255, 0        ' Yellow
    glVertex3f  1.0, -1.0, -1.0  ' Bottom Left
    glVertex3f -1.0, -1.0, -1.0  ' Bottom Right
    glVertex3f -1.0,  1.0, -1.0  ' Top Right
    glVertex3f  1.0,  1.0, -1.0  ' Top Left
   
    ' Left Quad
    glColor3f 0, 0, 255          ' Blue
    glVertex3f -1.0,  1.0, -1.0  ' Top Right
    glVertex3f -1.0, -1.0, -1.0  ' Top Left
    glVertex3f -1.0, -1.0,  1.0  ' Bottom Left
    glVertex3f -1.0,  1.0,  1.0  ' Bottom Right
   
    ' Right Quad
    glColor3f 255, 0, 255        ' Violet
    glVertex3f  1.0,  1.0, -1.0  ' Top Right
    glVertex3f  1.0,  1.0,  1.0  ' Top Left
    glVertex3f  1.0, -1.0,  1.0  ' Bottom Left
    glVertex3f  1.0, -1.0, -1.0  ' Bottom Right
 
  glEnd
 
  'UPDATE ROTATION ANGLES
  '----------------------
  '
  glLoadIdentity
  gltranslatef    -1.0, 0.0, -6.0 '-4.0
 
  drawpyramid()
'---------------- //
  glPushMatrix
  '
  glLoadIdentity
  static int framecount
  sys x,y
  framecount++
  gltranslatef -.5,.25,-4.0
  'glColor3f    .99,.50,.50
  glColor3f    .99,.20,.20
  glscalef     .2,.2,.01
  gprint       str(framecount)
  '
  glpopmatrix

  glpushMatrix
  'glClearColor 0.8, 0.3, 0.5, 0
  glscalef     .2,.2,.01
  glRotatef 90.0,0,0,1
  gprint "Hello Oxygen OpenGL"
  glPopMatrix

  ang1+=angi1
  if ang1>360 then ang1-=360
  '
  glLoadIdentity
  glpushMatrix
  gltranslatef    2.0, 0.0, -4.0
  'glClearColor 0.8, 0.3, 0.5, 0
  glscalef     .2,.2,.01
  glRotatef 90.0,0,0,1
  gprint "Hello nehe 5 example"
  glPopMatrix


  ang1+=angi1
  if ang1>360 then ang1-=360
  '
  end sub

  sub Release(sys hwnd)
  '====================
  end sub
#2
OxygenBasic Examples / Macros improvements?
Last post by Frank Brübach - Yesterday at 10:04:17 PM
Hello Charles..

Yesterday I have Made simple Tests noticed some similar macro Test at freebasic..

' test macros
'
macro join (a,b)  'macro join ? (a,b) 'no way
'a & b 'doesnt work with &
   a + b
end macro

print join 2,4 '6 go
print join "a","b" '' ab go
print join ("a","b") '' ab go

dim s1 as string = join (3,8) '11 -> ok
'dim s1 as string = join 3,8 ' doesnt work without () , not ok, undefined type for 8

print s1 '11 ok


dim s1 as string = join ("W","Y") + join ("X", "Y")
'dim s1 as string = join "W","Y" '' + join + "X", "Y" '  undefined type for "Y" problem
print s1

dim s2 as string = join ("W","Y") + join ("X", "Y")

'dim s3 as string = join( "W"  + join( "X", "Y") ) ' not found [b
'dim s4 as string = join + join ("W", "X") '' not found [b


print s2  '' WYXY WYXY
'print s3 
'print s4

macro cube(v)
v*v*v
end macro

print cube 3 '27 ok

macro cube(v)
v+v-v
end macro

print cube "a","c" 'aaac ok
#3
🚀 Exciting news! With the next update, the SmartPacketRobot will receive a major upgrade for the preprocessor – the biggest update yet!

🔧 You'll now be able to define preprocessor variables. Interestingly, the same variables used at runtime will be available. By default, they're in Module-Space 255 but will be accessible at runtime as well if you select Module-Space 255.

🤖 The update also introduces a Preprocessor if-else-and-if directive. This allows you to check these variables, numbers, formulas, and even lists, and remove lines or blocks of code accordingly.

✨ As the cherry on top, there's a new multi-select feature, similar to Select-Case-Case-Else, allowing the preprocessor to choose from various code options that will be included in the final code. This is particularly useful for creating different versions of a program.

PS: Its all ready, just not yet online.

📈 Overall, extensive improvements and enhancements for the SmartPacketRobot's preprocessor are coming!

#SmartPacketRobot #Update #TechNews #CodingLife #Preprocessor #Innovation 🚀🤖✨🔧📈💻
#4
OxygenBasic Examples / Re: Declare function (test DLL...
Last post by Frank Brübach - July 13, 2024, 07:13:57 PM
Update . Sorry load wrong File

'
' problem with testing and calling a function for a dll
'
declare function dosome lib "Avengerbasic2.dll" () as sys
declare function recursivefactorial lib "Avengerbasic2.dll" (int s) as sys

' missing or unloadable recursivefactorial

Solved! Sorry.. "recursiveFactorial" must be the Name of the function  exactly Like in my dll

'recursiveFactorial (ByVal n As Integer) As sys export

dosome

Print recursiveFactorial(4) ' 24 ''
Print recursiveFactorial(6) ' 720

All OK Here .. my mistake

I have missed one Capital Letter  F instead of f Example Works AS expected 
#5
OxygenBasic Examples / Declare function (test DLL)
Last post by Frank Brübach - July 13, 2024, 06:59:54 PM
Hello Charles,

Made a simple Test with an DLL Here Avengerbasic2.dll

and a factorial function in it but the declare function to Test the DLL doesn't Work I am doing Something wrong?

'
' problem with testing and calling a function for a dll
'
declare function dosome lib "Avengerbasic2.dll" () as sys
declare function recursivefactorial(byval n as integer) lib "Avengerbasic2.dll" () as sys
' line 5 not found as

'recursiveFactorial (ByVal n As Integer) As sys export

dosome

Print recursiveFactorial(4) ' 24 ''
Print recursiveFactorial(6) ' 720
#6
OxygenBasic / Re: Question about Redim Strin...
Last post by Roland Stowasser - July 13, 2024, 01:20:06 PM
Thank you Charles. Passing an argument string *dat(redim) was new to me and it is brilliant! I changed the names and I also passed count  by reference and Extend_dat() is declared now:

sub Extend_dat(string *data(Redim), int *cnt)

For me this is very impressive. I just have to remember it.

Test_Redim_String(redim).o2bas:

uses console

cls
printl "Redim String Test in procedure"
printl
 
int count = 20
redim string dat(count)
printl "count = " count
dat(10) = "Hello" : dat(11) = "World!"
printl dat(10) " " dat(11) : printl
'dat(40) = "Goodbye!" // will crash, which is ok

count += 20
printl "count = " count
redim string dat(count)
dat(40) = "Goodbye!"
printl dat(10) " " dat(11) " " dat(40) : printl

sub Extend_dat(string *data(Redim), int *cnt)
  printl "in Extend_dat procedure:"
  printl "cnt = " cnt
  printl data(10) " " data(11) " " data(40) : printl
 
  cnt +=20
  printl "cnt = " cnt
  redim string data(cnt)
  data(60) = "See you later!"
  printl data(10) " " data(11) " " data(40) " " data(60) : printl
end sub

Extend_dat(dat(), count)

printl "After Extend_dat procedure:"
printl "count = " count
printl dat(10) " " dat(11) " " dat(40) " " dat(60)
printl

printl "Enter ..." : waitkey
#7
OxygenBasic / Re: Question about Redim Strin...
Last post by Charles Pegge - July 13, 2024, 12:16:26 PM
Hi Roland,

To pass all the redim attributes to a procedure, the array must be passed by reference with brackets containing redim

sub Extend_dat(string* dat(redim), int count)

Alternatively, because you have defined Dat in global space, you can omit it as a parameter, then the procedure will be operating directly on the global Dat

sub Extend_dat(int count)

#8
OxygenBasic Examples / Re: OpenGL question gprint
Last post by Charles Pegge - July 13, 2024, 11:46:02 AM
Well done Frank. As you can see, setting up Opengl is not easy. It took me years to develop the OpenglScene framework for Oxygen. But I have just spotted a problem with the FontA and FontB macros. Currently they have a fixed definition which overrides the user definition. So I will try to resolve this for the next release.
#9
OxygenBasic / Question about Redim String
Last post by Roland Stowasser - July 13, 2024, 10:56:07 AM
Hi Charles,

it seems to me that redim string(n) does not preserve contents if using in a  procedure? Is there a solution / workaround or am I doing simply something wrong?

Test_redim_string.o2bas:

uses console

cls
printl "Redim String Test in procedure"
printl
 
int count = 20
redim string dat(count)
printl "count = " count
dat(10) = "Hello" : dat(11) = "World!"
printl dat(10) " " dat(11) : printl
'dat(40) = "Goodbye!" // will crash, which is ok

count += 20
printl "count = " count
redim string dat(count)
dat(40) = "Goodbye!"
printl dat(10) " " dat(11) " " dat(40) : printl

sub Extend_dat(string dat(), int count)
printl "in Extend_dat procedure:"
printl "count = " count
printl dat(10) " " dat(11) " " dat(40) : printl
 
count +=20
printl "count = " count
redim string dat(count)
printl "dat(10,11,40) = ? " dat(10) " " dat(11) " " dat(40) : printl
end sub

Extend_dat(dat(), count)

printl "Enter ..." : waitkey

#10
OxygenBasic Examples / Re: OpenGL question gprint
Last post by Frank Brübach - July 13, 2024, 12:08:59 AM
Hello Charles.. only a Message that I Have built an Powerbasic example with rotating Font with 90 degrees and that was some piece of Work to find the solution ;) I did and found solution in a gprint function of an NeHe 17 example..

Thx nevertheless.. its Always interesting to Adept Code example or looking for similar Setups in OpenGL or other winapi examples.. I wanted to solve the solution and I did it..

Regards, Frank