当前位置: 首页>>代码示例>>C++>>正文


C++ SwapBuffers函数代码示例

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


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

示例1: zepSwapBuffers

void zepSwapBuffers()
{
    SwapBuffers(hDC);
}
开发者ID:prideout,项目名称:pez,代码行数:4,代码来源:platform.win.c

示例2: screen_refresh

void screen_refresh() {
    window_set_caption(room_caption);
    enigma::update_mouse_variables();
    SwapBuffers(enigma::window_hDC);
}
开发者ID:Mikelle02,项目名称:enigma-dev,代码行数:5,代码来源:graphics_bridge.cpp

示例3: makeContextCurrent

bool WebGraphicsContext3DDefaultImpl::readBackFramebuffer(unsigned char* pixels, size_t bufferSize)
{
    if (bufferSize != static_cast<size_t>(4 * width() * height()))
        return false;

    makeContextCurrent();

#ifdef RENDER_TO_DEBUGGING_WINDOW
    SwapBuffers(m_canvasDC);
#else
    // Earlier versions of this code used the GPU to flip the
    // framebuffer vertically before reading it back for compositing
    // via software. This code was quite complicated, used a lot of
    // GPU memory, and didn't provide an obvious speedup. Since this
    // vertical flip is only a temporary solution anyway until Chrome
    // is fully GPU composited, it wasn't worth the complexity.

    bool mustRestoreFBO;
    if (m_attributes.antialias) {
        glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_multisampleFBO);
        glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fbo);
        glBlitFramebufferEXT(0, 0, m_cachedWidth, m_cachedHeight, 0, 0, m_cachedWidth, m_cachedHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
        mustRestoreFBO = true;
    } else {
        if (m_boundFBO != m_fbo) {
            mustRestoreFBO = true;
            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo);
        }
    }

    GLint packAlignment = 4;
    bool mustRestorePackAlignment = false;
    glGetIntegerv(GL_PACK_ALIGNMENT, &packAlignment);
    if (packAlignment > 4) {
        glPixelStorei(GL_PACK_ALIGNMENT, 4);
        mustRestorePackAlignment = true;
    }

#if PLATFORM(SKIA)
    glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
#elif PLATFORM(CG)
    glReadPixels(0, 0, m_cachedWidth, m_cachedHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
#else
#error Must port to your platform
#endif

    if (mustRestorePackAlignment)
        glPixelStorei(GL_PACK_ALIGNMENT, packAlignment);

    if (mustRestoreFBO)
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_boundFBO);

#ifdef FLIP_FRAMEBUFFER_VERTICALLY
    if (pixels)
        flipVertically(pixels, m_cachedWidth, m_cachedHeight);
#endif

#endif // RENDER_TO_DEBUGGING_WINDOW
    return true;
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:61,代码来源:WebGraphicsContext3DDefaultImpl.cpp

示例4: col_view_background

/* MapPreviewCanvas::draw
 * Draws the map
 *******************************************************************/
void MapPreviewCanvas::draw()
{
	// Setup colours
	wxColour wxc;
	wxc.Set(map_view_col_background);	rgba_t col_view_background(wxc.Red(), wxc.Green(), wxc.Blue(), 255);
	wxc.Set(map_view_col_line_1s);		rgba_t col_view_line_1s(wxc.Red(), wxc.Green(), wxc.Blue(), 255);
	wxc.Set(map_view_col_line_2s);		rgba_t col_view_line_2s(wxc.Red(), wxc.Green(), wxc.Blue(), 255);
	wxc.Set(map_view_col_line_special);	rgba_t col_view_line_special(wxc.Red(), wxc.Green(), wxc.Blue(), 255);
	wxc.Set(map_view_col_line_macro);	rgba_t col_view_line_macro(wxc.Red(), wxc.Green(), wxc.Blue(), 255);

	// Setup the viewport
	glViewport(0, 0, GetSize().x, GetSize().y);

	// Setup the screen projection
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, GetSize().x, 0, GetSize().y, -1, 1);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	// Clear
	glClearColor(((double)col_view_background.r)/255.f, ((double)col_view_background.g)/255.f,
	             ((double)col_view_background.b)/255.f, ((double)col_view_background.a)/255.f);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	// Translate to inside of pixel (otherwise inaccuracies can occur on certain gl implementations)
	if (OpenGL::accuracyTweak())
		glTranslatef(0.375f, 0.375f, 0);

	// Zoom/offset to show full map
	showMap();

	// Translate to middle of canvas
	glTranslated(GetSize().x * 0.5, GetSize().y * 0.5, 0);

	// Zoom
	glScaled(zoom, zoom, 1);

	// Translate to offset
	glTranslated(-offset_x, -offset_y, 0);

	// Setup drawing
	glDisable(GL_TEXTURE_2D);
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	glLineWidth(1.5f);
	glEnable(GL_LINE_SMOOTH);

	// Draw lines
	for (unsigned a = 0; a < lines.size(); a++)
	{
		mep_line_t line = lines[a];

		// Check ends
		if (line.v1 >= verts.size() || line.v2 >= verts.size())
			continue;

		// Get vertices
		mep_vertex_t v1 = verts[lines[a].v1];
		mep_vertex_t v2 = verts[lines[a].v2];

		// Set colour
		if (line.special)
			OpenGL::setColour(col_view_line_special);
		else if (line.macro)
			OpenGL::setColour(col_view_line_macro);
		else if (line.twosided)
			OpenGL::setColour(col_view_line_2s);
		else
			OpenGL::setColour(col_view_line_1s);

		// Draw line
		glBegin(GL_LINES);
		glVertex2d(v1.x, v1.y);
		glVertex2d(v2.x, v2.y);
		glEnd();
	}

	glLineWidth(1.0f);
	glDisable(GL_LINE_SMOOTH);

	// Swap buffers (ie show what was drawn)
	SwapBuffers();
}
开发者ID:DemolisherOfSouls,项目名称:SLADE,代码行数:87,代码来源:MapPreviewCanvas.cpp

示例5: main

int main()
{

	//
	// Create a new window
	//
	g_pHWND = CreateGameWindow();

	//
	// Create OpenGL Device
	//
	HGLRC OpenGLContext = CreateOpenGLDeviceContext();	


	//
	// Create a GWEN OpenGL Renderer
	//
	#ifdef USE_DEBUG_FONT
		Gwen::Renderer::OpenGL * pRenderer = new Gwen::Renderer::OpenGL_DebugFont();
	#else
		Gwen::Renderer::OpenGL * pRenderer = new Gwen::Renderer::OpenGL();
	#endif

		pRenderer->Init();

	//
	// Create a GWEN skin
	//
	Gwen::Skin::TexturedBase skin( pRenderer );
	skin.Init("DefaultSkin.png");

	//
	// Create a Canvas (it's root, on which all other GWEN panels are created)
	//
	Gwen::Controls::Canvas* pCanvas = new Gwen::Controls::Canvas( &skin );
	pCanvas->SetSize( 998, 650 - 24 );
	pCanvas->SetDrawBackground( true );
	pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) );

	//
	// Create our unittest control (which is a Window with controls in it)
	//
	UnitTest* pUnit = new UnitTest( pCanvas );
	pUnit->SetPos( 10, 10 );

	//
	// Create a Windows Control helper 
	// (Processes Windows MSG's and fires input at GWEN)
	//
	Gwen::Input::Windows GwenInput;
	GwenInput.Initialize( pCanvas );

	//
	// Begin the main game loop
	//
	MSG msg;
	while( true )
	{
		// Skip out if the window is closed
		if ( !IsWindowVisible( g_pHWND ) )
			break;

		// If we have a message from windows..
		if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
		{
			// .. give it to the input handler to process
			GwenInput.ProcessMessage( msg );

			// if it's QUIT then quit..
			if ( msg.message == WM_QUIT )
				break;


			// Handle the regular window stuff..
			TranslateMessage(&msg);
			DispatchMessage(&msg);

		}

		// Main OpenGL Render Loop
		{
			glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

			pCanvas->RenderCanvas();

			SwapBuffers( GetDC( g_pHWND ) );
		}
	}

	// Clean up OpenGL
	wglMakeCurrent( NULL, NULL );
	wglDeleteContext( OpenGLContext );

	delete pCanvas;
	delete pRenderer;

}
开发者ID:CmPons,项目名称:angel2d,代码行数:97,代码来源:OpenGLSample.cpp

示例6: WinMain

int 
WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
     MSG msg = {0};
     WNDCLASS wc = {0};
     RECT wr;
     unsigned threadNum;

     wr.left   = 0;
     wr.right  = VIEW_WIDTH;
     wr.top    = 0;
     wr.bottom = VIEW_HEIGHT;

     wc.lpfnWndProc = WndProc;
     wc.hInstance   = hInstance;
     wc.lpszClassName = "C8WinClass";

     if (!RegisterClass(&wc))
          return 0;

     AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);

     long style = WS_OVERLAPPEDWINDOW | WS_VISIBLE;
     /*
     style ^= WS_THICKFRAME;
     style ^= WS_MAXIMIZEBOX;
     */

     CreateWindow(wc.lpszClassName, "C8", style, 0, 0, (SCREEN_WIDTH * 4)+30, (SCREEN_HEIGHT * 4) + 30,
                  0, 0, hInstance, 0);

     freopen("stdout.txt", "w", stdout);
     freopen("stderr.txt", "w", stderr);

     if (!CHIP8_Init(lpCmdLine)) {
          running = false;
          return;
     }

     CHIP8_Reset();

     InitKeymap();

     _beginthread(InterpreterThread, 0, NULL);

     // TODO: formatting?
     while (running)
     {
          PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
          TranslateMessage(&msg);
          DispatchMessage(&msg);

          glClear(GL_COLOR_BUFFER_BIT);

          UpdateDisplay();

          SwapBuffers(dc);
     }

     return 0;
}
开发者ID:pqp,项目名称:c8,代码行数:61,代码来源:platform_win32.c

示例7: SwapBuffers

void OpenGLWindow::swapBuffers()
{
	SwapBuffers(m_WindowDeviceContext);
}
开发者ID:Cavan09,项目名称:School_Assignment3_LevelEditor,代码行数:4,代码来源:OpenGLWindow.cpp

示例8: fgPlatformGlutSwapBuffers

void fgPlatformGlutSwapBuffers( SFG_PlatformDisplay *pDisplayPtr, SFG_Window* CurrentWindow )
{
    SwapBuffers( CurrentWindow->Window.pContext.Device );
}
开发者ID:Galleondragon,项目名称:qb64,代码行数:4,代码来源:fg_display_mswin.c

示例9: WinMain

// Program Entry (WinMain)
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	Application			application;									// Application Structure
	GL_Window			window;											// Window Structure
//	Keys				keys;											// Key Structure
	BOOL				isMessagePumpActive;							// Message Pump Active?
	MSG					msg;											// Window Message Structure
	DWORD				tickCount;										// Used For The Tick Counter


	// Fill Out Application Data
	application.className = "OpenGL";									// Application Class Name
	application.hInstance = hInstance;									// Application Instance

	
	// Fill Out Window
	ZeroMemory (&window, sizeof (GL_Window));							// Make Sure Memory Is Zeroed
//	window.keys					= &keys;								// Window Key Structure
	window.init.application		= &application;							// Window Application
	window.init.title			= "Sky Gamblers: Jet Arena";			// Window Title
	window.init.width			= 1024;									// Window Width
	window.init.height			= 768;									// Window Height
	window.init.bitsPerPixel	= 32;									// Bits Per Pixel
	window.init.isFullScreen	= TRUE;									// Fullscreen? (Set To TRUE)

//	ZeroMemory (&keys, sizeof (Keys));									// Zero keys Structure

	// Ask The User If They Want To Start In FullScreen Mode?
	if (true)//MessageBox (HWND_DESKTOP, "Would You Like To Run In Fullscreen Mode?", "Start FullScreen?", MB_YESNO | MB_ICONQUESTION) == IDNO)
	{
		window.init.isFullScreen = FALSE;								// If Not, Run In Windowed Mode
	}

	// Register A Class For Our Window To Use
	if (RegisterWindowClass (&application) == FALSE)					// Did Registering A Class Fail?
	{
		// Failure
		MessageBox (HWND_DESKTOP, "Error Registering Window Class!", "Error", MB_OK | MB_ICONEXCLAMATION);
		return -1;														// Terminate Application
	}

	g_isProgramLooping = TRUE;											// Program Looping Is Set To TRUE
	g_createFullScreen = window.init.isFullScreen;						// g_createFullScreen Is Set To User Default
	while (g_isProgramLooping)											// Loop Until WM_QUIT Is Received
	{
		// Create A Window
		window.init.isFullScreen = g_createFullScreen;					// Set Init Param Of Window Creation To Fullscreen?
		if (CreateWindowGL (&window) == TRUE)							// Was Window Creation Successful?
		{
			// At This Point We Should Have A Window That Is Setup To Render OpenGL
			if (false)//Initialize (&window, &keys) == FALSE)					// Call User Intialization
			{
				// Failure
				TerminateApplication(&window);							// Close Window, This Will Handle The Shutdown
			}
			else														// Otherwise (Start The Message Pump)
			{	// Initialize was a success
				isMessagePumpActive = TRUE;								// Set isMessagePumpActive To TRUE


				TimerInit();

				init();
				//	return new RenderBuffer(0, frameBuffer, colorBuffer, 0, width, height, GL_COLOR_BUFFER_BIT, (void*) CreateScreenColor);

				while (isMessagePumpActive == TRUE)						// While The Message Pump Is Active
				{

				float start = GetTime();

					// Success Creating Window.  Check For Window Messages
					if (PeekMessage (&msg, window.hWnd, 0, 0, PM_REMOVE) != 0)
					{
						// Check For WM_QUIT Message
						if (msg.message != WM_QUIT)						// Is The Message A WM_QUIT Message?
						{
							DispatchMessage (&msg);						// If Not, Dispatch The Message
						}
						else											// Otherwise (If Message Is WM_QUIT)
						{
							isMessagePumpActive = FALSE;				// Terminate The Message Pump
						}
					}
					//else												// If There Are No Messages
					{
						if (window.isVisible == FALSE)					// If Window Is Not Visible
						{
							WaitMessage ();								// Application Is Minimized Wait For A Message
						}
						else											// If Window Is Visible
						{

							// Process Application Loop

							//draw
							display();

							SwapBuffers (window.hDC);					// Swap Buffers (Double Buffering)

//.........这里部分代码省略.........
开发者ID:elf11,项目名称:newRepo,代码行数:101,代码来源:main.cpp

示例10: swapGlBuffers_w32

static void swapGlBuffers_w32(MPGLContext *ctx)
{
    HDC vo_hdc = GetDC(ctx->vo->w32->window);
    SwapBuffers(vo_hdc);
    ReleaseDC(ctx->vo->w32->window, vo_hdc);
}
开发者ID:Aseeker,项目名称:mpv,代码行数:6,代码来源:gl_w32.c

示例11: SwapBuffers

	void OGLContext::render()
	{
		SwapBuffers(hdc); // Swap buffers so we can see our rendering
	}
开发者ID:byhj,项目名称:byhj-Render,代码行数:4,代码来源:oglContext.cpp

示例12: lae_graphics_present

void lae_graphics_present(lae_graphics_t* device)
{
    SwapBuffers(device->dc);
    UNUSED_PARAMETER(device);
}
开发者ID:10n1,项目名称:LAE,代码行数:5,代码来源:graphics_opengl_win32.c

示例13: WinMain


//.........这里部分代码省略.........
            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);
    }

#ifdef ZEP_DROP_HANDLER
    DragAcceptFiles(hWnd, TRUE);
#endif

    err = glewInit();
    if (GLEW_OK != err)
    {
        zepFatal("GLEW Error: %s\n", glewGetErrorString(err));
    }
    zepPrintString("OpenGL Version: %s\n", glGetString(GL_VERSION));

    if (!ZepGetConfig().VerticalSync)
    {
        wglSwapIntervalEXT(0);
    }

    if (ZEP_FORWARD_COMPATIBLE_GL && glewIsSupported("GL_VERSION_3_2"))
    {
        const int contextAttribs[] =
        {
            WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
            WGL_CONTEXT_MINOR_VERSION_ARB, 2,
            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);

        zepPrintString("Switched to a forward-compatible context.\n");
    }

    zepInit();
    zepAddPath("./", ".glsl");
    zepAddPath("../", ".glsl");

    char qualifiedPath[128];
    strcpy(qualifiedPath, zepResourcePath());
    strcat(qualifiedPath, "/");
    zepAddPath(qualifiedPath, ".glsl");

    zepAddDirective("*", "#version 150");

    ZepInitialize();
    SetWindowTextA(hWnd, ZepGetConfig().Title);

    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 = elapsed * 1000000.0 / freqTime.QuadPart;
            previousTime = currentTime;

            ZepUpdate((float) deltaTime / 1000000.0f);
            ZepRender();
            SwapBuffers(hDC);
            zepCheck(glGetError() == GL_NO_ERROR, "OpenGL error.\n");
        }
    }

    UnregisterClassA(szName, wc.hInstance);

    return 0;
}
开发者ID:prideout,项目名称:pez,代码行数:101,代码来源:platform.win.c

示例14: glctx_flip

void glctx_flip(GlctxHandle ctx)
{
    SwapBuffers(ctx->dpy);
}
开发者ID:realh,项目名称:glcontext,代码行数:4,代码来源:glctx-wgl.c

示例15: SwapBuffers

void	Win32Window::endRendering()
{
	SwapBuffers( m_data->m_hDC );
}
开发者ID:mrcrr8614,项目名称:bullet3,代码行数:4,代码来源:Win32Window.cpp


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