int init(){ if(setupGamepad() == -1){ printf("Error setting up gamepad\n"); return -1; } if(setupFrameBuffer() == -1){ printf("Error setting up framebuffer\n"); return -1; } return 0; }
void UWKRendererGL::InitInternal() { if (!glewInitialized_) { glewExperimental = GL_TRUE; glewInit(); glGetError(); // Clean up error generated by glewInit glewInitialized_ = true; } glPushAttrib(GL_ALL_ATTRIB_BITS); glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); glActiveTexture(GL_TEXTURE0); CGLContextObj cgl_ctx = CGLGetCurrentContext(); if (!setupFrameBuffer()) { glPopClientAttrib(); glPopAttrib(); return; } glGenTextures(1, &surfaceTextureID_); glEnable(GL_TEXTURE_RECTANGLE_ARB); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, surfaceTextureID_); glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST); CGLTexImageIOSurface2D(cgl_ctx, GL_TEXTURE_RECTANGLE_ARB, GL_RGBA, maxWidth_, maxHeight_, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,surfaceRef_, 0); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); glDisable(GL_TEXTURE_RECTANGLE_ARB); glPopClientAttrib(); glPopAttrib(); if (glCore_) InitInternalGLCore(); // mark as valid valid_ = true; }
void VulkanBase::prepare() { if (enableValidation) vkDebug::setupDebugging(instance, VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT, NULL); createCommandPool(); createSetupCommandBuffer(); setupSwapChain(); createCommandBuffers(); setupDepthStencil(); setupRenderPass(); createPipelineCache(); setupFrameBuffer(); flushSetupCommandBuffer(); // Recreate setup command buffer for derived class createSetupCommandBuffer(); // Create a simple texture loader class textureLoader = new vkTools::VulkanTextureLoader(physicalDevice, device, queue, cmdPool); }
void VulkanExampleBase::windowResize() { if (!prepared) { return; } prepared = false; // Recreate swap chain width = destWidth; height = destHeight; createSetupCommandBuffer(); setupSwapChain(); // Recreate the frame buffers vkDestroyImageView(device, depthStencil.view, nullptr); vkDestroyImage(device, depthStencil.image, nullptr); vkFreeMemory(device, depthStencil.mem, nullptr); setupDepthStencil(); for (uint32_t i = 0; i < frameBuffers.size(); i++) { vkDestroyFramebuffer(device, frameBuffers[i], nullptr); } setupFrameBuffer(); flushSetupCommandBuffer(); // Command buffers need to be recreated as they may store // references to the recreated frame buffer destroyCommandBuffers(); createCommandBuffers(); buildCommandBuffers(); vkQueueWaitIdle(queue); vkDeviceWaitIdle(device); // Notify derived class windowResized(); viewChanged(); prepared = true; }