Example #1
0
static void
UninitContexts (void)
{
	UninitQueue (&disp_q);

	DestroyContext (OffScreenContext);
	DestroyContext (SpaceContext);
	DestroyContext (StatusContext);
}
Example #2
0
void AndroidEGL::Terminate()
{
	ResetDisplay();
	DestroyContext(PImplData->SharedContext.eglContext);
	PImplData->SharedContext.Reset();
	DestroyContext(PImplData->RenderingContext.eglContext);
	PImplData->RenderingContext.Reset();
	DestroyContext(PImplData->SingleThreadedContext.eglContext);
	PImplData->SingleThreadedContext.Reset();
	DestroySurface();
	TerminateEGL();
}
Example #3
0
GLX::~GLX()
{
  if (mDisplay) {
    MakeCurrent(mDisplay, 0, 0);
  }

  if (mContext) {
    DestroyContext(mDisplay, mContext);
  }

  if (mGLXPixmap) {
    DestroyGLXPixmap(mDisplay, mGLXPixmap);
  }

  if (mPixmap) {
    XFreePixmap(mDisplay, mPixmap);
  }

  if (mDisplay) {
    XCloseDisplay(mDisplay);
  }

  if (mLibGL) {
    dlclose(mLibGL);
  }
}
Example #4
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
{
	g_hInstance = hInstance;

	InitializeContext();
	InitializeWindow();

	g_VkSwapchain.Initialize();
	g_VkSwapchain.InitializeSwapchain(kScreenWidth, kScreenHeight, false);

	InitializeRenderSettings();

	while (true)
	{
		PollEvents();

		if (g_CloseRequest)
		{
			break;
		}

		DrawScene();
	}

	DestroyRenderSettings();
	g_VkSwapchain.Destroy();
	DestroyWindow();
	DestroyContext();
	return 0;
}
Example #5
0
void MFSound_DeinitModulePlatformSpecific()
{
	MFCALLSTACK;

	// TODO: remove this, user will control contexts
	DestroyContext(gpCurrentContext);
}
Example #6
0
static void
DestroyPlanetContext (void)
{
	if (PlanetContext)
	{
		DestroyContext (PlanetContext);
		PlanetContext = NULL;
	}
}
Example #7
0
static void
Instance_DidChangeView(PP_Instance instance,
		       const struct PP_Rect* position,
		       const struct PP_Rect* clip)
{
  if (position->size.width == screenWidth &&
      position->size.height == screenHeight)
    return;  // Size didn't change, no need to update anything.
  Log("change view\n");
  DestroyContext(instance);
  CreateContext(instance, &position->size);
}
GalliumContext::~GalliumContext()
{
	CALLED();

	// Destroy our contexts
	Lock();
	for (context_id i = 0; i < CONTEXT_MAX; i++)
		DestroyContext(i);
	Unlock();

	pipe_mutex_destroy(fMutex);

	// TODO: Destroy fScreen
}
Example #9
0
//\brief
//	initialize the gl extension functions address.
static bool InitializeGlew()
{
	GLenum err;
	GLContext ctx;

	/* create OpenGL rendering context */
	InitContext(&ctx);
	if (GL_TRUE == CreateContext(&ctx))
	{
		std::cout << "Error: CreateContext failed" << std::endl;
		DestroyContext(&ctx);
		return false;
	}

	/* initialize GLEW */
	glewExperimental = GL_TRUE;
#ifdef GLEW_MX
	err = glewContextInit(glewGetContext());
#  ifdef _WIN32
	err = err || wglewContextInit(wglewGetContext());
#  elif !defined(__APPLE__) && !defined(__HAIKU__) || defined(GLEW_APPLE_GLX)
	err = err || glxewContextInit(glxewGetContext());
#  endif
#else
	err = glewInit();
#endif
	if (GLEW_OK != err)
	{
		std::cout << "Error [main]: glewInit failed: " << glewGetErrorString(err) << std::endl;
		DestroyContext(&ctx);
		return false;
	}

	DestroyContext(&ctx);
	return true;
}
Example #10
0
void
FreeKernel (void)
{
	UninitKernel (TRUE);
	UninitContexts ();

	UninitResourceSystem ();

	UninitPlayerInput ();

	DestroyDrawable (ReleaseDrawable (Screen));
	DestroyContext (ScreenContext);

	UninitVideoPlayer ();
	UninitSound ();
	UninitGraphics ();
}
Example #11
0
  void GboxInstance::DidChangeView(const pp::Rect& position,
                                  const pp::Rect& clip) {
    if (position.size().width() == width() &&
        position.size().height() == height())
      return;  // Size didn't change, no need to update anything.

    // Create a new device context with the new size.
    DestroyContext();
    CreateContext(position.size());
    // Delete the old pixel buffer and create a new one.
    ScopedMutexLock scoped_mutex(&pixel_buffer_mutex_);
    delete pixel_buffer_;
    pixel_buffer_ = NULL;
    if (graphics_2d_context_ != NULL) {
      pixel_buffer_ = new pp::ImageData(this,
                                        PP_IMAGEDATAFORMAT_BGRA_PREMUL,
                                        graphics_2d_context_->size(),
                                        false);
    }
  }
Example #12
0
BOOL CTcpEpollServer::EpollAcceptSocket(SOCKET hSocket, const sockaddr_in& SockAddr)
{
	if(INVALID_SOCKET == hSocket)
		return FALSE;

    // 设置程非阻塞式SOCKET
    if (!SetNonblock(hSocket, TRUE))
    {
        return FALSE;
    }

	// 回调上层创建context
	CTcpContext *pContext = CreateContext();
	if (pContext == NULL)
	{
		return FALSE;
	}

	// Context 赋值
	pContext->m_hSocket = hSocket;
	memcpy(&pContext->m_oSocketAddr, &SockAddr, sizeof(sockaddr_in));

	// 添加至队列
	AddTcpContext(pContext);

	struct epoll_event ev;
	ev.events	= EPOLLIN | EPOLLOUT | EPOLLET;  //ET模式+读事件+写事件
	ev.data.ptr = (void*)pContext;
	if (epoll_ctl(m_hEpollHandle, EPOLL_CTL_ADD, hSocket, &ev) < 0)
	{
		RemoveTcpContext(pContext);
		DestroyContext(pContext);
		return FALSE;
	}

	return TRUE;
}
Example #13
0
LRESULT CALLBACK WndProc(
	HWND hWnd,
	UINT nMessage,
	WPARAM wParam,
	LPARAM lParam
	)
{
	RECT ClientRect;
	switch (nMessage)
	{
	case WM_CREATE_IRC_WINDOW:
		if (Hash_Get(pHash, (char*)wParam))
		{
			ContextIRC.hCurrentWindow = Hash_Get(pHash, (char*)wParam);
		}
		else
		{
			static HWND __hWnd__;
			__hWnd__ = Create_Window(__hWnd__, hWnd);
			if (((char*)wParam)[0] == '#')
			{
				ShowWindow(ContextIRC.hCurrentWindow, SW_HIDE);
				ContextIRC.hCurrentWindow = __hWnd__;
				strArray_Add(ChannelNames, szChannel);
				Hash_Insert(pHash, ContextIRC.hCurrentWindow, (char*)wParam);
				ShowWindow(Hash_Get(pHash, (char*)wParam), SW_SHOW);
				ResizeWindows(ContextIRC.dwOldWidth, ContextIRC.dwOldHeight);
				SendMessage(ContextIRC.hCurrentWindow, WM_SETFONT, (WPARAM)ContextIRC.hFont, (LPARAM)TRUE);
			}
			else
			{
				ContextIRC.hCurrentWindow = Array_Index(pArray, Array_Num(pArray));
				ContextIRC.hCurrentWindow = __hWnd__;
				Hash_Insert(pHash, ContextIRC.hCurrentWindow, (char*)wParam);
				ResizeWindows(ContextIRC.dwOldWidth, ContextIRC.dwOldHeight);
				SendMessage(ContextIRC.hCurrentWindow, WM_SETFONT, (WPARAM)ContextIRC.hFont, (LPARAM)TRUE);
			}
			ContextIRC.hCurrentWindow = Array_Index(pArray, Array_Num(pArray));
			Hash_Insert(pHash, ContextIRC.hCurrentWindow, (char*)wParam);
			SendMessage(ContextIRC.hCurrentWindow, WM_SETFONT, (WPARAM)ContextIRC.hFont, (LPARAM)TRUE);
			break;
	}
	case WM_CREATE:
		pArray = Array_Init(pArray);
		ContextIRC.hCurrentWindow = Create_Window(ContextIRC.hCurrentWindow, hWnd);
		ContextIRC.hFont = InitFont(ContextIRC.hCurrentWindow);
		ContextIRC.hTypeBuffer = InitTypeBuffer(ContextIRC.hFont, hWnd);
		ContextIRC.hParentProc = SetWindowLongPtr(ContextIRC.hTypeBuffer, GWL_WNDPROC, (LONG_PTR)TypeBufferProc);
		ContextIRC.hNetworkThread = CreateThread(NULL, 0, Connect, NULL, 0, &ContextIRC.hNetworkThreadID);
		break;
	case WM_DESTROY:
		DestroyContext();
		PostQuitMessage(0);
		break;
	case WM_HOTKEY:
	{
					  register uint32_t nIndex = 0;
					  if (wParam == IRCContext->LeftKey)
					  {
						  if (Array_Num(pArray) <= 0)
							  break;
						  for (nIndex = Array_Num(pArray); nIndex > 0; nIndex--)
						  {
							  if (ContextIRC.hCurrentWindow == Array_Index(pArray, 0))
							  {
								  ShowWindow(ContextIRC.hCurrentWindow, SW_HIDE);
								  ContextIRC.hCurrentWindow = Array_Index(pArray, Array_Num(pArray));

								  strcpy_s(szChannel, 96, strArray_Index(ChannelNames, strArray_Num(ChannelNames)));
								  
								  ShowWindow(ContextIRC.hCurrentWindow, SW_SHOW);
								  MoveWindow(ContextIRC.hCurrentWindow, 0, 0, ContextIRC.dwOldWidth, ContextIRC.dwOldHeight, TRUE);
								  break;
							  }
							  nIndex--;
							  ShowWindow(ContextIRC.hCurrentWindow, SW_HIDE);
							  ContextIRC.hCurrentWindow = Array_Index(pArray, nIndex);

							  strcpy_s(szChannel, 96, strArray_Index(ChannelNames, nIndex - 1));

							  ShowWindow(ContextIRC.hCurrentWindow, SW_SHOW);
							  MoveWindow(ContextIRC.hCurrentWindow, 0, 0, ContextIRC.dwOldWidth, ContextIRC.dwOldHeight, TRUE);
							  break;
						  }
					  }
					  if (wParam == IRCContext->RightKey)
					  {
						  for (nIndex = 0; nIndex <= Array_Num(pArray); nIndex++)
						  {
							  if (Array_Num(pArray) <= 0)
								  break;
							  if (ContextIRC.hCurrentWindow == Array_Index(pArray, nIndex))
							  {
								  if (ContextIRC.hCurrentWindow == Array_Index(pArray, Array_Num(pArray)))
								  {
									  ShowWindow(ContextIRC.hCurrentWindow, SW_HIDE);
									  ContextIRC.hCurrentWindow = Array_Index(pArray, 0);

									  strcpy_s(szChannel, 96, strArray_Index(ChannelNames, 0));

									  ShowWindow(ContextIRC.hCurrentWindow, SW_SHOW);
									  MoveWindow(ContextIRC.hCurrentWindow, 0, 0, ContextIRC.dwOldWidth, ContextIRC.dwOldHeight, TRUE);
									  break;
								  }
								  nIndex++;
								  ShowWindow(ContextIRC.hCurrentWindow, SW_HIDE);
								  ContextIRC.hCurrentWindow = Array_Index(pArray, nIndex);

								  strcpy_s(szChannel, 96, strArray_Index(ChannelNames, nIndex - 1));

								  ShowWindow(ContextIRC.hCurrentWindow, SW_SHOW);
								  MoveWindow(ContextIRC.hCurrentWindow, 0, 0, ContextIRC.dwOldWidth, ContextIRC.dwOldHeight, TRUE);
								  break;
							  }
						  }
					  }
					  break;
	}
	case WM_SIZE:
		ResizeWindows(LOWORD(lParam), HIWORD(lParam) - IRCContext->nTypeHeight);
		GetClientRect(hWnd, &ClientRect);
		ContextIRC.dwOldWidth = LOWORD(lParam);
		ContextIRC.dwOldHeight = HIWORD(lParam);
		MoveWindow(ContextIRC.hTypeBuffer, 0, ClientRect.bottom - IRCContext->nTypeHeight, LOWORD(lParam), IRCContext->nTypeHeight, TRUE);
		break;
	default:
		return DefWindowProc(hWnd, nMessage, wParam, lParam);
	}
	return 0;
}
Example #14
0
int
main (int argc, char** argv)
{
  GLenum err;
  GLContext ctx;

  /* ---------------------------------------------------------------------- */
  /* parse arguments */
  if (GL_TRUE == ParseArgs(argc-1, argv+1))
  {
#if defined(_WIN32)
    fprintf(stderr, "Usage: visualinfo [-a] [-s] [-h] [-pf <id>]\n");
    fprintf(stderr, "        -a: show all visuals\n");
    fprintf(stderr, "        -s: display to stdout instead of visualinfo.txt\n");
    fprintf(stderr, "        -pf <id>: use given pixelformat\n");
    fprintf(stderr, "        -h: this screen\n");
#else
    fprintf(stderr, "Usage: visualinfo [-h] [-display <display>] [-visual <id>]\n");
    fprintf(stderr, "        -h: this screen\n");
    fprintf(stderr, "        -display <display>: use given display\n");
    fprintf(stderr, "        -visual <id>: use given visual\n");
#endif
    return 1;
  }

  /* ---------------------------------------------------------------------- */
  /* create OpenGL rendering context */
  InitContext(&ctx);
  if (GL_TRUE == CreateContext(&ctx))
  {
    fprintf(stderr, "Error: CreateContext failed\n");
    DestroyContext(&ctx);
    return 1;
  }

  /* ---------------------------------------------------------------------- */
  /* initialize GLEW */
  glewExperimental = GL_TRUE;
#ifdef GLEW_MX
  err = glewContextInit(glewGetContext());
#  ifdef _WIN32
  err = err || wglewContextInit(wglewGetContext());
#  elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
  err = err || glxewContextInit(glxewGetContext());
#  endif
#else
  err = glewInit();
#endif
  if (GLEW_OK != err)
  {
    fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
    DestroyContext(&ctx);
    return 1;
  }

  /* ---------------------------------------------------------------------- */
  /* open file */
#if defined(_WIN32)
  if (!displaystdout)
    file = fopen("visualinfo.txt", "w");
  if (file == NULL)
    file = stdout;
#else
  file = stdout;
#endif

  /* ---------------------------------------------------------------------- */
  /* output header information */
  /* OpenGL extensions */
  fprintf(file, "OpenGL vendor string: %s\n", glGetString(GL_VENDOR));
  fprintf(file, "OpenGL renderer string: %s\n", glGetString(GL_RENDERER));
  fprintf(file, "OpenGL version string: %s\n", glGetString(GL_VERSION));
  fprintf(file, "OpenGL extensions (GL_): \n");
  PrintExtensions((char*)glGetString(GL_EXTENSIONS));
  /* GLU extensions */
  fprintf(file, "GLU version string: %s\n", gluGetString(GLU_VERSION));
  fprintf(file, "GLU extensions (GLU_): \n");
  PrintExtensions((char*)gluGetString(GLU_EXTENSIONS));

  /* ---------------------------------------------------------------------- */
  /* extensions string */
#if defined(_WIN32)
  /* WGL extensions */
  if (WGLEW_ARB_extensions_string || WGLEW_EXT_extensions_string)
  {
    fprintf(file, "WGL extensions (WGL_): \n");
    PrintExtensions(wglGetExtensionsStringARB ?
                    (char*)wglGetExtensionsStringARB(ctx.dc) :
            (char*)wglGetExtensionsStringEXT());
  }
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)

#else
  /* GLX extensions */
  fprintf(file, "GLX extensions (GLX_): \n");
  PrintExtensions(glXQueryExtensionsString(glXGetCurrentDisplay(),
                                           DefaultScreen(glXGetCurrentDisplay())));
#endif

  /* ---------------------------------------------------------------------- */
  /* enumerate all the formats */
  VisualInfo(&ctx);

  /* ---------------------------------------------------------------------- */
  /* release resources */
  DestroyContext(&ctx);
  if (file != stdout)
    fclose(file);
  return 0;
}
void 
CipherContext::InitContext(
	PGPdiskEncryptionAlgorithm	algorithm, 
	const PGPUInt8				*key, 
	const PGPUInt8				*salt)
{
	PGPUInt32 i;

	pgpAssert(algorithm != kInvalidEncryptionAlgorithm);

	DestroyContext();
	mAlgorithm = algorithm;

	switch (mAlgorithm)
	{

	case kBrokenCASTEncryptionAlgorithm:
		pgpAssertAddrValid(salt, PGPUInt8);
		pgpAssertAddrValid(key, PGPUInt8);

		pgpCopyMemory(salt, mSalt.saltBytes, sizeof(mSalt.saltBytes));
		pgpCopyMemory(key, mCastCFB.expandedKey.keyBytes, 16);

#if PGP_USE_ASSEMBLY

		// The key schedule for assembly must be slightly different. The
		// rotate subkeys (every second word) must be XORed with 16. This
		// swaps the halves of some words internally in a way that the code
		// expects. Don't forget this!

		for (i=0; i<32; i+=2)
		{
			mCastCFB.expandedKey.keyDWords[i+1] = 
				mCastCFB.expandedKey.keyDWords[i+1] ^ 16;
		}

#else	// ] !PGP_USE_ASSEMBLY

		i;	// get rid of unreferenced local variable error

#endif	// ] PGP_USE_ASSEMBLY

		mInitialized = TRUE;
		break;

	case kCASTEncryptionAlgorithm:
		pgpAssertAddrValid(salt, PGPUInt8);
		pgpAssertAddrValid(key, PGPUInt8);

		pgpCopyMemory(salt, mSalt.saltBytes, sizeof(mSalt.saltBytes));

		// Expand the key.
		CAST5schedule(mCastCFB.expandedKey.keyDWords, key);

#if PGP_USE_ASSEMBLY

		// The key schedule for assembly must be slightly different. The
		// rotate subkeys (every second word) must be XORed with 16. This
		// swaps the halves of some words internally in a way that the code
		// expects. Don't forget this!

		for (i=0; i<32; i+=2)
		{
			mCastCFB.expandedKey.keyDWords[i+1] = 
				mCastCFB.expandedKey.keyDWords[i+1] ^ 16;
		}

#else	// ] !PGP_USE_ASSEMBLY

		i;	// get rid of unreferenced local variable error

#endif	// ] PGP_USE_ASSEMBLY

		mInitialized = TRUE;
		break;

	case kCopyDataEncryptionAlgorithm:
		mInitialized = TRUE;
		break;

	default:
		pgpAssert(FALSE);
		break;
	}
}
Example #16
0
// Show the contexts on the screen.
// Must be called from the main thread.
void
debugContexts (void)
{
	static volatile bool inDebugContexts = false;
			// Prevent this function from being called from within itself.
	
	CONTEXT orgContext;
	CONTEXT debugDrawContext;
			// We're going to use this context to draw in.
	FRAME debugDrawFrame;
	double hueIncrement;
	size_t visibleContextI;
	CONTEXT context;
	size_t contextCount;
	FRAME savedScreen;

	// Prevent this function from being called from within itself.
	if (inDebugContexts)
		return;
	inDebugContexts = true;

	contextCount = countVisibleContexts ();
	if (contextCount == 0)
	{
		goto out;
	}
	
	savedScreen = getScreen ();
	FlushGraphics ();
			// Make sure that the screen has actually been captured,
			// before we use the frame.

	// Create a new frame to draw on.
	debugDrawContext = CreateContext ("debugDrawContext");
	// New work frame is a copy of the original.
	debugDrawFrame = CaptureDrawable (CloneFrame (savedScreen));
	orgContext = SetContext (debugDrawContext);
	SetContextFGFrame (debugDrawFrame);

	hueIncrement = 360.0 / contextCount;

	visibleContextI = 0;
	for (context = GetFirstContext (); context != NULL;
			context = GetNextContext (context))
	{
		if (context == debugDrawContext) {
			// Skip our own context.
			continue;
		}
	
		if (isContextVisible (context))
		{
			// Only draw the visible contexts.
			drawContext (context, visibleContextI * hueIncrement);
			visibleContextI++;
		}

		describeContext (stderr, context);
	}

	// Blit the final debugging frame to the screen.
	putScreen (debugDrawFrame);

	// Wait for a key:
	{
		WAIT_STATE state;
		state.InputFunc = waitForKey;
		DoInput(&state, TRUE);
	}

	SetContext (orgContext);

	// Destroy the debugging frame and context.
	DestroyContext (debugDrawContext);
			// This does nothing with the drawable set with
			// SetContextFGFrame().
	DestroyDrawable (ReleaseDrawable (debugDrawFrame));
	
	putScreen (savedScreen);

	DestroyDrawable (ReleaseDrawable (savedScreen));

out:
	inDebugContexts = false;
}
Example #17
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
	WNDCLASS wc;
	MSG msg;
	RECT Rect;

	wc.style=CS_VREDRAW|CS_HREDRAW|CS_OWNDC;
	wc.lpfnWndProc=WndProc;
	wc.cbClsExtra=0;
	wc.cbWndExtra=0;
	wc.hInstance=hInstance;
	wc.hIcon=LoadIcon(NULL, IDI_WINLOGO);
	wc.hCursor=LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground=GetStockObject(BLACK_BRUSH);
	wc.lpszMenuName=NULL;
	wc.lpszClassName=szAppName;

	RegisterClass(&wc);

	SetRect(&Rect, 0, 0, Width, Height);
	AdjustWindowRect(&Rect, WS_OVERLAPPEDWINDOW, FALSE);

	Context.hWnd=CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS, CW_USEDEFAULT, CW_USEDEFAULT, Rect.right-Rect.left, Rect.bottom-Rect.top, NULL, NULL, hInstance, NULL);

	ShowWindow(Context.hWnd, SW_SHOW);
	SetForegroundWindow(Context.hWnd);

	if(!CreateContext(&Context, 32, 24, 0, 0, OGL_CORE33|OGL_DOUBLEBUFFER))
	{
		DestroyWindow(Context.hWnd);

		return -1;
	}

	if(!Init())
	{
		DestroyContext(&Context);
		DestroyWindow(Context.hWnd);

		return -1;
	}

	Frequency=GetFrequency();

	while(!Done)
	{
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if(msg.message==WM_QUIT)
				Done=1;
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else
		{
			StartTime=rdtsc();
			Render();
			SwapBuffers(Context.hDC);
			EndTime=rdtsc();

			fTimeStep=(float)(EndTime-StartTime)/Frequency;
			fTime+=fTimeStep;
			avgfps+=1.0f/fTimeStep;

			if(Frames++>200)
			{
				fps=avgfps/Frames;
				avgfps=0.0f;
				Frames=0;
			}
		}
	}

	DestroyContext(&Context);
	DestroyWindow(Context.hWnd);

	return msg.wParam;
}
Example #18
0
GLContext::~GLContext()
{
	DestroyContext();
}