Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
396 views
in Technique[技术] by (71.8m points)

iphone - Displaying an EAGLView with transparent background on a UIImageView

I have an EAGLView displaying an OpenGL 3D model, and a UIImageView displaying an image.



What I want is to display EAGLView above that UIImageView with transparent background.

Is there any way to display this 3D model with transparent background, on top of the UIImageView.

Any solution would be appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For reference, most of the accepted answer is unnecessary. The only key part is this (in the UIViewController - no need to edit or subclass EAGLView / GLKView):

self.view.opaque = NO; // NB: Apple DELETES THIS VALUE FROM NIB
self.view.backgroundColor = [UIColor clearColor]; // Optional: you can do this in NIB instead

You can set the background Color in the NIB - but you CANNOT set the opacity (Apple seems to overwrite this var for GL views at initWithCoder :( )

Plus, of course, in your OpenGL code you need to clear to alpha=0.0. So, wherever your glClear / glClearColor calls are already, replace the clearColor with:

glClearColor( 0, 0, 0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...