public void Update() { drawScreen.Update(); Raylib.BeginDrawing(); Raylib.BeginTextureMode(renderTexture); Raylib.ClearBackground(Color.BLACK); Raylib.BeginMode3D(camera); ModelRenderer.RenderQueue(); Raylib.EndMode3D(); Raylib.EndTextureMode(); Raylib.ClearBackground(Color.BLACK); Raylib.DrawTexturePro( renderTexture.texture, new Rectangle(0, 0, renderTexture.texture.width, -renderTexture.texture.height), new Rectangle(0, 0, 640, 480), Vector2.Zero, 0, Color.RAYWHITE ); drawScreen.Render(); Raylib.EndDrawing(); Debug.Label("swap window"); }
private void Draw() { Raylib.BeginDrawing(); Raylib.BeginMode3D(_camera); Raylib.ClearBackground(Color.RAYWHITE); _scenes[_currentSceneIndex].Draw(); Raylib.EndMode3D(); Raylib.EndDrawing(); }
private void Draw() { Raylib.BeginDrawing(); Raylib.BeginMode3D(_camera); Raylib.ClearBackground(Color.RAYWHITE); Raylib.DrawGrid(10, 1.0f); Raylib.EndMode3D(); Raylib.EndDrawing(); }
private void Draw() { Raylib.BeginDrawing(); Raylib.BeginMode3D(_camera); Raylib.ClearBackground(Color.DARKBLUE); Raylib.DrawSphere(new System.Numerics.Vector3(), 5, Color.RED); Raylib.DrawGrid(10, 1.0f); Raylib.EndMode3D(); Raylib.EndDrawing(); }
private void Draw() { Raylib.BeginDrawing(); Raylib.BeginMode3D(_camera); Raylib.ClearBackground(Color.DARKGRAY); Raylib.DrawSphere(new System.Numerics.Vector3(), 1, Color.PINK); Raylib.DrawGrid(20, 1.0f); Raylib.EndMode3D(); Raylib.EndDrawing(); }
public void Update() { drawScreen.Update(); Raylib.BeginDrawing(); Raylib.BeginTextureMode(renderTexture); Raylib.ClearBackground(Color.BLACK); Raylib.BeginMode3D(camera); ModelRenderer.RenderQueue(); Raylib.EndMode3D(); Raylib.EndTextureMode(); Raylib.ClearBackground(Color.BLACK); //Console.WriteLine(renderTexture.depth.id); Raylib.BeginShaderMode(postProcessShader); Raylib.SetShaderValueTexture(postProcessShader, Raylib.GetShaderLocation(postProcessShader, "depthTexture"), renderTexture.depth); unsafe { Vector4 screenDims = new Vector4(screenWidth, screenHeight, windowWidth, windowHeight); IntPtr pointer = new IntPtr(&screenDims); Raylib.SetShaderValue( postProcessShader, Raylib.GetShaderLocation(postProcessShader, "screenSize"), pointer, ShaderUniformDataType.SHADER_UNIFORM_VEC4 ); } Raylib.DrawTexturePro( renderTexture.texture, new Rectangle(0, 0, renderTexture.texture.width, -renderTexture.texture.height), new Rectangle(0, 0, windowWidth, windowHeight), Vector2.Zero, 0, Color.WHITE ); Raylib.EndShaderMode(); drawScreen.Render(); Rlgl.rlDrawRenderBatchActive(); Raylib.EndDrawing(); Debug.Label("swap window"); }
static void Main(string[] args) { Raylib.InitWindow(1366, 768, "Foam Test"); Raylib.SetTargetFPS(60); //args = new string[] { "C:/Projekti/Foam/bin/mapfoam/sample/test.mapfoam" }; //args = new[] { "C:/Projekti/Ray/build/bin/sample/light_test.mapfoam" }; Cam3D = new Camera3D(new Vector3(1, 1, 1), Vector3.Zero, Vector3.UnitY); Raylib.SetCameraMode(Cam3D, CameraMode.CAMERA_FREE); Model[] Models = null; FoamModel FoamModel = null; bool DrawText = true; bool DrawWireframe = false; bool DrawSkeleton = true; bool UpdateAnimation = true; while (!Raylib.WindowShouldClose()) { if (Raylib.IsKeyPressed(KeyboardKey.KEY_F1)) { DrawText = !DrawText; } if (Raylib.IsKeyPressed(KeyboardKey.KEY_F2)) { DrawWireframe = !DrawWireframe; } if (Raylib.IsKeyPressed(KeyboardKey.KEY_F3)) { DrawSkeleton = !DrawSkeleton; } if (Raylib.IsKeyPressed(KeyboardKey.KEY_F4)) { UpdateAnimation = !UpdateAnimation; } if (Raylib.IsFileDropped() || (args != null && args.Length > 0)) { string DroppedFile = null; if (args != null && args.Length > 0) { DroppedFile = args[0]; args = null; } else { DroppedFile = Raylib.GetDroppedFiles()[0]; } Model[] NewModels = LoadModels(DroppedFile, out float Scale, out FoamModel NewFoamModel); if (NewModels != null && NewFoamModel != null) { if (NewModels.Length == 0 && NewFoamModel.Animations != null && FoamModel != null) { foreach (var NewAnim in NewFoamModel.Animations) { Utils.Append(ref FoamModel.Animations, NewAnim); } } else { if (Models != null) { foreach (var M in Models) { Raylib.UnloadModel(M); } } Models = NewModels; FoamModel = NewFoamModel; //Cam3D.position = new Vector3(0.5f, 0.25f, 0.5f) * Scale; //Cam3D.target = new Vector3(0, 0.25f, 0) * Scale; } } Raylib.ClearDroppedFiles(); } /*if (Models != null) * UpdateModel(FoamModel, FrameIndex);*/ Raylib.BeginDrawing(); Raylib.ClearBackground(new Color(50, 50, 50)); //Raylib.ClearBackground(new Color(0, 0, 0)); if (Models != null) { Raylib.UpdateCamera(ref Cam3D); Raylib.BeginMode3D(Cam3D); for (int i = 0; i < Models.Length; i++) { if (DrawWireframe) { Raylib.DrawModelWires(Models[i], Vector3.Zero, 1, Color.White); } else { Raylib.DrawModel(Models[i], Vector3.Zero, 1, Color.White); } } if (UpdateAnimation) { UpdateModelAnimation(FoamModel); } if (FoamModel != null && DrawSkeleton) { DrawBones(FoamModel); } Raylib.EndMode3D(); if (DrawText) { if (WorldTexts != null) { foreach (var KV in WorldTexts) { Raylib.DrawText(KV.Value, (int)KV.Key.X, (int)KV.Key.Y, 10, Color.White); } } } } DrawTextLine("F1 - Toggle bone names", 0); DrawTextLine("F2 - Toggle wireframe", 1); DrawTextLine("F3 - Toggle skeleton", 2); DrawTextLine("F4 - Toggle animations", 3); Raylib.DrawFPS(5, 5); Raylib.EndDrawing(); } }