Author |
Topic: OPEN GL (Read 1496 times) |
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
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 » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: OPEN GL
« Reply #3 on: Jul 6th, 2015, 10:51am » |
|
on Jul 6th, 2015, 09:05am, bluatigro wrote: 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.
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: OPEN GL
« Reply #5 on: Jul 13th, 2015, 1:56pm » |
|
on Jul 13th, 2015, 1:16pm, bluatigro wrote: 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.
|
|
Logged
|
|
|
|
RobM
Junior Member
member is offline


Posts: 91
|
 |
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
|
|
Logged
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
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
|
|
Logged
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
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
|
|
Logged
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
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 » |
Logged
|
|
|
|
RNBW
Full Member
member is offline


Gender: 
Posts: 106
|
 |
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.
|
|
Logged
|
|
|
|
RNBW
Full Member
member is offline


Gender: 
Posts: 106
|
 |
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.
|
|
Logged
|
|
|
|
bluatigro
Full Member
member is offline


Gender: 
Posts: 111
|
 |
OPEN GL : rainbow torus
« Reply #15 on: Jul 26th, 2015, 1:32pm » |
|
update : - torus can have rainbow colors
code at : http://libertybasic.nl/viewtopic.php?f=4&t=637&p=2518#p2518
warning : if you make the sides of the totus to great or to smal the code stops whitout showing something
|
|
Logged
|
|
|
|
|