openGL

Alles over het toepassen van API en DLL's in Liberty BASIC

Moderator: anthonio

openGL

Berichtdoor bluatigro » zo aug 21, 2011 1:33 pm

mooi plaatje maar 3 error's :
- niet alles word getekend
- niet gesorteerd op diepte
- niet pekspertief

wat doe ik fout ?

Code: Selecteer alles

nomainwin
struct rect, x as long, y as long, x2 as long, y2 as long
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
global red , green , yellow , blue
red = hexdec(  "0000ff" )
green = hexdec( "00ff00" )
yellow = hexdec( "00ffff" )
blue = hexdec( "ff0000" )
dim px( 20 ) , py( 20 ) , pz( 20 )
open "opengl32.dll" for dll as #gl
open "glu32.dll" for dll as #glu
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
UpperLeftX = 1
UpperLeftY = 1
global frame
open "Triangle" for window_nf as #main
print #main,"trapclose [quit]"
MainH=hwnd(#main)
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
timer 40 , [tmr]
wait
[tmr]
frame = frame + 1
''glcolorbufferbit   gldepthbufferbit
SET = 16384 or 256
calldll #gl,"glClear", SET as long, ret as long
calldll #gl,"glLoadIdentity" , ret as void
call translate 0 , 0 , 0
call rotate frame , 0 , 1 , 0
call vorm .5
call pushmatrix
  call translate .5 , 0 , 0
  call rotate frame , 0 , 0 , 1
  call vorm .25
call popmatrix
calldll #gdi32,"SwapBuffers", MainDC as ulong, ret as long
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 #glu
close #gl
end
sub vorm a
  call point 0 , a,a,a
  call point 1 , a,0-a,0-a
  call point 2 , 0-a,0-a,a
  call point 3 , 0-a,a,0-a
  call tri 0,red,1,green,2,blue
  call tri 0,red,1,green,3,yellow
  call tri 0,red,2,blue,3,yellow
  call tri 1,green,2,blue,3,yellow
end sub
sub pushmatrix
  calldll #gl , "glPushMatrix" , ret as void
end sub
sub popmatrix
  calldll #gl , "glPopMatrix" , ret as void
end sub
sub translate x , y , z
  calldll #gl , "glTranslated" _
  , x as double _
  , y as double _
  , z as double _
  , ret as long
end sub
sub rotate hoek , x , y , z
  calldll #gl,"glRotated" _
  , hoek as double _
  , x as double _
  , y as double _
  , z as double _
  , ret as long
end sub
sub point no , x , y , z
  px( no ) = x
  py( no ) = y
  pz( no ) = z
end sub
sub tri p1,kl1,p2,kl2,p3,kl3
  calldll #gl,"glBegin", 4 as long, ret as long
  call setcolor kl1
  call vertex px(p1),py(p1),pz(p1)
  call setcolor kl2
  call vertex px(p2),py(p2),pz(p2)
  call setcolor kl3
  call vertex px(p3),py(p3),pz(p3)
  calldll #gl,"glEnd", ret as void
end sub
sub vertex x , y , z
  calldll #gl,"glVertex3d" _
  , x as double _
  , y as double _
  , z as double  _
  , ret as long
end sub
sub setcolor kl
  r = kl and 255
  g = int( kl / 256 ) and 255
  b = int( kl / 256 ^ 2 ) and 255
  calldll #gl , "glColor3d" _
  , r as double _
  , g as double _
  , b as double _
  , ret as long
end sub
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Keer terug naar API/DLL

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron