trunk/3rdparty/bgfx/examples/08-update/update.cpp
r244964 | r244965 | |
149 | 149 | loadTexture("texture_compression_ptc24.pvr"), |
150 | 150 | }; |
151 | 151 | |
| 152 | const bgfx::Memory* mem8 = bgfx::alloc(32*32*32); |
| 153 | const bgfx::Memory* mem16f = bgfx::alloc(32*32*32*2); |
| 154 | const bgfx::Memory* mem32f = bgfx::alloc(32*32*32*4); |
| 155 | for (uint8_t zz = 0; zz < 32; ++zz) |
| 156 | { |
| 157 | for (uint8_t yy = 0; yy < 32; ++yy) |
| 158 | { |
| 159 | for (uint8_t xx = 0; xx < 32; ++xx) |
| 160 | { |
| 161 | const uint32_t offset = ( (zz*32+yy)*32+xx); |
| 162 | const uint32_t val = xx ^ yy ^ zz; |
| 163 | mem8->data[offset] = val<<3; |
| 164 | *(uint16_t*)&mem16f->data[offset*2] = bx::halfFromFloat( (float)val/32.0f); |
| 165 | *(float*)&mem32f->data[offset*4] = (float)val/32.0f; |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | bgfx::TextureHandle textures3d[] = |
| 171 | { |
| 172 | bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R8, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem8), |
| 173 | bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R16F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem16f), |
| 174 | bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R32F, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem32f), |
| 175 | }; |
| 176 | |
152 | 177 | // Create static vertex buffer. |
153 | 178 | bgfx::VertexBufferHandle vbh = bgfx::createVertexBuffer(bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ), PosTexcoordVertex::ms_decl); |
154 | 179 | |
r244964 | r244965 | |
156 | 181 | bgfx::IndexBufferHandle ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) ); |
157 | 182 | |
158 | 183 | // Create texture sampler uniforms. |
159 | | bgfx::UniformHandle u_texCube = bgfx::createUniform("u_texCube", bgfx::UniformType::Uniform1iv); |
160 | | |
| 184 | bgfx::UniformHandle u_texCube = bgfx::createUniform("u_texCube", bgfx::UniformType::Uniform1iv); |
161 | 185 | bgfx::UniformHandle u_texColor = bgfx::createUniform("u_texColor", bgfx::UniformType::Uniform1iv); |
162 | 186 | |
163 | | bgfx::ProgramHandle program = loadProgram("vs_update", "fs_update"); |
164 | | bgfx::ProgramHandle programCmp = loadProgram("vs_update", "fs_update_cmp"); |
| 187 | bgfx::UniformHandle u_time = bgfx::createUniform("u_time", bgfx::UniformType::Uniform1f); |
165 | 188 | |
| 189 | bgfx::ProgramHandle program = loadProgram("vs_update", "fs_update"); |
| 190 | bgfx::ProgramHandle programCmp = loadProgram("vs_update", "fs_update_cmp"); |
| 191 | bgfx::ProgramHandle program3d = loadProgram("vs_update", "fs_update_3d"); |
| 192 | |
166 | 193 | const uint32_t textureSide = 2048; |
167 | 194 | |
168 | 195 | bgfx::TextureHandle textureCube = bgfx::createTextureCube(textureSide, 1 |
r244964 | r244965 | |
210 | 237 | const int64_t freq = bx::getHPFrequency(); |
211 | 238 | const double toMs = 1000.0/double(freq); |
212 | 239 | float time = (float)( (now - timeOffset)/double(bx::getHPFrequency() ) ); |
| 240 | bgfx::setUniform(u_time, &time); |
213 | 241 | |
214 | 242 | // Use debug font to print information about this example. |
215 | 243 | bgfx::dbgTextClear(); |
r244964 | r244965 | |
345 | 373 | // Submit primitive for rendering to view 1. |
346 | 374 | bgfx::submit(1); |
347 | 375 | |
| 376 | const float xpos = -8.0f - BX_COUNTOF(textures)*0.1f*0.5f; |
348 | 377 | |
349 | 378 | for (uint32_t ii = 0; ii < BX_COUNTOF(textures); ++ii) |
350 | 379 | { |
351 | | bx::mtxTranslate(mtx, -8.0f - BX_COUNTOF(textures)*0.1f*0.5f + ii*2.1f, 4.0f, 0.0f); |
| 380 | bx::mtxTranslate(mtx, xpos + ii*2.1f, 4.0f, 0.0f); |
352 | 381 | |
353 | 382 | // Set model matrix for rendering. |
354 | 383 | bgfx::setTransform(mtx); |
r244964 | r244965 | |
370 | 399 | bgfx::submit(1); |
371 | 400 | } |
372 | 401 | |
| 402 | for (uint32_t ii = 0; ii < BX_COUNTOF(textures3d); ++ii) |
| 403 | { |
| 404 | bx::mtxTranslate(mtx, xpos + ii*2.1f, -4.0f, 0.0f); |
| 405 | |
| 406 | // Set model matrix for rendering. |
| 407 | bgfx::setTransform(mtx); |
| 408 | |
| 409 | // Set vertex and fragment shaders. |
| 410 | bgfx::setProgram(program3d); |
| 411 | |
| 412 | // Set vertex and index buffer. |
| 413 | bgfx::setVertexBuffer(vbh); |
| 414 | bgfx::setIndexBuffer(ibh, 0, 6); |
| 415 | |
| 416 | // Bind texture. |
| 417 | bgfx::setTexture(0, u_texColor, textures3d[ii]); |
| 418 | |
| 419 | // Set render states. |
| 420 | bgfx::setState(BGFX_STATE_DEFAULT); |
| 421 | |
| 422 | // Submit primitive for rendering to view 1. |
| 423 | bgfx::submit(1); |
| 424 | } |
| 425 | |
373 | 426 | for (uint32_t ii = 0; ii < 3; ++ii) |
374 | 427 | { |
375 | | bx::mtxTranslate(mtx, -8.0f - BX_COUNTOF(textures)*0.1f*0.5f + 8*2.1f, -4.0f + ii*2.1f, 0.0f); |
| 428 | bx::mtxTranslate(mtx, xpos + 8*2.1f, -4.0f + ii*2.1f, 0.0f); |
376 | 429 | |
377 | 430 | // Set model matrix for rendering. |
378 | 431 | bgfx::setTransform(mtx); |
r244964 | r244965 | |
412 | 465 | bgfx::destroyTexture(textures[ii]); |
413 | 466 | } |
414 | 467 | |
| 468 | for (uint32_t ii = 0; ii < BX_COUNTOF(textures3d); ++ii) |
| 469 | { |
| 470 | bgfx::destroyTexture(textures3d[ii]); |
| 471 | } |
| 472 | |
415 | 473 | bgfx::destroyTexture(texture2d); |
416 | 474 | bgfx::destroyTexture(textureCube); |
417 | 475 | bgfx::destroyIndexBuffer(ibh); |
418 | 476 | bgfx::destroyVertexBuffer(vbh); |
| 477 | bgfx::destroyProgram(program3d); |
419 | 478 | bgfx::destroyProgram(programCmp); |
420 | 479 | bgfx::destroyProgram(program); |
| 480 | bgfx::destroyUniform(u_time); |
421 | 481 | bgfx::destroyUniform(u_texColor); |
422 | 482 | bgfx::destroyUniform(u_texCube); |
423 | 483 | |
trunk/3rdparty/bgfx/examples/common/imgui/imgui.cpp
r244964 | r244965 | |
388 | 388 | , m_halfTexel(0.0f) |
389 | 389 | , m_nvg(NULL) |
390 | 390 | , m_view(255) |
| 391 | , m_surfaceWidth(0) |
| 392 | , m_surfaceHeight(0) |
391 | 393 | , m_viewWidth(0) |
392 | 394 | , m_viewHeight(0) |
393 | 395 | , m_currentFontIdx(0) |
r244964 | r244965 | |
810 | 812 | m_char = _inputChar; |
811 | 813 | } |
812 | 814 | |
813 | | void beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, char _inputChar, uint8_t _view) |
| 815 | void beginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, uint16_t _surfaceWidth, uint16_t _surfaceHeight, char _inputChar, uint8_t _view) |
814 | 816 | { |
815 | | IMGUI_beginFrame(_mx, _my, _button, _width, _height, _inputChar, _view); |
816 | | nvgViewId(m_nvg, _view); |
817 | | |
818 | 817 | m_view = _view; |
819 | 818 | m_viewWidth = _width; |
820 | 819 | m_viewHeight = _height; |
| 820 | m_surfaceWidth = _surfaceWidth; |
| 821 | m_surfaceHeight = _surfaceHeight; |
| 822 | |
| 823 | const float xscale = float(m_surfaceWidth) /float(m_viewWidth); |
| 824 | const float yscale = float(m_surfaceHeight)/float(m_viewHeight); |
| 825 | const int32_t mx = int32_t(float(_mx)*xscale); |
| 826 | const int32_t my = int32_t(float(_my)*yscale); |
| 827 | |
| 828 | IMGUI_beginFrame(mx, my, _button, _width, _height, _inputChar, _view); |
| 829 | nvgBeginFrameScaled(m_nvg, m_viewWidth, m_viewHeight, m_surfaceWidth, m_surfaceHeight, 1.0f); |
| 830 | nvgViewId(m_nvg, _view); |
| 831 | |
821 | 832 | bgfx::setViewName(_view, "IMGUI"); |
822 | 833 | bgfx::setViewSeq(_view, true); |
823 | 834 | |
824 | 835 | const bgfx::HMD* hmd = bgfx::getHMD(); |
825 | 836 | if (NULL != hmd) |
826 | 837 | { |
827 | | m_viewWidth = _width / 2; |
| 838 | m_viewWidth = _width / 2; |
| 839 | m_surfaceWidth = _surfaceWidth / 2; |
828 | 840 | |
829 | 841 | float proj[16]; |
830 | 842 | bx::mtxProj(proj, hmd->eye[0].fov, 0.1f, 100.0f); |
r244964 | r244965 | |
837 | 849 | const float offset1 = -proj[8] + (hmd->eye[1].viewOffset[0] / dist * proj[0]); |
838 | 850 | |
839 | 851 | float ortho[2][16]; |
840 | | const float viewOffset = _width/4.0f; |
841 | | const float viewWidth = _width/2.0f; |
842 | | bx::mtxOrtho(ortho[0], viewOffset, viewOffset + viewWidth, (float)m_viewHeight, 0.0f, 0.0f, 1000.0f, offset0); |
843 | | bx::mtxOrtho(ortho[1], viewOffset, viewOffset + viewWidth, (float)m_viewHeight, 0.0f, 0.0f, 1000.0f, offset1); |
| 852 | const float viewOffset = _surfaceWidth/4.0f; |
| 853 | const float viewWidth = _surfaceWidth/2.0f; |
| 854 | bx::mtxOrtho(ortho[0], viewOffset, viewOffset + viewWidth, (float)m_surfaceHeight, 0.0f, 0.0f, 1000.0f, offset0); |
| 855 | bx::mtxOrtho(ortho[1], viewOffset, viewOffset + viewWidth, (float)m_surfaceHeight, 0.0f, 0.0f, 1000.0f, offset1); |
844 | 856 | bgfx::setViewTransform(_view, NULL, ortho[0], BGFX_VIEW_STEREO, ortho[1]); |
845 | 857 | bgfx::setViewRect(_view, 0, 0, hmd->width, hmd->height); |
846 | 858 | } |
847 | 859 | else |
848 | 860 | { |
849 | 861 | float ortho[16]; |
850 | | bx::mtxOrtho(ortho, 0.0f, (float)m_viewWidth, (float)m_viewHeight, 0.0f, 0.0f, 1000.0f); |
| 862 | bx::mtxOrtho(ortho, 0.0f, (float)m_surfaceWidth, (float)m_surfaceHeight, 0.0f, 0.0f, 1000.0f); |
851 | 863 | bgfx::setViewTransform(_view, NULL, ortho); |
852 | 864 | bgfx::setViewRect(_view, 0, 0, _width, _height); |
853 | 865 | } |
854 | 866 | |
855 | | updateInput(_mx, _my, _button, _scroll, _inputChar); |
| 867 | updateInput(mx, my, _button, _scroll, _inputChar); |
856 | 868 | |
857 | 869 | m_hot = m_hotToBe; |
858 | 870 | m_hotToBe = 0; |
r244964 | r244965 | |
884 | 896 | |
885 | 897 | clearInput(); |
886 | 898 | |
| 899 | nvgEndFrame(m_nvg); |
887 | 900 | IMGUI_endFrame(); |
888 | 901 | } |
889 | 902 | |
r244964 | r244965 | |
937 | 950 | setEnabled(m_areaId); |
938 | 951 | } |
939 | 952 | |
940 | | nvgScissor(m_nvg |
941 | | , float(area.m_scissorX) |
942 | | , float(area.m_scissorY-1) |
943 | | , float(area.m_scissorWidth) |
944 | | , float(area.m_scissorHeight+1) |
945 | | ); |
| 953 | nvgScissor(m_nvg, area); |
946 | 954 | |
947 | 955 | m_insideArea |= area.m_inside; |
948 | 956 | |
r244964 | r244965 | |
1080 | 1088 | } |
1081 | 1089 | } |
1082 | 1090 | |
1083 | | nvgScissor(m_nvg |
1084 | | , float(parentArea.m_scissorX) |
1085 | | , float(parentArea.m_scissorY-1) |
1086 | | , float(parentArea.m_scissorWidth) |
1087 | | , float(parentArea.m_scissorHeight+1) |
1088 | | ); |
| 1091 | nvgScissor(m_nvg, parentArea); |
1089 | 1092 | } |
1090 | 1093 | |
1091 | 1094 | bool beginArea(const char* _name, int32_t _x, int32_t _y, int32_t _width, int32_t _height, bool _enabled, int32_t _r) |
r244964 | r244965 | |
1159 | 1162 | } |
1160 | 1163 | area.m_scissorEnabled = true; |
1161 | 1164 | |
1162 | | nvgBeginFrame(m_nvg, m_viewWidth, m_viewHeight, 1.0f); |
1163 | | nvgScissor(m_nvg |
1164 | | , float(area.m_scissorX) |
1165 | | , float(area.m_scissorY-1) |
1166 | | , float(area.m_scissorWidth) |
1167 | | , float(area.m_scissorHeight+1) |
1168 | | ); |
| 1165 | nvgScissor(m_nvg, area); |
1169 | 1166 | |
1170 | 1167 | m_insideArea |= area.m_inside; |
1171 | 1168 | return area.m_inside; |
r244964 | r244965 | |
1173 | 1170 | |
1174 | 1171 | void endArea() |
1175 | 1172 | { |
| 1173 | m_areaId.pop(); |
1176 | 1174 | nvgResetScissor(m_nvg); |
1177 | | nvgEndFrame(m_nvg); |
1178 | 1175 | } |
1179 | 1176 | |
1180 | 1177 | bool button(const char* _text, bool _enabled, ImguiAlign::Enum _align, uint32_t _rgb0, int32_t _r) |
r244964 | r244965 | |
1203 | 1200 | //|| ImguiAlign::CenterIndented == _align). |
1204 | 1201 | { |
1205 | 1202 | xx = area.m_widgetX; |
1206 | | width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); |
| 1203 | width = area.m_widgetW - (area.m_widgetX-area.m_contentX); |
1207 | 1204 | } |
1208 | 1205 | |
1209 | 1206 | const bool enabled = _enabled && isEnabled(m_areaId); |
r244964 | r244965 | |
1386 | 1383 | //|| ImguiAlign::CenterIndented == _align). |
1387 | 1384 | { |
1388 | 1385 | xx = area.m_widgetX; |
1389 | | width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); |
| 1386 | width = area.m_widgetW - (area.m_widgetX-area.m_contentX); |
1390 | 1387 | } |
1391 | 1388 | |
1392 | 1389 | const bool drawLabel = (NULL != _label && _label[0] != '\0'); |
r244964 | r244965 | |
1525 | 1522 | //|| ImguiAlign::CenterIndented == _align). |
1526 | 1523 | { |
1527 | 1524 | xx = area.m_widgetX; |
1528 | | width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); |
| 1525 | width = area.m_widgetW - (area.m_widgetX-area.m_contentX); |
1529 | 1526 | } |
1530 | 1527 | |
1531 | 1528 | uint8_t selected = _selected; |
r244964 | r244965 | |
1745 | 1742 | //|| ImguiAlign::CenterIndented == _align). |
1746 | 1743 | { |
1747 | 1744 | xx = area.m_widgetX; |
1748 | | width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); |
| 1745 | width = area.m_widgetW - (area.m_widgetX-area.m_contentX); |
1749 | 1746 | } |
1750 | 1747 | |
1751 | 1748 | const int32_t height = width/2; |
r244964 | r244965 | |
1798 | 1795 | //|| ImguiAlign::CenterIndented == _align). |
1799 | 1796 | { |
1800 | 1797 | xx = area.m_widgetX; |
1801 | | width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); |
| 1798 | width = area.m_widgetW - (area.m_widgetX-area.m_contentX); |
1802 | 1799 | } |
1803 | 1800 | |
1804 | 1801 | const bool adjustHeight = (_cross && _sameHeight); |
r244964 | r244965 | |
2024 | 2021 | xx = -borderSize; |
2025 | 2022 | yy = -1; |
2026 | 2023 | width = 2*borderSize+1; |
2027 | | height = m_viewHeight+1; |
| 2024 | height = m_surfaceHeight+1; |
2028 | 2025 | triX = 0; |
2029 | | triY = (m_viewHeight-triSize)/2; |
| 2026 | triY = (m_surfaceHeight-triSize)/2; |
2030 | 2027 | orientation = _checked ? TriangleOrientation::Left : TriangleOrientation::Right; |
2031 | 2028 | } |
2032 | 2029 | else if (ImguiBorder::Right == _border) |
2033 | 2030 | { |
2034 | | xx = m_viewWidth - borderSize; |
| 2031 | xx = m_surfaceWidth - borderSize; |
2035 | 2032 | yy = -1; |
2036 | 2033 | width = 2*borderSize+1; |
2037 | | height = m_viewHeight+1; |
2038 | | triX = m_viewWidth - triSize - 2; |
2039 | | triY = (m_viewHeight-width)/2; |
| 2034 | height = m_surfaceHeight+1; |
| 2035 | triX = m_surfaceWidth - triSize - 2; |
| 2036 | triY = (m_surfaceHeight-width)/2; |
2040 | 2037 | orientation = _checked ? TriangleOrientation::Right : TriangleOrientation::Left; |
2041 | 2038 | } |
2042 | 2039 | else if (ImguiBorder::Top == _border) |
2043 | 2040 | { |
2044 | 2041 | xx = 0; |
2045 | 2042 | yy = -borderSize; |
2046 | | width = m_viewWidth; |
| 2043 | width = m_surfaceWidth; |
2047 | 2044 | height = 2*borderSize; |
2048 | | triX = (m_viewWidth-triSize)/2; |
| 2045 | triX = (m_surfaceWidth-triSize)/2; |
2049 | 2046 | triY = 0; |
2050 | 2047 | orientation = _checked ? TriangleOrientation::Up : TriangleOrientation::Down; |
2051 | 2048 | } |
2052 | 2049 | else //if (ImguiBorder::Bottom == _border). |
2053 | 2050 | { |
2054 | 2051 | xx = 0; |
2055 | | yy = m_viewHeight - borderSize; |
2056 | | width = m_viewWidth; |
| 2052 | yy = m_surfaceHeight - borderSize; |
| 2053 | width = m_surfaceWidth; |
2057 | 2054 | height = 2*borderSize; |
2058 | | triX = (m_viewWidth-triSize)/2; |
2059 | | triY = m_viewHeight-triSize; |
| 2055 | triX = (m_surfaceWidth-triSize)/2; |
| 2056 | triY = m_surfaceHeight-triSize; |
2060 | 2057 | orientation = _checked ? TriangleOrientation::Down : TriangleOrientation::Up; |
2061 | 2058 | } |
2062 | 2059 | |
r244964 | r244965 | |
2147 | 2144 | //|| ImguiAlign::CenterIndented == _align). |
2148 | 2145 | { |
2149 | 2146 | xx = area.m_widgetX; |
2150 | | width = area.m_widgetW - (area.m_widgetX-area.m_scissorX); |
| 2147 | width = area.m_widgetW - (area.m_widgetX-area.m_contentX); |
2151 | 2148 | } |
2152 | 2149 | |
2153 | 2150 | drawRoundedRect( (float)xx, (float)yy, (float)width, (float)height, 4.0f, imguiRGBA(0, 0, 0, 128) ); |
r244964 | r244965 | |
2265 | 2262 | area.m_widgetY += _height; |
2266 | 2263 | } |
2267 | 2264 | |
2268 | | void separatorLine(uint16_t _height) |
| 2265 | void separatorLine(uint16_t _height, ImguiAlign::Enum _align) |
2269 | 2266 | { |
2270 | 2267 | Area& area = getCurrentArea(); |
2271 | | const int32_t rectWidth = area.m_widgetW; |
2272 | | const int32_t rectHeight = 1; |
2273 | | const int32_t xx = area.m_widgetX; |
2274 | | const int32_t yy = area.m_widgetY + _height/2 - rectHeight; |
| 2268 | //const int32_t width = area.m_widgetW; |
| 2269 | const int32_t height = 1; |
| 2270 | //const int32_t xx = area.m_widgetX; |
| 2271 | const int32_t yy = area.m_widgetY + _height/2 - height; |
| 2272 | |
| 2273 | int32_t xx; |
| 2274 | int32_t width; |
| 2275 | if (ImguiAlign::Left == _align) |
| 2276 | { |
| 2277 | xx = area.m_contentX + SCROLL_AREA_PADDING; |
| 2278 | width = area.m_widgetW; |
| 2279 | } |
| 2280 | else if (ImguiAlign::LeftIndented == _align |
| 2281 | || ImguiAlign::Right == _align) |
| 2282 | { |
| 2283 | xx = area.m_widgetX; |
| 2284 | width = area.m_widgetW; |
| 2285 | } |
| 2286 | else //if (ImguiAlign::Center == _align |
| 2287 | //|| ImguiAlign::CenterIndented == _align). |
| 2288 | { |
| 2289 | xx = area.m_widgetX; |
| 2290 | width = area.m_widgetW - (area.m_widgetX-area.m_contentX) + 1; |
| 2291 | } |
| 2292 | |
2275 | 2293 | area.m_widgetY += _height; |
2276 | 2294 | |
2277 | 2295 | drawRect( (float)xx |
2278 | 2296 | , (float)yy |
2279 | | , (float)rectWidth |
2280 | | , (float)rectHeight |
| 2297 | , (float)width |
| 2298 | , (float)height |
2281 | 2299 | , imguiRGBA(255, 255, 255, 32) |
2282 | 2300 | ); |
2283 | 2301 | } |
r244964 | r244965 | |
3048 | 3066 | const Area& area = getCurrentArea(); |
3049 | 3067 | if (area.m_scissorEnabled) |
3050 | 3068 | { |
3051 | | bgfx::setScissor(uint16_t(IMGUI_MAX(0, area.m_scissorX) ) |
3052 | | , uint16_t(IMGUI_MAX(0, area.m_scissorY-1) ) |
3053 | | , area.m_scissorWidth |
3054 | | , area.m_scissorHeight+1 |
| 3069 | const float xscale = float(m_viewWidth) /float(m_surfaceWidth); |
| 3070 | const float yscale = float(m_viewHeight)/float(m_surfaceHeight); |
| 3071 | const int16_t scissorX = int16_t(float(area.m_scissorX)*xscale); |
| 3072 | const int16_t scissorY = int16_t(float(area.m_scissorY)*yscale); |
| 3073 | const int16_t scissorWidth = int16_t(float(area.m_scissorWidth)*xscale); |
| 3074 | const int16_t scissorHeight = int16_t(float(area.m_scissorHeight)*yscale); |
| 3075 | bgfx::setScissor(uint16_t(IMGUI_MAX(0, scissorX) ) |
| 3076 | , uint16_t(IMGUI_MAX(0, scissorY-1) ) |
| 3077 | , scissorWidth |
| 3078 | , scissorHeight+1 |
3055 | 3079 | ); |
3056 | 3080 | } |
3057 | 3081 | else |
r244964 | r244965 | |
3060 | 3084 | } |
3061 | 3085 | } |
3062 | 3086 | |
| 3087 | inline void nvgScissor(NVGcontext* _ctx, const Area& _area) |
| 3088 | { |
| 3089 | if (_area.m_scissorEnabled) |
| 3090 | { |
| 3091 | ::nvgScissor(_ctx |
| 3092 | , float(IMGUI_MAX(0, _area.m_scissorX) ) |
| 3093 | , float(IMGUI_MAX(0, _area.m_scissorY-1) ) |
| 3094 | , float(_area.m_scissorWidth) |
| 3095 | , float(_area.m_scissorHeight+1) |
| 3096 | ); |
| 3097 | } |
| 3098 | else |
| 3099 | { |
| 3100 | nvgResetScissor(_ctx); |
| 3101 | } |
| 3102 | } |
| 3103 | |
3063 | 3104 | template <typename Ty, uint16_t Max=64> |
3064 | 3105 | struct IdStack |
3065 | 3106 | { |
r244964 | r244965 | |
3149 | 3190 | uint8_t m_view; |
3150 | 3191 | uint16_t m_viewWidth; |
3151 | 3192 | uint16_t m_viewHeight; |
| 3193 | uint16_t m_surfaceWidth; |
| 3194 | uint16_t m_surfaceHeight; |
3152 | 3195 | |
3153 | 3196 | #if !USE_NANOVG_FONT |
3154 | 3197 | struct Font |
r244964 | r244965 | |
3203 | 3246 | return handle; |
3204 | 3247 | } |
3205 | 3248 | |
| 3249 | void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, uint16_t _surfaceWidth, uint16_t _surfaceHeight, char _inputChar, uint8_t _view) |
| 3250 | { |
| 3251 | s_imgui.beginFrame(_mx, _my, _button, _scroll, _width, _height, _surfaceWidth, _surfaceHeight, _inputChar, _view); |
| 3252 | } |
| 3253 | |
3206 | 3254 | void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, char _inputChar, uint8_t _view) |
3207 | 3255 | { |
3208 | | s_imgui.beginFrame(_mx, _my, _button, _scroll, _width, _height, _inputChar, _view); |
| 3256 | s_imgui.beginFrame(_mx, _my, _button, _scroll, _width, _height, _width, _height, _inputChar, _view); |
3209 | 3257 | } |
3210 | 3258 | |
3211 | 3259 | void imguiEndFrame() |
r244964 | r244965 | |
3288 | 3336 | s_imgui.separator(_height); |
3289 | 3337 | } |
3290 | 3338 | |
3291 | | void imguiSeparatorLine(uint16_t _height) |
| 3339 | void imguiSeparatorLine(uint16_t _height, ImguiAlign::Enum _align) |
3292 | 3340 | { |
3293 | | s_imgui.separatorLine(_height); |
| 3341 | s_imgui.separatorLine(_height, _align); |
3294 | 3342 | } |
3295 | 3343 | |
3296 | 3344 | int32_t imguiGetWidgetX() |