remove big assets
This commit is contained in:
commit
70c94e8e99
21
Makefile
Normal file
21
Makefile
Normal file
|
@ -0,0 +1,21 @@
|
|||
BINARY=flightsim
|
||||
|
||||
CC=gcc
|
||||
CFLAGS=-O3
|
||||
LDFLAGS=-lraylib -lm -lGL
|
||||
|
||||
CFILES=$(shell find -L * -type f -name '*.c')
|
||||
OBJ=$(CFILES:.c=.o)
|
||||
|
||||
$(BINARY): $(OBJ) Makefile
|
||||
$(CC) $(OBJ) $(LDFLAGS) -o $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
run: $(BINARY)
|
||||
./$(BINARY)
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJ) $(BINARY)
|
||||
|
75
main.c
Normal file
75
main.c
Normal file
|
@ -0,0 +1,75 @@
|
|||
#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;
|
||||
}
|
11
map.frag
Normal file
11
map.frag
Normal file
|
@ -0,0 +1,11 @@
|
|||
#version 330 core
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
|
||||
out vec4 finalColor;
|
||||
|
||||
void main() {
|
||||
finalColor = texture(texture0, fragTexCoord);
|
||||
}
|
19
map.vert
Normal file
19
map.vert
Normal file
|
@ -0,0 +1,19 @@
|
|||
#version 330 core
|
||||
|
||||
in vec3 vertexPosition;
|
||||
in vec2 vertexTexCoord;
|
||||
in vec4 vertexColor;
|
||||
|
||||
uniform mat4 mvp;
|
||||
uniform sampler2D texture1;
|
||||
|
||||
out vec2 fragTexCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragTexCoord = vec2((vertexTexCoord.x / 12) + 0.2, (vertexTexCoord.y / 12) + 0.2);
|
||||
fragColor = vertexColor;
|
||||
vec3 pos = vertexPosition;
|
||||
pos.y = texture(texture1, fragTexCoord).r * 100.0;
|
||||
gl_Position = mvp * vec4(pos, 1.0);
|
||||
}
|
Loading…
Reference in a new issue