您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ wglCreateContextAttribsARB函数代码示例

51自学网 2021-06-03 09:55:31
  C++
这篇教程C++ wglCreateContextAttribsARB函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中wglCreateContextAttribsARB函数的典型用法代码示例。如果您正苦于以下问题:C++ wglCreateContextAttribsARB函数的具体用法?C++ wglCreateContextAttribsARB怎么用?C++ wglCreateContextAttribsARB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了wglCreateContextAttribsARB函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: set_active

HGLRC CL_GL1CreationHelper::create_opengl3_context(HGLRC share_context, int major_version, int minor_version){	set_active();	ptr_wglCreateContextAttribsARB wglCreateContextAttribsARB = (ptr_wglCreateContextAttribsARB) wglGetProcAddress("wglCreateContextAttribsARB");	reset_active();	HGLRC opengl3_context = 0;	if (wglCreateContextAttribsARB)	{		std::vector<int> int_attributes;		int_attributes.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB);		int_attributes.push_back(major_version);		int_attributes.push_back(WGL_CONTEXT_MINOR_VERSION_ARB);		int_attributes.push_back(minor_version);		//int_attributes.push_back(WGL_CONTEXT_LAYER_PLANE_ARB);		//int_attributes.push_back(layer_plane);		//int_attributes.push_back(WGL_CONTEXT_FLAGS_ARB);		//int_attributes.push_back(flags);		//int_attributes.push_back(WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB);		//int_attributes.push_back(forward_compatible_bit);		int_attributes.push_back(0);		opengl3_context = wglCreateContextAttribsARB(hdc, share_context, &int_attributes[0]);	}	return opengl3_context;}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:27,


示例2: EnableDrawing

    void EnableDrawing (HGLRC *hRC)    {		/**		 * Edited by Cool Breeze on 16th October 2013		 * + Updated the Pixel Format to support 24-bitdepth buffers		 * + Correctly create a GL 3.x compliant context		 */				HGLRC LegacyRC;        PIXELFORMATDESCRIPTOR pfd;        int iFormat;        enigma::window_hDC = GetDC (hWnd);        ZeroMemory (&pfd, sizeof (pfd));        pfd.nSize = sizeof (pfd);        pfd.nVersion = 1;        pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;        pfd.iPixelType = PFD_TYPE_RGBA;        pfd.cColorBits = 24;        pfd.cDepthBits = 24;        pfd.iLayerType = PFD_MAIN_PLANE;        iFormat = ChoosePixelFormat (enigma::window_hDC, &pfd);        if (iFormat==0) { show_error("Failed to set the format of the OpenGL graphics device.",1); }        SetPixelFormat ( enigma::window_hDC, iFormat, &pfd );        LegacyRC = wglCreateContext( enigma::window_hDC );        wglMakeCurrent( enigma::window_hDC, LegacyRC );                // -- Initialise GLEW        GLenum err = glewInit();        if (GLEW_OK != err)        {			return;        } 		// -- Define an array of Context Attributes        int attribs[] =        {			WGL_CONTEXT_MAJOR_VERSION_ARB, 3,			WGL_CONTEXT_MINOR_VERSION_ARB, 0,			WGL_CONTEXT_FLAGS_ARB, 0,			0        };         if ( wglewIsSupported("WGL_ARB_create_context") )        {                *hRC = wglCreateContextAttribsARB( enigma::window_hDC,0, attribs );                wglMakeCurrent( NULL,NULL );                wglDeleteContext( LegacyRC );                wglMakeCurrent(enigma::window_hDC, *hRC );        }        else // Unable to get a 3.0 Core Context, use the Legacy 1.x context        {                *hRC = LegacyRC;        }				//TODO: This never reports higher than 8, but display_aa should be 14 if 2,4,and 8 are supported and 8 only when only 8 is supported		glGetIntegerv(GL_MAX_SAMPLES_EXT, &enigma_user::display_aa);    }
开发者ID:JPierreS,项目名称:enigma-dev,代码行数:60,


示例3: GetDC

void CGSH_HleOglWin32::InitializeImpl(){	m_dc = GetDC(m_outputWnd->m_hWnd);	unsigned int pf = ChoosePixelFormat(m_dc, &m_pfd);	SetPixelFormat(m_dc, pf, &m_pfd);	m_context = wglCreateContext(m_dc);	wglMakeCurrent(m_dc, m_context);	auto result = glewInit();	assert(result == GLEW_OK);#ifdef GLES_COMPATIBILITY	if(wglCreateContextAttribsARB != nullptr)	{		auto prevContext = m_context;		static const int attributes[] = 		{			WGL_CONTEXT_MAJOR_VERSION_ARB, 3,			WGL_CONTEXT_MINOR_VERSION_ARB, 2,			WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,			0		};		m_context = wglCreateContextAttribsARB(m_dc, nullptr, attributes);		assert(m_context != nullptr);		wglMakeCurrent(m_dc, m_context);		auto deleteResult = wglDeleteContext(prevContext);		assert(deleteResult == TRUE);	}#endif	CGSH_HleOgl::InitializeImpl();}
开发者ID:bigianb,项目名称:hle_play,代码行数:35,


示例4: memset

	bool cOpenGl::CreateGLContext(CDC* pDC) {		PIXELFORMATDESCRIPTOR pfd;		memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));		pfd.nSize  = sizeof(PIXELFORMATDESCRIPTOR);		pfd.nVersion   = 1;		pfd.dwFlags    = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;		pfd.iPixelType = PFD_TYPE_RGBA;		pfd.cColorBits = 32;		pfd.cDepthBits = 32;		pfd.iLayerType = PFD_MAIN_PLANE;		int nPixelFormat = ChoosePixelFormat(pDC->m_hDC, &pfd);		if (nPixelFormat == 0) return false;		BOOL bResult = SetPixelFormat (pDC->m_hDC, nPixelFormat, &pfd);		if (!bResult) return false; 		HGLRC tempContext = wglCreateContext(pDC->m_hDC);		wglMakeCurrent(pDC->m_hDC, tempContext);		GLenum err = glewInit();		if (GLEW_OK != err)		{			AfxMessageBox(_T("GLEW is not initialized!"));		}		int attribs[] =		{			WGL_CONTEXT_MAJOR_VERSION_ARB, 3,			WGL_CONTEXT_MINOR_VERSION_ARB, 1,			WGL_CONTEXT_FLAGS_ARB, 0,			0		};		if(wglewIsSupported("WGL_ARB_create_context") == 1)		{			m_hrc = wglCreateContextAttribsARB(pDC->m_hDC,0, attribs);			wglMakeCurrent(NULL,NULL);			wglDeleteContext(tempContext);			wglMakeCurrent(pDC->m_hDC, m_hrc);		}		else		{       //It's not possible to make a GL 3.x context. Use the old style context (GL 2.1 and before)			m_hrc = tempContext;		}		//Checking GL version		const GLubyte *GLVersionString = glGetString(GL_VERSION);		//Or better yet, use the GL3 way to get the version number		int OpenGLVersion[2];		glGetIntegerv(GL_MAJOR_VERSION, &OpenGLVersion[0]);		glGetIntegerv(GL_MINOR_VERSION, &OpenGLVersion[1]);		if (!m_hrc) return false;		return true;	}
开发者ID:liufeigit,项目名称:NetBuilder,代码行数:60,


示例5: initializeGL

void initializeGL() {    HGLRC tempContext = wglCreateContext(ghDC);    wglMakeCurrent(ghDC, tempContext);    GLenum err = glewInit();    if (err != GLEW_OK) {        // failed to initialize GLEW!    }    // My card currently only supports OpenGL 4.1 -- jbl    int attribs[] = {        WGL_CONTEXT_MAJOR_VERSION_ARB, 4,        WGL_CONTEXT_MINOR_VERSION_ARB, 1,        WGL_CONTEXT_FLAGS_ARB, 0,        0    };    if (wglewIsSupported("WGL_ARB_create_context") == 1) {        ghRC = wglCreateContextAttribsARB(ghDC, 0, attribs);        wglMakeCurrent(NULL, NULL);        wglDeleteContext(tempContext);        wglMakeCurrent(ghDC, ghRC);    }    else {        // It's not possible to make a GL 3.x context. Use the old style context (GL 2.1 and before)        ghRC = tempContext;    }    int OpenGLVersion[2];    glGetIntegerv(GL_MAJOR_VERSION, &OpenGLVersion[0]);    glGetIntegerv(GL_MINOR_VERSION, &OpenGLVersion[1]);}
开发者ID:jblee123,项目名称:WorldPointViewer,代码行数:32,


示例6: InitContext

HRESULT InitContext(){	int iMajorVersion=3;	int iMinorVersion=0;	HDC hDC = GetDC(g_hWnd);	PIXELFORMATDESCRIPTOR pfd;	ZeroMemory(&pfd,sizeof(pfd)); 	bool bError=false;		if(WGLEW_ARB_create_context && WGLEW_ARB_pixel_format)	{		const int iPixelFormatAttribList[] =		{			WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,			WGL_SUPPORT_OPENGL_ARB, GL_TRUE,			WGL_DOUBLE_BUFFER_ARB, GL_TRUE,			WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, 			WGL_COLOR_BITS_ARB, 32,			       			WGL_DEPTH_BITS_ARB, 24,             			WGL_STENCIL_BITS_ARB, 8,			0 // End of attributes list		};		int iContextAttribs[] =		{			WGL_CONTEXT_MAJOR_VERSION_ARB, iMajorVersion,			WGL_CONTEXT_MINOR_VERSION_ARB, iMinorVersion,			WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,			0 // End of attributes list		};		int iPixelFormat, iNumFormats;		wglChoosePixelFormatARB(hDC, iPixelFormatAttribList, NULL, 1, &iPixelFormat, (UINT*)&iNumFormats);		if(!SetPixelFormat(hDC, iPixelFormat, &pfd))return false; 		hRC = wglCreateContextAttribsARB(hDC, 0, iContextAttribs);		// If everything went OK		if(hRC) wglMakeCurrent(hDC, hRC);		else bError = true;	}	else bError = true;		if(bError)	{		// Generate error messages		char sErrorMessage[255], sErrorTitle[255];		sprintf(sErrorMessage, "OpenGL %d.%d is not supported! Please download latest GPU drivers!", iMajorVersion, iMinorVersion);		sprintf(sErrorTitle, "OpenGL %d.%d Not Supported", iMajorVersion, iMinorVersion);		MessageBoxA(g_hWnd, sErrorMessage, sErrorTitle, MB_ICONINFORMATION);		return false;	}   return S_OK;}
开发者ID:Yuriy29,项目名称:GL2DImageTo3DOOP,代码行数:56,


示例7: GetDC

/*create30Context creates an OpenGL context and attaches it to the window provided by the HWND. This method currently creates and OpenGL 3.2 context by default, but will default to an OpenGL 2.1 capable context if the OpenGL 3.2 context cannot be created.*/bool OpenGLContext::create30Context(HWND hwnd) {	this->hwnd = hwnd; // Set the hwnd for our window	hdc = GetDC(hwnd); // Get the device context for our window	PIXELFORMATDESCRIPTOR pfd; // Create a new PIXELFORMATDESCRIPTOR (PFD)	memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)); // Clear our PFD	pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); // Set the size of the PFD to the size of the class	pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW; //Enable double buffering, opengl support, and drawing to a window	pfd.iPixelType = PFD_TYPE_RGBA; // Set our application to use RGBA pixels  	pfd.cColorBits = 32; // Give us 32 bits of color information (the higher, the more colors)  	pfd.cDepthBits = 32; // Give us 32 bits of depth information (the higher, the more depth levels)  	pfd.iLayerType = PFD_MAIN_PLANE; // Set the layer of the PFD  	int nPixelFormat = ChoosePixelFormat(hdc, &pfd); // Check if our PFD is valid and get a pixel format back  	if (nPixelFormat == 0) // If it fails  		return false;	bool bResult = SetPixelFormat(hdc, nPixelFormat, &pfd); // Try and set the pixel format based on our PFD  	if (!bResult) // If it fails  		return false;	HGLRC tempOpenGLContext = wglCreateContext(hdc); // Create an OpenGL 2.1 context for our device context  	wglMakeCurrent(hdc, tempOpenGLContext); // Make the OpenGL 2.1 context current and active  	GLenum error = glewInit(); // Enable GLEW  	if (error != GLEW_OK) // If GLEW fails  		return false;	int attributes[] = {		WGL_CONTEXT_MAJOR_VERSION_ARB, 3, // Set the MAJOR version of OpenGL to 3  		WGL_CONTEXT_MINOR_VERSION_ARB, 2, // Set the MINOR version of OpenGL to 2  		WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, // Set our OpenGL context to be forward compatible  		0	};	if (wglewIsSupported("WGL_ARB_create_context") == 1) { // If the OpenGL 3.x context creation extension is available  		hrc = wglCreateContextAttribsARB(hdc, NULL, attributes); // Create and OpenGL 3.x context based on the given attributes  		wglMakeCurrent(NULL, NULL); // Remove the temporary context from being active  		wglDeleteContext(tempOpenGLContext); // Delete the temporary OpenGL 2.1 context  		wglMakeCurrent(hdc, hrc); // Make our OpenGL 3.0 context current  	}	else {		hrc = tempOpenGLContext; // If we didn't have support for OpenGL 3.x and up, use the OpenGL 2.1 context  	}	int glVersion[2] = { -1, -1 }; // Set some default values for the version  	glGetIntegerv(GL_MAJOR_VERSION, &glVersion[0]); // Get back the OpenGL MAJOR version we are using  	glGetIntegerv(GL_MINOR_VERSION, &glVersion[1]); // Get back the OpenGL MAJOR version we are using  	//std::cout << "Using OpenGL: " << glVersion[0] << "." << glVersion[1] << std::endl; // Output which version of OpenGL we are using On Windows, you won’t get a console for a Win32 Application, but a nifty trick to get console output, is to open up Command Prompt, navigate to your directory with your executable file, and use something like: “program.exe > temp.txt” 	return true; // We have successfully created a context, return true}
开发者ID:netsphereengineer,项目名称:Swiftless,代码行数:56,


示例8: Win32InitOpenGL

internal voidWin32InitOpenGL(HDC WindowDC){    Win32LoadWGLExtensions();    HGLRC OpenGLRC       = 0;    bool32 ModernContext = true;    if(wglCreateContextAttribsARB)    {        int Win32OpenGLAttribs[] = {            WGL_CONTEXT_MAJOR_VERSION_ARB,            3,            WGL_CONTEXT_MINOR_VERSION_ARB,            1,            WGL_CONTEXT_FLAGS_ARB,            WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB#if LUDUS_INTERNAL                |                WGL_CONTEXT_DEBUG_BIT_ARB#endif            ,            WGL_CONTEXT_PROFILE_MASK_ARB,            WGL_CONTEXT_CORE_PROFILE_BIT_ARB,            0        };        Win32SetPixelFormat(WindowDC);        OpenGLRC = wglCreateContextAttribsARB(WindowDC, 0, Win32OpenGLAttribs);    }    if(!OpenGLRC)    {        ModernContext = false;        OpenGLRC      = wglCreateContext(WindowDC);    }    if(wglMakeCurrent(WindowDC, OpenGLRC))    {        InitOpenGL(ModernContext);        if(wglSwapInterval)        {            wglSwapInterval(1);        }    }    else    {        Win32Log("Couldnt set OpenGL context");        LOG_FORMATTED_ERROR(4096);    }}
开发者ID:Clever-Boy,项目名称:Ludus,代码行数:52,


示例9: wglChoosePixelFormatARB

    void WindowGL3::setupDC()    {        if (!wglChoosePixelFormatARB || !wglCreateContextAttribsARB)        {            Window::setupDC();            return;        }        int nPixCount = 0;        int nPixelFormat  = -1;        int pixAttribs[] = {            WGL_SUPPORT_OPENGL_ARB, 1,            WGL_DRAW_TO_WINDOW_ARB, 1,            WGL_ACCELERATION_ARB, 1,            WGL_RED_BITS_ARB, 8,            WGL_GREEN_BITS_ARB, 8,            WGL_BLUE_BITS_ARB, 8,            WGL_DEPTH_BITS_ARB, 16,            WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,            0 };        wglChoosePixelFormatARB(mHDC, pixAttribs, NULL, 1, &nPixelFormat,            (UINT*)&nPixCount);        if (nPixelFormat == -1)        {            std::cerr << "wglChoosePixelFormatARB failed/n";            mHDC = 0;            return;        }        if (mSettings.profile == Context::GL32)        {            mSettings.context.vMajor = 3;            mSettings.context.vMinor = 2;        }        GLint attribs[] = {            WGL_CONTEXT_MAJOR_VERSION_ARB, mSettings.context.vMajor,            WGL_CONTEXT_MINOR_VERSION_ARB, mSettings.context.vMinor,            0 };        mHGLRC = wglCreateContextAttribsARB(mHDC, 0, attribs);        if (!mHGLRC)        {            std::cerr << "wglCreateContextAttribsARB failed/n";            return;        }    }
开发者ID:binary-cocoa,项目名称:LegacyXPG,代码行数:50,


示例10: EVE_LOG_ERROR

//=================================================================================================void eve::ogl::SubContext::init(void){	// Get DC from window handle.	m_hDC = ::GetDC(m_hWnd);	if (m_hDC == 0)	{		EVE_LOG_ERROR("Paint device cannot be null. GetDC() failed %s", eve::mess::get_error_msg().c_str());		EVE_ASSERT_FAILURE;	}	// Apply pixel format to DC.	if (::SetPixelFormat(m_hDC, eve::ogl::Context::get_pixel_format_ID(), &eve::ogl::Context::get_pixel_format_descriptor()) == 0)	{		EVE_LOG_ERROR("Unable to link pixel format to DC, SetPixelFormat() failed %s", eve::mess::get_error_msg().c_str());		EVE_ASSERT_FAILURE;	}#ifndef NDEBUG	static const int contextAttribs[] = { WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, 0 };#else	static const int contextAttribs[] = { 0 };#endif	// Create context (GLRC).	m_hGLRC = wglCreateContextAttribsARB(m_hDC, eve::ogl::Context::get_handle(), contextAttribs);	if (m_hGLRC == 0)	{		EVE_LOG_ERROR("Unable to create rendering context, wglCreateContext() failed %s", eve::mess::get_error_msg().c_str());		EVE_ASSERT_FAILURE;	}	// Make context current (has to be activated here to enforce DC bound).	if (::wglMakeCurrent(m_hDC, m_hGLRC) == 0)	{		EVE_LOG_ERROR("Unable to attach context, wglMakeCurrent() failed %s", eve::mess::get_error_msg().c_str());		EVE_ASSERT_FAILURE;	}	// Init OpenGL extensions for this context.	eve::ogl::Context::init_OpenGL();	// Release context.	if (::wglMakeCurrent(0, 0) == 0)	{		EVE_LOG_ERROR("Unable to detach context, wglMakeCurrent(0, 0) failed %s", eve::mess::get_error_msg().c_str());		EVE_ASSERT_FAILURE;	}}
开发者ID:mrvux,项目名称:Eve,代码行数:51,


示例11: wglGetCurrentContext

COffscreenGLContext::COffscreenGLContext(){	//! this creates a 2nd OpenGL context on the >onscreen< window/HDC	//! so don't render to the the default framebuffer (always bind FBOs,DLs,...) !!!	if (!mainGlActiveTexture)		mainGlActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTexture");	//! get the main (onscreen) GL context	HGLRC mainRC = wglGetCurrentContext();	hdc = wglGetCurrentDC();	if (!hdc || !mainRC) {		throw opengl_error("Couldn't create an offscreen GL context: wglGetCurrentDC failed!");	}	int status = TRUE;	offscreenRC = NULL;#ifdef WGL_ARB_create_context	if (wglCreateContextAttribsARB) {		static const int contextAttribs[] = { WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, 0 };		offscreenRC = wglCreateContextAttribsARB(hdc, mainRC, contextAttribs);		if (!offscreenRC)			LOG_L(L_WARNING, "Couldn't create an offscreen GL context: wglCreateContextAttribsARB failed!");	}#endif	if (!offscreenRC) {		//! create a 2nd GL context		offscreenRC = wglCreateContext(hdc);		if (!offscreenRC) {			throw opengl_error("Couldn't create an offscreen GL context: wglCreateContext failed!");		}		//! share the GL resources (textures,DLists,shaders,...)		if (!wglMakeCurrent(NULL, NULL))			throw opengl_error("Could not deactivate rendering context");		status = wglShareLists(mainRC, offscreenRC);		if (!wglMakeCurrent(hdc, mainRC))			throw opengl_error("Could not activate rendering context");	}	if (!status) {		DWORD err = GetLastError();		char msg[256];		SNPRINTF(msg, 255, "Couldn't create an offscreen GL context: wglShareLists failed (error: %i)!", (int)err);		throw opengl_error(msg);	}}
开发者ID:DoctorEmmettBrown,项目名称:spring,代码行数:47,


示例12: CreateOpenGLContextOnDC

static HGLRC CreateOpenGLContextOnDC( const HDC hdc, const bool debugContext ) {    HGLRC m_hrc = NULL;    int useOpenGL32 = r_useOpenGL32.GetInteger();    for ( int i = 0; i < 2; i++ ) {        const int glMajorVersion = ( useOpenGL32 != 0 ) ? 3 : 2;        const int glMinorVersion = ( useOpenGL32 != 0 ) ? 2 : 0;        const int glDebugFlag = debugContext ? WGL_CONTEXT_DEBUG_BIT_ARB : 0;        const int glProfileMask = ( useOpenGL32 != 0 ) ? WGL_CONTEXT_PROFILE_MASK_ARB : 0;        const int glProfile = ( useOpenGL32 == 1 ) ? WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : ( ( useOpenGL32 == 2 ) ? WGL_CONTEXT_CORE_PROFILE_BIT_ARB : 0 );        const int attribs[] =        {            WGL_CONTEXT_MAJOR_VERSION_ARB,	glMajorVersion,            WGL_CONTEXT_MINOR_VERSION_ARB,	glMinorVersion,            WGL_CONTEXT_FLAGS_ARB,			glDebugFlag,            glProfileMask,					glProfile,            0        };        m_hrc = wglCreateContextAttribsARB( hdc, 0, attribs );        if ( m_hrc != NULL ) {            idLib::Printf( "created OpenGL %d.%d context/n", glMajorVersion, glMinorVersion );            break;        }        idLib::Printf( "failed to create OpenGL %d.%d context/n", glMajorVersion, glMinorVersion );        useOpenGL32 = 0;	// fall back to OpenGL 2.0    }    if ( m_hrc == NULL ) {        int	err = GetLastError();        switch( err ) {        case ERROR_INVALID_VERSION_ARB:            idLib::Printf( "ERROR_INVALID_VERSION_ARB/n" );            break;        case ERROR_INVALID_PROFILE_ARB:            idLib::Printf( "ERROR_INVALID_PROFILE_ARB/n" );            break;        default:            idLib::Printf( "unknown error: 0x%x/n", err );            break;        }    }    return m_hrc;}
开发者ID:neilogd,项目名称:DOOM-3-BFG,代码行数:45,


示例13: set_active

	HGLRC OpenGLCreationHelper::create_opengl3_context(HGLRC share_context, int major_version, int minor_version, const OpenGLContextDescription &gldesc)	{		set_active();		ptr_wglCreateContextAttribsARB wglCreateContextAttribsARB = (ptr_wglCreateContextAttribsARB)wglGetProcAddress("wglCreateContextAttribsARB");		HGLRC opengl3_context = 0;		if (wglCreateContextAttribsARB)		{			std::vector<int> int_attributes;			int_attributes.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB);			int_attributes.push_back(major_version);			int_attributes.push_back(WGL_CONTEXT_MINOR_VERSION_ARB);			int_attributes.push_back(minor_version);			int_attributes.push_back(0x2093);	// WGL_CONTEXT_LAYER_PLANE_ARB			int_attributes.push_back(gldesc.get_layer_plane());			int_attributes.push_back(0x2094);	// WGL_CONTEXT_FLAGS_ARB			int flags = 0;			if (gldesc.get_debug())				flags |= 0x1;	// WGL_CONTEXT_DEBUG_BIT_ARB			if (gldesc.get_forward_compatible())	// WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB				flags |= 0x2;			int_attributes.push_back(flags);			int_attributes.push_back(0x9126);	// WGL_CONTEXT_PROFILE_MASK_ARB			flags = 0;			if (gldesc.get_core_profile())				flags |= 0x1;	// WGL_CONTEXT_CORE_PROFILE_BIT_ARB			if (gldesc.get_compatibility_profile())	// WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB				flags |= 0x2;			int_attributes.push_back(flags);			int_attributes.push_back(0);			opengl3_context = wglCreateContextAttribsARB(hdc, share_context, &int_attributes[0]);		}		reset_active();		return opengl3_context;	}
开发者ID:keigen-shu,项目名称:ClanLib,代码行数:43,


示例14: wglMakeCurrent

bool zglCoreContextWin::CreateCoreContext(){    if ( !m_tempContext )        return false;    bool makeCurResult = wglMakeCurrent( m_hDC, m_tempContext );    bool bCore = GL_LoadCreateWinCoreContext();    if (!bCore)        return false;    GetGLVersion(&m_major, &m_minor);    if( !makeCurResult || m_major < MAJOR || ( m_major == MAJOR && m_minor < MINOR ) )    {        wglMakeCurrent(NULL,NULL);        wglDeleteContext(m_tempContext);        return false;    }    int attribs[] =    {        WGL_CONTEXT_MAJOR_VERSION_ARB, m_major,        WGL_CONTEXT_MINOR_VERSION_ARB, m_minor,        WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,        0    };    m_Context = wglCreateContextAttribsARB(m_hDC,0, attribs);    if ( !m_Context )        return false;    LoadGL();    wglMakeCurrent(NULL,NULL);    wglDeleteContext(m_tempContext);    return true;}
开发者ID:Zandriy,项目名称:OGL_4,代码行数:42,


示例15: gl_init_context

static inline HGLRC gl_init_context(HDC hdc){#ifdef _DEBUG	if (wgl_ext_ARB_create_context) {		HGLRC hglrc = wglCreateContextAttribsARB(hdc, 0, attribs);		if (!hglrc) {			blog(LOG_ERROR, "wglCreateContextAttribsARB failed, %u",					GetLastError());			return NULL;		}		if (!wgl_make_current(hdc, hglrc)) {			wglDeleteContext(hglrc);			return NULL;		}		return hglrc;	}#endif	return gl_init_basic_context(hdc);}
开发者ID:Tyrrr,项目名称:obs-studio,代码行数:22,


示例16: ContextImpl

    WGLContextImpl::WGLContextImpl(const WindowHandle& windowHandle) : ContextImpl(windowHandle)    {        deviceContext = GetDC(windowHandle.hwnd);        PIXELFORMATDESCRIPTOR pfd;        memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));        pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);        pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;        pfd.iPixelType = PFD_TYPE_RGBA;        pfd.cColorBits = 32;        pfd.cDepthBits = 32;        pfd.iLayerType = PFD_MAIN_PLANE;        int nPixelFormat = ChoosePixelFormat(deviceContext, &pfd);        if (nPixelFormat == 0) {            MessageBox(NULL, "ChoosePixelFormat Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);        }        int bResult = SetPixelFormat(deviceContext, nPixelFormat, &pfd);        if (!bResult) {            MessageBox(NULL, "SetPixelFormat Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);        }        HGLRC tempContext = wglCreateContext(deviceContext);        wglMakeCurrent(deviceContext, tempContext);        int attributes[] = {            WGL_CONTEXT_MAJOR_VERSION_ARB, 3,            WGL_CONTEXT_MINOR_VERSION_ARB, 3,            WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,            0        };        renderContext = wglCreateContextAttribsARB(deviceContext, NULL, attributes);        wglMakeCurrent(NULL, NULL);        wglDeleteContext(tempContext);        wglMakeCurrent(deviceContext, renderContext);    }
开发者ID:dvdbrink,项目名称:ion,代码行数:38,


示例17: GetDC

bool GLContext::create30Context() {	running = true;	render = NULL;	hdc = GetDC(hwnd);	PIXELFORMATDESCRIPTOR pfd;	memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)); 	pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);	pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL;// | PFD_DRAW_TO_WINDOW;	pfd.iPixelType = PFD_TYPE_RGBA;	pfd.cColorBits = 32;	pfd.cDepthBits = 32;	pfd.iLayerType = PFD_MAIN_PLANE;	int nPixelFormat = ChoosePixelFormat(hdc, &pfd);	if (nPixelFormat == 0)		return false;	int bResult = SetPixelFormat(hdc, nPixelFormat, &pfd);	if (!bResult)		return false;	HGLRC tempOGLWidget = wglCreateContext(hdc);	wglMakeCurrent(hdc, tempOGLWidget);	GLenum error = glewInit();	if (error != GLEW_OK)		return false;		 	int attributes[] = 	{		WGL_CONTEXT_MAJOR_VERSION_ARB, 4,		WGL_CONTEXT_MINOR_VERSION_ARB, 1,		WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, 		0	};	if (wglewIsSupported("WGL_ARB_create_context") == 1) 	{		hrc = wglCreateContextAttribsARB(hdc, NULL, attributes);		wglMakeCurrent(NULL, NULL);		wglDeleteContext(tempOGLWidget);		wglMakeCurrent(hdc, hrc);	}	else 	{		hrc = tempOGLWidget; 	}	int glVersion[2] = {-1, -1}; 	glGetIntegerv(GL_MAJOR_VERSION, &glVersion[0]);	glGetIntegerv(GL_MINOR_VERSION, &glVersion[1]);	std::cout << "Using OpenGL: " << glVersion[0] << "." << glVersion[1] << std::endl; // Output which version of OpenGL we are using		render = new Render();	render->Init();	SetWindowLongPtr( hwnd, GWLP_USERDATA, reinterpret_cast<long>(render));	return true; // We have successfully created a context, return true}
开发者ID:rasmusgo,项目名称:virtual-sculpting,代码行数:63,


示例18: CreateEx

// 创建opengl窗口BOOL GLWindow::CreateGlWnd(const char* title, int x, int y, int width, int height){    m_width = width;    m_height = height;    RECT windowRect = { 0, 0, width, height };    DWORD windowStyle = WS_OVERLAPPEDWINDOW;   // 预留做全屏    DWORD windowExStyle = WS_EX_APPWINDOW;     // 扩展样式    // 全屏处理 - 预留    // 窗口样式    //windowStyle = WS_POPUP;    //windowExStyle |= WS_EX_TOPMOST;    ::AdjustWindowRectEx(&windowRect, windowStyle, 0, windowExStyle); // 调整窗口    CreateEx(0, "OpenGL", title, WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,             x, y, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, NULL, NULL);    if (!(m_hDc = GetDC(m_hWnd)))  // 获取DC    {        DestroyGL();		  // 销毁        return FALSE;		  // 不能获取DC    }    m_timerFrame = 1000;      // 初始化    GLuint PixelFormat;    static PIXELFORMATDESCRIPTOR pdf = {        sizeof(PIXELFORMATDESCRIPTOR),  // 结构体大小        1,					  // 版本号        PFD_DRAW_TO_WINDOW |  // 支持窗口        PFD_SUPPORT_OPENGL |  // 支持opengl        PFD_DOUBLEBUFFER,     // 支持双缓冲        PFD_TYPE_RGBA,        // 申请RGBA格式        32,					  // 色彩深度        0, 0, 0, 0, 0, 0,     // 忽略的色彩位        0,					  // 无alpha缓存        0,					  // 无shift Bit        0,					  // 无累加缓存        0, 0, 0, 0,			  // 忽略聚集位        24,					  // 16位Z-缓存        8,					  // 无蒙版缓存        0,					  // 无辅助缓存        PFD_MAIN_PLANE,		  // 主绘图层        0,					  // Reserved        0, 0, 0				  // 忽略层遮罩    };    if (!(PixelFormat = ChoosePixelFormat(m_hDc, &pdf)))  // 寻找相应像素格式    {        DestroyGL();  // 销毁        // printf("1====error choose====");        return FALSE;    }    if (!SetPixelFormat(m_hDc, PixelFormat, &pdf))    {        DestroyGL();        // printf("1====error choose====");        return FALSE;        // 不能设置像素格式    }    HGLRC tempContext;    if (!(tempContext = wglCreateContext(m_hDc)))    {        DestroyGL();        // printf("2====error create context====");        return FALSE;      // 不能获得着色描述表    }    if (!wglMakeCurrent(m_hDc, tempContext))  // 开启低版本opengl    {        DestroyGL();        // printf("3========");        return FALSE;      // 不能激活当前opengl渲染描述表    }    if (GLEW_OK != glewInit())    {        DestroyGL();        return FALSE;      // glew初始化失败    }    // 开启 opengl 4.3 支持    GLint attribs[] = { WGL_CONTEXT_MAJOR_VERSION_ARB,  4,  // 主版本4                        WGL_CONTEXT_MINOR_VERSION_ARB,  3,					// 次版本号3                        WGL_CONTEXT_PROFILE_MASK_ARB,WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,//要求返回兼容模式环境,如果不指定或指定为WGL_CONTEXT_CORE_PROFILE_BIT_ARB会返回只包含核心功能的环境                        0                      };    if (wglewIsSupported("WGL_ARB_create_context") == 1)    {        m_hRc = wglCreateContextAttribsARB(m_hDc, 0, attribs);        wglMakeCurrent(NULL, NULL);        wglDeleteContext(tempContext);        int result = wglMakeCurrent(m_hDc, m_hRc); // 设置opengl 4.3        if (result != 1)        {//.........这里部分代码省略.........
开发者ID:tencence,项目名称:ApanooEngine,代码行数:101,


示例19: switch

		LRESULT WindowsEventLoop::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)		{			int zDelta=0;			switch(uMsg)			{				case WM_CREATE:				{					m_hdc = GetDC(hWnd);					SetupPixelFormat();					int attribs[] = {						WGL_CONTEXT_MAJOR_VERSION_ARB, 3,						WGL_CONTEXT_MINOR_VERSION_ARB, 0,					0};					HGLRC tmpContext = wglCreateContext(m_hdc);					wglMakeCurrent(m_hdc, tmpContext);					wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) wglGetProcAddress("wglCreateContextAttribsARB");					if (!wglCreateContextAttribsARB)					{						//m_logger->Print(CLogger::Failure,"OpenGL 3.0 is not supported, falling back to GL 2.1");						m_hglrc = tmpContext;					}					else					{						m_hglrc = wglCreateContextAttribsARB(m_hdc, 0, attribs);						wglDeleteContext(tmpContext);					}					wglMakeCurrent(m_hdc, m_hglrc);					m_isRunning = true;				}				break;				case WM_DESTROY:				case WM_CLOSE:					wglMakeCurrent(m_hdc, NULL);					wglDeleteContext(m_hglrc);					m_isRunning = false;					PostQuitMessage(0);					return 0;				break;				case WM_SIZE:				{					m_height = HIWORD(lParam);					m_width = LOWORD(lParam);					m_pActivityHandler->onDeactivate();					Render::SetScreenSize(m_width,m_height);					m_pActivityHandler->onActivate();				}				break;				case WM_KEYDOWN:					Global::pContext->pInputService->GetKeyboard()->HandleKeyDown(Global::pContext->pInputService->GetKeyboard()->TranslateCode(wParam));				break;				case WM_KEYUP:					Global::pContext->pInputService->GetKeyboard()->HandleKeyUp(Global::pContext->pInputService->GetKeyboard()->TranslateCode(wParam));				break;				case WM_MOUSEWHEEL:					zDelta = GET_WHEEL_DELTA_WPARAM(wParam);					//m_input->m_currMouse->Wheel+=zDelta;				break;				case WM_KILLFOCUS:					m_enabled=true;				break;				case WM_SETFOCUS:					m_enabled=false;				break;				default:				break;			}			return DefWindowProc(hWnd, uMsg, wParam, lParam);		}
开发者ID:gitter-badger,项目名称:MPACK,代码行数:76,


示例20: SetupWindow

//.........这里部分代码省略.........    DestroyWindow(g_hWnd);    // Create the window again    g_hWnd = CreateWindowEx(dwExtStyle,     // Extended style                            szClassName,    // class name                            szWindowName,   // window name                            dwWindStyle |                                    WS_CLIPSIBLINGS |                             WS_CLIPCHILDREN,// window stlye                            nWindowX,       // window position, x                            nWindowY,       // window position, y                            nWindowWidth,   // height                            nWindowHeight,  // width                            NULL,           // Parent window                            NULL,           // menu                            g_hInstance,    // instance                            NULL);          // pass this to WM_CREATE    g_hDC = GetDC(g_hWnd);    int nPixCount = 0;    // Specify the important attributes we care about    int pixAttribs[] = { WGL_SUPPORT_OPENGL_ARB, 1, // Must support OGL rendering                         WGL_DRAW_TO_WINDOW_ARB, 1, // pf that can run a window                         WGL_ACCELERATION_ARB,   1, // must be HW accelerated                         WGL_RED_BITS_ARB,       8, // 8 bits of red precision in window                         WGL_GREEN_BITS_ARB,     8, // 8 bits of green precision in window                         WGL_BLUE_BITS_ARB,      8, // 8 bits of blue precision in window                         WGL_DEPTH_BITS_ARB,     16, // 16 bits of depth precision for window                         WGL_PIXEL_TYPE_ARB,      WGL_TYPE_RGBA_ARB, // pf should be RGBA type                         0}; // NULL termination    // Ask OpenGL to find the most relevant format matching our attribs    // Only get one format back.    wglChoosePixelFormatARB(g_hDC, &pixAttribs[0], NULL, 1, &nPixelFormat, (UINT*)&nPixCount);    if(nPixelFormat == -1)     {        // Couldn't find a format, perhaps no 3D HW or drivers are installed        g_hDC = 0;        g_hDC = 0;        bRetVal = false;        printf("!!! An error occurred trying to find a pixel format with the requested attribs./n");    }    else    {        // Got a format, now set it as the current one        SetPixelFormat( g_hDC, nPixelFormat, &pfd );        GLint attribs[] = {WGL_CONTEXT_MAJOR_VERSION_ARB,  3,	                       WGL_CONTEXT_MINOR_VERSION_ARB,  3,                           0 };                g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);        if (g_hRC == NULL)        {            printf("!!! Could not create an OpenGL 3.3 context./n");            attribs[3] = 2;            g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);            if (g_hRC == NULL)            {                printf("!!! Could not create an OpenGL 3.2 context./n");                attribs[3] = 1;                g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);                if (g_hRC == NULL)                {                    printf("!!! Could not create an OpenGL 3.1 context./n");                    attribs[3] = 0;                    g_hRC = wglCreateContextAttribsARB(g_hDC, 0, attribs);                    if (g_hRC == NULL)                    {                        printf("!!! Could not create an OpenGL 3.0 context./n");                        printf("!!! OpenGL 3.0 and higher are not supported on this system./n");                    }                }            }        }        wglMakeCurrent( g_hDC, g_hRC );    }    if (g_hDC == 0 ||        g_hDC == 0)    {        bRetVal = false;        printf("!!! An error occured creating an OpenGL window./n");    }    // If everything went as planned, display the window     if( bRetVal )    {        ShowWindow( g_hWnd, SW_SHOW );        SetForegroundWindow( g_hWnd );        SetFocus( g_hWnd );        g_ContinueRendering = true;    }        return bRetVal;}
开发者ID:1085075003,项目名称:oglsuperbible5,代码行数:101,


示例21: glewCreateContext

GLboolean glewCreateContext (struct createParams* params){  WNDCLASS wc;  PIXELFORMATDESCRIPTOR pfd;  /* register window class */  ZeroMemory(&wc, sizeof(WNDCLASS));  wc.hInstance = GetModuleHandle(NULL);  wc.lpfnWndProc = DefWindowProc;  wc.lpszClassName = "GLEW";  if (0 == RegisterClass(&wc)) return GL_TRUE;  /* create window */  wnd = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,                      CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL);  if (NULL == wnd) return GL_TRUE;  /* get the device context */  dc = GetDC(wnd);  if (NULL == dc) return GL_TRUE;  /* find pixel format */  ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));  if (params->pixelformat == -1) /* find default */  {    pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);    pfd.nVersion = 1;    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;    params->pixelformat = ChoosePixelFormat(dc, &pfd);    if (params->pixelformat == 0) return GL_TRUE;  }  /* set the pixel format for the dc */  if (FALSE == SetPixelFormat(dc, params->pixelformat, &pfd)) return GL_TRUE;  /* create rendering context */  rc = wglCreateContext(dc);  if (NULL == rc) return GL_TRUE;  if (FALSE == wglMakeCurrent(dc, rc)) return GL_TRUE;  if (params->major || params->profile || params->flags)  {    HGLRC oldRC = rc;    int contextAttrs[20];    int i;    wglewInit();    /* Intel HD 3000 has WGL_ARB_create_context, but not WGL_ARB_create_context_profile */    if (!wglewGetExtension("WGL_ARB_create_context"))      return GL_TRUE;    i = 0;    if (params->major)    {      contextAttrs[i++] = WGL_CONTEXT_MAJOR_VERSION_ARB;      contextAttrs[i++] = params->major;      contextAttrs[i++] = WGL_CONTEXT_MINOR_VERSION_ARB;      contextAttrs[i++] = params->minor;    }    if (params->profile)    {      contextAttrs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB;      contextAttrs[i++] = params->profile;    }    if (params->flags)    {      contextAttrs[i++] = WGL_CONTEXT_FLAGS_ARB;      contextAttrs[i++] = params->flags;    }    contextAttrs[i++] = 0;    rc = wglCreateContextAttribsARB(dc, 0, contextAttrs);    if (NULL == rc) return GL_TRUE;    if (!wglMakeCurrent(dc, rc)) return GL_TRUE;    wglDeleteContext(oldRC);  }  return GL_FALSE;}
开发者ID:donbright,项目名称:glew,代码行数:73,


示例22: WinMain

//.........这里部分代码省略.........            PezFatalError("Could not load function pointer for 'wglChoosePixelFormatARB'.  Is your driver properly installed?");        }        // Try fewer and fewer samples per pixel till we find one that is supported:        while (pixelFormat <= 0 && *sampleCount >= 0)        {            wglChoosePixelFormatARB(hDC, pixelAttribs, 0, 1, &pixelFormat, &numFormats);            (*sampleCount)--;            if (*sampleCount <= 1)            {                *useSampleBuffer = GL_FALSE;            }        }        // Win32 allows the pixel format to be set only once per app, so destroy and re-create the app:        DestroyWindow(hWnd);        hWnd = CreateWindowExA(0, szName, szName, dwStyle, windowLeft, windowTop, windowWidth, windowHeight, 0, 0, 0, 0);        SetWindowPos(hWnd, HWND_TOP, windowLeft, windowTop, windowWidth, windowHeight, 0);        hDC = GetDC(hWnd);        SetPixelFormat(hDC, pixelFormat, &pfd);        hRC = wglCreateContext(hDC);        wglMakeCurrent(hDC, hRC);    }#define PEZ_TRANSPARENT_WINDOW 0    // For transparency, this doesn't seem to work.  I think I'd need to read back from an OpenGL FBO and blit it with GDI.    if (PEZ_TRANSPARENT_WINDOW)    {        long flag = GetWindowLong(hWnd, GWL_EXSTYLE);        int opacity = 128;        flag |= WS_EX_LAYERED;        SetWindowLong(hWnd, GWL_EXSTYLE, flag);        SetLayeredWindowAttributes(hWnd, 0, opacity, LWA_ALPHA);		    }    err = glewInit();    if (GLEW_OK != err)    {        PezFatalError("GLEW Error: %s/n", glewGetErrorString(err));    }    PezDebugString("OpenGL Version: %s/n", glGetString(GL_VERSION));    if (!PEZ_VERTICAL_SYNC)    {        wglSwapIntervalEXT(0);    }    if (PEZ_FORWARD_COMPATIBLE_GL && glewIsSupported("GL_VERSION_3_0"))    {        const int contextAttribs[] =        {            WGL_CONTEXT_MAJOR_VERSION_ARB, 3,            WGL_CONTEXT_MINOR_VERSION_ARB, 0,            WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,            0        };        HGLRC newRC = wglCreateContextAttribsARB(hDC, 0, contextAttribs);        wglMakeCurrent(0, 0);        wglDeleteContext(hRC);        hRC = newRC;        wglMakeCurrent(hDC, hRC);    }    {        const char* szWindowTitle = PezInitialize(PEZ_VIEWPORT_WIDTH, PEZ_VIEWPORT_HEIGHT);        SetWindowTextA(hWnd, szWindowTitle);    }    // -------------------    // Start the Game Loop    // -------------------    while (msg.message != WM_QUIT)    {        if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))        {            TranslateMessage(&msg);            DispatchMessage(&msg);        }        else        {            DWORD currentTime = GetTickCount();            DWORD deltaTime = currentTime - previousTime;            previousTime = currentTime;            PezUpdate(deltaTime);            PezRender();            SwapBuffers(hDC);            if (glGetError() != GL_NO_ERROR)            {                PezFatalError("OpenGL error./n");            }        }    }    UnregisterClass(szName, wc.hInstance);    return 0;}
开发者ID:jsj2008,项目名称:blog-source,代码行数:101,


示例23: Platform

// TODO: Fix Fullscreen + More error handling.Platform* Platform::create(Game* game){    FileSystem::setResourcePath("./");    Platform* platform = new Platform(game);    // Get the application module handle.    __hinstance = ::GetModuleHandle(NULL);    LPCTSTR windowClass = L"gameplay";    LPCTSTR windowName = L"";    RECT rect = { 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT };    // Register our window class.    WNDCLASSEX wc;    wc.cbSize = sizeof(WNDCLASSEX);    wc.style          = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;    wc.lpfnWndProc    = (WNDPROC)__WndProc;    wc.cbClsExtra     = 0;    wc.cbWndExtra     = 0;    wc.hInstance      = __hinstance;    wc.hIcon          = LoadIcon(NULL, IDI_APPLICATION);    wc.hIconSm        = NULL;    wc.hCursor        = LoadCursor(NULL, IDC_ARROW);    wc.hbrBackground  = NULL;  // No brush - we are going to paint our own background    wc.lpszMenuName   = NULL;  // No default menu    wc.lpszClassName  = windowClass;    if (!::RegisterClassEx(&wc))        goto error;        // Set the window style.    DWORD style   = ( WINDOW_FULLSCREEN ? WS_POPUP : WS_POPUP | WS_BORDER | WS_CAPTION | WS_SYSMENU) | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;    DWORD styleEx = (WINDOW_FULLSCREEN ? WS_EX_APPWINDOW : WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);    // Adjust the window rectangle so the client size is the requested size.    AdjustWindowRectEx(&rect, style, FALSE, styleEx);        // Create the native Windows window.    __hwnd = CreateWindowEx(styleEx, windowClass, windowName, style, 0, 0, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, __hinstance, NULL);    // Get the drawing context.    __hdc = GetDC(__hwnd);    // Choose pixel format. 32-bit. RGBA.    PIXELFORMATDESCRIPTOR pfd;    memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));    pfd.nSize  = sizeof(PIXELFORMATDESCRIPTOR);    pfd.nVersion   = 1;    pfd.dwFlags    = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;    pfd.iPixelType = PFD_TYPE_RGBA;    pfd.cColorBits = 32;    pfd.cDepthBits = 32;    pfd.iLayerType = PFD_MAIN_PLANE;    int pixelFormat = ChoosePixelFormat(__hdc, &pfd);    if (pixelFormat == 0 || !SetPixelFormat (__hdc, pixelFormat, &pfd))        goto error;    HGLRC tempContext = wglCreateContext(__hdc);    wglMakeCurrent(__hdc, tempContext);    if (GLEW_OK != glewInit())        goto error;    int attribs[] =    {        WGL_CONTEXT_MAJOR_VERSION_ARB, 3,        WGL_CONTEXT_MINOR_VERSION_ARB, 1,        0    };    if (!(__hrc = wglCreateContextAttribsARB(__hdc, 0, attribs) ) )    {        wglDeleteContext(tempContext);        goto error;    }    wglDeleteContext(tempContext);    if (!wglMakeCurrent(__hdc, __hrc) || !__hrc)        goto error;    // Vertical sync.    wglSwapIntervalEXT(__vsync ? 1 : 0);    // Show the window    ShowWindow(__hwnd, SW_SHOW);    return platform;error:    // TODO: cleanup    exit(0);    return NULL;}
开发者ID:aaweb,项目名称:GamePlay,代码行数:99,


示例24: initGLBase

bool initGLBase(){    GLuint PixelFormat;        PIXELFORMATDESCRIPTOR pfd;    memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));    pfd.nSize      = sizeof(PIXELFORMATDESCRIPTOR);    pfd.nVersion   = 1;    pfd.dwFlags    = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;    pfd.iPixelType = PFD_TYPE_RGBA;    pfd.cColorBits = 32;    pfd.cDepthBits = 24;    pfd.cStencilBits = 8;        g_hDC = GetDC( g_hWnd );    PixelFormat = ChoosePixelFormat( g_hDC, &pfd );    SetPixelFormat( g_hDC, PixelFormat, &pfd);    g_hRC = wglCreateContext( g_hDC );    wglMakeCurrent( g_hDC, g_hRC );    // calling glewinit NOW because the inside glew, there is mistake to fix...    // This is the joy of using Core. The query glGetString(GL_EXTENSIONS) is deprecated from the Core profile.    // You need to use glGetStringi(GL_EXTENSIONS, <index>) instead. Sounds like a "bug" in GLEW.    glewInit();    //wglSwapInterval(0);#if 1#define GLCOMPAT    if(!wglCreateContextAttribsARB)        wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");    if(wglCreateContextAttribsARB)    {        HGLRC hRC = NULL;        int attribList[] =        {            WGL_CONTEXT_MAJOR_VERSION_ARB, 3,            WGL_CONTEXT_MINOR_VERSION_ARB, 3,#ifdef GLCOMPAT            WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,#else            WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,#endif            WGL_CONTEXT_FLAGS_ARB,            //WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB|#ifndef GLCOMPAT            //WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB| // use it if you want errors when compat options still used#endif#ifdef _DEBUG            WGL_CONTEXT_DEBUG_BIT_ARB#else            0#endif            ,0, 0        };        if (!(hRC = wglCreateContextAttribsARB(g_hDC, 0, attribList)))        {            LOGE("wglCreateContextAttribsARB() failed for OpenGL context./n");            return false;            //attribList[3] = 0;            //if (!(hRC = wglCreateContextAttribsARB(g_hDC, 0, attribList)))            //    LOGE("wglCreateContextAttribsARB() failed for OpenGL context./n");        }        if (!wglMakeCurrent(g_hDC, hRC))        { LOGE("wglMakeCurrent() failed for OpenGL context./n"); }        else {            wglDeleteContext( g_hRC );            g_hRC = hRC;#ifdef _DEBUG            if(!glDebugMessageCallbackARB)            {                glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)wglGetProcAddress("glDebugMessageCallbackARB");                glDebugMessageControlARB =  (PFNGLDEBUGMESSAGECONTROLARBPROC)wglGetProcAddress("glDebugMessageControlARB");            }            if(glDebugMessageCallbackARB)            {                glDebugMessageCallbackARB(myOpenGLCallback, NULL);                glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);            }#endif        }    }#endif    glewInit();    LOGOK("Loaded Glew/n");    LOGOK("initialized OpenGL basis/n");    return true;}
开发者ID:dquam,项目名称:Bak3d,代码行数:87,


示例25: create_context_w32_gl3

static bool create_context_w32_gl3(struct MPGLContext *ctx){    struct w32_context *w32_ctx = ctx->priv;    HDC windc = w32_ctx->hdc;    HGLRC context = 0;    // A legacy context is needed to get access to the new functions.    HGLRC legacy_context = wglCreateContext(windc);    if (!legacy_context) {        MP_FATAL(ctx->vo, "Could not create GL context!/n");        return false;    }    // set context    if (!wglMakeCurrent(windc, legacy_context)) {        MP_FATAL(ctx->vo, "Could not set GL context!/n");        goto out;    }    const char *(GLAPIENTRY *wglGetExtensionsStringARB)(HDC hdc)        = w32gpa((const GLubyte*)"wglGetExtensionsStringARB");    if (!wglGetExtensionsStringARB)        goto unsupported;    const char *wgl_exts = wglGetExtensionsStringARB(windc);    if (!strstr(wgl_exts, "WGL_ARB_create_context"))        goto unsupported;    HGLRC (GLAPIENTRY *wglCreateContextAttribsARB)(HDC hDC, HGLRC hShareContext,                                                   const int *attribList)        = w32gpa((const GLubyte*)"wglCreateContextAttribsARB");    if (!wglCreateContextAttribsARB)        goto unsupported;    int attribs[] = {        WGL_CONTEXT_MAJOR_VERSION_ARB, 3,        WGL_CONTEXT_MINOR_VERSION_ARB, 0,        WGL_CONTEXT_FLAGS_ARB, 0,        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,        0    };    context = wglCreateContextAttribsARB(windc, 0, attribs);    if (!context) {        // NVidia, instead of ignoring WGL_CONTEXT_FLAGS_ARB, will error out if        // it's present on pre-3.2 contexts.        // Remove it from attribs and retry the context creation.        attribs[6] = attribs[7] = 0;        context = wglCreateContextAttribsARB(windc, 0, attribs);    }    if (!context) {        int err = GetLastError();        MP_FATAL(ctx->vo, "Could not create an OpenGL 3.x context: error 0x%x/n", err);        goto out;    }    wglMakeCurrent(windc, NULL);    wglDeleteContext(legacy_context);    if (!wglMakeCurrent(windc, context)) {        MP_FATAL(ctx->vo, "Could not set GL3 context!/n");        wglDeleteContext(context);        return false;    }    w32_ctx->context = context;    /* update function pointers */    mpgl_load_functions(ctx->gl, w32gpa, NULL, ctx->vo->log);    return true;unsupported:    MP_ERR(ctx->vo, "The OpenGL driver does not support OpenGL 3.x /n");out:    wglMakeCurrent(windc, NULL);    wglDeleteContext(legacy_context);    return false;}
开发者ID:Jim-Duke,项目名称:mpv,代码行数:82,


示例26: void

// Initializes OpenGL rendering context. If succeeds, returns true.// hInstance - application instance// a_hWnd - window to init OpenGL into// a_initScene - pointer to init function// a_renderScene - pointer to render function// a_releaseScene - optional parameter of release functionbool COpenGLControl::InitOpenGL(HINSTANCE hInstance, HWND* a_hWnd, void (*a_InitScene)(LPVOID), void (*a_RenderScene)(LPVOID), void(*a_ReleaseScene)(LPVOID), LPVOID lpParam){	if(!InitGLEW(hInstance))return false;	hWnd = a_hWnd;	hDC = GetDC(*hWnd);	bool bError = false;	PIXELFORMATDESCRIPTOR pfd;	// if we have access to these functions	if(WGLEW_ARB_create_context && WGLEW_ARB_pixel_format)	{		const int iPixelFormatAttribList[] =		{			WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,			WGL_SUPPORT_OPENGL_ARB, GL_TRUE, // Enable OpenGL support			WGL_DOUBLE_BUFFER_ARB, GL_TRUE,  // and double buffer			WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,			WGL_COLOR_BITS_ARB, 32,			WGL_DEPTH_BITS_ARB, 24, // Depth buffer size			WGL_STENCIL_BITS_ARB, 8,			0 // End of attributes list		};		int iContextAttribs[] =		{			WGL_CONTEXT_MAJOR_VERSION_ARB, 3, // OpenGL 			WGL_CONTEXT_MINOR_VERSION_ARB, 3, // version 3.3			WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,			0 // End of attributes list		};		int iPixelFormat, iNumFormats;		wglChoosePixelFormatARB(hDC, iPixelFormatAttribList, NULL, 1, &iPixelFormat, (UINT*)&iNumFormats);		// PFD seems to be only redundant parameter now		if(!SetPixelFormat(hDC, iPixelFormat, &pfd))return false;		hRC = wglCreateContextAttribsARB(hDC, 0, iContextAttribs);		// If everything went OK		if(hRC) wglMakeCurrent(hDC, hRC);		else bError = true;	}	else bError = true;		if(bError)	{		// Generate error messages		char sErrorMessage[255], sErrorTitle[255];		sprintf(sErrorMessage, "OpenGL 3.3 is not supported! Please download latest GPU drivers!");		sprintf(sErrorTitle, "OpenGL 3.3 Not Supported");		MessageBox(*hWnd, sErrorMessage, sErrorTitle, MB_ICONINFORMATION);		return false;	}	RenderScene = a_RenderScene;	InitScene = a_InitScene;	ReleaseScene = a_ReleaseScene;	if(InitScene != NULL)InitScene(lpParam);	return true;}
开发者ID:MorkovkAs,项目名称:Computer-Graphics-OpenGL,代码行数:70,


示例27: create_context_w32_gl3

static bool create_context_w32_gl3(struct MPGLContext *ctx){    struct w32_context *w32_ctx = ctx->priv;    HGLRC *context = &w32_ctx->context;    if (*context) // reuse existing context        return true; // not reusing it breaks gl3!    HWND win = ctx->vo->w32->window;    HDC windc = GetDC(win);    HGLRC new_context = 0;    new_context = wglCreateContext(windc);    if (!new_context) {        MP_FATAL(ctx->vo, "Could not create GL context!/n");        return false;    }    // set context    if (!wglMakeCurrent(windc, new_context)) {        MP_FATAL(ctx->vo, "Could not set GL context!/n");        goto out;    }    const char *(GLAPIENTRY *wglGetExtensionsStringARB)(HDC hdc)        = w32gpa((const GLubyte*)"wglGetExtensionsStringARB");    if (!wglGetExtensionsStringARB)        goto unsupported;    const char *wgl_exts = wglGetExtensionsStringARB(windc);    if (!strstr(wgl_exts, "WGL_ARB_create_context"))        goto unsupported;    HGLRC (GLAPIENTRY *wglCreateContextAttribsARB)(HDC hDC, HGLRC hShareContext,                                                   const int *attribList)        = w32gpa((const GLubyte*)"wglCreateContextAttribsARB");    if (!wglCreateContextAttribsARB)        goto unsupported;    int gl_version = ctx->requested_gl_version;    int attribs[] = {        WGL_CONTEXT_MAJOR_VERSION_ARB, MPGL_VER_GET_MAJOR(gl_version),        WGL_CONTEXT_MINOR_VERSION_ARB, MPGL_VER_GET_MINOR(gl_version),        WGL_CONTEXT_FLAGS_ARB, 0,        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,        0    };    *context = wglCreateContextAttribsARB(windc, 0, attribs);    if (! *context) {        // NVidia, instead of ignoring WGL_CONTEXT_FLAGS_ARB, will error out if        // it's present on pre-3.2 contexts.        // Remove it from attribs and retry the context creation.        attribs[6] = attribs[7] = 0;        *context = wglCreateContextAttribsARB(windc, 0, attribs);    }    if (! *context) {        int err = GetLastError();        MP_FATAL(ctx->vo, "Could not create an OpenGL 3.x context: error 0x%x/n", err);        goto out;    }    wglMakeCurrent(NULL, NULL);    wglDeleteContext(new_context);    if (!wglMakeCurrent(windc, *context)) {        MP_FATAL(ctx->vo, "Could not set GL3 context!/n");        wglDeleteContext(*context);        return false;    }    /* update function pointers */    mpgl_load_functions(ctx->gl, w32gpa, NULL, ctx->vo->log);    int pfmt = GetPixelFormat(windc);    PIXELFORMATDESCRIPTOR pfd;    if (DescribePixelFormat(windc, pfmt, sizeof(PIXELFORMATDESCRIPTOR), &pfd)) {        ctx->depth_r = pfd.cRedBits;        ctx->depth_g = pfd.cGreenBits;        ctx->depth_b = pfd.cBlueBits;    }    return true;unsupported:    MP_ERR(ctx->vo, "The current OpenGL implementation does not support OpenGL 3.x /n");out:    wglDeleteContext(new_context);    return false;}
开发者ID:benf,项目名称:mpv,代码行数:92,


示例28: entrypoint

void entrypoint( void ){    // full screen#ifdef SETRESOLUTION    if( ChangeDisplaySettings(&screenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) return;#endif    // create window    HWND hWnd = CreateWindow( "static",0,WS_POPUP|WS_VISIBLE|WS_MAXIMIZE,0,0,0,0,0,0,0,0);    HDC hDC = GetDC(hWnd);    // initalize opengl    if( !SetPixelFormat(hDC,ChoosePixelFormat(hDC,&pfd),&pfd) ) return;    HGLRC tempOpenGLContext;    tempOpenGLContext = wglCreateContext(hDC);    wglMakeCurrent(hDC, tempOpenGLContext);    // create openGL functions    for (int i=0; i<NUM_GL_NAMES; i++) glFP[i] = (GenFP)wglGetProcAddress(glnames[i]);    HGLRC hRC = wglCreateContextAttribsARB(hDC, NULL, glAttribs);    // Remove temporary context and set new one    wglMakeCurrent(NULL, NULL);    wglDeleteContext(tempOpenGLContext);    wglMakeCurrent(hDC, hRC);    // init intro    intro_init();    // open audio device    waveOutOpen(&hWaveOut, WAVE_MAPPER, &wfx, 0, 0, CALLBACK_NULL);    // create music block    mzk_init();    // prepare and play music block    header[0].lpData = (char *)myMuzikBlock[0];    header[1].lpData = (char *)myMuzikBlock[1];    header[0].dwBufferLength = AUDIO_BUFFER_SIZE * MZK_NUMCHANNELS * 2;    header[1].dwBufferLength = AUDIO_BUFFER_SIZE * MZK_NUMCHANNELS * 2;    waveOutPrepareHeader(hWaveOut, &(header[0]), sizeof(WAVEHDR));    waveOutWrite(hWaveOut, &(header[0]), sizeof(WAVEHDR));    waveOutPrepareHeader(hWaveOut, &(header[1]), sizeof(WAVEHDR));    waveOutWrite(hWaveOut, &(header[1]), sizeof(WAVEHDR));    timer.wType = TIME_SAMPLES;    do    {        MSG msg;        PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);        ShowCursor(0);        waveOutGetPosition(hWaveOut, &timer, sizeof(timer));        DWORD t = timer.u.sample;        intro_do(t);        //SwapBuffers ( hDC );        wglSwapLayerBuffers( hDC, WGL_SWAP_MAIN_PLANE );        // Try to unprepare header        if (waveOutUnprepareHeader(hWaveOut, &(header[nextPlayBlock]), sizeof(WAVEHDR))                != WAVERR_STILLPLAYING)        {            mzk_prepare_block(myMuzikBlock[nextPlayBlock]);            waveOutPrepareHeader(hWaveOut, &(header[nextPlayBlock]), sizeof(WAVEHDR));            waveOutWrite(hWaveOut, &(header[nextPlayBlock]), sizeof(WAVEHDR));            nextPlayBlock = 1 - nextPlayBlock;        }    } while ( !(GetAsyncKeyState(VK_ESCAPE) || GetAsyncKeyState(VK_F4)));    sndPlaySound(0,0);    ExitProcess(0);}
开发者ID:chock-mostlyharmless,项目名称:mostlyharmless,代码行数:70,


示例29: WndProc

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){	static HWND		shwnd;	static HDC		hdc;	static HGLRC	hglrc, hglrc_legacy;	static Engine	altEngine;	static POINT	center;	static WSADATA	wsadata;	switch (message)	{	case WM_CREATE:		WSAStartup(MAKEWORD(2, 2), &wsadata);		AllocConsole();		RedirectIOToConsole();		SetTimer ( hwnd, TICK_TIMER, 16, NULL );		hdc = GetDC(hwnd);		setupPixelFormat(hdc);#ifndef DIRECTX		hglrc_legacy = wglCreateContext(hdc);		wglMakeCurrent(hdc, hglrc_legacy);		glewInit();		if(wglewIsSupported("WGL_ARB_create_context") == TRUE)		{			const int context[] =			{				WGL_CONTEXT_MAJOR_VERSION_ARB, 3,				WGL_CONTEXT_MINOR_VERSION_ARB, 1,//				WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,				0			};			const int pixelformat[] =			{				WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,				WGL_SUPPORT_OPENGL_ARB, GL_TRUE,				WGL_DOUBLE_BUFFER_ARB, GL_TRUE,				WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,				WGL_COLOR_BITS_ARB, 32,				WGL_DEPTH_BITS_ARB, 24,				WGL_STENCIL_BITS_ARB, 8,				0,			};			int format;			unsigned int num_formats;			wglChoosePixelFormatARB(hdc, (int *)pixelformat, NULL, 1, &format, &num_formats);			hglrc = wglCreateContextAttribsARB(hdc, 0, context);			wglMakeCurrent(NULL,NULL);			wglDeleteContext(hglrc_legacy);			wglMakeCurrent(hdc, hglrc);		}		else		{			//opengl 2.0			hglrc = hglrc_legacy;		}#endif		shwnd = hwnd;		altEngine.init(&shwnd, &hdc);		return 0;	case WMU_RENDER:		altEngine.render();		return 0;	case WM_TIMER:		if (glGetError() != GL_NO_ERROR)		{			printf("GL_ERROR/n");		}		switch(wParam)		{		case TICK_TIMER:			altEngine.step();			break;		}		return 0;	case WM_MOUSEMOVE:		{			int	x, y;			x = LOWORD(lParam);			y = HIWORD(lParam);			if ((x == center.x) && (y == center.y))				return 0;			if ( altEngine.mousepos(x, y, x - center.x, y - center.y) )			{				POINT screen = center;				ClientToScreen(hwnd, &screen);				SetCursorPos(screen.x, screen.y);			}		}//.........这里部分代码省略.........
开发者ID:marceniuk,项目名称:OpenGL_repository,代码行数:101,


示例30: screen_init

void screen_init(struct rdp_config* config){    // make window resizable for the user    if (!fullscreen) {        LONG style = GetWindowLong(gfx.hWnd, GWL_STYLE);        style |= WS_SIZEBOX | WS_MAXIMIZEBOX;        SetWindowLong(gfx.hWnd, GWL_STYLE, style);        BOOL zoomed = IsZoomed(gfx.hWnd);        if (zoomed) {            ShowWindow(gfx.hWnd, SW_RESTORE);        }        // Fix client size after changing the window style, otherwise the PJ64        // menu will be displayed incorrectly.        // For some reason, this needs to be called twice, probably because the        // style set above isn't applied immediately.        for (int i = 0; i < 2; i++) {            win32_client_resize(gfx.hWnd, gfx.hStatusBar, WINDOW_DEFAULT_WIDTH, WINDOW_DEFAULT_HEIGHT);        }        if (zoomed) {            ShowWindow(gfx.hWnd, SW_MAXIMIZE);        }    }    PIXELFORMATDESCRIPTOR win_pfd = {        sizeof(PIXELFORMATDESCRIPTOR), 1,        PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, // Flags        PFD_TYPE_RGBA, // The kind of framebuffer. RGBA or palette.        32,            // Colordepth of the framebuffer.        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,        24, // Number of bits for the depthbuffer        8,  // Number of bits for the stencilbuffer        0,  // Number of Aux buffers in the framebuffer.        PFD_MAIN_PLANE, 0, 0, 0, 0    };    dc = GetDC(gfx.hWnd);    if (!dc) {        msg_error("Can't get device context.");    }    int32_t win_pf = ChoosePixelFormat(dc, &win_pfd);    if (!win_pf) {        msg_error("Can't choose pixel format.");    }    SetPixelFormat(dc, win_pf, &win_pfd);    // create legacy context, required for wglGetProcAddress to work properly    glrc = wglCreateContext(dc);    if (!glrc || !wglMakeCurrent(dc, glrc)) {        msg_error("Can't create OpenGL context.");    }    // load wgl extension    wgl_LoadFunctions(dc);    // attributes for a 3.3 core profile without all the legacy stuff    GLint attribs[] = {        WGL_CONTEXT_MAJOR_VERSION_ARB, 3,        WGL_CONTEXT_MINOR_VERSION_ARB, 3,        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,        0    };    // create the actual context    glrc_core = wglCreateContextAttribsARB(dc, glrc, attribs);    if (!glrc_core || !wglMakeCurrent(dc, glrc_core)) {        // rendering probably still works with the legacy context, so just send        // a warning        msg_warning("Can't create OpenGL 3.3 core context.");    }    // enable vsync    wglSwapIntervalEXT(1);    gl_screen_init(config);}
开发者ID:Klozz,项目名称:mupen64plus-ae,代码行数:80,



注:本文中的wglCreateContextAttribsARB函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ wglDeleteContext函数代码示例
C++ wgettext函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。