LB Booster
« OPEN GL »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 05:15am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 hotthread  Author  Topic: OPEN GL  (Read 1495 times)
bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx OPEN GL
« Thread started on: Jan 28th, 2015, 09:01am »

i font on internet this Code:
   nomainwin
    struct PFD,   Size as word, Version as word, Flags as long,_
      PixelType as char[1], ColorBits as char[1], RedBits as char[1],_
      RedShift as char[1], GreenBits as char[1], GreenShift as char[1],_
      BlueBits as char[1], BlueShift as char[1], AlphaBits as char[1],_
      AlphaShift as char[1],AccumBits as char[1], AccumRedBits as char[1],_
      AccumGreenBits as char[1], AccumBlueBits as char[1], AccumAlphaBits as char[1],_
      DepthBits as char[1], StencilBits as char[1], AuxBuffers as char[1],_
      LayerType as char[1], Reserved as char[1], LayerMask as long,_
      VisibleMask as long, DamageMask as long
    PFD.Version.struct=1
    PFD.ColorBits.struct=24
    PFD.DepthBits.struct=16
    PFD.Size.struct=len(PFD.struct)
    PFD.Flags.struct=37
    GlColorBufferBit=16384
    open "opengl32.dll" for dll as #gl
    WindowWidth=500
    WindowHeight=500
    UpperLeftX=1
    UpperLeftY=1
    graphicbox #main.gr, 1, 1, 480, 480
    open "Triangle" for window as #main
    print #main,"trapclose [quit]"
    MainH=hwnd(#main.gr)
    #main.gr, "down"
    calldll #user32,"GetDC", MainH as ulong, MainDC as ulong
    calldll #gdi32,"ChoosePixelFormat", MainDC as ulong, PFD as struct, ret as long
    calldll #gdi32, "SetPixelFormat", MainDC as ulong, ret as long, PFD as struct, t as long
    calldll #gl,"wglCreateContext", MainDC as ulong, GLContext as ulong
    calldll #gl,"wglMakeCurrent", MainDC as ulong, GLContext as ulong, ret as long
    calldll #gl,"glClear", GlColorBufferBit as long,  ret as long
    calldll #gl,"glRotated", 0 as double, 0 as double, 0 as double, 0 as double, ret as long
    calldll #gl,"glBegin", 4 as long, ret as long
    calldll #gl,"glColor3d", 0 as double, 0 as double, 255 as double, ret as long
    calldll #gl,"glVertex3i", -1 as long, -1 as long, 0 as long, ret as long
    calldll #gl,"glColor3d", 255 as double, 0 as double, 0 as double, ret as long
    calldll #gl,"glVertex3i", 0 as long, 1 as long, 0 as long, ret as long
    calldll #gl,"glColor3d", 0 as double, 255 as double, 0 as double, ret as long
    calldll #gl,"glVertex3i", 1 as long, -1 as long, 0 as long, ret as long
    calldll #gl,"glEnd", ret as void
    calldll #gdi32,"SwapBuffers", MainDC as ulong, ret as long
    #main.gr, "place 220 220"
    #main.gr, "\LB Graphics and OpenGL"
    #main.gr, "color red"
    #main.gr, "circle 100"
    wait

[quit]
    calldll #gl,"wglMakeCurrent", 0 as ulong, 0 as ulong, ret as long
    calldll #gl,"wglDeleteContext", GLContext as ulong, ret as long
    calldll #user32, "ReleaseDC", MainH as ulong, MainDC as ulong,ret as long
    close #main
    close #gl
    end
 
 
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: OPEN GL
« Reply #1 on: Jan 28th, 2015, 09:12am »

i rebild it to :

see last post at :
http://libertybasic.nl/viewtopic.php?f=4&t=637

error :
- my polygons are not sorting

future :
- split this in modules
- OOP [ it wil not be compatible whit LB anymore ]
« Last Edit: Jan 28th, 2015, 09:24am by bluatigro » User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: OPEN GL
« Reply #2 on: Jul 6th, 2015, 09:05am »

update :
- sorting is now right

code at :
http://libertybasic.nl/viewtopic.php?f=4&t=637

see :
[solved] opengl : rot cube
and :
openGL : avatar robot

error :
- if i move the robot in z direction
it [ partly ] disapeers somtimes



« Last Edit: Jul 6th, 2015, 09:10am by bluatigro » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: OPEN GL
« Reply #3 on: Jul 6th, 2015, 10:51am »

on Jul 6th, 2015, 09:05am, bluatigro wrote:
code at :
http://libertybasic.nl/viewtopic.php?f=4&t=637#p2509

To make this work in LBB you must change open for graphics to open for window (in LBB graphics windows are buffered in memory, so they 'stick' without the use of flush, and OpenGL cannot render to a memory DC):

Code:
open "Avatar : robot 1.0" for window as #m 

This change isn't compatible with LB 4.04 because "when characterInput [key]" is rejected, so if you want to maintain compatibility you can do:

Code:
  if instr(Platform$, "LBB") then
    open "Avatar : robot 1.0" for window as #m
  else
    open "Avatar : robot 1.0" for graphics as #m
  end if  

Richard.
« Last Edit: Jul 7th, 2015, 5:15pm by Richard Russell » User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: OPEN GL
« Reply #4 on: Jul 13th, 2015, 1:16pm »


update :
- i made a minion avatar !

code at :
http://libertybasic.nl/viewtopic.php?f=4&t=637
see :
opengl : minion
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: OPEN GL
« Reply #5 on: Jul 13th, 2015, 1:56pm »

on Jul 13th, 2015, 1:16pm, bluatigro wrote:
- i made a minion avatar !
http://libertybasic.nl/viewtopic.php?f=4&t=637#p2511

It's a good example of the speed benefit of LBB over LB.

When run on a 'widescreen' (16:9) display the aspect ratio isn't right (the minion is rather fat!) but my knowledge of OpenGL is not good enough to fix it.

Richard.
User IP Logged

RobM
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 91
xx Re: OPEN GL
« Reply #6 on: Jul 13th, 2015, 11:45pm »

Under the "[tmr]" branch you can decrease the first value in the two "call glScale" lines. You should be able to use DisplayWidth & DisplayHeight to calculate the correct ratio, if you are so inclined.

Code:
call glScale 0.<change me>,0.3,0.3 
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: OPEN GL
« Reply #7 on: Jul 14th, 2015, 07:40am »


update :
- right scale

error ? :
- the animation is a litle shaky

change the Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
 

Code:
[tmr]
  scan
  call glClear GL.COLOR.BUFFER.BIT or GL.DEPTH.BUFFER.BIT
  call glLoadIdentity
  call glTranslate .6,.3,0
  call glScale 0.3*winy/winx,0.3,0.3
  call glRotate angle , 0,1,0
  call walk.man angle * 3 , 30
  call minion
  call glLoadIdentity
  call glTranslate -.6,0,0
  call glScale 0.3*winy/winx,0.3,0.3
  call glRotate angle , 0,1,0
  call robot

  calldll #gdi32,"SwapBuffers" _
  , MainDC as ulong _
  , ret as long
  angle = angle + 5
wait

 
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: OPEN GL
« Reply #8 on: Jul 17th, 2015, 09:27am »


update :
- scaled better

Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , winyx
winx = WindowWidth
winy = WindowHeight
winyx = winy / winx
 

Code:
[tmr]
  scan
  call glClear GL.COLOR.BUFFER.BIT or GL.DEPTH.BUFFER.BIT
  call glLoadIdentity
  call glScale winyx , 1 , 1
  call glPushMatrix
    call glTranslate .6,.3,0
    call glScale 0.3,0.3,0.3
    call glRotate angle , 0,1,0
    call walk.man angle * 3 , 30
    call minion
  call glPopMatrix
  call glPushMatrix
    call glTranslate -.6,0,0
    call glScale 0.3,0.3,0.3
    call glRotate angle , 0,1,0
    call robot
  call glPopMatrix

  calldll #gdi32,"SwapBuffers" _
  , MainDC as ulong _
  , ret as long
  angle = angle + 5
wait
 
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: OPEN GL
« Reply #9 on: Jul 21st, 2015, 08:55am »

update :
- minion whit glasses

Code:
sub minion
  call setbox 0 , 1 , 0 , 1 , 1 , 1
  call sphere 24 , 24 , yellow
  call setbox 0 , .5 , 0 , 1 , .5 , 1
  call cylinder 24 , 1 , 1 , yellow
  call setbox 0 , -1 , 0 , 1 , 1 , 1
  call sphere 24 , 24 , blue
  call setbox 0 , -.5 , 0 , 1 , .5 , 1
  call cylinder 24 , 1 , 1 , blue
  call glPushMatrix
    call glTranslate .4 , .7 , -.8
    call glRotate 90 , 1 , 0 , 0
    call setbox 0,0,0 , .4,.4,.4
    call cylinder 12 , 1 , 1 , gray
  call glPopMatrix
  call glPushMatrix
    call glTranslate -.4 , .7 , -.8
    call glRotate 90 , 1 , 0 , 0
    call setbox 0,0,0 , .4,.4,.4
    call cylinder 12 , 1 , 1 , gray
  call glPopMatrix
  call glPushMatrix
  call child .4 , .7 , -.8 , eye , xyz
    call setbox 0,0,0 , .3,.3,.3
    call sphere 12 , 12 , white
    call setbox 0,0,-.3 , .1,.1,.1
    call sphere 12 , 12 , black 
  call glPopMatrix 
  call glPushMatrix
  call child -.4 , .7 , -.8 , eye+lr , xyz
    call setbox 0,0,0 , .3,.3,.3
    call sphere 12 , 12 , white
    call setbox 0,0,-.3 , .1,.1,.1
    call sphere 12 , 12 , black 
  call glPopMatrix 
  call glPushMatrix
  call child 1 , -.3  , 0 , arm , xzy
    call setbox 0,0,0 , .2,.2,.2
    call sphere 12 , 12 , yellow
    call setbox .2,-.5,0 , .1,.5,.1
    call cylinder 12 , 1 , 1 , yellow
    call glPushMatrix
    call child .2 , -1 , 0 , elbow , xyz
      call setbox 0,-.5,0 , .1,.5,.1
      call cylinder 12 , 1 , 1 , yellow
      call glPushMatrix
      call child 0 , -1 , 0 , wrist , yzx
        call setbox 0,-.3,0 , .15,.3,.15
        call sphere 12 , 12 , yellow
      call glPopMatrix
    call glPopMatrix
  call glPopMatrix
  call glPushMatrix
  call child -1 , -.3  , 0 , arm+lr , xzy
    call setbox 0,0,0 , .2,.2,.2
    call sphere 12 , 12 , yellow
    call setbox -.2,-.5,0 , .1,.5,.1
    call cylinder 12 , 1 , 1 , yellow
    call glPushMatrix
    call child -.2 , -1 , 0 , elbow+lr , xyz
      call setbox 0,-.5,0 , .1,.5,.1
      call cylinder 12 , 1 , 1 , yellow
      call glPushMatrix
      call child 0 , -1 , 0 , wrist+lr , yzx
        call setbox 0,-.3,0 , .15,.3,.15
        call sphere 12 , 12 , yellow
      call glPopMatrix
    call glPopMatrix
  call glPopMatrix
  call glPushMatrix
  call child .5 , -1 , 0 , leg , yxz
    call setbox 0,-.5,0 , .2,.5,.2
    call cylinder 12 , 1 , 1 , blue
    call glPushMatrix
    call child 0 , -1 , 0 , knee , xyz
      call cylinder 12 , 1 , 1 , blue
      call glPushMatrix
      call child 0 , -1 , 0 , enkle , zxy
        call setbox 0,0,-.3 , .2,.2,.4
        call cube gray,gray,gray,gray,gray,gray
      call glPopMatrix
    call glPopMatrix
  call glPopMatrix
  call glPushMatrix
  call child -.5 , -1 , 0 , leg+lr , yxz
    call setbox 0,-.5,0 , .2,.5,.2
    call cylinder 12 , 1 , 1 , blue
    call glPushMatrix
    call child 0 , -1 , 0 , knee+lr , xyz
      call cylinder 12 , 1 , 1 , blue
      call glPushMatrix
      call child 0 , -1 , 0 , enkle+lr , zxy
        call setbox 0,0,-.3 , .2,.2,.4
        call cube gray,gray,gray,gray,gray,gray
      call glPopMatrix
    call glPopMatrix
  call glPopMatrix
end sub
 
« Last Edit: Jul 21st, 2015, 08:55am by bluatigro » User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: OPEN GL
« Reply #10 on: Jul 21st, 2015, 1:18pm »



update :
- more shapes in subs

code at :
http://libertybasic.nl/viewtopic.php?f=4&t=637

see :
opengl : meer vormen in subs



User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: OPEN GL
« Reply #11 on: Jul 22nd, 2015, 8:49pm »

on Jul 21st, 2015, 1:18pm, bluatigro wrote:
see :
opengl : meer vormen in subs

Direct link:
http://libertybasic.nl/viewtopic.php?f=4&t=637&start=15#p2515
User IP Logged

RNBW
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 106
xx Re: OPEN GL
« Reply #12 on: Jul 23rd, 2015, 09:29am »

This shows the difference in speed between LBB and LB!

The figures crawl and stutter in LB, whereas in LBB they move quickly and smoothly.

grin
User IP Logged

bluatigro
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 111
xx Re: OPEN GL
« Reply #13 on: Jul 25th, 2015, 11:27am »


update :
- now whiot torus

code at :
http://libertybasic.nl/viewtopic.php?f=4&t=637&p=2517#p2517
User IP Logged

RNBW
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 106
xx Re: OPEN GL
« Reply #14 on: Jul 25th, 2015, 2:08pm »

I've not looked at the updated code, but it has improved the speed on LB and no longer stutters, although it is not showing as much on the screen (it's now just a sort of doughnut).

However, loading the code into LBB shows that it is still much quicker and smoother than LB. All credit to Richard Russell and BB4W.

smiley
User IP Logged

Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »


This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls