Recent posts

#1
OxygenBasic Examples / Re: Axis + Curves Coordinates
Last post by Charles Pegge - Today at 03:44:00 PM
This example is fairly close:

You can move / rotate the graph by dragging the origin (TouchZone)

.\demos\OpenGl\DataGraphs\XYZBarLinePlot.o2bas


  % Title "Graph"
 '% Animated
  % ScaleUp
 '% PlaceCentral
 '% AnchorCentral

  uses glo2\GraphUtil


  sub main
  ========
  static sys   imgn,res,wi,ht
  cls

  pushstate 'FOR GRAPH
  '
  static MoveableObject gr
  if not gr.id
    gr.mode=0x111
    gr.snap=.1
    gr.set 100, 0, 5, -16, 0
  end if
  gr.act
  TouchZone
  'color 0,.8,.8,1
  linescale 20.0, 1.0,  .3, 5  'X AXIS
  glRotatef  90,0,1,0
  linescale 20.0, 1.0,  .3, 5  'Z AXIS
  glRotatef -90,0,1,0
  glRotatef  90,0,0,1
  linescale  10.0, 1.0, -.3, 5 'Y AXIS
  glRotatef -90,0,0,1
  '
  'GRIDS
  thickness 1
  color      0,.4,.4,1.
  glRotatef -90,1,0,0
  grid       1,20,20 'FLOOR GRID
  glRotatef  90,1,0,0
  '
  glRotatef  90,0,1,0
  grid       1,20,10 'SIDE GRID
  glRotatef -90,0,1,0
  '
  'X AXIS VALUES
  color .5,1
  pushstate
  move 0,-1.5
  numscale 0,0,10,0,  0,10,2,1,  3 'X NUMBERS
  glRotatef  90,0,1,0
  numscale 0,0,10,0,  0,10,2,1,  3 'Z NUMBERS
  glRotatef -90,0,1,0
  '
  popstate
  'Y AXIS VALUES
  color .99,.50
  pushstate
  move -3
  numscale 0,0,0,5,  0,500,3,0,  3 'Y NUMBERS
  popstate
  'PLOTS
  float d={ 0,1,-0,  5,2,-5,  10,5,-10,  20,9,-15 }
  sys   n=countof(d)/3
  '
  pushstate
    shading
   'color 1.,.3,.0  :  VertBarPlot3d  n,d, .5
    color 1.,.3,.0  :  VertRodPlot3d  n,d, .5
    move 6,8,-10
    'go cube
    'color 1.,.7,.0  :  go sphere
    flat
  popstate
  '
  thickness 2 : color 1.,1.,.0  :     LinePlot3d  n,d
 'thickness 3 : color .0,.5,.0  : VertLinePlot    n,d
 'thickness 3 : color .0,.5,.0  : HorzLinePlot    n,d
  move 0,0,.01
  PointSize 12 : color 0,0,.5,1 : PointPlot3d     n,d
  move 0,0,-.01
 'color .7,.5,.0  : VertBarPlot  n,d, 1.0
 'color .7,.5,.0  : HorzBarPlot  n,d, 1.0
  '
  popstate 'END OF GRAPH
  '
  pushstate
  static MoveableObject title
  if not title.id
    title.mode=0x111
    title.snap=.1
    title.set 200, 0, 2, -3, 0
  end if
  title.act
  TouchZone .5
  scale 2
  printl "3D Graphs"
  popstate
  end sub 'main

  EndScript

#2
It's time for you to get some insights that you don't see in the daily news. In fact, Ukraine is completely lost and there is nothing that can save Ukraine.
🇺🇸 Americans are pledging an additional $60 billion to Ukraine, but why?

The truth is, 90% of that money will stay in the US and line the pockets of the weapons industry. Only 10% will actually go to Ukraine. This is just a way for the current president to pay for his own costs and for those who support him.

And of course, the US wants compensation from Europe, particularly Germany, who will also end up buying weapons from the US. It's all just a big arms deal. 💰🔫 #Ukraine #USA #Germany #ArmsDeal

😔💔 #Ukraine #lost #news #insights



#3
🔍 Just tested the subprogram below and it's a game changer! 🚀 It closes brackets on both sides, even in complicated cases. 💪 And it's all thanks to a stack.
But not just any stack, the built-in PowerBasicStack object. ⚡️ However, it's a bit slow. ⏱️ So I compared it to using a normal string, which also works in this case, and the difference in speed is mind-blowing.

⚡️ 74 ticks for PowerBasicStack vs. 21 ticks for normal string.

 🤯 #coding #programming #PowerBasicStack #bracketcloser #gamechanger #speed #stacks #strings

🤔 Have you ever wondered why Bob added those weird objects for stacks and queues in his latest version? 🤔 It goes against the core philosophy of smaller and faster in Power Basic. Instead, they are slow, bloated, and mostly useless. 🚫 #programming #powerbasic #stacks #queues 🚀

' More complex will also handle: "3.141*5)))+(((3.141*5)*(3.141*5.56"
'
#IF 1
SUB A_BBS(BYREF T01 AS STRING, BYVAL T03 AS STRING, BYVAL T04 AS STRING)
  LOCAL char AS STRING
  LOCAL V01 AS VARIANT
  REGISTER i AS LONG,j AS LONG
  Make_Stack(stack)

  V01=0
  FOR i = 1 TO LEN(T01)
    char = MID$(T01, i, 1)
    IF char = T03 THEN
      stack.Push V01
    ELSEIF char = T04 THEN
      IF stack.COUNT = 0 THEN
        ' Unmatched closing delimiter, add an opening delimiter at the beginning
        T01 = T03 & T01
        i = i + 1
      ELSE
        V01=stack.Pop
      END IF
    END IF
  NEXT i

  ' Add missing closing delimiters
  WHILE stack.COUNT > 0
    V01=stack.Pop
    T01 = T01 & T04
  WEND
END SUB
#ELSE
SUB A_BBS(BYREF T01 AS STRING, BYVAL T03 AS STRING, BYVAL T04 AS STRING)
    LOCAL char AS STRING
    LOCAL nesting AS STRING
    REGISTER i AS LONG, j AS LONG

    FOR i = 1 TO LEN(T01)
        char = MID$(T01, i, 1)
        IF char = T03 THEN
            nesting = nesting + "a"  ' Add a character for each opening delimiter
        ELSEIF char = T04 THEN
            IF LEN(nesting) = 0 THEN
                ' Unmatched closing delimiter, add an opening delimiter at the beginning
                T01 = T03 & T01
                i = i + LEN(T03)
            ELSE
                nesting = LEFT$(nesting, LEN(nesting) - 1)  ' Remove the last character
            END IF
        END IF
    NEXT i

    ' Add missing closing delimiters
    WHILE LEN(nesting) > 0
        T01 = T01 & T04
        nesting = LEFT$(nesting, LEN(nesting) - 1)
    WEND
END SUB
#ENDIF
#4
OxygenBasic Examples / Re: Class example salary
Last post by Theo Gottwald - Yesterday at 08:00:46 PM
Maybe Thread functions that can have all sorts of IN/OUT Parameters would be a great feature that beats Powerbasic as it currently is.
#5
OxygenBasic Examples / Moveable objects qt
Last post by Frank Brübach - Yesterday at 07:35:23 PM
One more question about General programming with consoleG

It's possible in moveable objects with Text to produce a collision without using the glVertex x,y,z with the Standard programming (Pong Game)  and to use IT for example a GL_Quads AS one closed Block you can move and let make a collision?


'-- test openGL oxygen
 '-- moveable text and objects part two, frank bruebach
 '-- 24-25/02/2024
 
   ' Question: its possible to make a collision between object 500 and 400 both cubes 
   ' without using the standard way of collision with glVertex3f x,y,z ? 
   ' perhaps it's possible to use the GL_QUADS below as one new Object as a "block" ?
  
 #compact
 % Title "ConsoleG Demo:  Move text and objects with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
 '% Animated
  '% ScaleUp
  % PlaceCentral
  % AnchorCentral

  % shaders

  $filename "t.exe"
 'uses RTL64
  uses consoleG
 
  'Keys: Esc, arrow-keys, n,m, F4

  BeginScript

  sub main
  ========

  'WaitForEvent '0 off 1 on (default on)
  static int  z, y, x
  static quad t1,t2,t3
  if opening then 'FIRST CALL ONLY
    timemark t1
    picked=100
    'mbox "helo"
  end if
  '
  if closing then 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    'exit sub
  end if
  cls
  pushstate
  color 1,.5,0,1
  UserMovement m1,100 'identity in steps of 100
  scale 2, 3
  print "Hello "
  popstate
  move 5

  pushstate
  color 1,1,0,1
  UserMovement m2,200
  scale 4
  print "World"
  popstate

  if not pick then
    if key[49] then picked=100 'keypress '1'
    if key[50] then picked=200 'kypress  '2'
    pushstate
    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    macro pr(a,b) 'PRINTING LIST
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 8 : print b : popstate
      printl ""
    end macro
    '
   'pr "Action Code:   ", str(act)
    pr "Picked ID:     ", str(picked)
    pr "Keyboard Code: ", str(keyd)
    popstate
  end if

  cls 0.0, 0.2, 0.7
  shading
  scale 1 '3
  move 1,-4
  pushstate
    Material Gold
    UserMovement m3,300
    static float ang
    rotateX 'ang
    rotateY 'ang
    scale 1,3,4
    go cube
  popstate
  'ang+=.5 : if ang>=360 then ang-=360

'--------------------------------- //
'
  scale 2 '3
  move -4,-2
  pushstate
 
      UserMovement m4,400
' -- Creates quads, shapes with 4 vertices
      glbegin GL_QUADS
        glcolor4f   1,0,0,1    ' 255 -- Red color       
        glvertex3f -1, -1,  0
       
        glcolor4f   0, 1,   0,1    ' -- Green color               
        glvertex3f  1, -1,  0
               
        glcolor4f   0,   0, 1,1    ' -- Blue color                       
        glvertex3f  1,  1,  0       
       
        glcolor4f 1, 1, 0,1      ' -- Yellow color                               
        glvertex3f -1,  1,  0               
      glend
popstate

'------------------ left little cube --------------- //
'
  static single ang1,angi1=-2,angi2=1
  static float ang,ang2
  float s1,s2,s3,s4
      's1=.2
      's2=-1
      's3=0.5
      's4=s3*.2
      s1=.4
      s2=-2
      s3=1.5
      s4=s3*.4

  scale 2.5
  move -3,2
  pushstate
  Material Gold
  UserMovement m5,500

   ' its possible to make a collision between object 500 and 400 both cubes 
   ' without using the standard way of collision with glVertex3f x,y,z ? 
   ' perhaps it's possible to use the GL_QUADS below as one new Object as a "block" ?
     
      glbegin GL_QUADS
      glcolor4f   s3,   0,  s4, 1
      glvertex3f -s1, -s1,  s2

      glcolor4f    0,  s3,  s4, 1
      glvertex3f -s1,  s1,  s2

      glcolor4f   s4,   0,  s3, 1
      glvertex3f  s1,  s1,  s2

      glcolor4f   s3,   0,  s4, 1
      glvertex3f  s1, -s1,  s2
      glend
      popstate
 
  sleep 15
  end sub 'main

  EndScript

I Hope you can follows my thoughts ;)
#6
OxygenBasic Examples / Axis + Curves Coordinates
Last post by Frank Brübach - Yesterday at 07:06:27 PM
Hello Charles again :)

My Idea was to create a simple coordinate system with openGl (consoleG) started this example few days ago but the marks are too Long and perhaps you have an Idea to Set for Marks some values thx, Frank

oxygen

  ' -- opgl test with axis and sin cos curves
  ' -- oxygen by frank bruebach, 15-04-2024
  '
  $ FileName "t.exe"
  $ title    "Triangle and Axis with sin cos curves"
  int width=800
  int height=600

  uses OpenglSceneFrame

  function KeyState(int k) as int
  ===============================
  return GetAsyncKeyState(k) and 0x8000 'key down
  end function

  sub Initialize(sys hWnd)
  '=======================
  end sub
  '
  '--------------------------------------------- //
  sub Scene(sys hWnd)
    'angle = radians(i) ' what is radians(i) it's rad(i) ?

  static single ang1, angi1 = 1
  dim i as integer
  dim x, y, angle as single
  dim radius as single = 2.0
  'dim radius as single = 100.0 ' Larger radius for better curve visibility

 
  glClearColor 0.3, 0.3, 0.5, 0
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
 
  glLoadIdentity
 
  gltranslatef 0.0, 0.0, -10.0 '-4.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
 
  ' Draw axis
  glBegin GL_LINES
  glLineWidth 2.0
  gltranslatef 0,0,-6 '-1
  glscalef 0.01,0.01,0.01
 
  glColor4ub 250,50,0,0 ' X axis color
  glVertex2i -500,0
  glVertex2i 500,0
 
  glColor4ub 0,0,255,0 ' Y axis color
  glVertex2i 0,500
  glVertex2i 0,-500
  glEnd
 
  glBegin GL_LINES
  gltranslatef 0,0,-6
  glscalef 0.5,0.5,0.5
  glColor4ub 0,255,255,0

  ' -- some Marks on axes ---------- //
      for i = -5 to 5 step 1.025
        glVertex2i  i, -0.5001 ' too long and wide the marks (length)
        glVertex2i  i,  0.5001 ' values below 0.5 aren't working
       
        glVertex2i -0.5001, i ' too long and wide the marks (length)
        glVertex2i  0.5001, i ' values below 0.5 aren't working
      next
  glEnd
 
  ' Draw rounded, smooth sine and cosine curves
    'int pi = 3.1415926536

glLineWidth 2.0
glColor4ub 255, 200, 0, 0 
glBegin GL_LINE_STRIP
for i = -360 to 360
angle = i * 3.1415926536 / 180  ' Correct conversion from degrees to radians
glVertex2f i / 360.0 * 2.0 * 3.1415926536, sin(angle)           
next
glEnd

  glBegin GL_LINE_STRIP
    glColor4ub 0, 255, 200, 0
    for i = -360 to 360 'step 5
      angle = i * 3.1415926536 / 180 ' Convert degrees to radians
      glVertex2f i / 360.0 * 2.0 * 3.1415926536, cos(angle) 
    next
  glEnd
  '
  'UPDATE ROTATION ANGLES
  '----------------------
  '
  'ang1+=angi1
  'if ang1>360 then ang1-=360
  '
  end sub


  sub Release(sys hwnd)
  '====================
  end sub

#7
OxygenBasic Examples / Re: Class example salary
Last post by Zlatko Vid - Yesterday at 04:47:45 PM
QuoteWindows kernel thread API.
Yes it is the safest way to use API
i try to use it once but i am not impressed with performance
well maybe this depend on used processor..i am not sure.
#8
Another non-technical piece: Mastery of theoretical physics is no protection against Romance Fraud.

The Prof Who Looked for Love and Ended up in Prison: The Supermodel Scam

Sabine Hossenfelder
20 apr 2024

#9
OxygenBasic Examples / Re: Class example salary
Last post by Charles Pegge - Yesterday at 01:54:59 PM
I would be very cautious about creating and destroying things in the correct order. O2 does not have any built-in thread functions, so you have to use the Windows kernel thread API. Only local variables are inherently thread-safe.
#10
OxygenBasic Examples / Re: Class example salary
Last post by Theo Gottwald - April 18, 2024, 06:49:30 PM
When using Powerbasic Classes, to get B-String Parameters into Threads,I found that when opening and destroying classes, there is some memory Leak in Powerbasic. therefore it an not be used for all cases.
I wonder it would work better in O2, getting String and other Parameters inside Threads and out of there.