MCPcopy Create free account
hub / github.com/SFML/imgui-sfml / SetupRenderState

Function SetupRenderState

imgui-SFML.cpp:895–944  ·  view source on GitHub ↗

copied from imgui/backends/imgui_impl_opengl2.cpp

Source from the content-addressed store, hash-verified

893{
894// copied from imgui/backends/imgui_impl_opengl2.cpp
895void SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height)
896{
897 // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor
898 // enabled, vertex/texcoord/color pointers, polygon fill.
899 glEnable(GL_BLEND);
900 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
901 // glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); //
902 // In order to composite our output buffer we need to preserve alpha
903 glDisable(GL_CULL_FACE);
904 glDisable(GL_DEPTH_TEST);
905 glDisable(GL_STENCIL_TEST);
906 glDisable(GL_LIGHTING);
907 glDisable(GL_COLOR_MATERIAL);
908 glEnable(GL_SCISSOR_TEST);
909 glEnableClientState(GL_VERTEX_ARRAY);
910 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
911 glEnableClientState(GL_COLOR_ARRAY);
912 glDisableClientState(GL_NORMAL_ARRAY);
913 glEnable(GL_TEXTURE_2D);
914 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
915 glShadeModel(GL_SMOOTH);
916 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
917
918 // Setup viewport, orthographic projection matrix
919 // Our visible imgui space lies from draw_data->DisplayPos (top left) to
920 // draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single
921 // viewport apps.
922 glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
923 glMatrixMode(GL_PROJECTION);
924 glPushMatrix();
925 glLoadIdentity();
926#ifdef GL_VERSION_ES_CL_1_1
927 glOrthof(draw_data->DisplayPos.x,
928 draw_data->DisplayPos.x + draw_data->DisplaySize.x,
929 draw_data->DisplayPos.y + draw_data->DisplaySize.y,
930 draw_data->DisplayPos.y,
931 -1.0f,
932 +1.0f);
933#else
934 glOrtho(draw_data->DisplayPos.x,
935 draw_data->DisplayPos.x + draw_data->DisplaySize.x,
936 draw_data->DisplayPos.y + draw_data->DisplaySize.y,
937 draw_data->DisplayPos.y,
938 -1.0f,
939 +1.0f);
940#endif
941 glMatrixMode(GL_MODELVIEW);
942 glPushMatrix();
943 glLoadIdentity();
944}
945
946// Rendering callback
947void RenderDrawLists(ImDrawData* draw_data)

Callers 1

RenderDrawListsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected