Rendering with raylib.
This commit is contained in:
@@ -10,7 +10,7 @@ OBJ_DIR = $(BUILD_DIR)/obj
|
||||
CC = clang -std=c23
|
||||
LINK = clang
|
||||
CFLAGS = -Wall -DDBG -ggdb -fsanitize=leak
|
||||
LDFLAGS = -lGL -lX11 -lXi -lXcursor -ldl -lpthread -lm
|
||||
LDFLAGS = -lraylib
|
||||
PRINT = echo -e
|
||||
|
||||
SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
|
||||
|
||||
10
src/gen.c
10
src/gen.c
@@ -12,8 +12,14 @@ void gen(void) {
|
||||
for (int x = 0; x < VOL_WIDTH; x++) {
|
||||
for (int y = 0; y < VOL_HEIGHT; y++) {
|
||||
for (int z = 0; z < VOL_DEPTH; z++) {
|
||||
if (rand() % 2 == 0) vol_set_vox(x, y, z, COL_WHT);
|
||||
else vol_set_vox(x, y, z, COL_BLK);
|
||||
int r = rand() % 4;
|
||||
switch (r) {
|
||||
case 0: vol_set_pt(x, y, z, COL_WHT); break;
|
||||
case 1: vol_set_pt(x, y, z, COL_GRY); break;
|
||||
case 2: vol_set_pt(x, y, z, COL_GRN); break;
|
||||
case 3: vol_set_pt(x, y, z, COL_BLU); break;
|
||||
default: vol_set_pt(x, y, z, COL_MAG);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,6 @@ typedef struct {
|
||||
#define COL_RED (Col) {255, 0, 0}
|
||||
#define COL_GRN (Col) {0, 255, 0}
|
||||
#define COL_BLU (Col) {0, 0, 255}
|
||||
#define COL_MAG (Col) {255, 127, 255}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
#ifndef VOL_H
|
||||
#define VOL_H
|
||||
|
||||
#include "vox.h"
|
||||
#include "pt.h"
|
||||
#include "col.h"
|
||||
|
||||
#define VOL_WIDTH 128
|
||||
#define VOL_HEIGHT 128
|
||||
#define VOL_DEPTH 128
|
||||
#define VOL_SZ 8
|
||||
#define VOL_WIDTH VOL_SZ
|
||||
#define VOL_HEIGHT VOL_SZ
|
||||
#define VOL_DEPTH VOL_SZ
|
||||
|
||||
// The volume in which our voxels may be found.
|
||||
extern Vox volume[VOL_WIDTH][VOL_HEIGHT][VOL_DEPTH];
|
||||
// The volume in which our points may be found.
|
||||
extern Pt volume[VOL_WIDTH][VOL_HEIGHT][VOL_DEPTH];
|
||||
|
||||
void vol_set_vox(int x, int y, int z, Col col);
|
||||
void vol_set_pt(int x, int y, int z, Col col);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#ifndef VOX_H
|
||||
#define VOX_H
|
||||
|
||||
#include "col.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// A voxel.
|
||||
typedef struct {
|
||||
Col col;
|
||||
} Vox;
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "include/main.h"
|
||||
|
||||
#include "include/gen.h"
|
||||
#include "include/vol.h"
|
||||
#include "include/vox.h"
|
||||
#include "include/render.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -11,11 +10,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
gen();
|
||||
|
||||
Vox testvox = volume[10][5][20];
|
||||
printf(
|
||||
"Test voxel is (%d, %d, %d)\n", testvox.col.r, testvox.col.g,
|
||||
testvox.col.b
|
||||
);
|
||||
render();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
Vox volume[VOL_WIDTH][VOL_HEIGHT][VOL_DEPTH];
|
||||
Pt volume[VOL_WIDTH][VOL_HEIGHT][VOL_DEPTH];
|
||||
|
||||
void vol_set_vox(int x, int y, int z, Col col) {
|
||||
void vol_set_pt(int x, int y, int z, Col col) {
|
||||
if (x >= 0 && x < VOL_WIDTH && y >= 0 && y < VOL_HEIGHT && z >= 0 &&
|
||||
z < VOL_DEPTH)
|
||||
volume[x][y][z].col = col;
|
||||
|
||||
Reference in New Issue
Block a user