76 lines
2.8 KiB
C
76 lines
2.8 KiB
C
|
#include <raylib.h>
|
||
|
#include <GL/gl.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
int main() {
|
||
|
InitWindow(800, 600, "flightsim");
|
||
|
|
||
|
int max_texture_size;
|
||
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
|
||
|
printf("%dx%d\n", max_texture_size, max_texture_size);
|
||
|
|
||
|
Image map_image = LoadImage("map.png");
|
||
|
if(map_image.width != max_texture_size || map_image.height != max_texture_size) {
|
||
|
ImageResize(&map_image, max_texture_size, max_texture_size);
|
||
|
ExportImage(map_image, "map.png");
|
||
|
}
|
||
|
Texture map = LoadTextureFromImage(map_image);
|
||
|
UnloadImage(map_image);
|
||
|
|
||
|
Image terrain_image = LoadImage("terrain.png");
|
||
|
if(terrain_image.width != max_texture_size || terrain_image.height != max_texture_size) {
|
||
|
ImageResize(&terrain_image, max_texture_size, max_texture_size);
|
||
|
ExportImage(terrain_image, "terrain.png");
|
||
|
}
|
||
|
Texture terrain = LoadTextureFromImage(terrain_image);
|
||
|
UnloadImage(terrain_image);
|
||
|
|
||
|
Shader shader = LoadShader("map.vert", "map.frag");
|
||
|
int terrain_loc = GetShaderLocation(shader, "texture1");
|
||
|
|
||
|
Camera cam = { 0 };
|
||
|
cam.position = (Vector3){ 10.0f, 10.0f, 10.0f };
|
||
|
cam.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||
|
cam.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||
|
cam.fovy = 90.0f;
|
||
|
cam.projection = CAMERA_PERSPECTIVE;
|
||
|
|
||
|
Mesh plane = GenMeshPlane(250.0f, 250.0f, 500, 500);
|
||
|
Model model = LoadModelFromMesh(plane);
|
||
|
model.materials[0].maps[0].texture = map;
|
||
|
model.materials[0].maps[1].texture = terrain;
|
||
|
model.materials[0].shader = shader;
|
||
|
|
||
|
DisableCursor();
|
||
|
|
||
|
while(!WindowShouldClose()) {
|
||
|
if(IsKeyPressed(KEY_R)) {
|
||
|
UnloadShader(shader);
|
||
|
shader = LoadShader("map.vert", "map.frag");
|
||
|
model.materials[0].shader = shader;
|
||
|
}
|
||
|
|
||
|
BeginDrawing();
|
||
|
{
|
||
|
ClearBackground(BLACK);
|
||
|
UpdateCamera(&cam, CAMERA_FREE);
|
||
|
|
||
|
BeginMode3D(cam);
|
||
|
{
|
||
|
DrawModel(model, (Vector3){ 0.0f, 0.0f, 0.0f }, 0.4f, WHITE);
|
||
|
|
||
|
/*DrawTexturePro(map,
|
||
|
(Rectangle){ 0, 0, map.width, map.height },
|
||
|
(Rectangle){ 0, 0, GetScreenWidth(), GetScreenHeight() },
|
||
|
(Vector2){ 0.0f, 0.0f }, 0.0f, WHITE);*/
|
||
|
}
|
||
|
EndMode3D();
|
||
|
}
|
||
|
EndDrawing();
|
||
|
}
|
||
|
|
||
|
CloseWindow();
|
||
|
|
||
|
return 0;
|
||
|
}
|