;============================================================================== ; ; GEARS3D ENGINE FOR PUREBASIC 4.x WRAPPER ; ; FILE CREATED : 17/04/2008 ; AUTHOR : CPL.BATOR ; ; ; For any bugs : http://moteur3d.frenchboard.com ; ;==============================================================================
IncludeFile "./OpenGL.pbi"
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ;- STRUCTURES ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Structure CEntity EndStructure Structure CMesh EndStructure Structure CCamera EndStructure Structure CTexture EndStructure Structure CSceneRoot EndStructure
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ; ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- CompilerIf #PB_Compiler_OS = #PB_OS_Linux ImportC "-lGears3D" CompilerEndIf ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ; ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- CompilerIf #PB_Compiler_OS = #PB_OS_Windows Global hdc ImportC "libgears3D.lib" CompilerEndIf ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ; ; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ;- CSceneRoot members ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- g3d_CreateScene.l() g3d_BeginRender(*sceneRoot.CSceneRoot) g3d_EndRender(*sceneRoot.CSceneRoot) g3d_Render(*sceneRoot.CSceneRoot, *camera.CCamera)
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ;- CENTITY ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- g3d_EntityX.f(*entity.CEntity, globale.b=#True) g3d_EntityY.f(*entity.CEntity, globale.b=#True) g3d_EntityZ.f(*entity.CEntity, globale.b=#True) g3d_EntityYaw.f(*entity.CEntity, globale.b=#False) g3d_EntityPitch.f(*entity.CEntity, globale.b=#False) g3d_EntityRoll.f(*entity.CEntity, globale.b=#False) g3d_PositionEntity(*entity.CEntity, posx.f, posy.f, posz.f, globale.b = #False) g3d_ScaleEntity(*entity.CEntity, scalex.f, scaley.f, scalez.f, globale.b = #False) g3d_MoveEntity(*entity.CEntity, movex.f, movey.f, movez.f, type.b = #False) g3d_TranslateEntity(*entity.CEntity, translatex.f, translatey.f, translatez.f, globale.b = #False) g3d_TurnEntity(*entity.CEntity, turnx.f, turny.f, turnz.f, type.b = #False) g3d_RotateEntity(*entity.CEntity, rotx.f, roty.f, rotz.f, globale.b = #False) g3d_EntityVisible(*entity.CEntity, flag.l ) g3d_EntityParent(*child.CEntity, *entity_parent.CEntity)
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ;- CAMERAS ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- g3d_CreateCamera.l(fov.f=90,near.f=0.01,far.f=1500, *entity_parent.CEntity = #Null)
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ;- MESHES ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- g3d_CreateCube.l(*parent.CEntity=#Null ) g3d_CreateSphere.l(*parent.CEntity=#Null ) g3d_CreateTours.l(*parent.CEntity=#Null ) g3d_CreateMesh.l(format.l, *parent.CEntity=#Null ) g3d_AddVertex( *mesh.CMesh, x.f, y.f, z.f, tu.f, tv.f) g3d_MeshGetTexture.l(*mesh.CMesh, surf.l=0)
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ;- MESHES CONTROL ; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ;- TEXTURES CONTROL ; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- g3d_LoadTexture( *texture.CTexture, filename.s, Stage.l=0)
EndImport
; --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ;- FONCTIONS ADAPTEES A PURE BASIC ; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
;===================================================================================== Procedure g3d_OpenScreen(Width,Height,Depth,Fullscreen.b,Title$="Gears3Dapp") ;===================================================================================== ; LINUX SPECIFIC ;===================================================================================== CompilerIf #PB_Compiler_OS = #PB_OS_Linux If SDL_Init_(#SDL_INIT_VIDEO )=>0 Select Fullscreen Case 0 : Screen = SDL_SetVideoMode_(Width,Height,Depth, #SDL_OPENGL) Case 1 : Screen = SDL_SetVideoMode_(Width,Height,Depth, #SDL_OPENGL|#SDL_FULLSCREEN) EndSelect ; Debug SDL_GL_SetAttribute_(#SDL_GL_MULTISAMPLESAMPLES, 6) Else MessageRequester("Fatal error.","Can't initialize SDL environement") EndIf CompilerEndIf
;===================================================================================== ; WINDOWS SPECIFIC ;===================================================================================== CompilerIf #PB_Compiler_OS = #PB_OS_Windows pfd.PIXELFORMATDESCRIPTOR hWnd = OpenWindow(0, 0, 0, Width,Height, Title$) hdc = GetDC_(hWnd) pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR) pfd\nVersion = 1 pfd\dwFlags = #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER | #PFD_DRAW_TO_WINDOW pfd\dwLayerMask = #PFD_MAIN_PLANE pfd\iPixelType = #PFD_TYPE_RGBA pfd\cColorBits = 16 pfd\cDepthBits = 16 pixformat = ChoosePixelFormat_(hdc, pfd) SetPixelFormat_(hdc, pixformat, pfd) hrc = wglCreateContext_(hdc) wglMakeCurrent_(hdc,hrc) CompilerEndIf
EndProcedure ;===================================================================================== ; ;===================================================================================== Procedure g3d_ClearScreen(red,green,blue) glClearColor_(red/255,green/255,blue/255,0) glClear_(#GL_COLOR_BUFFER_BIT|#GL_DEPTH_BUFFER_BIT) EndProcedure ;===================================================================================== ; ;===================================================================================== Procedure g3d_FlipBuffers() ;===================================================================================== ; LINUX SPECIFIC ;===================================================================================== CompilerIf #PB_Compiler_OS = #PB_OS_Linux glFlush_() SDL_GL_SwapBuffers_() CompilerEndIf ;===================================================================================== ; WINDOWS SPECIFIC ;===================================================================================== CompilerIf #PB_Compiler_OS = #PB_OS_Windows glFlush_() SwapBuffers_(hdc) CompilerEndIf EndProcedure ;===================================================================================== ; ;=====================================================================================
|