62 lines
1.2 KiB
C
62 lines
1.2 KiB
C
#ifndef APP_H
|
|
#define APP_H
|
|
#include <SDL2/SDL.h>
|
|
#include <SDL2/SDL_image.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <GL/gl.h>
|
|
#include <time.h>
|
|
#include "camera.h"
|
|
#include "noise.h"
|
|
#include "chunk.h"
|
|
|
|
#define SPEED 5
|
|
|
|
#define VIEWPORT_RATIO (16.0 / 9.0)
|
|
#define VIEWPORT_ASPECT 50.0
|
|
|
|
typedef unsigned int uint;
|
|
|
|
#define CHUNK_MAX_X 16
|
|
#define CHUNK_MAX_Y 16
|
|
#define CHUNK_MAX_Z 128
|
|
|
|
typedef struct {
|
|
bool is_running;
|
|
SDL_Window *window;
|
|
SDL_GLContext context;
|
|
Camera camera;
|
|
double frame_time;
|
|
ChunkManager *cm;
|
|
Type_surface *surfaces;
|
|
unsigned int surface_count;
|
|
} App;
|
|
|
|
void app_generate_world(App *app, int a);
|
|
|
|
void app_load_textures(App *app);
|
|
|
|
GLuint app_get_texture(App *app, Block_type type);
|
|
|
|
int check_intersection_block(App *app, vec3i *retv, int *chunk_index);
|
|
|
|
void app_break_block(App *app);
|
|
|
|
void app_place_block(App *app);
|
|
|
|
bool app_check_collision(vec3f camera_pos, ChunkManager *cm);
|
|
|
|
void init_app(App *app, uint w, uint h);
|
|
|
|
void init_opengl();
|
|
|
|
void handle_events(App *app);
|
|
|
|
void reshape(GLsizei width, GLsizei height);
|
|
|
|
void update_app(App* app);
|
|
|
|
float calc_frame_time(struct timespec *start, struct timespec *end);
|
|
|
|
#endif
|