Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mediastreamer2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BC
public
mediastreamer2
Commits
6fe0ff91
Commit
6fe0ff91
authored
Feb 08, 2012
by
Pierre-Eric Pelloux-Prayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ios: do not recreate ios gl view on rotate
parent
03008484
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
19 deletions
+47
-19
iosdisplay.h
src/iosdisplay.h
+1
-0
iosdisplay.m
src/iosdisplay.m
+46
-19
No files found.
src/iosdisplay.h
View file @
6fe0ff91
...
...
@@ -36,6 +36,7 @@
GLuint
defaultFrameBuffer
,
colorRenderBuffer
;
struct
opengles_display
*
helper
;
BOOL
glInitDone
;
BOOL
storageAllocationDone
;
id
displayLink
;
...
...
src/iosdisplay.m
View file @
6fe0ff91
...
...
@@ -88,6 +88,7 @@
[
EAGLContext
setCurrentContext
:
nil
];
glInitDone
=
FALSE
;
storageAllocationDone
=
FALSE
;
}
-
(
void
)
drawView
:
(
id
)
sender
...
...
@@ -101,7 +102,6 @@
ms_error
(
"Failed to bind GL context"
);
return
;
}
glBindFramebuffer
(
GL_FRAMEBUFFER
,
defaultFrameBuffer
);
if
(
!
glInitDone
)
{
...
...
@@ -117,18 +117,25 @@
-
(
void
)
layoutSubviews
{
[
EAGLContext
setCurrentContext
:
context
];
if
(
!
storageAllocationDone
)
{
[
EAGLContext
setCurrentContext
:
context
];
int
width
,
height
;
glBindRenderbuffer
(
GL_RENDERBUFFER
,
colorRenderBuffer
);
CAEAGLLayer
*
layer
=
(
CAEAGLLayer
*
)
self
.
layer
;
[
context
renderbufferStorage
:
GL_RENDERBUFFER
fromDrawable
:
layer
];
glGetRenderbufferParameteriv
(
GL_RENDERBUFFER
,
GL_RENDERBUFFER_WIDTH
,
&
width
);
glGetRenderbufferParameteriv
(
GL_RENDERBUFFER
,
GL_RENDERBUFFER_HEIGHT
,
&
height
);
ogl_display_init
(
helper
,
width
,
height
);
int
width
,
height
;
glBindRenderbuffer
(
GL_RENDERBUFFER
,
colorRenderBuffer
);
CAEAGLLayer
*
layer
=
(
CAEAGLLayer
*
)
self
.
layer
;
if
(
!
[
context
renderbufferStorage
:
GL_RENDERBUFFER
fromDrawable
:
layer
])
{
NSLog
(
@"Error in renderbufferStorage"
);
}
glGetRenderbufferParameteriv
(
GL_RENDERBUFFER
,
GL_RENDERBUFFER_WIDTH
,
&
width
);
glGetRenderbufferParameteriv
(
GL_RENDERBUFFER
,
GL_RENDERBUFFER_HEIGHT
,
&
height
);
storageAllocationDone
=
TRUE
;
ogl_display_init
(
helper
,
self
.
superview
.
frame
.
size
.
width
,
self
.
superview
.
frame
.
size
.
height
);
//ogl_display_init(helper, width, height);
}
else
{
ogl_display_init
(
helper
,
self
.
superview
.
frame
.
size
.
width
,
self
.
superview
.
frame
.
size
.
height
);
}
glInitDone
=
TRUE
;
}
...
...
@@ -136,7 +143,17 @@
{
if
(
!
animating
)
{
[
self
.
imageView
addSubview
:
self
];
if
(
self
.
superview
!=
self
.
imageView
)
{
// remove from old parent
[
self
removeFromSuperview
];
// add to new parent
[
self
.
imageView
addSubview
:
self
];
}
// we use a square view, so we need to offset it
// the GL code draws in the bottom-left corner
[
self
setCenter
:
CGPointMake
(
self
.
frame
.
size
.
width
*
0
.
5
,
self
.
frame
.
size
.
height
*
0
.
5
-
(
self
.
frame
.
size
.
height
-
self
.
superview
.
frame
.
size
.
height
))];
[
self
layoutSubviews
];
displayLink
=
[
self
.
window
.
screen
displayLinkWithTarget
:
self
selector
:
@selector
(
drawView
:
)];
...
...
@@ -153,7 +170,7 @@
{
[
displayLink
release
];
displayLink
=
nil
;
animating
=
TRU
E
;
animating
=
FALS
E
;
[
self
removeFromSuperview
];
}
...
...
@@ -207,16 +224,26 @@ static void iosdisplay_unit(MSFilter *f){
}
/*filter specific method*/
/* This methods declare the PARENT window of the opengl view.
We'll create on gl view for once, and then simply change its parent.
This works only if parent size is the size in all possible orientation.
*/
static
int
iosdisplay_set_native_window
(
MSFilter
*
f
,
void
*
arg
)
{
UIView
*
parentView
=
*
(
UIView
**
)
arg
;
IOSDisplay
*
thiz
;
if
(
f
->
data
!=
nil
)
{
NSLog
(
@"%@"
,
@"Multiple calls to iosdisplay_set_native_window
\n
"
);
NSLog
(
@"OpenGL view parent changed."
);
thiz
=
f
->
data
;
[
thiz
performSelectorOnMainThread
:
@selector
(
stopRendering
:)
withObject
:
nil
waitUntilDone
:
NO
];
}
else
if
(
parentView
==
nil
)
{
return
0
;
}
else
{
// we need to allocate a square view as it'll be used in portrait/landscape mode
// (in landscape mode, height become width etc...)
int
maxDim
=
MAX
(
parentView
.
frame
.
size
.
width
,
parentView
.
frame
.
size
.
height
);
thiz
=
f
->
data
=
[[
IOSDisplay
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
maxDim
,
maxDim
)];
}
f
->
data
=
[[
IOSDisplay
alloc
]
initWithFrame
:[
parentView
bounds
]];
IOSDisplay
*
thiz
=
f
->
data
;
thiz
.
imageView
=
parentView
;
[
thiz
performSelectorOnMainThread
:
@selector
(
startRendering
:)
withObject
:
nil
waitUntilDone
:
NO
];
...
...
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