server_context.c revision 6cc021fd3b938167e394bcc965950905e190b53c
/* Copyright (c) 2001, Stanford University
* All rights reserved.
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "cr_spu.h"
#include "chromium.h"
#include "cr_error.h"
#include "cr_net.h"
#include "cr_rand.h"
#include "server_dispatch.h"
#include "server.h"
#include "cr_mem.h"
#include "cr_string.h"
{
}
GLint crServerDispatchCreateContextEx(const char *dpyName, GLint visualBits, GLint shareCtx, GLint preloadCtxID, int32_t internalID)
{
if (shareCtx > 0) {
crWarning("CRServer: context sharing not implemented.");
shareCtx = 0;
}
if (!pContextInfo)
{
crWarning("failed to alloc context info!");
return -1;
}
* one outgoing GL stream, we only need to create one context for the
* head SPU. We'll only have to make it current once too, below.
*/
if (cr_server.firstCallCreateContext) {
crWarning("crServerDispatchCreateContext() failed.");
return -1;
}
}
else {
/* second or third or ... context */
if (!cr_server.bUseMultipleContexts && ((visualBits & cr_server.MainContextInfo.CreateInfo.visualBits) != visualBits)) {
int oldSpuContext;
/* the new context needs new visual attributes */
crDebug("crServerDispatchCreateContext requires new visual (0x%x).",
/* Here, we used to just destroy the old rendering context.
* Unfortunately, this had the side effect of destroying
* all display lists and textures that had been loaded on
* the old context as well.
*
* Now, first try to create a new context, with a suitable
* visual, sharing display lists and textures with the
* old context. Then destroy the old context.
*/
/* create new rendering context with suitable visual */
CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.visualBits, cr_server.MainContextInfo.SpuContext);
/* destroy old rendering context */
crWarning("crServerDispatchCreateContext() failed.");
return -1;
}
}
}
if (cr_server.bUseMultipleContexts) {
CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.visualBits, cr_server.MainContextInfo.SpuContext);
if (pContextInfo->SpuContext < 0) {
crWarning("crServerDispatchCreateContext() failed.");
if (!fFirst)
crError("creating shared context failed, while it is expected to work!");
}
else if (fFirst)
{
}
}
else
{
}
/* Now create a new state-tracker context and initialize the
* dispatch function pointers.
*/
if (newCtx) {
}
int pos;
break;
}
}
}
return retVal;
}
{
int pos;
{
{
return true;
}
}
return false;
}
{
}
{
int found=false;
if (!crCtxInfo) {
return;
}
{
}
if (crCtxInfo->SpuContext >= 0)
{
/* If we delete our current context, default back to the null context */
}
/*Some application call destroy context not in a thread where it was created...have do deal with it.*/
if (!found)
{
{
continue;
if (found) break;
}
}
if (!found)
{
{
}
}
}
/*Make sure this context isn't active in other clients*/
{
{
}
}
while (pNode)
{
{
}
}
}
{
/* Ubuntu 11.04 hosts misbehave if context window switch is
* done with non-default framebuffer object settings.
* crStateSwitchPrepare & crStateSwitchPostprocess are supposed to work around this problem
* crStateSwitchPrepare restores the FBO state to its default values before the context window switch,
* while crStateSwitchPostprocess restores it back to the original values */
oldCtx = crStateGetCurrent();
{
}
else
{
idDrawFBO = 0;
idReadFBO = 0;
}
/*
crDebug("**** %s client %d curCtx=%d curWin=%d", __func__,
cr_server.curClient->number, ctxPos, window);
*/
/* This is a hack to force updating the 'current' attribs */
if (ctx)
/* check if being made current for first time, update viewport */
#if 0
if (ctx) {
/* initialize the viewport */
}
}
#endif
/*
crDebug("**** %s currentWindow %d newWindow %d", __func__,
cr_server.currentWindow, window);
*/
if (1/*cr_server.firstCallMakeCurrent ||
cr_server.currentWindow != window ||
cr_server.currentNativeWindow != nativeWindow*/) {
* one output stream of GL commands, we only need to call the head
* SPU's MakeCurrent() function once.
* BUT, if we're rendering to multiple windows, we do have to issue
* MakeCurrent() calls sometimes. The same GL context will always be
* used though.
*/
0,
ctxInfo->SpuContext >= 0
if (cr_server.currentCtxInfo)
}
/* This used to be earlier, after crStateUpdateColorBits() call */
{
{
crWarning("DBO draw buffer changed on make current");
}
{
crWarning("DBO read buffer changed on make current");
}
}
else
{
idDrawFBO = 0;
idReadFBO = 0;
}
crStateSwitchPostprocess(ctx, cr_server.bUseMultipleContexts ? NULL : oldCtx, idDrawFBO, idReadFBO);
{
}
else
{
}
}
{
if (!mural)
{
return;
}
/* Update the state tracker's current context */
if (!ctxInfo) {
return;
}
}
else {
#if 0
{
{
}
{
}
}
window = -1;
#endif
return;
}
}