early-access version 1617
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
|
||||
#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_opengles2.h"
|
||||
#include "../SDL_sysrender.h"
|
||||
@@ -783,6 +782,48 @@ GLES2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
|
||||
{
|
||||
int i;
|
||||
const size_t vertlen = (sizeof (GLfloat) * 2) * count;
|
||||
GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
/* Offset to hit the center of the pixel. */
|
||||
for (i = 0; i < count; i++) {
|
||||
*(verts++) = 0.5f + points[i].x;
|
||||
*(verts++) = 0.5f + points[i].y;
|
||||
}
|
||||
|
||||
/* Make the last line segment one pixel longer, to satisfy the
|
||||
diamond-exit rule. */
|
||||
verts -= 4;
|
||||
{
|
||||
const GLfloat xstart = verts[0];
|
||||
const GLfloat ystart = verts[1];
|
||||
const GLfloat xend = verts[2];
|
||||
const GLfloat yend = verts[3];
|
||||
|
||||
if (ystart == yend) { /* horizontal line */
|
||||
verts[2] += (xend > xstart) ? 1.0f : -1.0f;
|
||||
} else if (xstart == xend) { /* vertical line */
|
||||
verts[3] += (yend > ystart) ? 1.0f : -1.0f;
|
||||
} else { /* bump a pixel in the direction we are moving in. */
|
||||
const GLfloat deltax = xend - xstart;
|
||||
const GLfloat deltay = yend - ystart;
|
||||
const GLfloat angle = SDL_atan2f(deltay, deltax);
|
||||
verts[2] += SDL_cosf(angle);
|
||||
verts[3] += SDL_sinf(angle);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
GLES2_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count)
|
||||
{
|
||||
@@ -1294,17 +1335,10 @@ GLES2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *ver
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_DRAW_LINES: {
|
||||
const GLfloat *verts = (GLfloat *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
const size_t count = cmd->data.draw.count;
|
||||
SDL_assert(count >= 2);
|
||||
if (SetDrawState(data, cmd, GLES2_IMAGESOURCE_SOLID) == 0) {
|
||||
if (count > 2 && (verts[0] == verts[(count-1)*2]) && (verts[1] == verts[(count*2)-1])) {
|
||||
/* GL_LINE_LOOP takes care of the final segment */
|
||||
data->glDrawArrays(GL_LINE_LOOP, 0, (GLsizei) (count - 1));
|
||||
} else {
|
||||
data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) count);
|
||||
/* We need to close the endpoint of the line */
|
||||
data->glDrawArrays(GL_POINTS, (GLsizei) (count - 1), 1);
|
||||
}
|
||||
data->glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) count);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1977,7 +2011,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR);
|
||||
|
||||
if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
|
||||
if (SDL_RecreateWindow(window, (window_flags & ~(SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)) | SDL_WINDOW_OPENGL) < 0) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@@ -2099,7 +2133,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
renderer->QueueSetViewport = GLES2_QueueSetViewport;
|
||||
renderer->QueueSetDrawColor = GLES2_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
renderer->QueueDrawPoints = GLES2_QueueDrawPoints;
|
||||
renderer->QueueDrawLines = GLES2_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueDrawLines = GLES2_QueueDrawLines;
|
||||
renderer->QueueFillRects = GLES2_QueueFillRects;
|
||||
renderer->QueueCopy = GLES2_QueueCopy;
|
||||
renderer->QueueCopyEx = GLES2_QueueCopyEx;
|
||||
|
Reference in New Issue
Block a user