Hi!
I have hard time connecting all libraries.
sfimgui ->
https://github.com/eliasdaler/imgui-sfmlI can use both RenderWindow + GLEW2 (it renders a simple rectangle), but whenever i add ImGui::SFML::Init it stops rendering my rectangle and displays following messages:
An internal OpenGL call failed in Texture.cpp(563).
Expression:
glBindTexture(GL_TEXTURE_2D, 0)
Error description:
GL_INVALID_OPERATION
The specified operation is not allowed in the current state.
I've also tried changing glew2 to glad, but integrating imgui still fails
My code (shortened) looks this way:
#define GLEW_STATIC
#include "GL/glew.h"
#include "include/imgui/imgui.h"
#include "include/imgui/imgui-SFML.h"
#include "my_opengl_wrapper.hpp" //vao & shader loader
#include <SFML/Graphics.hpp>
std::vector<GLfloat> cube_Pos = {...}; //my rect vertices
//prints version of opengl
void getOpenglVersion(){
int v1=31337, v2=1337;
glGetIntegerv(GL_MAJOR_VERSION, &v1);
glGetIntegerv(GL_MINOR_VERSION, &v2);
std::cout << "versions (imGUI): " << v1 << " " << v2 << "\n";
}
int main(){
sf::ContextSettings settings;
settings.majorVersion = 3;
settings.minorVersion = 3;
sf::RenderWindow window(sf::VideoMode(1280, 720), "sf_glew", sf::Style::Default, settings);
getOpenglVersion(); //prints 3 3
ImGui::SFML::Init(window); //this causes all problems, root of all evil
getOpenglVersion(); //prints 4 0, if ImGui::SFML::Init is commented it prints 3 3
glewExperimental=GL_TRUE;
if(glewInit() == GLEW_OK)
std::cout << "ok! " << x << "\n";
getOpenglVersion(); //prints 4 0, if ImGui::SFML::Init is commented it prints 3 3
//my sh1 and vao loaders, it works great
chaos::ShaderProgram sh1({std::make_pair("chaos/files/shaders/shader2.vs", GL_VERTEX_SHADER),
std::make_pair("chaos/files/shaders/shader2.fs", GL_FRAGMENT_SHADER)});
chaos::VertexArray vao(3, 0, 2, 0, &cube_Pos);
while(window.isOpen()){
window.clear(sf::Color::Green);
sf::Event event;
while(window.pollEvent(event)){
if(event.type == sf::Event::Closed ){
window.close();
return 0;
}
if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
window.close();
return 0;
}
}
//this all works as expected if imgui isn't enabled
sh1.run();
sh1.setUniform("uniColor", glm::vec4(1.0f, 0.0f, 0.5f, 1.0f));
sh1.setUniform("mx",glm::mat4());
vao.bind();
glDrawArrays(GL_TRIANGLES, 0, vao.countVertices());
vao.unbind();
glUseProgram(0);
window.display();
}
return 0;
}
I have to add that if i use only sfml2(RenderWindow) + imgui then it works, also sfml2(RenderWindow) + glew works fine, the problem is in using all three at once.