void Scene_polyhedron_selection_item::draw(Viewer_interface* viewer) const
{

    if(!are_buffers_filled)
        initialize_buffers(viewer);

    draw_points(viewer);
    GLfloat offset_factor;
    GLfloat offset_units;
    viewer->glGetFloatv( GL_POLYGON_OFFSET_FACTOR, &offset_factor);
    viewer->glGetFloatv(GL_POLYGON_OFFSET_UNITS, &offset_units);
    glPolygonOffset(-1.f, 1.f);

    vaos[0]->bind();
    program = getShaderProgram(PROGRAM_WITH_LIGHT);
    attrib_buffers(viewer,PROGRAM_WITH_LIGHT);
    program->bind();
    program->setAttributeValue("colors",facet_color);
    viewer->glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(nb_facets/3));
    program->release();
    vaos[0]->release();
    glPolygonOffset(offset_factor, offset_units);
    draw_edges(viewer);


}
void TriMeshView::draw_base_mesh()
{
    // Enable the vertex array
    glEnableClientState(GL_VERTEX_ARRAY);
    glVertexPointer(3, GL_FLOAT, 0, &triMesh->vertices[0][0]);

    //normal array
    if(!triMesh->normals.empty())
    {
        glEnableClientState(GL_NORMAL_ARRAY);
        glNormalPointer(GL_FLOAT, 0, &triMesh->normals[0][0]);
    }
    else
    {
        glDisableClientState(GL_NORMAL_ARRAY);
    }

//    glColor3f(1, 1, 1);
//    draw_strips();//遮住背面法线

    // Draw the mesh, possibly with color and/or lighting
    glDepthFunc(GL_LESS);
    glEnable(GL_DEPTH_TEST);
    glPolygonOffset(5.0f, 30.0f);
    glEnable(GL_POLYGON_OFFSET_FILL);
    glEnable(GL_CULL_FACE);


    if(isDrawCurvColors)
        draw_curv_colors();

    if(isDrawNormalColors)
        draw_normal_colors();

    //draw_color_maps();
    glColor3f(1, 1, 1);
    draw_strips();//遮住背面法线
 //
    // Reset everything
    glDisableClientState(GL_COLOR_ARRAY);
    glDisable(GL_CULL_FACE);
    glDepthMask(GL_FALSE); // Do not remove me, else get dotted lines--zdd: That's true.

    if(isDrawEdges)
        draw_edges();

    if(isDrawNormals)
        draw_normals();

    if(isDrawPreview)
        draw_preview();

    if(isDrawCurv1)
        draw_curv1();
    if(isDrawCurv2)
        draw_curv2();

    glDisableClientState(GL_VERTEX_ARRAY);
}
Example #3
0
static SCREEN_UPDATE( madalien )
{
	madalien_state *state = screen->machine->driver_data<madalien_state>();
	int flip = BIT(input_port_read(screen->machine, "DSW"), 6) && BIT(*state->video_control, 0);

	// bits #0 and #1 define scrolling mode
	//
	// mode 0 - cycle over map section A
	// mode 1 - cycle over map section B
	//
	// mode 2 - transition from B to A
	// mode 3 - transition from A to B
	int scroll_mode = *state->scroll & 3;

	bitmap_fill(bitmap, cliprect, 0);
	draw_edges(screen->machine, bitmap, cliprect, flip, scroll_mode);
	draw_foreground(screen->machine, bitmap, cliprect, flip);

	/* highlight section A (outside of tunnels).
     * also, bit 1 of the state->video_flags register (6A) is
     * combined with the headlight signal through NOR gate 1A,
     * which is used to light up the tunnel when an alien explodes
    */
	if (scroll_mode != 1 || *state->video_flags & 2)
	{
		int x;
		int y;

		int min_x = 0;
		int max_x = 0xff;

		if (!(*state->video_flags & 2))
		{
			if (scroll_mode == 2) min_x = (*state->scroll & 0xfc);
			else if (scroll_mode == 3) max_x = (*state->scroll & 0xfc) - 1;
		}

		if (flip)
		{
			int max_x_save = max_x;
			max_x = 0xff - min_x;
			min_x = 0xff - max_x_save;
		}

		for (y = cliprect->min_y; y <= cliprect->max_y ; y++)
			for (x = min_x; x <= max_x; x++)
				if ((x >= cliprect->min_x) && (x <= cliprect->max_x))
					*BITMAP_ADDR16(bitmap, y, x) |= 8;
	}

	draw_headlight(screen->machine, bitmap, cliprect, flip);

	return 0;
}
Example #4
0
UINT32 madalien_state::screen_update_madalien(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	int flip = BIT(ioport("DSW")->read(), 6) && BIT(*m_video_control, 0);

	// bits #0 and #1 define scrolling mode
	//
	// mode 0 - cycle over map section A
	// mode 1 - cycle over map section B
	//
	// mode 2 - transition from B to A
	// mode 3 - transition from A to B
	int scroll_mode = *m_scroll & 3;

	bitmap.fill(0, cliprect);
	draw_edges(screen, bitmap, cliprect, flip, scroll_mode);
	draw_foreground(screen, bitmap, cliprect, flip);

	/* highlight section A (outside of tunnels).
	 * also, bit 1 of the video_flags register (6A) is
	 * combined with the headlight signal through NOR gate 1A,
	 * which is used to light up the tunnel when an alien explodes
	*/
	if (scroll_mode != 1 || *m_video_flags & 2)
	{
		int x;
		int y;

		int min_x = 0;
		int max_x = 0xff;

		if (!(*m_video_flags & 2))
		{
			if (scroll_mode == 2) min_x = (*m_scroll & 0xfc);
			else if (scroll_mode == 3) max_x = (*m_scroll & 0xfc) - 1;
		}

		if (flip)
		{
			int max_x_save = max_x;
			max_x = 0xff - min_x;
			min_x = 0xff - max_x_save;
		}

		for (y = cliprect.min_y; y <= cliprect.max_y ; y++)
			for (x = min_x; x <= max_x; x++)
				if ((x >= cliprect.min_x) && (x <= cliprect.max_x))
					bitmap.pix16(y, x) |= 8;
	}

	draw_headlight(bitmap, cliprect, flip);

	return 0;
}
Example #5
0
void	draw_main()
#endif
{
	debugmessage("draw_main","");

	start_time();
	draw_nodes();
	stop_time("draw_main draw_nodes");
	start_time();
	draw_edges();
	stop_time("draw_main draw_edges");
}
Example #6
0
static VIDEO_UPDATE( madalien )
{
	int flip = BIT(input_port_read(screen->machine, "DSW"), 6) && BIT(*madalien_video_control, 0);

	// bits #0 and #1 define scrolling mode
	//
	// mode 0 - cycle over map section A
	// mode 1 - cycle over map section B
	//
	// mode 2 - transition from B to A
	// mode 3 - transition from A to B
	int scroll_mode = *madalien_scroll & 3;

	bitmap_fill(bitmap, cliprect, 0);
	draw_edges(bitmap, cliprect, flip, scroll_mode);
	draw_foreground(screen->machine, bitmap, cliprect, flip);

	/* highlight section A (outside of tunnels) */

	if (scroll_mode != 1)
	{
		int x;
		int y;

		int min_x = 0;
		int max_x = 0xff;

		if (scroll_mode == 2)
			min_x = (*madalien_scroll & 0xfc);

		if (scroll_mode == 3)
			max_x = (*madalien_scroll & 0xfc) - 1;

		if (flip)
		{
			int max_x_save = max_x;
			max_x = 0xff - min_x;
			min_x = 0xff - max_x_save;
		}

		for (y = cliprect->min_y; y <= cliprect->max_y ; y++)
			for (x = min_x; x <= max_x; x++)
				if ((x >= cliprect->min_x) && (x <= cliprect->max_x))
					*BITMAP_ADDR16(bitmap, y, x) |= 8;
	}

	draw_headlight(bitmap, cliprect, flip);

	return 0;
}
Example #7
0
void generate( int polygons ) {
	double knob_value;
	vary_node *knobs;
	vary_node vn;
	char frame_name[128];

	if (first_pass()) {
		knobs = second_pass();
	}
	else {
		num_frames = 1;
	}

	// Default values
	char color_type = PNG_RGB, shading = GOROUD;
	int width = 1000, height = 1000, segments = 20;
	screen s = make_screen(width, height);
	vertex_list vlist = new_vlist(100);
	face_list flist = new_flist(100);
	edge_list elist = new_elist(100);
	stack coord_systems = new_stack(5);
	vector center = new_vector(0, 0, 0);
	vector eye = new_vector(0, 0, 200);
	double distance = 200;
	vertex text0, text1;
	text0.x = -100; text0.y = 0; text0.z = 0;
	text1.x =  100; text1.y = 0; text1.z = 0;
	text0.nx = text1.x - text0.x;
	text0.ny = text1.y - text0.y;
	text0.nz = text1.z - text0.z;
	text1.nx = text0.nx * text0.nx + text0.ny * text0.ny + text0.nz * text0.nz;
	text0.color = rgb(255, 255, 255);
	text0.shine = 3;
	text1.color = rgb(255, 0, 255);
	text1.shine = 3;
	uint32_t amb_color = rgb(255, 255, 255), light_color = rgb(0, 255, 255),
	wire_color = rgb(255, 255, 255);
	vector light_source = new_vector(0, 100, 200);
	double amb_ref_constant = 0.1, diff_ref_constant = 1, spec_ref_constant = 1;

	int frame, i, j; double temp;
	for (frame = 0; frame < num_frames; frame++) {
		if (num_frames > 1) {
			for (vn = knobs[frame]; vn != NULL; vn = vn->next) {
				set_value(lookup_symbol(vn->name), vn->value);
			}
		}
		for (i = 0; i < lastop; i++) {
			switch (op[i].opcode) {
				case TEXTURE:
				text0.x = op[lastop].op.texture.d0[0];
				text0.y = op[lastop].op.texture.d0[1];
				text0.z = op[lastop].op.texture.d0[2];
				text1.x = op[lastop].op.texture.d1[0];
				text1.y = op[lastop].op.texture.d1[1];
				text1.z = op[lastop].op.texture.d1[2];
				text0.nx = text1.x - text0.x;
				text0.ny = text1.y - text0.y;
				text0.nz = text1.z - text0.z;
				text1.nx =
				text0.nx * text0.nx + text0.ny * text0.ny + text0.nz * text0.nz;
				text0.color = rgb(
					(uint8_t) max(0, min(0xFF, op[lastop].op.texture.d2[0])),
					(uint8_t) max(0, min(0xFF, op[lastop].op.texture.d2[1])),
					(uint8_t) max(0, min(0xFF, op[lastop].op.texture.d2[2]))
 					);
				text0.shine = op[lastop].op.texture.d2[3];
				text1.color = rgb(
					(uint8_t) max(0, min(0xFF, op[lastop].op.texture.d3[0])),
					(uint8_t) max(0, min(0xFF, op[lastop].op.texture.d3[1])),
					(uint8_t) max(0, min(0xFF, op[lastop].op.texture.d3[2]))
 					);
				text1.shine = op[lastop].op.texture.d3[3];
				break;

				case CAMERA:
				eye.x = op[lastop].op.camera.eye[0];
				eye.y = op[lastop].op.camera.eye[1];
				eye.z = op[lastop].op.camera.eye[2];
				center.x = eye.x + op[lastop].op.camera.aim[0];
				center.y = eye.y + op[lastop].op.camera.aim[1];
				center.z = eye.z + op[lastop].op.camera.aim[2];
				break;

				case FOCAL:
				distance = op[lastop].op.focal.value;
				break;

				case AMBIENT:
				amb_color = rgb(
					(uint8_t) max(0, min(0xFF, op[lastop].op.ambient.c[0])),
					(uint8_t) max(0, min(0xFF, op[lastop].op.ambient.c[1])),
					(uint8_t) max(0, min(0xFF, op[lastop].op.ambient.c[2]))
					);
				break;

				case LIGHT:
				light_color = rgb(
					(uint8_t) max(0, min(0xFF, op[lastop].op.light.c[0])),
					(uint8_t) max(0, min(0xFF, op[lastop].op.light.c[1])),
					(uint8_t) max(0, min(0xFF, op[lastop].op.light.c[2]))
					);
				light_source = new_vector(
					op[lastop].op.light.l[0],
					op[lastop].op.light.l[1],
					op[lastop].op.light.l[2]
					);
				break;

				case SHADING:
				if (strcmp(op[i].op.shading.p->name, "GOROUD") == 0) {
					shading = GOROUD;
				}
				else {
					shading = WIRE;
				}
				break;

				case SPHERE:
				add_sphere(
					vlist, elist, flist,
					op[i].op.sphere.d[0],
					op[i].op.sphere.d[1],
					op[i].op.sphere.d[2],
					op[i].op.sphere.r, segments, text0, text1
					);
				transform(vlist, peek(coord_systems));
				if (shading == GOROUD) {
					draw_faces(
						s, vlist, flist, center, eye, distance,
						amb_color, light_color, light_source,
						amb_ref_constant, diff_ref_constant, spec_ref_constant
						);
				}
				else {
					draw_edges(
						s, vlist, elist, center, eye, distance, wire_color
						);
				}
				clear_vlist(vlist);
				clear_elist(elist);
				clear_flist(flist);
				break;

				case BOX:
				add_box(
					vlist, elist, flist,
					op[i].op.box.d0[0],
					op[i].op.box.d0[1],
					op[i].op.box.d0[2],
					op[i].op.box.d1[0],
					op[i].op.box.d1[1],
					op[i].op.box.d1[2],
					text0, text1
					);
				transform(vlist, peek(coord_systems));
				if (shading == GOROUD) {
					draw_faces(
						s, vlist, flist, center, eye, distance,
						amb_color, light_color, light_source,
						amb_ref_constant, diff_ref_constant, spec_ref_constant
						);
				}
				else {
					draw_edges(
						s, vlist, elist, center, eye, distance, wire_color
						);
				}
				clear_vlist(vlist);
				clear_elist(elist);
				clear_flist(flist);
				break;

				case LINE:
				add_line(
					vlist, elist,
					op[i].op.line.p0[0],
					op[i].op.line.p0[1],
					op[i].op.line.p0[2],
					op[i].op.line.p1[0],
					op[i].op.line.p1[1],
					op[i].op.line.p1[2],
					text0, text1
					);
				transform(vlist, peek(coord_systems));
				draw_edges(s, vlist, elist, center, eye, distance, wire_color);
				clear_vlist(vlist);
				clear_elist(elist);
				break;

				case MOVE:
				if (op[i].op.move.p == NULL){
					knob_value = 1;
				}
				else {
					knob_value = op[i].op.move.p->s.value;
				}
				translate(
					op[i].op.move.d[0] * knob_value,
					op[i].op.move.d[1] * knob_value,
					op[i].op.move.d[2] * knob_value,
					peek(coord_systems)
					);
				break;

				case SCALE:
				if (op[i].op.scale.p == NULL){
					knob_value = 1;
				}
				else {
					knob_value = op[i].op.scale.p->s.value;
				}
				scale(
					op[i].op.scale.d[0] * knob_value,
					op[i].op.scale.d[1] * knob_value,
					op[i].op.scale.d[2] * knob_value,
					peek(coord_systems)
					);
				break;

				case ROTATE:
				if (op[i].op.rotate.p == NULL){
					knob_value = 1;
				}
				else {
					knob_value = op[i].op.rotate.p->s.value;
				}
				temp = op[i].op.rotate.axis;
				if (temp == 0) {
					rotate_x(
						op[i].op.rotate.degrees * knob_value,
						peek(coord_systems)
						);
				}
				else if (temp == 1) {
					rotate_y(
						op[i].op.rotate.degrees * knob_value,
						peek(coord_systems)
						);
				}
				else {
					rotate_z(
						op[i].op.rotate.degrees * knob_value,
						peek(coord_systems)
						);
				}
				break;

				case SET:
				set_value(
					lookup_symbol(op[i].op.set.p->name),
					op[i].op.set.val
					);
				break;

				case SETKNOBS:
				for (j = 0; j < lastsym; j++) {
					set_value(&symtab[j], op[j].op.setknobs.value);
				}
				break;

				case PUSH:
				push(coord_systems);
				break;

				case POP:
				pop(coord_systems);
				break;

				case SAVE:
				make_png(op[i].op.save.p->name, s, color_type);
				break;

				case DISPLAY:
				display_png(s, color_type);
				break;
			}
		}
		if (num_frames > 1){
			sprintf(frame_name, "anim/%s%03d.png", name, frame);
			make_png(frame_name, s, color_type);
			clear_screen(s);
			clear_stack(coord_systems);
		}
	}

	free_screen(s);
	free_vlist(vlist);
	free_flist(flist);
	free_elist(elist);
	free(coord_systems);
}
Example #8
0
static void draw_polygon (cairo_t *cr, polygon_t *p, gdouble sf)
{
    draw_edges (cr, p, sf, -1);

    draw_edges (cr, p, sf, +1);
}
Example #9
0
File: npr.c Project: xtmacbook/SGI
void
redraw(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if (show_texture) {
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(-2., 2., -2., 2., -1., 1);
	glBegin(GL_QUADS);
	glTexCoord2f(0.f, 0.f);
	glVertex2f(-1.f, -1.f);
	glTexCoord2f(1.f, 0.f);
	glVertex2f(1.f, -1.f);
	glTexCoord2f(1.f, 1.f);
	glVertex2f(1.f, 1.f);
	glTexCoord2f(0.f, 1.f);
	glVertex2f(-1.f, 1.f);
	glEnd();
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	CHECK_ERROR("OpenGL Error in redraw()");
	glutSwapBuffers();
	return;
    }
    glPushMatrix();				/* assuming modelview */
    glTranslatef(objpos[X], objpos[Y], 0.f);	/* translate object */
    glRotatef(objangle[X], 0.f, 1.f, 0.f);	/* rotate object */
    glRotatef(objangle[Y], 1.f, 0.f, 0.f);

    /*
     * The object 
     */
    glEnable(GL_POLYGON_OFFSET_FILL);
    glPolygonOffset(1.0, 1.0);
    glCallList(1);
    glDisable(GL_POLYGON_OFFSET_FILL);

    /*
     * The edges 
     */
    if (edgelines) {
#if 0
	glDisable(GL_LIGHTING);
	glColor3f(0.0, 0.0, 0.0);
	glLineWidth(2.0);
	glCallList(2);
	if (lighting)
	    glEnable(GL_LIGHTING);
	glColor3f(1.0, 1.0, 1.0);
	glLineWidth(1.0);
#else
	draw_edges();
#endif
    }
    glPopMatrix();		/* assuming modelview */

    CHECK_ERROR("OpenGL Error in redraw()");
    glutSwapBuffers();
}