forum-msg-id-134060-edit

Original date:2019-07-12 01:39:46 Edited by: Icy_Viking Subject: Re: Raylib 3D

Maccuq said...

It works when you write it this way.

xBeginMode3D = define_c_proc(ray,"+BeginMode3D",{C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_FLOAT,C_INT}), 
 
public procedure BeginMode3D(atom px, atom py, atom pz, atom tx, atom ty, atom tz, atom ux, atom uy, atom uz, atom fov, integer mode) 
 
 c_proc(xBeginMode3D,{px, py, pz, tx, ty, tz, ux, uy, uz, fov, mode}) 
	 
end procedure 

Thank you Maccuq, it works!

include std/machine.e 
include std/convert.e 
 
include flags.e 
include Euraylib.ew 
 
atom width = 800 
atom height = 450 
 
InitWindow(width,height,"3D Stuff") 
 
constant Vector3_X = 0, 
		 Vector3_Y = 4, 
		 Vector3_Z = 8, 
		 SIZEOF_VECTOR3 = 12, 
		 $ 
		  
constant Camera3D_Position = 0, 
		 Camera3D_Target = 12, 
		 Camera3D_Up = 24, 
		 Camera3D_Fovy = 36, 
		 Camera3D_Type = 40, 
		 SIZEOF_CAMERA3D = 44, 
		 $ 
 
atom cam = allocate_data(SIZEOF_CAMERA3D) 
mem_set(cam,0,SIZEOF_CAMERA3D) 
 
procedure poke_float(atom p,atom f) 
 
  poke(p,atom_to_float32(f)) 
	 
end procedure 
 
atom blue = bytes_to_int({0,0,255,255}) 
atom white = bytes_to_int({255,255,255,255}) 
 
SetTargetFPS(60) 
 
public procedure SetCameraPosition(atom cam,atom x,atom y,atom z) 
 
 poke_float(cam + Camera3D_Position + Vector3_X,x) 
 poke_float(cam + Camera3D_Position + Vector3_Y,y) 
 poke_float(cam + Camera3D_Position + Vector3_Z,z) 
	 
end procedure 
 
public procedure SetCameraTarget(atom cam,atom x,atom y,atom z) 
 
 poke_float(cam + Camera3D_Target + Vector3_X,x) 
 poke_float(cam + Camera3D_Target + Vector3_Y,y) 
 poke_float(cam + Camera3D_Target + Vector3_Z,z) 
	 
end procedure 
 
public procedure SetCameraUp(atom cam,atom x,atom y,atom z) 
 
 poke_float(cam + Camera3D_Up + Vector3_X,x) 
 poke_float(cam + Camera3D_Up + Vector3_Y,y) 
 poke_float(cam + Camera3D_Up + Vector3_Z,z) 
	 
end procedure 
 
public procedure SetCameraFOVY(atom cam,atom fovy) 
 
 poke_float(cam + Camera3D_Fovy,fovy) 
	 
end procedure 
 
public procedure SetCameraType(atom cam,integer xtype) 
 
 poke4(cam + Camera3D_Type,xtype) 
	 
end procedure 
 
SetCameraPosition(cam,0,10.0,10.0) 
SetCameraTarget(cam,0,0,0) 
SetCameraUp(cam,0,1,0) 
SetCameraFOVY(cam,45.0) 
SetCameraType(cam,CAMERA_PERSPECTIVE) 
 
while not WindowShouldClose() do 
 
	BeginDrawing() 
	 
	ClearBackground(white) 
	 
	BeginMode3D(0,10.0,10.0,0,0,0,0,1,0,45.0,CAMERA_PERSPECTIVE) 
	 
	DrawCube(-4.0,0.0,2.0,2.0,5.0,2.0,blue) 
	 
	DrawGrid(10,1.0) 
	 
	EndMode3D() 
 
	DrawFPS(1,1) 
	 
	EndDrawing() 
	 
end while 
 
CloseWindow() 
Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu