Renderer logical size is now implemented as a render target
This fixes rounding errors with coordinate scaling and gives more flexibility in the presentation, as well as making it easy to maintain device independent resolution as windows move between different pixel density displays. By default when a renderer is created, it will match the window size so window coordinates and render coordinates are 1-1. Mouse and touch events are no longer filtered to change their coordinates, instead you can call SDL_ConvertEventToRenderCoordinates() to explicitly map event coordinates into the rendering viewport. SDL_RenderWindowToLogical() and SDL_RenderLogicalToWindow() have been renamed SDL_RenderCoordinatesFromWindow() and SDL_RenderCoordinatesToWindow() and take floating point coordinates in both directions. The viewport, clipping state, and scale for render targets are now persistent and will remain set whenever they are active.
This commit is contained in:
parent
93fc72a405
commit
dcd17f5473
28 changed files with 1113 additions and 910 deletions
|
@ -331,12 +331,6 @@ static void GL_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
static int GL_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
|
||||
{
|
||||
SDL_GetWindowSizeInPixels(renderer->window, w, h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GLenum GetBlendFunc(SDL_BlendFactor factor)
|
||||
{
|
||||
switch (factor) {
|
||||
|
@ -1440,7 +1434,7 @@ static int GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
|||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
SDL_GetRendererOutputSize(renderer, &w, &h);
|
||||
SDL_GetCurrentRenderOutputSize(renderer, &w, &h);
|
||||
|
||||
data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
data->glPixelStorei(GL_PACK_ROW_LENGTH,
|
||||
|
@ -1749,7 +1743,6 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|||
}
|
||||
|
||||
renderer->WindowEvent = GL_WindowEvent;
|
||||
renderer->GetOutputSize = GL_GetOutputSize;
|
||||
renderer->SupportsBlendMode = GL_SupportsBlendMode;
|
||||
renderer->CreateTexture = GL_CreateTexture;
|
||||
renderer->UpdateTexture = GL_UpdateTexture;
|
||||
|
@ -1935,9 +1928,13 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|||
SDL_GL_GetProcAddress("glBindFramebufferEXT");
|
||||
data->glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)
|
||||
SDL_GL_GetProcAddress("glCheckFramebufferStatusEXT");
|
||||
renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE;
|
||||
} else {
|
||||
SDL_SetError("Can't create render targets, GL_EXT_framebuffer_object not available");
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
data->framebuffers = NULL;
|
||||
|
||||
/* Set up parameters for rendering */
|
||||
data->glMatrixMode(GL_MODELVIEW);
|
||||
|
@ -1972,7 +1969,7 @@ error:
|
|||
SDL_RenderDriver GL_RenderDriver = {
|
||||
GL_CreateRenderer,
|
||||
{ "opengl",
|
||||
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
|
||||
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
|
||||
4,
|
||||
{ SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_PIXELFORMAT_ABGR8888,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue