📄 dlist.c
字号:
/* Mimic the old behaviour of alloc_instruction:
* - sz is in units of sizeof(Node)
* - return value a pointer to sizeof(Node) before the actual
* usable data area.
*/
#define ALLOC_INSTRUCTION(ctx, opcode, sz) \
((Node *)_mesa_alloc_instruction(ctx, opcode, sz*sizeof(Node)) - 1)
/*
* Display List compilation functions
*/
static void GLAPIENTRY save_Accum( GLenum op, GLfloat value )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_ACCUM, 2 );
if (n) {
n[1].e = op;
n[2].f = value;
}
if (ctx->ExecuteFlag) {
CALL_Accum(ctx->Exec, ( op, value ));
}
}
static void GLAPIENTRY save_AlphaFunc( GLenum func, GLclampf ref )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_ALPHA_FUNC, 2 );
if (n) {
n[1].e = func;
n[2].f = (GLfloat) ref;
}
if (ctx->ExecuteFlag) {
CALL_AlphaFunc(ctx->Exec, ( func, ref ));
}
}
static void GLAPIENTRY save_BindTexture( GLenum target, GLuint texture )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_TEXTURE, 2 );
if (n) {
n[1].e = target;
n[2].ui = texture;
}
if (ctx->ExecuteFlag) {
CALL_BindTexture(ctx->Exec, ( target, texture ));
}
}
static void GLAPIENTRY save_Bitmap( GLsizei width, GLsizei height,
GLfloat xorig, GLfloat yorig,
GLfloat xmove, GLfloat ymove,
const GLubyte *pixels )
{
GET_CURRENT_CONTEXT(ctx);
GLvoid *image = _mesa_unpack_bitmap( width, height, pixels, &ctx->Unpack );
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_BITMAP, 7 );
if (n) {
n[1].i = (GLint) width;
n[2].i = (GLint) height;
n[3].f = xorig;
n[4].f = yorig;
n[5].f = xmove;
n[6].f = ymove;
n[7].data = image;
}
else if (image) {
FREE(image);
}
if (ctx->ExecuteFlag) {
CALL_Bitmap(ctx->Exec, ( width, height,
xorig, yorig, xmove, ymove, pixels ));
}
}
static void GLAPIENTRY save_BlendEquation( GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION, 1 );
if (n) {
n[1].e = mode;
}
if (ctx->ExecuteFlag) {
CALL_BlendEquation(ctx->Exec, ( mode ));
}
}
static void GLAPIENTRY save_BlendEquationSeparateEXT( GLenum modeRGB,
GLenum modeA )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2 );
if (n) {
n[1].e = modeRGB;
n[2].e = modeA;
}
if (ctx->ExecuteFlag) {
CALL_BlendEquationSeparateEXT(ctx->Exec, ( modeRGB, modeA ));
}
}
static void GLAPIENTRY save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
GLenum sfactorA, GLenum dfactorA)
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
if (n) {
n[1].e = sfactorRGB;
n[2].e = dfactorRGB;
n[3].e = sfactorA;
n[4].e = dfactorA;
}
if (ctx->ExecuteFlag) {
CALL_BlendFuncSeparateEXT(ctx->Exec,
(sfactorRGB, dfactorRGB, sfactorA, dfactorA));
}
}
static void GLAPIENTRY save_BlendColor( GLfloat red, GLfloat green,
GLfloat blue, GLfloat alpha )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_COLOR, 4 );
if (n) {
n[1].f = red;
n[2].f = green;
n[3].f = blue;
n[4].f = alpha;
}
if (ctx->ExecuteFlag) {
CALL_BlendColor(ctx->Exec, ( red, green, blue, alpha ));
}
}
void GLAPIENTRY _mesa_save_CallList( GLuint list )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
SAVE_FLUSH_VERTICES(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST, 1 );
if (n) {
n[1].ui = list;
}
/* After this, we don't know what begin/end state we're in:
*/
ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
if (ctx->ExecuteFlag) {
CALL_CallList(ctx->Exec, ( list ));
}
}
void GLAPIENTRY _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
{
GET_CURRENT_CONTEXT(ctx);
GLint i;
GLboolean typeErrorFlag;
SAVE_FLUSH_VERTICES(ctx);
switch (type) {
case GL_BYTE:
case GL_UNSIGNED_BYTE:
case GL_SHORT:
case GL_UNSIGNED_SHORT:
case GL_INT:
case GL_UNSIGNED_INT:
case GL_FLOAT:
case GL_2_BYTES:
case GL_3_BYTES:
case GL_4_BYTES:
typeErrorFlag = GL_FALSE;
break;
default:
typeErrorFlag = GL_TRUE;
}
for (i=0;i<n;i++) {
GLuint list = translate_id( i, type, lists );
Node *n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST_OFFSET, 2 );
if (n) {
n[1].ui = list;
n[2].b = typeErrorFlag;
}
}
/* After this, we don't know what begin/end state we're in:
*/
ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
if (ctx->ExecuteFlag) {
CALL_CallLists(ctx->Exec, ( n, type, lists ));
}
}
static void GLAPIENTRY save_Clear( GLbitfield mask )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR, 1 );
if (n) {
n[1].bf = mask;
}
if (ctx->ExecuteFlag) {
CALL_Clear(ctx->Exec, ( mask ));
}
}
static void GLAPIENTRY save_ClearAccum( GLfloat red, GLfloat green,
GLfloat blue, GLfloat alpha )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_ACCUM, 4 );
if (n) {
n[1].f = red;
n[2].f = green;
n[3].f = blue;
n[4].f = alpha;
}
if (ctx->ExecuteFlag) {
CALL_ClearAccum(ctx->Exec, ( red, green, blue, alpha ));
}
}
static void GLAPIENTRY save_ClearColor( GLclampf red, GLclampf green,
GLclampf blue, GLclampf alpha )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_COLOR, 4 );
if (n) {
n[1].f = red;
n[2].f = green;
n[3].f = blue;
n[4].f = alpha;
}
if (ctx->ExecuteFlag) {
CALL_ClearColor(ctx->Exec, ( red, green, blue, alpha ));
}
}
static void GLAPIENTRY save_ClearDepth( GLclampd depth )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_DEPTH, 1 );
if (n) {
n[1].f = (GLfloat) depth;
}
if (ctx->ExecuteFlag) {
CALL_ClearDepth(ctx->Exec, ( depth ));
}
}
static void GLAPIENTRY save_ClearIndex( GLfloat c )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_INDEX, 1 );
if (n) {
n[1].f = c;
}
if (ctx->ExecuteFlag) {
CALL_ClearIndex(ctx->Exec, ( c ));
}
}
static void GLAPIENTRY save_ClearStencil( GLint s )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_STENCIL, 1 );
if (n) {
n[1].i = s;
}
if (ctx->ExecuteFlag) {
CALL_ClearStencil(ctx->Exec, ( s ));
}
}
static void GLAPIENTRY save_ClipPlane( GLenum plane, const GLdouble *equ )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_CLIP_PLANE, 5 );
if (n) {
n[1].e = plane;
n[2].f = (GLfloat) equ[0];
n[3].f = (GLfloat) equ[1];
n[4].f = (GLfloat) equ[2];
n[5].f = (GLfloat) equ[3];
}
if (ctx->ExecuteFlag) {
CALL_ClipPlane(ctx->Exec, ( plane, equ ));
}
}
static void GLAPIENTRY save_ColorMask( GLboolean red, GLboolean green,
GLboolean blue, GLboolean alpha )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MASK, 4 );
if (n) {
n[1].b = red;
n[2].b = green;
n[3].b = blue;
n[4].b = alpha;
}
if (ctx->ExecuteFlag) {
CALL_ColorMask(ctx->Exec, ( red, green, blue, alpha ));
}
}
static void GLAPIENTRY save_ColorMaterial( GLenum face, GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MATERIAL, 2 );
if (n) {
n[1].e = face;
n[2].e = mode;
}
if (ctx->ExecuteFlag) {
CALL_ColorMaterial(ctx->Exec, ( face, mode ));
}
}
static void GLAPIENTRY save_ColorTable( GLenum target, GLenum internalFormat,
GLsizei width, GLenum format, GLenum type,
const GLvoid *table )
{
GET_CURRENT_CONTEXT(ctx);
if (target == GL_PROXY_TEXTURE_1D ||
target == GL_PROXY_TEXTURE_2D ||
target == GL_PROXY_TEXTURE_3D ||
target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
/* execute immediately */
CALL_ColorTable(ctx->Exec, ( target, internalFormat, width,
format, type, table ));
}
else {
GLvoid *image = unpack_image(1, width, 1, 1, format, type, table,
&ctx->Unpack);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE, 6 );
if (n) {
n[1].e = target;
n[2].e = internalFormat;
n[3].i = width;
n[4].e = format;
n[5].e = type;
n[6].data = image;
}
else if (image) {
FREE(image);
}
if (ctx->ExecuteFlag) {
CALL_ColorTable(ctx->Exec, ( target, internalFormat, width,
format, type, table ));
}
}
}
static void GLAPIENTRY
save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6 );
if (n) {
n[1].e = target;
n[2].e = pname;
n[3].f = params[0];
if (pname == GL_COLOR_TABLE_SGI ||
pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI ||
pname == GL_TEXTURE_COLOR_TABLE_SGI) {
n[4].f = params[1];
n[5].f = params[2];
n[6].f = params[3];
}
}
if (ctx->ExecuteFlag) {
CALL_ColorTableParameterfv(ctx->Exec, ( target, pname, params ));
}
}
static void GLAPIENTRY
save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6 );
if (n) {
n[1].e = target;
n[2].e = pname;
n[3].i = params[0];
if (pname == GL_COLOR_TABLE_SGI ||
pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI ||
pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI ||
pname == GL_TEXTURE_COLOR_TABLE_SGI) {
n[4].i = params[1];
n[5].i = params[2];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -