coverity check bug fix going over end of array
[mesa.git] / src / mesa / drivers / svga / svgamesa.c
index 4581517678b3bf85aa4a0a287f0e04b7d15a5af0..09330e78ab535f71c3cbe1c3bd53722f1be1bd69 100644 (file)
@@ -1,9 +1,9 @@
-/* $Id: svgamesa.c,v 1.21 2002/10/14 17:08:27 brianp Exp $ */
+/* $Id: svgamesa.c,v 1.26 2005/09/07 23:26:01 brianp 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 "mtypes.h"
 #include "swrast/swrast.h"
-#endif
-
 #include "svgapix.h"
 #include "svgamesa8.h"
 #include "svgamesa15.h"
@@ -217,6 +213,11 @@ static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *heigh
    *height = SVGAMesa->height = vga_getydim();
 }
 
+static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+   /* poll for window size change and realloc software Z/stencil/etc if needed */
+   _mesa_ResizeBuffersMESA();
+}
 
 static void set_buffer( GLcontext *ctx, GLframebuffer *colorBuffer,
                         GLenum buffer )
@@ -262,16 +263,7 @@ static void svgamesa_update_state( GLcontext *ctx, GLuint new_state )
    ctx->Driver.UpdateState = svgamesa_update_state;
 
    ctx->Driver.GetBufferSize = get_buffer_size;
-   ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
-
-   /* Software rasterizer pixel paths:
-    */
-   ctx->Driver.Accum = _swrast_Accum;
-   ctx->Driver.Bitmap = _swrast_Bitmap;
-   ctx->Driver.CopyPixels = _swrast_CopyPixels;
-   ctx->Driver.DrawPixels = _swrast_DrawPixels;
-   ctx->Driver.ReadPixels = _swrast_ReadPixels;
-   ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
+   ctx->Driver.Viewport = viewport;
 
    /* Fill in the swrast driver interface:
     */
@@ -355,7 +347,6 @@ SVGAMesaContext SVGAMesaCreateContext( GLboolean doubleBuffer )
    GLfloat redscale, greenscale, bluescale, alphascale;
    GLint index_bits;
    GLint redbits, greenbits, bluebits, alphabits;
-   __GLimports imports;
 
    /* determine if we're in RGB or color index mode */
    if ((SVGABuffer.Depth==32) || (SVGABuffer.Depth==24)) {
@@ -405,14 +396,15 @@ SVGAMesaContext SVGAMesaCreateContext( GLboolean doubleBuffer )
                                       1     /* samples */
                                       );
 
-   _mesa_init_default_imports( &imports, (void *) ctx);
    ctx->gl_ctx = _mesa_create_context( ctx->gl_vis,
                                        NULL,  /* share list context */
-                                       &imports );
+                                       (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,
@@ -453,10 +445,8 @@ void SVGAMesaMakeCurrent( SVGAMesaContext ctx )
    _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();
-      _mesa_set_viewport( ctx->gl_ctx, 0, 0, ctx->width, ctx->height );
    }
 #endif
 }
@@ -510,7 +500,7 @@ void SVGAMesaSwapBuffers( void )
  * 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;