@@ -16,22 +16,11 @@ OvEditor::Panels::AView::AView
1616 const OvUI::Settings::PanelWindowSettings& p_windowSettings
1717) : PanelWindow(p_title, p_opened, p_windowSettings), m_editorRenderer(EDITOR_RENDERER())
1818{
19- glGenFramebuffers (1 , &m_fbo);
20- glGenTextures (1 , &m_renderTexture);
21- glGenRenderbuffers (1 , &m_depthStencilBuffer);
22-
2319 m_cameraPosition = { -10 .0f , 4 .0f , 10 .0f };
2420 m_camera.SetPitch (-10 .0f );
2521 m_camera.SetYaw (-45 .f );
2622
27- m_image = &CreateWidget<OvUI::Widgets::Visual::Image>(m_renderTexture, OvMaths::FVector2{ 0 .f , 0 .f });
28- }
29-
30- OvEditor::Panels::AView::~AView ()
31- {
32- glDeleteBuffers (1 , &m_fbo);
33- glDeleteTextures (1 , &m_renderTexture);
34- glGenRenderbuffers (1 , &m_depthStencilBuffer);
23+ m_image = &CreateWidget<OvUI::Widgets::Visual::Image>(m_fbo.GetTextureID (), OvMaths::FVector2{ 0 .f , 0 .f });
3524}
3625
3726void OvEditor::Panels::AView::Update (float p_deltaTime)
@@ -42,20 +31,7 @@ void OvEditor::Panels::AView::Update(float p_deltaTime)
4231
4332 m_image->size = OvMaths::FVector2 (static_cast <float >(winWidth), static_cast <float >(winHeight));
4433
45- /* Setup texture */
46- glBindTexture (GL_TEXTURE_2D, m_renderTexture);
47- glTexImage2D (GL_TEXTURE_2D, 0 , GL_RGB, winWidth, winHeight, 0 , GL_RGB, GL_UNSIGNED_BYTE, 0 );
48- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
49- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
50-
51- /* Setup depth-stencil buffer (24 + 8 bits) */
52- glBindRenderbuffer (GL_RENDERBUFFER, m_depthStencilBuffer);
53- glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_STENCIL, winWidth, winHeight);
54-
55- /* Setup frame buffer */
56- glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
57- glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
58- glFramebufferTexture (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_renderTexture, 0 );
34+ m_fbo.Resize (winWidth, winHeight);
5935
6036 Unbind ();
6137}
@@ -66,12 +42,12 @@ void OvEditor::Panels::AView::Bind()
6642
6743 glViewport (0 , 0 , winWidth, winHeight);
6844
69- glBindFramebuffer (GL_FRAMEBUFFER, m_fbo);
45+ m_fbo. Bind ( );
7046}
7147
7248void OvEditor::Panels::AView::Unbind ()
7349{
74- glBindFramebuffer (GL_FRAMEBUFFER, 0 );
50+ m_fbo. Unbind ( );
7551}
7652
7753void OvEditor::Panels::AView::_Draw_Impl ()
0 commit comments