i965: Pass brw_compile pointer to brw_set_src[01].
[mesa.git] / src / mesa / drivers / osmesa / osmesa.c
index 043262910e436ecd4dcf260e5a218fe92348248f..68d711446428b76f0da5554f60ea48c3535ffd25 100644 (file)
 
 
 /**
- * OSMesa rendering context, derived from core Mesa GLcontext.
+ * OSMesa rendering context, derived from core Mesa struct gl_context.
  */
 struct osmesa_context
 {
-   GLcontext mesa;             /*< Base class - this must be first */
-   GLvisual *gl_visual;                /*< Describes the buffers */
+   struct gl_context mesa;             /*< Base class - this must be first */
+   struct gl_config *gl_visual;                /*< Describes the buffers */
    struct gl_renderbuffer *rb;  /*< The user's colorbuffer */
-   GLframebuffer *gl_buffer;   /*< The framebuffer, containing user's rb */
+   struct gl_framebuffer *gl_buffer;   /*< The framebuffer, containing user's rb */
    GLenum format;              /*< User-specified context format */
    GLint userRowLength;                /*< user-specified number of pixels per row */
    GLint rInd, gInd, bInd, aInd;/*< index offsets for RGBA formats */
@@ -75,7 +75,7 @@ struct osmesa_context
 
 
 static INLINE OSMesaContext
-OSMESA_CONTEXT(GLcontext *ctx)
+OSMESA_CONTEXT(struct gl_context *ctx)
 {
    /* Just cast, since we're using structure containment */
    return (OSMesaContext) ctx;
@@ -88,7 +88,7 @@ OSMESA_CONTEXT(GLcontext *ctx)
 
 
 static const GLubyte *
-get_string( GLcontext *ctx, GLenum name )
+get_string( struct gl_context *ctx, GLenum name )
 {
    (void) ctx;
    switch (name) {
@@ -107,7 +107,7 @@ get_string( GLcontext *ctx, GLenum name )
 
 
 static void
-osmesa_update_state( GLcontext *ctx, GLuint new_state )
+osmesa_update_state( struct gl_context *ctx, GLuint new_state )
 {
    /* easy - just propogate */
    _swrast_InvalidateState( ctx, new_state );
@@ -515,11 +515,7 @@ do {                                                               \
    PACK_RGBA(p, color[0], color[1], color[2], color[3]);       \
 } while (0)
 
-#ifdef WIN32
-#include "..\swrast\s_linetemp.h"
-#else
 #include "swrast/s_linetemp.h"
-#endif
 
 
 
@@ -544,11 +540,7 @@ do {                                                       \
    }                                                   \
 } while (0)
 
-#ifdef WIN32
-#include "..\swrast\s_linetemp.h"
-#else
 #include "swrast/s_linetemp.h"
-#endif
 
 
 
@@ -557,7 +549,7 @@ do {                                                        \
  * function.  Otherwise, return NULL.
  */
 static swrast_line_func
-osmesa_choose_line_function( GLcontext *ctx )
+osmesa_choose_line_function( struct gl_context *ctx )
 {
    const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
    const SWcontext *swrast = SWRAST_CONTEXT(ctx);
@@ -624,11 +616,7 @@ osmesa_choose_line_function( GLcontext *ctx )
       span.z += span.zStep;                                    \
    }                                                            \
 }
-#ifdef WIN32
-#include "..\swrast\s_tritemp.h"
-#else
 #include "swrast/s_tritemp.h"
-#endif
 
 
 
@@ -656,11 +644,8 @@ osmesa_choose_line_function( GLcontext *ctx )
       span.z += span.zStep;                            \
    }                                                    \
 }
-#ifdef WIN32
-#include "..\swrast\s_tritemp.h"
-#else
+
 #include "swrast/s_tritemp.h"
-#endif
 
 
 
@@ -668,7 +653,7 @@ osmesa_choose_line_function( GLcontext *ctx )
  * Return pointer to an optimized triangle function if possible.
  */
 static swrast_tri_func
-osmesa_choose_triangle_function( GLcontext *ctx )
+osmesa_choose_triangle_function( struct gl_context *ctx )
 {
    const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
    const SWcontext *swrast = SWRAST_CONTEXT(ctx);
@@ -708,7 +693,7 @@ osmesa_choose_triangle_function( GLcontext *ctx )
  * standard swrast functions.
  */
 static void
-osmesa_choose_triangle( GLcontext *ctx )
+osmesa_choose_triangle( struct gl_context *ctx )
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
 
@@ -718,7 +703,7 @@ osmesa_choose_triangle( GLcontext *ctx )
 }
 
 static void
-osmesa_choose_line( GLcontext *ctx )
+osmesa_choose_line( struct gl_context *ctx )
 {
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
 
@@ -806,7 +791,7 @@ osmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
  * Just set up all the gl_renderbuffer methods.
  */
 static GLboolean
-osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+osmesa_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb,
                             GLenum internalFormat, GLuint width, GLuint height)
 {
    const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
@@ -994,7 +979,7 @@ osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
  * Allocate a new renderbuffer to describe the user-provided color buffer.
  */
 static struct gl_renderbuffer *
-new_osmesa_renderbuffer(GLcontext *ctx, GLenum format, GLenum type)
+new_osmesa_renderbuffer(struct gl_context *ctx, GLenum format, GLenum type)
 {
    const GLuint name = 0;
    struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name);
@@ -1009,7 +994,7 @@ new_osmesa_renderbuffer(GLcontext *ctx, GLenum format, GLenum type)
          rb->Format = MESA_FORMAT_RGBA8888;
          break;
       case GL_UNSIGNED_SHORT:
-         rb->Format = MESA_FORMAT_SIGNED_RGBA_16;
+         rb->Format = MESA_FORMAT_RGBA_16;
          break;
       case GL_FLOAT:
          rb->Format = MESA_FORMAT_RGBA_FLOAT32;
@@ -1155,9 +1140,10 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
       functions.GetBufferSize = NULL;
 
       if (!_mesa_initialize_context(&osmesa->mesa,
+                                    API_OPENGL,
                                     osmesa->gl_visual,
                                     sharelist ? &sharelist->mesa
-                                              : (GLcontext *) NULL,
+                                              : (struct gl_context *) NULL,
                                     &functions, (void *) osmesa)) {
          _mesa_destroy_visual( osmesa->gl_visual );
          free(osmesa);
@@ -1202,7 +1188,7 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
 
       /* Initialize the software rasterizer and helper modules. */
       {
-        GLcontext *ctx = &osmesa->mesa;
+        struct gl_context *ctx = &osmesa->mesa;
          SWcontext *swrast;
          TNLcontext *tnl;
 
@@ -1327,9 +1313,12 @@ OSMesaMakeCurrent( OSMesaContext osmesa, void *buffer, GLenum type,
     * that converts rendering from CHAN_BITS to the user-requested channel
     * size.
     */
-   osmesa->rb = new_osmesa_renderbuffer(&osmesa->mesa, osmesa->format, type);
-   _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT, osmesa->rb);
-   assert(osmesa->rb->RefCount == 2);
+   if (!osmesa->rb) {
+      osmesa->rb = new_osmesa_renderbuffer(&osmesa->mesa, osmesa->format, type);
+      _mesa_remove_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT);
+      _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT, osmesa->rb);
+      assert(osmesa->rb->RefCount == 2);
+   }
 
    /* Set renderbuffer fields.  Set width/height = 0 to force 
     * osmesa_renderbuffer_storage() being called by _mesa_resize_framebuffer()
@@ -1353,7 +1342,7 @@ OSMesaMakeCurrent( OSMesaContext osmesa, void *buffer, GLenum type,
 
 
    /* this updates the visual's red/green/blue/alphaBits fields */
-   _mesa_update_framebuffer_visual(osmesa->gl_buffer);
+   _mesa_update_framebuffer_visual(&osmesa->mesa, osmesa->gl_buffer);
 
    /* update the framebuffer size */
    _mesa_resize_framebuffer(&osmesa->mesa, osmesa->gl_buffer, width, height);
@@ -1366,7 +1355,7 @@ OSMesaMakeCurrent( OSMesaContext osmesa, void *buffer, GLenum type,
 GLAPI OSMesaContext GLAPIENTRY
 OSMesaGetCurrentContext( void )
 {
-   GLcontext *ctx = _mesa_get_current_context();
+   struct gl_context *ctx = _mesa_get_current_context();
    if (ctx)
       return (OSMesaContext) ctx;
    else