/*\r
* Mesa 3-D graphics library\r
- * Version: 5.0\r
+ * Version: 5.0.1\r
* \r
- * Copyright (C) 1999 Brian Paul All Rights Reserved.\r
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.\r
* \r
* Permission is hereby granted, free of charge, to any person obtaining a\r
* copy of this software and associated documentation files (the "Software"),\r
/*\r
* DOS/DJGPP device driver v1.3 for Mesa\r
*\r
- * Copyright (C) 2002 - Borca Daniel\r
+ * Copyright (c) 2003 - Borca Daniel\r
* Email : dborca@yahoo.com\r
* Web : http://www.geocities.com/dborca\r
*/\r
\r
\r
#ifndef FX\r
-\r
#include "glheader.h"\r
#include "context.h"\r
-#include "GL/dmesa.h"\r
#include "extensions.h"\r
#include "macros.h"\r
#include "matrix.h"\r
#include "tnl/tnl.h"\r
#include "tnl/t_context.h"\r
#include "tnl/t_pipeline.h"\r
-\r
#ifndef MATROX\r
-\r
#include "video.h"\r
-\r
#else /* MATROX */\r
-\r
#include "mga/mga.h"\r
-\r
#endif /* MATROX */\r
-\r
#else /* FX */\r
-\r
#include "../FX/fxdrv.h"\r
-#include "GL/dmesa.h"\r
-\r
#endif /* FX */\r
\r
+#include "GL/dmesa.h"\r
+\r
\r
\r
/*\r
* Add system-specific fields to it.\r
*/\r
struct dmesa_visual {\r
- GLvisual *gl_visual;\r
+ GLvisual gl_visual;\r
GLboolean db_flag; /* double buffered? */\r
GLboolean rgb_flag; /* RGB mode? */\r
GLuint depth; /* bits per pixel (1, 8, 24, etc) */\r
* Add system-specific fields to it.\r
*/\r
struct dmesa_context {\r
- GLcontext *gl_ctx; /* the core library context */\r
+ GLcontext gl_ctx; /* the core library context */\r
DMesaVisual visual;\r
DMesaBuffer Buffer;\r
GLuint ClearColor;\r
static void write_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,\r
const GLubyte rgba[][4], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, offset;\r
\r
#ifndef MATROX\r
static void write_rgb_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,\r
const GLubyte rgb[][3], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, offset;\r
\r
offset = DSTRIDE * FLIP(y) + x;\r
GLuint n, GLint x, GLint y,\r
const GLchan color[4], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, offset, rgba = vl_mixrgba(color);\r
\r
offset = DSTRIDE * FLIP(y) + x;\r
static void read_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,\r
GLubyte rgba[][4])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, offset;\r
\r
offset = DSTRIDE * FLIP(y) + x;\r
GLuint n, const GLint x[], const GLint y[],\r
const GLubyte rgba[][4], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;\r
\r
if (mask) {\r
GLuint n, const GLint x[], const GLint y[],\r
const GLchan color[4], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1, rgba = vl_mixrgba(color);\r
\r
if (mask) {\r
GLuint n, const GLint x[], const GLint y[],\r
GLubyte rgba[][4], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;\r
\r
if (mask) {\r
static void write_index_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,\r
const GLuint index[], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, offset;\r
\r
offset = DSTRIDE * FLIP(y) + x;\r
static void write_index8_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,\r
const GLubyte index[], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, offset;\r
\r
offset = DSTRIDE * FLIP(y) + x;\r
GLuint n, GLint x, GLint y,\r
GLuint colorIndex, const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, offset;\r
\r
offset = DSTRIDE * FLIP(y) + x;\r
static void read_index_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,\r
GLuint index[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, offset;\r
\r
offset = DSTRIDE * FLIP(y) + x;\r
GLuint n, const GLint x[], const GLint y[],\r
const GLuint index[], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;\r
\r
if (mask) {\r
GLuint n, const GLint x[], const GLint y[],\r
GLuint colorIndex, const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;\r
\r
if (mask) {\r
GLuint n, const GLint x[], const GLint y[],\r
GLuint index[], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;\r
\r
if (mask) {\r
static void write_depth_span (GLcontext *ctx, GLuint n, GLint x, GLint y,\r
const GLdepth depth[], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, offset;\r
\r
offset = DSTRIDE * FLIP(y) + x;\r
static void read_depth_span (GLcontext *ctx, GLuint n, GLint x, GLint y,\r
GLdepth depth[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, offset;\r
\r
offset = DSTRIDE * FLIP(y) + x;\r
const GLint x[], const GLint y[],\r
const GLdepth depth[], const GLubyte mask[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;\r
\r
if (mask) {\r
const GLint x[], const GLint y[],\r
GLdepth depth[])\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint i, _w_ = DSTRIDE, _b_ = dmesa->Buffer->height - 1;\r
\r
/* read all values */\r
const SWvertex *v1,\r
const SWvertex *v2)\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint _b_ = dmesa->Buffer->height - 1;\r
#ifndef MATROX\r
GLuint _w_ = dmesa->Buffer->width;\r
const SWvertex *v1,\r
const SWvertex *v2)\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint _b_ = dmesa->Buffer->height - 1;\r
#ifndef MATROX\r
GLuint _w_ = dmesa->Buffer->width;\r
const SWvertex *v1,\r
const SWvertex *v2)\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint _b_ = dmesa->Buffer->height - 1;\r
#ifndef MATROX\r
GLuint _w_ = dmesa->Buffer->width;\r
const SWvertex *v1,\r
const SWvertex *v2)\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint _b_ = dmesa->Buffer->height - 1;\r
#ifndef MATROX\r
GLuint _w_ = dmesa->Buffer->width;\r
const SWvertex *vert0,\r
const SWvertex *vert1)\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint _b_ = dmesa->Buffer->height - 1;\r
#ifndef MATROX\r
GLuint _w_ = dmesa->Buffer->width;\r
const SWvertex *vert0,\r
const SWvertex *vert1)\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint _b_ = dmesa->Buffer->height - 1;\r
#ifndef MATROX\r
GLuint _w_ = dmesa->Buffer->width;\r
const SWvertex *vert0,\r
const SWvertex *vert1)\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint _b_ = dmesa->Buffer->height - 1;\r
MGAvertex m0, m1;\r
matrox_line_clip_hack(ctx, _b_, &m0, vert0, &m1, vert1);\r
const SWvertex *vert0,\r
const SWvertex *vert1)\r
{\r
- const DMesaContext dmesa = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext dmesa = (DMesaContext)ctx;\r
GLuint _b_ = dmesa->Buffer->height - 1;\r
MGAvertex m0, m1;\r
matrox_line_clip_hack(ctx, _b_, &m0, vert0, &m1, vert1);\r
\r
static void clear_index (GLcontext *ctx, GLuint index)\r
{\r
- ((DMesaContext)ctx->DriverCtx)->ClearIndex = index;\r
+ ((DMesaContext)ctx)->ClearIndex = index;\r
}\r
\r
static void clear_color (GLcontext *ctx, const GLfloat color[4])\r
CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);\r
CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);\r
CLAMPED_FLOAT_TO_UBYTE(col[3], color[3]);\r
- ((DMesaContext)ctx->DriverCtx)->ClearColor = vl_mixrgba(col);\r
+ ((DMesaContext)ctx)->ClearColor = vl_mixrgba(col);\r
}\r
\r
\r
static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all,\r
GLint x, GLint y, GLint width, GLint height)\r
{\r
- const DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext c = (DMesaContext)ctx;\r
const GLuint *colorMask = (GLuint *)&ctx->Color.ColorMask;\r
\r
/*\r
* pretty sure they will never change during the life of the Visual\r
*/\r
#ifdef MATROX\r
- if (((DMesaContext)ctx->DriverCtx)->visual->zbuffer == -1) {\r
+ if (((DMesaContext)ctx)->visual->zbuffer == -1) {\r
/* Depth span/pixel functions */\r
dd->WriteDepthSpan = write_depth_span;\r
dd->WriteDepthPixels = write_depth_pixels;\r
alphaBits = 8;\r
}\r
\r
- if ((v=(DMesaVisual)calloc(1, sizeof(struct dmesa_visual))) != NULL) {\r
+ if ((v=(DMesaVisual)CALLOC_STRUCT(dmesa_visual)) != NULL) {\r
/* Create core visual */\r
- v->gl_visual = _mesa_create_visual(rgbFlag, /* rgb */\r
- dbFlag,\r
- GL_FALSE, /* stereo */\r
- redBits,\r
- greenBits,\r
- blueBits,\r
- alphaBits,\r
- indexBits, /* indexBits */\r
- depthSize,\r
- stencilSize,\r
- accumSize, /* accumRed */\r
- accumSize, /* accumGreen */\r
- accumSize, /* accumBlue */\r
- alphaFlag?accumSize:0, /* accumAlpha */\r
- 1); /* numSamples */\r
+ _mesa_initialize_visual((GLvisual *)v,\r
+ rgbFlag, /* rgb */\r
+ dbFlag,\r
+ GL_FALSE, /* stereo */\r
+ redBits,\r
+ greenBits,\r
+ blueBits,\r
+ alphaBits,\r
+ indexBits, /* indexBits */\r
+ depthSize,\r
+ stencilSize,\r
+ accumSize, /* accumRed */\r
+ accumSize, /* accumGreen */\r
+ accumSize, /* accumBlue */\r
+ alphaFlag?accumSize:0, /* accumAlpha */\r
+ 1); /* numSamples */\r
\r
v->depth = colDepth;\r
v->db_flag = dbFlag;\r
void DMesaDestroyVisual (DMesaVisual v)\r
{\r
#ifndef FX\r
- _mesa_destroy_visual(v->gl_visual);\r
- free(v);\r
+ _mesa_destroy_visual((GLvisual *)v);\r
\r
#ifndef MATROX\r
vl_video_exit();\r
#ifndef FX\r
DMesaBuffer b;\r
\r
- if ((b=(DMesaBuffer)calloc(1, sizeof(struct dmesa_buffer))) != NULL) {\r
-\r
- _mesa_initialize_framebuffer(&b->gl_buffer,\r
- visual->gl_visual,\r
+ if ((b=(DMesaBuffer)CALLOC_STRUCT(dmesa_buffer)) != NULL) {\r
+ _mesa_initialize_framebuffer((GLframebuffer *)b,\r
+ (GLvisual *)visual,\r
visual->zbuffer == 1,\r
- visual->gl_visual->stencilBits > 0,\r
- visual->gl_visual->accumRedBits > 0,\r
- visual->gl_visual->alphaBits > 0);\r
+ ((GLvisual *)visual)->stencilBits > 0,\r
+ ((GLvisual *)visual)->accumRedBits > 0,\r
+ ((GLvisual *)visual)->alphaBits > 0);\r
b->xpos = xpos;\r
b->ypos = ypos;\r
b->width = width;\r
#ifndef MATROX\r
free(b->the_window);\r
#endif\r
- _mesa_free_framebuffer_data(&b->gl_buffer);\r
- free(b);\r
+ _mesa_destroy_framebuffer((GLframebuffer *)b);\r
#endif\r
}\r
\r
DMesaContext c;\r
GLboolean direct = GL_FALSE;\r
\r
- if ((c=(DMesaContext)calloc(1, sizeof(struct dmesa_context))) != NULL) {\r
- c->gl_ctx = _mesa_create_context(visual->gl_visual,\r
- share ? share->gl_ctx : NULL,\r
- (void *)c, direct);\r
+ if ((c=(DMesaContext)CALLOC_STRUCT(dmesa_context)) != NULL) {\r
+ _mesa_initialize_context((GLcontext *)c,\r
+ (GLvisual *)visual,\r
+ (GLcontext *)share,\r
+ (void *)c, direct);\r
\r
- _mesa_enable_sw_extensions(c->gl_ctx);\r
- _mesa_enable_1_3_extensions(c->gl_ctx);\r
- _mesa_enable_1_4_extensions(c->gl_ctx);\r
+ _mesa_enable_sw_extensions((GLcontext *)c);\r
+ _mesa_enable_1_3_extensions((GLcontext *)c);\r
+ _mesa_enable_1_4_extensions((GLcontext *)c);\r
\r
/* you probably have to do a bunch of other initializations here. */\r
c->visual = visual;\r
\r
- c->gl_ctx->Driver.UpdateState = dmesa_update_state;\r
+ ((GLcontext *)c)->Driver.UpdateState = dmesa_update_state;\r
\r
/* Initialize the software rasterizer and helper modules.\r
*/\r
- _swrast_CreateContext(c->gl_ctx);\r
- _ac_CreateContext(c->gl_ctx);\r
- _tnl_CreateContext(c->gl_ctx);\r
- _swsetup_CreateContext(c->gl_ctx);\r
- if (visual->rgb_flag) dmesa_register_swrast_functions(c->gl_ctx);\r
- dmesa_init_pointers(c->gl_ctx);\r
+ _swrast_CreateContext((GLcontext *)c);\r
+ _ac_CreateContext((GLcontext *)c);\r
+ _tnl_CreateContext((GLcontext *)c);\r
+ _swsetup_CreateContext((GLcontext *)c);\r
+ if (visual->rgb_flag) dmesa_register_swrast_functions((GLcontext *)c);\r
+ dmesa_init_pointers((GLcontext *)c);\r
}\r
\r
return c;\r
void DMesaDestroyContext (DMesaContext c)\r
{\r
#ifndef FX\r
- if (c->gl_ctx) {\r
- _swsetup_DestroyContext(c->gl_ctx);\r
- _swrast_DestroyContext(c->gl_ctx);\r
- _tnl_DestroyContext(c->gl_ctx);\r
- _ac_DestroyContext(c->gl_ctx);\r
- _mesa_destroy_context(c->gl_ctx);\r
+ if (c) {\r
+ _swsetup_DestroyContext((GLcontext *)c);\r
+ _swrast_DestroyContext((GLcontext *)c);\r
+ _tnl_DestroyContext((GLcontext *)c);\r
+ _ac_DestroyContext((GLcontext *)c);\r
+ _mesa_destroy_context((GLcontext *)c);\r
}\r
- free(c);\r
#endif\r
}\r
\r
{\r
#if !defined(FX) && !defined(MATROX)\r
GET_CURRENT_CONTEXT(ctx);\r
- DMesaBuffer b = ((DMesaContext)ctx->DriverCtx)->Buffer;\r
+ DMesaBuffer b = ((DMesaContext)ctx)->Buffer;\r
\r
if (vl_sync_buffer(&b->the_window, xpos, ypos, b->width, b->height) != 0) {\r
return GL_FALSE;\r
{\r
#if !defined(FX) && !defined(MATROX)\r
GET_CURRENT_CONTEXT(ctx);\r
- DMesaBuffer b = ((DMesaContext)ctx->DriverCtx)->Buffer;\r
+ DMesaBuffer b = ((DMesaContext)ctx)->Buffer;\r
\r
if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, width, height) != 0) {\r
return GL_FALSE;\r
\r
c->Buffer = b;\r
\r
- _mesa_make_current(c->gl_ctx, &b->gl_buffer);\r
- if (c->gl_ctx->Viewport.Width == 0) {\r
+ _mesa_make_current((GLcontext *)c, (GLframebuffer *)b);\r
+ if (((GLcontext *)c)->Viewport.Width == 0) {\r
/* initialize viewport to window size */\r
_mesa_Viewport(0, 0, b->width, b->height);\r
}\r
#ifndef MATROX\r
vl_flip();\r
#else\r
- if (((DMesaContext)ctx->DriverCtx)->visual->db_flag) {\r
+ if (((DMesaContext)ctx)->visual->db_flag) {\r
mga_swapbuffers(1);\r
}\r
#endif\r
{\r
#ifndef FX\r
GET_CURRENT_CONTEXT(ctx);\r
- return (ctx == NULL) ? NULL : (DMesaContext)ctx->DriverCtx;\r
+ return (DMesaContext)ctx;\r
#else\r
return (DMesaContext)fxMesaGetCurrentContext();\r
#endif\r
{\r
#ifndef FX\r
GET_CURRENT_CONTEXT(ctx);\r
- const DMesaContext c = (ctx == NULL) ? NULL : (DMesaContext)ctx->DriverCtx;\r
+ const DMesaContext c = (DMesaContext)ctx;\r
#else\r
const fxMesaContext c = fxMesaGetCurrentContext();\r
#endif\r