Hello,
For some reasons I have to redraw twice the window on osx after a window resize event, otherwise the window shows garbage. This is on osx 10.8.5 with a retina display. A minimal repro case is given below, can anyone confirm ? Is it a retina display only issue ?
Btw, is it possible to get resize events while the window is being resized ?
Best,
Daniel
---- minc.c ----
/*
Compile with:
gcc -o minc minc.c sdl2-config --cflags --libs
-framework OpenGL
*/
#include <unistd.h>
#include <assert.h>
#include <stdio.h>
#include <OpenGL/gl3.h>
#include “SDL.h”
void draw (SDL_Window *w)
{
glClearColor (1.0, 0.0, 0.0, 1.0);
glClear (GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow (w);
}
void reshape (SDL_Window *w, int width, int height)
{
glViewport (0, 0, width, height);
}
int main(int argc, char** argv)
{
assert (SDL_Init(SDL_INIT_VIDEO) == 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_Window *w =
SDL_CreateWindow (“SDL OpenGL ©”,
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
640, 480,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
assert (w);
SDL_GLContext *c = SDL_GL_CreateContext(w);
assert ©;
draw (w);
while (1)
{
SDL_Event e;
assert (SDL_WaitEvent (&e));
switch (e.type) {
case SDL_KEYUP: if (e.key.keysym.sym == SDLK_ESCAPE) exit(0); break;
case SDL_WINDOWEVENT:
if (e.window.event == SDL_WINDOWEVENT_RESIZED)
{
reshape (w, e.window.data1, e.window.data2);
draw (w);
/* draw (w) */
}
break;
default: break;
}
}
SDL_GL_DeleteContext ©;
SDL_DestroyWindow (w);
SDL_Quit ();
return 0;
}--------------------