Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,859 questions

51,780 answers

573 users

How to draw a cube with Raylib in C

1 Answer

0 votes
#include "raylib.h"

#define WIDTH 800
#define HEIGHT 600

int main(void)
{
    InitWindow(WIDTH, HEIGHT, "Raylib Draw Cube");

    // Define the camera to look into 3d world
    Camera camera = {0};
    camera.position = (Vector3){ 0.0f, 9.0f, 9.0f };
    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
    camera.fovy = 45.0f;
    camera.projection = CAMERA_PERSPECTIVE;

    SetTargetFPS(60); // Set our game to run at 60 frames-per-second
 
    // Main game loop
    while (!WindowShouldClose()) // Detect window close button or ESC key
    {
        BeginDrawing();

        ClearBackground(WHITE);

        BeginMode3D(camera);

        // void DrawCube(Vector3 position, float width, float height, float length, Color color);
        DrawCube((Vector3) { -2.0f, 1.0f, 1.0f }, 2.0f, 3.0f, 3.0f, GREEN);

        // void DrawCubeWires(Vector3 position, float width, float height, float length, Color color);
        DrawCubeWires((Vector3) { -2.0f, 1.0f, 1.0f }, 2.0f, 3.0f, 3.0f, ORANGE);

        EndMode3D();

        EndDrawing();
    }

    CloseWindow(); // Close window and OpenGL context

    return 0;
}


/*
run:


*/

 



answered Jan 16, 2025 by avibootz

Related questions

1 answer 120 views
120 views asked Jan 12, 2025 by avibootz
1 answer 100 views
100 views asked Jan 12, 2025 by avibootz
1 answer 90 views
1 answer 80 views
80 views asked Jan 12, 2025 by avibootz
...