Exemplo n.º 1
0
CameraOrtho2::CameraOrtho2 (const string& name="default")
{
    _mvid = SGR::SeedGenerator::getInst().maxseed();
    _invmvid = SGR::SeedGenerator::getInst().maxseed();
    _projid = SGR::SeedGenerator::getInst().maxseed();
    _invprojid = SGR::SeedGenerator::getInst().maxseed();

    camera_create ( _mvid );
    camera_create ( _invmvid );
    projection_create ( _projid );
    projection_create ( _invprojid );
}
Exemplo n.º 2
0
void scene_load(void)
{
	load_bitmaps();
	scene.realImages = 0;
	scene.camera = camera_create();
	scene.octree = octree_init(input_path_concat("galaxies.txt"), 20000);
	scene.galaxies = galaxylist_create();
}
static void startup(void)
{
	fprintf(stderr, "%s test\n", __func__);
	/* start of TC */
	int ret;
	ret = camera_create(CAMERA_DEVICE_CAMERA0, &camera);
	if( ret != 0 )
		dts_fail("camera_create", "Could not create camera"); 	
}
Exemplo n.º 4
0
void init()
{
  heightfield hf;
  heightfieldinfo hfi;
  skybox sb;
  object3d plan = create_plan_xy(100, 100, 1, 1);
  material mat = material_create(NULL, 0, &color_red, 0, 0);
  matrix4 tmp;
  vector3 cam_pos = {0,50,0};
  vector3 cam_up = {0,1,0};
  vector3 cam_look = {0,50,-1};
  viewport vp = viewport_create(0, 0, display_width(screen), display_height(screen));

  /* Camera */
  camfps = camera_create(60, ZFAR, ZNEAR, &cam_pos, &cam_look, &cam_up, vp);

  /* Heightfied creation */
  hf = heightfield_create_from_file("data/height.png", 1000, 1000, 100);
  heightfield_set_textures_from_file(hf, "data/land.jpg", "data/detail.jpg");
  heightfield_set_detail_scale(hf, 50, 50);
  matrix4_to_rot_x(tmp, -90);
  heightfield_set_world_matrix(hf, tmp);

  /* Heightfield infos*/
  hfi = heightfieldinfo_create("data/land.jpg", hf, camfps, screen, 250, 250);

  /* Skybox */
  sb = skybox_create(camfps, "data/left.jpg", "data/right.jpg", "data/front.jpg", "data/back.jpg", "data/top.jpg", "data/bottom.jpg", 10);

  /* Test plane */
  object3d_set_material(plan, mat);

  /* Populate the scene */
  scn = scene_create();
  scene_set_camera(scn, camfps);
  scene_set_display(scn, screen);
  scene_add_object(scn, sb, (void *)skybox_to_opengl, NULL);
  scene_add_object(scn, hf, (void *)heightfield_to_opengl, NULL);
  scene_add_object(scn, plan, (void *)object3d_to_opengl, NULL);
  scene_add_object2d(scn, hfi, (void *)heightfieldinfo_to_opengl, NULL);

  fontgl_init();
  font = fontgl_create("data/vera.ttf", 800, 600, 16);
  fontgl_set_color(font, 1,0,0);

  glEnable(GL_CULL_FACE);
  glEnable(GL_DEPTH_TEST);
  glDepthFunc(GL_LEQUAL);

  SDL_WarpMouse(CENTERX,CENTERY);
  SDL_WM_GrabInput(SDL_GRAB_ON);
  SDL_ShowCursor(SDL_DISABLE);
}
Exemplo n.º 5
0
TrayObject *camera(TrayLangState *state, int arg_num) {
    TrayObject *fov  = traylang_get_obj(state);
    check(fov, "camera fov arg error");
    TrayObject *pos  = traylang_get_obj(state);
    check(pos, "camera position arg error");
    TrayObject *look = traylang_get_obj(state);
    check(look, "camera look_at arg error");
    return traylang_new_cdata(
               state,
               camera_create(fov->number, *(Vector3D*)pos->cdata, *(Vector3D*)look->cdata)
           );
error:
    return NULL;
}
Exemplo n.º 6
0
static Eina_Bool _main_view_init_camera(main_view *main_view_data)
{
	camera_state_e cur_state = CAMERA_STATE_NONE;
    int result = camera_create(CAMERA_DEVICE_CAMERA0, &main_view_data->camera);
    if (CAMERA_ERROR_NONE == result)
    {
        if (main_view_data->preview_canvas)
        {
        	int result = camera_get_state(main_view_data->camera, &cur_state);
        	if(cur_state == CAMERA_STATE_CREATED)
        	{
                result = camera_set_display(main_view_data->camera, CAMERA_DISPLAY_TYPE_EVAS, GET_DISPLAY(main_view_data->preview_canvas));
                if (CAMERA_ERROR_NONE == result)
                {
                	/* Camera Disply Set */
                    camera_set_display_mode(main_view_data->camera, CAMERA_DISPLAY_MODE_LETTER_BOX);
                    //camera_set_display_flip(main_view_data->camera, CAMERA_FLIP_VERTICAL);
                    camera_set_display_visible(main_view_data->camera, true);

                    camera_foreach_supported_capture_format (main_view_data->camera, _camera_supported_capture_format_callback, main_view_data);

            		_get_screen_resolution();


                    camera_foreach_supported_preview_resolution  ( main_view_data->camera, _camera_supported_preview_resolution_callback, main_view_data);
                    camera_foreach_supported_capture_resolution  ( main_view_data->camera, _camera_supported_capture_resolution_callback, main_view_data);

            		result = camera_get_preview_resolution(main_view_data->camera, &height , &width);
            		INF("camera preview resolution width %d, height %d", width, height);

            		result = camera_get_capture_resolution(main_view_data->camera, &height , &width);
            		INF("camera capture resolution width %d, height %d", width, height);

                    return _main_view_start_camera_preview(main_view_data->camera);
                }
        	}

        }
    }
    return !result;
}
Exemplo n.º 7
0
static int load_camera(scene_t *scene,FILE *file,char *path) {
    char buffer[128],pathname[256];
    float length = 0;
    camera_config_t config;
    memset(&config,0,sizeof(camera_config_t));
    config.aspect = 4.0 / 3.0;
    fscanf(file,"%s",buffer);
    while(fscanf(file,"%s",buffer) != EOF) {
        if(buffer[0] == '#') skeep_comment(file);
        else if(!strcmp(buffer,"start")) scene->start = load_float(file);
        else if(!strcmp(buffer,"end")) scene->end = load_float(file);
        else if(!strcmp(buffer,"length")) length = load_float(file);
        else if(!strcmp(buffer,"pathpos")) {
            load_name(file,path,pathname);
            if(length <= scene->end - scene->start) scene->pathpos = spline_close_load(pathname,length,0,0,0);
            else scene->pathpos = spline_load(pathname,length,0,0,0);
            if(!scene->pathpos) return 0;
        } else if(!strcmp(buffer,"pathdir")) {
            load_name(file,path,pathname);
            if(length <= scene->end - scene->start) scene->pathdir = spline_close_load(pathname,length,0,0,0);
            else scene->pathdir = spline_load(pathname,length,0,0,0);
            if(!scene->pathdir) return 0;
        } else if(!strcmp(buffer,"fov")) config.fov = load_float(file);
        else if(!strcmp(buffer,"aspect")) config.aspect = load_float(file);
        else if(!strcmp(buffer,"clipnear")) config.clipnear = load_float(file);
        else if(!strcmp(buffer,"clipfar")) config.clipfar = load_float(file);
        else if(!strcmp(buffer,"fogcolor")) load_color(file,config.fogcolor);
        else if(!strcmp(buffer,"fogstart")) config.fogstart = load_float(file);
        else if(!strcmp(buffer,"fogend")) config.fogend = load_float(file);
        else if(!strcmp(buffer,"}")) {
            scene->camera = camera_create(&config);
            break;
        } else return 0;
    }
    if(!scene->camera) return 0;
    return 1;
}
Exemplo n.º 8
0
void arcball_create(SDL_Window* window, Vec4f eye, Vec4f target, float z_near, float z_far, struct Arcball* arcball) {
    int32_t width,height;
    sdl2_debug( SDL_GL_GetDrawableSize(window, &width, &height) );

    // - if the user specifies an eye and target so that we are looking along the y-axis (like 0,1,0 and 0,0,0),
    // then we just adjust the eye a tiny bit upwards to prevent a black screen because the up_axis used in
    // arcball_event is the y axis, and two parallel axis have no cross product and things become 0 and everything
    // gets messy, so just add FLOAT_EPSILON to the z coord and be done with it
    if( eye[0] == target[0] && eye[2] == target[2] ) {
        bool assert_test = eye[1] != target[1];
        log_assert( assert_test == true );

        eye[2] += CUTE_EPSILON;
    }

    if( z_near < 0.01f ) {
        log_warn(__FILE__, __LINE__,
                 "you are trying to create a camera with a very small z_near value, "
                 "this would cause problems when rendering vbomeshes with a z_offset, "
                 "this function (arcball_create) will clamp the z_near value to 0.01f\n");
        z_near = 0.01f;
    }

    camera_create(width, height, CAMERA_PERSPECTIVE, &arcball->camera);
    float top = (z_near/width) * height/2.0f;
    float bottom = -top;
    camera_set_frustum(&arcball->camera, -z_near/2.0f, z_near/2.0f, bottom, top, z_near, z_far);

    vec_copy4f(eye, arcball->camera.pivot.position);
    arcball->flipped = pivot_lookat(&arcball->camera.pivot, target);
    arcball->rotate_button = INPUT_MOUSE_ARCBALL_ROTATE;
    arcball->translate_button = INPUT_MOUSE_ARCBALL_TRANSLATE;
    arcball->translate_factor = 500.0f;
    arcball->zoom_factor = 10.0f;

    vec_copy4f(target, arcball->target);
}
Exemplo n.º 9
0
void
camera_start(void)
	{
	MMAL_STATUS_T	status;

	motion_init();
	circular_buffer_init();

	camera_create();

	/* ====== Create the camera preview port path ====== :
	|  preview --(tunnel)--> resizer --> I420_callback --> jpeg_encoder --> mjpeg_callback
	|                                   (draws on frame)                   (writes stream mjpeg.jpg)
	*/
	pikrellcam.mjpeg_height = pikrellcam.mjpeg_width *
					pikrellcam.camera_config.video_height / pikrellcam.camera_config.video_width;
	pikrellcam.mjpeg_width &= ~0xf;		/* Make resize multiple of 16 */
	pikrellcam.mjpeg_height &= ~0xf;
	resizer_create("stream_resizer", &stream_resizer,
							camera.component->output[CAMERA_PREVIEW_PORT],
							pikrellcam.mjpeg_width, pikrellcam.mjpeg_height);
	ports_tunnel_connect(&camera, CAMERA_PREVIEW_PORT, &stream_resizer);
	jpeg_encoder_create("mjpeg_encoder", &mjpeg_encoder,
					stream_resizer.component->output[0], pikrellcam.mjpeg_quality);
	ports_callback_connect(&stream_resizer, 0, &mjpeg_encoder,
					I420_video_callback);
	out_port_callback(&mjpeg_encoder, 0, mjpeg_callback);


	/* ====== Create the camera still port path ====== :
	|  camera_capture --(tunnel)--> jpeg_encoder --> still_jpeg__callback
	|                                               (writes stills and timelapse jpegs)
	*/
	jpeg_encoder_create("still_jpeg_encoder", &still_jpeg_encoder,
					NULL, pikrellcam.camera_adjust.still_quality);
	ports_tunnel_connect(&camera, CAMERA_CAPTURE_PORT, &still_jpeg_encoder);
	out_port_callback(&still_jpeg_encoder, 0, still_jpeg_callback);


	/* ====== Create the camera video port path ====== :
	|  camera_video--(tunnel)-->h264 encoder-->video_h264_encoder_callback
	|                                         (writes data into video circular buffer)
	|                                         (records video / checks motion vectors)
	|                                         (schedules mjpeg.jpg copy into previews)
	*/
	h264_encoder_create("video_h264_encoder", &video_h264_encoder, NULL);
	ports_tunnel_connect(&camera, CAMERA_VIDEO_PORT, &video_h264_encoder);
	out_port_callback(&video_h264_encoder, 0, video_h264_encoder_callback);

	time(&pikrellcam.t_start);

	/* Turn on the video stream. It free runs into the video circular buffer.
	*/
	if ((status = mmal_port_parameter_set_boolean(
				camera.component->output[CAMERA_VIDEO_PORT],
				MMAL_PARAMETER_CAPTURE, 1)) != MMAL_SUCCESS)
		log_printf("Video capture startup failed. Status %s\n",
					mmal_status[status]);

	/* With everything created and running, set the config'ed camera params.
	*/
	mmalcam_config_parameters_set_camera();

	display_init();
	video_circular_buffer.state = VCB_STATE_NONE;
	video_circular_buffer.pause = FALSE;
	}
Exemplo n.º 10
0
Arquivo: main.c Projeto: nowl/open-dm
int main(int argc, char *argv[])
{
    lapis_init();

    engine_t *engine = lapis_get_engine();
    set_ticks_per_second(30);

    game_state_t *state = game_state_create(0);
    state->num_render_levels = RL_NUM;

    engine_switch_state(engine, state);

    /* initialize video */

    lsdl_set_video_mode(engine->sdl_driver,
                        WIDTH, HEIGHT, 0, 1);

    SDL_EnableKeyRepeat(500, 50);
    SDL_WM_SetCaption( "Open DM v. 0.1", NULL );

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity( );
    gluPerspective(FIELD_OF_VISION, 1, 0.1, 100);

//    glEnable(GL_TEXTURE_2D);

    glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_DEPTH_TEST);
//    glDisable(GL_LIGHTING);
//    glEnable(GL_LIGHTING);

    glViewport(0, 0, WIDTH, HEIGHT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(0,0,0, 0, 0, -10, 0, 1.0, 0);

    /* test */
    /* load graphics */
//    lapis_lua_t *lua = lua_scripting_init();
//    if( lua_scripting_run_file(lua, "main.lua") != 0 )
//        return 0;
    /* end test */

    /* create objects */

    game_object_t * global_object = game_object_create("global", NULL);
    game_state_append_object(state, global_object);
    game_object_set_recv_callback_c_func(global_object, global_message_handler);
    game_state_append_bcast_recvr(state,
                                  global_object,
                                  "sdl-event");

    block_t *block = block_create(1, 1);
    game_state_append_object(state, block->go);

    camera_t *camera = camera_create(0, 0, 0);
    game_state_append_object(state, camera->go);

    lapis_mainloop();

    /* this will be cleaned up by the OS */
    //game_state_destroy(state);
    //lapis_deinit();

    return 0;
}
Exemplo n.º 11
0
// Create the appropriate GUI proxy for a given set of device info.
void create_proxy(device_t *device, opt_t *opt, mainwnd_t *mainwnd, playerc_client_t *client)
{
  switch (device->addr.interf)
  {
    case PLAYER_ACTARRAY_CODE:
      device->proxy = actarray_create(mainwnd, opt, client,
                                    device->addr.index,
                                    device->drivername,
                                    device->subscribe);
      device->fndestroy = (fndestroy_t) actarray_destroy;
      device->fnupdate = (fnupdate_t) actarray_update;
      break;

    case PLAYER_AIO_CODE:
      device->proxy = aio_create(mainwnd, opt, client,
                                    device->addr.index,
                                    device->drivername,
                                    device->subscribe);
      device->fndestroy = (fndestroy_t) aio_destroy;
      device->fnupdate = (fnupdate_t) aio_update;
      break;

     case PLAYER_BUMPER_CODE:
       device->proxy = bumper_create(mainwnd, opt, client,
                                   device->addr.index,
                                   device->drivername,
                                   device->subscribe);
       device->fndestroy = (fndestroy_t) bumper_destroy;
       device->fnupdate = (fnupdate_t) bumper_update;
       break;

     case PLAYER_DIO_CODE:
       device->proxy = dio_create(mainwnd, opt, client,
                                  device->addr.index,
                                  device->drivername,
                                  device->subscribe);
       device->fndestroy = (fndestroy_t) dio_destroy;
       device->fnupdate = (fnupdate_t) dio_update;
       break;

    case PLAYER_IR_CODE:
      device->proxy = ir_create(mainwnd, opt, client,
                                   device->addr.index, device->drivername, device->subscribe);
      device->fndestroy = (fndestroy_t) ir_destroy;
      device->fnupdate = (fnupdate_t) ir_update;
      break;

    case PLAYER_LASER_CODE:
      device->proxy = laser_create(mainwnd, opt, client,
                                   device->addr.index,
                                   device->drivername,
                                   device->subscribe);
      device->fndestroy = (fndestroy_t) laser_destroy;
      device->fnupdate = (fnupdate_t) laser_update;
      break;

    case PLAYER_POWER_CODE:
      device->proxy = power_create(mainwnd, opt, client,
                                   device->addr.index,
                                   device->drivername, device->subscribe);
      device->fndestroy = (fndestroy_t) power_destroy;
      device->fnupdate = (fnupdate_t) power_update;
      break;

    case PLAYER_POSITION2D_CODE:
      device->proxy = position2d_create(mainwnd, opt, client,
                                        device->addr.index,
                                        device->drivername,
                                        device->subscribe);
      device->fndestroy = (fndestroy_t) position2d_destroy;
      device->fnupdate = (fnupdate_t) position2d_update;
      break;

    case PLAYER_PTZ_CODE:
      device->proxy = ptz_create(mainwnd, opt, client,
                                        device->addr.index,
                                        device->drivername,
                                        device->subscribe);
      device->fndestroy = (fndestroy_t) ptz_destroy;
      device->fnupdate = (fnupdate_t) ptz_update;
      break;

    case PLAYER_RANGER_CODE:
      device->proxy = ranger_create(mainwnd, opt, client,
                                    device->addr.index,
                                    device->drivername,
                                    device->subscribe);
      device->fndestroy = (fndestroy_t) ranger_destroy;
      device->fnupdate = (fnupdate_t) ranger_update;
      break;

    case PLAYER_SONAR_CODE:
      device->proxy = sonar_create(mainwnd, opt, client,
                                   device->addr.index,
                                   device->drivername,
                                   device->subscribe);
      device->fndestroy = (fndestroy_t) sonar_destroy;
      device->fnupdate = (fnupdate_t) sonar_update;
      break;

    case PLAYER_WIFI_CODE:
      device->proxy = wifi_create(mainwnd, opt, client,
                                        device->addr.index,
                                        device->drivername,
                                        device->subscribe);
      device->fndestroy = (fndestroy_t) wifi_destroy;
      device->fnupdate = (fnupdate_t) wifi_update;
      break;

    case PLAYER_BLOBFINDER_CODE:
      device->proxy = blobfinder_create(mainwnd, opt, client,
					device->addr.index,
                                        device->drivername,
					device->subscribe);
      device->fndestroy = (fndestroy_t) blobfinder_destroy;
      device->fnupdate = (fnupdate_t) blobfinder_update;
      break;

    case PLAYER_CAMERA_CODE:
      device->proxy = camera_create(mainwnd, opt, client,
					device->addr.index,
                                        device->drivername,
					device->subscribe);
      device->fndestroy = (fndestroy_t) camera_destroy;
      device->fnupdate = (fnupdate_t) camera_update;
      break;



    case PLAYER_FIDUCIAL_CODE:
      device->proxy = fiducial_create(mainwnd, opt, client,
                                      device->addr.index,
				      device->drivername,
				      device->subscribe);
      device->fndestroy = (fndestroy_t) fiducial_destroy;
      device->fnupdate = (fnupdate_t) fiducial_update;
      break;

    case PLAYER_GRIPPER_CODE:
      device->proxy = gripper_create(mainwnd, opt, client,
				     device->addr.index,
				     device->drivername,
				     device->subscribe);
      device->fndestroy = (fndestroy_t) gripper_destroy;
      device->fnupdate = (fnupdate_t) gripper_update;
      break;

    case PLAYER_MAP_CODE:
      device->proxy = map_create(mainwnd, opt, client,
				 device->addr.index,
				 device->drivername,
				 device->subscribe);
      device->fndestroy = (fndestroy_t) map_destroy;
      device->fnupdate = (fnupdate_t) map_update;
      break;

    case PLAYER_VECTORMAP_CODE:
      device->proxy = vectormap_create(mainwnd, opt, client,
         device->addr.index,
         device->drivername,
         device->subscribe);
      device->fndestroy = (fndestroy_t) vectormap_destroy;
      device->fnupdate = (fnupdate_t) vectormap_update;
      break;


#if 0
    case PLAYER_LOCALIZE_CODE:
      device->proxy = localize_create(mainwnd, opt, client,
                                 device->index, device->drivername, device->subscribe);
      device->fndestroy = (fndestroy_t) localize_destroy;
      device->fnupdate = (fnupdate_t) localize_update;
      break;



#endif

    default:
      device->proxy = NULL;
      device->fndestroy = NULL;
      device->fnupdate = NULL;
      break;
  }
  return;
}
int main(int argc, char* argv[])
{
	// our demo variables
	World* demoworld = 0;
	Camera* democamera = 0;
	Tileset* demotileset = 0;
	Renderer* demorenderer = 0;

	// init SDL
	if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
	{
		fprintf(stderr, "SDL Library Initialization Failed!\n\tSDL Error: %s\n", SDL_GetError());
		exit(1);
	}
	atexit(SDL_Quit);

	// create the window
	if (!SDL_SetVideoMode(SCREEN_W, SCREEN_H, SCREEN_BPP, SDL_HWSURFACE | SDL_DOUBLEBUF))
	{
		fprintf(stderr, "SDL Screen Initialization Failed! %dx%d@%dbpp\nSDL Error: %s\n",
			SCREEN_W,
			SCREEN_H,
			SCREEN_BPP,
			SDL_GetError());
		exit(1);
	}

	// set the window caption
	SDL_WM_SetCaption("Basic SDL Map Editor Example Demo -- by Richard Marks <*****@*****.**>", 0);

	// create our keyboard handler
	Keyboard* keyboard = keyboard_create();

	// load the world
	demoworld = world_load("example_demo.map");
	if (!demoworld)
	{
		fprintf(stderr, "unable to load the world file!\n");
		exit(1);
	}

	// load the tileset
	demotileset = tileset_load("example_demo.png", 32, 32);
	if (!demotileset)
	{
		fprintf(stderr, "unable to load the tileset file!\n");
		exit(1);
	}

	// create the camera
	democamera = camera_create(
		// anchor position of the camera is at 32,32 on the screen
		32, 32,
		// the camera view is 30 x 22 tiles
		30, 22,
		// need to tell the camera the size of the tiles
		demotileset->width, demotileset->height);

	// create the renderer
	demorenderer = renderer_create(demoworld, demotileset, democamera);

	// pre-render the scene
	renderer_pre_render(demorenderer);

	fprintf(stderr, "\nstarting main loop...\n\n");
	// start the main loop
	SDL_Event event;
	bool running = true;
	int startticks = SDL_GetTicks();
	int mainlooptimer = SDL_GetTicks();
	while(running)
	{
		// check for our window being closed
		while(SDL_PollEvent(&event))
		{
			if (SDL_QUIT == event.type)
			{
				running = false;
			}
		}

		// update our keyboard handler
		keyboard_update(keyboard);

		// start timing our code
		startticks = SDL_GetTicks();

		// check for our controls

		// ESC and Q quits
		if (keyboard->key[SDLK_ESCAPE] || keyboard->key[SDLK_q])
		{
			running = false;
		}

		const unsigned int CAMERASPEED = 16;

		// W and up arrow
		if (keyboard->key[SDLK_w] || keyboard->key[SDLK_UP])
		{
			if (democamera->inpixels->y > 0)
			{
				democamera->inpixels->y -= CAMERASPEED;
			}
		}

		// S and down arrow
		if (keyboard->key[SDLK_s] || keyboard->key[SDLK_DOWN])
		{
			if (democamera->inpixels->y < demorenderer->scene->h - democamera->inpixels->h)
			{
				democamera->inpixels->y += CAMERASPEED;
			}
		}

		// A and left arrow
		if (keyboard->key[SDLK_a] || keyboard->key[SDLK_LEFT])
		{
			if (democamera->inpixels->x > 0)
			{
				democamera->inpixels->x -= CAMERASPEED;
			}
		}

		// D and right arrow
		if (keyboard->key[SDLK_d] || keyboard->key[SDLK_RIGHT])
		{
			if (democamera->inpixels->x < demorenderer->scene->w - democamera->inpixels->w)
			{
				democamera->inpixels->x += CAMERASPEED;
			}
		}

		// render our scene
		renderer_render(demorenderer);

		// flip our double buffer
		SDL_Flip(SDL_GetVideoSurface());

		// lock our framerate to roughly 30 FPS
		int tickdiff = SDL_GetTicks() - startticks;
		if (tickdiff < 33)
		{
			SDL_Delay(33 - tickdiff);
		}
	}

	int tickdiff = SDL_GetTicks() - mainlooptimer;

	fprintf(stderr, "finished after %d ticks!\n\n", tickdiff);

	// destroy our pointers
	tileset_destroy(demotileset);
	renderer_destroy(demorenderer);
	world_destroy(demoworld);
	camera_destroy(democamera);
	keyboard_destroy(keyboard);

	return 0;
}