本文整理汇总了C++中eglSwapBuffers函数的典型用法代码示例。如果您正苦于以下问题:C++ eglSwapBuffers函数的具体用法?C++ eglSwapBuffers怎么用?C++ eglSwapBuffers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eglSwapBuffers函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Java_org_lwjgl_opengles_EGL_neglSwapBuffers
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengles_EGL_neglSwapBuffers(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong surface_ptr) {
EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr;
EGLSurface surface = (EGLSurface)(intptr_t)surface_ptr;
return eglSwapBuffers(dpy, surface);
}
示例2: gfx_ctx_qnx_swap_buffers
static void gfx_ctx_qnx_swap_buffers(void *data)
{
(void)data;
eglSwapBuffers(g_egl_dpy, g_egl_surf);
}
示例3: eglSwapBuffers
// Show the current FPS
void cInterfaceEGL::Swap()
{
eglSwapBuffers(egl_dpy, egl_surf);
}
示例4: main
int main(int argc, char **argv)
{
EGLDisplay display;
EGLConfig ecfg;
EGLint num_config;
EGLint attr[] = { // some attributes to set up our egl-interface
EGL_BUFFER_SIZE, 32,
EGL_RENDERABLE_TYPE,
EGL_OPENGL_ES2_BIT,
EGL_NONE
};
EGLSurface surface;
EGLint ctxattr[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
EGLContext context;
EGLBoolean rv;
display = eglGetDisplay(NULL);
assert(eglGetError() == EGL_SUCCESS);
assert(display != EGL_NO_DISPLAY);
rv = eglInitialize(display, 0, 0);
assert(eglGetError() == EGL_SUCCESS);
assert(rv == EGL_TRUE);
eglChooseConfig((EGLDisplay) display, attr, &ecfg, 1, &num_config);
assert(eglGetError() == EGL_SUCCESS);
assert(rv == EGL_TRUE);
surface = eglCreateWindowSurface((EGLDisplay) display, ecfg, (EGLNativeWindowType)NULL, NULL);
assert(eglGetError() == EGL_SUCCESS);
assert(surface != EGL_NO_SURFACE);
context = eglCreateContext((EGLDisplay) display, ecfg, EGL_NO_CONTEXT, ctxattr);
assert(eglGetError() == EGL_SUCCESS);
assert(context != EGL_NO_CONTEXT);
assert(eglMakeCurrent((EGLDisplay) display, surface, surface, context) == EGL_TRUE);
const char *version = (const char *)glGetString(GL_VERSION);
assert(version);
printf("%s\n",version);
GLuint vertexShader = load_shader ( vertex_src , GL_VERTEX_SHADER ); // load vertex shader
GLuint fragmentShader = load_shader ( fragment_src , GL_FRAGMENT_SHADER ); // load fragment shader
GLuint shaderProgram = glCreateProgram (); // create program object
glAttachShader ( shaderProgram, vertexShader ); // and attach both...
glAttachShader ( shaderProgram, fragmentShader ); // ... shaders to it
glLinkProgram ( shaderProgram ); // link the program
glUseProgram ( shaderProgram ); // and select it for usage
//// now get the locations (kind of handle) of the shaders variables
position_loc = glGetAttribLocation ( shaderProgram , "position" );
phase_loc = glGetUniformLocation ( shaderProgram , "phase" );
offset_loc = glGetUniformLocation ( shaderProgram , "offset" );
if ( position_loc < 0 || phase_loc < 0 || offset_loc < 0 ) {
return 1;
}
//glViewport ( 0 , 0 , 800, 600); // commented out so it uses the initial window dimensions
glClearColor ( 1. , 1. , 1. , 1.); // background color
float phase = 0;
int i;
for (i=0; i<3*60; ++i) {
glClear(GL_COLOR_BUFFER_BIT);
glUniform1f ( phase_loc , phase ); // write the value of phase to the shaders phase
phase = fmodf ( phase + 0.5f , 2.f * 3.141f ); // and update the local variable
glUniform4f ( offset_loc , offset_x , offset_y , 0.0 , 0.0 );
glVertexAttribPointer ( position_loc, 3, GL_FLOAT, GL_FALSE, 0, vertexArray );
glEnableVertexAttribArray ( position_loc );
glDrawArrays ( GL_TRIANGLE_STRIP, 0, 5 );
eglSwapBuffers ( (EGLDisplay) display, surface ); // get the rendered buffer to the screen
}
printf("stop\n");
#if 0
(*egldestroycontext)((EGLDisplay) display, context);
printf("destroyed context\n");
(*egldestroysurface)((EGLDisplay) display, surface);
printf("destroyed surface\n");
(*eglterminate)((EGLDisplay) display);
printf("terminated\n");
android_dlclose(baz);
#endif
}
示例5: main
int main(void) {
EGLDisplay m_eglDisplay;
EGLContext m_eglContext;
EGLSurface m_eglSurface;
EGLint attributeList[] = { EGL_RED_SIZE, 1, EGL_DEPTH_SIZE, 1, EGL_NONE };
EGLint aEGLAttributes[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_DEPTH_SIZE, 16,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
EGL_NONE
};
EGLint aEGLContextAttributes[] = {
EGL_CONTEXT_CLIENT_VERSION, 1,
EGL_NONE
};
EGLConfig m_eglConfig[1];
EGLint nConfigs;
unsigned char mIndices[] = { 0, 1, 2 };
signed short mVertices[] = {
-50, -29, 0,
50, -29, 0,
0, 58, 0
};
HWND hwnd;
HDC hdc;
MSG sMessage;
int bDone = 0;
// Platform init.
platform(&hwnd, 640, 480);
ShowWindow(hwnd, SW_SHOW);
SetForegroundWindow(hwnd);
SetFocus(hwnd);
// EGL init.
hdc = GetDC(hwnd);
m_eglDisplay = eglGetDisplay(hdc);
eglInitialize(m_eglDisplay, NULL, NULL);
eglChooseConfig(m_eglDisplay, aEGLAttributes, m_eglConfig, 1, &nConfigs);
printf("EGLConfig = %p\n", m_eglConfig[0]);
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig[0], (NativeWindowType)hwnd, 0);
m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig[0], EGL_NO_CONTEXT, aEGLContextAttributes);
printf("EGLContext = %p\n", m_eglContext);
eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_SHORT, 0, mVertices);
/* Set projection matrix so screen extends to (-160, -120) at bottom left
* and to (160, 120) at top right, with -128..128 as Z buffer. */
glMatrixMode(GL_PROJECTION);
glOrthox(-160<<16, 160<<16, -120<<16, 120<<16, -128<<16, 128<<16);
glMatrixMode(GL_MODELVIEW);
glClearColorx(0x10000, 0x10000, 0, 0);
glColor4x(0x10000, 0, 0, 0);
// Main event loop
while(!bDone)
{
// Do Windows stuff:
if(PeekMessage(&sMessage, NULL, 0, 0, PM_REMOVE))
{
if(sMessage.message == WM_QUIT)
{
bDone = 1;
}
else
{
TranslateMessage(&sMessage);
DispatchMessage(&sMessage);
}
}
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, mIndices);
glRotatex(2<<16, 0, 0, 0x10000);
eglSwapBuffers(m_eglDisplay, m_eglSurface);
Sleep(30);
}
// Exit.
eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(m_eglDisplay, m_eglContext);
eglDestroySurface(m_eglDisplay, m_eglSurface);
eglTerminate(m_eglDisplay);
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);
return 0;
}
示例6: eglSwapBuffers
void cXInterface::SwapBuffers()
{
eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
}
示例7: enddraw
void enddraw(int x, int y, int width, int height)
{
eglSwapBuffers(display, surface);
}
示例8: main
//.........这里部分代码省略.........
}
GLuint prog = glCreateProgram();
glAttachShader(prog, vertex_shader);
glAttachShader(prog, fragment_shader);
glLinkProgram(prog);
glGetProgramiv(prog, GL_LINK_STATUS, &status);
if (!status) {
glGetProgramInfoLog(prog, 512, NULL, message);
printf("%s\n", message);
}
glUseProgram(prog);
/* set up resource */
GLfloat pos_buf[] = {
-0.25f, 0.25f, 0.0f,
0.25f, -0.25f, 0.0f,
-0.25f, -0.25f, 0.0f,
0.25f, 0.25f, 0.0f
};
GLfloat color_buf[] = {
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f, 0.0f,
};
GLushort index_buf[] = {
0, 1, 2,
0, 3, 1
};
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
/* setup array buffer for position and color
*/
GLuint vbo_pos;
glGenBuffers(1, &vbo_pos);
glBindBuffer(GL_ARRAY_BUFFER, vbo_pos);
glBufferData(GL_ARRAY_BUFFER, sizeof(pos_buf), pos_buf, GL_STATIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid *)0);
GLuint vbo_color;
glGenBuffers(1, &vbo_color);
glBindBuffer(GL_ARRAY_BUFFER, vbo_color);
glBufferData(GL_ARRAY_BUFFER, sizeof(color_buf), color_buf, GL_STATIC_DRAW);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (GLvoid *)0);
/* setup index buffer for index
*/
GLuint vbo_index;
glGenBuffers(1, &vbo_index);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo_index);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(index_buf), index_buf, GL_STATIC_DRAW);
/* game loop */
while (1) {
XNextEvent(wrt->x11_display, &(wrt->event));
switch(wrt->event.type) {
case Expose:
/* do the render */
glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glBindVertexArray(vao);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (void*)0);
glBindVertexArray(0);
eglSwapBuffers(wrt->egl_display, wrt->egl_surface);
break;
case ButtonPress:
case KeyPress:
goto finish;
default:
break;
}
}
finish:
glDeleteShader(vertex_shader);
glDeleteShader(fragment_shader);
glDeleteProgram(prog);
glDeleteBuffers(1, &vbo_pos);
glDeleteBuffers(1, &vbo_color);
glDeleteBuffers(1, &vbo_index);
glDeleteVertexArrays(1, &vao);
destroy_warp_runtime(wrt);
return 0;
}
示例9: eglSwapBuffers
void CoreWindow::SwapBuffer()
{
eglSwapBuffers(esContext.eglDisplay, esContext.eglSurface);
// glXSwapBuffers(m_display, g_win->m_imp->m_win);
}
示例10: WndProc
//.........这里部分代码省略.........
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch ( uMsg ) // Check For Windows Messages
{
case WM_ACTIVATE:
{
if ( ! HIWORD( wParam ) ) // Check Minimization State
{
g_active = TRUE;
}
else
{
g_active = FALSE;
}
return 0;
}
case WM_SYSCOMMAND:
{
if ( ( wParam == SC_SCREENSAVE ) ||
( wParam == SC_MONITORPOWER ) )
{
return 0;
}
break;
}
case WM_CLOSE:
{
PostQuitMessage( 0 );
return 0;
}
case WM_KEYDOWN:
{
g_keys[wParam] = TRUE;
if(wParam == 8)
{
// Backspace is pressed then undo
g_scene->undoLastMove();
}
else if(wParam == 13)
{
g_scene->start();
}
else if(wParam == 32)
{
g_scene->end();
}
return 0;
}
case WM_KEYUP:
{
g_keys[wParam] = FALSE;
return 0;
}
case WM_LBUTTONDOWN:
{
g_scene->mouseClick(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), MS_BOX_SHIFT_DOWN);
return 0;
}
case WM_SIZE:
{
ResizeScene( LOWORD( lParam ), HIWORD( lParam ) ); // LoWord=Width, HiWord=Height
return 0;
}
case WM_TIMER:
switch (wParam)
{
case 43:
#ifdef PERFORMANCE_TUNING
double newstart = static_cast <double> (clock ());
double time = frameCount / ( (newstart - start) / static_cast <double> (CLOCKS_PER_SEC));
printf("%f.2\r\n", time);
frameCount = 0;
start = newstart;
#else
// process the 60fps timer
DrawScene();
eglSwapBuffers( g_egl.dsp, g_egl.surf );
#endif
return 0;
}
}
// Pass All Unhandled Messages To DefWindowProc
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
示例11: WinMain
//=================================================================================================================================
///
/// WinMain function for this simple ES app.
///
/// \param hInstance instance.
/// \param hPrevInstance previous instance.
/// \param lpCmdLine command line parameters.
/// \param nCmdShow window show state.
///
/// \return void
//=================================================================================================================================
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
UINT res = WinExec ("C:\\Program Files (x86)\\NVIDIA Corporation\\win_x86_es2emu\\ait\\esTriangle\\copy.bat", SW_SHOWNORMAL);
MSG msg;
BOOL done=FALSE;
g_scene = new msScene();
// redirect stdin/stdout to a console window
RedirectIOToConsole();
// unit tests
//msBox::unitTest();
//msAnimation::unitTest();
//msAnimationBundle::unitTest();
// msBoxGrid::unitTest();
// return 0;
MainFuncInit();
HWND hWnd = CreateWind( SCR_WIDTH, SCR_HEIGHT ) ;
if ( !hWnd )
{
return 0;
}
string *uniformsPath = new string("\\data\\uniforms.txt");
msMapDataFileName(*uniformsPath);
g_scene->loadData(*uniformsPath);
delete uniformsPath;
g_scene->init();
#ifdef PERFORMANCE_TUNING
SetTimer(hWnd, // handle to main window
43, // timer identifier
2000,
(TIMERPROC) NULL); // no timer callback
#else
SetTimer(hWnd, // handle to main window
43, // timer identifier
FRAME_INTERVAL, // 10-second interval
(TIMERPROC) NULL); // no timer callback
#endif
while ( ! done )
{
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) // Is There A Message Waiting?
{
if ( msg.message == WM_QUIT )
{
done=TRUE;
}
else
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
else
{
#ifdef PERFORMANCE_TUNING
if ( ( g_active && !DrawScene() ) || g_keys[VK_ESCAPE] )
{
done=TRUE; // ESC or DrawGLScene Signalled A Quit
}
else
{
eglSwapBuffers( g_egl.dsp, g_egl.surf );
frameCount ++;
}
#else
if ( ( g_active && FALSE ) || g_keys[VK_ESCAPE] )
{
done=TRUE; // ESC or DrawGLScene Signalled A Quit
}
#endif
}
}
eglDestroyContext( g_egl.dsp, g_egl.cxt );
//.........这里部分代码省略.........
示例12: ngi_context_egl_swap
int ngi_context_egl_swap(ngi_context* ctx) {
return eglSwapBuffers(ctx->platform.egl.edpy, ctx->platform.egl.esfc);
}
示例13: engine_draw_frame
/**
* Just the current frame in the display.
*/
static void engine_draw_frame(struct engine* engine) {
engine->kiwiApp->render();
eglSwapBuffers(engine->display, engine->surface);
}
示例14: gfx_ctx_swap_buffers
static void gfx_ctx_swap_buffers(void)
{
eglSwapBuffers(g_egl_dpy, g_egl_surf);
}
示例15: main
//.........这里部分代码省略.........
// set some defaults
XnMapOutputMode defaultMode;
defaultMode.nXRes = 320;
defaultMode.nYRes = 240;
defaultMode.nFPS = 30;
nRetVal = mockDepth.SetMapOutputMode(defaultMode);
CHECK_RC(nRetVal, "set default mode");
// set FOV
XnFieldOfView fov;
fov.fHFOV = 1.0225999419141749;
fov.fVFOV = 0.79661567681716894;
nRetVal = mockDepth.SetGeneralProperty(XN_PROP_FIELD_OF_VIEW, sizeof(fov), &fov);
CHECK_RC(nRetVal, "set FOV");
XnUInt32 nDataSize = defaultMode.nXRes * defaultMode.nYRes * sizeof(XnDepthPixel);
XnDepthPixel* pData = (XnDepthPixel*)xnOSCallocAligned(nDataSize, 1, XN_DEFAULT_MEM_ALIGN);
nRetVal = mockDepth.SetData(1, 0, nDataSize, pData);
CHECK_RC(nRetVal, "set empty depth map");
g_DepthGenerator = mockDepth;
}
nRetVal = g_Context.FindExistingNode(XN_NODE_TYPE_USER, g_UserGenerator);
if (nRetVal != XN_STATUS_OK)
{
nRetVal = g_UserGenerator.Create(g_Context);
CHECK_RC(nRetVal, "Find user generator");
}
XnCallbackHandle hUserCallbacks, hCalibrationStart, hCalibrationComplete, hPoseDetected, hCalibrationInProgress, hPoseInProgress;
if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_SKELETON))
{
printf("Supplied user generator doesn't support skeleton\n");
return 1;
}
nRetVal = g_UserGenerator.RegisterUserCallbacks(User_NewUser, User_LostUser, NULL, hUserCallbacks);
CHECK_RC(nRetVal, "Register to user callbacks");
nRetVal = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationStart(UserCalibration_CalibrationStart, NULL, hCalibrationStart);
CHECK_RC(nRetVal, "Register to calibration start");
nRetVal = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationComplete(UserCalibration_CalibrationComplete, NULL, hCalibrationComplete);
CHECK_RC(nRetVal, "Register to calibration complete");
XnCallbackHandle hUserExitCB, hUserReenterCB;
nRetVal = g_UserGenerator.RegisterToUserExit(User_Exit, NULL, hUserExitCB);
CHECK_RC(nRetVal, "Register to user exit");
nRetVal = g_UserGenerator.RegisterToUserReEnter(User_ReEnter, NULL, hUserReenterCB);
CHECK_RC(nRetVal, "Register to user re-enter");
if (g_UserGenerator.GetSkeletonCap().NeedPoseForCalibration())
{
g_bNeedPose = TRUE;
if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION))
{
printf("Pose required, but not supported\n");
return 1;
}
nRetVal = g_UserGenerator.GetPoseDetectionCap().RegisterToPoseDetected(UserPose_PoseDetected, NULL, hPoseDetected);
CHECK_RC(nRetVal, "Register to Pose Detected");
g_UserGenerator.GetSkeletonCap().GetCalibrationPose(g_strPose);
nRetVal = g_UserGenerator.GetPoseDetectionCap().RegisterToPoseInProgress(MyPoseInProgress, NULL, hPoseInProgress);
CHECK_RC(nRetVal, "Register to pose in progress");
}
g_UserGenerator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_ALL);
nRetVal = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationInProgress(MyCalibrationInProgress, NULL, hCalibrationInProgress);
CHECK_RC(nRetVal, "Register to calibration in progress");
nRetVal = g_Context.StartGeneratingAll();
CHECK_RC(nRetVal, "StartGenerating");
#ifndef USE_GLES
glInit(&argc, argv);
glutMainLoop();
#else
if (!opengles_init(GL_WIN_SIZE_X, GL_WIN_SIZE_Y, &display, &surface, &context))
{
printf("Error initializing opengles\n");
CleanupExit();
}
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
while (!g_bQuit)
{
glutDisplay();
eglSwapBuffers(display, surface);
}
opengles_shutdown(display, surface, context);
CleanupExit();
#endif
}