Example #1
0
static void
render_page(ImpRenderCtx *ctx, void *drw_data)
{
	iks *x;
	char *element;
	int i;

	i = _imp_fill_back(ctx, drw_data, ctx->page->page);
	element = iks_find_attrib(ctx->page->page, "draw:master-page-name");
	if (element) {
		x = iks_find_with_attrib(
			iks_find(ctx->page->doc->styles, "office:master-styles"),
			"style:master-page", "style:name", element
		);
		if (x) {
			if (i == 0) _imp_fill_back(ctx, drw_data, x);
			for (x = iks_first_tag(x); x; x = iks_next_tag(x)) {
				if (iks_find_attrib(x, "presentation:class"))
					continue;
				render_object(ctx, drw_data, x);
			}
		}
	}
	for (x = iks_first_tag(ctx->page->page); x; x = iks_next_tag(x)) {
		render_object(ctx, drw_data, x);
	}
}
Example #2
0
void atari_motion_objects_device::draw(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	// compute start/stop bands
	int startband = ((cliprect.min_y + m_yscroll - m_slipoffset) & m_bitmapymask) >> m_slipshift;
	int stopband = ((cliprect.max_y + m_yscroll - m_slipoffset) & m_bitmapymask) >> m_slipshift;
	if (startband > stopband)
		startband -= m_bitmapheight >> m_slipshift;
	if (m_slipshift == 0)
		stopband = startband;

	// loop over SLIP bands
	for (int band = startband; band <= stopband; band++)
	{
		// compute the starting link and clip for the current band
		rectangle bandclip = cliprect;
		int link = 0;
		if (m_slipshift != 0)
		{
			// extract the link from the SLIP RAM
			link = (m_slipram[band & m_sliprammask] >> m_linkmask.shift()) & m_linkmask.mask();

			// compute minimum Y and wrap around if necessary
			bandclip.min_y = ((band << m_slipshift) - m_yscroll + m_slipoffset) & m_bitmapymask;
			if (bandclip.min_y >= bitmap.height())
				bandclip.min_y -= m_bitmapheight;

			// maximum Y is based on the minimum
			bandclip.max_y = bandclip.min_y + (1 << m_slipshift) - 1;

			// keep within the cliprect
			bandclip &= cliprect;
		}

		// if this matches the last link, we don't need to re-process the list
		build_active_list(link);

		// set the start and end points
		UINT16 *first, *last;
		int step;
		if (m_reverse)
		{
			first = m_activelast - 4;
			// TODO: this sets last to index m_activelist[-4]
			last = m_activelist - 4;
			step = -4;
		}
		else
		{
			first = m_activelist;
			last = m_activelast;
			step = 4;
		}

		// initialize the parameters
		m_next_xpos = 123456;

		// render the mos
		for (UINT16 *current = first; current != last; current += step)
			render_object(bitmap, bandclip, current);
	}
Example #3
0
		void c_ent_death(const vec2f& pos)
		{
			auto r(mlk::rnd<std::uint8_t>(0, 255)), g(mlk::rnd<std::uint8_t>(0, 255)), b(mlk::rnd<std::uint8_t>(0, 255)), a(mlk::rnd<std::uint8_t>(150, 255));
			auto rec1(factory::create<platform>(pos, vec2f{40.f, 40.f}));
			rec1->render_object().setFillColor({r, g, b, a});
			rec1->set_propertie(entity_propertie::death);
			m_entity_handler.create_entity(rec1);
		}
Example #4
0
render_external_scene(fix eye_offset)
{

	Viewer_eye = Viewer->pos;

	if (eye_offset)
		vm_vec_scale_add2(&Viewer_eye,&Viewer->orient.rvec,eye_offset);

	g3_set_view_matrix(&Viewer->pos,&Viewer->orient,Render_zoom);

	//g3_draw_horizon(BM_XRGB(0,0,0),BM_XRGB(16,16,16));		//,-1);
	gr_clear_canvas(BM_XRGB(0,0,0));

	g3_start_instance_matrix(&vmd_zero_vector,&surface_orient);
	draw_stars();
	g3_done_instance();

	{	//draw satellite

		vms_vector delta;
		g3s_point p,top_pnt;

		g3_rotate_point(&p,&satellite_pos);
		g3_rotate_delta_vec(&delta,&satellite_upvec);

		g3_add_delta_vec(&top_pnt,&p,&delta);

		if (! (p.p3_codes & CC_BEHIND)) {
			int save_im = Interpolation_method;
			//p.p3_flags &= ~PF_PROJECTED;
			//g3_project_point(&p);
			if (! (p.p3_flags & PF_OVERFLOW)) {
				Interpolation_method = 0;
				//gr_bitmapm(f2i(p.p3_sx)-32,f2i(p.p3_sy)-32,satellite_bitmap);
				g3_draw_rod_tmap(satellite_bitmap,&p,SATELLITE_WIDTH,&top_pnt,SATELLITE_WIDTH,f1_0);
				Interpolation_method = save_im;
			}
		}
	}

	#ifdef STATION_ENABLED
	draw_polygon_model(&station_pos,&vmd_identity_matrix,NULL,station_modelnum,0,f1_0,NULL,NULL);
	#endif

	render_terrain(&mine_ground_exit_point,exit_point_bmx,exit_point_bmy);

	draw_exit_model();
	if (ext_expl_playing)
		draw_fireball(&external_explosion);

	Lighting_on=0;
	render_object(ConsoleObject);
	Lighting_on=1;
}
Example #5
0
void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef(0,0,-5);
	glRotatef(rot_x, 1, 0, 0);
	glRotatef(rot_y, 0, 1, 0);

	render_axes();

	glColor3f(1,1,1);
	glPolygonMode(GL_FRONT, GL_LINE);
	render_object();
	glColor3f(.5,.5,.5);
	glPolygonMode(GL_FRONT, GL_FILL);
	render_object();

	glutSwapBuffers();
}
Example #6
0
int main()
{
   clock_t t;
   long fr;

   for (int k=0; k<64000; k++) back[k] = back[k] / 7;

   srand(666);
   if (!add_stars()) { printf("err\n"); exit(1); }

	open_vid();
//   set_mode(0x13);
//   for (int i=0; i<256; i++) set_col(i, i/12, i/8, i/4);

   translate_object(stars, 0.0, 0.0, 2.0);

   fr = 0;
   t = clock();
	while (!ptc_console_key(console))
   {
//      memfill_d((long)screen, 16000, 0);
//      memcopy_d((long)back, (long)screen, 16000);
	memcpy(screen, back, 64000);
//      memset(screen, 0, 64000);
      rotate_object_local(stars);
      cast_object(stars);
      vis_object(stars);
      render_object(stars);
      alfa();
//      memcpy((char *)0xA0000, old_screen, 64000);
//      memcopy_d((long)old_screen, 0xA0000, 16000);
	show(old_screen);

      rotate_object(stars, 9, 9, 9);
      fr++;
   }
   t = clock() - t;
//   getch();

	close_vid();
//   set_mode(3);
   printf("f/s = %f\n", ((float)fr * CLOCKS_PER_SEC / (float)t));
   return 0;
}
Example #7
0
static void
render_object(ImpRenderCtx *ctx, void *drw_data, iks *node)
{
	char *tag, *t;
	ImpColor fg;

	tag = iks_name(node);
	if (strcmp(tag, "draw:g") == 0) {
		iks *x;
		for (x = iks_first_tag(node); x; x = iks_next_tag(x)) {
			render_object(ctx, drw_data, x);
		}
	} else if (strcmp(tag, "draw:frame") == 0) {
		iks *x;
		for (x = iks_first_tag(node); x; x = iks_next_tag(x)) {
			render_object(ctx, drw_data, x);
		}
	} else if (strcmp(tag, "draw:line") == 0) {
		r_get_color(ctx, node, "svg:stroke-color", &fg);
		ctx->drw->set_fg_color(drw_data, &fg);
		ctx->drw->draw_line(drw_data,
			r_get_x(ctx, node, "svg:x1"), r_get_y(ctx, node, "svg:y1"),
			r_get_x(ctx, node, "svg:x2"), r_get_y(ctx, node, "svg:y2")
		);
	} else if (strcmp(tag, "draw:rect") == 0) {
		int x, y, w, h, r = 0;
		char *t;
		x = r_get_x(ctx, node, "svg:x");
		y = r_get_y(ctx, node, "svg:y");
		w = r_get_x(ctx, node, "svg:width");
		h = r_get_y(ctx, node, "svg:height");
		t = r_get_style(ctx, node, "draw:corner-radius");
		if (t) r = atof(t) * ctx->fact_x;
		if (r_get_style(ctx, node, "draw:fill")) {
			r_get_color(ctx, node, "draw:fill-color", &fg);
			ctx->drw->set_fg_color(drw_data, &fg);
			_imp_draw_rect(ctx, drw_data, 1, x, y, w, h, r);
		}
		r_get_color(ctx, node, "svg:stroke-color", &fg);
		ctx->drw->set_fg_color(drw_data, &fg);
		_imp_draw_rect(ctx, drw_data, 0, x, y, w, h, r);
		r_text(ctx, drw_data, node);
	} else if (strcmp(tag, "draw:ellipse") == 0 || strcmp(tag, "draw:circle") == 0) {
		int sa, ea, fill = 0;
		r_get_color(ctx, node, "svg:stroke-color", &fg);
		sa = r_get_angle(node, "draw:start-angle", 0);
		ea = r_get_angle(node, "draw:end-angle", 360);
		if (ea > sa) ea = ea - sa; else ea = 360 + ea - sa;
		t = r_get_style(ctx, node, "draw:fill");
		if (t) fill = 1;
		ctx->drw->set_fg_color(drw_data, &fg);
		ctx->drw->draw_arc(drw_data,
			fill,
			r_get_x(ctx, node, "svg:x"), r_get_y(ctx, node, "svg:y"),
			r_get_x(ctx, node, "svg:width"), r_get_y(ctx, node, "svg:height"),
			sa, ea
		);
	} else if (strcmp(tag, "draw:polygon") == 0) {
		// FIXME:
		r_polygon(ctx, drw_data, node);
	} else if (strcmp(tag, "draw:text-box") == 0) {
		// FIXME:
		r_text(ctx, drw_data, node);
	} else if (strcmp(tag, "draw:image") == 0) {
		char *name;

		name = iks_find_attrib(node, "xlink:href");
		if (!name) return;
		if (name[0] == '#') ++name;

		_imp_draw_image(ctx, drw_data,
			name,
			r_get_x(ctx, node, "svg:x"),
			r_get_y(ctx, node, "svg:y"),
			r_get_x(ctx, node, "svg:width"),
			r_get_y(ctx, node, "svg:height")
		);
	} else {
		printf("Unknown element: %s\n", tag);
	}
}
Example #8
0
int main(int argc, char **args)
{
  const char *ctm_filepath = (argc > 1) ? args[1] : "teapot.ctm";

	trackback_state_initialize(camera_rotation);
	trackback_state_initialize(light_rotation);
	current_trackball_state = &camera_rotation;

  if (!glfwInit()) {
    std::cerr << "Failed to initialize GLFW" << std::endl;
    exit(EXIT_FAILURE);
  }

  int depth_bits = 16;
  if (!glfwOpenWindow(640, 480, 0, 0, 0, 0, depth_bits, 0, GLFW_WINDOW)) {
    std::cerr << "Failed to open GLFW window" << std::endl;
    glfwTerminate();
    exit(EXIT_FAILURE);
  }
  glfwGetWindowSize(&screen_width, &screen_height);
  glfwSetWindowSizeCallback(resize);
  glfwSetKeyCallback(keyboard);
  glfwSetMouseButtonCallback(mouse);
  glfwSetMousePosCallback(motion);
  glfwSetWindowTitle("Spinning Teapot");
  glfwEnable(GLFW_STICKY_KEYS);
  glfwSwapInterval(1);

	// Shaders
	shader_program_t phong_shader;
	build_shader_program(phong_shader, "phong.vs", "phong.fs");
	shader_program_t rect_shader;
	build_shader_program(rect_shader, "rect.vs", "rect.fs");
	shader_program_t render_buffer_shader;
	build_shader_program(render_buffer_shader, "render_buffer.vs", "render_buffer.fs");
	shader_program_t bump_shader;
	build_shader_program(bump_shader, "bump.vs", "bump.fs");

	//--- Mesh Objects
	mesh_t mesh_floor;
	load_mesh_cube(mesh_floor);
  mesh_object_t floor;
  if (! build_mesh_object(mesh_floor, floor) ) {
    glfwTerminate();
    exit(EXIT_FAILURE);	
	}

	mesh_t mesh_plane;
	load_mesh_plane(mesh_plane);
  mesh_object_t plane;
  if (! build_mesh_object(mesh_plane, plane) ) {
    glfwTerminate();
    exit(EXIT_FAILURE);	
	}

	mesh_t mesh_teapot;
	if (! load_mesh_from_file(ctm_filepath, mesh_teapot) ) {
	  glfwTerminate();
    exit(EXIT_FAILURE);		
	}
	compute_tangent_vectors(mesh_teapot);
  mesh_object_t teapot;
  if (! build_mesh_object(mesh_teapot, teapot) ) {
	  glfwTerminate();
    exit(EXIT_FAILURE);
	}

  //--- Texture
	const char *texture_filepath = "checker.tga";
	texture_t tex;
	tex.unit_id = 1;
	if (! build_texutre_from_file(texture_filepath, tex)) {
		std::cout << "Failed to load texture: " << texture_filepath << std::endl;
	  glfwTerminate();
	  exit(EXIT_FAILURE);		
	}

	//--- FBO
	texture_t depth_tex_buffer;
	int depth_tex_width = 2 * screen_width;
	int depth_tex_height = 2 * screen_height;
	depth_tex_buffer.unit_id = 2;
	GLuint fb_handle;
	create_framebuffer_and_depth_texture(depth_tex_width, depth_tex_height, depth_tex_buffer, &fb_handle);

	// Scene settings
  glm::vec3 camera_position(0.0f, 0.0f, 5.0f);
  glm::vec3 camera_center(0.0f, 0.0f, 0.0f);
  glm::vec3 camera_up(0.0f, 1.0f, 0.0f);
  glm::mat4 view_matrix = glm::lookAt(camera_position, camera_center, camera_up); // from world to camera

	glm::mat4 light_pov_matrix;	
	glm::mat4 bias(
		0.5f, 0.0f, 0.0f, 0.0f,
		0.0f, 0.5f, 0.0f, 0.0f,
		0.0f, 0.0f, 0.5f, 0.0f,
		0.5f, 0.5f, 0.5f, 1.0f
		);

	teapot.material.diffuse = glm::vec3(0.0f, 1.0f, 1.0f);
	teapot.material.specular = glm::vec3(0.8f);
	teapot.material.shininess = 128.0f;	
	teapot.textures.push_back(tex);	
	teapot.textures.push_back(depth_tex_buffer);
	
	floor.material.diffuse = glm::vec3(1.0f, 1.0f, 1.0f);
	floor.material.specular = glm::vec3(0.8f);
	floor.material.shininess = 2.0f;
	floor.textures.push_back(depth_tex_buffer);
	
	plane.textures.push_back(depth_tex_buffer);

	glEnable(GL_TEXTURE_2D);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);

  do {
		//--- Transform
		glm::vec3 light_position = glm::mat3_cast(light_rotation.orientation) * glm::vec3(0.0f, 5.0f, 0.0f);
		glm::vec3 light_center(0.0f, 0.0f, 0.0f);
		glm::vec3 light_up(0.0f, 0.0f, 1.0f);
		glm::mat4 light_view_matrix = glm::lookAt(light_position, light_center, light_up);
		
		teapot.matrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.5f, 0.0f));
		floor.matrix = glm::scale(glm::mat4(1.0f), glm::vec3(2.0f, 0.05f, 2.0f));
		plane.matrix = glm::scale(glm::mat4(1.0f), glm::vec3(screen_width, screen_height, 1.0f));
		
		//--- Render
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb_handle);
		{
	    __projection_matrix = glm::perspective(30.0f, (float) screen_width / (float) screen_height, 0.5f, 30.0f);
			__view_matrix = light_view_matrix;
			light_pov_matrix = bias * __projection_matrix * light_view_matrix;
			
			glClear(GL_DEPTH_BUFFER_BIT);
			glClearDepth(1.0f);
			glViewport(0, 0, depth_tex_width, depth_tex_height);
			teapot.shader_program = &render_buffer_shader;
			teapot.shader_program->bind();
			render_object(teapot);
			teapot.shader_program->release();
			floor.shader_program = &render_buffer_shader;
			floor.shader_program->bind();
    	render_object(floor);
			floor.shader_program->release();		
		}
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);		
	
#ifdef DEPTH_BUFFER_DEBUG
		{
			__projection_matrix = glm::ortho(0.0f, (float)screen_width, 0.0f, (float)screen_height, 0.5f, 1.0f);
			__view_matrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -1.0f));
			
			glDisable(GL_DEPTH_TEST);
			glClear(GL_COLOR_BUFFER_BIT);		
    	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    	glViewport(0, 0, screen_width, screen_height);	
			plane.shader_program = &rect_shader;
			plane.shader_program->bind();	
			plane.shader_program->set_uniform_value("texture2", depth_tex_buffer.unit_id); 
	  	render_object(plane);
			plane.shader_program->release();
			glEnable(GL_DEPTH_TEST);
		}
#endif

#ifndef DEPTH_BUFFER_DEBUG
		{			
			glCullFace(GL_BACK);
			glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
			glClearDepth(1.0f);
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			glViewport(0, 0, screen_width, screen_height);

	    __projection_matrix = glm::perspective(camera_fovy, (float) screen_width / (float) screen_height, 1.0f, 30.0f);
			__view_matrix = view_matrix * glm::mat4_cast(camera_rotation.orientation);

#ifdef USE_BUMP_MAPPING
			teapot.shader_program = &bump_shader;
			teapot.shader_program->bind();		
			teapot.shader_program->set_uniform_value("light_world_position", light_position);
			teapot.shader_program->set_uniform_value("surface_color", glm::vec3(0.7f, 0.6f, 0.18f));
			teapot.shader_program->set_uniform_value("bump_density", 16.0f);
			teapot.shader_program->set_uniform_value("bump_size", 0.15f);
			teapot.shader_program->set_uniform_value("specular_factor", 0.5f);
			render_object(teapot);
			teapot.shader_program->release();
#else
			teapot.shader_program = &phong_shader;
			teapot.shader_program->bind();		
			teapot.shader_program->set_uniform_value("light_world_position", light_position);
			teapot.shader_program->set_uniform_value("light_pov_matrix", light_pov_matrix);
			teapot.shader_program->set_uniform_value("texture1", tex.unit_id); 
			teapot.shader_program->set_uniform_value("texture2", depth_tex_buffer.unit_id); 
			render_object(teapot);
			teapot.shader_program->release();
#endif

			floor.shader_program = &phong_shader;
			floor.shader_program->bind();	
			floor.shader_program->set_uniform_value("light_world_position", light_position);
			floor.shader_program->set_uniform_value("light_pov_matrix", light_pov_matrix);
			floor.shader_program->set_uniform_value("texture2", depth_tex_buffer.unit_id); 
	    render_object(floor);
			floor.shader_program->release();	
		}
#endif

    glfwSwapBuffers();

  }
  while (glfwGetKey(GLFW_KEY_ESC) != GLFW_PRESS && glfwGetWindowParam(GLFW_OPENED));

  glfwTerminate();

  return 0;
}