server_context.c revision 113e32cd5ad8ef067495b103da706e9494d30d37
/* 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;
}
* 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) {
if (cr_server.SpuContext < 0) {
crWarning("crServerDispatchCreateContext() failed.");
return -1;
}
}
else {
/* second or third or ... context */
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 */
/* destroy old rendering context */
if (cr_server.SpuContext < 0) {
crWarning("crServerDispatchCreateContext() failed.");
return -1;
}
}
}
/* Now create a new state-tracker context and initialize the
* dispatch function pointers.
*/
if (newCtx) {
}
int pos;
break;
}
}
}
{
/* As we're using only one host context to serve all client contexts, newly created context will still
* hold last error value from any previous failed opengl call. Proper solution would be to redirect any
* client glGetError calls to our state tracker, but right now it's missing quite a lot of checks and doesn't
* reflect host driver/gpu specific issues. Thus we just reset last opengl error at context creation.
*/
if (err!=GL_NO_ERROR)
{
#ifdef DEBUG_misha
#else
#endif
}
}
return retVal;
}
{
int pos;
{
{
return true;
}
}
return false;
}
{
int found=false;
if (!crCtx) {
return;
}
{
/* 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)
{
{
}
}
}
{
if (!mural)
{
return;
}
/* Update the state tracker's current context */
if (!ctx) {
return;
}
}
else {
{
{
}
{
}
}
window = -1;
return;
}
/* Ubuntu 11.04 hosts misbehave if context window switch is
* done with non-default framebuffer object settings.
* crStateSwichPrepare & crStateSwichPostprocess are supposed to work around this problem
* crStateSwichPrepare restores the FBO state to its default values before the context window switch,
* while crStateSwichPostprocess restores it back to the original values */
/*
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.
*/
}
/* This used to be earlier, after crStateUpdateColorBits() call */
{
{
cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, mural->bUseFBO ? mural->idFBO:0);
}
{
cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, mural->bUseFBO ? mural->idFBO:0);
}
}
{
}
else
{
}
}