Skip to content

Commit

Permalink
Minor edits to code, added some more goals to the TODO list in the Re…
Browse files Browse the repository at this point in the history
…adme
  • Loading branch information
rdavison committed May 7, 2014
1 parent 4f67aa8 commit 5288cdf
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 30 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Dependencies: SDL2 http://www.libsdl.org/download-2.0.php
TODO List
=========

* Figure out why SDL2 sometimes does not register events while rendering. I need to investigate Multithreading the gui.
* Fix the warping of the image <s>near the edges of the screen</s> when objects are at high viewing angles and the aspect ratio isn't 1:1.
* Allow variable amount of lights in the scene.
* Implement functionality to allow the user to move the camera via user input to "fly around" the scene.
* Figure out why the floor (and maybe the ceiling too) is moving down/up in the demo even though it should only be moving in the Z direction.
* Implement rotations.
* Implement matrices.
16 changes: 2 additions & 14 deletions cl_kernels.cl
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@
//////////////////////////////////////////////////////////////////////////////


struct Intersection intersect_cube(
constant float16 *scene,
int obj_index,
float3 ray_pos,
float3 ray_dir,
float max_t)
{
struct Intersection jieguo;
//
// TODO
//
return jieguo;
}

struct Intersection intersect_box(
constant float16 *scene,
int obj_index,
Expand Down Expand Up @@ -500,8 +486,10 @@ kernel void update_scene(
}

if(i < num_objects) {
int sign = 1.f;
unsigned int j = i * 2;
float delta = sin((float)frame_num/4.f)/4.f;
delta = i % 2 == 0 ? delta : -delta;
scene_objects[j].s1 += delta;
//scene_objects[j].s123 += clamp(sin(1.f/(scene_objects[j].s123)), -delta, delta);
//scene_objects[j].s1 += clamp(sin((float)frame_num), (float)-i, (float)i);
Expand Down
25 changes: 22 additions & 3 deletions gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,26 @@ int gui_destroy()
}

bool gui_quit_pressed() {
SDL_Event e;
SDL_PollEvent(&e);
return e.type == SDL_QUIT;
SDL_Event event;
SDL_PollEvent(&event);
switch(event.type) {

case SDL_WINDOWEVENT:
switch(event.window.event) {

case SDL_WINDOWEVENT_ENTER:
printf("entered\n");
break;

case SDL_WINDOWEVENT_LEAVE:
printf("left\n");
break;
}
break;

case SDL_KEYDOWN:
printf("key pressed: %d\n", event.key.keysym.sym);
break;
}
return event.type == SDL_QUIT;
}
8 changes: 4 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
int main(int argc, char *argv[])
{
//int width = 1440, height = 852;
int width = 320, height = 320;
//int width = 320, height = 320;
//int width = 160, height = 120;
//int width = 640, height = 480;
//int width = 1920, height = 1080;
int width = 640, height = 640;
//int width = 1440, height = 1440;
int recursion_depth = 1;
int pitch = 4;
int scale = 4;
int scale = 1;
int renderer_flags = RENDERER_USE_OPENCL_RENDERER;

struct timeval time_start;
Expand Down
18 changes: 9 additions & 9 deletions rtcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void rtcl_init(struct renderer *renderer)
srand(time(NULL));

strcpy(rtcl.kernel_name, "INVALID");
rtcl.num_scene_objects = 31;
rtcl.num_scene_objects = 301;
rtcl.recursion_depth = 5;
rtcl.renderer = renderer;
rtcl.num_pixels = renderer->width * renderer->height;
Expand Down Expand Up @@ -191,12 +191,12 @@ void rtcl_copy_scene_to_device()
.material_type = LIGHT
};

//struct plane light = {
// .position = { 0.0f, 10.0f, -28.0f },
// .normal = { 0.0f, -0.209529f, 0.977802f },
// .color = { 1.0f, 1.0f, 1.0f, 1.0f },
// .material_type = LIGHT
//};
struct plane light_plane = {
.position = { 0.0f, 10.0f, -28.0f },
.normal = { 0.0f, -0.209529f, 0.977802f },
.color = { 1.0f, 1.0f, 1.0f, 1.0f },
.material_type = LIGHT
};

struct sphere ball = {
.position = { -1.5f, 0.0f, -4.0f },
Expand All @@ -207,8 +207,8 @@ void rtcl_copy_scene_to_device()

struct llist *llist = (struct llist *)calloc(1, sizeof(struct llist));
struct sphere *spheres = (struct sphere *)calloc(rtcl.num_scene_objects-1, sizeof(struct sphere));
llist_append(llist, compile_sphere(&light));
//llist_append(llist, compile_plane(&light));
//llist_append(llist, compile_sphere(&light));
llist_append(llist, compile_plane(&light_plane));
llist_append(llist, compile_plane(&U));
llist_append(llist, compile_plane(&R));
llist_append(llist, compile_plane(&F));
Expand Down

0 comments on commit 5288cdf

Please sign in to comment.