Browse Source

aspect ratio modes, new panorama

Iver 1 month ago
parent
commit
4b4162f39c

BIN
builds/librasteriver.so


BIN
builds/main.bin


+ 1 - 5
changelog.txt

@@ -1,5 +1 @@
--added checker texture
--added desert panorama and blue gradient skybox textures
--added skybox example
--fixed vector 2 lerp function by changing multiply 0 to memset 0
--added vector 2 memset
+-added window modes: stretch, letterbox

+ 6 - 0
src/headers/types.h

@@ -5,6 +5,11 @@
 #include <CL/cl.h>
 #include <CL/cl.h>
 #include "math.h"
 #include "math.h"
 
 
+enum {
+    RI_ASPECT_MODE_STRETCH = 1 << 0,
+    RI_ASPECT_MODE_LETTERBOX = 1 << 1,
+};
+
 enum {
 enum {
     RI_DEBUG_NONE = 0,
     RI_DEBUG_NONE = 0,
 
 
@@ -201,6 +206,7 @@ typedef struct {
 typedef struct {
 typedef struct {
     int width, height, half_width, half_height;
     int width, height, half_width, half_height;
     char* title;
     char* title;
+    unsigned char aspect_mode;
 } RI_window;
 } RI_window;
 
 
 typedef struct {
 typedef struct {

+ 9 - 7
src/launch program/main.c

@@ -4,8 +4,8 @@
 int main(){
 int main(){
     RI_context* context = RI_get_context();
     RI_context* context = RI_get_context();
         
         
-    context->window.width = 600;
-    context->window.height = 600;
+    context->window.width = 16 * 100;
+    context->window.height = 9 * 100;
     context->window.title = "This is RasterIver 3.0!!!!!!!";
     context->window.title = "This is RasterIver 3.0!!!!!!!";
     
     
     if (RI_init() != 0){
     if (RI_init() != 0){
@@ -16,7 +16,7 @@ int main(){
 
 
     RI_scene *scene = RI_new_scene();
     RI_scene *scene = RI_new_scene();
 
 
-    scene->camera.FOV = 2.1;
+    scene->camera.FOV = 1.5;
     scene->camera.min_clip = 0.1;
     scene->camera.min_clip = 0.1;
 
 
     RI_mesh *skybox_mesh = RI_load_mesh("objects/skybox.obj");
     RI_mesh *skybox_mesh = RI_load_mesh("objects/skybox.obj");
@@ -24,10 +24,12 @@ int main(){
 
 
     scene->actors = malloc(sizeof(RI_actor));
     scene->actors = malloc(sizeof(RI_actor));
 
 
-    RI_texture* texture = RI_load_image("textures/desert_skybox_1000x1000.bmp");
+    RI_texture* texture = RI_load_image("textures/alley_skybox_3072x3072.bmp");
 
 
     scene->actors[0] = RI_new_actor();
     scene->actors[0] = RI_new_actor();
          
          
+    context->window.aspect_mode = RI_ASPECT_MODE_LETTERBOX;
+
     scene->actors[0]->mesh = skybox_mesh;
     scene->actors[0]->mesh = skybox_mesh;
     scene->actors[0]->texture = texture;
     scene->actors[0]->texture = texture;
          
          
@@ -47,16 +49,16 @@ int main(){
     double delta_min = 0.0001;
     double delta_min = 0.0001;
     double delta_max = 100000;
     double delta_max = 100000;
     
     
-    double rotation = 0;
+    double rotation = -1.5;
     
     
     while (context->is_running){
     while (context->is_running){
         start = clock();
         start = clock();
         
         
         // scene->camera.FOV = context->current_frame;
         // scene->camera.FOV = context->current_frame;
         
         
-        RI_euler_rotation_to_quaternion(&scene->camera.rotation, (RI_vector_3){0, rotation, 0});
+        RI_euler_rotation_to_quaternion(&scene->camera.rotation, (RI_vector_3){rotation, 0, 0});
 
 
-        rotation += delta_time;
+        rotation += delta_time / 5;
 
 
         RI_render(scene);
         RI_render(scene);
 
 

+ 3 - 2
src/main/main.c

@@ -457,7 +457,8 @@ void RI_render(RI_scene *scene){
     
     
     double horizontal_fov_factor = (double)context.window.width / tanf(0.5 * scene->camera.FOV);
     double horizontal_fov_factor = (double)context.window.width / tanf(0.5 * scene->camera.FOV);
     double vertical_fov_factor = (double)context.window.height / tanf(0.5 * scene->camera.FOV);
     double vertical_fov_factor = (double)context.window.height / tanf(0.5 * scene->camera.FOV);
-    
+
+    if (context.window.aspect_mode == RI_ASPECT_MODE_LETTERBOX) horizontal_fov_factor /= horizontal_fov_factor / vertical_fov_factor;
 
 
     // kernel args    
     // kernel args    
     
     
@@ -846,7 +847,7 @@ void RI_tick(){
 RI_context *RI_get_context(){
 RI_context *RI_get_context(){
     context.sdl = (RI_SDL){NULL, NULL, NULL, NULL, -1};
     context.sdl = (RI_SDL){NULL, NULL, NULL, NULL, -1};
     context.opencl = (RI_CL){NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 1, 0, 0};
     context.opencl = (RI_CL){NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 1, 0, 0};
-    context.window = (RI_window){800, 800, 400, 400, "RasterIver Window"};
+    context.window = (RI_window){800, 800, 400, 400, "RasterIver Window", RI_ASPECT_MODE_LETTERBOX};
     
     
     context.debug_flags = RI_DEBUG_ERRORS;
     context.debug_flags = RI_DEBUG_ERRORS;
     context.current_frame = 0;
     context.current_frame = 0;

BIN
textures/skybox_texture_4_cube_1024x1024.xcf