-/* $Id: osmesa.c,v 1.79 2002/04/19 14:05:51 brianp Exp $ */
+/* $Id: osmesa.c,v 1.93 2002/10/24 23:57:23 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "colormac.h"
#include "depth.h"
#include "extensions.h"
+#include "imports.h"
#include "macros.h"
#include "matrix.h"
-#include "mem.h"
#include "mmath.h"
#include "mtypes.h"
#include "texformat.h"
osmesa->gl_visual,
sharelist ? &sharelist->gl_ctx
: (GLcontext *) NULL,
- (void *) osmesa, GL_TRUE )) {
+ (void *) osmesa,
+ GL_FALSE)) {
_mesa_destroy_visual( osmesa->gl_visual );
FREE(osmesa);
return NULL;
_mesa_enable_sw_extensions(&(osmesa->gl_ctx));
_mesa_enable_1_3_extensions(&(osmesa->gl_ctx));
+ /*_mesa_enable_1_4_extensions(&(osmesa->gl_ctx));*/
osmesa->gl_buffer = _mesa_create_framebuffer( osmesa->gl_visual,
(GLboolean) ( osmesa->gl_visual->depthBits > 0 ),
_mesa_ResizeBuffersMESA();
}
+ /* Added by Gerk Huisma: */
+ _tnl_MakeCurrent( &ctx->gl_ctx, ctx->gl_ctx.DrawBuffer,
+ ctx->gl_ctx.ReadBuffer );
+
return GL_TRUE;
}
* Useful macros:
*/
+#if CHAN_TYPE == GL_FLOAT
+#define PACK_RGBA(DST, R, G, B, A) \
+do { \
+ (DST)[0] = MAX2( R, 0.0F ); \
+ (DST)[1] = MAX2( G, 0.0F ); \
+ (DST)[2] = MAX2( B, 0.0F ); \
+ (DST)[3] = CLAMP(A, 0.0F, CHAN_MAXF);\
+} while (0)
+#else
#define PACK_RGBA(DST, R, G, B, A) \
do { \
(DST)[osmesa->rInd] = R; \
(DST)[osmesa->bInd] = B; \
(DST)[osmesa->aInd] = A; \
} while (0)
+#endif
#define PACK_RGB(DST, R, G, B) \
do { \
-static GLboolean set_draw_buffer( GLcontext *ctx, GLenum mode )
-{
- (void) ctx;
- if (mode==GL_FRONT_LEFT) {
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
-}
-
-
-static void set_read_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode )
+static void set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
{
/* separate read buffer not supported */
ASSERT(buffer == ctx->DrawBuffer);
- ASSERT(mode == GL_FRONT_LEFT);
+ ASSERT(bufferBit == FRONT_LEFT_BIT);
}
}
}
else if (osmesa->format == OSMESA_RGB) {
- const GLchan r = ctx->Color.ClearColor[0];
- const GLchan g = ctx->Color.ClearColor[1];
- const GLchan b = ctx->Color.ClearColor[2];
+ GLchan r, g, b;
+ CLAMPED_FLOAT_TO_CHAN(r, ctx->Color.ClearColor[0]);
+ CLAMPED_FLOAT_TO_CHAN(g, ctx->Color.ClearColor[1]);
+ CLAMPED_FLOAT_TO_CHAN(b, ctx->Color.ClearColor[2]);
if (all) {
/* Clear whole RGB buffer */
GLuint n = osmesa->rowlength * osmesa->height;
}
}
else if (osmesa->format == OSMESA_BGR) {
- const GLchan r = ctx->Color.ClearColor[0];
- const GLchan g = ctx->Color.ClearColor[1];
- const GLchan b = ctx->Color.ClearColor[2];
+ GLchan r, g, b;
+ CLAMPED_FLOAT_TO_CHAN(r, ctx->Color.ClearColor[0]);
+ CLAMPED_FLOAT_TO_CHAN(g, ctx->Color.ClearColor[1]);
+ CLAMPED_FLOAT_TO_CHAN(b, ctx->Color.ClearColor[2]);
if (all) {
/* Clear whole RGB buffer */
const GLint n = osmesa->rowlength * osmesa->height;
}
}
else if (osmesa->format == OSMESA_RGB_565) {
- const GLchan r = ctx->Color.ClearColor[0];
- const GLchan g = ctx->Color.ClearColor[1];
- const GLchan b = ctx->Color.ClearColor[2];
GLushort clearPixel;
+ GLchan r, g, b;
+ CLAMPED_FLOAT_TO_CHAN(r, ctx->Color.ClearColor[0]);
+ CLAMPED_FLOAT_TO_CHAN(g, ctx->Color.ClearColor[1]);
+ CLAMPED_FLOAT_TO_CHAN(b, ctx->Color.ClearColor[2]);
PACK_RGB_565(clearPixel, r, g, b);
if (all) {
/* Clear whole RGB buffer */
/* 4-byte pixel value */
GLuint clearPixel;
GLchan *clr = (GLchan *) &clearPixel;
- clr[osmesa->rInd] = ctx->Color.ClearColor[0];
- clr[osmesa->gInd] = ctx->Color.ClearColor[1];
- clr[osmesa->bInd] = ctx->Color.ClearColor[2];
- clr[osmesa->aInd] = ctx->Color.ClearColor[3];
+ CLAMPED_FLOAT_TO_CHAN(clr[osmesa->rInd], ctx->Color.ClearColor[0]);
+ CLAMPED_FLOAT_TO_CHAN(clr[osmesa->gInd], ctx->Color.ClearColor[1]);
+ CLAMPED_FLOAT_TO_CHAN(clr[osmesa->bInd], ctx->Color.ClearColor[2]);
+ CLAMPED_FLOAT_TO_CHAN(clr[osmesa->aInd], ctx->Color.ClearColor[3]);
if (all) {
/* Clear whole RGBA buffer */
const GLuint n = osmesa->rowlength * osmesa->height;
}
}
#else
- const GLchan r = ctx->Color.ClearColor[0];
- const GLchan g = ctx->Color.ClearColor[1];
- const GLchan b = ctx->Color.ClearColor[2];
- const GLchan a = ctx->Color.ClearColor[3];
+ GLchan r, g, b, a;
+ CLAMPED_FLOAT_TO_CHAN(r, ctx->Color.ClearColor[0]);
+ CLAMPED_FLOAT_TO_CHAN(g, ctx->Color.ClearColor[1]);
+ CLAMPED_FLOAT_TO_CHAN(b, ctx->Color.ClearColor[2]);
+ CLAMPED_FLOAT_TO_CHAN(a, ctx->Color.ClearColor[3]);
if (all) {
/* Clear whole RGBA buffer */
const GLuint n = osmesa->rowlength * osmesa->height;
if (CHAN_BITS != 8) return NULL;
if (ctx->RenderMode != GL_RENDER) return NULL;
if (ctx->Line.SmoothFlag) return NULL;
- if (ctx->Texture._ReallyEnabled) return NULL;
+ if (ctx->Texture._EnabledUnits) return NULL;
if (ctx->Light.ShadeModel != GL_FLAT) return NULL;
if (ctx->Line.Width != 1.0F) return NULL;
if (ctx->Line.StippleFlag) return NULL;
const SWvertex *v2 )
{
const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
-
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define RENDER_SPAN( span ) \
GLuint i; \
- GLchan *img = PIXELADDR4(span->x, span->y); \
- for (i = 0; i < span->end; i++, img += 4) { \
- const GLdepth z = FixedToDepth(span->z); \
+ GLchan *img = PIXELADDR4(span.x, span.y); \
+ for (i = 0; i < span.end; i++, img += 4) { \
+ const GLdepth z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
- PACK_RGBA(img, FixedToChan(span->red), \
- FixedToChan(span->green), FixedToChan(span->blue), \
- FixedToChan(span->alpha)); \
+ PACK_RGBA(img, FixedToChan(span.red), \
+ FixedToChan(span.green), FixedToChan(span.blue), \
+ FixedToChan(span.alpha)); \
zRow[i] = z; \
} \
- span->red += span->redStep; \
- span->green += span->greenStep; \
- span->blue += span->blueStep; \
- span->alpha += span->alphaStep; \
- span->z += span->zStep; \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.alpha += span.alphaStep; \
+ span.z += span.zStep; \
}
#ifdef WIN32
#define RENDER_SPAN( span ) \
GLuint i; \
- GLuint *img = (GLuint *) PIXELADDR4(span->x, span->y); \
- for (i = 0; i < span->end; i++) { \
- const GLdepth z = FixedToDepth(span->z); \
+ GLuint *img = (GLuint *) PIXELADDR4(span.x, span.y); \
+ for (i = 0; i < span.end; i++) { \
+ const GLdepth z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
img[i] = pixel; \
zRow[i] = z; \
} \
- span->z += span->zStep; \
+ span.z += span.zStep; \
}
#ifdef WIN32
if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
if (ctx->Polygon.StippleFlag) return (swrast_tri_func) NULL;
- if (ctx->Texture._ReallyEnabled) return (swrast_tri_func) NULL;
+ if (ctx->Texture._EnabledUnits) return (swrast_tri_func) NULL;
if (osmesa->format != OSMESA_RGBA &&
osmesa->format != OSMESA_BGRA &&
osmesa->format != OSMESA_ARGB) return (swrast_tri_func) NULL;
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
+ return (swrast_tri_func) NULL;
if (swrast->_RasterMask == DEPTH_BIT &&
ctx->Depth.Func == GL_LESS &&
ctx->Driver.GetString = get_string;
ctx->Driver.UpdateState = osmesa_update_state;
- ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.GetBufferSize = buffer_size;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+ ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d;
+ ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d;
+ ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d;
+ ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
+ ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
+ ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
+
ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
- ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;
- ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
- ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
+ swdd->SetBuffer = set_buffer;
/* RGB(A) span/pixel functions */
if (osmesa->format == OSMESA_RGB) {
swdd->ReadCI32Span = read_index_span;
swdd->ReadCI32Pixels = read_index_pixels;
- swdd->SetReadBuffer = set_read_buffer;
-
tnl->Driver.RunPipeline = _tnl_run_pipeline;
_swrast_InvalidateState( ctx, new_state );