Skip to content

Commit b2fc8dc

Browse files
committed
idk
1 parent b9a8383 commit b2fc8dc

3 files changed

Lines changed: 23 additions & 53 deletions

File tree

‎project/lib/sdl/src/video/uikit/SDL_uikitopengles.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ SDL_FunctionPointer UIKit_GL_GetProcAddress(SDL_VideoDevice *_this, const char *
4444
bool UIKit_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context)
4545
{
4646
@autoreleasepool {
47-
SDL_uikitopenglview *view = (__bridge_transfer SDL_uikitopenglview *)context;
47+
SDL_uikitopenglview *view = (__bridge SDL_uikitopenglview *)context;
4848

4949
if (!view || !eglMakeCurrent(view.eglDisplay, view.eglSurface, view.eglSurface, view.eglContext)) {
5050
return SDL_SetError("Could not make EGL context current");

‎project/lib/sdl/src/video/uikit/SDL_uikitopenglview.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#import <EGL/eglext.h>
2727
#import <GLES2/gl2.h>
2828
#import <GLES2/gl2ext.h>
29+
#import <GLES3/gl3.h>
2930
#import <Metal/Metal.h>
3031

3132
#import "SDL_uikitview.h"

‎project/lib/sdl/src/video/uikit/SDL_uikitopenglview.m‎

Lines changed: 21 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
2. Altered source versions must be plainly marked as such, and must not be
1818
misrepresented as being the original software.
1919
3. This notice may not be removed or altered from any source distribution.
20-
*/
20+
*/
2121
#include "SDL_internal.h"
2222

2323
#if defined(SDL_VIDEO_DRIVER_UIKIT) && (defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2))
@@ -26,6 +26,8 @@
2626
#include <EGL/eglext.h>
2727
#include <GLES2/gl2.h>
2828
#include <GLES2/gl2ext.h>
29+
#include <GLES3/gl3.h>
30+
#include <GLES3/gl3ext.h>
2931
#include <Metal/Metal.h>
3032
#import "SDL_uikitopenglview.h"
3133
#include "SDL_uikitwindow.h"
@@ -35,7 +37,6 @@ @implementation SDL_uikitopenglview
3537
EGLDisplay eglDisplay;
3638
EGLSurface eglSurface;
3739
EGLContext eglContext;
38-
EGLSurface eglPbufferSurface;
3940

4041
GLuint viewRenderbuffer, viewFramebuffer;
4142
GLuint depthRenderbuffer;
@@ -91,7 +92,7 @@ - (instancetype)initWithFrame:(CGRect)frame
9192

9293
self.contentScaleFactor = scale;
9394

94-
eglDisplay = eglGetDisplay((EGLNativeDisplayType)metalLayer.device);
95+
eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
9596
if (eglDisplay == EGL_NO_DISPLAY) {
9697
SDL_SetError("Could not create EGL display");
9798
return nil;
@@ -141,7 +142,7 @@ - (instancetype)initWithFrame:(CGRect)frame
141142
EGL_HEIGHT, (int)(frame.size.height * scale),
142143
EGL_NONE
143144
};
144-
eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, (EGLNativeWindowType)metalLayer, surfaceAttribs);
145+
eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, (__bridge EGLNativeWindowType)metalLayer, surfaceAttribs);
145146
if (eglSurface == EGL_NO_SURFACE) {
146147
SDL_SetError("Could not create EGL surface");
147148
return nil;
@@ -153,9 +154,13 @@ - (instancetype)initWithFrame:(CGRect)frame
153154
}
154155

155156
if (samples > 0) {
156-
GLint maxsamples = 0;
157-
glGetIntegerv(GL_MAX_SAMPLES, &maxsamples);
158-
samples = SDL_min(samples, maxsamples);
157+
EGLint maxsamples = 0;
158+
eglGetConfigAttrib(eglDisplay, eglConfig, EGL_SAMPLES, &maxsamples);
159+
if (maxsamples > 0) {
160+
samples = SDL_min(samples, (int)maxsamples);
161+
} else {
162+
samples = 0;
163+
}
159164
}
160165

161166
backingWidth = (int)(frame.size.width * scale);
@@ -192,7 +197,7 @@ - (instancetype)initWithFrame:(CGRect)frame
192197

193198
glGenRenderbuffers(1, &msaaRenderbuffer);
194199
glBindRenderbuffer(GL_RENDERBUFFER, msaaRenderbuffer);
195-
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_RGBA8, backingWidth, backingHeight);
200+
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB, backingWidth, backingHeight);
196201

197202
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, msaaRenderbuffer);
198203
}
@@ -247,62 +252,26 @@ - (void)updateFrame
247252

248253
if (depthRenderbuffer != 0) {
249254
glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
250-
if (samples > 0) {
251-
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, depthBufferFormat, backingWidth, backingHeight);
252-
} else {
253-
glRenderbufferStorage(GL_RENDERBUFFER, depthBufferFormat, backingWidth, backingHeight);
254-
}
255+
glRenderbufferStorage(GL_RENDERBUFFER, depthBufferFormat, backingWidth, backingHeight);
255256
}
256257

257258
if (msaaRenderbuffer != 0) {
258259
glBindRenderbuffer(GL_RENDERBUFFER, msaaRenderbuffer);
259-
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_RGBA8, backingWidth, backingHeight);
260-
}
261-
}
262-
263-
- (void)setDebugLabels
264-
{
265-
if (viewFramebuffer != 0) {
266-
glLabelObjectEXT(GL_FRAMEBUFFER, viewFramebuffer, 0, "context FBO");
267-
}
268-
269-
if (viewRenderbuffer != 0) {
270-
glLabelObjectEXT(GL_RENDERBUFFER, viewRenderbuffer, 0, "context color buffer");
271-
}
272-
273-
if (depthRenderbuffer != 0) {
274-
if (depthBufferFormat == GL_DEPTH24_STENCIL8_OES) {
275-
glLabelObjectEXT(GL_RENDERBUFFER, depthRenderbuffer, 0, "context depth-stencil buffer");
276-
} else {
277-
glLabelObjectEXT(GL_RENDERBUFFER, depthRenderbuffer, 0, "context depth buffer");
278-
}
279-
}
280-
281-
if (msaaFramebuffer != 0) {
282-
glLabelObjectEXT(GL_FRAMEBUFFER, msaaFramebuffer, 0, "context MSAA FBO");
283-
}
284-
285-
if (msaaRenderbuffer != 0) {
286-
glLabelObjectEXT(GL_RENDERBUFFER, msaaRenderbuffer, 0, "context MSAA renderbuffer");
260+
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB, backingWidth, backingHeight);
287261
}
288262
}
289263

290264
- (void)swapBuffers
291265
{
292266
if (msaaFramebuffer) {
293-
const GLenum attachments[] = { GL_COLOR_ATTACHMENT0 };
294-
295-
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, viewFramebuffer);
296-
glBlitFramebuffer(0, 0, backingWidth, backingHeight, 0, 0, backingWidth, backingHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
297-
298-
if (!retainedBacking) {
299-
glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 1, attachments);
300-
}
301-
302-
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, msaaFramebuffer);
267+
glBindFramebuffer(GL_FRAMEBUFFER, viewFramebuffer);
303268
}
304269

305270
eglSwapBuffers(eglDisplay, eglSurface);
271+
272+
if (msaaFramebuffer) {
273+
glBindFramebuffer(GL_FRAMEBUFFER, msaaFramebuffer);
274+
}
306275
}
307276

308277
- (void)layoutSubviews
@@ -382,4 +351,4 @@ - (void)dealloc
382351

383352
@end
384353

385-
#endif // SDL_VIDEO_DRIVER_UIKIT
354+
#endif // SDL_VIDEO_DRIVER_UIKIT

0 commit comments

Comments
 (0)