void imguiBeginFrame(int mx, int my, unsigned char mbut, int scroll) { updateInput(mx,my,mbut,scroll); g_state.hot = g_state.hotToBe; g_state.hotToBe = 0; g_state.wentActive = false; g_state.isActive = false; g_state.isHot = false; g_state.widgetX = 0; g_state.widgetY = 0; g_state.widgetW = 0; g_state.areaId = 1; g_state.widgetId = 1; resetGfxCmdQueue(); }
void RenderGLFlush(int width, int height) { const GfxCmd* q = g_gfxCmdQueue; int nq = g_gfxCmdQueueSize; const float s = 1.0f / 8.0f; glViewport(0, 0, width, height); glUseProgram(g_program); glUniform2f(g_programViewportLocation, (float)width, (float)height); glUniform1i(g_programTextureLocation, 0); glDisable(GL_SCISSOR_TEST); for (int i = 0; i < nq; ++i) { const GfxCmd& cmd = q[i]; if (cmd.type == GFXCMD_RECT) { if (cmd.rect.r == 0) { sDrawRect((float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f, (float)cmd.rect.w*s - 1, (float)cmd.rect.h*s - 1, 1.0f, cmd.col); } else { sDrawRoundedRect((float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f, (float)cmd.rect.w*s - 1, (float)cmd.rect.h*s - 1, (float)cmd.rect.r*s, 1.0f, cmd.col); } } else if (cmd.type == GFXCMD_LINE) { sRenderLine(cmd.line.x0*s, cmd.line.y0*s, cmd.line.x1*s, cmd.line.y1*s, cmd.line.r*s, 1.0f, cmd.col); } else if (cmd.type == GFXCMD_TRIANGLE) { if (cmd.flags == 1) { const float verts[3 * 2] = { (float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f, (float)cmd.rect.x*s + 0.5f + (float)cmd.rect.w*s - 1, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s / 2 - 0.5f, (float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s - 1, }; sDrawPolygon(verts, 3, 1.0f, cmd.col); } if (cmd.flags == 2) { const float verts[3 * 2] = { (float)cmd.rect.x*s + 0.5f, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s - 1, (float)cmd.rect.x*s + 0.5f + (float)cmd.rect.w*s / 2 - 0.5f, (float)cmd.rect.y*s + 0.5f, (float)cmd.rect.x*s + 0.5f + (float)cmd.rect.w*s - 1, (float)cmd.rect.y*s + 0.5f + (float)cmd.rect.h*s - 1, }; sDrawPolygon(verts, 3, 1.0f, cmd.col); } } else if (cmd.type == GFXCMD_TEXT) { sRenderString(cmd.text.x, cmd.text.y, cmd.text.text, cmd.text.align, cmd.col); } else if (cmd.type == GFXCMD_SCISSOR) { if (cmd.flags) { glEnable(GL_SCISSOR_TEST); glScissor(cmd.rect.x, cmd.rect.y, cmd.rect.w, cmd.rect.h); } else { glDisable(GL_SCISSOR_TEST); } } } glDisable(GL_SCISSOR_TEST); glUseProgram(0); resetGfxCmdQueue(); }