/*initalizes all needed objects for opencl OCLHandle - Datastructure containg the opencl objects */ bool SetupOpenCLEnvironment( OpenCLData * OCLHandle) { InitializePlatform(OCLHandle); InitializeDevice(OCLHandle); InitializeContext(OCLHandle); InitializeProgram(OCLHandle); InitializeKernels(OCLHandle); InitializeQueue(OCLHandle); return true; }
// Gameplay Screen Initialization logic void InitGameplayScreen(void) { // TODO: Initialize GAMEPLAY screen variables here! framesCounter = 0; finishScreen = 0; // MAP LAODING // TODO: Read .bmp file propierly in order to get image width & height Color *mapPixels = malloc(GRID_WIDTH*GRID_HEIGHT * sizeof(Color)); mapPixels = GetImageData(LoadImage("assets/gameplay_screen/maps/map.bmp")); maxTriangles = 0; maxPlatforms = 0; for (int i=0; i<GRID_WIDTH*GRID_HEIGHT; i++) { /* printf("r: %i\n", mapPixels[i].r); printf("g: %i\n", mapPixels[i].g); printf("b: %i\n\n", mapPixels[i].b); */ if (mapPixels[i].r == 255 && mapPixels[i].g == 0 && mapPixels[i].b == 0) maxTriangles++; else if (mapPixels[i].r == 0 && mapPixels[i].g == 255 && mapPixels[i].b == 0) maxPlatforms++; } triangles = malloc(maxTriangles * sizeof(TriangleObject)); platforms = malloc(maxPlatforms * sizeof(SquareObject)); int trianglesCounter=0; int platformsCounter=0; for (int y=0; y<GRID_HEIGHT; y++) { for (int x=0; x<GRID_WIDTH; x++) { if (mapPixels[y*GRID_WIDTH+x].r == 255 && mapPixels[y*GRID_WIDTH+x].g == 0 && mapPixels[y*GRID_WIDTH+x].b == 0) { InitializeTriangle(&triangles[trianglesCounter], (Vector2){x, y}); trianglesCounter++; } else if (mapPixels[y*GRID_WIDTH+x].r == 0 && mapPixels[y*GRID_WIDTH+x].g == 255 && mapPixels[y*GRID_WIDTH+x].b == 0) { InitializePlatform(&platforms[platformsCounter], (Vector2){x, y}); platformsCounter++; } } } free(mapPixels); //DEBUGGING && TESTING variables pause = FALSE; srand(time(NULL)); // Textures loading player.texture = LoadTexture("assets/gameplay_screen/cube_main.png"); triangleTexture = LoadTexture("assets/gameplay_screen/triangle_main.png"); platformTexture = LoadTexture("assets/gameplay_screen/platform_main.png"); player.pEmitter.texture = LoadTexture("assets/gameplay_screen/particle_main.png"); bg = LoadTexture("assets/gameplay_screen/bg_main.png"); // Sound loading InitAudioDevice(); PlayMusicStream("assets/gameplay_screen/music/Flash_Funk_MarshmelloRemix.ogg"); PauseMusicStream(); SetMusicVolume(0.5f); // Did player win? startGame = FALSE; /* player.texture = LoadTexture("assets/gameplay_screen/debug.png"); triangleTexture = LoadTexture("assets/gameplay_screen/debug.png"); platformTexture = LoadTexture("assets/gameplay_screen/debug.png"); player.pEmitter.texture = LoadTexture("assets/gameplay_screen/particle_main.png"); */ // Camera initialization mainCamera = (Camera2D){Vector2Right(), (Vector2){6.5f, 6.5f}, Vector2Zero(), TRUE}; // Gravity initialization gravity = (GravityForce){Vector2Up(), 1.5f}; // Ground position and coordinate groundCoordinadeY = GetScreenHeight()/CELL_SIZE-1; groundPositionY = GetOnGridPosition((Vector2){0, groundCoordinadeY}).y; // Player initialization InitializePlayer(&player, (Vector2){4, groundCoordinadeY-1}, (Vector2){0, 15}, 0.35f*GAME_SPEED); /* // Triangles initialization InitializeTriangle(&triangles[0], (Vector2){40, groundCoordinadeY-1}); InitializeTriangle(&triangles[1], (Vector2){50, groundCoordinadeY-1}); InitializeTriangle(&triangles[2], (Vector2){85, groundCoordinadeY-1}); // Platforms initialization InitializePlatform(&platforms[0], (Vector2){20, groundCoordinadeY-1}); InitializePlatform(&platforms[1], (Vector2){21, groundCoordinadeY-1}); InitializePlatform(&platforms[2], (Vector2){22, groundCoordinadeY-1}); InitializePlatform(&platforms[3], (Vector2){23, groundCoordinadeY-2}); InitializePlatform(&platforms[4], (Vector2){24, groundCoordinadeY-2}); */ }
void Initialize(bool* Continue, bool* Error) { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { *Continue = false; *Error = true; printf("SDL initialisation failed: %s\n", SDL_GetError()); SDL_ClearError(); return; } else printf("SDL initialisation succeeded\n"); Screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_HWSURFACE | #ifdef SDL_TRIPLEBUF SDL_TRIPLEBUF #else SDL_DOUBLEBUF #endif ); if (Screen == NULL) { *Continue = false; *Error = true; printf("SDL_SetVideoMode failed: %s\n", SDL_GetError()); SDL_ClearError(); return; } else printf("SDL_SetVideoMode succeeded\n"); SDL_ShowCursor(0); uint32_t i; for (i = 0; i < BG_LAYER_COUNT; i++) { BackgroundImages[i] = IMG_Load(BackgroundImageNames[i]); if (!CheckImage(Continue, Error, BackgroundImages[i], BackgroundImageNames[i])) return; if ((BackgroundImages[i] = ConvertSurface(Continue, Error, BackgroundImages[i], BackgroundImageNames[i])) == NULL) return; } CharacterFrames = IMG_Load("Bee.png"); if (!CheckImage(Continue, Error, CharacterFrames, "Bee.png")) return; if ((CharacterFrames = ConvertSurface(Continue, Error, CharacterFrames, "Bee.png")) == NULL) return; CollisionImage = IMG_Load("Crash.png"); if (!CheckImage(Continue, Error, CollisionImage, "Crash.png")) return; if ((CollisionImage = ConvertSurface(Continue, Error, CollisionImage, "Crash.png")) == NULL) return; ColumnImage = IMG_Load("Bamboo.png"); if (!CheckImage(Continue, Error, ColumnImage, "Bamboo.png")) return; if ((ColumnImage = ConvertSurface(Continue, Error, ColumnImage, "Bamboo.png")) == NULL) return; InitializePlatform(); // Title screen. (-> title.c) ToTitleScreen(); }
// Create rendering window. // Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize() bool cInterfaceEGL::Create(void *window_handle) { const char *s; EGLint egl_major, egl_minor; egl_dpy = OpenDisplay(); if (!egl_dpy) { INFO_LOG(VIDEO, "Error: eglGetDisplay() failed\n"); return false; } if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { INFO_LOG(VIDEO, "Error: eglInitialize() failed\n"); return false; } /* Detection code */ EGLConfig config; EGLint num_configs; DetectMode(); // attributes for a visual in RGBA format with at least // 8 bits per color int attribs[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_NONE }; EGLint ctx_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; switch (s_opengl_mode) { case MODE_OPENGL: attribs[1] = EGL_OPENGL_BIT; ctx_attribs[0] = EGL_NONE; break; case MODE_OPENGLES2: attribs[1] = EGL_OPENGL_ES2_BIT; ctx_attribs[1] = 2; break; case MODE_OPENGLES3: attribs[1] = (1 << 6); /* EGL_OPENGL_ES3_BIT_KHR */ ctx_attribs[1] = 3; break; default: ERROR_LOG(VIDEO, "Unknown opengl mode set\n"); return false; break; } if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n"); exit(1); } if (s_opengl_mode == MODE_OPENGL) eglBindAPI(EGL_OPENGL_API); else eglBindAPI(EGL_OPENGL_ES_API); EGLNativeWindowType host_window = (EGLNativeWindowType) window_handle; EGLNativeWindowType native_window = InitializePlatform(host_window, config); s = eglQueryString(egl_dpy, EGL_VERSION); INFO_LOG(VIDEO, "EGL_VERSION = %s\n", s); s = eglQueryString(egl_dpy, EGL_VENDOR); INFO_LOG(VIDEO, "EGL_VENDOR = %s\n", s); s = eglQueryString(egl_dpy, EGL_EXTENSIONS); INFO_LOG(VIDEO, "EGL_EXTENSIONS = %s\n", s); s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); INFO_LOG(VIDEO, "EGL_CLIENT_APIS = %s\n", s); egl_ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs ); if (!egl_ctx) { INFO_LOG(VIDEO, "Error: eglCreateContext failed\n"); exit(1); } egl_surf = eglCreateWindowSurface(egl_dpy, config, native_window, nullptr); if (!egl_surf) { INFO_LOG(VIDEO, "Error: eglCreateWindowSurface failed\n"); exit(1); } return true; }
/// \brief Constructor for the AcceleratorDevice class. /// \param logger The application logger. AcceleratorDevice::AcceleratorDevice(log4cpp::Category* logger) { logger_ = logger; InitializePlatform(); InitializeDevices(); InitializeContexts(); }
bool cInterfaceEGL::ChooseAndCreate(void *window_handle, bool core, bool use565) { int attribs32[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Keep this first! EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 16, EGL_STENCIL_SIZE, 8, EGL_TRANSPARENT_TYPE, EGL_NONE, EGL_NONE, 0 }; int attribs16[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Keep this first! EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6, EGL_BLUE_SIZE, 5, EGL_ALPHA_SIZE, 0, EGL_DEPTH_SIZE, 16, EGL_STENCIL_SIZE, 8, EGL_TRANSPARENT_TYPE, EGL_NONE, EGL_NONE, 0 }; int attribsFallback32[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Keep this first! EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 16, EGL_NONE, 0 }; int attribsFallback16[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Keep this first! EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6, EGL_BLUE_SIZE, 5, EGL_ALPHA_SIZE, 0, EGL_DEPTH_SIZE, 16, EGL_NONE, 0 }; int *attribs = attribs32; int *attribsFallback = attribsFallback32; if (use565) { attribs = attribs16; attribsFallback = attribsFallback16; } EGLint ctx_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, 0 }; switch (s_opengl_mode) { case MODE_OPENGL: EGL_ILOG("Setting RENDERABLE_TYPE to EGL_OPENGL_BIT"); attribs[1] = EGL_OPENGL_BIT; ctx_attribs[0] = EGL_NONE; break; case MODE_OPENGLES2: EGL_ILOG("Setting RENDERABLE_TYPE to EGL_OPENGL_ES2_BIT"); attribs[1] = EGL_OPENGL_ES2_BIT; ctx_attribs[1] = 2; break; case MODE_OPENGLES3: EGL_ILOG("Setting RENDERABLE_TYPE to EGL_OPENGL_ES3_BIT_KHR"); attribs[1] = (1 << 6); /* EGL_OPENGL_ES3_BIT_KHR */ ctx_attribs[1] = 3; break; default: EGL_ELOG("Unknown OpenGL mode set\n"); return false; break; } EGL_ILOG("Calling eglChooseConfig to get number of configs (use16bit=%d)...", (int)use565); EGLConfig *configs; EGLint num_configs; if (!eglChooseConfig(egl_dpy, attribs, NULL, 0, &num_configs) || num_configs == 0) { EGL_ILOG("Error: couldn't get a number of configs. Trying with fallback config (no stencil, not specifying transparent:none)\n"); attribsFallback[1] = attribs[1]; attribs = attribsFallback; if (!eglChooseConfig(egl_dpy, attribs, NULL, 0, &num_configs) || num_configs == 0) { eglTerminate(egl_dpy); return false; } } EGL_ILOG("Got %d configs. Now choosing...", num_configs); configs = new EGLConfig[num_configs]; if (!eglChooseConfig(egl_dpy, attribs, configs, num_configs, &num_configs)) { EGL_ELOG("Error: couldn't get an EGL visual config (num_configs=%d)! Terminating EGL.\n", num_configs); eglTerminate(egl_dpy); return false; } int chosenConfig = -1; // Find our ideal config in the list. If it's there, use it, otherwise pick whatever the device wanted (#0) int wantedAlpha = 8; // Requiring alpha seems to be a problem on older devices. Let's see if this helps... if (attribs[1] == EGL_OPENGL_ES2_BIT) wantedAlpha = 0; for (int i = 0; i < num_configs; i++) { EGL_ILOG("Config %d:", i); LogEGLConfig(egl_dpy, configs[i]); int red, green, blue, alpha, depth, stencil; eglGetConfigAttrib(egl_dpy, configs[i], EGL_RED_SIZE, &red); eglGetConfigAttrib(egl_dpy, configs[i], EGL_GREEN_SIZE, &green); eglGetConfigAttrib(egl_dpy, configs[i], EGL_BLUE_SIZE, &blue); eglGetConfigAttrib(egl_dpy, configs[i], EGL_ALPHA_SIZE, &alpha); eglGetConfigAttrib(egl_dpy, configs[i], EGL_DEPTH_SIZE, &depth); eglGetConfigAttrib(egl_dpy, configs[i], EGL_STENCIL_SIZE, &stencil); if (chosenConfig == -1 && red == 8 && green == 8 && blue == 8 && alpha == wantedAlpha && depth == 24 && stencil == 8) { chosenConfig = i; } } if (chosenConfig == -1) chosenConfig = 0; EGL_ILOG("eglChooseConfig successful: num_configs=%d, choosing config %d", num_configs, chosenConfig); if (s_opengl_mode == MODE_OPENGL) { EGL_ILOG("eglBindAPI(OPENGL)"); eglBindAPI(EGL_OPENGL_API); } else { EGL_ILOG("eglBindAPI(OPENGL_ES)"); eglBindAPI(EGL_OPENGL_ES_API); } EGLNativeWindowType host_window = (EGLNativeWindowType)window_handle; EGLNativeWindowType native_window = InitializePlatform(host_window, configs[chosenConfig]); const char *s = eglQueryString(egl_dpy, EGL_VERSION); EGL_ILOG("EGL_VERSION = %s\n", s); s = eglQueryString(egl_dpy, EGL_VENDOR); EGL_ILOG("EGL_VENDOR = %s\n", s); s = eglQueryString(egl_dpy, EGL_EXTENSIONS); EGL_ILOG("EGL_EXTENSIONS = %s\n", s); s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); EGL_ILOG("EGL_CLIENT_APIS = %s\n", s); egl_ctx = eglCreateContext(egl_dpy, configs[chosenConfig], EGL_NO_CONTEXT, ctx_attribs); if (!egl_ctx) { EGL_ILOG("Error: eglCreateContext failed: %s\n", EGLGetErrorString(eglGetError())); delete[] configs; return false; } EGL_ILOG("Successfully created EGL context.\n"); egl_surf = eglCreateWindowSurface(egl_dpy, configs[chosenConfig], native_window, nullptr); if (!egl_surf) { EGL_ILOG("Error: eglCreateWindowSurface failed: native_window=%p error=%s ctx_attribs[1]==%d\n", native_window, EGLGetErrorString(eglGetError()), ctx_attribs[1]); eglDestroyContext(egl_dpy, egl_ctx); delete[] configs; return false; } EGL_ILOG("Successfully created EGL window surface (window=%p).\n", native_window); delete[] configs; return true; }
EFI_STATUS EFIAPI PlatformEarlyInitEntry ( IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices ) { EFI_STATUS Status; SYSTEM_CONFIGURATION SystemConfiguration; EFI_PLATFORM_INFO_HOB *PlatformInfo; EFI_PEI_HOB_POINTERS Hob; EFI_PLATFORM_CPU_INFO PlatformCpuInfo; // // Initialize SmbusPolicy PPI // Status = (*PeiServices)->InstallPpi(PeiServices, &mInstallSmbusPolicyPpi); ASSERT_EFI_ERROR (Status); // // Initialize Stall PPIs // Status = (*PeiServices)->InstallPpi (PeiServices, &mInstallStallPpi); ASSERT_EFI_ERROR (Status); // // Initialize platform PPIs // Status = (*PeiServices)->InstallPpi (PeiServices, &mInstallSpeakerInterfacePpi); ASSERT_EFI_ERROR (Status); // // Variable initialization // ZeroMem(&PlatformCpuInfo, sizeof(EFI_PLATFORM_CPU_INFO)); // // Set the some PCI and chipset range as UC // And align to 1M at leaset // Hob.Raw = GetFirstGuidHob (&gEfiPlatformInfoGuid); ASSERT (Hob.Raw != NULL); PlatformInfo = GET_GUID_HOB_DATA(Hob.Raw); // // Initialize PlatformInfo HOB // MultiPlatformInfoInit(PeiServices, PlatformInfo); // // Do basic MCH init // MchInit (PeiServices); // // Set the new boot mode // Status = UpdateBootMode (PeiServices, PlatformInfo); ASSERT_EFI_ERROR (Status); SetPlatformBootMode (PeiServices, PlatformInfo); // // Get setup variable. This can only be done after BootMode is updated // GetSetupVariable (PeiServices, &SystemConfiguration); CheckOsSelection(PeiServices, &SystemConfiguration); // // Update PlatformInfo HOB according to setup variable // PlatformInfoUpdate(PeiServices, PlatformInfo, &SystemConfiguration); InitializePlatform (PeiServices, PlatformInfo, &SystemConfiguration); // // Initialize VlvPolicy PPI // Status = VlvPolicyInit (PeiServices, &SystemConfiguration); ASSERT_EFI_ERROR (Status); // // Soc specific GPIO setting // ConfigureSoCGpio(&SystemConfiguration); // // Baylake Board specific. // if (PlatformInfo->BoardId == BOARD_ID_BL_RVP || PlatformInfo->BoardId == BOARD_ID_BL_FFRD || PlatformInfo->BoardId == BOARD_ID_BL_FFRD8 || PlatformInfo->BoardId == BOARD_ID_BL_RVP_DDR3L || PlatformInfo->BoardId == BOARD_ID_BL_STHI || PlatformInfo->BoardId == BOARD_ID_BB_RVP || PlatformInfo->BoardId == BOARD_ID_BS_RVP || PlatformInfo->BoardId == BOARD_ID_MINNOW2 || PlatformInfo->BoardId == BOARD_ID_MINNOW2_TURBOT|| PlatformInfo->BoardId == BOARD_ID_CVH) { ConfigureLpssAndSccGpio(&SystemConfiguration, PlatformInfo); } // // Configure LPE // Alpine Valley and Bayley Bay board specific // ConfigureLpeGpio(&SystemConfiguration); // // Bayley Bay Board specific. // ConfigureSciSmiGpioRout(PlatformInfo); if (SystemConfiguration.LpssI2C3Enabled == 1) { ConfigureMipiCsi(); } // // Do basic CPU init // Status = PlatformCpuInit (PeiServices, &SystemConfiguration, &PlatformCpuInfo); // // Perform basic SSA related platform initialization // PlatformSsaInit (&SystemConfiguration,PeiServices); // // Do basic PCH init // Status = PlatformPchInit (&SystemConfiguration, PeiServices, PlatformInfo->PlatformType); ASSERT_EFI_ERROR (Status); // // Initialize platform PPIs // Status = (*PeiServices)->InstallPpi (PeiServices, &mPpiList[0]); ASSERT_EFI_ERROR (Status); if (PlatformInfo->BoardId != BOARD_ID_CVH) { InstallPlatformClocksNotify (PeiServices); InstallPlatformSysCtrlGPIONotify(PeiServices); } // // Initialize platform PPIs // Status = (*PeiServices)->NotifyPpi(PeiServices, &mNotifyList[0]); ASSERT_EFI_ERROR (Status); // // Initialize Measured Boot // Status = MeasuredBootInit (PeiServices, &SystemConfiguration); ASSERT_EFI_ERROR (Status); return Status; }
// Create rendering window. bool cInterfaceEGL::Create(void *window_handle, bool core, bool use16bit) { const char *s; EGLint egl_major, egl_minor; egl_dpy = OpenDisplay(); if (!egl_dpy) { INFO_LOG(G3D, "Error: eglGetDisplay() failed\n"); return false; } if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { INFO_LOG(G3D, "Error: eglInitialize() failed\n"); return false; } INFO_LOG(G3D, "eglInitialize() succeeded\n"); if (s_opengl_mode == MODE_DETECT || s_opengl_mode == MODE_DETECT_ES) DetectMode(); int attribs32[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Keep this first! EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 16, EGL_STENCIL_SIZE, 8, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_TRANSPARENT_TYPE, EGL_NONE, EGL_SAMPLES, 0, EGL_NONE, 0 }; int attribs16[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, // Keep this first! EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6, EGL_BLUE_SIZE, 5, EGL_ALPHA_SIZE, 0, EGL_DEPTH_SIZE, 16, EGL_STENCIL_SIZE, 8, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_TRANSPARENT_TYPE, EGL_NONE, EGL_SAMPLES, 0, EGL_NONE, 0 }; int *attribs = attribs32; if (use16bit) { attribs = attribs16; } EGLint ctx_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE, 0 }; switch (s_opengl_mode) { case MODE_OPENGL: attribs[1] = EGL_OPENGL_BIT; ctx_attribs[0] = EGL_NONE; break; case MODE_OPENGLES2: attribs[1] = EGL_OPENGL_ES2_BIT; ctx_attribs[1] = 2; break; case MODE_OPENGLES3: attribs[1] = (1 << 6); /* EGL_OPENGL_ES3_BIT_KHR */ ctx_attribs[1] = 3; break; default: ERROR_LOG(G3D, "Unknown OpenGL mode set\n"); return false; break; } EGLConfig *configs; EGLint num_configs; if (!eglChooseConfig(egl_dpy, attribs, NULL, 0, &num_configs) || num_configs == 0) { INFO_LOG(G3D, "Error: couldn't get a number of configs\n"); eglTerminate(egl_dpy); return false; } configs = new EGLConfig[num_configs]; if (!eglChooseConfig(egl_dpy, attribs, configs, num_configs, &num_configs)) { INFO_LOG(G3D, "Error: couldn't get an EGL visual config\n"); eglTerminate(egl_dpy); return false; } INFO_LOG(G3D, "eglChooseConfig successful: num_configs=%d, choosing config 0", num_configs); for (int i = 0; i < num_configs; i++) { INFO_LOG(G3D, "Config %d:", i); LogEGLConfig(egl_dpy, configs[i]); } if (s_opengl_mode == MODE_OPENGL) eglBindAPI(EGL_OPENGL_API); else eglBindAPI(EGL_OPENGL_ES_API); EGLNativeWindowType host_window = (EGLNativeWindowType) window_handle; EGLNativeWindowType native_window = InitializePlatform(host_window, configs[0]); s = eglQueryString(egl_dpy, EGL_VERSION); INFO_LOG(G3D, "EGL_VERSION = %s\n", s); s = eglQueryString(egl_dpy, EGL_VENDOR); INFO_LOG(G3D, "EGL_VENDOR = %s\n", s); s = eglQueryString(egl_dpy, EGL_EXTENSIONS); INFO_LOG(G3D, "EGL_EXTENSIONS = %s\n", s); s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); INFO_LOG(G3D, "EGL_CLIENT_APIS = %s\n", s); egl_ctx = eglCreateContext(egl_dpy, configs[0], EGL_NO_CONTEXT, ctx_attribs); if (!egl_ctx) { INFO_LOG(G3D, "Error: eglCreateContext failed: %s\n", EGLGetErrorString(eglGetError())); eglTerminate(egl_dpy); delete[] configs; return false; } egl_surf = eglCreateWindowSurface(egl_dpy, configs[0], native_window, nullptr); if (!egl_surf) { INFO_LOG(G3D, "Error: eglCreateWindowSurface failed: native_window=%p error=%s ctx_attribs[1]==%d\n", native_window, EGLGetErrorString(eglGetError()), ctx_attribs[1]); eglDestroyContext(egl_dpy, egl_ctx); eglTerminate(egl_dpy); delete[] configs; return false; } delete[] configs; return true; }