Hi!
I'm creating a game engine similar to unity but just for 2D games and right now I'm trying to finish the scene view but I'm having problems when resizing.
This is how Unity scene view looks and is what I want to achieve:
And this is what I have right now:
Here is the code used. I'm using ImGui:
// Function drawing the GameObjects to RenderTexture. window = RenderTexture
bool ModuleSceneWindow::PostUpdate()
{
window->clear(sf::Color(100, 100, 100, 255));
for (int j = 0; j < drawableObjects.size(); j++) {
if (drawableObjects[j]->isActive()) {
window->draw(*drawableObjects[j]->gameObjectSprite);
}
}
window->display();
return true;
}
// Function drawing the RenderTexture as the scene view
void PanelScene::DrawPanel()
{
if (ImGui::BeginDock(panelName.c_str(), ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
sf::Vector2u size = ImGui::GetContentRegionAvail();
ImGui::Image((void*)engine->sceneWindow->window->getTexture().getNativeHandle(), size, ImVec2(0, 1), ImVec2(1, 0), sf::Color::White, sf::Color::Transparent);
}
}
As you see, the sprite is stretching with the screen.
Any idea to know how to do it?
I know scene in Unity is 3D but uses a 2D view. Should i use openGL to achieve this result? If it's the case, I'll need extra info because I don't know openGL.
If you need more info, tell me.
Thanks.