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