{"action":"created","issue":{"url":"https://api.github.com/repos/eliasdaler/imgui-sfml/issues/61","repository_url":"https://api.github.com/repos/eliasdaler/imgui-sfml","labels_url":"https://api.github.com/repos/eliasdaler/imgui-sfml/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/eliasdaler/imgui-sfml/issues/61/comments","events_url":"https://api.github.com/repos/eliasdaler/imgui-sfml/issues/61/events","html_url":"https://github.com/eliasdaler/imgui-sfml/issues/61","id":340841081,"node_id":"MDU6SXNzdWUzNDA4NDEwODE=","number":61,"title":"How to draw using OpenGL on a sf::RenderTexture?","user":{"login":"sgiurgiu","id":1079312,"node_id":"MDQ6VXNlcjEwNzkzMTI=","avatar_url":"https://avatars1.githubusercontent.com/u/1079312?v=4","gravatar_id":"","url":"https://api.github.com/users/sgiurgiu","html_url":"https://github.com/sgiurgiu","followers_url":"https://api.github.com/users/sgiurgiu/followers","following_url":"https://api.github.com/users/sgiurgiu/following{/other_user}","gists_url":"https://api.github.com/users/sgiurgiu/gists{/gist_id}","starred_url":"https://api.github.com/users/sgiurgiu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgiurgiu/subscriptions","organizations_url":"https://api.github.com/users/sgiurgiu/orgs","repos_url":"https://api.github.com/users/sgiurgiu/repos","events_url":"https://api.github.com/users/sgiurgiu/events{/privacy}","received_events_url":"https://api.github.com/users/sgiurgiu/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-13T00:24:45Z","updated_at":"2018-07-15T09:35:50Z","closed_at":"2018-07-13T17:07:13Z","author_association":"NONE","body":"Hi,\r\nI am having a bit of a problem here as I don't seem to be able to correctly draw an 3D cube on a RenderTexture.\r\nHere's the code, as small as I could make it:\r\n\r\n```C++\r\n#include \"imgui.h\"\r\n#include \"imgui-SFML.h\"\r\n\r\n#include <SFML/Graphics.hpp>\r\n#include <SFML/System/Clock.hpp>\r\n#include <SFML/Window/Event.hpp>\r\n#include <SFML/OpenGL.hpp>\r\n#include <vector>\r\n#include <iostream>\r\n\r\n#include <GL/glu.h>\r\n#include <GL/glext.h>\r\n\r\nvoid showOpenGLWindow();\r\n\r\nsf::RenderTexture renderTexture;\r\nint angle;\r\nsf::Clock drawingClock;\r\n\r\nint main(int, char**)\r\n{\r\n    sf::RenderWindow window(sf::VideoMode(1024, 768), \"\");\r\n    window.setVerticalSyncEnabled(true);\r\n    ImGui::SFML::Init(window);\r\n\r\n    \r\n    // Setup ImGui binding\r\n    ImGui::CreateContext();\r\n    ImGuiIO& io = ImGui::GetIO(); (void)io;\r\n    io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;  // Enable Keyboard Controls\r\n    \r\n\r\n    // Setup style\r\n    ImGui::StyleColorsDark();\r\n    io.Fonts->AddFontDefault();\r\n\r\n    sf::Color bgColor = ImVec4(0.37f, 0.61f, 0.62f, 1.00f);//some teal color\r\n    window.setTitle(\"ImgUI OpenGL Test\");\r\n    window.resetGLStates(); // call it if you only draw ImGui. Otherwise not needed.\r\n    \r\n    bool done = false;\r\n    bool demoOpen = true;\r\n   \r\n     \r\n    renderTexture.create(300,300);\r\n    renderTexture.setActive(true);\r\n\r\n    glEnable(GL_DEPTH_TEST);\r\n    glDepthMask(GL_TRUE);\r\n    glFrontFace(GL_CCW);\r\n    glEnable(GL_CULL_FACE);\r\n    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);    \r\n    glMatrixMode (GL_PROJECTION);\r\n     glLoadIdentity();\r\n    glFrustum (-0.1333, 0.1333, -0.1, 0.1, 0.5, 25.0); \r\n    \r\n    glViewport(0, 0, 300, 300);\r\n    gluPerspective(90.f, 1.f, .1f, 100.f);        \r\n    \r\n    renderTexture.setActive(false);\r\n\r\n    sf::Clock deltaClock;\r\n    while (!done) {\r\n        sf::Event event;\r\n        while (window.pollEvent(event)) {\r\n            ImGui::SFML::ProcessEvent(event);\r\n \r\n            if (event.type == sf::Event::Closed ||\r\n                (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Q && event.key.control)\r\n            ) {\r\n                done = true;\r\n            }\r\n        }\r\n \r\n        ImGui::SFML::Update(window, deltaClock.restart());\r\n        \r\n        ImGui::ShowMetricsWindow(&demoOpen);\r\n        \r\n        showOpenGLWindow();\r\n \r\n        window.clear(bgColor); // fill background with color\r\n        ImGui::SFML::Render(window);\r\n        window.display();\r\n    }\r\n\r\n   \r\n    window.close();\r\n \r\n    ImGui::SFML::Shutdown();\r\n    return 0;\r\n}\r\n\r\n\r\nvoid showOpenGLWindow()\r\n{\r\n    ImGui::SetNextWindowSize(ImVec2(350,350),ImGuiCond_FirstUseEver);\r\n    if(ImGui::Begin(\"GL\"))\r\n    {\r\n        renderTexture.setActive(true);       \r\n        renderTexture.clear();\r\n        \r\n        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\r\n    // Apply some transformations for the cube\r\n        glMatrixMode(GL_MODELVIEW);\r\n        glLoadIdentity();\r\n\r\n        glPushMatrix();\r\n        glTranslatef(100.f, 100.f, 0.f);\r\n                \r\n        angle=drawingClock.getElapsedTime().asSeconds();\r\n        \r\n        glRotatef(angle * 50, 1.f, 0.f, 0.f);\r\n        glRotatef(angle * 80, 0.f, 1.f, 0.f);\r\n        glRotatef(angle * 120, 0.f, 0.f, 1.f);\r\n\r\n        float size = 50.f;\r\n        glBegin(GL_QUADS);\r\n            glColor3f(0.0f, 1.0f, 0.0f);\r\n            glNormal3f(0.0f, 1.0f, 0.0f);\r\n            glVertex3f(-size, -size, -size);\r\n            glVertex3f(-size,  size, -size);\r\n            glVertex3f( size,  size, -size);\r\n            glVertex3f( size, -size, -size);\r\n\r\n            glColor3f(0.0f, 1.0f, 0.0f);\r\n            glNormal3f(0.0f, 0.0f, 1.0f);\r\n            glVertex3f(-size, -size, size);\r\n            glVertex3f(-size,  size, size);\r\n            glVertex3f( size,  size, size);\r\n            glVertex3f( size, -size, size);\r\n\r\n            glColor3f(0.0f, 0.0f, 1.0f);\r\n            glNormal3f(1.0f, 0.0f, 0.0f);\r\n            glVertex3f(-size, -size, -size);\r\n            glVertex3f(-size,  size, -size);\r\n            glVertex3f(-size,  size,  size);\r\n            glVertex3f(-size, -size,  size);\r\n\r\n            glColor3f(0.0f, 0.0f, 0.5f);\r\n            glNormal3f(-1.0f, 0.0f, 0.0f);\r\n            glVertex3f(size, -size, -size);\r\n            glVertex3f(size,  size, -size);\r\n            glVertex3f(size,  size,  size);\r\n            glVertex3f(size, -size,  size);\r\n\r\n            glColor3f(0.5f, 0.0f, 0.0f);\r\n            glNormal3f(0.0f, -1.0f, 0.0f);\r\n            glVertex3f(-size, -size,  size);\r\n            glVertex3f(-size, -size, -size);\r\n            glVertex3f( size, -size, -size);\r\n            glVertex3f( size, -size,  size);\r\n\r\n            glColor3f(0.0f, 0.5f, 0.0f);\r\n            glNormal3f(0.0f, 0.0f, -1.0f);\r\n            glVertex3f(-size, size,  size);\r\n            glVertex3f(-size, size, -size);\r\n            glVertex3f( size, size, -size);\r\n            glVertex3f( size, size,  size);\r\n        glEnd();\r\n\r\n        glPopMatrix();\r\n        \r\n        sf::RectangleShape rect(sf::Vector2f(20, 20));\r\n        rect.setFillColor(sf::Color::Cyan);\r\n        renderTexture.draw(rect);\r\n        \r\n        renderTexture.setActive(false);\r\n            \r\n        renderTexture.display();\r\n        ImGui::Image(renderTexture.getTexture());\r\n        \r\n        ImGui::End();\r\n    }\r\n}\r\n```\r\n\r\nAnd here's the result:\r\n\r\n![App](https://media.giphy.com/media/2zoLe790MW7v4pb1M3/giphy.gif)\r\n\r\nAny suggestion as to what I am doing wrong is greatly appreciated.\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/eliasdaler/imgui-sfml/issues/comments/405079041","html_url":"https://github.com/eliasdaler/imgui-sfml/issues/61#issuecomment-405079041","issue_url":"https://api.github.com/repos/eliasdaler/imgui-sfml/issues/61","id":405079041,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNTA3OTA0MQ==","user":{"login":"eliasdaler","id":1285136,"node_id":"MDQ6VXNlcjEyODUxMzY=","avatar_url":"https://avatars0.githubusercontent.com/u/1285136?v=4","gravatar_id":"","url":"https://api.github.com/users/eliasdaler","html_url":"https://github.com/eliasdaler","followers_url":"https://api.github.com/users/eliasdaler/followers","following_url":"https://api.github.com/users/eliasdaler/following{/other_user}","gists_url":"https://api.github.com/users/eliasdaler/gists{/gist_id}","starred_url":"https://api.github.com/users/eliasdaler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eliasdaler/subscriptions","organizations_url":"https://api.github.com/users/eliasdaler/orgs","repos_url":"https://api.github.com/users/eliasdaler/repos","events_url":"https://api.github.com/users/eliasdaler/events{/privacy}","received_events_url":"https://api.github.com/users/eliasdaler/received_events","type":"User","site_admin":false},"created_at":"2018-07-15T09:35:50Z","updated_at":"2018-07-15T09:35:50Z","author_association":"OWNER","body":"Awesome. :)"}}
{"actor":{"display_login":"eliasdaler"}}