MCPcopy Index your code
hub / github.com/SpaiR/imgui-java / runFrame

Method runFrame

imgui-app/src/main/java/imgui/app/WindowSdl.java:121–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

runMethod · 0.95

Calls 15

newFrameMethod · 0.95
renderMethod · 0.95
getDrawDataMethod · 0.95
processEventMethod · 0.80
preProcessMethod · 0.80
postProcessMethod · 0.80
prepareDrawDataMethod · 0.80
getRedMethod · 0.80
getGreenMethod · 0.80
getBlueMethod · 0.80
processMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected