Ejemplo n.º 1
0
int flush_dma() {
	dma_data.count = pbuf - dma_data.virt_base;

	if(version == 1) {
		// Start the DMA transfer
		while(EVAL_CONTROL(DMACount) != 0) ;
		LOAD_CONTROL(DMAAddress, glint_board.dmagob[dma_num].phys_base);
		LOAD_CONTROL(DMACount, dma_data.count);

		// Switch to the other DMA buffer
		dma_num = (dma_num == 0)?1:0;
		pbuf = dma_data.virt_base =
			glint_board.dmagob[dma_num].virt_base;
	} else {
		// Start the DMA transfer and get the new virtual base
		ioctl(fd, START_DMA, &dma_data);
		pbuf = dma_data.virt_base;
	}
	return GRAPH3D_OK;
}
Ejemplo n.º 2
0
int draw_color_tri(
	int x1, int y1, GraphicsColor c1,
	int x2, int y2, GraphicsColor c2,
	int x3, int y3, GraphicsColor c3) {

	int c;
	int drdy, dgdy, dbdy;
	int drdx, dgdx, dbdx;

	c1.r <<= 15; c2.r <<= 15; c3.r <<= 15;
	c1.g <<= 15; c2.g <<= 15; c3.g <<= 15;
	c1.b <<= 15; c2.b <<= 15; c3.b <<= 15;

	c = abs((x1 - x3)*(y2-y3) - (x2-x3)*(y1-y3));
	drdy = (c3.r-c1.r)/(y3-y1);
	dgdy = (c3.g-c1.g)/(y3-y1);
	dbdy = (c3.b-c1.b)/(y3-y1);

	// Without these casts, we can run into overflow problems
	drdx = ((long long)(c1.r - c3.r)*(y2-y3)/c) -
	       ((long long)(c2.r-c3.r)*(y1-y3)/c);
	dgdx = ((long long)(c1.g - c3.g)*(y2-y3)/c) -
	       ((long long)(c2.g-c3.g)*(y1-y3)/c);
	dbdx = ((long long)(c1.b - c3.b)*(y2-y3)/c) -
	       ((long long)(c2.b-c3.b)*(y1-y3)/c);

	// Set up color
	printf("%d\n%d %d %d\n", c, c1.r, c1.g, c1.b);
	printf("%lld %lld %lld\n%d %d %d\n", drdx, dgdx, dbdx, drdy, dgdy, dbdy);
	LOAD_CONTROL(RStart, c1.r);
	LOAD_CONTROL(GStart, c1.g);
	LOAD_CONTROL(BStart, c1.b);
	LOAD_CONTROL(dRdyDom, drdy);
	LOAD_CONTROL(dGdyDom, dgdy);
	LOAD_CONTROL(dBdyDom, dbdy);
	LOAD_CONTROL(dRdx, drdx);
	LOAD_CONTROL(dGdx, dgdx);
	LOAD_CONTROL(dBdx, dbdx);

	// Set up the top half of the triangle
	LOAD_CONTROL(StartXDom, x1 << 16);
	LOAD_CONTROL(dXDom, ((x3 - x1)<<16) / (y3 - y1));
	LOAD_CONTROL(StartXSub, x1 << 16);
	LOAD_CONTROL(dXSub, ((x2 - x1)<<16) / (y2 - y1));
	LOAD_CONTROL(StartY, y1 << 16);
	LOAD_CONTROL(dY, 1 << 16);
	LOAD_CONTROL(Count, abs(y2 - y1));
	LOAD_CONTROL(Render, RENDER_TRAPEZOID_SPC);

	// Draw the second half of the triangle
	LOAD_CONTROL(StartXSub, x2 << 16);
	LOAD_CONTROL(dXSub, ((x3 - x2)<<16) / (y3 - y2));
	LOAD_CONTROL(ContinueNewSub, abs(y3 - y2));

	return GRAPHICS_OK;
}
Ejemplo n.º 3
0
int draw_rect(int x1, int y1, int x2, int y2) {
	// Set up constant color
	LOAD_CONTROL(RStart, gp.draw_color.r);
	LOAD_CONTROL(GStart, gp.draw_color.g);
	LOAD_CONTROL(BStart, gp.draw_color.b);
	// LOAD_CONTROL(AStart, 0);
	LOAD_CONTROL(dRdx, 0);
	LOAD_CONTROL(dGdx, 0);
	LOAD_CONTROL(dBdx, 0);
	// LOAD_CONTROL(dAdx, 0);
	LOAD_CONTROL(dRdyDom, 0);
	LOAD_CONTROL(dGdyDom, 0);
	LOAD_CONTROL(dBdyDom, 0);
	// LOAD_CONTROL(dAdyDom, 0);

	LOAD_CONTROL(StartXDom, x1 << 16);
	LOAD_CONTROL(StartXSub, x2 << 16);
	LOAD_CONTROL(dXDom, 0);
	LOAD_CONTROL(dXSub, 0);
	LOAD_CONTROL(Count, y2 - y1);
	LOAD_CONTROL(YStart, y1 << 16);
	LOAD_CONTROL(dY, 1 << 16);
	LOAD_CONTROL(Render, RENDER_TRAPEZOID_SPC);

	return GRAPHICS_OK;
}