0

I am trying to use OpenGL to paint a view which is a subview of another view. I have created a view class for this purpose, and if I use this class in a simple test application it works fine. However, if I place an instance of this class on a particular page of my app, the OpenGL painting does not display anything. I am certain that the view is visible (I can set a background color, and that is displayed, and I can receive touch events). I can also trace through the OpenGL initialization and paint routines, and everything seems fine. My paint routine IS being called, and I call glGetError frequently and no errors are returned. I can compare tracing the routine with the case that works, and everything seems pretty much the same, but nothing paints (I even have simply tried doing nothing but clearing the window to black but that does nothing either).

The code for the app that does not work is far to complex to post here. I assume that I am doing something wrong, but for the life of me I cannot figure out what. Can anyone give me any ideas about why the OpenGL painting would appear to succeed and yet not draw anything, or suggest a strategy for figuring this out?

Thanks.

1 Answer 1

0

The link between OpenGL and the outside world is platform specific and not part of the core API. So a problem there wouldn't affect the result of glGetError.

In the case of iOS the relevant call is EAGLContext -presentRenderbuffer:, which will work provided you've used renderbufferStorage:fromDrawable: to create storage for a render buffer from a CAEAGLLayer. You probably want to inspect the return result of presentRenderbuffer: and the code around that to look for an error rather than the internal GL state.

3
  • Thanks for taking a look at it. I do use renderbufferStorage:fromDrawable to create the storage and the call to presentRenderbuffer returns 'YES'. As I said, this exact class works elsewhere, so there is something that I am doing on this particular view that is causing the problem, but I cannot fathom what it is.
    – John Gaby
    Sep 4, 2011 at 0:39
  • In that case is it possible you've used a UIView subclass that implicitly creates a brand new EAGLContext per view, then been unattentive about which context you're creating resources in? If they're not in a sharegroup then resources aren't portable.
    – Tommy
    Sep 4, 2011 at 5:25
  • I encountered a similar problem. SignatureView library from git hub works when used in a demo project but not in mine. In the end I discover that I have to set glColor4f to some non transparent colour before the lines shows. The demo project did not set this colour.
    – Cymric
    Jun 22, 2015 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.