Implement shaders (#1)
Reviewed-on: #1 * Start implementing shaders and move vector code to dedicated files * Extract shader into its own header * Ensure pixel coordinates are within bounds * Refactor shader code and implement fragment shaders * Create shaders * Reorganise code Co-authored-by: Abdelrahman <said.abdelrahman89@gmail.com> Co-committed-by: Abdelrahman <said.abdelrahman89@gmail.com>
This commit is contained in:
16
src/main.c
16
src/main.c
@@ -2,6 +2,9 @@
|
||||
#include "mem_arena.h"
|
||||
#include "mem_utils.h"
|
||||
#include "obj.h"
|
||||
#include "shader.h"
|
||||
#include "shaders.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -10,6 +13,13 @@
|
||||
#define SIZE 1200
|
||||
#define RESOURCE(NAME) "resources/" NAME
|
||||
|
||||
extern ShaderID perspective_lit_textured_id;
|
||||
extern ShaderID perspective_lit_coloured_id;
|
||||
extern ShaderID perspective_albedo_id;
|
||||
extern ShaderID orthographic_lit_textured_id;
|
||||
extern ShaderID orthographic_lit_coloured_id;
|
||||
extern ShaderID orthographic_albedo_id;
|
||||
|
||||
enum {
|
||||
TINY_EXIT_SUCCESS,
|
||||
TINY_EXIT_ARENA_INIT_FAILED,
|
||||
@@ -38,9 +48,11 @@ int main(void) {
|
||||
return TINY_EXIT_MODEL_LOAD_FAILED;
|
||||
}
|
||||
|
||||
load_shaders();
|
||||
|
||||
clear_buffer(&(render.img), &bg);
|
||||
render_model(&obj, &render, teal, RENDER_TYPE_SHADED, COLOUR_TYPE_FIXED,
|
||||
PROJECTION_TYPE_PERSPECTIVE);
|
||||
render_model(&obj, &render, perspective_lit_textured_id, RENDER_TYPE_SHADED,
|
||||
teal);
|
||||
save_image(&(render.img), "result.pam");
|
||||
|
||||
wapp_mem_arena_destroy(&arena);
|
||||
|
||||
Reference in New Issue
Block a user