Test 3D camera
This commit is contained in:
56
src/graphics.c
Normal file
56
src/graphics.c
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* IGC parser
|
||||
* @brief parse IGC file, get all data points, compute average horizontal/vertical speed, print to STDOUT
|
||||
*
|
||||
* As per standard: https://xp-soaring.github.io/igc_file_format/igc_format_2008.html
|
||||
* https://xp-soaring.github.io/igc_file_format/igc_fr_specification_with_al8_2023-2-1_0.pdf
|
||||
*
|
||||
* @author xamidev <xamidev@riseup.net>
|
||||
* @license GNU GPL v3
|
||||
*/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
void start_graphics()
|
||||
{
|
||||
SetTraceLogLevel(4);
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "camera");
|
||||
|
||||
Camera3D camera = {0};
|
||||
camera.position = (Vector3){10.0f, 10.0f, 10.0f};
|
||||
camera.target = (Vector3){0.0f, 0.0f, 0.0f};
|
||||
camera.up = (Vector3){0.0f, 1.0f, 0.0f};
|
||||
camera.fovy = 45.0f;
|
||||
camera.projection = CAMERA_PERSPECTIVE;
|
||||
|
||||
Vector3 cubePosition = {0.0f, 0.0f, 0.0f};
|
||||
DisableCursor();
|
||||
SetTargetFPS(60);
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
// Update
|
||||
// Variables should update HERE
|
||||
UpdateCamera(&camera, CAMERA_FREE);
|
||||
|
||||
// Draw
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
EndMode3D();
|
||||
DrawText("3rd Dimension", 10, 40, 20, DARKGRAY);
|
||||
DrawFPS(10, 10);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
CloseWindow();
|
||||
return;
|
||||
}
|
||||
17
src/graphics.h
Normal file
17
src/graphics.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* IGC parser
|
||||
* @brief parse IGC file, get all data points, compute average horizontal/vertical speed, print to STDOUT
|
||||
*
|
||||
* As per standard: https://xp-soaring.github.io/igc_file_format/igc_format_2008.html
|
||||
* https://xp-soaring.github.io/igc_file_format/igc_fr_specification_with_al8_2023-2-1_0.pdf
|
||||
*
|
||||
* @author xamidev <xamidev@riseup.net>
|
||||
* @license GNU GPL v3
|
||||
*/
|
||||
|
||||
#ifndef GRAPHICS_H
|
||||
#define GRAPHICS_H
|
||||
|
||||
void start_graphics();
|
||||
|
||||
#endif
|
||||
17
src/main.c
17
src/main.c
@@ -9,14 +9,13 @@
|
||||
* @license GNU GPL v3
|
||||
*/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "igc.h"
|
||||
#include "linkage.h"
|
||||
#include "graphics.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
@@ -43,19 +42,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
print_datapoint_list(head);
|
||||
|
||||
// Raylib test window
|
||||
SetTraceLogLevel(4);
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 600;
|
||||
InitWindow(screenWidth, screenHeight, "Raylib basic window");
|
||||
SetTargetFPS(60);
|
||||
while (!WindowShouldClose()) {
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("It works!", 20, 20, 20, BLACK);
|
||||
EndDrawing();
|
||||
}
|
||||
CloseWindow();
|
||||
start_graphics();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user