本文整理汇总了C++中eglCreateWindowSurface函数的典型用法代码示例。如果您正苦于以下问题:C++ eglCreateWindowSurface函数的具体用法?C++ eglCreateWindowSurface怎么用?C++ eglCreateWindowSurface使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eglCreateWindowSurface函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateWindowL
// ---------------------------------------------------------
// CRollerCoasterContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CRollerCoasterContainer::ConstructL(const TRect& /*aRect*/)
{
iIsGenerating = ETrue;
CreateWindowL();
// Make the window fullscreen
SetExtentToWholeScreen();
ActivateL();
EGLConfig Config;
// Get the display for drawing graphics
iEglDisplay = eglGetDisplay( EGL_DEFAULT_DISPLAY );
if( iEglDisplay == NULL )
{
_LIT(KGetDisplayFailed, "eglGetDisplay failed");
User::Panic( KGetDisplayFailed, 0 );
}
// Initialize display
if( eglInitialize( iEglDisplay, NULL, NULL ) == EGL_FALSE )
{
_LIT(KInitializeFailed, "eglInitialize failed");
User::Panic( KInitializeFailed, 0 );
}
EGLConfig *configList = NULL;
EGLint numOfConfigs = 0;
EGLint configSize = 0;
// Get the number of possible EGLConfigs
if( eglGetConfigs(iEglDisplay, configList, configSize, &numOfConfigs) == EGL_FALSE )
{
_LIT(KGetConfigsFailed, "eglGetConfigs failed");
User::Panic( KGetConfigsFailed, 0 );
}
configSize = numOfConfigs;
// Allocate memory for the configList
configList = (EGLConfig*) User::Alloc( sizeof(EGLConfig)*configSize );
if( configList == NULL )
{
_LIT(KConfigAllocFailed, "config alloc failed");
User::Panic( KConfigAllocFailed, 0 );
}
/* Define properties for the wanted EGLSurface.
To get the best possible performance, choose
an EGLConfig with a buffersize matching
the current window's display mode*/
TDisplayMode DMode = Window().DisplayMode();
TInt BufferSize = 0;
switch( DMode )
{
case(EColor4K):
BufferSize = 12;
break;
case(EColor64K):
BufferSize = 16;
break;
case(EColor16M):
BufferSize = 24;
break;
default:
_LIT(KDModeError, "unsupported displaymode");
User::Panic( KDModeError, 0 );
break;
}
// Define properties for the wanted EGLSurface
const EGLint attrib_list[] = {EGL_BUFFER_SIZE, BufferSize, EGL_DEPTH_SIZE, 16, EGL_NONE};
// Choose an EGLConfig that best matches to the properties in attrib_list
if( eglChooseConfig(iEglDisplay, attrib_list, configList, configSize, &numOfConfigs) == EGL_FALSE )
{
_LIT(KChooseConfigFailed, "eglChooseConfig failed");
User::Panic( KChooseConfigFailed, 0 );
}
Config = configList[0];
User::Free( configList );
// Create a window where the graphics are blitted
iEglSurface = eglCreateWindowSurface( iEglDisplay, Config, &Window(), NULL );
if( iEglSurface == NULL )
{
_LIT(KCreateWindowSurfaceFailed, "eglCreateWindowSurface failed");
User::Panic( KCreateWindowSurfaceFailed, 0 );
}
// Create a rendering context
iEglContext = eglCreateContext( iEglDisplay, Config, NULL, NULL );
//.........这里部分代码省略.........
示例2: maemoGLinit
//.........这里部分代码省略.........
if (!x11Display)
{
printf("GLES Error: Unable to open X display\n");
}
x11Screen = XDefaultScreen( x11Display );
// Gets the display parameters so we can pass the same parameters to the window to be created.
sRootWindow = RootWindow(x11Display, x11Screen);
i32Depth = DefaultDepth(x11Display, x11Screen);
px11Visual = &x11Visual;
XMatchVisualInfo( x11Display, x11Screen, i32Depth, TrueColor, px11Visual);
if (!px11Visual)
{
printf("GLES Error: Unable to acquire visual\n");
}
// Colormap of the specified visual type for the display.
x11Colormap = XCreateColormap( x11Display, sRootWindow, px11Visual->visual, AllocNone );
sWA.colormap = x11Colormap;
// List of events to be handled by the application. Add to these for handling other events.
sWA.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask;
// Display capabilities list.
ui32Mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;
// Creates the X11 window
x11Window = XCreateWindow( x11Display, RootWindow(x11Display, x11Screen), 0, 0, iResX, iResY,
0, CopyFromParent, InputOutput, CopyFromParent, ui32Mask, &sWA);
// Make the window viewable and flush the output buffer.
XMapWindow(x11Display, x11Window);
XFlush(x11Display);
// Make the window fullscreen
unsigned char fullScreen = 1;
Atom wmState = XInternAtom(x11Display, "_NET_WM_STATE", False);
Atom wmFullScreen = XInternAtom(x11Display,"_NET_WM_STATE_FULLSCREEN", False);
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
xev.xclient.window = x11Window;
xev.xclient.message_type = wmState;
xev.xclient.format = 32;
xev.xclient.data.l[0] = (fullScreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE);
xev.xclient.data.l[1] = wmFullScreen;
xev.xclient.data.l[2] = 0;
XSendEvent(x11Display, DefaultRootWindow(x11Display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
display = eglGetDisplay( (EGLNativeDisplayType)x11Display );
break;
#endif
case MODE_RAW:
default:
display = eglGetDisplay( (EGLNativeDisplayType)0 );
break;
}
if( display == EGL_NO_DISPLAY )
{
printf( "GLES EGL Error: GL No Display\n" );
}
if( !eglInitialize( display, &majorVersion, &minorVersion ) )
{
printf( "GLES EGL Error: eglInitialize failed\n" );
}
if( !eglChooseConfig( display, attribList, &config, 1, &numConfigs ) )
{
printf( "GLES EGL Error: eglChooseConfig failed\n" );
}
context = eglCreateContext( display, config, NULL, NULL );
if( context==0 )
{
printf( "GLES EGL Error: eglCreateContext failed\n" );
}
switch(pandora_driver_mode)
{
#if defined(USE_X11)
case MODE_X11:
surface = eglCreateWindowSurface( display, config, (EGLNativeDisplayType)x11Window, NULL );
break;
#endif
case MODE_RAW:
default:
surface = eglCreateWindowSurface( display, config, (EGLNativeDisplayType)0, NULL );
break;
}
eglMakeCurrent( display, surface, surface, context );
if (!TestEGLError("eglMakeCurrent"))
printf("error eglMakeCurrent");
else
printf("GLES Window Opened\n");
}
示例3: make_x_window
static Bool
make_x_window(struct app_data *data, const char *name,
int x, int y, int width, int height)
{
static const EGLint attribs[] = {
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_DEPTH_SIZE, 1,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
EGL_NONE
};
static const EGLint ctx_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 1,
EGL_NONE
};
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
Window root;
Window win;
XVisualInfo *visInfo, visTemplate;
int num_visuals;
EGLConfig config;
EGLint num_configs;
EGLint vid;
scrnum = DefaultScreen( data->xdpy );
root = RootWindow( data->xdpy, scrnum );
if (!eglChooseConfig( data->dpy, attribs, &config, 1, &num_configs)) {
printf("Error: couldn't get an EGL visual config\n");
exit(1);
}
assert(config);
assert(num_configs > 0);
if (!eglGetConfigAttrib(data->dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
printf("Error: eglGetConfigAttrib() failed\n");
exit(1);
}
/* The X window visual must match the EGL config */
visTemplate.visualid = vid;
visInfo = XGetVisualInfo(data->xdpy, VisualIDMask, &visTemplate, &num_visuals);
if (!visInfo) {
printf("Error: couldn't get X visual\n");
exit(1);
}
/* window attributes */
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap( data->xdpy, root, visInfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask |
KeyPressMask | ButtonPressMask | ButtonMotionMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow( data->xdpy, root, 0, 0, width * 2, height,
0, visInfo->depth, InputOutput,
visInfo->visual, mask, &attr );
/* set hints and properties */
{
XSizeHints sizehints;
sizehints.x = x;
sizehints.y = y;
sizehints.width = width;
sizehints.height = height;
sizehints.flags = USSize | USPosition;
XSetNormalHints(data->xdpy, win, &sizehints);
XSetStandardProperties(data->xdpy, win, name, name,
None, (char **)NULL, 0, &sizehints);
}
data->canvas = win;
attr.event_mask = 0x0;
win = XCreateWindow( data->xdpy, win, width, 0, width, height,
0, visInfo->depth, InputOutput,
visInfo->visual, mask, &attr );
data->cube = win;
eglBindAPI(EGL_OPENGL_ES_API);
data->ctx = eglCreateContext(data->dpy, config, EGL_NO_CONTEXT, ctx_attribs );
if (!data->ctx) {
printf("Error: eglCreateContext failed\n");
exit(1);
}
data->surf = eglCreateWindowSurface(data->dpy, config, data->cube, NULL);
if (!data->surf) {
printf("Error: eglCreateWindowSurface failed\n");
exit(1);
}
XFree(visInfo);
//.........这里部分代码省略.........
示例4: LOG
void AppLocal::CreateWindowSurface()
{
LOG( "AppLocal::CreateWindowSurface()" );
// Optionally force the window to a different resolution, which
// will be automatically scaled up by the HWComposer.
//
// Useful for checking operation, but note that the "frame" is always in full
// display resolution, while the source crop can be shrunk down:
// adb shell dumpsys SurfaceFlinger
//
// Strangely, setting the format here doesn't actually change the window bit depth.
// The window bit depth seems to be determined solely by the EGL config, presumably
// on eglMakeCurrent.
//
// That also means that it can't be changed by localparms between leave / enter vr mode,
// you need to quit all the way out to get the new value.
if ( VrSettings.Use16BitFramebuffer )
{
const int displayPixelsWide = vrapi_GetSystemPropertyInt( &Java, VRAPI_SYS_PROP_DISPLAY_PIXELS_WIDE );
const int displayPixelsHigh = vrapi_GetSystemPropertyInt( &Java, VRAPI_SYS_PROP_DISPLAY_PIXELS_HIGH );
LOG( "ANativeWindow_setBuffersGeometry( %i, %i, %s )",
displayPixelsWide, displayPixelsHigh,
VrSettings.Use16BitFramebuffer ? "5:6:5" : "8:8:8:8" );
ANativeWindow_setBuffersGeometry( nativeWindow, displayPixelsWide, displayPixelsHigh,
VrSettings.Use16BitFramebuffer ? WINDOW_FORMAT_RGB_565 : WINDOW_FORMAT_RGBA_8888 );
}
EGLint attribs[16];
int numAttribs = 0;
// Set the colorspace on the window
if ( VrSettings.UseSrgbFramebuffer )
{
attribs[numAttribs++] = EGL_GL_COLORSPACE_KHR;
attribs[numAttribs++] = EGL_GL_COLORSPACE_SRGB_KHR;
}
attribs[numAttribs++] = EGL_NONE;
// Android doesn't let the non-standard extensions show up in the
// extension string, so we need to try it blind.
windowSurface = eglCreateWindowSurface( glSetup.display, glSetup.config, nativeWindow, attribs );
if ( windowSurface == EGL_NO_SURFACE )
{
const EGLint attribs2[] =
{
EGL_NONE
};
windowSurface = eglCreateWindowSurface( glSetup.display, glSetup.config, nativeWindow, attribs2 );
if ( windowSurface == EGL_NO_SURFACE )
{
FAIL( "eglCreateWindowSurface failed: %s", GL_GetErrorString() );
}
FramebufferIsSrgb = false;
}
else
{
FramebufferIsSrgb = VrSettings.UseSrgbFramebuffer;
}
LOG( "nativeWindow %p gives surface %p", nativeWindow, windowSurface );
if ( eglMakeCurrent( glSetup.display, windowSurface, windowSurface, glSetup.context ) == EGL_FALSE )
{
FAIL( "eglMakeCurrent failed: %s", GL_GetErrorString() );
}
}
示例5: main
//----------------------------------------------------------------------------//
int main(int argc, char* argv[])
{
// Create X11 window.
Display* dpy = XOpenDisplay(0);
int scn = DefaultScreen(dpy);
Window wnd = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
50, 50, 480, 320, 1,
BlackPixel(dpy, scn),
WhitePixel(dpy, scn));
XSelectInput(dpy, wnd, StructureNotifyMask |
PointerMotionMask |
ButtonPressMask | ButtonReleaseMask |
KeyPressMask | KeyReleaseMask);
XMapWindow(dpy, wnd);
XEvent evt;
while (true)
{
XNextEvent(dpy, &evt);
if (evt.type == MapNotify)
break;
}
// EGL setup
EGLDisplay egldpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
EGLint majVer, minVer;
eglInitialize(egldpy, &majVer, &minVer);
EGLint attrs[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NONE
};
EGLConfig config;
EGLint numconfigs;
eglChooseConfig(egldpy, attrs, &config, 1, &numconfigs);
EGLSurface surface =
eglCreateWindowSurface(egldpy, config, (NativeWindowType)wnd, 0);
EGLContext ctx = eglCreateContext(egldpy, config, 0, 0);
eglMakeCurrent(egldpy, surface, surface, ctx);
eglBindAPI(EGL_OPENGL_ES_API);
// basic gl state setup;
glViewport(0, 0, 480, 320);
glClearColor(0.2, 0.2, 0.2, 1);
// CEGUI setup
CEGUI::OpenGLESRenderer::bootstrapSystem();
initialiseResourceGroupDirectories();
initialiseDefaultResourceGroups();
CEGUI::SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");
CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");
CEGUI::WindowManager& winMgr(CEGUI::WindowManager::getSingleton());
CEGUI::Window* root = winMgr.createWindow("DefaultWindow", "root");
CEGUI::Window* fw = root->createChild("TaharezLook/FrameWindow");
fw->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25, 0), CEGUI::UDim(0.25, 0)));
fw->setSize(CEGUI::USize(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.5, 0)));
fw->setText("OpenGL ES 1 Test");
CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(root);
// Main looop
bool running = true;
while (running)
{
while (XPending(dpy))
{
XNextEvent(dpy, &evt);
switch (evt.type)
{
case KeyPress:
{
int kspkcr;
KeySym* ks = XGetKeyboardMapping(dpy, evt.xkey.keycode, 1, &kspkcr);
if (ks[0] == XK_Escape)
running = false;
break;
}
case MotionNotify:
CEGUI::System::getSingleton().getDefaultGUIContext().injectMousePosition(evt.xmotion.x, evt.xmotion.y);
break;
case ButtonPress:
{
//.........这里部分代码省略.........
示例6: angle_init
static int angle_init(struct MPGLContext *ctx, int flags)
{
struct priv *p = ctx->priv;
struct vo *vo = ctx->vo;
if (!vo_w32_init(vo))
goto fail;
HDC dc = GetDC(vo_w32_hwnd(vo));
if (!dc) {
MP_FATAL(vo, "Couldn't get DC\n");
goto fail;
}
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT =
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
if (!eglGetPlatformDisplayEXT) {
MP_FATAL(vo, "Missing EGL_EXT_platform_base\n");
goto fail;
}
EGLint d3d_types[] = {EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE};
for (int i = 0; i < MP_ARRAY_SIZE(d3d_types); i++) {
EGLint display_attributes[] = {
EGL_PLATFORM_ANGLE_TYPE_ANGLE,
d3d_types[i],
EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE,
EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE,
EGL_NONE,
};
p->egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, dc,
display_attributes);
if (p->egl_display != EGL_NO_DISPLAY)
break;
}
if (p->egl_display == EGL_NO_DISPLAY) {
MP_FATAL(vo, "Couldn't get display\n");
goto fail;
}
if (!eglInitialize(p->egl_display, NULL, NULL)) {
MP_FATAL(vo, "Couldn't initialize EGL\n");
goto fail;
}
eglBindAPI(EGL_OPENGL_ES_API);
if (eglGetError() != EGL_SUCCESS) {
MP_FATAL(vo, "Couldn't bind GLES API\n");
goto fail;
}
EGLConfig config = select_fb_config_egl(ctx);
if (!config)
goto fail;
p->egl_surface = eglCreateWindowSurface(p->egl_display, config,
vo_w32_hwnd(vo), NULL);
if (p->egl_surface == EGL_NO_SURFACE) {
MP_FATAL(ctx->vo, "Could not create EGL surface!\n");
goto fail;
}
if (!create_context_egl(ctx, config, 3) &&
!create_context_egl(ctx, config, 2))
{
MP_FATAL(ctx->vo, "Could not create EGL context!\n");
goto fail;
}
mpgl_load_functions(ctx->gl, get_proc_address, NULL, vo->log);
return 0;
fail:
angle_uninit(ctx);
return -1;
}
示例7: gfx_ctx_xegl_set_video_mode
//.........这里部分代码省略.........
width = new_width;
height = new_height;
}
}
#endif
RARCH_LOG("[X/EGL]: X = %d, Y = %d, W = %u, H = %u.\n",
x_off, y_off, width, height);
g_win = XCreateWindow(g_dpy, RootWindow(g_dpy, vi->screen),
x_off, y_off, width, height, 0,
vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask | (true_full ? CWOverrideRedirect : 0), &swa);
XSetWindowBackground(g_dpy, g_win, 0);
g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT,
attr != egl_attribs ? egl_attribs : NULL);
RARCH_LOG("[X/EGL]: Created context: %p.\n", (void*)g_egl_ctx);
if (g_egl_ctx == EGL_NO_CONTEXT)
goto error;
if (g_use_hw_ctx)
{
g_egl_hw_ctx = eglCreateContext(g_egl_dpy, g_egl_config, g_egl_ctx,
attr != egl_attribs ? egl_attribs : NULL);
RARCH_LOG("[X/EGL]: Created shared context: %p.\n", (void*)g_egl_hw_ctx);
if (g_egl_hw_ctx == EGL_NO_CONTEXT)
goto error;
}
g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, (EGLNativeWindowType)g_win, NULL);
if (!g_egl_surf)
goto error;
if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx))
goto error;
RARCH_LOG("[X/EGL]: Current context: %p.\n", (void*)eglGetCurrentContext());
x11_set_window_attr(g_dpy, g_win);
if (fullscreen)
x11_show_mouse(g_dpy, g_win, false);
if (true_full)
{
RARCH_LOG("[X/EGL]: Using true fullscreen.\n");
XMapRaised(g_dpy, g_win);
}
else if (fullscreen)
{
/* We attempted true fullscreen, but failed.
* Attempt using windowed fullscreen. */
XMapRaised(g_dpy, g_win);
RARCH_LOG("[X/EGL]: Using windowed fullscreen.\n");
/* We have to move the window to the screen we
* want to go fullscreen on first.
* x_off and y_off usually get ignored in XCreateWindow().
*/
x11_move_window(g_dpy, g_win, x_off, y_off, width, height);
x11_windowed_fullscreen(g_dpy, g_win);
}
示例8: init_ogl
static void init_ogl( void )
{
int32_t success;
static EGL_DISPMANX_WINDOW_T nativewindow;
DISPMANX_ELEMENT_HANDLE_T dispman_element;
DISPMANX_DISPLAY_HANDLE_T dispman_display;
DISPMANX_UPDATE_HANDLE_T dispman_update;
VC_RECT_T dst_rect;
VC_RECT_T src_rect;
EGLBoolean result;
// Change this to get without alpha to save some resources.
static const EGLint attribute_list[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 0, // was 8
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NONE
};
static const EGLint context_attributes[] =
{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
EGLConfig config;
EGLint num_config;
bcm_host_init();
// get an EGL display connection
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
assert( display!=EGL_NO_DISPLAY );
// initialize the EGL display connection
result = eglInitialize( display, NULL, NULL);
assert(EGL_FALSE != result);
// get an appropriate EGL frame buffer configuration
result = eglChooseConfig( display, attribute_list, &config, 1, &num_config);
assert(EGL_FALSE != result);
// get an appropriate EGL frame buffer configuration
result = eglBindAPI(EGL_OPENGL_ES_API);
assert(EGL_FALSE != result);
// create an EGL rendering context
context = eglCreateContext( display, config, EGL_NO_CONTEXT, context_attributes );
assert( context != EGL_NO_CONTEXT );
// create an EGL window surface
success = graphics_get_display_size(0 /* LCD */, &screenWidth, &screenHeight);
assert( success >= 0 );
printf( "Screen size: %d x %d pixels\n", screenWidth, screenHeight );
dst_rect.x = 0;
dst_rect.y = 0;
dst_rect.width = screenWidth;
dst_rect.height = screenHeight;
src_rect.x = 0;
src_rect.y = 0;
src_rect.width = screenWidth << 16;
src_rect.height = screenHeight << 16;
dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
dispman_update = vc_dispmanx_update_start( 0 );
dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display,
0/*layer*/, &dst_rect, 0/*src*/,
&src_rect, DISPMANX_PROTECTION_NONE, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);
nativewindow.element = dispman_element;
nativewindow.width = screenWidth;
nativewindow.height = screenHeight;
vc_dispmanx_update_submit_sync( dispman_update );
surface = eglCreateWindowSurface( display, config, &nativewindow, NULL );
assert(surface != EGL_NO_SURFACE);
// connect the context to the surface
result = eglMakeCurrent( display, surface, surface, context);
assert(EGL_FALSE != result);
}
示例9: g_print
//.........这里部分代码省略.........
EGLNativeWindowType eglWindow = 0;
EGLDisplay eglDisplay = EGL_NO_DISPLAY;
EGLSurface eglSurface = EGL_NO_SURFACE;
EGLContext eglContext = EGL_NO_CONTEXT;
EGLBoolean ret = eglBindAPI(EGL_OPENGL_ES_API);
if (EGL_TRUE != ret)
g_print("eglBindAPI() failed. [0x%x]\n", eglGetError());
eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (EGL_NO_DISPLAY == eglDisplay)
g_print("eglGetDisplay() failed. [0x%x]\n", eglGetError());
EGLint major = 2;
EGLint minor = 0;
if (EGL_FALSE == eglInitialize(eglDisplay, &major, &minor) || EGL_SUCCESS != eglGetError())
g_print("eglInitialize() failed. [0x%x]\n", eglGetError());
g_print("EGL Version :%s\n", eglQueryString(eglDisplay, EGL_VERSION));
g_print("EGL Vendor :%s\n", eglQueryString(eglDisplay, EGL_VENDOR));
g_print("EGL Extensions:%s\n", eglQueryString(eglDisplay, EGL_EXTENSIONS));
// 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
EGLint eglNumConfigs = 0;
EGLConfig eglConfig;
eglGetConfigs(eglDisplay, NULL, 0, &eglNumConfigs);
g_print("eglNumConfigs = %i\n", eglNumConfigs);
/*
int i = 0;
for (i = 0; i<eglNumConfigs; ++i) {
EGLint samples = 0;
//if (EGL_FALSE == eglGetConfigAttrib(eglDisplay, eglConfig[i], EGL_SAMPLES, &samples))
// printf("eglGetConfigAttrib in loop for an EGL_SAMPLES fail at i = %i\n", i);
if (EGL_FALSE == eglGetConfigAttrib(eglDisplay, eglConfig[i], EGL_SAMPLE_BUFFERS, &samples))
printf("eglGetConfigAttrib in loop for an EGL_SAMPLE_BUFFERS fail at i = %i\n", i);
if (samples > 0)
printf("sample found: %i\n", samples);
}
eglGetConfigs(eglDisplay, configs, num_config[0], num_config))
*/
// 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 eglConfigList[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_NONE
};
if (EGL_FALSE == eglChooseConfig(eglDisplay, eglConfigList, &eglConfig, 1, &eglNumConfigs))
g_print("eglChooseConfig() failed. [0x%x]\n", eglGetError());
if (0 == eglNumConfigs)
g_print("eglChooseConfig() eglNumConfigs no matching config [0x%x]\n", eglGetError());
eglWindow = (EGLNativeWindowType) gtk_widget_get_window(engine->window);
if (FALSE == eglWindow) {
g_print("ERROR: EGLNativeWindowType is NULL (can't draw)\n");
g_assert(0);
}
g_print("DEBUG: eglDisplay =0X%X\n", (guint)eglDisplay);
g_print("DEBUG: eglConfig =0X%X\n", (guint)eglConfig);
g_print("DEBUG: eglWindowXID=0X%X\n", (guint)GDK_WINDOW_XID(eglWindow));
eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, GDK_WINDOW_XID(gtk_widget_get_window(engine->window)), NULL);
if (EGL_NO_SURFACE == eglSurface || EGL_SUCCESS != eglGetError())
g_print("eglCreateWindowSurface() failed. EGL_NO_SURFACE [0x%x]\n", eglGetError());
// Then we can create the context and set it current:
EGLint eglContextList[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
eglContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, eglContextList);
if (EGL_NO_CONTEXT == eglContext || EGL_SUCCESS != eglGetError())
g_print("eglCreateContext() failed. [0x%x]\n", eglGetError());
if (EGL_FALSE == eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext))
g_print("Unable to eglMakeCurrent()\n");
engine->eglDisplay = eglDisplay;
engine->eglContext = eglContext;
engine->eglSurface = eglSurface;
engine->eglWindow = eglWindow;
g_print("s52egl:_egl_init(): end ..\n");
return 1;
}
示例10: defined
void EGLRuntime::initializeEGL(OpenGLESVersion requestedAPIVersion)
{
Platform* platform = Platform::getInstance();
EGLBoolean success = EGL_FALSE;
#if defined(_WIN32)
/* Win32 */
display = eglGetDisplay(platform->deviceContext);
#elif defined(__arm__)
/* Linux on ARM */
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
#else
/* Desktop Linux */
platform->display = XOpenDisplay(NULL);
display = eglGetDisplay(platform->display);
#endif
if(display == EGL_NO_DISPLAY)
{
EGLint error = eglGetError();
LOGE("eglGetError(): %i (0x%.4x)\n", (int)error, (int)error);
LOGE("No EGL Display available at %s:%i\n", __FILE__, __LINE__);
exit(1);
}
/* Initialize EGL. */
success = eglInitialize(display, NULL, NULL);
if(success != EGL_TRUE)
{
EGLint error = eglGetError();
LOGE("eglGetError(): %i (0x%.4x)\n", (int)error, (int)error);
LOGE("Failed to initialize EGL at %s:%i\n", __FILE__, __LINE__);
exit(1);
}
/* Depending on app-requested EGL attributes, tweak the attributes we pass to EGL. */
if(requestedAPIVersion == OPENGLES1)
{
configAttributes[15] = EGL_OPENGL_ES_BIT;
contextAttributes[1] = 1;
}
else if(requestedAPIVersion == OPENGLES2)
{
configAttributes[15] = EGL_OPENGL_ES2_BIT;
contextAttributes[1] = 2;
}
/*
* Despite the fact an OpenGL ES 3.0 config is required, we request configs using the OpenGL_ES2_BIT.
* At the time of writing there is no OpenGL_ES3_BIT, and so platforms return
* OpenGL ES 3.0 configs with the OpenGL_ES2_BIT set.
* We request a context with EGL_CONTEXT_CLIENT_VERSION of 3 (OpenGL ES 3.0) which will ensure that
* OpenGL ES 3.0 features are supported.
*/
else if (requestedAPIVersion == OPENGLES3)
{
configAttributes[15] = EGL_OPENGL_ES2_BIT;
contextAttributes[1] = 3;
}
/*
* Find a matching config and store it in our static variable.
* On ARM devices perform a strict match to ensure we get the best performance.
* On desktop devices perform a loose match to ensure greatest compatability.
*/
#if defined(__arm__)
config = findConfig(true);
#else
config = findConfig(false);
#endif
#if defined(__linux__) && !defined(__arm__)
((DesktopLinuxPlatform*)(platform))->createX11Window();
#endif
/* Create a surface. */
surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)(platform->window), windowAttributes);
if(surface == EGL_NO_SURFACE)
{
EGLint error = eglGetError();
LOGE("eglGetError(): %i (0x%.4x)\n", (int)error, (int)error);
LOGE("Failed to create EGL surface at %s:%i\n", __FILE__, __LINE__);
exit(1);
}
/* Unconditionally bind to OpenGL ES API as we exit this function, since it's the default. */
eglBindAPI(EGL_OPENGL_ES_API);
context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttributes);
if(context == EGL_NO_CONTEXT)
{
EGLint error = eglGetError();
LOGE("eglGetError(): %i (0x%.4x)\n", (int)error, (int)error);
LOGE("Failed to create EGL context at %s:%i\n", __FILE__, __LINE__);
exit(1);
}
}
示例11: gfx_ctx_set_video_mode
static bool gfx_ctx_set_video_mode(
unsigned width, unsigned height,
bool fullscreen)
{
if (g_inited)
return false;
int ret = 0;
struct drm_fb *fb = NULL;
struct sigaction sa = {{0}};
sa.sa_handler = sighandler;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
#define EGL_ATTRIBS_BASE \
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, \
EGL_RED_SIZE, 0, \
EGL_GREEN_SIZE, 0, \
EGL_BLUE_SIZE, 0, \
EGL_DEPTH_SIZE, 0, \
EGL_STENCIL_SIZE, 0
static const EGLint egl_attribs_gl[] = {
EGL_ATTRIBS_BASE,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_NONE,
};
static const EGLint egl_attribs_gles[] = {
EGL_ATTRIBS_BASE,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_NONE,
};
static const EGLint egl_attribs_vg[] = {
EGL_ATTRIBS_BASE,
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
EGL_NONE,
};
// GLES 2.0. Don't use for any other API.
static const EGLint gles_context_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
const EGLint *attrib_ptr;
switch (g_api)
{
case GFX_CTX_OPENGL_API:
attrib_ptr = egl_attribs_gl;
break;
case GFX_CTX_OPENGL_ES_API:
attrib_ptr = egl_attribs_gles;
break;
case GFX_CTX_OPENVG_API:
attrib_ptr = egl_attribs_vg;
break;
default:
attrib_ptr = NULL;
}
g_egl_dpy = eglGetDisplay((EGLNativeDisplayType)g_gbm_dev);
if (!g_egl_dpy)
{
RARCH_ERR("[KMS/EGL]: Couldn't get EGL display.\n");
goto error;
}
EGLint major, minor;
if (!eglInitialize(g_egl_dpy, &major, &minor))
goto error;
EGLint n;
if (!eglChooseConfig(g_egl_dpy, attrib_ptr, &g_config, 1, &n) || n != 1)
goto error;
g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, (g_api == GFX_CTX_OPENGL_ES_API) ? gles_context_attribs : NULL);
if (!g_egl_ctx)
goto error;
g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_config, (EGLNativeWindowType)g_gbm_surface, NULL);
if (!g_egl_surf)
goto error;
if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx))
goto error;
glClear(GL_COLOR_BUFFER_BIT);
eglSwapBuffers(g_egl_dpy, g_egl_surf);
g_bo = gbm_surface_lock_front_buffer(g_gbm_surface);
fb = drm_fb_get_from_bo(g_bo);
ret = drmModeSetCrtc(g_drm_fd, g_crtc_id, fb->fb_id, 0, 0, &g_connector_id, 1, g_drm_mode);
if (ret < 0)
goto error;
//.........这里部分代码省略.........
示例12: Windows
// Init the device
void Device::InitWindow(int width, int height)
{
this->width = width;
this->height = height;
Logger::Info("Device", "Init Windows (%d - %d)", width, height);
#ifdef WIN32
windowHandler = CreateWin("OpenGLES Window", (int) (width * WINDOW_SCALE), (int) (height * WINDOW_SCALE));
EGLint attribList[] =
{
EGL_RED_SIZE, 5,
EGL_GREEN_SIZE, 6,
EGL_BLUE_SIZE, 5,
EGL_ALPHA_SIZE, EGL_DONT_CARE,
EGL_DEPTH_SIZE, 8,
EGL_STENCIL_SIZE, EGL_DONT_CARE,
EGL_SAMPLE_BUFFERS, 0,
EGL_NONE
};
EGLint numConfigs;
EGLint majorVersion;
EGLint minorVersion;
EGLConfig config;
EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, EGL_NONE };
// Get Display
display = eglGetDisplay(GetDC(windowHandler));
if ( display == EGL_NO_DISPLAY )
{
Logger::Error("OpenGLESDevice", "Couldn't Get Display");
return;
}
// Initialize EGL
if ( !eglInitialize(display, &majorVersion, &minorVersion) )
{
Logger::Error("OpenGLESDevice", "Couldn't Initialize Display");
return;
}
// Get configs
if ( !eglGetConfigs(display, NULL, 0, &numConfigs) )
{
Logger::Error("OpenGLESDevice", "Couldn't Get Config");
return;
}
// Choose config
if ( !eglChooseConfig(display, attribList, &config, 1, &numConfigs) )
{
Logger::Error("OpenGLESDevice", "Couldn't Choose Config");
return;
}
// Create a surface
surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType) windowHandler, NULL);
if ( surface == EGL_NO_SURFACE )
{
Logger::Error("OpenGLESDevice", "Couldn't Create Window Surface");
return;
}
// Create a GL context
context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs );
if ( context == EGL_NO_CONTEXT )
{
Logger::Error("OpenGLESDevice", "Couldn't Get Context");
return;
}
// Make the context current
if ( !eglMakeCurrent(display, surface, surface, context) )
{
Logger::Error("OpenGLESDevice", "Couldn't Make Current Display");
return;
}
#endif // if WIN32
graphics = new Graphics(width, height);
}
示例13: LogError
bool AndroidWindow::CreateGLContext(unsigned int major, unsigned int minor)
{
EGLConfig config;
EGLint eglMajor;
EGLint eglMinor;
EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
if (!eglInitialize(mDisplay, &eglMajor, &eglMinor))
{
LogError("Unable to initialize EGL", 0);
return false;
}
EGLint numConfigs = 0;
EGLint attribList[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, (mParameters.ColorBits == 32) ? 8 : EGL_DONT_CARE,
EGL_DEPTH_SIZE, (mParameters.DepthBits > 0) ? mParameters.DepthBits : EGL_DONT_CARE,
EGL_STENCIL_SIZE, (mParameters.StencilBits > 0) ? mParameters.StencilBits : EGL_DONT_CARE,
EGL_SAMPLE_BUFFERS, (mParameters.MSAA > 0) ? mParameters.MSAA : 0,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_NONE
};
if (!eglChooseConfig(mDisplay, attribList, &config, 1, &numConfigs))
{
LogError("Unable to choose EGL Config", 0);
return false;
}
if (numConfigs < 1)
{
LogError("No valid EGL config found", 0);
return false;
}
EGLint format = 0;
eglGetConfigAttrib(mDisplay, config, EGL_NATIVE_VISUAL_ID, &format);
ANativeWindow_setBuffersGeometry(mNativeWindow, 0, 0, format);
mSurface = eglCreateWindowSurface(mDisplay, config,
mNativeWindow, NULL);
if (mSurface == EGL_NO_SURFACE)
{
LogError("Unable to create EGL window surface", 0);
return false;
}
mContext = eglCreateContext(mDisplay, config,
EGL_NO_CONTEXT, contextAttribs);
if (mContext == EGL_NO_CONTEXT)
{
LogError("Unable to create EGL context", 0);
return false;
}
if (!eglMakeCurrent(mDisplay, mSurface, mSurface, mContext))
{
LogError("Unable to make EGL context current", 0);
return false;
}
return true;
}
示例14: gfx_ctx_emscripten_init
static bool gfx_ctx_emscripten_init(void *data)
{
EGLint width, height, num_config;
static const EGLint attribute_list[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NONE
};
static const EGLint context_attributes[] =
{
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
(void)data;
RARCH_LOG("[EMSCRIPTEN/EGL]: Initializing...\n");
if (g_inited)
{
RARCH_LOG("[EMSCRIPTEN/EGL]: Attempted to re-initialize driver.\n");
return true;
}
/* Get an EGL display connection. */
g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (!g_egl_dpy)
goto error;
/* Initialize the EGL display connection. */
if (!eglInitialize(g_egl_dpy, NULL, NULL))
goto error;
/* Get an appropriate EGL frame buffer configuration. */
if (!eglChooseConfig(g_egl_dpy, attribute_list, &g_egl_config, 1, &num_config))
goto error;
/* Create an EGL rendering context. */
g_egl_ctx = eglCreateContext(g_egl_dpy, g_egl_config, EGL_NO_CONTEXT, context_attributes);
if (!g_egl_ctx)
goto error;
/* create an EGL window surface. */
g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, 0, NULL);
if (!g_egl_surf)
goto error;
/* Connect the context to the surface. */
if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx))
goto error;
eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_WIDTH, &width);
eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_HEIGHT, &height);
g_fb_width = width;
g_fb_height = height;
RARCH_LOG("[EMSCRIPTEN/EGL]: Dimensions: %ux%u\n", width, height);
return true;
error:
gfx_ctx_emscripten_destroy(data);
return false;
}
示例15: CompoScopedJNI
bool CompoGraphicsContext::init( void *surfacePtr )
{
JNIEnv *env;
JavaVM *vm = CompoBridge->getVM();
CompoScopedJNI(vm, &env);
ANativeWindow *window =
ANativeWindow_fromSurface(env, (jobject) surfacePtr);
LOGI("-- Initializing OpenGL Context --");
if ((mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY)
{
LOGE("eglGetDisplay returned error %d", eglGetError());
return false;
}
else {
LOGI("eglGetDisplay SUCCEDED [0x%X]", (unsigned) mDisplay);
}
const EGLint attributes [] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_DEPTH_SIZE, 16,
EGL_NONE
};
if (!eglInitialize(mDisplay, 0, 0)) {
LOGE("eglInitialze returned error %d", eglGetError());
return false;
}
EGLint numConfigs;
EGLint format;
if (!eglChooseConfig(mDisplay, attributes, &mConfig, 1, &numConfigs)) {
LOGE("eglChooseConfig() returned error %d", eglGetError());
this->destroy();
return false;
}
if (!eglGetConfigAttrib(mDisplay, mConfig, EGL_NATIVE_VISUAL_ID, &format))
{
LOGE("eglGetConfigAttrib returned error %d", eglGetError());
this->destroy();
return false;
}
ANativeWindow_setBuffersGeometry(window, 0, 0, format);
if ((mSurface = eglCreateWindowSurface(mDisplay, mConfig, window, 0))
== EGL_NO_SURFACE)
{
LOGE("eglCreateWindowSurface returned error %d", eglGetError());
this->destroy();
return false;
}
EGLint contextAttributes [] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
if ((mContext = eglCreateContext(mDisplay, mConfig, 0, contextAttributes))
== EGL_NO_CONTEXT)
{
LOGE("eglCreateContext returned error %d", eglGetError());
this->destroy();
return false;
}
else
{
LOGI("eglCreateContext create [0x%X]", (unsigned) mContext);
}
if (!eglMakeCurrent(mDisplay, mSurface, mSurface, mContext)) {
LOGE("eglMakeCurrent() returned error %d", eglGetError());
this->destroy();
return false;
}
EGLint width, height;
if (!eglQuerySurface(mDisplay, mSurface, EGL_WIDTH, &width) ||
!eglQuerySurface(mDisplay, mSurface, EGL_HEIGHT, &height)) {
LOGE("eglQuerySurface() returned error %d", eglGetError());
this->destroy();
return false;
}
else {
mWidth = width;
mHeight = height;
LOGI("Surface Initialized %dx%d", width, height);
}
glDisable(GL_DITHER);
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClearDepthf(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//.........这里部分代码省略.........