Re: [Bug] Artifacts after windows resize with OpenGL3Rendere
Posted: Thu Sep 11, 2014 06:00
Could you try another SDL version?
The official forum for CEGUI
http://cegui.org.uk/forum/
Ident wrote:Could you try another SDL version?
Code: Select all
#ifdef USE_SDL2
# include <SDL2/SDL.h>
# include <SDL2/SDL_video.h>
#elif USE_GLFW3
# include <GLFW/glfw3.h>
#endif
#include <CEGUI/System.h>
#include <CEGUI/RendererModules/OpenGL/GL3Renderer.h>
#include <CEGUI/SchemeManager.h>
#include <CEGUI/WindowManager.h>
#include <CEGUI/GUIContext.h>
#include <CEGUI/DefaultResourceProvider.h>
#include <CEGUI/Font.h>
#include <CEGUI/Scheme.h>
#include <CEGUI/WindowManager.h>
#include <CEGUI/falagard/WidgetLookManager.h>
#include <CEGUI/ImageManager.h>
int main()
{
#ifdef USE_SDL2
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(
SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_CONTEXT_PROFILE_CORE
);
SDL_Window * const window = SDL_CreateWindow(
"Sample",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
1200,
700,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE
);
SDL_GLContext sdl_opengl_context = SDL_GL_CreateContext(window);
#elif USE_GLFW3
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
GLFWwindow * const window = glfwCreateWindow(
1200,
700,
"Sample",
NULL,
NULL
);
glfwMakeContextCurrent(window);
#endif
CEGUI::OpenGL3Renderer::bootstrapSystem();
CEGUI::System & system = CEGUI::System::getSingleton();
{
CEGUI::DefaultResourceProvider * rp = (
static_cast<CEGUI::DefaultResourceProvider*>(
system.getResourceProvider()
)
);
rp->setResourceGroupDirectory("schemes", "./datafiles/schemes/");
rp->setResourceGroupDirectory("imagesets", "./datafiles/imagesets/");
rp->setResourceGroupDirectory("fonts", "./datafiles/fonts/");
rp->setResourceGroupDirectory("layouts", "./datafiles/layouts/");
rp->setResourceGroupDirectory("looknfeels", "./datafiles/looknfeel/");
CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets");
CEGUI::Font::setDefaultResourceGroup("fonts");
CEGUI::Scheme::setDefaultResourceGroup("schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
CEGUI::WindowManager::setDefaultResourceGroup("layouts");
}
{
CEGUI::SchemeManager::getSingleton().createFromFile("Generic.scheme");
CEGUI::SchemeManager::getSingleton().createFromFile("GameMenu.scheme");
CEGUI::Window * const root_window = (
CEGUI::WindowManager::getSingleton().loadLayoutFromFile(
"GameMenu.layout"
)
);
system.getDefaultGUIContext().setRootWindow(root_window);
}
#ifdef USE_SDL2
while (!SDL_QuitRequested()) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (event.type == SDL_WINDOWEVENT
&& event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
int x, y;
SDL_GL_GetDrawableSize(window, &x, &y);
system.notifyDisplaySizeChanged({
static_cast<float>(x),
static_cast<float>(y)
});
}
}
system.renderAllGUIContexts();
SDL_GL_SwapWindow(window);
}
#elif USE_GLFW3
while (!glfwWindowShouldClose(window)) {
int x, y;
glfwGetFramebufferSize(window, &x, &y);
system.notifyDisplaySizeChanged({
static_cast<float>(x),
static_cast<float>(y)
});
system.renderAllGUIContexts();
glfwSwapBuffers(window);
glfwPollEvents();
}
#endif
CEGUI::OpenGL3Renderer::destroySystem();
#ifdef USE_SDL2
SDL_GL_DeleteContext(sdl_opengl_context);
SDL_DestroyWindow(window);
SDL_Quit();
#elif USE_GLFW3
glfwDestroyWindow(window);
glfwTerminate();
#endif
return 0;
}
Ident wrote:I have to ask again because it is such a common issue and we often get false reports on this: Did you do any OpenGL calls at all in your code? Please check multiple times before you respond.