예제 #1
0
void *GLimp_RendererSleep( void ) {
	void    *data;

	if ( !qwglMakeCurrent( glw_state.hDC, NULL ) ) {
		wglErrors++;
	}

	ResetEvent( renderActiveEvent );

	// after this, the front end can exit GLimp_FrontEndSleep
	SetEvent( renderCompletedEvent );

	WaitForSingleObject( renderCommandsEvent, INFINITE );

	if ( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) ) {
		wglErrors++;
	}

	ResetEvent( renderCompletedEvent );
	ResetEvent( renderCommandsEvent );

	data = smpData;

	// after this, the main thread can exit GLimp_WakeRenderer
	SetEvent( renderActiveEvent );

	return data;
}
예제 #2
0
void idGLWidget::OnPaint()
{

    if (!initialized)
    {
        CDC *dc = GetDC();
        QEW_SetupPixelFormat(dc->m_hDC);
        ReleaseDC(dc);
        initialized = true;
    }
    CPaintDC dc(this); // device context for painting

    CRect rect;
    GetClientRect(rect);

    if (!qwglMakeCurrent(dc.m_hDC, win32.hGLRC))
    {
    }

    qglViewport(0, 0, rect.Width(), rect.Height());
    qglScissor(0, 0, rect.Width(), rect.Height());
    qglMatrixMode(GL_PROJECTION);
    qglLoadIdentity();
    qglClearColor (0.4f, 0.4f, 0.4f, 0.7f);
    qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    qglDisable(GL_DEPTH_TEST);
    qglDisable(GL_BLEND);
    qglOrtho(0, rect.Width(), 0, rect.Height(), -256, 256);

    if (drawable)
    {
        drawable->draw(1, 1, rect.Width()-1, rect.Height()-1);
    }
    else
    {
        qglViewport(0, 0, rect.Width(), rect.Height());
        qglScissor(0, 0, rect.Width(), rect.Height());
        qglMatrixMode(GL_PROJECTION);
        qglLoadIdentity();
        qglClearColor (0.4f, 0.4f, 0.4f, 0.7f);
        qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    }

    qwglSwapBuffers(dc);
    qglFlush();
    qwglMakeCurrent(win32.hDC, win32.hGLRC);

}
예제 #3
0
qtexture_t* WINAPI QERApp_Texture_ForName (const char *name)
{
	// if the texture is not loaded yet, this call will get it loaded
	// but: when we assign a GL bind number, we need to be in the g_qeglobals.d_hdcBase , g_qeglobals.d_hglrcBase GL context
	// the plugin may set the GL context to whatever he likes, but then load would fail
	// NOTE: is context switching time-consuming? then maybe the plugin could handle the context switch and only add a 
	// sanity check in debug mode here
	// read current context
	HDC pluginHDC = qwglGetCurrentDC();
	HGLRC pluginHGLRC = qwglGetCurrentContext();
	qwglMakeCurrent( g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase );
	qtexture_t* qtex = Texture_ForName( name );
	return qtex;
	qwglMakeCurrent( pluginHDC, pluginHGLRC );
}
예제 #4
0
/*
===================
GLimp_RenderThreadWrapper
===================
*/
static void GLimp_RenderThreadWrapper()
{
    win32.glimpRenderThread();

    // unbind the context before we die
    qwglMakeCurrent( win32.hDC, NULL );
}
예제 #5
0
/*
===================
GLimp_ActivateContext
===================
*/
void GLimp_ActivateContext()
{
    if( !qwglMakeCurrent( win32.hDC, win32.hGLRC ) )
    {
        win32.wglErrors++;
    }
}
예제 #6
0
/*
===============
ResizeWindow
===============
*/
static void ResizeWindow( int width, int height ) {
#ifdef WIN32
	int	winWidth, winHeight;
	if ( glConfig.isFullscreen ) {
		winWidth = width;
		winHeight = height;
	} else {
		RECT	r;

		// adjust width and height for window border
		r.bottom = height;
		r.left = 0;
		r.top = 0;
		r.right = width;

		AdjustWindowRect (&r, WINDOW_STYLE|WS_SYSMENU, FALSE);
		winHeight = r.bottom - r.top;
		winWidth = r.right - r.left;

	}
	SetWindowPos( win32.hWnd, HWND_TOP, 0, 0, winWidth, winHeight, SWP_SHOWWINDOW );

	qwglMakeCurrent( win32.hDC, win32.hGLRC );
#endif
}
예제 #7
0
파일: win_glw.c 프로젝트: MGXRace/racesow
/*
** GLimp_SharedContext_MakeCurrent
*/
bool GLimp_SharedContext_MakeCurrent( void *context, void *surface )
{
	if( qwglMakeCurrent && !qwglMakeCurrent( glw_state.hDC, context ) ) {
		return false;
	}
	return true;
}
예제 #8
0
파일: win_glw.c 프로젝트: ewirch/qfusion
/*
** GLimp_SharedContext_MakeCurrent
*/
qboolean GLimp_SharedContext_MakeCurrent( void *ctx )
{
	if( qwglMakeCurrent && !qwglMakeCurrent( glw_state.hDC, ctx ) ) {
		return qfalse;
	}
	return qtrue;
}
예제 #9
0
파일: win_glimp.cpp 프로젝트: DaTa-/cnq3x
static int GLW_MakeContext( PIXELFORMATDESCRIPTOR *pPFD )
{
	//
	// don't putz around with pixelformat if it's already set (e.g. this is a soft
	// reset of the graphics system)
	//
	if ( !glw_state.pixelFormatSet )
	{
        int pixelformat;

		//
		// choose, set, and describe our desired pixel format.  If we're
		// using a minidriver then we need to bypass the GDI functions,
		// otherwise use the GDI functions.
		//
		if (glw_state.nPendingPF)
			pixelformat = glw_state.nPendingPF;
		else
		if ( ( pixelformat = GLW_ChoosePFD( glw_state.hDC, pPFD ) ) == 0 )
		{
			ri.Printf( PRINT_ALL, "...GLW_ChoosePFD failed\n");
			return TRY_PFD_FAIL_SOFT;
		}
		ri.Printf( PRINT_DEVELOPER, "...PIXELFORMAT %d selected\n", pixelformat );

		DescribePixelFormat( glw_state.hDC, pixelformat, sizeof( *pPFD ), pPFD );

		if ( SetPixelFormat( glw_state.hDC, pixelformat, pPFD ) == FALSE )
		{
			ri.Printf( PRINT_ALL, "...SetPixelFormat failed\n", glw_state.hDC );
			return TRY_PFD_FAIL_SOFT;
		}

		glw_state.pixelFormatSet = qtrue;
	}

	//
	// startup the OpenGL subsystem by creating a context and making it current
	//
	if ( !glw_state.hGLRC )
	{
		if ( ( glw_state.hGLRC = qwglCreateContext( glw_state.hDC ) ) == 0 )
		{
			ri.Printf( PRINT_ALL, "...GL context creation failure\n" );
			return TRY_PFD_FAIL_HARD;
		}
		ri.Printf( PRINT_DEVELOPER, "...GL context created\n" );

		if ( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) )
		{
			qwglDeleteContext( glw_state.hGLRC );
			glw_state.hGLRC = NULL;
			ri.Printf( PRINT_ALL, "...GL context creation currency failure\n" );
			return TRY_PFD_FAIL_HARD;
		}
		ri.Printf( PRINT_DEVELOPER, "...GL context creation made current\n" );
	}

	return TRY_PFD_SUCCESS;
}
예제 #10
0
파일: win_glimp.cpp 프로젝트: DaTa-/cnq3x
static void GLW_AttemptFSAA()
{
	static const float ar[] = { 0, 0 };
	// ignore r_xyzbits vars - FSAA requires 32-bit color, and anyone using it is implicitly on decent HW
	static int anAttributes[] = {
		WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
		WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
		WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
		WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
		WGL_COLOR_BITS_ARB, 32,
		WGL_ALPHA_BITS_ARB, 0,
		WGL_DEPTH_BITS_ARB, 24,
		WGL_STENCIL_BITS_ARB, 8,
		WGL_SAMPLE_BUFFERS_ARB, GL_TRUE,
		WGL_SAMPLES_ARB, 4,
		0, 0
	};

	qwglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)qwglGetProcAddress( "wglChoosePixelFormatARB" );
	if (!r_ext_multisample->integer || !qwglChoosePixelFormatARB) {
		glDisable(GL_MULTISAMPLE_ARB);
		return;
	}

	int iPFD;
	UINT cPFD;
	anAttributes[19] = r_ext_multisample->integer;	// !!! UGH
	if (!qwglChoosePixelFormatARB(glw_state.hDC, anAttributes, ar, 1, &iPFD, &cPFD) || !cPFD)
		return;

	// now bounce the ENTIRE f*****g subsystem thanks to WGL stupidity
	// we can't use GLimp_Shutdown() for this, because that does CDS poking that we don't want
	assert( glw_state.hGLRC && glw_state.hDC && g_wv.hWnd );

	qwglMakeCurrent( glw_state.hDC, NULL );

	if ( glw_state.hGLRC ) {
		qwglDeleteContext( glw_state.hGLRC );
		glw_state.hGLRC = NULL;
	}

	if ( glw_state.hDC ) {
		ReleaseDC( g_wv.hWnd, glw_state.hDC );
		glw_state.hDC = NULL;
	}

	if ( g_wv.hWnd ) {
		DestroyWindow( g_wv.hWnd );
		g_wv.hWnd = NULL;
	}

	ri.Printf( PRINT_ALL, "...enabling FSAA\n" );

	glw_state.nPendingPF = iPFD;
	glw_state.pixelFormatSet = qfalse;
	GLW_CreateWindow( glConfig.vidWidth, glConfig.vidHeight, glConfig.colorBits );
	glw_state.nPendingPF = 0;

	glEnable(GL_MULTISAMPLE_ARB);
}
예제 #11
0
파일: glw_imp.c 프로젝트: q3aql/quake2
/*
** GLimp_Shutdown
**
** This routine does all OS specific shutdown procedures for the OpenGL
** subsystem.  Under OpenGL this means NULLing out the current DC and
** HGLRC, deleting the rendering context, and releasing the DC acquired
** for the window.  The state structure is also nulled out.
**
*/
void GLimp_Shutdown( void )
{
    if ( qwglMakeCurrent && !qwglMakeCurrent( NULL, NULL ) )
        Com_Printf ( "GLimp_Shutdown() - wglMakeCurrent failed\n");
    if ( glw_state.hGLRC )
    {
        if (  qwglDeleteContext && !qwglDeleteContext( glw_state.hGLRC ) )
            Com_Printf ( "GLimp_Shutdown() - wglDeleteContext failed\n");
        glw_state.hGLRC = NULL;
    }
    if (glw_state.hDC)
    {
        if ( !ReleaseDC( glw_state.hWnd, glw_state.hDC ) )
            Com_Printf ( "GLimp_Shutdown() - ReleaseDC failed\n" );
        glw_state.hDC   = NULL;
    }
    if (glw_state.hWnd)
    {
        ShowWindow (glw_state.hWnd, SW_HIDE);
        DestroyWindow (	glw_state.hWnd );
        glw_state.hWnd = NULL;
    }

    UnregisterClass (WINDOW_CLASS_NAME, glw_state.hInstance);
    s_classRegistered = false;

    if ( gl_state.fullscreen )
    {
        ChangeDisplaySettings( 0, 0 );
        gl_state.fullscreen = false;
    }
}
예제 #12
0
void CCamWnd::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
  bool bPaint = true;
  if (!qwglMakeCurrent( dc.m_hDC, g_qeglobals.d_hglrcBase ))
  {
    Sys_Printf("ERROR: wglMakeCurrent failed..\n ");
    Sys_Printf("Please restart Q3Radiant if the camera view is not working\n");
  }
  else
  {
    QE_CheckOpenGLForErrors();
    g_pSplitList = NULL;
    if (g_bClipMode)
    {
      if (g_Clip1.Set() && g_Clip2.Set())
      {
        g_pSplitList = ( (g_pParentWnd->ActiveXY()->GetViewType() == XZ) ? !g_bSwitch : g_bSwitch) ? &g_brBackSplits : &g_brFrontSplits;
      }
    }
		Cam_Draw ();
		QE_CheckOpenGLForErrors();
		qwglSwapBuffers(dc.m_hDC);
  }
}
예제 #13
0
파일: win_glimp.cpp 프로젝트: DaTa-/cnq3x
void GLimp_FrontEndSleep( void ) {
	
	WaitForSingleObject( renderCompletedEvent, INFINITE );
	if ( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) ) {
		wglErrors++;
	}
}
예제 #14
0
void CCamWnd::BenchMark()
{
	PAINTSTRUCT	ps;
  CRect rct;
  GetWindowRect(rct);
  long lStyle = ::GetWindowLong(GetSafeHwnd(), GWL_STYLE);
  ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, QE3_CHILDSTYLE);
  CWnd* pParent = GetParent();
  SetParent(g_pParentWnd);
  MoveWindow(CRect(30, 30, 400, 400), TRUE);

  BeginPaint(&ps);
  if (!qwglMakeCurrent(ps.hdc, g_qeglobals.d_hglrcBase))
		Error ("wglMakeCurrent failed in Benchmark");
  
	qglDrawBuffer (GL_FRONT);
	double dStart = Sys_DoubleTime ();
	for (int i=0 ; i < 100 ; i++)
	{
		m_Camera.angles[YAW] = i*4;
		Cam_Draw();
	}
	qwglSwapBuffers(ps.hdc);
	qglDrawBuffer (GL_BACK);
	double dEnd = Sys_DoubleTime ();
	EndPaint(&ps);
	Sys_Printf ("%5.2f seconds\n", dEnd - dStart);
  ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, lStyle);
  SetParent(pParent);
  MoveWindow(rct, TRUE);
}
예제 #15
0
파일: win_glw.c 프로젝트: Racenet/racesow
/*
** GLimp_Shutdown
**
** This routine does all OS specific shutdown procedures for the OpenGL
** subsystem.  Under OpenGL this means NULLing out the current DC and
** HGLRC, deleting the rendering context, and releasing the DC acquired
** for the window.  The state structure is also nulled out.
**
*/
void GLimp_Shutdown( void )
{
	if( glw_state.parenthWnd )
		PostMessage( glw_state.parenthWnd, UWM_APPACTIVE, WA_INACTIVE, 0 );

	if( qwglMakeCurrent && !qwglMakeCurrent( NULL, NULL ) )
		Com_Printf( "ref_gl::R_Shutdown() - wglMakeCurrent failed\n" );
	if( glw_state.hGLRC )
	{
		if( qwglDeleteContext && !qwglDeleteContext( glw_state.hGLRC ) )
			Com_Printf( "ref_gl::R_Shutdown() - wglDeleteContext failed\n" );
		glw_state.hGLRC = NULL;
	}
	if( glw_state.hDC )
	{
		if( !ReleaseDC( glw_state.hWnd, glw_state.hDC ) )
			Com_Printf( "ref_gl::R_Shutdown() - ReleaseDC failed\n" );
		glw_state.hDC   = NULL;
	}
	if( glw_state.hWnd )
	{
		ShowWindow( glw_state.hWnd, SW_HIDE );
		DestroyWindow( glw_state.hWnd );
		glw_state.hWnd = NULL;
	}

	UnregisterClass( WINDOW_CLASS_NAME, glw_state.hInstance );

	if( glState.fullScreen )
	{
		ChangeDisplaySettings( 0, 0 );
		glState.fullScreen = qfalse;
	}
}
예제 #16
0
/*
===================
GLimp_DeactivateContext
===================
*/
void GLimp_DeactivateContext()
{
    qglFinish();
    if( !qwglMakeCurrent( win32.hDC, NULL ) )
    {
        win32.wglErrors++;
    }
}
예제 #17
0
void CCamWnd::ReInitGL()
{

  qwglMakeCurrent(0,0);
	QEW_SetupPixelFormat(GetDC()->m_hDC, true);
  if (!qwglMakeCurrent(g_qeglobals.d_hdcBase, g_qeglobals.d_hglrcBase))
	  Error ("wglMakeCurrent failed");

  return;

  long lStyle = ::GetWindowLong(GetSafeHwnd(), GWL_STYLE);
  int nID = ::GetWindowLong(GetSafeHwnd(), GWL_ID);
  CWnd* pParent = GetParent();
  CRect rctClient;
  GetClientRect(rctClient);
  DestroyWindow();
  Create(CAMERA_WINDOW_CLASS, "", lStyle, rctClient, pParent, nID);
}
예제 #18
0
파일: win_glw.c 프로젝트: MGXRace/racesow
/*
** GLimp_Shutdown
**
** This routine does all OS specific shutdown procedures for the OpenGL
** subsystem.  Under OpenGL this means NULLing out the current DC and
** HGLRC, deleting the rendering context, and releasing the DC acquired
** for the window.  The state structure is also nulled out.
**
*/
void GLimp_Shutdown( void )
{
	if( qwglMakeCurrent && !qwglMakeCurrent( NULL, NULL ) )
		ri.Com_Printf( "ref_gl::R_Shutdown() - wglMakeCurrent failed\n" );
	if( glw_state.hGLRC )
	{
		if( qwglDeleteContext && !qwglDeleteContext( glw_state.hGLRC ) )
			ri.Com_Printf( "ref_gl::R_Shutdown() - wglDeleteContext failed\n" );
		glw_state.hGLRC = NULL;
	}
	if( glw_state.hDC )
	{
		if( !ReleaseDC( glw_state.hWnd, glw_state.hDC ) )
			ri.Com_Printf( "ref_gl::R_Shutdown() - ReleaseDC failed\n" );
		glw_state.hDC   = NULL;
	}
	if( glw_state.hWnd )
	{
		ShowWindow( glw_state.hWnd, SW_HIDE );
		DestroyWindow( glw_state.hWnd );
		glw_state.hWnd = NULL;
	}

#ifdef WITH_UTF8
	UnregisterClassW( glw_state.windowClassNameW, glw_state.hInstance );
#else
	UnregisterClass( glw_state.windowClassName, glw_state.hInstance );
#endif

	if( glConfig.fullScreen )
	{
		ChangeDisplaySettings( 0, 0 );
		glConfig.fullScreen = false;
	}

	if( glw_state.applicationName )
	{
		free( glw_state.applicationName );
		glw_state.applicationName = NULL;
	}

	if( glw_state.applicationNameW )
	{
		free( glw_state.applicationNameW );
		glw_state.applicationNameW = NULL;
	}

	glw_state.applicationIconResourceID = 0;

	glw_state.win_x = 0;
	glw_state.win_y = 0;

	glConfig.width = 0;
	glConfig.height = 0;
}
예제 #19
0
/*
===================
GLimp_Shutdown

This routine does all OS specific shutdown procedures for the OpenGL
subsystem.
===================
*/
void GLimp_Shutdown( void ) {
	const char *success[] = { "failed", "success" };
	int retVal;

	common->Printf( "Shutting down OpenGL subsystem\n" );

	// set current context to NULL
	if ( qwglMakeCurrent ) {
		retVal = qwglMakeCurrent( NULL, NULL ) != 0;
		common->Printf( "...wglMakeCurrent( NULL, NULL ): %s\n", success[retVal] );
	}

	// delete HGLRC
	if ( win32.hGLRC ) {
		retVal = qwglDeleteContext( win32.hGLRC ) != 0;
		common->Printf( "...deleting GL context: %s\n", success[retVal] );
		win32.hGLRC = NULL;
	}

	// release DC
	if ( win32.hDC ) {
		retVal = ReleaseDC( win32.hWnd, win32.hDC ) != 0;
		common->Printf( "...releasing DC: %s\n", success[retVal] );
		win32.hDC   = NULL;
	}

	// destroy window
	if ( win32.hWnd ) {
		common->Printf( "...destroying window\n" );
		ShowWindow( win32.hWnd, SW_HIDE );
		DestroyWindow( win32.hWnd );
		win32.hWnd = NULL;
	}

	// reset display settings
	if ( win32.cdsFullscreen ) {
		common->Printf( "...resetting display\n" );
		ChangeDisplaySettings( 0, 0 );
		win32.cdsFullscreen = false;
	}

	// close the thread so the handle doesn't dangle
	if ( win32.renderThreadHandle ) {
		common->Printf( "...closing smp thread\n" );
		CloseHandle( win32.renderThreadHandle );
		win32.renderThreadHandle = NULL;
	}

	// restore gamma
	GLimp_RestoreGamma();

	// shutdown QGL subsystem
	QGL_Shutdown();
}
예제 #20
0
/*
====================
FakeWndProc

Only used to get wglExtensions
====================
*/
LONG WINAPI FakeWndProc(
	HWND    hWnd,
	UINT    uMsg,
	WPARAM  wParam,
	LPARAM  lParam )
{

	if( uMsg == WM_DESTROY )
	{
		PostQuitMessage( 0 );
	}
	
	if( uMsg != WM_CREATE )
	{
		return DefWindowProc( hWnd, uMsg, wParam, lParam );
	}
	
	const static PIXELFORMATDESCRIPTOR pfd =
	{
		sizeof( PIXELFORMATDESCRIPTOR ),
		1,
		PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
		PFD_TYPE_RGBA,
		24,
		0, 0, 0, 0, 0, 0,
		8, 0,
		0, 0, 0, 0,
		24, 8,
		0,
		PFD_MAIN_PLANE,
		0,
		0,
		0,
		0,
	};
	int		pixelFormat;
	HDC hDC;
	HGLRC hGLRC;
	
	hDC = GetDC( hWnd );
	
	// Set up OpenGL
	pixelFormat = ChoosePixelFormat( hDC, &pfd );
	SetPixelFormat( hDC, pixelFormat, &pfd );
	hGLRC = qwglCreateContext( hDC );
	qwglMakeCurrent( hDC, hGLRC );
	
	// free things
	wglMakeCurrent( NULL, NULL );
	wglDeleteContext( hGLRC );
	ReleaseDC( hWnd, hDC );
	
	return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
예제 #21
0
파일: win_glimp.cpp 프로젝트: DaTa-/cnq3x
void GLimp_WakeRenderer( void *data ) {
	smpData = data;

	if ( !qwglMakeCurrent( glw_state.hDC, NULL ) ) {
		wglErrors++;
	}

	// after this, the renderer can continue through GLimp_RendererSleep
	SetEvent( renderCommandsEvent );
    
	WaitForSingleObject( renderActiveEvent, INFINITE );
}
예제 #22
0
/*
===================
GLimp_DeactivateContext

===================
*/
void GLimp_DeactivateContext( void ) {
	qglFinish();
	if ( !qwglMakeCurrent( win32.hDC, NULL ) ) {
		win32.wglErrors++;
	}
#ifdef REALLOC_DC
	// makeCurrent NULL frees the DC, so get another
	if ( ( win32.hDC = GetDC( win32.hWnd ) ) == NULL ) {
		win32.wglErrors++;
	}
#endif

}
예제 #23
0
/*
=================
RadiantInit

This is also called when you 'quit' in doom
=================
*/
void RadiantInit( void ) {

	// make sure the renderer is initialized
	if ( !renderSystem->IsOpenGLRunning() ) {
		common->Printf( "no OpenGL running\n" );
		return;
	}

	g_editorAlive = true;

	// allocate a renderWorld and a soundWorld
	if ( g_qeglobals.rw == NULL ) {
		g_qeglobals.rw = renderSystem->AllocRenderWorld();
		g_qeglobals.rw->InitFromMap( NULL );
	}
	if ( g_qeglobals.sw == NULL ) {
		g_qeglobals.sw = soundSystem->AllocSoundWorld( g_qeglobals.rw );
	}

	if ( g_DoomInstance ) {
		if ( ::IsWindowVisible( win32.hWnd ) ) {
			::ShowWindow( win32.hWnd, SW_HIDE );
			g_pParentWnd->ShowWindow( SW_SHOW );
			g_pParentWnd->SetFocus();
		}
	} else {
		Sys_GrabMouseCursor( false );

		g_DoomInstance = win32.hInstance;
		CWinApp* pApp = AfxGetApp();
		CWinThread *pThread = AfxGetThread();

		InitAfx();

		// App global initializations (rare)
		pApp->InitApplication();

		// Perform specific initializations
		pThread->InitInstance();

		qglFinish();
		//qwglMakeCurrent(0, 0);
		qwglMakeCurrent(win32.hDC, win32.hGLRC);

		// hide the doom window by default
		::ShowWindow( win32.hWnd, SW_HIDE );
	}
}
void CZWnd::OnPaint() {
	CPaintDC dc( this ); // device context for painting
	//if (!wglMakeCurrent(m_dcZ, m_hglrcZ))
	//if (!qwglMakeCurrent(dc.m_hDC, m_hglrcZ))
	if ( !qwglMakeCurrent( dc.m_hDC, win32.hGLRC ) ) {
		common->Printf( "ERROR: wglMakeCurrent failed..\n " );
		common->Printf( "Please restart " EDITOR_WINDOWTEXT " if the Z view is not working\n" );
	} else {
		QE_CheckOpenGLForErrors();

		Z_Draw ();
		//qwglSwapBuffers( m_dcZ );
		qwglSwapBuffers( dc.m_hDC );
		TRACE( "Z Paint\n" );
	}
}
예제 #25
0
void CZWnd::OnPaint()
{
    CPaintDC dc(this); // device context for painting
    //if (!wglMakeCurrent(m_dcZ, m_hglrcZ))
    if (!qwglMakeCurrent(dc.m_hDC, m_hglrcZ))
    {
        Sys_Printf("ERROR: wglMakeCurrent failed..\n ");
        Sys_Printf("Please restart QERadiant if the Z view is not working\n");
    }
    else
    {
        QE_CheckOpenGLForErrors();
        Z_Draw ();
        //qwglSwapBuffers(m_dcZ);
        qwglSwapBuffers(dc.m_hDC);
//    TRACE("Z Paint\n");
    }
}
예제 #26
0
void RadiantRun( void ) {
	static bool exceptionErr = false;
	int show = ::IsWindowVisible(win32.hWnd);

	try {
		if (!exceptionErr && !show) {
			//qglPushAttrib(GL_ALL_ATTRIB_BITS);
			qglDepthMask(true);
			theApp.Run();
			//qglPopAttrib();
			//qwglMakeCurrent(0, 0);
			qwglMakeCurrent(win32.hDC, win32.hGLRC);
		}
	}
	catch( idException &ex ) {
		::MessageBox(NULL, ex.error, "Exception error", MB_OK);
		RadiantShutdown();
	}
}
예제 #27
0
파일: ZWnd.cpp 프로젝트: Izhido/qrevpak
int CZWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	g_qeglobals.d_hwndZ = GetSafeHwnd();

  m_dcZ = ::GetDC(GetSafeHwnd());
  QEW_SetupPixelFormat(m_dcZ, false);
	if ((m_hglrcZ = qwglCreateContext(m_dcZ )) == 0)
	  Error("wglCreateContext in CZWnd::OnCreate failed");

	if (!qwglShareLists(g_qeglobals.d_hglrcBase, m_hglrcZ))
	  Error( "wglShareLists in CZWnd::OnCreate failed");

  if (!qwglMakeCurrent(m_dcZ, m_hglrcZ))
	  Error ("wglMakeCurrent in CZWnd::OnCreate failed");

	return 0;
}
예제 #28
0
파일: glw_imp.c 프로젝트: lambda/wxQuake2
/*
** GLimp_Shutdown
**
** This routine does all OS specific shutdown procedures for the OpenGL
** subsystem.  Under OpenGL this means NULLing out the current DC and
** HGLRC, deleting the rendering context, and releasing the DC acquired
** for the window.  The state structure is also nulled out.
**
*/
void GLimp_Shutdown( void )
{
	if ( qwglMakeCurrent && !qwglMakeCurrent( NULL, NULL ) )
		ri.Con_Printf( PRINT_ALL, "ref_gl::R_Shutdown() - wglMakeCurrent failed\n");
	if ( glw_state.hGLRC )
	{
		if (  qwglDeleteContext && !qwglDeleteContext( glw_state.hGLRC ) )
			ri.Con_Printf( PRINT_ALL, "ref_gl::R_Shutdown() - wglDeleteContext failed\n");
		glw_state.hGLRC = NULL;
	}
	if (glw_state.hDC)
	{
		if ( !ReleaseDC( glw_state.hWnd, glw_state.hDC ) )
			ri.Con_Printf( PRINT_ALL, "ref_gl::R_Shutdown() - ReleaseDC failed\n" );
		glw_state.hDC   = NULL;
	}
#ifndef __WXWINDOWS__
	if (glw_state.hWnd)
	{
		DestroyWindow (	glw_state.hWnd );
		glw_state.hWnd = NULL;
	}
#endif // ndef __WXWINDOWS__

	if ( glw_state.log_fp )
	{
		fclose( glw_state.log_fp );
		glw_state.log_fp = 0;
	}

#ifndef __WXWINDOWS__
	UnregisterClass (WINDOW_CLASS_NAME, glw_state.hInstance);
#endif // ndef __WXWINDOWS__

	if ( gl_state.fullscreen )
	{
		ChangeDisplaySettings( 0, 0 );
		gl_state.fullscreen = false;
	}
}
예제 #29
0
파일: glimp.c 프로젝트: Jenco420/q2pro
/*
VID_Shutdown

This routine does all OS specific shutdown procedures for the OpenGL
subsystem.  Under OpenGL this means NULLing out the current DC and
HGLRC, deleting the rendering context, and releasing the DC acquired
for the window.  The state structure is also nulled out.
*/
void VID_Shutdown(void)
{
    if (qwglMakeCurrent) {
        qwglMakeCurrent(NULL, NULL);
    }

    if (glw.hGLRC && qwglDeleteContext) {
        qwglDeleteContext(glw.hGLRC);
        glw.hGLRC = NULL;
    }

    WGL_Shutdown();
    Win_Shutdown();

    if (gl_swapinterval) {
        gl_swapinterval->changed = NULL;
    }
    if (gl_drawbuffer) {
        gl_drawbuffer->changed = NULL;
    }

    memset(&glw, 0, sizeof(glw));
}
예제 #30
0
파일: win_glw.c 프로젝트: Racenet/racesow
static int GLimp_InitGL( void )
{
	PIXELFORMATDESCRIPTOR pfd =
	{
		sizeof( PIXELFORMATDESCRIPTOR ), // size of this pfd
		1,                      // version number
		PFD_DRAW_TO_WINDOW |    // support window
		PFD_SUPPORT_OPENGL |    // support OpenGL
		PFD_DOUBLEBUFFER,       // double buffered
		PFD_TYPE_RGBA,          // RGBA type
		32,                     // 32-bit color depth
		0, 0, 0, 0, 0, 0,       // color bits ignored
		0,                      // no alpha buffer
		0,                      // shift bit ignored
		0,                      // no accumulation buffer
		0, 0, 0, 0,             // accum bits ignored
		24,                     // 32-bit z-buffer
		0,                      // no stencil buffer
		0,                      // no auxiliary buffer
		PFD_MAIN_PLANE,         // main layer
		0,                      // reserved
		0, 0, 0                 // layer masks ignored
	};
	int pixelformat;
	cvar_t *stereo;

	stereo = Cvar_Get( "cl_stereo", "0", 0 );

	pfd.cStencilBits = max( 0, r_stencilbits->integer );

	if( pfd.cStencilBits != 0 )
		glState.stencilEnabled = qtrue;
	else
		glState.stencilEnabled = qfalse;

	/*
	** set PFD_STEREO if necessary
	*/
	if( stereo->integer != 0 )
	{
		Com_Printf( "...attempting to use stereo\n" );
		pfd.dwFlags |= PFD_STEREO;
		glState.stereoEnabled = qtrue;
	}
	else
	{
		glState.stereoEnabled = qfalse;
	}

	/*
	** figure out if we're running on a minidriver or not
	*/
	if( strstr( gl_driver->string, "opengl32" ) != 0 )
		glw_state.minidriver = qfalse;
	else
		glw_state.minidriver = qtrue;

	/*
	** Get a DC for the specified window
	*/
	if( glw_state.hDC != NULL )
		Com_Printf( "GLimp_Init() - non-NULL DC exists\n" );

	if( ( glw_state.hDC = GetDC( glw_state.hWnd ) ) == NULL )
	{
		Com_Printf( "GLimp_Init() - GetDC failed\n" );
		return qfalse;
	}

	if( glw_state.minidriver )
	{
		if( ( pixelformat = qwglChoosePixelFormat( glw_state.hDC, &pfd ) ) == 0 )
		{
			Com_Printf( "GLimp_Init() - qwglChoosePixelFormat failed\n" );
			return qfalse;
		}
		if( qwglSetPixelFormat( glw_state.hDC, pixelformat, &pfd ) == FALSE )
		{
			Com_Printf( "GLimp_Init() - qwglSetPixelFormat failed\n" );
			return qfalse;
		}
		qwglDescribePixelFormat( glw_state.hDC, pixelformat, sizeof( pfd ), &pfd );
	}
	else
	{
		if( ( pixelformat = ChoosePixelFormat( glw_state.hDC, &pfd ) ) == 0 )
		{
			Com_Printf( "GLimp_Init() - ChoosePixelFormat failed\n" );
			return qfalse;
		}
		if( SetPixelFormat( glw_state.hDC, pixelformat, &pfd ) == FALSE )
		{
			Com_Printf( "GLimp_Init() - SetPixelFormat failed\n" );
			return qfalse;
		}
		DescribePixelFormat( glw_state.hDC, pixelformat, sizeof( pfd ), &pfd );

		if( !( pfd.dwFlags & PFD_GENERIC_ACCELERATED ) )
		{
			extern cvar_t *r_allow_software;

			if( r_allow_software->integer )
				glw_state.mcd_accelerated = qtrue;
			else
				glw_state.mcd_accelerated = qfalse;
		}
		else
		{
			glw_state.mcd_accelerated = qtrue;
		}
	}

	/*
	** report if stereo is desired but unavailable
	*/
	if( !( pfd.dwFlags & PFD_STEREO ) && ( stereo->integer != 0 ) )
	{
		Com_Printf( "...failed to select stereo pixel format\n" );
		Cvar_SetValue( "cl_stereo", 0 );
		glState.stereoEnabled = qfalse;
	}

	/*
	** startup the OpenGL subsystem by creating a context and making
	** it current
	*/
	if( ( glw_state.hGLRC = qwglCreateContext( glw_state.hDC ) ) == 0 )
	{
		Com_Printf( "GLimp_Init() - qwglCreateContext failed\n" );
		goto fail;
	}

	if( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) )
	{
		Com_Printf( "GLimp_Init() - qwglMakeCurrent failed\n" );
		goto fail;
	}

	if( !VerifyDriver() )
	{
		Com_Printf( "GLimp_Init() - no hardware acceleration detected\n" );
		goto fail;
	}

	/*
	** print out PFD specifics
	*/
	Com_Printf( "GL PFD: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", ( int ) pfd.cColorBits, ( int ) pfd.cDepthBits, ( int )pfd.cStencilBits );

	return qtrue;

fail:
	if( glw_state.hGLRC )
	{
		qwglDeleteContext( glw_state.hGLRC );
		glw_state.hGLRC = NULL;
	}

	if( glw_state.hDC )
	{
		ReleaseDC( glw_state.hWnd, glw_state.hDC );
		glw_state.hDC = NULL;
	}
	return qfalse;
}