Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
63918281
Commit
63918281
authored
Feb 01, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed spacing
parent
b13cdc5d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
100 deletions
+96
-100
SDL_uikitopenglview.m
src/video/uikit/SDL_uikitopenglview.m
+96
-100
No files found.
src/video/uikit/SDL_uikitopenglview.m
View file @
63918281
...
@@ -37,128 +37,124 @@
...
@@ -37,128 +37,124 @@
@synthesize
context
;
@synthesize
context
;
+
(
Class
)
layerClass
{
+
(
Class
)
layerClass
{
return
[
CAEAGLLayer
class
];
return
[
CAEAGLLayer
class
];
}
}
-
(
id
)
initWithFrame
:
(
CGRect
)
frame
\
-
(
id
)
initWithFrame
:
(
CGRect
)
frame
\
retainBacking
:
(
BOOL
)
retained
\
retainBacking
:
(
BOOL
)
retained
\
rBits
:
(
int
)
rBits
\
rBits
:
(
int
)
rBits
\
gBits
:
(
int
)
gBits
\
gBits
:
(
int
)
gBits
\
bBits
:
(
int
)
bBits
\
bBits
:
(
int
)
bBits
\
aBits
:
(
int
)
aBits
\
aBits
:
(
int
)
aBits
\
depthBits
:
(
int
)
depthBits
\
depthBits
:
(
int
)
depthBits
\
{
{
NSString
*
colorFormat
=
nil
;
NSString
*
colorFormat
=
nil
;
GLuint
depthBufferFormat
;
GLuint
depthBufferFormat
;
BOOL
useDepthBuffer
;
BOOL
useDepthBuffer
;
if
(
rBits
==
8
&&
gBits
==
8
&&
bBits
==
8
)
{
if
(
rBits
==
8
&&
gBits
==
8
&&
bBits
==
8
)
{
/* if user specifically requests rbg888 or some color format higher than 16bpp */
/* if user specifically requests rbg888 or some color format higher than 16bpp */
colorFormat
=
kEAGLColorFormatRGBA8
;
colorFormat
=
kEAGLColorFormatRGBA8
;
}
}
else
{
else
{
/* default case (faster) */
/* default case (faster) */
colorFormat
=
kEAGLColorFormatRGB565
;
colorFormat
=
kEAGLColorFormatRGB565
;
}
}
if
(
depthBits
==
24
)
{
if
(
depthBits
==
24
)
{
useDepthBuffer
=
YES
;
useDepthBuffer
=
YES
;
depthBufferFormat
=
GL_DEPTH_COMPONENT24_OES
;
depthBufferFormat
=
GL_DEPTH_COMPONENT24_OES
;
}
}
else
if
(
depthBits
==
0
)
{
else
if
(
depthBits
==
0
)
{
useDepthBuffer
=
NO
;
useDepthBuffer
=
NO
;
}
}
else
{
else
{
/* default case when depth buffer is not disabled */
/* default case when depth buffer is not disabled */
/*
/*
strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone.
strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone.
perhaps that's the only depth format iPhone actually supports
perhaps that's the only depth format iPhone actually supports
*/
*/
useDepthBuffer
=
YES
;
useDepthBuffer
=
YES
;
depthBufferFormat
=
GL_DEPTH_COMPONENT16_OES
;
depthBufferFormat
=
GL_DEPTH_COMPONENT16_OES
;
}
}
if
((
self
=
[
super
initWithFrame
:
frame
]))
{
if
((
self
=
[
super
initWithFrame
:
frame
]))
{
// Get the layer
// Get the layer
CAEAGLLayer
*
eaglLayer
=
(
CAEAGLLayer
*
)
self
.
layer
;
CAEAGLLayer
*
eaglLayer
=
(
CAEAGLLayer
*
)
self
.
layer
;
eaglLayer
.
opaque
=
YES
;
eaglLayer
.
opaque
=
YES
;
eaglLayer
.
drawableProperties
=
[
NSDictionary
dictionaryWithObjectsAndKeys
:
eaglLayer
.
drawableProperties
=
[
NSDictionary
dictionaryWithObjectsAndKeys
:
[
NSNumber
numberWithBool
:
retained
],
kEAGLDrawablePropertyRetainedBacking
,
colorFormat
,
kEAGLDrawablePropertyColorFormat
,
nil
];
[
NSNumber
numberWithBool
:
retained
],
kEAGLDrawablePropertyRetainedBacking
,
colorFormat
,
kEAGLDrawablePropertyColorFormat
,
nil
];
context
=
[[
EAGLContext
alloc
]
initWithAPI
:
kEAGLRenderingAPIOpenGLES1
];
context
=
[[
EAGLContext
alloc
]
initWithAPI
:
kEAGLRenderingAPIOpenGLES1
];
if
(
!
context
||
!
[
EAGLContext
setCurrentContext
:
context
])
{
if
(
!
context
||
!
[
EAGLContext
setCurrentContext
:
context
])
{
[
self
release
];
[
self
release
];
return
nil
;
return
nil
;
}
}
/* create the buffers */
/* create the buffers */
glGenFramebuffersOES
(
1
,
&
viewFramebuffer
);
glGenFramebuffersOES
(
1
,
&
viewFramebuffer
);
glGenRenderbuffersOES
(
1
,
&
viewRenderbuffer
);
glGenRenderbuffersOES
(
1
,
&
viewRenderbuffer
);
glBindFramebufferOES
(
GL_FRAMEBUFFER_OES
,
viewFramebuffer
);
glBindFramebufferOES
(
GL_FRAMEBUFFER_OES
,
viewFramebuffer
);
glBindRenderbufferOES
(
GL_RENDERBUFFER_OES
,
viewRenderbuffer
);
glBindRenderbufferOES
(
GL_RENDERBUFFER_OES
,
viewRenderbuffer
);
[
context
renderbufferStorage
:
GL_RENDERBUFFER_OES
fromDrawable
:(
CAEAGLLayer
*
)
self
.
layer
];
[
context
renderbufferStorage
:
GL_RENDERBUFFER_OES
fromDrawable
:(
CAEAGLLayer
*
)
self
.
layer
];
glFramebufferRenderbufferOES
(
GL_FRAMEBUFFER_OES
,
GL_COLOR_ATTACHMENT0_OES
,
GL_RENDERBUFFER_OES
,
viewRenderbuffer
);
glFramebufferRenderbufferOES
(
GL_FRAMEBUFFER_OES
,
GL_COLOR_ATTACHMENT0_OES
,
GL_RENDERBUFFER_OES
,
viewRenderbuffer
);
glGetRenderbufferParameterivOES
(
GL_RENDERBUFFER_OES
,
GL_RENDERBUFFER_WIDTH_OES
,
&
backingWidth
);
glGetRenderbufferParameterivOES
(
GL_RENDERBUFFER_OES
,
GL_RENDERBUFFER_WIDTH_OES
,
&
backingWidth
);
glGetRenderbufferParameterivOES
(
GL_RENDERBUFFER_OES
,
GL_RENDERBUFFER_HEIGHT_OES
,
&
backingHeight
);
glGetRenderbufferParameterivOES
(
GL_RENDERBUFFER_OES
,
GL_RENDERBUFFER_HEIGHT_OES
,
&
backingHeight
);
if
(
useDepthBuffer
)
{
if
(
useDepthBuffer
)
{
glGenRenderbuffersOES
(
1
,
&
depthRenderbuffer
);
glGenRenderbuffersOES
(
1
,
&
depthRenderbuffer
);
glBindRenderbufferOES
(
GL_RENDERBUFFER_OES
,
depthRenderbuffer
);
glBindRenderbufferOES
(
GL_RENDERBUFFER_OES
,
depthRenderbuffer
);
glRenderbufferStorageOES
(
GL_RENDERBUFFER_OES
,
depthBufferFormat
,
backingWidth
,
backingHeight
);
glRenderbufferStorageOES
(
GL_RENDERBUFFER_OES
,
depthBufferFormat
,
backingWidth
,
backingHeight
);
glFramebufferRenderbufferOES
(
GL_FRAMEBUFFER_OES
,
GL_DEPTH_ATTACHMENT_OES
,
GL_RENDERBUFFER_OES
,
depthRenderbuffer
);
glFramebufferRenderbufferOES
(
GL_FRAMEBUFFER_OES
,
GL_DEPTH_ATTACHMENT_OES
,
GL_RENDERBUFFER_OES
,
depthRenderbuffer
);
}
}
if
(
glCheckFramebufferStatusOES
(
GL_FRAMEBUFFER_OES
)
!=
GL_FRAMEBUFFER_COMPLETE_OES
)
{
if
(
glCheckFramebufferStatusOES
(
GL_FRAMEBUFFER_OES
)
!=
GL_FRAMEBUFFER_COMPLETE_OES
)
{
return
NO
;
return
NO
;
}
}
/* end create buffers */
/* end create buffers */
}
}
return
self
;
return
self
;
}
}
-
(
void
)
setCurrentContext
{
-
(
void
)
setCurrentContext
{
[
EAGLContext
setCurrentContext
:
context
];
[
EAGLContext
setCurrentContext
:
context
];
}
}
-
(
void
)
swapBuffers
{
-
(
void
)
swapBuffers
{
glBindRenderbufferOES
(
GL_RENDERBUFFER_OES
,
viewRenderbuffer
);
glBindRenderbufferOES
(
GL_RENDERBUFFER_OES
,
viewRenderbuffer
);
[
context
presentRenderbuffer
:
GL_RENDERBUFFER_OES
];
[
context
presentRenderbuffer
:
GL_RENDERBUFFER_OES
];
}
}
-
(
void
)
layoutSubviews
{
-
(
void
)
layoutSubviews
{
[
EAGLContext
setCurrentContext
:
context
];
[
EAGLContext
setCurrentContext
:
context
];
}
}
-
(
void
)
destroyFramebuffer
{
-
(
void
)
destroyFramebuffer
{
glDeleteFramebuffersOES
(
1
,
&
viewFramebuffer
);
glDeleteFramebuffersOES
(
1
,
&
viewFramebuffer
);
viewFramebuffer
=
0
;
viewFramebuffer
=
0
;
glDeleteRenderbuffersOES
(
1
,
&
viewRenderbuffer
);
glDeleteRenderbuffersOES
(
1
,
&
viewRenderbuffer
);
viewRenderbuffer
=
0
;
viewRenderbuffer
=
0
;
if
(
depthRenderbuffer
)
{
if
(
depthRenderbuffer
)
{
glDeleteRenderbuffersOES
(
1
,
&
depthRenderbuffer
);
glDeleteRenderbuffersOES
(
1
,
&
depthRenderbuffer
);
depthRenderbuffer
=
0
;
depthRenderbuffer
=
0
;
}
}
}
}
-
(
void
)
dealloc
{
-
(
void
)
dealloc
{
[
self
destroyFramebuffer
];
[
self
destroyFramebuffer
];
if
([
EAGLContext
currentContext
]
==
context
)
{
if
([
EAGLContext
currentContext
]
==
context
)
{
[
EAGLContext
setCurrentContext
:
nil
];
[
EAGLContext
setCurrentContext
:
nil
];
}
}
[
context
release
];
[
context
release
];
[
super
dealloc
];
[
super
dealloc
];
}
}
@end
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment