-/* $Id: svgamesa.c,v 1.8 2000/11/16 21:05:39 keithw Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.3
- * Copyright (C) 1995-2000 Brian Paul
+ * Version: 5.0
+ * Copyright (C) 1995-2002 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#ifdef SVGA
-#ifdef PC_HEADER
-#include "all.h"
-#else
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <vga.h>
#include "GL/svgamesa.h"
+#include "buffers.h"
#include "context.h"
+#include "extensions.h"
+#include "imports.h"
#include "matrix.h"
-#include "types.h"
-#include <string.h>
-#endif
-
+#include "mtypes.h"
+#include "swrast/swrast.h"
#include "svgapix.h"
#include "svgamesa8.h"
#include "svgamesa15.h"
if (!logfile) return;
fprintf(logfile,"%s\n",what);
fclose(logfile);
-}
+}
#endif
/**********************************************************************/
/**********************************************************************/
int SVGAMesaInit( int GraphMode )
-{
+{
vga_init();
if (!vga_hasmode(GraphMode))
{
fprintf(stderr,"GraphMode %d unavailable...",GraphMode);
#ifdef SVGA_DEBUG
SVGAlog("SVGAMesaInit: invalid GraphMode (doesn't exist)");
-#endif
+#endif
return(1);
}
- SVGAInfo=vga_getmodeinfo(GraphMode);
+ SVGAInfo=vga_getmodeinfo(GraphMode);
if (SVGAInfo->flags & IS_MODEX)
{
fprintf(stderr,"ModeX not implemented...");
#ifdef SVGA_DEBUG
SVGAlog("SVGAMesaInit: invalid GraphMode (ModeX)");
-#endif
+#endif
return(2);
}
if (!SVGAInfo->bytesperpixel)
fprintf(stderr,"1 / 4 bit color not implemented...");
#ifdef SVGA_DEBUG
SVGAlog("SVGAMesaInit: invalid GraphMode (1 or 4 bit)");
-#endif
+#endif
return(3);
}
switch (SVGAInfo->colors) {
SVGABuffer.Depth,GraphMode,SVGAInfo->linewidth, \
SVGAInfo->height,SVGABuffer.BufferSize);
SVGAlog(cbuf);
-#endif
+#endif
SVGABuffer.FrontBuffer=(void*)malloc(SVGABuffer.BufferSize + 4);
if (!SVGABuffer.FrontBuffer) {
{
fprintf(stderr,"Not enough RAM for FRONT_LEFT_BUFFER...");
#ifdef SVGA_DEBUG
SVGAlog("SVGAMesaInit: Not enough RAM (front buffer)");
-#endif
+#endif
return(4);
}
- }
+ }
#ifdef SVGA_DEBUG
sprintf(cbuf,"SVGAMesaInit: FrontBuffer - %p",SVGABuffer.FrontBuffer);
SVGAlog(cbuf);
-#endif
+#endif
SVGABuffer.BackBuffer=(void*)malloc(SVGABuffer.BufferSize + 4);
if (!SVGABuffer.BackBuffer) {
{
fprintf(stderr,"Not enough RAM for BACK_LEFT_BUFFER...");
#ifdef SVGA_DEBUG
SVGAlog("SVGAMesaInit: Not enough RAM (back buffer)");
-#endif
+#endif
return(5);
}
- }
+ }
#ifdef SVGA_DEBUG
sprintf(cbuf,"SVGAMesaInit: BackBuffer - %p",SVGABuffer.BackBuffer);
SVGAlog(cbuf);
-#endif
+#endif
vga_setmode(GraphMode);
SVGABuffer.VideoRam=vga_getgraphmem();
SVGABuffer.ReadBuffer = SVGABuffer.BackBuffer;
return 0;
-}
+}
int SVGAMesaClose( void )
-{
- vga_setmode(TEXT);
+{
+ vga_setmode(TEXT);
free(SVGABuffer.FrontBuffer);
free(SVGABuffer.BackBuffer);
return 0;
#ifdef SVGA_DEBUG
sprintf(cbuf,"copy_buffer: copy %p to %p",buffer,SVGABuffer.VideoRam);
SVGAlog(cbuf);
-#endif
+#endif
while(size>0) {
vga_setpage(page++);
- if (size>>16) {
+ if (size>>16) {
memcpy(SVGABuffer.VideoRam,buffer,0x10000);
buffer+=0x10000;
- }else{
+ }else{
memcpy(SVGABuffer.VideoRam,buffer,size & 0xffff);
}
- size-=0xffff;
+ size-=0xffff;
}
}
-static void get_buffer_size( GLcontext *ctx, GLuint *width, GLuint *height )
+static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
*width = SVGAMesa->width = vga_getxdim();
*height = SVGAMesa->height = vga_getydim();
}
-static GLboolean set_draw_buffer( GLcontext *ctx, GLenum buffer )
+/**
+ * We only implement this function as a mechanism to check if the
+ * framebuffer size has changed (and update corresponding state).
+ */
+static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
- if (buffer == GL_FRONT_LEFT) {
- SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer;
-#if 0
- /* vga_waitretrace(); */
- void * tmpptr;
- copy_buffer(SVGABuffer.FrontBuffer);
- tmpptr=SVGABuffer.BackBuffer;
- SVGABuffer.BackBuffer=SVGABuffer.FrontBuffer;
- SVGABuffer.FrontBuffer=tmpptr;
-#endif
- return GL_TRUE;
- }
- else if (buffer == GL_BACK_LEFT) {
- SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer;
-#if 0
- /* vga_waitretrace(); */
- copy_buffer(SVGABuffer.BackBuffer);
-#endif
- return GL_TRUE;
+ GLuint newWidth, newHeight;
+ GLframebuffer *buffer = ctx->WinSysDrawBuffer;
+ get_buffer_size( buffer, &newWidth, &newHeight );
+ if (buffer->Width != newWidth || buffer->Height != newHeight) {
+ _mesa_resize_framebuffer(ctx, buffer, newWidth, newHeight );
}
- else
- return GL_FALSE;
}
-
-static void set_read_buffer( GLcontext *ctx, GLframebuffer *colorBuffer,
- GLenum buffer )
+static void set_buffer( GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLenum buffer )
{
/* We can ignore colorBuffer since we don't support a MakeCurrentRead()
* function.
if (buffer == GL_FRONT_LEFT) {
SVGABuffer.ReadBuffer = SVGABuffer.FrontBuffer;
+ SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer;
#if 0
void * tmpptr;
/* vga_waitretrace(); */
}
else if (buffer == GL_BACK_LEFT) {
SVGABuffer.ReadBuffer = SVGABuffer.BackBuffer;
+ SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer;
#if 0
/* vga_waitretrace(); */
copy_buffer(SVGABuffer.BackBuffer);
/***** *****/
/**********************************************************************/
-static void svgamesa_update_state( GLcontext *ctx )
+static void svgamesa_update_state( GLcontext *ctx, GLuint new_state )
{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
+
/* Initialize all the pointers in the DD struct. Do this whenever */
/* a new context is made current or we change buffers via set_buffer! */
ctx->Driver.UpdateState = svgamesa_update_state;
ctx->Driver.GetBufferSize = get_buffer_size;
- ctx->Driver.SetDrawBuffer = set_draw_buffer;
- ctx->Driver.SetReadBuffer = set_read_buffer;
+ ctx->Driver.Viewport = viewport;
- ctx->Driver.PointsFunc = NULL;
- ctx->Driver.LineFunc = NULL;
- ctx->Driver.TriangleFunc = NULL;
+ /* Fill in the swrast driver interface:
+ */
+ swdd->SetBuffer = set_buffer;
switch (SVGABuffer.Depth) {
case 8: ctx->Driver.ClearIndex = __clear_index8;
ctx->Driver.Clear = __clear8;
- ctx->Driver.ReadCI32Span = __read_ci32_span8;
- ctx->Driver.ReadCI32Pixels = __read_ci32_pixels8;
- ctx->Driver.WriteCI8Span = __write_ci8_span8;
- ctx->Driver.WriteCI32Span = __write_ci32_span8;
- ctx->Driver.WriteCI32Pixels = __write_ci32_pixels8;
- ctx->Driver.WriteMonoCISpan = __write_mono_ci_span8;
- ctx->Driver.WriteMonoCIPixels = __write_mono_ci_pixels8;
+ swdd->ReadCI32Span = __read_ci32_span8;
+ swdd->ReadCI32Pixels = __read_ci32_pixels8;
+ swdd->WriteCI8Span = __write_ci8_span8;
+ swdd->WriteCI32Span = __write_ci32_span8;
+ swdd->WriteCI32Pixels = __write_ci32_pixels8;
+ swdd->WriteMonoCISpan = __write_mono_ci_span8;
+ swdd->WriteMonoCIPixels = __write_mono_ci_pixels8;
#ifdef SVGA_DEBUG
SVGAlog("SVGAUpdateState: 8 bit mode.");
-#endif
+#endif
break;
case 15: ctx->Driver.ClearColor = __clear_color15;
ctx->Driver.Clear = __clear15;
- ctx->Driver.ReadRGBASpan = __read_rgba_span15;
- ctx->Driver.ReadRGBAPixels = __read_rgba_pixels15;
- ctx->Driver.WriteRGBASpan = __write_rgba_span15;
- ctx->Driver.WriteRGBAPixels = __write_rgba_pixels15;
- ctx->Driver.WriteMonoRGBASpan = __write_mono_rgba_span15;
- ctx->Driver.WriteMonoRGBAPixels = __write_mono_rgba_pixels15;
+ swdd->ReadRGBASpan = __read_rgba_span15;
+ swdd->ReadRGBAPixels = __read_rgba_pixels15;
+ swdd->WriteRGBASpan = __write_rgba_span15;
+ swdd->WriteRGBAPixels = __write_rgba_pixels15;
+ swdd->WriteMonoRGBASpan = __write_mono_rgba_span15;
+ swdd->WriteMonoRGBAPixels = __write_mono_rgba_pixels15;
#ifdef SVGA_DEBUG
SVGAlog("SVGAUpdateState: 15 bit mode.");
-#endif
+#endif
break;
case 16: ctx->Driver.ClearColor = __clear_color16;
ctx->Driver.Clear = __clear16;
- ctx->Driver.ReadRGBASpan = __read_rgba_span16;
- ctx->Driver.ReadRGBAPixels = __read_rgba_pixels16;
- ctx->Driver.WriteRGBASpan = __write_rgba_span16;
- ctx->Driver.WriteRGBAPixels = __write_rgba_pixels16;
- ctx->Driver.WriteMonoRGBASpan = __write_mono_rgba_span16;
- ctx->Driver.WriteMonoRGBAPixels = __write_mono_rgba_pixels16;
+ swdd->ReadRGBASpan = __read_rgba_span16;
+ swdd->ReadRGBAPixels = __read_rgba_pixels16;
+ swdd->WriteRGBASpan = __write_rgba_span16;
+ swdd->WriteRGBAPixels = __write_rgba_pixels16;
+ swdd->WriteMonoRGBASpan = __write_mono_rgba_span16;
+ swdd->WriteMonoRGBAPixels = __write_mono_rgba_pixels16;
break;
#ifdef SVGA_DEBUG
SVGAlog("SVGAUpdateState: 16 bit mode.");
-#endif
+#endif
case 24: ctx->Driver.ClearColor = __clear_color24;
ctx->Driver.Clear = __clear24;
- ctx->Driver.ReadRGBASpan = __read_rgba_span24;
- ctx->Driver.ReadRGBAPixels = __read_rgba_pixels24;
- ctx->Driver.WriteRGBASpan = __write_rgba_span24;
- ctx->Driver.WriteRGBAPixels = __write_rgba_pixels24;
- ctx->Driver.WriteMonoRGBASpan = __write_mono_rgba_span24;
- ctx->Driver.WriteMonoRGBAPixels = __write_mono_rgba_pixels24;
+ swdd->ReadRGBASpan = __read_rgba_span24;
+ swdd->ReadRGBAPixels = __read_rgba_pixels24;
+ swdd->WriteRGBASpan = __write_rgba_span24;
+ swdd->WriteRGBAPixels = __write_rgba_pixels24;
+ swdd->WriteMonoRGBASpan = __write_mono_rgba_span24;
+ swdd->WriteMonoRGBAPixels = __write_mono_rgba_pixels24;
break;
#ifdef SVGA_DEBUG
SVGAlog("SVGAUpdateState: 32 bit mode.");
-#endif
+#endif
case 32: ctx->Driver.ClearColor = __clear_color32;
ctx->Driver.Clear = __clear32;
- ctx->Driver.ReadRGBASpan = __read_rgba_span32;
- ctx->Driver.ReadRGBAPixels = __read_rgba_pixels32;
- ctx->Driver.WriteRGBASpan = __write_rgba_span32;
- ctx->Driver.WriteRGBAPixels = __write_rgba_pixels32;
- ctx->Driver.WriteMonoRGBASpan = __write_mono_rgba_span32;
- ctx->Driver.WriteMonoRGBAPixels = __write_mono_rgba_pixels32;
- }
+ swdd->ReadRGBASpan = __read_rgba_span32;
+ swdd->ReadRGBAPixels = __read_rgba_pixels32;
+ swdd->WriteRGBASpan = __write_rgba_span32;
+ swdd->WriteRGBAPixels = __write_rgba_pixels32;
+ swdd->WriteMonoRGBASpan = __write_mono_rgba_span32;
+ swdd->WriteMonoRGBAPixels = __write_mono_rgba_pixels32;
+ }
}
/*
GLfloat redscale, greenscale, bluescale, alphascale;
GLint index_bits;
GLint redbits, greenbits, bluebits, alphabits;
+
/* determine if we're in RGB or color index mode */
if ((SVGABuffer.Depth==32) || (SVGABuffer.Depth==24)) {
rgb_flag = GL_TRUE;
ctx->gl_ctx = _mesa_create_context( ctx->gl_vis,
NULL, /* share list context */
- (void *) ctx, GL_TRUE );
+ (void *) ctx, GL_FALSE );
+
+ _mesa_enable_sw_extensions(ctx->gl_ctx);
+ _mesa_enable_1_3_extensions(ctx->gl_ctx);
+
+ _mesa_init_driver_functions(&ctx->Driver);
ctx->gl_buffer = _mesa_create_framebuffer( ctx->gl_vis,
- ctx->gl_vis->DepthBits > 0,
- ctx->gl_vis->StencilBits > 0,
- ctx->gl_vis->AccumRedBits > 0,
- ctx->gl_vis->AlphaBits > 0 );
+ ctx->gl_vis->depthBits > 0,
+ ctx->gl_vis->stencilBits > 0,
+ ctx->gl_vis->accumRedBits > 0,
+ ctx->gl_vis->alphaBits > 0 );
ctx->width = ctx->height = 0; /* temporary until first "make-current" */
#endif
if (ctx) {
_mesa_destroy_visual( ctx->gl_vis );
_mesa_destroy_context( ctx->gl_ctx );
- _mesa_destroy_framebuffer( ctx->gl_buffer );
free( ctx );
if (ctx==SVGAMesa) {
SVGAMesa = NULL;
{
#ifndef DEV
SVGAMesa = ctx;
- svgamesa_update_state( ctx->gl_ctx );
+ svgamesa_update_state( ctx->gl_ctx, ~0 );
_mesa_make_current( ctx->gl_ctx, ctx->gl_buffer );
if (ctx->width==0 || ctx->height==0) {
- /* setup initial viewport */
ctx->width = vga_getxdim();
ctx->height = vga_getydim();
- gl_Viewport( ctx->gl_ctx, 0, 0, ctx->width, ctx->height );
}
#endif
}
copy_buffer(SVGABuffer.BackBuffer);
#ifndef DEV
- _mesa_swapbuffers( SVGAMesa->gl_ctx );
- if (SVGAMesa->gl_vis->DBflag)
-#endif /* DEV */
+ _mesa_notifySwapBuffers( SVGAMesa->gl_ctx );
+ if (SVGAMesa->gl_vis->doubleBufferMode)
+#endif /* DEV */
{
#ifdef SVGA_DEBUG
sprintf(cbuf,"SVGAMesaSwapBuffers : Swapping...");
* Need this to provide at least one external definition when SVGA is
* not defined on the compiler command line.
*/
-
+extern int gl_svga_dummy_function(void);
int gl_svga_dummy_function(void)
{
return 0;