本文整理汇总了C++中eglSwapBuffers函数的典型用法代码示例。如果您正苦于以下问题:C++ eglSwapBuffers函数的具体用法?C++ eglSwapBuffers怎么用?C++ eglSwapBuffers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eglSwapBuffers函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:2048Studio,项目名称:lwjgl,代码行数:6,代码来源:org_lwjgl_opengles_EGL.c
示例2: gfx_ctx_qnx_swap_buffers
static void gfx_ctx_qnx_swap_buffers(void *data)
{
(void)data;
eglSwapBuffers(g_egl_dpy, g_egl_surf);
}
开发者ID:ChowZenki,项目名称:RetroArch,代码行数:5,代码来源:bbqnx_ctx.c
示例3: eglSwapBuffers
// Show the current FPS
void cInterfaceEGL::Swap()
{
eglSwapBuffers(egl_dpy, egl_surf);
}
开发者ID:Blackbird88,项目名称:dolphin,代码行数:5,代码来源:EGL.cpp
示例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
}
开发者ID:F35X70,项目名称:libhybris,代码行数:96,代码来源:test_glesv2.c
示例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;
}
开发者ID:FlyingTarrasque,项目名称:lotus2d-engine,代码行数:97,代码来源:main.c
示例6: eglSwapBuffers
void cXInterface::SwapBuffers()
{
eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
}
开发者ID:Annovae,项目名称:dolphin,代码行数:4,代码来源:X11_Util.cpp
示例7: enddraw
void enddraw(int x, int y, int width, int height)
{
eglSwapBuffers(display, surface);
}
开发者ID:Antonius-git,项目名称:uTox,代码行数:4,代码来源:gl.c
示例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;
}
开发者ID:wuyuehang,项目名称:yuehan9,代码行数:101,代码来源:es3_indexdraw_rect.c
示例9: eglSwapBuffers
void CoreWindow::SwapBuffer()
{
eglSwapBuffers(esContext.eglDisplay, esContext.eglSurface);
// glXSwapBuffers(m_display, g_win->m_imp->m_win);
}
开发者ID:kioku-systemk,项目名称:CoreWindow,代码行数:5,代码来源:CoreWindow_egl.cpp
示例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 );
}
开发者ID:mikalai-silivonik,项目名称:annihilate-it,代码行数:101,代码来源:main.cpp
示例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 );
//.........这里部分代码省略.........
开发者ID:mikalai-silivonik,项目名称:annihilate-it,代码行数:101,代码来源:main.cpp
示例12: ngi_context_egl_swap
int ngi_context_egl_swap(ngi_context* ctx) {
return eglSwapBuffers(ctx->platform.egl.edpy, ctx->platform.egl.esfc);
}
开发者ID:scoopr,项目名称:ngi,代码行数:3,代码来源:ngi_context_egl.c
示例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);
}
开发者ID:Nom1vk,项目名称:VES,代码行数:7,代码来源:main.cpp
示例14: gfx_ctx_swap_buffers
static void gfx_ctx_swap_buffers(void)
{
eglSwapBuffers(g_egl_dpy, g_egl_surf);
}
开发者ID:chiefdeputy,项目名称:RetroArch,代码行数:4,代码来源:androidegl_ctx.c
示例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
}
开发者ID:wair,项目名称:Patched_Kinect_Drivers_for_Ubuntu,代码行数:101,代码来源:main.cpp
示例16: InitLocal
static DFBResult
InitLocal( AndroidData *android )
{
/*
* Here specify the attributes of the desired configuration.
* Below, we select an EGLConfig with at least 8 bits per color
* component compatible with on-screen windows
*/
const EGLint attribs[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_NATIVE_VISUAL_ID, HAL_PIXEL_FORMAT_RGBA_8888, // DSPF_ARGB
EGL_NONE
};
static const EGLint ctx_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
EGLint w, h, dummy, format;
EGLint numConfigs;
EGLConfig config;
EGLSurface surface;
EGLContext context;
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display, 0, 0);
/* Here, the application chooses the configuration it desires. In this
* sample, we have a very simplified selection process, where we pick
* the first EGLConfig that matches our criteria */
eglChooseConfig(display, attribs, &config, 1, &numConfigs);
/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
* As soon as we picked a EGLConfig, we can safely reconfigure the
* ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
ANativeWindow_setBuffersGeometry( native_data.app->window, 0, 0, format);
// ANativeActivity_setWindowFlags( native_data.app->window, AWINDOW_FLAG_FULLSCREEN | AWINDOW_FLAG_KEEP_SCREEN_ON , 0 );
surface = eglCreateWindowSurface(display, config, native_data.app->window, NULL);
context = eglCreateContext(display, config, NULL, ctx_attribs);
if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
LOGW("Unable to eglMakeCurrent");
return -1;
}
eglQuerySurface(display, surface, EGL_WIDTH, &w);
eglQuerySurface(display, surface, EGL_HEIGHT, &h);
android->dpy = display;
android->ctx = context;
android->surface = surface;
android->shared->screen_size.w = w;
android->shared->screen_size.h = h;
if (strstr(glGetString(GL_RENDERER),"SGX"))
android->shared->native_pixelformat = HAL_PIXEL_FORMAT_RGBA_8888; //ANativeWindow_getFormat(native_data.app->window);
else
android->shared->native_pixelformat = ANativeWindow_getFormat(native_data.app->window);
// Initialize GL state.
// glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
glEnable(GL_CULL_FACE);
// glShadeModel(GL_SMOOTH);
glDisable(GL_DEPTH_TEST);
// Just fill the screen with a color.
glClearColor( .5, .5, .5, 1 );
glClear( GL_COLOR_BUFFER_BIT );
eglSwapBuffers( android->dpy, android->surface );
return DFB_OK;
}
开发者ID:lelou6666,项目名称:DirectFB-1.6.3-ab,代码行数:87,代码来源:android_system.c
示例17: _glfwPlatformSwapBuffers
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
{
eglSwapBuffers(_glfw.egl.display, window->egl.surface);
}
开发者ID:jayschwa,项目名称:glfw,代码行数:4,代码来源:egl_context.c
示例18: glClear
//.........这里部分代码省略.........
int count = regions.size();
for (int i=0 ; i<count ; i++)
{
region_t *region = regions.at(i);
region_chip_t *chip = region->chip;
if ((region->state != MENU_DEFAULT) && (chip))
{
glBindTexture(GL_TEXTURE_2D, this->m_textures[LAYER_MENU_OVERLAY]);
glBegin(GL_QUADS);
glTexCoord2f(chip->x1, chip->y1); glVertex3f(region->x1, region->y1, LAYER_MENU_OVERLAY);
glTexCoord2f(chip->x2, chip->y1); glVertex3f(region->x2, region->y1, LAYER_MENU_OVERLAY);
glTexCoord2f(chip->x2, chip->y2); glVertex3f(region->x2, region->y2, LAYER_MENU_OVERLAY);
glTexCoord2f(chip->x1, chip->y2); glVertex3f(region->x1, region->y2, LAYER_MENU_OVERLAY);
glEnd();
}
}
}
//draw_quad(this->m_textures[LAYER_SYS_BASE], LAYER_SYS_BASE);
if (global.menu->in_dlg())
{
draw_quad(this->m_textures[LAYER_DLG], LAYER_DLG);
region_t *dlg_regions = global.menu->get_dlg_regions();
for (int i=0 ; i<2 ; i++)
{
region_t *region = &dlg_regions[i];
region_chip_t *chip = region->chip;
if ((region->state != MENU_DEFAULT) && (chip))
{
glBindTexture(GL_TEXTURE_2D, this->m_textures[LAYER_DLG_OVERLAY]);
glBegin(GL_QUADS);
glTexCoord2f(chip->x1, chip->y1); glVertex3f(region->x1, region->y1, LAYER_DLG_OVERLAY);
glTexCoord2f(chip->x2, chip->y1); glVertex3f(region->x2, region->y1, LAYER_DLG_OVERLAY);
glTexCoord2f(chip->x2, chip->y2); glVertex3f(region->x2, region->y2, LAYER_DLG_OVERLAY);
glTexCoord2f(chip->x1, chip->y2); glVertex3f(region->x1, region->y2, LAYER_DLG_OVERLAY);
glEnd();
}
}
}
//for (int i=0 ; i<LAYERS_COUNT ; i++)
//draw_quad(this->m_textures[i], i);
if (this->m_fade_color != -1)
{
glColor4d(this->m_fade_color, this->m_fade_color, this->m_fade_color, this->m_fade);
if (this->m_fade_color)
draw_quad(this->m_texture_white, LAYER_OVERLAY);
else
draw_quad(this->m_texture_black, LAYER_OVERLAY);
}
#ifdef _WIN32
SwapBuffers(this->m_dc);
#elif defined __unix__
glXSwapBuffers(this->m_dpy, this->m_win);
#else
#error here!
#endif
#else
glViewport(0, 0, this->m_gwa.width, this->m_gwa.height);
for (int i=0 ; i<=LAYERS_COUNT ; i++)
if (this->m_textures[i] != uint32_t(-1))
{
glBindTexture(GL_TEXTURE_2D, this->m_textures[i]);
GLint box[] =
{
-1, -1, i,
1, -1, i,
1, 1, i,
-1, 1, i
};
GLfloat tex[] =
{
0.0, 1.0,
1.0, 1.0,
1.0, 0.0,
0.0, 0.0
};
glVertexAttribPointer(attr_pos, 3, GL_INT, GL_FALSE, 0, box);
glVertexAttribPointer(attr_color, 2, GL_FLOAT, GL_FALSE, 0, tex);
glEnableVertexAttribArray(attr_pos);
glEnableVertexAttribArray(attr_color);
//glVertexPointer(3, GL_FLOAT, 0, box);
//glTexCoordPointer(2, GL_FLOAT, 0, tex);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableVertexAttribArray(attr_pos);
glDisableVertexAttribArray(attr_color);
}
eglSwapBuffers(this->m_dpy, this->m_surf);
#endif
}
开发者ID:andreili,项目名称:School-Days,代码行数:101,代码来源:interface.cpp
示例19: SwapBuffers
void SwapBuffers( void ) {
int err, i;
int t;
int size[2];
int pos[2];
t = Sys_Milliseconds();
if (!setup_vert)
{
vert = (GLfloat*)malloc(2*(NUM_VERT+2) * sizeof(GLfloat));
vert[0] = 0;
vert[1] = 0;
for (i = 0; i < NUM_VERT+1; i+=2)
{
vert[i+2] = (GLfloat)(sinf(2 * PI / NUM_VERT * i)) * 600 / 768;
vert[i+3] = (GLfloat)(cosf(2 * PI / NUM_VERT * i));
}
setup_vert = 1;
}
if (cls.state == CA_ACTIVE)
{
if ( !backEnd.projection2D )
RB_SetGL2D();
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
if (!uis.activemenu)
drawControls();
glEnable(GL_TEXTURE_2D);
}
// if (min || max) {
// eglMakeCurrent(eglDisplay,
// EGL_NO_SURFACE,
// EGL_NO_SURFACE,
// EGL_NO_CONTEXT);
// eglMakeCurrent(eglDisplay,
// eglSurface,
// eglSurface,
// eglContext);
//
// size[0] = glConfig.vidWidth;
// size[1] = glConfig.vidHeight;
// screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_SIZE, size);
//
// if (min) {
// pos[0] = 0;
// pos[1] = bz[1] - size[1];
// min = 0;
// } else {
// pos[0] = 0;
// pos[1] = 0;
// max = 0;
// }
//
// screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_POSITION, pos);
// }
eglSwapBuffers(eglDisplay, eglSurface);
err = eglGetError( );
if (err != EGL_SUCCESS ) {
Com_Printf( "Error, eglSwapBuffers failed" );
PrintEglError( err );
return;
}
}
开发者ID:LoudHoward,项目名称:Quake3,代码行数:74,代码来源:qnx_glimp.c
示例20: RenderScene
/*!*****************************************************************************************************************************************
@Function RenderScene
@Input eglDisplay The EGLDisplay used by the application
@Input eglSurface The EGLSurface created from the native window.
@Input nativeWindow A native window, used to display error messages
@Return Whether the function succeeds or not.
@Description Renders the scene to the framebuffer. Usually called within a loop.
*******************************************************************************************************************************************/
bool RenderScene( EGLDisplay eglDisplay, EGLSurface eglSurface, HWND nativeWindow )
{
// The message handler setup for the window system will signal this variable when the window is closed, so close the application.
if (g_hasUserQuit)
{
return false;
}
/* Set the clear color
At the start of a frame, generally you clear the image to tell OpenGL ES that you're done with whatever was there before and want to
draw a new frame. In order to do that however, OpenGL ES needs to know what colour to set in the image's place. glClearColor
sets this value as 4 floating point values between 0.0 and 1.x, as the Red, Green, Blue and Alpha channels. Each value represents
the intensity of the particular channel, with all 0.0 being transparent black, and all 1.x being opaque white. Subsequent calls to
glClear with the colour bit will clear the frame buffer to this value.
The functions glClearDepth and glClearStencil allow an application to do the same with depth and stencil values respectively.
*/
glClearColor(0.6f, 0.8f, 1.0f, 1.0f);
/* Clears the color buffer.
glClear is used here with the Colour Buffer to clear the colour. It can also be used to clear the depth or stencil buffer using
GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT, respectively.
*/
glClear(GL_COLOR_BUFFER_BIT);
// Enable the vertex array
glEnableClientState(GL_VERTEX_ARRAY);
// Sets the vertex data to this attribute index, with the number of floats in each position
glVertexPointer(3, GL_FLOAT, 3*sizeof(GLfloat), (GLvoid*)0);
if (!TestGLError(nativeWindow, "glVertexAttribPointer"))
{
return false;
}
// Set a color to render
glColor4f(1.0f, 1.0f, 0.66, 1.0f);
/* Draw the triangle
glDrawArrays is a draw call, and executes the shader program using the vertices and other state set by the user. Draw calls are the
functions which tell OpenGL ES when to actually draw something to the framebuffer given the current state.
glDrawArrays causes the vertices to be submitted sequentially from the position given by the "first" argument until it has processed
"count" vertices. Other draw calls exist, notably glDrawElements which also accepts index data to allow the user to specify that
some vertices are accessed multiple times, without copying the vertex multiple times.
Others include versions of the above that allow the user to draw the same object multiple times with slightly different data, and
a version of glDrawElements which allows a user to restrict the actual indices accessed.
*/
glDrawArrays(GL_TRIANGLES, 0, 3);
if (!TestGLError(nativeWindow, "glDrawArrays"))
{
return false;
}
/* Present the display data to the screen.
When rendering to a Window surface, OpenGL ES is double buffered. This means that OpenGL ES renders directly to one frame buffer,
known as the back buffer, whilst the display reads from another - the front buffer. eglSwapBuffers signals to the windowing system
that OpenGL ES 1.x has finished rendering a scene, and that the display should now draw to the screen from the new data. At the same
time, the front buffer is made available for OpenGL ES 1.x to start rendering to. In effect, this call swaps the front and back
buffers.
*/
if (!eglSwapBuffers(eglDisplay, eglSurface) )
{
TestEGLError(nativeWindow, "eglSwapBuffers");
return false;
}
// Check for messages from the windowing system. These will pass through the callback registered earlier.
MSG eventMessage;
PeekMessage(&eventMessage, nativeWindow, NULL, NULL, PM_REMOVE);
TranslateMessage(&eventMessage);
DispatchMessage(&eventMessage);
return true;
}
开发者ID:joyfish,项目名称:GameThirdPartyLibs,代码行数:81,代码来源:OGLESHelloAPI_Windows.cpp
注:本文中的eglSwapBuffers函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论