DECLEXPORT(void) STATE_APIENTRY crStateUseProgram(GLuint program)
{
    CRContext *g = GetCurrentContext();

    if (program>0)
    {
        CRGLSLProgram *pProgram = crStateGetProgramObj(program);

        if (!pProgram)
        {
            crWarning("Unknown program %d", program);
            return;
        }

        g->glsl.activeProgram = pProgram;
    }
    else
    {
        g->glsl.activeProgram = NULL;
    }
}
EOpenGLCurrentContext PlatformOpenGLCurrentContext(FPlatformOpenGLDevice* Device)
{
	HGLRC Context = GetCurrentContext();

	if (Context == Device->RenderingContext.OpenGLContext)	// most common case
	{
		return CONTEXT_Rendering;
	}
	else if (Context == Device->SharedContext.OpenGLContext)
	{
		return CONTEXT_Shared;
	}
	else if (Context)
	{
		return CONTEXT_Other;
	}
	else
	{
		return CONTEXT_Invalid;
	}
}
GLboolean crStateIsBufferBound(GLenum target)
{
    CRContext *g = GetCurrentContext();
    CRBufferObjectState *b = &(g->bufferobject);

    switch (target)
    {
        case GL_ARRAY_BUFFER_ARB:
            return b->arrayBuffer->id!=0;
        case GL_ELEMENT_ARRAY_BUFFER_ARB:
            return b->elementsBuffer->id!=0;
#ifdef CR_ARB_pixel_buffer_object
        case GL_PIXEL_PACK_BUFFER_ARB:
            return b->packBuffer->id!=0;
        case GL_PIXEL_UNPACK_BUFFER_ARB:
            return b->unpackBuffer->id!=0;
#endif
        default:
            return GL_FALSE;
    }
}
Exemple #4
0
/*
 * As above, but don't call crStateSwitchContext().
 */
void crStateSetCurrent( CRContext *ctx )
{
    CRContext *current = GetCurrentContext();

    if (ctx == NULL)
        ctx = defaultContext;

    if (current == ctx)
        return; /* no-op */

    CRASSERT(ctx);

#ifdef CHROMIUM_THREADSAFE
    SetCurrentContext(ctx);
#else
    __currentContext = ctx;
#endif

    /* ensure matrix state is also current */
    crStateMatrixMode(ctx->transform.matrixMode);
}
DECLEXPORT(void) STATE_APIENTRY
crStateBindRenderbufferEXT(GLenum target, GLuint renderbuffer)
{
    CRContext *g = GetCurrentContext();
    CRFramebufferObjectState *fbo = &g->framebufferobject;

    CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end");
    CRSTATE_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target");

    if (renderbuffer)
    {
        fbo->renderbuffer = (CRRenderbufferObject*) crHashtableSearch(g->shared->rbTable, renderbuffer);
        if (!fbo->renderbuffer)
        {
            CRSTATE_CHECKERR(!crHashtableIsKeyUsed(g->shared->rbTable, renderbuffer), GL_INVALID_OPERATION, "name is not a renderbuffer");
            fbo->renderbuffer = crStateRenderbufferAllocate(g, renderbuffer);
        }
        CR_STATE_SHAREDOBJ_USAGE_SET(fbo->renderbuffer, g);
    }
    else fbo->renderbuffer = NULL;
}
Exemple #6
0
void  STATE_APIENTRY crStatePolygonMode (GLenum face, GLenum mode) 
{
	CRContext *g = GetCurrentContext();
	CRPolygonState *p = &(g->polygon);
        CRStateBits *sb = GetCurrentBits();
	CRPolygonBits *pb = &(sb->polygon);

	if (g->current.inBeginEnd) 
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
				"glPolygonMode called in begin/end");
		return;
	}

	FLUSH();

	if (mode != GL_POINT && mode != GL_LINE && mode != GL_FILL)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
				"glPolygonMode called with bogus mode: 0x%x", mode);
		return;
	}

	switch (face) {
		case GL_FRONT:
			p->frontMode = mode;
			break;
		case GL_FRONT_AND_BACK:
			p->frontMode = mode;
		case GL_BACK:
			p->backMode = mode;
			break;
		default:
			crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
					"glPolygonMode called with bogus face: 0x%x", face);
			return;
	}
	DIRTY(pb->mode, g->neg_bitid);
	DIRTY(pb->dirty, g->neg_bitid);
}
void PlatformGetNewRenderQuery( GLuint* OutQuery, uint64* OutQueryContext )
{
	if( !ReleasedQueriesGuard )
	{
		ReleasedQueriesGuard = new FCriticalSection;
	}

	{
		FScopeLock Lock(ReleasedQueriesGuard);

#ifdef UE_BUILD_DEBUG
		check( OutQuery && OutQueryContext );
#endif

		HGLRC Context = GetCurrentContext();
		check( Context );

		GLuint NewQuery = 0;

		// Check for possible query reuse
		const int32 ArraySize = ReleasedQueries.Num();
		for( int32 Index = 0; Index < ArraySize; ++Index )
		{
			if( ReleasedQueries[Index].Context == Context )
			{
				NewQuery = ReleasedQueries[Index].Query;
				ReleasedQueries.RemoveAtSwap(Index);
				break;
			}
		}

		if( !NewQuery )
		{
			FOpenGL::GenQueries( 1, &NewQuery );
		}

		*OutQuery = NewQuery;
		*OutQueryContext = (uint64)Context;
	}
}
Exemple #8
0
void STATE_APIENTRY crStateSecondaryColorPointerEXT(GLint size,
		GLenum type, GLsizei stride, const GLvoid *p)
{
	CRContext *g = GetCurrentContext();
	CRClientState *c = &(g->client);
	CRStateBits *sb = GetCurrentBits();
	CRClientBits *cb = &(sb->client);

	FLUSH();

	if ( !g->extensions.EXT_secondary_color )
	{
		crError( "glSecondaryColorPointerEXT called but EXT_secondary_color is disabled." );
		return;
	}

	if (size != 3)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glSecondaryColorPointerEXT: invalid size: %d", size);
		return;
	}
	if (type != GL_BYTE && type != GL_UNSIGNED_BYTE &&
			type != GL_SHORT && type != GL_UNSIGNED_SHORT &&
			type != GL_INT && type != GL_UNSIGNED_INT &&
			type != GL_FLOAT && type != GL_DOUBLE)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glSecondaryColorPointerEXT: invalid type: 0x%x", type);
		return;
	}
	if (stride < 0) 
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glSecondaryColorPointerEXT: stride was negative: %d", stride);
		return;
	}

	crStateClientSetPointer(&(c->array.s), size, type, GL_TRUE, stride, p);
	DIRTY(cb->dirty, g->neg_bitid);
	DIRTY(cb->clientPointer, g->neg_bitid);
	DIRTY(cb->s, g->neg_bitid);
}
Exemple #9
0
/**
 *  \brief Get the currently selected key string
 *
 *   If no key is selected, an empty string is returned.
 *
 *  \return The currently selected key string
 */
QString MythControls::GetCurrentKey(void)
{
    MythUIButtonListItem* currentButton;
    if (m_leftListType == kKeyList &&
        (currentButton = m_leftList->GetItemCurrent()))
    {
        return currentButton->GetText();
    }

    if (GetFocusWidget() == m_leftList)
        return QString();

    if ((m_leftListType == kContextList) && (m_rightListType == kActionList))
    {
        QString context = GetCurrentContext();
        QString action = GetCurrentAction();
        uint b = GetCurrentButton();
        QStringList keys = m_bindings->GetActionKeys(context, action);

        if (b < (uint)keys.count())
            return keys[b];

        return QString();
    }

    currentButton = m_rightList->GetItemCurrent();
    QString desc;
    if (currentButton)
        desc = currentButton->GetText();

    int loc = desc.indexOf(" => ");
    if (loc == -1)
        return QString(); // Should not happen


    if (m_rightListType == kKeyList)
        return desc.left(loc);

    return desc.mid(loc + 4);
}
void STATE_APIENTRY crStateClearDepth (GLclampd depth) 
{
    CRContext *g = GetCurrentContext();
    CRBufferState *b = &(g->buffer);
    CRStateBits *sp = GetCurrentBits();
    CRBufferBits *bb = &(sp->buffer);

    if (g->current.inBeginEnd)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearDepth called in begin/end");
        return;
    }

    FLUSH();

    if (depth < 0.0) depth = 0.0;
    if (depth > 1.0) depth = 1.0;

    b->depthClearValue = (GLdefault) depth;
    DIRTY(bb->dirty, g->neg_bitid);
    DIRTY(bb->clearDepth, g->neg_bitid);
}
void STATE_APIENTRY crStatePolygonOffset (PCRStateTracker pState, GLfloat factor, GLfloat units) 
{
    CRContext *g = GetCurrentContext(pState);
    CRPolygonState *p = &(g->polygon);
        CRStateBits *sb = GetCurrentBits(pState);
    CRPolygonBits *pb = &(sb->polygon);

    if (g->current.inBeginEnd) 
    {
        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
                "glPolygonOffset called in begin/end");
        return;
    }

    FLUSH();

    p->offsetFactor = factor;
    p->offsetUnits = units;

    DIRTY(pb->offset, g->neg_bitid);
    DIRTY(pb->dirty, g->neg_bitid);
}
Exemple #12
0
void GLSTATE_DECL
__glstate_StencilMask (GLuint mask) {
	GLcontext *g = GetCurrentContext();
	GLstencilstate *s = &(g->stencil);
	GLstatebits *stateb = GetStateBits();
	GLstencilbits *sb = &(stateb->stencil);

	/*ECHECK*/
	if (g->current.beginend)
		if (__glerror(__LINE__, __FILE__, GL_INVALID_OPERATION, 
			"glStencilMask called in begin/end"))
			return;

 
		
	/*ECHECK*/

	s->mask = mask;

	sb->writemask = g->nbitID;
	sb->dirty = g->nbitID;
}
Exemple #13
0
void GLSTATE_DECL
__glstate_ClearStencil (GLint c) {
	GLcontext *g = GetCurrentContext();
	GLstencilstate *s = &(g->stencil);
	GLstatebits *stateb = GetStateBits();
	GLstencilbits *sb = &(stateb->stencil);

	/*ECHECK*/
	if (g->current.beginend)
		if (__glerror(__LINE__, __FILE__, GL_INVALID_OPERATION, 
			"glClearStencil called in begin/end"))
			return;

 
		
	/*ECHECK*/

	s->clearvalue = c;
	
	sb->clearvalue = g->nbitID;
	sb->dirty = g->nbitID;
}
void STATE_APIENTRY crStateAlphaFunc (GLenum func, GLclampf ref) 
{
    CRContext *g             = GetCurrentContext();
    CRBufferState *b         = &(g->buffer);
    CRStateBits *sb          = GetCurrentBits();
    CRBufferBits *bb = &(sb->buffer);

    if (g->current.inBeginEnd)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glAlphaFunc called in begin/end");
        return;
    }

    FLUSH();

    switch (func) 
    {
        case GL_NEVER:
        case GL_LESS:
        case GL_EQUAL:
        case GL_LEQUAL:
        case GL_GREATER:
        case GL_GEQUAL:
        case GL_NOTEQUAL:
        case GL_ALWAYS:
            break;
        default:
            crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glAlphaFunc:  Invalid func: %d", func);
            return;
    }

    if (ref < 0.0f) ref = 0.0f;
    if (ref > 1.0f) ref = 1.0f;

    b->alphaTestFunc = func;
    b->alphaTestRef = ref;
    DIRTY(bb->dirty, g->neg_bitid);
    DIRTY(bb->alphaFunc, g->neg_bitid);
}
void STATE_APIENTRY crStateColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) 
{
    CRContext *g = GetCurrentContext();
    CRBufferState *b = &(g->buffer);
    CRStateBits *sp = GetCurrentBits();
    CRBufferBits *bb = &(sp->buffer);

    if (g->current.inBeginEnd)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer called in begin/end");
        return;
    }

    FLUSH();

    b->colorWriteMask.r = red;
    b->colorWriteMask.g = green;
    b->colorWriteMask.b = blue;
    b->colorWriteMask.a = alpha;
    DIRTY(bb->dirty, g->neg_bitid);
    DIRTY(bb->colorWriteMask, g->neg_bitid);
}
Exemple #16
0
void STATE_APIENTRY crStateVertexAttribPointerARB(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *p) 
{
	CRContext *g = GetCurrentContext();
	CRClientState *c = &(g->client);
	CRStateBits *sb = GetCurrentBits();
	CRClientBits *cb = &(sb->client);

	FLUSH();

	if (index > CR_MAX_VERTEX_ATTRIBS)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glVertexAttribPointerARB: invalid index: %d", (int) index);
		return;
	}
	if (size != 1 && size != 2 && size != 3 && size != 4)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glVertexAttribPointerARB: invalid size: %d", size);
		return;
	}
	if (type != GL_BYTE && type != GL_UNSIGNED_BYTE &&
			type != GL_SHORT && type != GL_UNSIGNED_SHORT &&
			type != GL_INT && type != GL_UNSIGNED_INT &&
			type != GL_FLOAT && type != GL_DOUBLE)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glVertexAttribPointerARB: invalid type: 0x%x", type);
		return;
	}
	if (stride < 0) 
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glVertexAttribPointerARB: stride was negative: %d", stride);
		return;
	}

	crStateClientSetPointer(&(c->array.a[index]), size, type, normalized, stride, p);
	DIRTY(cb->dirty, g->neg_bitid);
	DIRTY(cb->clientPointer, g->neg_bitid);
	DIRTY(cb->a[index], g->neg_bitid);
}
void STATE_APIENTRY crStateBlendEquationEXT( GLenum mode )
{
    CRContext *g = GetCurrentContext();
    CRBufferState *b = &(g->buffer);
    CRStateBits *sb = GetCurrentBits();
    CRBufferBits *bb = &(sb->buffer);

    if( g->current.inBeginEnd )
    {
        crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "BlendEquationEXT called inside a Begin/End" );
        return;
    }
    switch( mode )
    {
#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op)
        case GL_FUNC_ADD_EXT:
#ifdef CR_EXT_blend_subtract
        case GL_FUNC_SUBTRACT_EXT:
        case GL_FUNC_REVERSE_SUBTRACT_EXT:
#endif /* CR_EXT_blend_subtract */
#ifdef CR_EXT_blend_minmax
        case GL_MIN_EXT:
        case GL_MAX_EXT:
#endif /* CR_EXT_blend_minmax */
#ifdef CR_EXT_blend_logic_op
        case GL_LOGIC_OP:
#endif /* CR_EXT_blend_logic_op */
            b->blendEquation = mode;
            break;
#endif /* defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) */
        default:
            crStateError( __LINE__, __FILE__, GL_INVALID_ENUM,
                "BlendEquationEXT: mode called with illegal parameter: 0x%x", (GLenum) mode );
            return;
    }
    DIRTY(bb->blendEquation, g->neg_bitid);
    DIRTY(bb->dirty, g->neg_bitid);
}
void CContextManager::DestroyState(CState* pState)
{
	for (unsigned int i = 0; i < m_contexts.size(); i++)
	{
		if (m_contexts[i] != pState)
			continue;

		m_contexts.erase(m_contexts.begin() + i);
		if ((int)i < m_current_context)
			m_current_context--;
		else if ((int)i == m_current_context)
		{
			if (i >= m_contexts.size())
				m_current_context--;
			NotifyHandlers(GetCurrentContext(), STATECHANGE_CHANGEDCONTEXT, _T(""), 0, false);
		}

		break;
	}

	NotifyHandlers(pState, STATECHANGE_REMOVECONTEXT, _T(""), 0, false);
	delete pState;
}
Exemple #19
0
void crStateDestroyContext( CRContext *ctx )
{
    CRContext *current = GetCurrentContext();

    if (current == ctx) {
        /* destroying the current context - have to be careful here */
        CRASSERT(defaultContext);
        /* Check to see if the differencer exists first,
           we may not have one, aka the packspu */
        if (diff_api.AlphaFunc)
            crStateSwitchContext(current, defaultContext);
#ifdef CHROMIUM_THREADSAFE
        crSetTSD(&__contextTSD, defaultContext);
#else
        __currentContext = defaultContext;
#endif
        /* ensure matrix state is also current */
        crStateMatrixMode(defaultContext->transform.matrixMode);
    }
    g_availableContexts[ctx->id] = 0;

    crStateFreeContext(ctx);
}
DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateShader(GLuint hwid, GLenum type)
{
    CRGLSLShader *pShader;
    CRContext *g = GetCurrentContext();
    GLuint stateId = hwid;

#ifdef IN_GUEST
    CRASSERT(!crStateGetShaderObj(stateId));
#else
    /* the id may not necesserily be hwid after save state restoration */
    while ((pShader = crStateGetShaderObj(stateId)) != NULL)
    {
        GLuint newStateId = stateId + 7;
        crDebug("Shader object %d already exists, generating a new one, %d", stateId, newStateId);
        stateId = newStateId;
    }
#endif

    pShader = (CRGLSLShader *) crAlloc(sizeof(*pShader));
    if (!pShader)
    {
        crWarning("crStateCreateShader: Out of memory!");
        return 0;
    }

    pShader->id = stateId;
    pShader->hwid = hwid;
    pShader->type = type;
    pShader->source = NULL;
    pShader->compiled = GL_FALSE;
    pShader->deleted = GL_FALSE;
    pShader->refCount = 0;

    crHashtableAdd(g->glsl.shaders, stateId, pShader);

    return stateId;
}
void STATE_APIENTRY crStateCombinerStageParameterfvNV( GLenum stage, GLenum pname, const GLfloat *params )
{
	CRContext *g = GetCurrentContext();
	CRRegCombinerState *r = &(g->regcombiner);
	CRStateBits *sb = GetCurrentBits();
	CRRegCombinerBits *rb = &(sb->regcombiner);
	
	stage -= GL_COMBINER0_NV;
	if( stage >= g->limits.maxGeneralCombiners )
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerStageParameterfvNV passed bogus stage: 0x%x", stage+GL_COMBINER0_NV );
		return;
	}
	
	switch( pname )
	{
		case GL_CONSTANT_COLOR0_NV:
			r->stageConstantColor0[stage].r = params[0];
			r->stageConstantColor0[stage].g = params[1];
			r->stageConstantColor0[stage].b = params[2];
			r->stageConstantColor0[stage].a = params[3];
			DIRTY(rb->regCombinerStageColor0[stage], g->neg_bitid);
			break;
		case GL_CONSTANT_COLOR1_NV:
			r->stageConstantColor1[stage].r = params[0];
			r->stageConstantColor1[stage].g = params[1];
			r->stageConstantColor1[stage].b = params[2];
			r->stageConstantColor1[stage].a = params[3];
			DIRTY(rb->regCombinerStageColor1[stage], g->neg_bitid);
			break;
		default:
			crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerStageParameter passed bogus pname: 0x%x", pname );
			return;
	}

	DIRTY(rb->dirty, g->neg_bitid);
}
Exemple #22
0
void GLSTATE_DECL
__glstate_StencilFunc(GLenum func, GLint ref, GLuint mask) {
	GLcontext *g = GetCurrentContext();
	GLstencilstate *s = &(g->stencil);
	GLstatebits *stateb = GetStateBits();
	GLstencilbits *sb = &(stateb->stencil);

	/*ECHECK*/
	if (g->current.beginend)
		if (__glerror(__LINE__, __FILE__, GL_INVALID_OPERATION, 
			"glStencilFunc called in begin/end"))
			return;

 
		

	if (func != GL_NEVER &&
		func != GL_LESS &&
		func != GL_LEQUAL &&
		func != GL_GREATER &&
		func != GL_GEQUAL &&
		func != GL_EQUAL &&
		func != GL_NOTEQUAL &&
		func != GL_ALWAYS)
		if (__glerror(__LINE__, __FILE__, GL_INVALID_ENUM, 
			"glStencilFunc called with bogu func: %d", func))
			return;
	/*ECHECK*/

	s->func = func;
	s->ref = ref;
	s->mask = mask;

	sb->func = g->nbitID;
	sb->dirty = g->nbitID;
}
Exemple #23
0
/**
 *  \brief Delete the currently active key to action mapping
 *
 *   TODO FIXME This code needs work to support deleteKey
 *              in any mode exc. Context/Action
 */
void MythControls::DeleteKey(void)
{
    QString context = GetCurrentContext();
    QString key     = GetCurrentKey();
    QString action  = GetCurrentAction();

    if (context.isEmpty() || key.isEmpty() || action.isEmpty())
    {
        LOG(VB_GENERAL, LOG_ERR,
            "Unable to delete binding, missing information");
        return;
    }

    if (m_bindings->RemoveActionKey(context, action, key))
    {
        RefreshKeyInformation();
        return;
    }

    QString label = tr("This action is mandatory and needs at least one key "
                       "bound to it. Instead, try rebinding with another key.");

    MythScreenStack *popupStack =
                            GetMythMainWindow()->GetStack("popup stack");

    MythConfirmationDialog *confirmPopup =
            new MythConfirmationDialog(popupStack, label, false);

    if (confirmPopup->Create())
    {
        confirmPopup->SetReturnEvent(this, "mandatorydelete");
        popupStack->AddScreen(confirmPopup);
    }
    else
        delete confirmPopup;
}
Exemple #24
0
/**
 *  \brief Updates the list of keys that are shown and the
 *         description of the action.
 */
void MythControls::RefreshKeyInformation(void)
{
    for (uint i = 0; i < Action::kMaximumNumberOfBindings; i++)
        m_actionButtons.at(i)->SetText("");

    if (GetFocusWidget() == m_leftList)
    {
        m_description->Reset();
        return;
    }

    const QString context = GetCurrentContext();
    const QString action  = GetCurrentAction();

    QString desc = m_bindings->GetActionDescription(context, action);
    m_description->SetText(tr(desc.toLatin1().constData()));

    QStringList keys = m_bindings->GetActionKeys(context, action);
    for (int i = 0; (i < keys.count()) &&
             (i < (int)Action::kMaximumNumberOfBindings); i++)
    {
        m_actionButtons.at(i)->SetText(keys[i]);
    }
}
Exemple #25
0
void STATE_APIENTRY
crStateGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
{
	CRContext *g = GetCurrentContext();
	CROcclusionState *o = &(g->occlusion);
	CROcclusionObject *q;

	FLUSH();

	if (g->current.inBeginEnd) {
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
								 "glGetGetQueryObjectuivARB called in begin/end");
		return;
	}

	q = (CROcclusionObject *) crHashtableSearch(o->objects, id);
	if (!q || q->active) {
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
								"glGetQueryObjectuivARB");
		return;
	}

	switch (pname) {
	case GL_QUERY_RESULT_ARB:
		*params = q->passedCounter;
		break;
	case GL_QUERY_RESULT_AVAILABLE_ARB:
		/* XXX revisit when we have a hardware implementation! */
		*params = GL_TRUE;
		break;
	default:
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
								 "glGetQueryObjectuivARB(pname)");
		return;
   }
}
Exemple #26
0
void STATE_APIENTRY crStateGetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer)
{
	CRContext *g = GetCurrentContext();

	if (g->current.inBeginEnd) {
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
								 "glGetVertexAttribPointervNV called in Begin/End");
		return;
	}

	if (index >= CR_MAX_VERTEX_ATTRIBS) {
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
								 "glGetVertexAttribPointervNV(index)");
		return;
	}

	if (pname != GL_ATTRIB_ARRAY_POINTER_NV) {
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
								 "glGetVertexAttribPointervNV(pname)");
		return;
	}

	*pointer = g->client.array.a[index].p;
}
void crStateRegRenderbuffers(GLsizei n, GLuint *buffers)
{
    CRContext *g = GetCurrentContext();
    crStateRegNames(g, g->shared->rbTable, n, buffers);
}
void STATE_APIENTRY crStateGenRenderbuffersEXT(GLsizei n, GLuint *buffers)
{
    CRContext *g = GetCurrentContext();
    crStateGenNames(g, g->shared->rbTable, n, buffers);
}
void STATE_APIENTRY crStateFogfv(PCRStateTracker pState, GLenum pname, const GLfloat *param) 
{
	CRContext *g = GetCurrentContext(pState);
	CRFogState *f = &(g->fog);
	CRStateBits *sb = GetCurrentBits(pState);
	CRFogBits *fb = &(sb->fog);

	if (g->current.inBeginEnd)
	{
		crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glFogfv called in Begin/End");
		return;
	}

	FLUSH();

	switch (pname) 
	{
		case GL_FOG_MODE:
			{
				GLenum e = (GLenum) *param;
				if (e != GL_LINEAR && e != GL_EXP && e != GL_EXP2)
				{
					crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid param for glFog: %d", e);
					return;
				}
				f->mode = e;
				DIRTY(fb->mode, g->neg_bitid);
			}
			break;
		case GL_FOG_DENSITY:
			f->density = *param;
			if (f->density < 0.0f)
			{
				f->density = 0.0f;
			}
			DIRTY(fb->density, g->neg_bitid);
			break;
		case GL_FOG_START:
			f->start = *param;
			DIRTY(fb->start, g->neg_bitid);
			break;
		case GL_FOG_END:
			f->end = *param;
			DIRTY(fb->end, g->neg_bitid);
			break;
		case GL_FOG_INDEX:
			f->index = (GLint) *param;
			DIRTY(fb->index, g->neg_bitid);
			break;
		case GL_FOG_COLOR:
			f->color.r = param[0];
			f->color.g = param[1];
			f->color.b = param[2];
			f->color.a = param[3];
			DIRTY(fb->color, g->neg_bitid);
			break;
#ifdef CR_NV_fog_distance
		case GL_FOG_DISTANCE_MODE_NV:
			if (g->extensions.NV_fog_distance)
			{
				if (param[0] != GL_EYE_RADIAL_NV &&
					param[0] != GL_EYE_PLANE &&
					param[0] != GL_EYE_PLANE_ABSOLUTE_NV )
				{
					crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
						"Fogfv: GL_FOG_DISTANCE_MODE_NV called with illegal parameter: 0x%x", (GLenum) param[0]);
					return;
				}
				f->fogDistanceMode = (GLenum) param[0];
				DIRTY(fb->fogDistanceMode, g->neg_bitid);
			}
			else
			{
				crStateError(pState, __LINE__, __FILE__, GL_INVALID_VALUE, "Invalid glFog Param: %d", param);
				return;
			}
			break;
#endif
#ifdef CR_EXT_fog_coord
		case GL_FOG_COORDINATE_SOURCE_EXT:
			if (g->extensions.EXT_fog_coord)
			{
				if ((GLenum) param[0] != GL_FOG_COORDINATE_EXT &&
						(GLenum) param[0] != GL_FRAGMENT_DEPTH_EXT)
				{
					crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
						"Fogfv: GL_FOG_COORDINATE_SOURCE_EXT called with illegal parameter: 0x%x", (GLenum) param[0]);
					return;
				}
				f->fogCoordinateSource = (GLenum) param[0];
				DIRTY(fb->fogCoordinateSource, g->neg_bitid);
			}
			else
			{
				crStateError(pState, __LINE__, __FILE__, GL_INVALID_VALUE, "Invalid glFog Param: 0x%x", (GLint) param[0]);
				return;
			}
			break;
#endif
		default:
			crStateError(pState, __LINE__, __FILE__, GL_INVALID_VALUE, "Invalid glFog Param: %d", param);
			return;
	}
	DIRTY(fb->dirty, g->neg_bitid);
}
Exemple #30
0
CRContext *crStateGetCurrent(void)
{
    return GetCurrentContext();
}