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

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

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

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

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

示例1: main

intmain (int argc, char **argv){#ifdef WIN32  HGLRC sdl_gl_context = 0;  HDC sdl_dc = 0;#else  SDL_SysWMinfo info;  Display *sdl_display = NULL;  Window sdl_win = 0;  GLXContext sdl_gl_context = NULL;#endif  GMainLoop *loop = NULL;  GstPipeline *pipeline = NULL;  GstBus *bus = NULL;  GstElement *glfilter = NULL;  GstElement *fakesink = NULL;  GstState state;  GAsyncQueue *queue_input_buf = NULL;  GAsyncQueue *queue_output_buf = NULL;  GstGLDisplay *display;  GstGLContext *sdl_context;  const gchar *platform;  /* Initialize SDL for video output */  if (SDL_Init (SDL_INIT_VIDEO) < 0) {    fprintf (stderr, "Unable to initialize SDL: %s/n", SDL_GetError ());    return -1;  }  /* Create a 640x480 OpenGL screen */  if (SDL_SetVideoMode (640, 480, 0, SDL_OPENGL) == NULL) {    fprintf (stderr, "Unable to create OpenGL screen: %s/n", SDL_GetError ());    SDL_Quit ();    return -1;  }  /* Set the title bar in environments that support it */  SDL_WM_SetCaption ("SDL and gst-plugins-gl", NULL);  /* Loop, drawing and checking events */  InitGL (640, 480);  gst_init (&argc, &argv);  loop = g_main_loop_new (NULL, FALSE);  /* retrieve and turn off sdl opengl context */#ifdef WIN32  sdl_gl_context = wglGetCurrentContext ();  sdl_dc = wglGetCurrentDC ();  wglMakeCurrent (0, 0);  platform = "wgl";  display = gst_gl_display_new ();#else  SDL_VERSION (&info.version);  SDL_GetWMInfo (&info);  /* FIXME: This display is different to the one that SDL uses to create the   * GL context inside SDL_SetVideoMode() above which fails on Intel hardware   */  sdl_display = info.info.x11.display;  sdl_win = info.info.x11.window;  sdl_gl_context = glXGetCurrentContext ();  glXMakeCurrent (sdl_display, None, 0);  platform = "glx";  display = (GstGLDisplay *) gst_gl_display_x11_new_with_display (sdl_display);#endif  sdl_context = gst_gl_context_new_wrapped (display, (guintptr) sdl_gl_context,      gst_gl_platform_from_string (platform), GST_GL_API_OPENGL);  pipeline =      GST_PIPELINE (gst_parse_launch      ("videotestsrc ! video/x-raw, width=320, height=240, framerate=(fraction)30/1 ! "          "gleffects effect=5 ! fakesink sync=1", NULL));  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));  gst_bus_add_signal_watch (bus);  g_signal_connect (bus, "message::error", G_CALLBACK (end_stream_cb), loop);  g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb), loop);  g_signal_connect (bus, "message::eos", G_CALLBACK (end_stream_cb), loop);  gst_object_unref (bus);  /* sdl_gl_context is an external OpenGL context with which gst-plugins-gl want to share textures */  glfilter = gst_bin_get_by_name (GST_BIN (pipeline), "gleffects0");  g_object_set (G_OBJECT (glfilter), "other-context", sdl_context, NULL);  gst_object_unref (glfilter);  /* NULL to PAUSED state pipeline to make sure the gst opengl context is created and   * shared with the sdl one */  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED);  state = GST_STATE_PAUSED;  if (gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL,          GST_CLOCK_TIME_NONE) != GST_STATE_CHANGE_SUCCESS) {    g_debug ("failed to pause pipeline/n");    return -1;  }//.........这里部分代码省略.........
开发者ID:Lachann,项目名称:gst-plugins-bad,代码行数:101,


示例2: DisableOpenGL

void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC){	wglMakeCurrent( NULL, NULL );	wglDeleteContext( hRC );	ReleaseDC( hWnd, hDC );}
开发者ID:davidad,项目名称:kokompe-old,代码行数:6,


示例3: DisableOpenGL

// 取消 OpenGL ,在程序结束前调用,释放渲染环境,设备环境以及最终窗口句柄。void DisableOpenGL(){	wglMakeCurrent( NULL, NULL );	wglDeleteContext( ghRC );	ReleaseDC( ghWnd, ghDC );}
开发者ID:jtianling,项目名称:blog-sample-code,代码行数:7,


示例4: GetModuleHandle

//.........这里部分代码省略.........		if (!(hWnd=CreateWindowEx(	dwExStyle,							// Extended Style For The Window									windowName,							// Class Name									title,								// Window Title									dwStyle |							// Defined Window Style									WS_CLIPSIBLINGS |					// Required Window Style									WS_CLIPCHILDREN,					// Required Window Style									0, 0,								// Window Position									WindowRect.right-WindowRect.left,	// Calculate Window Width									WindowRect.bottom-WindowRect.top,	// Calculate Window Height									NULL,								// No Parent Window									NULL,								// No Menu									hInstance,							// Instance									NULL)))								// Dont Pass Anything To WM_CREATE		{			KillPlatformWindow();								// Reset The 			Debug::Log("Window Creation Error");			return false;								// Return FALSE		}		static PIXELFORMATDESCRIPTOR pfd=				// pfd Tells Windows How We Want Things To Be		{			sizeof(PIXELFORMATDESCRIPTOR),				// Size Of This Pixel Format Descriptor			1,											// Version Number			PFD_DRAW_TO_WINDOW |						// Format Must Support Window			PFD_SUPPORT_OPENGL |						// Format Must Support OpenGL			PFD_DOUBLEBUFFER,							// Must Support Double Buffering			PFD_TYPE_RGBA,								// Request An RGBA Format			bits,										// Select Our 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,									// Accumulation Bits Ignored			16,											// 16Bit Z-Buffer (Depth Buffer)  			0,											// No Stencil Buffer			0,											// No Auxiliary Buffer			PFD_MAIN_PLANE,								// Main Drawing Layer			0,											// Reserved			0, 0, 0										// Layer Masks Ignored		};			if (!(hDC=GetDC(hWnd)))							// Did We Get A Device Context?		{			KillPlatformWindow();								// Reset The Display			Debug::Log("Can't Create Device Context");			return false;								// Return FALSE		}		if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))	// Did Windows Find A Matching Pixel Format?		{			KillPlatformWindow();								// Reset The Display			Debug::Log("Can't Find A Suitable PixelFormat");			return false;								// Return FALSE		}		if(!SetPixelFormat(hDC,PixelFormat,&pfd))		// Are We Able To Set The Pixel Format?		{			KillPlatformWindow();								// Reset The Display			Debug::Log("Can't Set The PixelFormat");			return false;								// Return FALSE		}		if (!(hRC=wglCreateContext(hDC)))				// Are We Able To Get A Rendering Context?		{			KillPlatformWindow();								// Reset The Display			Debug::Log("Can't Create a GL Rendering Context");			return false;								// Return FALSE		}		if(!wglMakeCurrent(hDC,hRC))					// Try To Activate The Rendering Context		{			KillPlatformWindow();								// Reset The Display			Debug::Log("Can't Activate The GL Rendering Context");			return FALSE;								// Return FALSE		}		ShowWindow(hWnd,SW_SHOW);						// Show The Window		CenterWindow();		SetForegroundWindow(hWnd);		SetFocus(hWnd);				/*		if (fullscreen)		{			DEVMODE settings;			settings.dmBitsPerPel = bits;			settings.dmPelsWidth = width;			settings.dmPelsHeight = height;			settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;			bool changed = (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL);		}		*/		return true;	}
开发者ID:amackworth,项目名称:Monocle-Engine,代码行数:101,


示例5: InitializeOpenGL

static bool InitializeOpenGL (){	bool hasGLSL = false;#ifdef _MSC_VER	// setup minimal required GL	HWND wnd = CreateWindowA(		"STATIC",		"GL",		WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS |	WS_CLIPCHILDREN,		0, 0, 16, 16,		NULL, NULL,		GetModuleHandle(NULL), NULL );	HDC dc = GetDC( wnd );	PIXELFORMATDESCRIPTOR pfd = {		sizeof(PIXELFORMATDESCRIPTOR), 1,		PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL,		PFD_TYPE_RGBA, 32,		0, 0, 0, 0, 0, 0,		0, 0, 0, 0, 0, 0, 0,		16, 0,		0, PFD_MAIN_PLANE, 0, 0, 0, 0	};	int fmt = ChoosePixelFormat( dc, &pfd );	SetPixelFormat( dc, fmt, &pfd );	HGLRC rc = wglCreateContext( dc );	wglMakeCurrent( dc, rc );#else	GLint attributes[16];	int i = 0;	attributes[i++]=AGL_RGBA;	attributes[i++]=AGL_PIXEL_SIZE;	attributes[i++]=32;	attributes[i++]=AGL_NO_RECOVERY;	attributes[i++]=AGL_NONE;		AGLPixelFormat pixelFormat = aglChoosePixelFormat(NULL,0,attributes);	AGLContext agl = aglCreateContext(pixelFormat, NULL);	aglSetCurrentContext (agl);#endif		// check if we have GLSL	const char* extensions = (const char*)glGetString(GL_EXTENSIONS);	hasGLSL = strstr(extensions, "GL_ARB_shader_objects") && strstr(extensions, "GL_ARB_vertex_shader") && strstr(extensions, "GL_ARB_fragment_shader");	#ifdef _MSC_VER	if (hasGLSL)	{		glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)wglGetProcAddress("glDeleteObjectARB");		glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)wglGetProcAddress("glCreateShaderObjectARB");		glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)wglGetProcAddress("glShaderSourceARB");		glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)wglGetProcAddress("glCompileShaderARB");		glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)wglGetProcAddress("glGetInfoLogARB");		glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB");	}#endif		return hasGLSL;}
开发者ID:DerSaidin,项目名称:OpenWolf,代码行数:64,


示例6: drawScene

GLvoid drawScene(GLvoid) { 	wglMakeCurrent(g_hDC, g_hGLRC);    glClear(GL_COLOR_BUFFER_BIT);      glEnable(GL_TEXTURE_2D);	glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);	glColor4ub(255, 255, 255, 255);				GLfloat maxU = (GLfloat) ((g_windowWidth * 1.0) / g_vTextures[0].nWidth);	GLfloat maxV = (GLfloat) ((g_windowHeight * 1.0) / g_vTextures[0].nHeight);		glBindTexture(GL_TEXTURE_2D, g_vTextureIDs[0]);		glBegin(GL_QUADS);	glTexCoord2f(0.0f, maxV); glVertex2i(0, 0);	glTexCoord2f(maxU, maxV); glVertex2i(g_windowWidth, 0);	glTexCoord2f(maxU, 0.0f); glVertex2i(g_windowWidth, g_windowHeight);	glTexCoord2f(0.0f, 0.0f); glVertex2i(0, g_windowHeight);	glEnd();		glBindTexture(GL_TEXTURE_2D, g_vTextureIDs[1]);		glBegin(GL_QUADS);		glTexCoord2f(0.0f, g_vTextures[1].nMaxV);	glVertex2i(100, 100);		glTexCoord2f(g_vTextures[1].nMaxU, 		g_vTextures[1].nMaxV);					glVertex2i(171, 100); 	glTexCoord2f(g_vTextures[1].nMaxU, 0.0f); 	glVertex2i(171, 196);	glTexCoord2f(0.0f, 0.0f); 					glVertex2i(100, 196);		glEnd(); 		glDisable(GL_TEXTURE_2D);		glBegin(GL_QUADS);	glColor4ub(0, 200, 0, 255);	glVertex2i(200, 100);	glVertex2i(350, 100);	glVertex2i(350, 200);	glVertex2i(200, 200);	glEnd();	glBegin(GL_LINE_LOOP);	glColor4ub(0, 0, 0, 255);	glVertex2i(200, 100);	glVertex2i(350, 100);	glVertex2i(350, 200);	glVertex2i(200, 200);	glEnd();	glEnable(GL_TEXTURE_2D);	glBindTexture(GL_TEXTURE_2D, g_vTextureIDs[2]);	glBegin(GL_QUADS);	glColor4ub(255, 0, 0, 255);	glTexCoord2f(0.0f, g_vTextures[2].nMaxV);	glVertex2i(10, 10);	glTexCoord2f(g_vTextures[2].nMaxU, 		g_vTextures[2].nMaxV);					glVertex2i(20, 10); 	glTexCoord2f(g_vTextures[2].nMaxU, 0.0f); 	glVertex2i(20, 20);	glTexCoord2f(0.0f, 0.0f);					glVertex2i(10, 20);	glEnd();	glDisable(GL_TEXTURE_2D);	glFlush();	     SwapBuffers(g_hDC); }
开发者ID:merelalkar,项目名称:zlpacman,代码行数:76,


示例7: WinMain

INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE ignoreMe0, LPSTR ignoreMe1, INT ignoreMe2){	HRESULT hr = S_OK;	HWND hWnd = NULL;	HDC hDC = NULL;	HGLRC hRC = NULL;	MSG msg = {};	PIXELFORMATDESCRIPTOR pfd;	    LARGE_INTEGER previousTime;    LARGE_INTEGER freqTime;	double aveDeltaTime = 0.0;    LPCSTR wndName = "Flow Snake";	IFC( InitWindow(hWnd, g_width, g_height, wndName) );    hDC = GetDC(hWnd);    // Create the GL context.    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 = 16;    pfd.iLayerType = PFD_MAIN_PLANE;    int pixelFormat = ChoosePixelFormat(hDC, &pfd);	SetPixelFormat(hDC, pixelFormat, &pfd);    	hRC = wglCreateContext(hDC);    wglMakeCurrent(hDC, hRC);	IFC( Init() );    QueryPerformanceFrequency(&freqTime);    QueryPerformanceCounter(&previousTime);		// -------------------    // Start the Game Loop    // -------------------    while (msg.message != WM_QUIT)    {        if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))        {            TranslateMessage(&msg);             DispatchMessage(&msg);        }        else        {            LARGE_INTEGER currentTime;            __int64 elapsed;            double deltaTime;            QueryPerformanceCounter(&currentTime);            elapsed = currentTime.QuadPart - previousTime.QuadPart;            deltaTime = double(elapsed) / freqTime.QuadPart;			aveDeltaTime = aveDeltaTime * 0.9 + 0.1 * deltaTime;            previousTime = currentTime;			IFC( Update(deltaTime) );			Render();            SwapBuffers(hDC);            if (glGetError() != GL_NO_ERROR)            {                Error("OpenGL error./n");            }        }    }Cleanup:	if(hRC)  wglDeleteContext(hRC);	if(hDC)  ReleaseDC(hWnd, hDC);	if(hWnd) DestroyWindow(hWnd);	char strBuf[256];	sprintf_s(strBuf, "Average frame duration = %.3f ms/n", aveDeltaTime*1000.0f); 	OutputDebugString(strBuf);    return FAILED(hr);}
开发者ID:roblourens,项目名称:FlowSnake,代码行数:82,


示例8: CClientDC

//-----------------------------------------------------------------------------// Name: InitOpenGL()// Desc: //-----------------------------------------------------------------------------HRESULTCOpenGL::InitOpenGL( COscillDlg *pCWnd ){    PIXELFORMATDESCRIPTOR   pfd;        m_pCDrawWnd = pCWnd->GetDlgItem( IDC_DRAWFRAME );    m_pDC = new CClientDC( m_pCDrawWnd );    if( NULL == m_pDC )    {        return RptError( pCWnd->m_hWnd, FALSE, "GetDC Failed" );    }        if( !SetupPixelFormat( pCWnd->m_hWnd ) )        return FALSE;    int nIndex = GetPixelFormat( m_pDC->GetSafeHdc() );    DescribePixelFormat( m_pDC->GetSafeHdc(), nIndex, sizeof(pfd), &pfd );    m_hDC = m_pDC->GetSafeHdc();    m_hRC1 = wglCreateContext( m_pDC->GetSafeHdc() );//	m_hRC2 = wglCreateContext( m_pDC->GetSafeHdc() );	wglMakeCurrent( m_hDC, m_hRC1 );//	wglShareLists( m_hRC2, m_hRC1 );    glClearDepth( 1.0f );    glEnable( GL_DEPTH_TEST );    glMatrixMode( GL_PROJECTION );    glLoadIdentity();    	glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );	gluOrtho2D( GLLEFT, GLRIGHT, GLBOTTOM, GLTOP );        CRect   rcDrawFrame;    GetWindowRect( m_pCDrawWnd->m_hWnd, &rcDrawFrame );// 	TRACE( "%d,%d,%d,%d/r/n", rcDrawFrame.left,// 							  rcDrawFrame.top, // 							  rcDrawFrame.right,// 							  rcDrawFrame.bottom );    rcDrawFrame.SetRect( rcDrawFrame.left + 3,                         rcDrawFrame.top + 3,                         rcDrawFrame.right - 3,                         rcDrawFrame.bottom - 3 );		int nWidth = (int)( ( rcDrawFrame.Height() - 16 ) * 2.3 );	if ( nWidth > rcDrawFrame.Width() - 20 )	{		nWidth = rcDrawFrame.Width() - 20;	}	int xMargin = ( rcDrawFrame.Width() - nWidth ) / 2;    glViewport(  xMargin, 5, nWidth, rcDrawFrame.Height() - 17 );    glEnable( GL_SCISSOR_TEST );    glScissor( xMargin, 5, nWidth, rcDrawFrame.Height() - 17 );    	wglMakeCurrent( NULL, NULL );	m_bDspyThreadRunning = true;	m_pDspyThread = AfxBeginThread( DspyThreadFunc, &m_sDspyThreadPara/*, THREAD_PRIORITY_HIGHEST*/ );    return TRUE;}
开发者ID:gamesun,项目名称:hello-world,代码行数:75,


示例9: m_inputHandler

	Window::Window(const char* _name, int32_t _width, int32_t _height, int32_t _xpos, int32_t _ypos, uint32_t _options)		: m_inputHandler(new InputHandler())		, m_initialized(false)		, m_active(false){		TCHAR* windowName = 0;		m_windowPlacement.length = sizeof(WINDOWPLACEMENT);		windowName = (TCHAR*)_strdup(_name);		WNDCLASSEX windowClass = {			sizeof(WNDCLASSEX),			CS_CLASSDC,			(WNDPROC)WndProc,			0, 0,			GetModuleHandle(nullptr),			LoadIcon(NULL, IDI_WINLOGO),			LoadCursor(0, IDC_ARROW),			nullptr,			nullptr,			windowName		};		if (!RegisterClassEx(&windowClass)){			std::cerr << "Failed to register Window class. RegisterClassEx returned FALSE/n";			return;		}		auto btst = [](uint32_t _reg, uint32_t _mask) { return (_reg & _mask) != 0; };		int32_t multisample = (btst(_options, MULTISAMPLE2) ? 2 :			(btst(_options, MULTISAMPLE4) ? 4 :			(btst(_options, MULTISAMPLE8) ? 8 :			(btst(_options, MULTISAMPLE16) ? 16 :			(btst(_options, MULTISAMPLE32) ? 32 : 0)))));		const int32_t rgbbits = (btst(_options, RGB16) ? 16 :			(btst(_options, RGB24) ? 24 :			(btst(_options, RGB32) ? 32 :			(btst(_options, RGB64) ? 64 : 32))));		const int32_t alphabits = (btst(_options, ALPHA4) ? 4 :			(btst(_options, ALPHA8) ? 8 :			(btst(_options, ALPHA12) ? 12 :			(btst(_options, ALPHA16) ? 16 : 0))));		const int32_t depthbits = (btst(_options, DEPTH8) ? 8 :			(btst(_options, DEPTH16) ? 16 :			(btst(_options, DEPTH24) ? 24 :			(btst(_options, DEPTH32) ? 32 : 24))));		const int32_t stencilbits = (btst(_options, STENCIL4) ? 4 :			(btst(_options, STENCIL8) ? 8 :			(btst(_options, STENCIL16) ? 16 : 8)));		if (!createWindow(windowName, windowName, WS_OVERLAPPEDWINDOW, _xpos, _ypos, _width, _height)){			std::cerr << "Failed to create Window CreateWindowEx returned FALSE/n";			return;		}		m_active = true;		PIXELFORMATDESCRIPTOR pfd = {			sizeof(PIXELFORMATDESCRIPTOR),  //  size of this pfd  			1,                     // version number  			PFD_DRAW_TO_WINDOW |   // support window  			PFD_SUPPORT_OPENGL |   // support OpenGL  			(btst(_options, DOUBLE_BUFFER) ? PFD_DOUBLEBUFFER : 0) |   // double buffered			PFD_GENERIC_ACCELERATED,			PFD_TYPE_RGBA,         // RGBA type  			rgbbits,               // 24-bit color depth  			0, 0, 0, 0, 0, 0,      // color bits ignored  			alphabits,             // no alpha buffer  			0,                     // shift bit ignored  			0,                     // no accumulation buffer  			0, 0, 0, 0,            // accum bits ignored  			depthbits,             // 32-bit z-buffer      			stencilbits,           // no stencil buffer  			0,                     // no auxiliary buffer  			PFD_MAIN_PLANE,        // main layer  			0,                     // reserved  			0, 0, 0                // layer masks ignored  		};		int32_t nPixelFormat = ChoosePixelFormat(m_hdc, &pfd);		if (nPixelFormat == 0 || SetPixelFormat(m_hdc, nPixelFormat, &pfd) <= 0){			GetLastError();			std::cerr << "Error " << GetLastError() << ": Cannot find hardware accelerated OpenGL pixel format /n";			return;		}		int32_t majorVersion = -1, minorVersion = -1;		HGLRC dummyContext = wglCreateContext(m_hdc);		if (dummyContext == 0){			std::cerr << "Cannot create basic OpenGL context/n";			return;		}		wglMakeCurrent(m_hdc, dummyContext);		const GLubyte*(GL_FUNCPTR*_tempglGetString)(GLenum) = (const GLubyte*(GL_FUNCPTR*)(GLenum))GetGLProcAddress("glGetString");		const GLubyte* str = _tempglGetString(GL_VERSION);//.........这里部分代码省略.........
开发者ID:Failee,项目名称:LuaMetaSystem,代码行数:101,


示例10: wglMakeCurrent

	void Win32Context::endCurrent()	{		wglMakeCurrent(NULL, NULL);	}
开发者ID:monwarez-grit,项目名称:grit-ogre,代码行数:4,


示例11: fgSetupPixelFormat

GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly,                              unsigned char layer_type ){#if defined(_WIN32_WCE)    return GL_TRUE;#else    PIXELFORMATDESCRIPTOR pfd;    PIXELFORMATDESCRIPTOR* ppfd = &pfd;    int pixelformat;    HDC current_hDC;    GLboolean success;    if (checkOnly)      current_hDC = CreateDC(TEXT("DISPLAY"), NULL ,NULL ,NULL);    else      current_hDC = window->Window.pContext.Device;    fghFillPFD( ppfd, current_hDC, layer_type );    pixelformat = ChoosePixelFormat( current_hDC, ppfd );    /* windows hack for multismapling/sRGB */    if ( ( fgState.DisplayMode & GLUT_MULTISAMPLE ) ||         ( fgState.DisplayMode & GLUT_SRGB ) )    {                HGLRC rc, rc_before=wglGetCurrentContext();        HWND hWnd;        HDC hDC, hDC_before=wglGetCurrentDC();        WNDCLASS wndCls;        /* create a dummy window */        ZeroMemory(&wndCls, sizeof(wndCls));        wndCls.lpfnWndProc = DefWindowProc;        wndCls.hInstance = fgDisplay.pDisplay.Instance;        wndCls.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;        wndCls.lpszClassName = _T("FREEGLUT_dummy");        RegisterClass( &wndCls );        hWnd=CreateWindow(_T("FREEGLUT_dummy"), _T(""), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW , 0,0,0,0, 0, 0, fgDisplay.pDisplay.Instance, 0 );        hDC=GetDC(hWnd);        SetPixelFormat( hDC, pixelformat, ppfd );        rc = wglCreateContext( hDC );        wglMakeCurrent(hDC, rc);        if ( fghIsExtensionSupported( hDC, "WGL_ARB_multisample" ) )        {            PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARBProc =              (PFNWGLCHOOSEPIXELFORMATARBPROC) wglGetProcAddress("wglChoosePixelFormatARB");            if ( wglChoosePixelFormatARBProc )            {                int attributes[100];                int iPixelFormat;                BOOL bValid;                float fAttributes[] = { 0, 0 };                UINT numFormats;                fghFillPixelFormatAttributes( attributes, ppfd );                bValid = wglChoosePixelFormatARBProc(hDC, attributes, fAttributes, 1, &iPixelFormat, &numFormats);                if ( bValid && numFormats > 0 )                {                    pixelformat = iPixelFormat;                }            }        }        wglMakeCurrent( hDC_before, rc_before);        wglDeleteContext(rc);        ReleaseDC(hWnd, hDC);        DestroyWindow(hWnd);        UnregisterClass(_T("FREEGLUT_dummy"), fgDisplay.pDisplay.Instance);    }    success = ( pixelformat != 0 ) && ( checkOnly || SetPixelFormat( current_hDC, pixelformat, ppfd ) );    if (checkOnly)        DeleteDC(current_hDC);    return success;#endif /* defined(_WIN32_WCE) */}
开发者ID:383530895,项目名称:liquidfun,代码行数:80,


示例12: wglMakeCurrent

void ContextGL_Win::release_current() {	wglMakeCurrent(hDC,NULL);}
开发者ID:lonesurvivor,项目名称:godot,代码行数:6,


示例13: EnableDrawing

void EnableDrawing (HGLRC *hRC){    WindowResizedCallback = &WindowResized;    /**     * 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, 3,        //WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,#ifdef DEBUG_MODE        WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,#else        WGL_CONTEXT_FLAGS_ARB, 0,#endif        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.3 Core Context, use the Legacy 1.x context    {        *hRC = LegacyRC;    }#ifdef DEBUG_MODE    glDebugMessageCallbackARB((GLDEBUGPROCARB)&DebugCallbackARB, 0);    glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);    printf("OpenGL version supported by this platform (%s): /n", glGetString(GL_VERSION));    GLuint ids[] = { 131185 };    glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB, GL_DEBUG_TYPE_OTHER_ARB, GL_DONT_CARE, 1, ids, GL_FALSE); //Disable notification about rendering HINTS like so:    //OpenGL: Buffer detailed info: Buffer object 1 (bound to GL_ELEMENT_ARRAY_BUFFER_ARB, usage hint is GL_STATIC_DRAW) will use VIDEO memory as the source for buffer object operations. [source=API type=OTHER severity=UNDEFINED (33387) id=131185]#endif    //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:Mikelle02,项目名称:enigma-dev,代码行数:77,


示例14: main

//----------------------------------------------------------------------------------////----------------------------------------------------------------------------------int main(){	InitWindow();		// 描画用インスタンスの生成	g_renderer = ::EffekseerRendererGL::Renderer::Create( 2000 );		// エフェクト管理用インスタンスの生成	g_manager = ::Effekseer::Manager::Create( 2000 );	// 描画用インスタンスから描画
C++ wglShareLists函数代码示例
C++ wglGetProcAddress函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。