Exemplo n.º 1
0
/*
 * Run engine until stop() is called.
 *
 * The virtual member frame() will be called once for
 * each control system frame. pre_render() and
 * post_render() will be called before/after the engine
 * renders each video frame.
 */
void gfxengine_t::run()
{
	open();
	show();
	start_engine();
	is_running = 1;
	double toframe = 0.0f;
	double fdt = 1.0f;
	cs_engine_advance(csengine, 0);
	while(is_running)
	{
		int t = (int)SDL_GetTicks();
		int dt = t - last_tick;
		last_tick = t;
		if(abs(dt) > 500)
			last_tick = t;
		if(dt > 250)
			dt = (int)ticks_per_frame;
		if(_timefilter)
			fdt += (dt - fdt) * _timefilter;
		else
			fdt = ticks_per_frame;
		toframe += fdt / ticks_per_frame;
		cs_engine_advance(csengine, toframe);
		pre_render();
		window->select();
		cs_engine_render(csengine);
		post_render();
		if(_autoinvalidate)
			window->invalidate();
		flip();
	}
	stop_engine();
}
Exemplo n.º 2
0
    bool renderer::render(const crowd & people, const platform::tstring & text)
    {
        if (!pre_render()) { return false; }

        D3DXMATRIX skel_transform;
        ::D3DXMatrixScaling(&skel_transform, 0.5, 0.5, 0.5);
        
        for (crowd::size_type i = 0; i < people.size(); ++i)
        {
            skeleton s = people.person(i);
            draw_skeleton(*s.bind_pose(), *s.structure(), visuals, skel_transform);
        }

        if (scene_visual->reflective())
        {
            pipeline.culling(D3DCULL_CCW);
            D3DXMATRIX invert_transform;
            ::D3DXMatrixScaling(&invert_transform, 1.0f, -1.0f, 1.0f);
            D3DXMATRIX reflection_transform;
            ::D3DXMatrixMultiply(&reflection_transform, &skel_transform, &invert_transform);
       
            for (crowd::size_type i = 0; i < people.size(); ++i)
            {
                skeleton s = people.person(i);
                draw_skeleton(*s.bind_pose(), *s.structure(), visuals, reflection_transform);
            }

            pipeline.culling();
        }

        return post_render(text);
    }
Exemplo n.º 3
0
RenderObject::RenderObject(std::string model, bool normalize_scale, unsigned int aiOptions)
	: MovableObject()
	, normalization_matrix_(1.0f)
	, scene(nullptr)
	, name(model)
	, scale(1.0f) {

	std::string real_path = model;

	importer.SetIOHandler(new AssimpDataImport());

	scene = importer.ReadFile(real_path,
		aiProcess_Triangulate | aiProcess_GenSmoothNormals |
		aiProcess_JoinIdenticalVertices |
		aiProcess_OptimizeMeshes | aiProcess_OptimizeGraph  |
		aiProcess_ImproveCacheLocality | aiProcess_GenUVCoords |
		aiProcess_ValidateDataStructure | aiProcess_FixInfacingNormals |
		aiProcess_SortByPType |
		aiProcess_CalcTangentSpace | aiOptions
		);

	if ( !scene ) {
		printf("Failed to load model `%s': %s\n", real_path.c_str(), importer.GetErrorString());
		return;
	}

	fprintf(verbose, "Loaded model %s:\n"
	        "  Meshes: %d\n"
	        "  Textures: %d\n"
	        "  Materials: %d\n",
	        model.c_str(), scene->mNumMeshes, scene->mNumTextures, scene->mNumMaterials);

	//Get bounds:
	aiVector3D s_min, s_max;
	get_bounding_box(&s_min, &s_max);
	scene_min = glm::make_vec3((float*)&s_min);
	scene_max = glm::make_vec3((float*)&s_max);
	scene_center  = (scene_min+scene_max)/2.0f;

	//Calculate normalization matrix
	if(normalize_scale) {
		const glm::vec3 size = scene_max - scene_min;
		float tmp = std::max(size.x, size.y);
		tmp = std::max(tmp, size.z);
		normalization_matrix_ = glm::scale(normalization_matrix_, glm::vec3(1.f/tmp));
	}

	pre_render();
}
Exemplo n.º 4
0
void Renderer::render_frame()
{
	begin_frame();
	
	if (scene_to_render != nullptr)
	{
		pre_render();

		gbuffer_render();

		main_render();

		post_render();
	}

	gui.render_frame();

	end_frame();
}
Exemplo n.º 5
0
void osd_xenon_update_video(render_primitive_list &primlist) {
    primlist.acquire_lock();
    
    pre_render();
    
    int minwidth, minheight;

    // get the minimum width/height for the current layout
    xenos_target->compute_minimum_size(minwidth, minheight);

    // make that the size of our target
    xenos_target->set_bounds(minwidth, minheight);

    n = 0;
    // begin ...
    render_primitive *prim;
    for (prim = primlist.first(); prim != NULL; prim = prim->next()) {
        switch (prim->type) {
            case render_primitive::LINE:
                draw_line(prim);
                break;

            case render_primitive::QUAD:
                draw_quad(prim);
                break;

            default:
                throw emu_fatalerror("Unexpected render_primitive type");
        }
        
        n++;
    }

    printf("Number of primitives :%d\r\n", n);

    render();
    
    primlist.release_lock();
}
Exemplo n.º 6
0
void osd_xenon_update_video(render_primitive_list &primlist) {
	currList = &primlist;
	pre_render();

	int minwidth, minheight;
	int newwidth, newheight;

	XenosSurface * fb = Xe_GetFramebufferSurface(g_pVideoDevice);

	// make that the size of our target
	xenos_target->set_bounds(fb->width, fb->height);

	xenos_target->compute_visible_area(fb->width, fb->height, (float) fb->width / (float) fb->height, xenos_target->orientation(), newwidth, newheight);

	n = 0;

	render_primitive *prim;
	for (prim = currList->first(); prim != NULL; prim = prim->next()) {
		switch (prim->type) {
			case render_primitive::LINE:
				DrawLine(prim);
				break;

			case render_primitive::QUAD:
				DrawQuad(prim);                        
				break;

			default:
				throw emu_fatalerror("Unexpected render_primitive type");
		}

		n++;
	}

	render();
}
Exemplo n.º 7
0
void osd_xenon_update_video(render_primitive_list &primlist) {

    //primlist->acquire_lock();
    currList = &primlist;
	pre_render();

	int minwidth, minheight;
	int newwidth, newheight;

	// get the minimum width/height for the current layout
	xenos_target->compute_minimum_size(minwidth, minheight);

//            minwidth = screen_width;
//            minheight = screen_height;

	// make that the size of our target
	xenos_target->set_bounds(minwidth, minheight);

	xenos_target->compute_visible_area(screen_width, screen_height, screen_width / screen_height, xenos_target->orientation(), newwidth, newheight);

	//ShaderEffects.at(2).Render(minwidth, minheight);
	ShaderEffects.at(0).Render(minwidth, minheight);

	Xe_SetStreamSource(g_pVideoDevice, 0, soft_vb, nb_vertices, sizeof (MameVerticeFormats));

	vertices = (MameVerticeFormats *) Xe_VB_Lock(g_pVideoDevice, soft_vb, 0, 3 * sizeof (MameVerticeFormats), XE_LOCK_WRITE);
	//CreateRect(((float) newwidth / (float) screen_width), -((float) newheight / (float) screen_height), vertices);
	CreateRectHlsl(screen_width, screen_height, vertices);
	Xe_VB_Unlock(g_pVideoDevice, soft_vb);

	// update texture
	//draw32_draw_primitives(primlist, screen, minwidth, minheight, g_pTexture->wpitch / 4);

	/* loop over the list and render each element */
	const render_primitive *prim;
	void *dstdata = (void *) screen;
	UINT32 width = minwidth;
	UINT32 height = minheight;
	UINT32 pitch = g_pTexture->wpitch / 4;
	/*
	for (prim = currList->first(); prim != NULL; prim = prim->next()) {
		switch (prim->type) {
			case render_primitive::LINE:
				draw32_draw_line(prim, dstdata, width, height, pitch);
				break;

			case render_primitive::QUAD:
				if (!prim->texture.base)
					draw32_draw_rect(prim, dstdata, width, height, pitch);
				else
					draw32_setup_and_draw_textured_quad(prim, dstdata, width, height, pitch);
				break;

			default:
				throw emu_fatalerror("Unexpected render_primitive type");
		}
	}
	* */
	
	software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(primlist, dstdata, width, height, pitch);

	Xe_Surface_LockRect(g_pVideoDevice, g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE);
	Xe_Surface_Unlock(g_pVideoDevice, g_pTexture);

	// correct texture size
	g_pTexture->width = minwidth;
	g_pTexture->height = minheight;

	// draw
	Xe_SetTexture(g_pVideoDevice, 0, g_pTexture);
	Xe_DrawPrimitive(g_pVideoDevice, XE_PRIMTYPE_RECTLIST, 0, 1);

	render();
}