//---------------------------------------------------------
void CGrid_3D_Image::_Set_Grid(void)
{
	T3DPoint	*a, *b, *c, *d, p[3];

	//-----------------------------------------------------
	a	= (T3DPoint *)SG_Malloc(sizeof(T3DPoint) *  Get_NX());
	b	= (T3DPoint *)SG_Malloc(sizeof(T3DPoint) *  Get_NX());
	c	= (T3DPoint *)SG_Malloc(sizeof(T3DPoint) * (Get_NX() - 1));

	//-----------------------------------------------------
	_Get_Line(0, b);

	for(int y=1; y<Get_NY() && Set_Progress(y); y++)
	{
		d	= a;
		a	= b;
		b	= d;

		_Get_Line(y, b);
		_Get_Line(a, b, c);

		for(int ax=0, bx=1; bx<Get_NX(); ax++, bx++)
		{
			DRAW_TRIANGLE(a[ax], a[bx], c[ax]);
			DRAW_TRIANGLE(b[ax], b[bx], c[ax]);
			DRAW_TRIANGLE(a[ax], b[ax], c[ax]);
			DRAW_TRIANGLE(a[bx], b[bx], c[ax]);
		}
	}

	//-----------------------------------------------------
	SG_Free(a);
	SG_Free(b);
	SG_Free(c);

	//-----------------------------------------------------
	DataObject_Add(m_pRGB_Z);
	DataObject_Add(m_pRGB);
	DataObject_Set_Colors(m_pRGB, 100, SG_COLORS_BLACK_WHITE);
}
Example #2
0
File: sdl.c Project: 0xheart0/xbmc
void display() {
	int i, wm;
	float size = 5;

	if (!can_render())
		return;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	if (render_mode == IR) {
		/* draw the IR stuff */

		glDisable(GL_LIGHTING);

		glBegin(GL_TRIANGLES);
			/* green center */
			glColor3f(0.0, 1.0, 0.0);
			DRAW_TRIANGLE(width/2, height/2, 0, size);
		glEnd();

		for (wm = 0; wm < MAX_WIIMOTES; ++wm) {
			glBegin(GL_TRIANGLES);
				/* red ir */
				glColor3f(1.0, 0.0, 0.0);
				for (i = 0; i < 4; ++i) {
					if (wiimotes[wm]->ir.dot[i].visible)
						DRAW_TRIANGLE(wiimotes[wm]->ir.dot[i].rx, wiimotes[wm]->ir.dot[i].ry, 0, size);
				}

				/* yellow corrected ir */
				glColor3f(1.0, 1.0, 0.0);
				for (i = 0; i < 4; ++i) {
					if (wiimotes[wm]->ir.dot[i].visible)
						DRAW_TRIANGLE(wiimotes[wm]->ir.dot[i].x, wiimotes[wm]->ir.dot[i].y, 0, size);
				}

				/* blue cursor */
				glColor3f(0.0, 0.0, 1.0);
				DRAW_TRIANGLE(wiimotes[wm]->ir.x, wiimotes[wm]->ir.y-size, 0, size);
			glEnd();
		}
	} else {
		/* draw the teapot */
		gluLookAt(0.0, 0.0, -5.0,
				  0.0, 0.0, 0.0,
				  0.0, 1.0, 0.0);

		glEnable(GL_LIGHTING);
		glEnable(GL_LIGHT0);
		update_light(GL_LIGHT0, &light);
		set_material(&red_plastic);

		glRotatef(wiimotes[0]->orient.roll, 0.0f, 0.0f, 1.0f);
		glRotatef(wiimotes[0]->orient.pitch, 1.0f, 0.0f, 0.0f);


		glutSolidTeapot(1);
	}

	SDL_GL_SwapBuffers();
}