Exemple #1
0
/* XXX support for separate read/draw buffers hasn't been tested */
static GLboolean gl_ggiSetBuffer(GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit)
{
	ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;

	printf("set read %d\n", bufferBit);
	GGIMESADPRINT_CORE("gl_ggiSetBuffer() called\n");

	if (bufferBit == DD_FRONT_LEFT_BIT) 
	{
		ggiSetReadFrame(ggi_ctx->ggi_visual,
				ggiGetDisplayFrame(ggi_ctx->ggi_visual));
		ggiSetWriteFrame(ggi_ctx->ggi_visual,
				 ggiGetDisplayFrame(ggi_ctx->ggi_visual));
		return GL_TRUE;
	}
	else if (bufferBit == DD_BACK_LEFT_BIT)
	{
		ggiSetReadFrame(ggi_ctx->ggi_visual,
				ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1);
		ggiSetWriteFrame(ggi_ctx->ggi_visual,
				 ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1);
		return GL_TRUE;
	}
	else
		return GL_FALSE;
}
Exemple #2
0
static void animate(ggi_visual_t vis, ggi_mode * mode, int j)
{
	int f, w, h;
	ggi_pixel *buf;
	ggi_color c1, c2;

	c1.r = ((sin((double) j / 100) + 1) * 32768);
	c1.g = ((sin(2.094394 + (double) j / 100) + 1) * 32768);
	c1.b = ((sin(4.188789 + (double) j / 100) + 1) * 32768);
	c1.a = 0;

	c2.r = ((sin(3.141592 + (double) j / 100) + 1) * 32768);
	c2.g = ((sin(5.235986 + (double) j / 100) + 1) * 32768);
	c2.b = ((sin(7.330381 + (double) j / 100) + 1) * 32768);
	c2.a = 0;

	ggiSetGCForeground(vis, ggiMapColor(vis, &c1));
	ggiSetGCBackground(vis, ggiMapColor(vis, &c2));

	w = mode->virt.x / mode->frames;
	h = mode->virt.y / 5;

	buf = malloc(w * h * GT_SIZE(mode->graphtype));
	if (buf == NULL)
		return;

	ggiSetOrigin(vis, j % (mode->virt.x - mode->visible.x + 1),
		     j % (mode->virt.y - mode->visible.y + 1));

	for (f = 0; f < mode->frames; f++) {
		int x, y, yspan;

		x = f * w;
		yspan = mode->virt.y - h;
		y = (j + (yspan * 2 * (f / mode->frames))) % (2 * yspan);
		y += yspan * 2 * f / mode->frames;
		y %= yspan * 2;
		if (y >= yspan)
			y = yspan * 2 - y;
		x += (int)(sin(3.14159264 * 4 * y / yspan) + 1) * (w * 1 / 10);
		ggiSetWriteFrame(vis, f);
		ggiSetReadFrame(vis, (f + 1) % mode->frames);
		animate_one_frame(vis, x, y, w * 4 / 5, h, buf,
				  (x + w * (mode->frames - 1) + w / 2) %
				  mode->virt.x);
	}

	free(buf);
}
Exemple #3
0
/*
 * Swap front/back buffers for current context if double buffered.
 */
void ggiMesaSwapBuffers(void)
{
	GLcontext *ctx;
	ggi_mesa_context_t ggi_ctx;
	ctx = _mesa_get_current_context();
	ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
	
	GGIMESADPRINT_CORE("ggiMesaSwapBuffers() called\n");	
	
	_mesa_notifySwapBuffers(ctx);
	gl_ggiFlush(ctx);

	ggiSetDisplayFrame(ggi_ctx->ggi_visual,
			   !ggiGetDisplayFrame(ggi_ctx->ggi_visual));
	ggiSetWriteFrame(ggi_ctx->ggi_visual,
			 !ggiGetWriteFrame(ggi_ctx->ggi_visual));
	ggiSetReadFrame(ggi_ctx->ggi_visual,
			 !ggiGetReadFrame(ggi_ctx->ggi_visual));

	GGIMESADPRINT_CORE("swap disp: %d, write %d\n",
			   ggiGetDisplayFrame(ggi_ctx->ggi_visual),
			   ggiGetWriteFrame(ggi_ctx->ggi_visual));
}