Some house keeping
git-svn-id: https://svn.tlawal.org/svn/ragar@10 618e81bd-0769-42e7-8608-769e73fecc77
This commit is contained in:
parent
eab8d3b631
commit
6536ec9afb
@ -6,8 +6,13 @@
|
|||||||
|
|
||||||
#include "base/base_inc.h"
|
#include "base/base_inc.h"
|
||||||
#include "renderer/display.h"
|
#include "renderer/display.h"
|
||||||
|
#include "renderer/vector.h"
|
||||||
|
|
||||||
#include "renderer/display.c"
|
#include "renderer/display.c"
|
||||||
|
#include "renderer/vector.c"
|
||||||
|
|
||||||
|
Vec3 cube_points[9 * 9 * 9] = {0}; // 9 x 9 x 9 cube
|
||||||
|
Vec2 projected_points[9 * 9 * 9];
|
||||||
|
|
||||||
int is_running;
|
int is_running;
|
||||||
|
|
||||||
@ -15,6 +20,23 @@ void setup(void) {
|
|||||||
colour_buffer = (u32 *)malloc(sizeof(u32) * window_width * window_height);
|
colour_buffer = (u32 *)malloc(sizeof(u32) * window_width * window_height);
|
||||||
colour_buffer_texture =
|
colour_buffer_texture =
|
||||||
SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, window_width, window_height);
|
SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, window_width, window_height);
|
||||||
|
|
||||||
|
// Load vector array
|
||||||
|
int point_count = 0;
|
||||||
|
for (f32 x = -1; x <= 1; x += 0.25) {
|
||||||
|
for (f32 y = -1; y <= 1; y += 0.25) {
|
||||||
|
for (f32 z = -1; z <= 1; z += 0.25) {
|
||||||
|
Vec3 new_point = {.x = x, .y = y, .z = z};
|
||||||
|
cube_points[point_count++] = new_point;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Orthographic projection
|
||||||
|
Vec2 project(Vec3 point) {
|
||||||
|
Vec2 projected_point = {.x = point.x, .y = point.y};
|
||||||
|
return projected_point;
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_input(void) {
|
void process_input(void) {
|
||||||
@ -35,14 +57,21 @@ void process_input(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(void) {}
|
void update(void) {
|
||||||
|
for (int i = 0; i < (9*9*9); i++) {
|
||||||
|
Vec3 point = cube_points[i];
|
||||||
|
Vec2 projected_point = project(point);
|
||||||
|
projected_points[i] = projected_point;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void render(void) {
|
void render(void) {
|
||||||
// FrameMarkStart("render");
|
// FrameMarkStart("render");
|
||||||
|
draw_grid(0xFFFFFFFF);
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(renderer, 28, 450, 560, 255);
|
SDL_SetRenderDrawColor(renderer, 28, 450, 560, 255);
|
||||||
SDL_RenderClear(renderer);
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
draw_pixel(400, 400, 0xFF839149);
|
|
||||||
render_colour_buffer();
|
render_colour_buffer();
|
||||||
// clear_colour_buffer(0xFF384893);
|
// clear_colour_buffer(0xFF384893);
|
||||||
clear_colour_buffer(0xFF000000);
|
clear_colour_buffer(0xFF000000);
|
||||||
|
@ -59,7 +59,7 @@ void draw_dots(u32 colour) {
|
|||||||
void draw_grid(u32 colour) {
|
void draw_grid(u32 colour) {
|
||||||
for (s32 column = 0; column < window_height; column++) {
|
for (s32 column = 0; column < window_height; column++) {
|
||||||
for (s32 row = 0; row < window_width; row++) {
|
for (s32 row = 0; row < window_width; row++) {
|
||||||
if ((row % 50) == 0 || (column % 100) == 0) {
|
if ((row % 10) == 0 || (column % 100) == 0) {
|
||||||
colour_buffer[(window_width * column) + row] = colour;
|
colour_buffer[(window_width * column) + row] = colour;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user