native_gfx_t * native_gfx_open_display(void) { native_gfx_t *gfx; gfx = malloc(sizeof (*gfx)); if (gfx == NULL) { fprintf(stderr, "native_gfx_open_display(): Can't allocate memory: error %i: %s\n", errno, strerror(errno)); exit(EXIT_FAILURE); } memset(gfx, 0, sizeof (*gfx)); gfx->disp = fbGetDisplay(NULL); if (gfx->disp == NULL) { fprintf(stderr, "ERROR: native_gfx_open_display(): " "fbGetDisplay() returned NULL\n"); exit(EXIT_FAILURE); } fbGetDisplayGeometry(gfx->disp, &gfx->disp_width, &gfx->disp_height); return (gfx); }
int call_fbGetDisplay(int *pDatabuf) { str_fbGetDisplay *function; EGLNativeDisplayType native; void *context = NULL; unsigned int context_front = 0; int ret; function = (str_fbGetDisplay *)pDatabuf; context_front = *((int*)(function->context)); if(context_front == 0x0) context = NULL; else context = function->context; native = fbGetDisplay(context); function->retVal = native; if(function->hd.retFlag == RT_REQUEST){ function->hd.retFlag = RT_RESPONSE; ret = write(dev, function, MAX_BUF_SIZE); } return 0; }
//-------------------------------------------------------------------------------------- // Name: GLInit () // Desc: Initializate the EGL functions //-------------------------------------------------------------------------------------- bool GLCVUtils::GLInit (void) { static const EGLint s_configAttribs[] = { EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6, EGL_BLUE_SIZE, 5, EGL_ALPHA_SIZE, EGL_DONT_CARE, EGL_SAMPLES, 0, EGL_DEPTH_SIZE, 24, EGL_NONE }; EGLint numconfigs; EGLint ContextAttribList[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; // Initialize Display - Get the default display. egldisplay = eglGetDisplay (EGL_DEFAULT_DISPLAY); eglInitialize (egldisplay, NULL, NULL); assert (eglGetError () == EGL_SUCCESS); //Initialize EGL. eglInitialize(egldisplay, NULL, NULL); assert (eglGetError () == EGL_SUCCESS); // EGL Surface Config eglChooseConfig (egldisplay, s_configAttribs, &eglconfig, 1, &numconfigs); assert (eglGetError () == EGL_SUCCESS); assert (numconfigs == 1); //You must pass in the file system handle to the linux framebuffer when creating a window EGLNativeDisplayType native_display = fbGetDisplay(); EGLNativeWindowType native_window = fbCreateWindow(native_display, 0, 1, 1024, 768); eglsurface = eglCreateWindowSurface (egldisplay, eglconfig, native_window, NULL); assert (eglGetError () == EGL_SUCCESS); eglBindAPI (EGL_OPENGL_ES_API); // Create the EGL graphic Context EGLContext eglcontext = eglCreateContext (egldisplay, eglconfig, EGL_NO_CONTEXT, ContextAttribList); assert (eglGetError() == EGL_SUCCESS); eglMakeCurrent (egldisplay, eglsurface, eglsurface, eglcontext); assert (eglGetError() == EGL_SUCCESS); // clear buffer to the black color glClearColor (0.0, 0.0, 0.0, 0.0); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); assert (eglGetError() == EGL_SUCCESS); // Swap Buffers. // Brings to the native display the current render surface. eglSwapBuffers (egldisplay, eglsurface); assert (eglGetError () == EGL_SUCCESS); return true; }
//! create the driver void CIrrDeviceFB::createDriver() { switch(CreationParams.DriverType) { case video::EDT_SOFTWARE: #ifdef _IRR_COMPILE_WITH_SOFTWARE_ VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); #else os::Printer::log("No Software driver support compiled in.", ELL_WARNING); #endif break; case video::EDT_BURNINGSVIDEO: #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this); #else os::Printer::log("Burning's video driver was not compiled in.", ELL_WARNING); #endif break; case video::EDT_OGLES2: #ifdef _IRR_COMPILE_WITH_OGLES2_ { video::SExposedVideoData data; s32 width = 0; s32 height = 0; NativeDisplayType display = fbGetDisplay(0); fbGetDisplayGeometry(display, &width, &height); data.OpenGLFB.Window = (void*)fbCreateWindow(display, 0, 0, width, height); ContextManager = new video::CEGLManager(); ContextManager->initialize(CreationParams, data); VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager); } #else os::Printer::log("No OpenGL-ES2 support compiled in.", ELL_ERROR); #endif break; case video::EDT_OGLES1: case video::EDT_OPENGL: case video::EDT_DIRECT3D8: case video::EDT_DIRECT3D9: os::Printer::log("This driver is not available in FB. Try Software renderer.", ELL_WARNING); break; default: VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize); break; } }