13
13
using static Raylib_cs . Raylib ;
14
14
using static Raylib_cs . Color ;
15
15
using static Raylib_cs . CameraMode ;
16
+ using static Raylib_cs . CameraType ;
16
17
using static Raylib_cs . MaterialMapType ;
17
18
using static Raylib_cs . ShaderUniformDataType ;
18
19
@@ -30,29 +31,29 @@ public unsafe static int Main()
30
31
InitWindow ( screenWidth , screenHeight , "raylib [models] example - skybox loading and drawing" ) ;
31
32
32
33
// Define the camera to look into our 3d world
33
- Camera3D camera = new Camera3D ( new Vector3 ( 1.0f , 1.0f , 1.0f ) , new Vector3 ( 4.0f , 1.0f , 4.0f ) , new Vector3 ( 0.0f , 1.0f , 0.0f ) , 45.0f , 0 ) ;
34
+ Camera3D camera = new Camera3D ( new Vector3 ( 1.0f , 1.0f , 1.0f ) , new Vector3 ( 4.0f , 1.0f , 4.0f ) , new Vector3 ( 0.0f , 1.0f , 0.0f ) , 45.0f , CAMERA_PERSPECTIVE ) ;
34
35
35
36
// Load skybox model
36
37
Mesh cube = GenMeshCube ( 1.0f , 1.0f , 1.0f ) ;
37
38
Model skybox = LoadModelFromMesh ( cube ) ;
38
39
39
40
// Load skybox shader and set required locations
40
41
// NOTE: Some locations are automatically set at shader loading
41
- Material * materials = ( Material * ) skybox . materials . ToPointer ( ) ;
42
- materials [ 0 ] . shader = LoadShader ( "resources/shaders/ skybox.vs" , "resources/shaders/skybox.fs" ) ;
43
- SetShaderValue ( materials [ 0 ] . shader , GetShaderLocation ( materials [ 0 ] . shader , "environmentMap" ) , new int [ ] { ( int ) MAP_CUBEMAP } , UNIFORM_INT ) ;
42
+ Shader shader = LoadShader ( "resources/shaders/glsl330/skybox.vs" , "resources/shaders/glsl330/ skybox.fs" ) ;
43
+ Utils . SetMaterialShader ( ref skybox , 0 , ref shader ) ;
44
+ Utils . SetShaderValue ( shader , GetShaderLocation ( shader , "environmentMap" ) , new int [ ] { ( int ) MAP_CUBEMAP } , UNIFORM_INT ) ;
44
45
45
46
// Load cubemap shader and setup required shader locations
46
- Shader shdrCubemap = LoadShader ( "resources/shaders/cubemap.vs" , "resources/shaders/cubemap.fs" ) ;
47
- SetShaderValue ( shdrCubemap , GetShaderLocation ( shdrCubemap , "equirectangularMap" ) , new int [ ] { 0 } , UNIFORM_INT ) ;
47
+ Shader shdrCubemap = LoadShader ( "resources/shaders/glsl330/ cubemap.vs" , "resources/shaders/glsl330 /cubemap.fs" ) ;
48
+ Utils . SetShaderValue ( shdrCubemap , GetShaderLocation ( shdrCubemap , "equirectangularMap" ) , new int [ ] { 0 } , UNIFORM_INT ) ;
48
49
49
50
// Load HDR panorama (sphere) texture
50
51
Texture2D texHDR = LoadTexture ( "resources/dresden_square.hdr" ) ;
51
52
52
53
// Generate cubemap (texture with 6 quads-cube-mapping) from panorama HDR texture
53
54
// NOTE: New texture is generated rendering to texture, shader computes the sphre->cube coordinates mapping
54
- MaterialMap * maps = ( MaterialMap * ) materials [ 0 ] . maps . ToPointer ( ) ;
55
- maps [ ( int ) MAP_CUBEMAP ] . texture = GenTextureCubemap ( shdrCubemap , texHDR , 512 ) ;
55
+ Texture2D cubemap = GenTextureCubemap ( shdrCubemap , texHDR , 512 ) ;
56
+ Utils . SetMaterialTexture ( ref skybox , 0 , MAP_CUBEMAP , ref cubemap ) ;
56
57
57
58
UnloadTexture ( texHDR ) ; // Texture not required anymore, cubemap already generated
58
59
UnloadShader ( shdrCubemap ) ; // Unload cubemap generation shader, not required anymore
0 commit comments