added a simple GLRendererRoster

imported missing pieces of mesa
GLView now gets a renderer correctly


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18772 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2006-09-07 14:02:34 +00:00
parent 35c2c27e98
commit b785569a0d
11 changed files with 1463 additions and 6 deletions

View File

@ -8,11 +8,26 @@ if $(TARGET_PLATFORM) != haiku {
}
{
local defines ;
defines = BEOS_THREADS GNU_ASSEMBLER ;
if $(TARGET_ARCH) = x86 {
defines += USE_X86_ASM USE_MMX_ASM USE_3DNOW_ASM USE_SSE_ASM ;
} else {
# Not yet supported, as current Mesa3D PPC assembly is Linux-dependent!
# defines += USE_PPC_ASM ;
}
SubDirC++Flags [ FDefines $(defines) ] ;
}
UsePrivateHeaders opengl ;
UseHeaders [ FDirName $(HAIKU_TOP) src kits opengl mesa ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src kits opengl mesa main ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src kits opengl mesa glapi ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src kits opengl mesa tnl ] ;
Addon mesa_soft : opengl :
MesaRenderer.cpp

View File

@ -10,9 +10,49 @@
*/
#include "MesaRenderer.h"
extern "C" {
#include "array_cache/acache.h"
#include "extensions.h"
#include "drivers/common/driverfuncs.h"
#include "main/colormac.h"
#include "main/buffers.h"
#include "main/version.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
}
extern const char * color_space_name(color_space space);
// BeOS component ordering for B_RGBA32 bitmap format
#if B_HOST_IS_LENDIAN
#define BE_RCOMP 2
#define BE_GCOMP 1
#define BE_BCOMP 0
#define BE_ACOMP 3
#define PACK_B_RGBA32(color) (color[BCOMP] | (color[GCOMP] << 8) | \
(color[RCOMP] << 16) | (color[ACOMP] << 24))
#define PACK_B_RGB32(color) (color[BCOMP] | (color[GCOMP] << 8) | \
(color[RCOMP] << 16) | 0xFF000000)
#else
// Big Endian B_RGBA32 bitmap format
#define BE_RCOMP 1
#define BE_GCOMP 2
#define BE_BCOMP 3
#define BE_ACOMP 0
#define PACK_B_RGBA32(color) (color[ACOMP] | (color[RCOMP] << 8) | \
(color[GCOMP] << 16) | (color[BCOMP] << 24))
#define PACK_B_RGB32(color) ((color[RCOMP] << 8) | (color[GCOMP] << 16) | \
(color[BCOMP] << 24) | 0xFF000000)
#endif
extern "C" _EXPORT BGLRenderer *
instanciate_gl_renderer(BGLView *view, BGLDispatcher *dispatcher)
{
@ -20,14 +60,90 @@ instanciate_gl_renderer(BGLView *view, BGLDispatcher *dispatcher)
}
MesaRenderer::MesaRenderer(BGLView *view, ulong bgl_options, BGLDispatcher *dispatcher)
: BGLRenderer(view, bgl_options, dispatcher),
MesaRenderer::MesaRenderer(BGLView *view, ulong options, BGLDispatcher *dispatcher)
: BGLRenderer(view, options, dispatcher),
fBitmap(NULL),
fContext(NULL),
fVisual(NULL),
fFrameBuffer(NULL)
{
fClearColor[BE_RCOMP] = 0;
fClearColor[BE_GCOMP] = 0;
fClearColor[BE_BCOMP] = 0;
fClearColor[BE_ACOMP] = 0;
fClearIndex = 0;
// We don't support single buffering (yet): double buffering forced.
options |= BGL_DOUBLE;
const GLboolean rgbFlag = ((options & BGL_INDEX) == 0);
const GLboolean alphaFlag = ((options & BGL_ALPHA) == BGL_ALPHA);
const GLboolean dblFlag = ((options & BGL_DOUBLE) == BGL_DOUBLE);
const GLboolean stereoFlag = false;
const GLint depth = (options & BGL_DEPTH) ? 16 : 0;
const GLint stencil = (options & BGL_STENCIL) ? 8 : 0;
const GLint accum = (options & BGL_ACCUM) ? 16 : 0;
const GLint index = (options & BGL_INDEX) ? 32 : 0;
const GLint red = rgbFlag ? 8 : 0;
const GLint green = rgbFlag ? 8 : 0;
const GLint blue = rgbFlag ? 8 : 0;
const GLint alpha = alphaFlag ? 8 : 0;
//fOptions = options | BGL_INDIRECT;
struct dd_function_table functions;
fVisual = _mesa_create_visual( rgbFlag, dblFlag, stereoFlag, red, green, blue, alpha,
index, depth, stencil, accum, accum, accum, accum, 1);
// Initialize device driver function table
_mesa_init_driver_functions(&functions);
functions.GetString = GetString;
functions.UpdateState = UpdateState;
functions.GetBufferSize = GetBufferSize;
functions.Clear = Clear;
functions.ClearIndex = ClearIndex;
functions.ClearColor = ClearColor;
functions.Error = Error;
functions.Viewport = Viewport;
// create core context
fContext = _mesa_create_context(fVisual, NULL, &functions, this);
if (!fContext) {
_mesa_destroy_visual(fVisual);
return;
}
_mesa_enable_sw_extensions(fContext);
_mesa_enable_1_3_extensions(fContext);
_mesa_enable_1_4_extensions(fContext);
_mesa_enable_1_5_extensions(fContext);
// create core framebuffer
fFrameBuffer = _mesa_create_framebuffer(fVisual, depth > 0 ? GL_TRUE : GL_FALSE,
stencil > 0 ? GL_TRUE: GL_FALSE, accum > 0 ? GL_TRUE : GL_FALSE, alphaFlag);
/* Initialize the software rasterizer and helper modules. */
_swrast_CreateContext(fContext);
_ac_CreateContext(fContext);
_tnl_CreateContext(fContext);
_swsetup_CreateContext(fContext);
_swsetup_Wakeup(fContext);
MesaRenderer * mr = (MesaRenderer *) fContext->DriverCtx;
struct swrast_device_driver * swdd = _swrast_GetDeviceDriverReference( fContext );
TNLcontext * tnl = TNL_CONTEXT(fContext);
assert(mr->fContext == fContext );
assert(tnl);
assert(swdd);
// Use default TCL pipeline
tnl->Driver.RunPipeline = _tnl_run_pipeline;
swdd->SetBuffer = this->SetBuffer;
}
MesaRenderer::~MesaRenderer()
@ -132,3 +248,771 @@ MesaRenderer::CopyPixelsIn(BBitmap *bitmap, BPoint location)
return B_OK;
}
void
MesaRenderer::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();
}
const GLubyte *
MesaRenderer::GetString(GLcontext *ctx, GLenum name)
{
switch (name) {
case GL_RENDERER:
return (const GLubyte *) "Mesa " MESA_VERSION_STRING " powered BGLView (software)";
default:
// Let core library handle all other cases
return NULL;
}
}
void
MesaRenderer::Error(GLcontext *ctx)
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
if (mr && mr->GLView())
mr->GLView()->ErrorCallback((unsigned long) ctx->ErrorValue);
}
void
MesaRenderer::ClearIndex(GLcontext *ctx, GLuint index)
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
mr->fClearIndex = index;
}
void
MesaRenderer::ClearColor(GLcontext *ctx, const GLfloat color[4])
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
CLAMPED_FLOAT_TO_CHAN(mr->fClearColor[BE_RCOMP], color[0]);
CLAMPED_FLOAT_TO_CHAN(mr->fClearColor[BE_GCOMP], color[1]);
CLAMPED_FLOAT_TO_CHAN(mr->fClearColor[BE_BCOMP], color[2]);
CLAMPED_FLOAT_TO_CHAN(mr->fClearColor[BE_ACOMP], color[3]);
assert(mr->GLView());
}
void
MesaRenderer::Clear(GLcontext *ctx, GLbitfield mask,
GLboolean all, GLint x, GLint y,
GLint width, GLint height)
{
if (mask & DD_FRONT_LEFT_BIT)
ClearFront(ctx, all, x, y, width, height);
if (mask & DD_BACK_LEFT_BIT)
ClearBack(ctx, all, x, y, width, height);
mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
if (mask)
_swrast_Clear( ctx, mask, all, x, y, width, height );
return;
}
void
MesaRenderer::ClearFront(GLcontext *ctx,
GLboolean all, GLint x, GLint y,
GLint width, GLint height)
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BGLView *bglview = mr->GLView();
assert(bglview);
bglview->SetHighColor(mr->fClearColor[BE_RCOMP],
mr->fClearColor[BE_GCOMP],
mr->fClearColor[BE_BCOMP],
mr->fClearColor[BE_ACOMP]);
bglview->SetLowColor(mr->fClearColor[BE_RCOMP],
mr->fClearColor[BE_GCOMP],
mr->fClearColor[BE_BCOMP],
mr->fClearColor[BE_ACOMP]);
if (all) {
BRect b = bglview->Bounds();
bglview->FillRect(b);
}
else {
// XXX untested
BRect b;
b.left = x;
b.right = x + width;
b.bottom = mr->fHeight - y - 1;
b.top = b.bottom - height;
bglview->FillRect(b);
}
// restore drawing color
#if 0
bglview->SetHighColor(md->mColor[BE_RCOMP],
md->mColor[BE_GCOMP],
md->mColor[BE_BCOMP],
md->mColor[BE_ACOMP]);
bglview->SetLowColor(md->mColor[BE_RCOMP],
md->mColor[BE_GCOMP],
md->mColor[BE_BCOMP],
md->mColor[BE_ACOMP]);
#endif
}
void
MesaRenderer::ClearBack(GLcontext *ctx,
GLboolean all, GLint x, GLint y,
GLint width, GLint height)
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BGLView *bglview = mr->GLView();
assert(bglview);
BBitmap *bitmap = mr->fBitmap;
assert(bitmap);
GLuint *start = (GLuint *) bitmap->Bits();
const GLuint *clearPixelPtr = (const GLuint *) mr->fClearColor;
const GLuint clearPixel = B_LENDIAN_TO_HOST_INT32(*clearPixelPtr);
if (all) {
const int numPixels = mr->fWidth * mr->fHeight;
if (clearPixel == 0) {
memset(start, 0, numPixels * 4);
}
else {
for (int i = 0; i < numPixels; i++) {
start[i] = clearPixel;
}
}
}
else {
// XXX untested
start += y * mr->fWidth + x;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
start[j] = clearPixel;
}
start += mr->fWidth;
}
}
}
void
MesaRenderer::UpdateState( GLcontext *ctx, GLuint new_state )
{
struct swrast_device_driver * swdd = _swrast_GetDeviceDriverReference( ctx );
_swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
_ac_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state );
if (ctx->Color.DrawBuffer[0] == GL_FRONT) {
/* read/write front buffer */
swdd->WriteRGBASpan = WriteRGBASpanFront;
swdd->WriteRGBSpan = WriteRGBSpanFront;
swdd->WriteRGBAPixels = WriteRGBAPixelsFront;
swdd->WriteMonoRGBASpan = WriteMonoRGBASpanFront;
swdd->WriteMonoRGBAPixels = WriteMonoRGBAPixelsFront;
swdd->WriteCI32Span = WriteCI32SpanFront;
swdd->WriteCI8Span = WriteCI8SpanFront;
swdd->WriteMonoCISpan = WriteMonoCISpanFront;
swdd->WriteCI32Pixels = WriteCI32PixelsFront;
swdd->WriteMonoCIPixels = WriteMonoCIPixelsFront;
swdd->ReadRGBASpan = ReadRGBASpanFront;
swdd->ReadRGBAPixels = ReadRGBAPixelsFront;
swdd->ReadCI32Span = ReadCI32SpanFront;
swdd->ReadCI32Pixels = ReadCI32PixelsFront;
} else {
/* read/write back buffer */
swdd->WriteRGBASpan = WriteRGBASpanBack;
swdd->WriteRGBSpan = WriteRGBSpanBack;
swdd->WriteRGBAPixels = WriteRGBAPixelsBack;
swdd->WriteMonoRGBASpan = WriteMonoRGBASpanBack;
swdd->WriteMonoRGBAPixels = WriteMonoRGBAPixelsBack;
swdd->WriteCI32Span = WriteCI32SpanBack;
swdd->WriteCI8Span = WriteCI8SpanBack;
swdd->WriteMonoCISpan = WriteMonoCISpanBack;
swdd->WriteCI32Pixels = WriteCI32PixelsBack;
swdd->WriteMonoCIPixels = WriteMonoCIPixelsBack;
swdd->ReadRGBASpan = ReadRGBASpanBack;
swdd->ReadRGBAPixels = ReadRGBAPixelsBack;
swdd->ReadCI32Span = ReadCI32SpanBack;
swdd->ReadCI32Pixels = ReadCI32PixelsBack;
}
}
void
MesaRenderer::GetBufferSize(GLframebuffer * framebuffer, GLuint *width,
GLuint *height)
{
GET_CURRENT_CONTEXT(ctx);
if (!ctx)
return;
MesaRenderer * mr = (MesaRenderer *) ctx->DriverCtx;
BGLView *bglview = mr->GLView();
assert(bglview);
BRect b = bglview->Bounds();
*width = (GLuint) b.IntegerWidth() + 1; // (b.right - b.left + 1);
*height = (GLuint) b.IntegerHeight() + 1; // (b.bottom - b.top + 1);
mr->fBottom = (GLint) b.bottom;
if (ctx->Visual.doubleBufferMode) {
if (*width != mr->fWidth || *height != mr->fHeight) {
// allocate new size of back buffer bitmap
if (mr->fBitmap)
delete mr->fBitmap;
BRect rect(0.0, 0.0, *width - 1, *height - 1);
mr->fBitmap = new BBitmap(rect, B_RGBA32);
}
} else {
mr->fBitmap = NULL;
}
mr->fWidth = *width;
mr->fHeight = *height;
}
void
MesaRenderer::SetBuffer(GLcontext *ctx, GLframebuffer *buffer,
GLenum mode)
{
/* TODO */
(void) ctx;
(void) buffer;
(void) mode;
}
// Plot a pixel. (0,0) is upper-left corner
// This is only used when drawing to the front buffer.
inline void Plot(BGLView *bglview, int x, int y)
{
// XXX There's got to be a better way!
BPoint p(x, y), q(x+1, y);
bglview->StrokeLine(p, q);
}
void
MesaRenderer::WriteRGBASpanFront(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
CONST GLubyte rgba[][4],
const GLubyte mask[])
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BGLView *bglview = mr->GLView();
assert(bglview);
int flippedY = mr->fBottom - y;
if (mask) {
for (GLuint i = 0; i < n; i++) {
if (mask[i]) {
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]);
Plot(bglview, x++, flippedY);
}
}
} else {
for (GLuint i = 0; i < n; i++) {
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]);
Plot(bglview, x++, flippedY);
}
}
}
void
MesaRenderer::WriteRGBSpanFront(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
CONST GLubyte rgba[][3],
const GLubyte mask[])
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BGLView *bglview = mr->GLView();
assert(bglview);
int flippedY = mr->fBottom - y;
if (mask) {
for (GLuint i = 0; i < n; i++) {
if (mask[i]) {
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
Plot(bglview, x++, flippedY);
}
}
} else {
for (GLuint i = 0; i < n; i++) {
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
Plot(bglview, x++, flippedY);
}
}
}
void
MesaRenderer::WriteMonoRGBASpanFront(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
const GLchan color[4],
const GLubyte mask[])
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BGLView *bglview = mr->GLView();
assert(bglview);
int flippedY = mr->fBottom - y;
bglview->SetHighColor(color[RCOMP], color[GCOMP], color[BCOMP]);
if (mask) {
for (GLuint i = 0; i < n; i++) {
if (mask[i]) {
Plot(bglview, x++, flippedY);
}
}
} else {
for (GLuint i = 0; i < n; i++) {
Plot(bglview, x++, flippedY);
}
}
}
void
MesaRenderer::WriteRGBAPixelsFront(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
CONST GLubyte rgba[][4],
const GLubyte mask[] )
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BGLView *bglview = mr->GLView();
assert(bglview);
if (mask) {
for (GLuint i = 0; i < n; i++) {
if (mask[i]) {
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
Plot(bglview, x[i], mr->fBottom - y[i]);
}
}
} else {
for (GLuint i = 0; i < n; i++) {
bglview->SetHighColor(rgba[i][0], rgba[i][1], rgba[i][2]);
Plot(bglview, x[i], mr->fBottom - y[i]);
}
}
}
void
MesaRenderer::WriteMonoRGBAPixelsFront(const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
const GLchan color[4],
const GLubyte mask[])
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BGLView *bglview = mr->GLView();
assert(bglview);
// plot points using current color
bglview->SetHighColor(color[RCOMP], color[GCOMP], color[BCOMP]);
if (mask) {
for (GLuint i = 0; i < n; i++) {
if (mask[i]) {
Plot(bglview, x[i], mr->fBottom - y[i]);
}
}
} else {
for (GLuint i = 0; i < n; i++) {
Plot(bglview, x[i], mr->fBottom - y[i]);
}
}
}
void
MesaRenderer::WriteCI32SpanFront( const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLuint index[], const GLubyte mask[] )
{
printf("WriteCI32SpanFront() not implemented yet!\n");
// TODO
}
void
MesaRenderer::WriteCI8SpanFront( const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLubyte index[], const GLubyte mask[] )
{
printf("WriteCI8SpanFront() not implemented yet!\n");
// TODO
}
void
MesaRenderer::WriteMonoCISpanFront( const GLcontext *ctx, GLuint n,
GLint x, GLint y,
GLuint colorIndex, const GLubyte mask[] )
{
printf("WriteMonoCISpanFront() not implemented yet!\n");
// TODO
}
void
MesaRenderer::WriteCI32PixelsFront( const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
const GLuint index[], const GLubyte mask[] )
{
printf("WriteCI32PixelsFront() not implemented yet!\n");
// TODO
}
void
MesaRenderer::WriteMonoCIPixelsFront( const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
GLuint colorIndex, const GLubyte mask[] )
{
printf("WriteMonoCIPixelsFront() not implemented yet!\n");
// TODO
}
void
MesaRenderer::ReadCI32SpanFront( const GLcontext *ctx,
GLuint n, GLint x, GLint y, GLuint index[] )
{
printf("ReadCI32SpanFront() not implemented yet!\n");
// TODO
}
void
MesaRenderer::ReadRGBASpanFront( const GLcontext *ctx, GLuint n,
GLint x, GLint y, GLubyte rgba[][4] )
{
printf("ReadRGBASpanFront() not implemented yet!\n");
// TODO
}
void
MesaRenderer::ReadCI32PixelsFront( const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint indx[], const GLubyte mask[] )
{
printf("ReadCI32PixelsFront() not implemented yet!\n");
// TODO
}
void
MesaRenderer::ReadRGBAPixelsFront( const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4], const GLubyte mask[] )
{
printf("ReadRGBAPixelsFront() not implemented yet!\n");
// TODO
}
void
MesaRenderer::WriteRGBASpanBack(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
CONST GLubyte rgba[][4],
const GLubyte mask[])
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BBitmap *bitmap = mr->fBitmap;
assert(bitmap);
int row = mr->fBottom - y;
uint8 * ptr = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + x * 4;
uint32 * pixel = (uint32 *) ptr;
if (mask) {
while(n--) {
if (*mask++)
*pixel = PACK_B_RGBA32(rgba[0]);
pixel++;
rgba++;
};
} else {
while(n--) {
*pixel++ = PACK_B_RGBA32(rgba[0]);
rgba++;
};
};
}
void
MesaRenderer::WriteRGBSpanBack(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
CONST GLubyte rgb[][3],
const GLubyte mask[])
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BBitmap *bitmap = mr->fBitmap;
assert(bitmap);
int row = mr->fBottom - y;
uint8 * ptr = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + x * 4;
uint32 * pixel = (uint32 *) ptr;
if (mask) {
while(n--) {
if (*mask++)
*pixel = PACK_B_RGB32(rgb[0]);
pixel++;
rgb++;
};
} else {
while(n--) {
*pixel++ = PACK_B_RGB32(rgb[0]);
rgb++;
};
};
}
void
MesaRenderer::WriteMonoRGBASpanBack(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
const GLchan color[4], const GLubyte mask[])
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BBitmap *bitmap = mr->fBitmap;
assert(bitmap);
int row = mr->fBottom - y;
uint8 * ptr = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + x * 4;
uint32 * pixel = (uint32 *) ptr;
uint32 pixel_color = PACK_B_RGBA32(color);
if (mask) {
while(n--) {
if (*mask++)
*pixel = pixel_color;
pixel++;
};
} else {
while(n--) {
*pixel++ = pixel_color;
};
};
}
void
MesaRenderer::WriteRGBAPixelsBack(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
CONST GLubyte rgba[][4],
const GLubyte mask[] )
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BBitmap *bitmap = mr->fBitmap;
assert(bitmap);
#if 0
while(n--) {
if (*mask++) {
int row = md->m_bottom - *y;
uint8 * pixel = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + *x * 4;
*((uint32 *) pixel) = PACK_B_RGBA32(rgba[0]);
};
x++;
y++;
rgba++;
};
#else
if (mask) {
for (GLuint i = 0; i < n; i++) {
if (mask[i]) {
GLubyte *pixel = (GLubyte *) bitmap->Bits()
+ ((mr->fBottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
pixel[BE_RCOMP] = rgba[i][RCOMP];
pixel[BE_GCOMP] = rgba[i][GCOMP];
pixel[BE_BCOMP] = rgba[i][BCOMP];
pixel[BE_ACOMP] = rgba[i][ACOMP];
}
}
}
else {
for (GLuint i = 0; i < n; i++) {
GLubyte *pixel = (GLubyte *) bitmap->Bits()
+ ((mr->fBottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
pixel[BE_RCOMP] = rgba[i][RCOMP];
pixel[BE_GCOMP] = rgba[i][GCOMP];
pixel[BE_BCOMP] = rgba[i][BCOMP];
pixel[BE_ACOMP] = rgba[i][ACOMP];
}
}
#endif
}
void
MesaRenderer::WriteMonoRGBAPixelsBack(const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
const GLchan color[4],
const GLubyte mask[])
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
BBitmap *bitmap = mr->fBitmap;
assert(bitmap);
uint32 pixel_color = PACK_B_RGBA32(color);
#if 0
while(n--) {
if (*mask++) {
int row = md->m_bottom - *y;
uint8 * pixel = (uint8 *) bitmap->Bits() + (row * bitmap->BytesPerRow()) + *x * 4;
*((uint32 *) pixel) = pixel_color;
};
x++;
y++;
};
#else
if (mask) {
for (GLuint i = 0; i < n; i++) {
if (mask[i]) {
GLubyte * ptr = (GLubyte *) bitmap->Bits()
+ ((mr->fBottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
*((uint32 *) ptr) = pixel_color;
}
}
}
else {
for (GLuint i = 0; i < n; i++) {
GLubyte * ptr = (GLubyte *) bitmap->Bits()
+ ((mr->fBottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
*((uint32 *) ptr) = pixel_color;
}
}
#endif
}
void
MesaRenderer::WriteCI32SpanBack( const GLcontext *ctx, GLuint n,
GLint x, GLint y,
const GLuint index[], const GLubyte mask[] )
{
printf("WriteCI32SpanBack() not implemented yet!\n");
// TODO
}
void
MesaRenderer::WriteCI8SpanBack( const GLcontext *ctx, GLuint n,
GLint x, GLint y,
const GLubyte index[], const GLubyte mask[] )
{
printf("WriteCI8SpanBack() not implemented yet!\n");
// TODO
}
void
MesaRenderer::WriteMonoCISpanBack( const GLcontext *ctx, GLuint n,
GLint x, GLint y,
GLuint colorIndex, const GLubyte mask[] )
{
printf("WriteMonoCISpanBack() not implemented yet!\n");
// TODO
}
void
MesaRenderer::WriteCI32PixelsBack( const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
const GLuint index[], const GLubyte mask[] )
{
printf("WriteCI32PixelsBack() not implemented yet!\n");
// TODO
}
void
MesaRenderer::WriteMonoCIPixelsBack( const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
GLuint colorIndex, const GLubyte mask[] )
{
printf("WriteMonoCIPixelsBack() not implemented yet!\n");
// TODO
}
void
MesaRenderer::ReadCI32SpanBack( const GLcontext *ctx,
GLuint n, GLint x, GLint y, GLuint index[] )
{
printf("ReadCI32SpanBack() not implemented yet!\n");
// TODO
}
void
MesaRenderer::ReadRGBASpanBack( const GLcontext *ctx, GLuint n,
GLint x, GLint y, GLubyte rgba[][4] )
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
const BBitmap *bitmap = mr->fBitmap;
assert(bitmap);
int row = mr->fBottom - y;
const GLubyte *pixel = (GLubyte *) bitmap->Bits()
+ (row * bitmap->BytesPerRow()) + x * 4;
for (GLuint i = 0; i < n; i++) {
rgba[i][RCOMP] = pixel[BE_RCOMP];
rgba[i][GCOMP] = pixel[BE_GCOMP];
rgba[i][BCOMP] = pixel[BE_BCOMP];
rgba[i][ACOMP] = pixel[BE_ACOMP];
pixel += 4;
}
}
void
MesaRenderer::ReadCI32PixelsBack( const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint indx[], const GLubyte mask[] )
{
printf("ReadCI32PixelsBack() not implemented yet!\n");
// TODO
}
void
MesaRenderer::ReadRGBAPixelsBack( const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4], const GLubyte mask[] )
{
MesaRenderer *mr = (MesaRenderer *) ctx->DriverCtx;
const BBitmap *bitmap = mr->fBitmap;
assert(bitmap);
if (mask) {
for (GLuint i = 0; i < n; i++) {
if (mask[i]) {
GLubyte *pixel = (GLubyte *) bitmap->Bits()
+ ((mr->fBottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
rgba[i][RCOMP] = pixel[BE_RCOMP];
rgba[i][GCOMP] = pixel[BE_GCOMP];
rgba[i][BCOMP] = pixel[BE_BCOMP];
rgba[i][ACOMP] = pixel[BE_ACOMP];
};
};
} else {
for (GLuint i = 0; i < n; i++) {
GLubyte *pixel = (GLubyte *) bitmap->Bits()
+ ((mr->fBottom - y[i]) * bitmap->BytesPerRow()) + x[i] * 4;
rgba[i][RCOMP] = pixel[BE_RCOMP];
rgba[i][GCOMP] = pixel[BE_GCOMP];
rgba[i][BCOMP] = pixel[BE_BCOMP];
rgba[i][ACOMP] = pixel[BE_ACOMP];
};
};
}

View File

@ -31,12 +31,130 @@ public:
virtual status_t CopyPixelsIn(BBitmap *source, BPoint dest);
private:
static void Error(GLcontext *ctx);
static const GLubyte * GetString(GLcontext *ctx, GLenum name);
static void Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
static void UpdateState(GLcontext *ctx, GLuint new_state);
static void GetBufferSize(GLframebuffer * framebuffer, GLuint *width,
GLuint *height);
static void SetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
GLenum mode);
static void ClearFront(GLcontext *ctx, GLboolean all, GLint x, GLint y,
GLint width, GLint height);
static void ClearBack(GLcontext *ctx, GLboolean all, GLint x, GLint y,
GLint width, GLint height);
static void ClearIndex(GLcontext *ctx, GLuint index);
static void ClearColor(GLcontext *ctx, const GLfloat color[4]);
static void Clear(GLcontext *ctx, GLbitfield mask,
GLboolean all, GLint x, GLint y,
GLint width, GLint height);
// Front-buffer functions
static void WriteRGBASpanFront(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
CONST GLubyte rgba[][4],
const GLubyte mask[]);
static void WriteRGBSpanFront(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
CONST GLubyte rgba[][3],
const GLubyte mask[]);
static void WriteMonoRGBASpanFront(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
const GLchan color[4],
const GLubyte mask[]);
static void WriteRGBAPixelsFront(const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
CONST GLubyte rgba[][4],
const GLubyte mask[]);
static void WriteMonoRGBAPixelsFront(const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
const GLchan color[4],
const GLubyte mask[]);
static void WriteCI32SpanFront(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
const GLuint index[], const GLubyte mask[]);
static void WriteCI8SpanFront(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
const GLubyte index[], const GLubyte mask[]);
static void WriteMonoCISpanFront(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
GLuint colorIndex, const GLubyte mask[]);
static void WriteCI32PixelsFront(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLuint index[], const GLubyte mask[]);
static void WriteMonoCIPixelsFront(const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
GLuint colorIndex, const GLubyte mask[]);
static void ReadCI32SpanFront(const GLcontext *ctx,
GLuint n, GLint x, GLint y, GLuint index[]);
static void ReadRGBASpanFront(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
GLubyte rgba[][4]);
static void ReadCI32PixelsFront(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint indx[], const GLubyte mask[]);
static void ReadRGBAPixelsFront(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4], const GLubyte mask[]);
// Back buffer functions
static void WriteRGBASpanBack(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
CONST GLubyte rgba[][4],
const GLubyte mask[]);
static void WriteRGBSpanBack(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
CONST GLubyte rgba[][3],
const GLubyte mask[]);
static void WriteMonoRGBASpanBack(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
const GLchan color[4],
const GLubyte mask[]);
static void WriteRGBAPixelsBack(const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
CONST GLubyte rgba[][4],
const GLubyte mask[]);
static void WriteMonoRGBAPixelsBack(const GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
const GLchan color[4],
const GLubyte mask[]);
static void WriteCI32SpanBack(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
const GLuint index[], const GLubyte mask[]);
static void WriteCI8SpanBack(const GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLubyte index[], const GLubyte mask[]);
static void WriteMonoCISpanBack(const GLcontext *ctx, GLuint n,
GLint x, GLint y, GLuint colorIndex,
const GLubyte mask[]);
static void WriteCI32PixelsBack(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLuint index[], const GLubyte mask[]);
static void WriteMonoCIPixelsBack(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint colorIndex, const GLubyte mask[]);
static void ReadCI32SpanBack(const GLcontext *ctx,
GLuint n, GLint x, GLint y, GLuint index[]);
static void ReadRGBASpanBack(const GLcontext *ctx, GLuint n,
GLint x, GLint y,
GLubyte rgba[][4]);
static void ReadCI32PixelsBack(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLuint indx[], const GLubyte mask[]);
static void ReadRGBAPixelsBack(const GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
GLubyte rgba[][4], const GLubyte mask[]);
BBitmap *fBitmap;
GLcontext *fContext;
GLvisual *fVisual;
GLframebuffer *fFrameBuffer;
GLchan fClearColor[4]; // buffer clear color
GLuint fClearIndex; // buffer clear color index
GLint fBottom; // used for flipping Y coords
GLuint fWidth;
GLuint fHeight;
};
#endif // MESARENDERER_H

View File

@ -3,10 +3,13 @@
* Distributed under the terms of the MIT License.
*/
#include "GLDispatcher.h"
#include "GLRenderer.h"
BGLRenderer::BGLRenderer(BGLView *view, ulong bgl_options, BGLDispatcher *dispatcher)
: fRefCount(1)
: fRefCount(1),
fOptions(bgl_options),
fDispatcher(dispatcher)
{
}
@ -14,6 +17,7 @@ BGLRenderer::BGLRenderer(BGLView *view, ulong bgl_options, BGLDispatcher *dispat
BGLRenderer::~BGLRenderer()
{
delete fDispatcher;
}

View File

@ -0,0 +1,147 @@
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
*/
#include <Directory.h>
#include <FindDirectory.h>
#include <image.h>
#include <Path.h>
#include <String.h>
#include "GLDispatcher.h"
#include "GLRendererRoster.h"
#include <new>
#include <string.h>
GLRendererRoster::GLRendererRoster(BGLView *view)
: fNextID(0),
fView(view)
{
AddDefaultPaths();
}
GLRendererRoster::~GLRendererRoster()
{
}
BGLRenderer *
GLRendererRoster::GetRenderer(int32 id)
{
struct renderer_item item = fRenderers[id];
return item.renderer;
}
void
GLRendererRoster::AddDefaultPaths()
{
// add user directories first, so that they can override system renderers
const directory_which paths[] = {
B_USER_ADDONS_DIRECTORY,
B_COMMON_ADDONS_DIRECTORY,
B_BEOS_ADDONS_DIRECTORY,
};
for (uint32 i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
BPath path;
status_t status = find_directory(paths[i], &path, true);
if (status == B_OK && path.Append("opengl") == B_OK)
AddPath(path.Path());
}
}
status_t
GLRendererRoster::AddPath(const char* path)
{
BDirectory directory(path);
status_t status = directory.InitCheck();
if (status < B_OK)
return status;
node_ref nodeRef;
status = directory.GetNodeRef(&nodeRef);
if (status < B_OK)
return status;
int32 count = 0;
int32 files = 0;
entry_ref ref;
while (directory.GetNextRef(&ref) == B_OK) {
if (CreateRenderer(ref) == B_OK)
count++;
files++;
}
if (files != 0 && count == 0)
return B_BAD_VALUE;
return B_OK;
}
status_t
GLRendererRoster::AddRenderer(BGLRenderer* renderer,
image_id image, const entry_ref* ref, ino_t node)
{
renderer_item item;
item.renderer = renderer;
item.image = image;
item.node = node;
if (ref != NULL)
item.ref = *ref;
try {
fRenderers[fNextID] = item;
} catch (...) {
return B_NO_MEMORY;
}
renderer->fOwningRoster = this;
renderer->fID = fNextID++;
return B_OK;
}
status_t
GLRendererRoster::CreateRenderer(const entry_ref& ref)
{
BEntry entry(&ref);
node_ref nodeRef;
status_t status = entry.GetNodeRef(&nodeRef);
if (status < B_OK)
return status;
BPath path(&ref);
image_id image = load_add_on(path.Path());
if (image < B_OK)
return image;
BGLRenderer *(*instanc)(BGLView *view, BGLDispatcher *dispatcher);
status = get_image_symbol(image, "instanciate_gl_renderer",
B_SYMBOL_TYPE_TEXT, (void**)&instanc);
if (status == B_OK) {
BGLRenderer *renderer = instanc(fView, new BGLDispatcher());
if (AddRenderer(renderer, image, &ref, nodeRef.node) != B_OK) {
renderer->Release();
// this will delete the renderer
unload_add_on(image);
}
return B_OK;
}
unload_add_on(image);
return status;
}

View File

@ -0,0 +1,39 @@
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _GLRENDERER_ROSTER_H
#define _GLRENDERER_ROSTER_H
#include <GLRenderer.h>
#include <map>
struct renderer_item {
BGLRenderer *renderer;
entry_ref ref;
ino_t node;
image_id image;
};
typedef std::map<renderer_id, renderer_item> RendererMap;
class GLRendererRoster {
public:
GLRendererRoster(BGLView *view);
virtual ~GLRendererRoster();
BGLRenderer *GetRenderer(int32 id = 0);
private:
void AddDefaultPaths();
status_t AddPath(const char* path);
status_t AddRenderer(BGLRenderer* renderer,
image_id image, const entry_ref* ref, ino_t node);
status_t CreateRenderer(const entry_ref& ref);
RendererMap fRenderers;
int32 fNextID;
BGLView *fView;
};
#endif /* _GLRENDERER_ROSTER_H */

View File

@ -27,14 +27,18 @@
#include <stdio.h>
#include <GLView.h>
// #include "GLRenderersManager.h"
#include "GLRenderer.h"
#include <GLRenderer.h>
#include "GLRendererRoster.h"
BGLView::BGLView(BRect rect, char *name, ulong resizingMode, ulong mode, ulong options)
: BView(rect, name, B_FOLLOW_ALL_SIDES, mode | B_WILL_DRAW | B_FRAME_EVENTS), // | B_FULL_UPDATE_ON_RESIZE)
fRenderer(NULL)
{
// TODO: get a renderer instance!
fRoster = new GLRendererRoster(this);
fRenderer = fRoster->GetRenderer();
if (!fRenderer) {
fprintf(stderr, "no renderer found! \n");
}
}

View File

@ -39,6 +39,7 @@ SharedLibrary libGL.so :
GLView.cpp
GLDispatcher.cpp
GLRenderer.cpp
GLRendererRoster.cpp
:

View File

@ -18,6 +18,7 @@ UseHeaders [ FDirName $(SUBDIR) swrast ] ;
UseHeaders [ FDirName $(SUBDIR) swrast_setup ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) array_cache ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) drivers common ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) glapi ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) main ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) math ] ;
@ -114,6 +115,7 @@ StaticLibrary libmesa.a :
depth.c
dlist.c
drawpix.c
driverfuncs.c
enable.c
enums.c
eval.c

View File

@ -0,0 +1,211 @@
/*
* Mesa 3-D graphics library
* Version: 6.1
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "glheader.h"
#include "imports.h"
#include "buffers.h"
#include "context.h"
#include "program.h"
#include "texcompress.h"
#include "texformat.h"
#include "teximage.h"
#include "texobj.h"
#include "texstore.h"
#include "bufferobj.h"
#include "driverfuncs.h"
#include "swrast/swrast.h"
/**
* Plug in default functions for all pointers in the dd_function_table
* structure.
* Device drivers should call this function and then plug in any
* functions which it wants to override.
* Some functions (pointers) MUST be implemented by all drivers (REQUIRED).
*
* \param table the dd_function_table to initialize
*/
void
_mesa_init_driver_functions(struct dd_function_table *driver)
{
_mesa_bzero(driver, sizeof(*driver));
driver->GetString = NULL; /* REQUIRED! */
driver->UpdateState = NULL; /* REQUIRED! */
driver->GetBufferSize = NULL; /* REQUIRED! */
driver->ResizeBuffers = _swrast_alloc_buffers;
driver->Error = NULL;
driver->Finish = NULL;
driver->Flush = NULL;
/* framebuffer/image functions */
driver->Clear = _swrast_Clear;
driver->Accum = _swrast_Accum;
driver->DrawPixels = _swrast_DrawPixels;
driver->ReadPixels = _swrast_ReadPixels;
driver->CopyPixels = _swrast_CopyPixels;
driver->Bitmap = _swrast_Bitmap;
/* Texture functions */
driver->ChooseTextureFormat = _mesa_choose_tex_format;
driver->TexImage1D = _mesa_store_teximage1d;
driver->TexImage2D = _mesa_store_teximage2d;
driver->TexImage3D = _mesa_store_teximage3d;
driver->TexSubImage1D = _mesa_store_texsubimage1d;
driver->TexSubImage2D = _mesa_store_texsubimage2d;
driver->TexSubImage3D = _mesa_store_texsubimage3d;
driver->CopyTexImage1D = _swrast_copy_teximage1d;
driver->CopyTexImage2D = _swrast_copy_teximage2d;
driver->CopyTexSubImage1D = _swrast_copy_texsubimage1d;
driver->CopyTexSubImage2D = _swrast_copy_texsubimage2d;
driver->CopyTexSubImage3D = _swrast_copy_texsubimage3d;
driver->TestProxyTexImage = _mesa_test_proxy_teximage;
driver->CompressedTexImage1D = _mesa_store_compressed_teximage1d;
driver->CompressedTexImage2D = _mesa_store_compressed_teximage2d;
driver->CompressedTexImage3D = _mesa_store_compressed_teximage3d;
driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
driver->CompressedTextureSize = _mesa_compressed_texture_size;
driver->BindTexture = NULL;
driver->NewTextureObject = _mesa_new_texture_object;
driver->DeleteTexture = _mesa_delete_texture_object;
driver->NewTextureImage = _mesa_new_texture_image;
driver->IsTextureResident = NULL;
driver->PrioritizeTexture = NULL;
driver->ActiveTexture = NULL;
driver->UpdateTexturePalette = NULL;
/* imaging */
driver->CopyColorTable = _swrast_CopyColorTable;
driver->CopyColorSubTable = _swrast_CopyColorSubTable;
driver->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
driver->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
/* Vertex/fragment programs */
driver->BindProgram = NULL;
driver->NewProgram = _mesa_new_program;
driver->DeleteProgram = _mesa_delete_program;
/* simple state commands */
driver->AlphaFunc = NULL;
driver->BlendColor = NULL;
driver->BlendEquationSeparate = NULL;
driver->BlendFuncSeparate = NULL;
driver->ClearColor = NULL;
driver->ClearDepth = NULL;
driver->ClearIndex = NULL;
driver->ClearStencil = NULL;
driver->ClipPlane = NULL;
driver->ColorMask = NULL;
driver->ColorMaterial = NULL;
driver->CullFace = NULL;
driver->DrawBuffer = _swrast_DrawBuffer;
driver->FrontFace = NULL;
driver->DepthFunc = NULL;
driver->DepthMask = NULL;
driver->DepthRange = NULL;
driver->Enable = NULL;
driver->Fogfv = NULL;
driver->Hint = NULL;
driver->IndexMask = NULL;
driver->Lightfv = NULL;
driver->LightModelfv = NULL;
driver->LineStipple = NULL;
driver->LineWidth = NULL;
driver->LogicOpcode = NULL;
driver->PointParameterfv = NULL;
driver->PointSize = NULL;
driver->PolygonMode = NULL;
driver->PolygonOffset = NULL;
driver->PolygonStipple = NULL;
driver->ReadBuffer = NULL;
driver->RenderMode = NULL;
driver->Scissor = NULL;
driver->ShadeModel = NULL;
driver->StencilFunc = NULL;
driver->StencilMask = NULL;
driver->StencilOp = NULL;
driver->ActiveStencilFace = NULL;
driver->TexGen = NULL;
driver->TexEnv = NULL;
driver->TexParameter = NULL;
driver->TextureMatrix = NULL;
driver->Viewport = NULL;
/* vertex arrays */
driver->VertexPointer = NULL;
driver->NormalPointer = NULL;
driver->ColorPointer = NULL;
driver->FogCoordPointer = NULL;
driver->IndexPointer = NULL;
driver->SecondaryColorPointer = NULL;
driver->TexCoordPointer = NULL;
driver->EdgeFlagPointer = NULL;
driver->VertexAttribPointer = NULL;
driver->LockArraysEXT = NULL;
driver->UnlockArraysEXT = NULL;
/* state queries */
driver->GetBooleanv = NULL;
driver->GetDoublev = NULL;
driver->GetFloatv = NULL;
driver->GetIntegerv = NULL;
driver->GetPointerv = NULL;
#if FEATURE_ARB_vertex_buffer_object
driver->NewBufferObject = _mesa_new_buffer_object;
driver->DeleteBuffer = _mesa_delete_buffer_object;
driver->BindBuffer = NULL;
driver->BufferData = _mesa_buffer_data;
driver->BufferSubData = _mesa_buffer_subdata;
driver->GetBufferSubData = _mesa_buffer_get_subdata;
driver->MapBuffer = _mesa_buffer_map;
driver->UnmapBuffer = NULL;
#endif
/* T&L stuff */
driver->NeedValidate = GL_FALSE;
driver->ValidateTnlModule = NULL;
driver->CurrentExecPrimitive = 0;
driver->CurrentSavePrimitive = 0;
driver->NeedFlush = 0;
driver->SaveNeedFlush = 0;
driver->FlushVertices = NULL;
driver->SaveFlushVertices = NULL;
driver->NotifySaveBegin = NULL;
driver->LightingSpaceChange = NULL;
driver->MakeCurrent = NULL;
/* display list */
driver->NewList = NULL;
driver->EndList = NULL;
driver->BeginCallList = NULL;
driver->EndCallList = NULL;
}

View File

@ -0,0 +1,32 @@
/*
* Mesa 3-D graphics library
* Version: 6.1
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef DRIVERFUNCS_H
#define DRIVERFUNCS_H
extern void
_mesa_init_driver_functions(struct dd_function_table *driver);
#endif