()
| 119 | } |
| 120 | |
| 121 | @Override |
| 122 | protected void runFrame() { |
| 123 | // Pump events |
| 124 | try (SDL_Event event = SDL_Event.calloc()) { |
| 125 | while (SDL_PollEvent(event)) { |
| 126 | final int type = event.type(); |
| 127 | imGuiSdl3.processEvent(event.address()); |
| 128 | if (type == SDL_EVENT_QUIT || type == SDL_EVENT_WINDOW_CLOSE_REQUESTED) { |
| 129 | shouldClose = true; |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | // Begin a Dear ImGui frame |
| 135 | imGuiSdlGpu3.newFrame(); |
| 136 | imGuiSdl3.newFrame(); |
| 137 | ImGui.newFrame(); |
| 138 | |
| 139 | owner.preProcess(); |
| 140 | owner.process(); |
| 141 | owner.postProcess(); |
| 142 | |
| 143 | ImGui.render(); |
| 144 | |
| 145 | final long commandBuffer = SDL_AcquireGPUCommandBuffer(gpuDevice); |
| 146 | if (commandBuffer != 0L) { |
| 147 | imGuiSdlGpu3.prepareDrawData(ImGui.getDrawData().ptr, commandBuffer); |
| 148 | |
| 149 | try (MemoryStack stack = MemoryStack.stackPush()) { |
| 150 | final PointerBuffer pSwapchain = stack.callocPointer(1); |
| 151 | final IntBuffer pW = stack.mallocInt(1); |
| 152 | final IntBuffer pH = stack.mallocInt(1); |
| 153 | final boolean acquired = SDL_WaitAndAcquireGPUSwapchainTexture(commandBuffer, handle, pSwapchain, pW, pH); |
| 154 | final long swapchainTexture = pSwapchain.get(0); |
| 155 | if (acquired && swapchainTexture != 0L) { |
| 156 | final SDL_GPUColorTargetInfo.Buffer colorTargets = SDL_GPUColorTargetInfo.calloc(1, stack); |
| 157 | final SDL_GPUColorTargetInfo target = colorTargets.get(0); |
| 158 | target.texture(swapchainTexture); |
| 159 | target.load_op(SDL_GPU_LOADOP_CLEAR); |
| 160 | target.store_op(SDL_GPU_STOREOP_STORE); |
| 161 | target.clear_color().set(colorBg.getRed(), colorBg.getGreen(), colorBg.getBlue(), colorBg.getAlpha()); |
| 162 | |
| 163 | final long renderPass = SDL_BeginGPURenderPass(commandBuffer, colorTargets, null); |
| 164 | if (renderPass != 0L) { |
| 165 | imGuiSdlGpu3.renderDrawData(ImGui.getDrawData().ptr, commandBuffer, renderPass); |
| 166 | SDL_EndGPURenderPass(renderPass); |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | SDL_SubmitGPUCommandBuffer(commandBuffer); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * @return native {@code SDL_Window*} handle |
no test coverage detected