Access violation in GeForceGLDriver (OS X 10.10.2, NVIDIA)

Hey all,

We are doing some internal testing and we have several machines where an EXC_BAD_ACCESS occurs inside the GeForceGLDriver.

What all those machines have in common is that they have NVidia cards and are running Yosemite. I tried an older machine with a NVidia card running 10.9.2 and that works fine. On Windows rendering works fine with NVidia cards.

Does anybody know more about this? Am I doing something wrong while rendering or is this a driver bug? I’ve been trying different ways of rendering, but haven’t been able to find a workaround yet. Does anybody know a workaround?

NVIDIA Corporation
NVIDIA GeForce GT 750M OpenGL Engine
4.1 NVIDIA-10.2.1 310.41.15f01
4.10

Here is part of a crash rapport:

Process: Frontend [616]
Path: /Applications/IFCviewer KUBUS/*/Frontend.app/Contents/MacOS/Frontend
Identifier: Kubus.Frontend
Version: 1.0 (1)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Frontend [616]
User ID: 501

Date/Time: 2015-04-03 11:35:40.797 +0200
OS Version: Mac OS X 10.10.2 (14C1514)
Report Version: 11
Anonymous UUID: 00F4257A-5DD5-4939-85E6-08230642EC2A

Time Awake Since Boot: 930 seconds

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008

VM Regions Near 0x8:

__TEXT 000000010158e000-0000000101c61000 [ 6988K] r-x/rwx SM=COW /Applications/IFCviewer KUBUS/*/Frontend.app/Contents/MacOS/Frontend

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.GeForceGLDriver 0x000012344025a36b gldReadTextureData + 202073
1 com.apple.GeForceGLDriver 0x000012344023c7d6 gldReadTextureData + 80324
2 com.apple.GeForceGLDriver 0x0000123440259db8 gldReadTextureData + 200614
3 com.apple.GeForceGLDriver 0x000012344001b0aa 0x123440000000 + 110762
4 com.apple.GeForceGLDriver 0x000012344001c160 0x123440000000 + 115040
5 com.apple.GeForceGLDriver 0x00001234400220eb 0x123440000000 + 139499
6 com.apple.GeForceGLDriver 0x00001234400227a2 0x123440000000 + 141218
7 com.apple.GeForceGLDriver 0x000012344032bb20 gldBlitFramebufferData + 66936
8 com.apple.GeForceGLDriver 0x000012344032c372 gldBlitFramebufferData + 69066
9 com.apple.GeForceGLDriver 0x000012344032c985 gldBlitFramebufferData + 70621
10 com.apple.GeForceGLDriver 0x00001234402286e5 gldUnbindPipelineProgram + 3567
11 com.apple.GeForceGLDriver 0x000012344032b719 gldBlitFramebufferData + 65905
12 com.apple.GeForceGLDriver 0x0000123440319dc6 gldUpdateDispatch + 864
13 GLEngine 0x00007fff905ae315 gleDoDrawDispatchCoreGL3 + 536
14 GLEngine 0x00007fff9055eabb gleDrawArraysOrElements_Entries_Body + 128
15 GLEngine 0x00007fff9055bd9e glDrawElementsBaseVertex_GL3Exec + 208
16 Kubus.Frontend 0x0000000101609ba1 Viewer::OpenGLRenderSystem::RenderIndexedGeometry(Viewer::RenderMode, Viewer::Mesh*) + 41
17 Kubus.Frontend 0x0000000101609e9f Viewer::OpenGLRenderSystem::Render(Viewer::CameraController const*, std::__1::vector<Viewer::Light*, std::__1::allocator<Viewer::Light*> > const&, Viewer::ClippingPlane const**, float, Viewer::Entity*, Viewer::Mesh*, Viewer::Material*) + 183
18 Kubus.Frontend 0x0000000101609d65 Viewer::OpenGLRenderSystem::Render(Viewer::CameraController const*, std::__1::vector<Viewer::Light*, std::__1::allocator<Viewer::Light*> > const&, Viewer::ClippingPlane const**, float, Viewer::RenderQueue*) + 271
19 Kubus.Frontend 0x00000001015ba83a Viewer::IfcViewer::Draw() + 214
20 Kubus.Frontend 0x00000001015b839f -[ModelView drawRect:] + 182
21 com.apple.AppKit 0x00007fff83c5db19 -[NSView _drawRect:clip:] + 4238
22 com.apple.AppKit 0x00007fff83c5c17a -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1875
23 com.apple.AppKit 0x00007fff83c5a016 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 913
24 com.apple.AppKit 0x00007fff83c5b420 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 6043
25 com.apple.AppKit 0x00007fff83c5b420 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 6043
26 com.apple.AppKit 0x00007fff83c5b420 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 6043
27 com.apple.AppKit 0x00007fff83c59773 -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 333
28 com.apple.AppKit 0x00007fff83c562cb -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 2761
29 com.apple.AppKit 0x00007fff83c34e2d -[NSView displayIfNeeded] + 1876
30 com.apple.AppKit 0x00007fff83c521c5 -[NSWindow displayIfNeeded] + 232
31 com.apple.AppKit 0x00007fff83c8f322 _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 936
32 com.apple.AppKit 0x00007fff842580e1 __83-[NSWindow _postWindowNeedsDisplayOrLayoutOrUpdateConstraintsUnlessPostingDisabled]_block_invoke1531 + 46
33 com.apple.CoreFoundation 0x00007fff85e4eda7 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
34 com.apple.CoreFoundation 0x00007fff85e4ed00 __CFRunLoopDoObservers + 368
35 com.apple.CoreFoundation 0x00007fff85e40e08 __CFRunLoopRun + 872
36 com.apple.CoreFoundation 0x00007fff85e40858 CFRunLoopRunSpecific + 296
37 com.apple.HIToolbox 0x00007fff87d87aef RunCurrentEventLoopInMode + 235
38 com.apple.HIToolbox 0x00007fff87d8786a ReceiveNextEventCommon + 431
39 com.apple.HIToolbox 0x00007fff87d876ab _BlockUntilNextEventMatchingListInModeWithFilter + 71
40 com.apple.AppKit 0x00007fff83b2ff81 _DPSNextEvent + 964
41 com.apple.AppKit 0x00007fff83b2f730 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194
42 com.apple.AppKit 0x00007fff83b23593 -[NSApplication run] + 594
43 com.apple.AppKit 0x00007fff83b0ea14 NSApplicationMain + 1832
44 libdyld.dylib 0x00007fff8b9015c9 start + 1

Greets,

Floris

[QUOTE=CainitePrince;1265845]We are doing some internal testing and we have several machines where an EXC_BAD_ACCESS occurs inside the GeForce GL Driver. …
Does anybody know more about this? Am I doing something wrong while rendering or is this a driver bug? …

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008

15 GLEngine 0x00007fff9055bd9e glDrawElementsBaseVertex_GL3Exec + 208
16 Kubus.Frontend 0x0000000101609ba1 Viewer::OpenGLRenderSystem::RenderIndexedGeometry(Viewer::RenderMode, Viewer::Mesh*) + 41
17 Kubus.Frontend 0x0000000101609e9f Viewer::OpenGLRenderSystem::Render(Viewer::CameraController const*, std::__1::vector<Viewer::Light*, std::__1::allocator<Viewer::Light*> > const&, Viewer::ClippingPlane const**, float, Viewer::Entity*, Viewer::Mesh*, Viewer::Material*) + 183

[/QUOTE]

I would dump/inspect the GL batch state at your glDrawElementsBaseVertex() call. If it is your bug, I suspect you are passing a buffer offset (8) in for one of the vertex attribute arrays or index lists, but there was no buffer object bound to the appropriate buffer object bind point (e.g. ARRAY or ELEMENT_ARRAY).

Another possibility is that you have a rogue vertex attribute array you left enabled but which you thought was disabled, and the driver is reading from it potentially causing a crash.

Thanks for your response. I will see if I can inspect the OpenGL state when I have access to the hardware again.

It’s certainly possible I’m using vertex attribute arrays in a wrong way. I thought that part was very confusing. This is currently how I’m using them. I’m calling SetVertexBuffer/SetIndexBuffer once to set up the VAO. After that I only bind and unbind the VAO. Do I need to call glDisableVertexAttribArray somewhere?

    struct Vertex
    {
        float position[3];
        float normal[3];
    };

    OpenGLMesh::OpenGLMesh() : Mesh()
    {
        VERIFY(glGenVertexArrays(1, &_vao));
    }

    OpenGLMesh::~OpenGLMesh()
    {
        VERIFY(glDeleteVertexArrays(1, &_vao));
    }

    void OpenGLMesh::SetVertexBuffer(std::shared_ptr&lt;VertexBuffer&gt; vertexBuffer)
    {
        VERIFY(glBindVertexArray(_vao));

        vertexBuffer-&gt;UseBuffer();
        Mesh::SetVertexBuffer(vertexBuffer);

        //specifies what the data in the buffer is.
        VERIFY(glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) 0));

        VERIFY(glVertexAttribPointer(1,
                                     3,
                                     GL_FLOAT,
                                     GL_FALSE,
                                     sizeof(Vertex),
                                     (void*) (3 * sizeof(float))));

        //signal to OpenGL to feed the vertex data to the shader automatically.
        VERIFY(glEnableVertexAttribArray(0));
        VERIFY(glEnableVertexAttribArray(1));

        VERIFY(glBindVertexArray(0));
    }

    std::shared_ptr&lt;VertexBuffer&gt; OpenGLMesh::GetVertexBuffer()
    {
        return Mesh::GetVertexBuffer();
    }

    void OpenGLMesh::SetIndexBuffer(std::shared_ptr&lt;IndexBuffer&gt; indexBuffer)
    {
        VERIFY(glBindVertexArray(_vao));

        indexBuffer-&gt;UseBuffer();
        Mesh::SetIndexBuffer(indexBuffer);

        //specifies what the data in the buffer is.
        //glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
        VERIFY(glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) 0));
        VERIFY(glVertexAttribPointer(1,
                                     3,
                                     GL_FLOAT,
                                     GL_FALSE,
                                     sizeof(Vertex),
                                     (void*) (3 * sizeof(float))));

        //signal to OpenGL to feed the vertex data to the shader automatically.
        VERIFY(glEnableVertexAttribArray(0));
        VERIFY(glEnableVertexAttribArray(1));

        VERIFY(glBindVertexArray(0));
    }

    std::shared_ptr&lt;IndexBuffer&gt; OpenGLMesh::GetIndexBuffer()
    {
        return Mesh::GetIndexBuffer();
    }

    void OpenGLMesh::BindMesh()
    {
        VERIFY(glBindVertexArray(_vao));
    }

    void OpenGLMesh::UnbindMesh()
    {
        VERIFY(glBindVertexArray(0));
    }```

See previous posts about setting up Apple’s OpenGL Profiler. Use the “break on VAO error” checkbox to detect if your draw calls read outside the bound buffers.

(You can also do this introspection yourself, wrapping draw calls with your own debug macros.)

[QUOTE=Dark Photon;1265846]I would dump/inspect the GL batch state at your glDrawElementsBaseVertex() call. If it is your bug, I suspect you are passing a buffer offset (8) in for one of the vertex attribute arrays or index lists, but there was no buffer object bound to the appropriate buffer object bind point (e.g. ARRAY or ELEMENT_ARRAY).

Another possibility is that you have a rogue vertex attribute array you left enabled but which you thought was disabled, and the driver is reading from it potentially causing a crash.[/QUOTE]

I have used OpenGL Profiler and can’t find anything wrong with arrays, elements arrays or vertex attribute arrays. Here’s the relevant state I saved from OpenGL Profiler. There are both an array and an element array bound and two vertex attributes are active.

Arrays &lt;nil&gt;
    GL_VERTEX_ARRAY_BINDING 15
    Generic Vertex Attributes &lt;nil&gt;
            0 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_TRUE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 3
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 24
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 28
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            1 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_TRUE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 3
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 24
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x0000000c
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 28
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            2 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            3 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            4 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            5 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            6 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            7 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            8 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            9 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            10 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            11 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            12 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            13 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            14 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0
            15 &lt;nil&gt;
                            GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_SIZE 4
                            GL_VERTEX_ATTRIB_ARRAY_STRIDE 0
                            GL_VERTEX_ATTRIB_ARRAY_TYPE GL_FLOAT
                            GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_POINTER 0x00000000
                            GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0
                            GL_VERTEX_ATTRIB_ARRAY_INTEGER GL_FALSE
                            GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0

Buffer Objects &lt;nil&gt;
    GL_ARRAY_BUFFER_BINDING 23
    GL_ELEMENT_ARRAY_BUFFER_BINDING 29
    GL_PIXEL_PACK_BUFFER_BINDING 0
    GL_PIXEL_UNPACK_BUFFER_BINDING 0
    GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0
    GL_COPY_READ_BUFFER 0
    GL_COPY_WRITE_BUFFER 0

[QUOTE=arekkusu;1265848]See previous posts about setting up Apple’s OpenGL Profiler. Use the “break on VAO error” checkbox to detect if your draw calls read outside the bound buffers.

(You can also do this introspection yourself, wrapping draw calls with your own debug macros.)[/QUOTE]

I’ve used both OpenGL Profiler and gDebugger and checked all the break on OpenGL/VAO error boxes I could find. I tested this on Windows and OS X with an Intel chipset, and on OS X on a machine that has the problem. On the Intel machine it doesn’t break at all. On the Nvidia machine it crashes but I hit no breakpoints.

Interestingly, with OpenGL Profiler attached it seems to crash in a different place.

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008

VM Regions Near 0x8:
–>
__TEXT 00000001092d9000-0000000109b38000 [ 8572K] r-x/rwx SM=COW /Users/USER/Documents/*/Frontend.app/Contents/MacOS/Frontend

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.GeForceGLDriver 0x000012344025a36b 0x123440000000 + 2466667
1 com.apple.GeForceGLDriver 0x000012344023c7d6 0x123440000000 + 2344918
2 com.apple.GeForceGLDriver 0x0000123440259db8 0x123440000000 + 2465208
3 com.apple.GeForceGLDriver 0x000012344001b0aa 0x123440000000 + 110762
4 com.apple.GeForceGLDriver 0x000012344001c160 0x123440000000 + 115040
5 com.apple.GeForceGLDriver 0x00001234400220eb 0x123440000000 + 139499
6 com.apple.GeForceGLDriver 0x00001234400227a2 0x123440000000 + 141218
7 com.apple.GeForceGLDriver 0x000012344032bb20 0x123440000000 + 3324704
8 com.apple.GeForceGLDriver 0x000012344032c372 0x123440000000 + 3326834
9 com.apple.GeForceGLDriver 0x000012344032c985 0x123440000000 + 3328389
10 com.apple.GeForceGLDriver 0x00001234402286e5 0x123440000000 + 2262757
11 com.apple.GeForceGLDriver 0x000012344032b719 0x123440000000 + 3323673
12 com.apple.GeForceGLDriver 0x0000123440319dc6 gldUpdateDispatch + 864
13 GLEngine 0x00007fff91241cba gleDoSelectiveDispatchNoErrorCoreGL3 + 456
14 GLEngine 0x00007fff912d6cad gliGetInteger + 2453
15 com.apple.opengl 0x00007fff895d5eac GLCGetParameter + 361
16 com.apple.GLEngineProfiler 0x00000001115e7129 0x1115e3000 + 16681
17 com.apple.GLEngineProfiler 0x00000001115e7d6f 0x1115e3000 + 19823
18 com.apple.GLEngineProfiler 0x00000001117055cb 0x1115e3000 + 1189323
19 Kubus.Frontend 0x000000010936bc4f Viewer::OpenGLShader::UseShader() + 31 (OpenGLShader.cpp:134)
20 Kubus.Frontend 0x00000001094a6c5d Viewer::OpenGLRenderSystem::Render(Viewer::CameraController const*, std::__1::vector<Viewer::Light*, std::__1::allocator<Viewer::Light*> > const&, Viewer::ClippingPlane const**, float, Viewer::Entity*, Viewer::Mesh*, Viewer::Material*) + 125 (OpenGLRenderSystem.cpp:291)
21 Kubus.Frontend 0x00000001094a6ad2 Viewer::OpenGLRenderSystem::Render(Viewer::CameraController const*, std::__1::vector<Viewer::Light*, std::__1::allocator<Viewer::Light*> > const&, Viewer::ClippingPlane const**, float, Viewer::RenderQueue*) + 418 (OpenGLRenderSystem.cpp:265)
22 Kubus.Frontend 0x0000000109371a0e Viewer::IfcViewer::Draw() + 414 (Viewer.cpp:447)
23 Kubus.Frontend 0x000000010936961a -[ModelView drawRect:] + 282 (ModelView.mm:203)
24 com.apple.AppKit 0x00007fff8d756b19 -[NSView _drawRect:clip:] + 4238
25 com.apple.AppKit 0x00007fff8d75517a -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1875
26 com.apple.AppKit 0x00007fff8d753016 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 913
27 com.apple.AppKit 0x00007fff8d754420 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 6043
28 com.apple.AppKit 0x00007fff8d754420 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 6043
29 com.apple.AppKit 0x00007fff8d754420 -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 6043
30 com.apple.AppKit 0x00007fff8d752773 -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + 333
31 com.apple.AppKit 0x00007fff8d74f2cb -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 2761
32 com.apple.AppKit 0x00007fff8d72de2d -[NSView displayIfNeeded] + 1876
33 com.apple.AppKit 0x00007fff8d74b1c5 -[NSWindow displayIfNeeded] + 232
34 com.apple.AppKit 0x00007fff8d788322 _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 936
35 com.apple.AppKit 0x00007fff8dd510e1 __83-[NSWindow _postWindowNeedsDisplayOrLayoutOrUpdateConstraintsUnlessPostingDisabled]_block_invoke1531 + 46
36 com.apple.CoreFoundation 0x00007fff849e6da7 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
37 com.apple.CoreFoundation 0x00007fff849e6d00 __CFRunLoopDoObservers + 368
38 com.apple.CoreFoundation 0x00007fff849d8e08 __CFRunLoopRun + 872
39 com.apple.CoreFoundation 0x00007fff849d8858 CFRunLoopRunSpecific + 296
40 com.apple.HIToolbox 0x00007fff87b6daef RunCurrentEventLoopInMode + 235
41 com.apple.HIToolbox 0x00007fff87b6d86a ReceiveNextEventCommon + 431
42 com.apple.HIToolbox 0x00007fff87b6d6ab _BlockUntilNextEventMatchingListInModeWithFilter + 71
43 com.apple.AppKit 0x00007fff8d628f81 _DPSNextEvent + 964
44 com.apple.AppKit 0x00007fff8d628730 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194
45 com.apple.AppKit 0x00007fff8d61c593 -[NSApplication run] + 594
46 com.apple.AppKit 0x00007fff8d607a14 NSApplicationMain + 1832
47 Kubus.Frontend 0x00000001092fdd42 main + 34 (main.m:13)
48 libdyld.dylib 0x00007fff8b12b5c9 start + 1

File a bug with clear steps to reproduce the problem (i.e. a copy of your application.)
Apple can symbolicate the com.apple.GeForceGLDriver backtrace and see exactly what’s happening.

[QUOTE=arekkusu;1265918]File a bug with clear steps to reproduce the problem (i.e. a copy of your application.)
Apple can symbolicate the com.apple.GeForceGLDriver backtrace and see exactly what’s happening.

[/QUOTE]

Thanks, I submitted a bug report with a small program that replicates the problem attached to it.

Here is the OpenGL code in it’s entirety:


//
//  TestProgram.m
//  NVidiaDebugProgram
//
//  Copyright (c) 2015 Kubus. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "TestProgram.h"

#include <string>

struct Vertex
{
    float position[3];
    float normal[3];
};

@implementation TestProgram

-(void) Initialize
{
    VERIFY(glDisable(GL_CULL_FACE));
    VERIFY(glFrontFace(GL_CW));
    
    //turn on depth testing
    VERIFY(glEnable(GL_DEPTH_TEST));
    VERIFY(glDepthFunc(GL_LEQUAL));
    
    //disable blending
    VERIFY(glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA));
    VERIFY(glDisable(GL_BLEND));
    
    //write to depth buffer
    VERIFY(glDepthMask(GL_TRUE));
        
    GLint maxClippingPlanes;
    VERIFY(glGetIntegerv(GL_MAX_CLIP_DISTANCES, &maxClippingPlanes));
    if (maxClippingPlanes)
    {
        //return false;
    }
    
    // Enable 6 clipping planes
    VERIFY(glEnable(GL_CLIP_DISTANCE0));
    VERIFY(glEnable(GL_CLIP_DISTANCE1));
    VERIFY(glEnable(GL_CLIP_DISTANCE2));
    VERIFY(glEnable(GL_CLIP_DISTANCE3));
    VERIFY(glEnable(GL_CLIP_DISTANCE4));
    VERIFY(glEnable(GL_CLIP_DISTANCE5));

    //create shader
    std::string geometryVertexProgram =
    "#version 150 core                                                  
"
    "                                                                   
"
    "in vec4 position;                                                  
"
    "in vec3 normal;                                                    
"
    "uniform mat4 mvp;                                                  
"
    "uniform vec4 plane1;                                               
"
    "uniform vec4 plane2;                                               
"
    "uniform vec4 plane3;                                               
"
    "uniform vec4 plane4;                                               
"
    "uniform vec4 plane5;                                               
"
    "uniform vec4 plane6;                                               
"
    "out vec4 wsPosition;                                               
"
    "out vec3 wsNormal;                                                 
"
    "                                                                   
"
    "void main(void)                                                    
"
    "{                                                                  
"
    "    wsPosition = position;                                         
"
    "    wsNormal = normal;                                             
"
    "    gl_ClipDistance[0] = dot(plane1, wsPosition);                  
"
    "    gl_ClipDistance[1] = dot(plane2, wsPosition);                  
"
    "    gl_ClipDistance[2] = dot(plane3, wsPosition);                  
"
    "    gl_ClipDistance[3] = dot(plane4, wsPosition);                  
"
    "    gl_ClipDistance[4] = dot(plane5, wsPosition);                  
"
    "    gl_ClipDistance[5] = dot(plane6, wsPosition);                  
"
    "    gl_Position = mvp * position;                                  
"
    "}                                                                  
";
    
    std::string geometryFragmentProgram =
    "#version 150 core                                                          
"
    "                                                                           
"
    "in vec4 wsPosition;                                                        
"
    "in vec3 wsNormal;                                                          
"
    "out vec4 color;                                                            
"
    "uniform vec3 lightdir1;                                                    
"
    "uniform vec3 lightdir2;                                                    
"
    "uniform vec3 lightdir3;                                                    
"
    "uniform vec3 camerapos;                                                    
"
    "uniform vec4 diffuse;                                                      
"
    "uniform vec4 ambient;                                                      
"
    "uniform vec4 specular;                                                     
"
    "uniform float shininess;                                                   
"
    "uniform float transparency;                                                
"
    "                                                                           
"
    "void main(void)                                                            
"
    "{                                                                          
"
    "  vec3 n = normalize(wsNormal.xyz);                                        
"
    "  vec3 l1 = normalize(-lightdir1);                                         
"
    "  vec3 l2 = normalize(-lightdir2);                                         
"
    "  vec3 l3 = normalize(-lightdir3);                                         
"
    "  vec3 v = normalize(camerapos - wsPosition.xyz);                          
"
    "  vec3 r1 = normalize(-reflect(l1, n));                                    
"
    "  vec3 r2 = normalize(-reflect(l2, n));                                    
"
    "  vec3 r3 = normalize(-reflect(l3, n));                                    
"
    "  //mat3 m = mat3(l1, l2, l3);                                             
"
    "  float dotNL1 = dot(n, l1);                                               
"
    "  float dotNL2 = dot(n, l2);                                               
"
    "  float dotNL3 = dot(n, l3);                                               
"
    "  float lamb1 = 0.9 * clamp(dotNL1, 0.0, 1.0);                             
"
    "  float lamb2 = 0.7 * clamp(dotNL2, 0.0, 1.0);                             
"
    "  float lamb3 = 0.5 * clamp(dotNL3, 0.0, 1.0);                             
"
    "  float phong1 = 0.9 * pow(max(dot(r1,v), 0.0), shininess);                
"
    "  float phong3 = 0.7 * pow(max(dot(r3,v), 0.0), shininess);                
"
    "  vec3 c;                                                                  
"
    "  vec3 exp = vec3(2.0, 2.0, 2.0);                                          
"
    "  c = (lamb1 + lamb2 + lamb3) * pow(diffuse.rgb, exp);                     
"
    "  c += 0.2 * pow(ambient.rgb, exp);                                        
"
    "  c += (phong1 + phong3) * pow(specular.rgb, exp);                         
"
    "  color = vec4(pow(c, vec3(1.0, 1.0, 1.0) / exp), transparency);           
"
    "}                                                                          
";

    //create shader
    _program = glCreateProgram();
    assert(glGetError() == 0);

    //set vertex program
    const GLchar *vertexSource = (const GLchar *) geometryVertexProgram.c_str();
    
    _vertexProgram = glCreateShader(GL_VERTEX_SHADER);
    assert(glGetError() == 0);
    
    VERIFY(glShaderSource(_vertexProgram, 1, &vertexSource, nullptr));
    VERIFY(glCompileShader(_vertexProgram));
    GLint isCompiled = 0;
    VERIFY(glGetShaderiv(_vertexProgram, GL_COMPILE_STATUS, &isCompiled));
    if (isCompiled == GL_FALSE)
    {
        VERIFY(glDeleteShader(_vertexProgram));
        //return false;
    }

    //set fragment program
    const GLchar *fragmentSource = (const GLchar *)geometryFragmentProgram.c_str();
    
    _fragmentProgram = glCreateShader(GL_FRAGMENT_SHADER);
    assert(glGetError() == 0);
    
    VERIFY(glShaderSource(_fragmentProgram, 1, &fragmentSource, nullptr));
    VERIFY(glCompileShader(_fragmentProgram));
    //GLint isCompiled = 0;
    VERIFY(glGetShaderiv(_fragmentProgram, GL_COMPILE_STATUS, &isCompiled));
    if (isCompiled == GL_FALSE)
    {
        VERIFY(glDeleteShader(_fragmentProgram));
        //return false;
    }
    
    //compile shader
    VERIFY(glAttachShader(_program, _vertexProgram));
    VERIFY(glAttachShader(_program, _fragmentProgram));
    
    VERIFY(glBindAttribLocation(_program, 0, "position"));
    VERIFY(glBindAttribLocation(_program, 1, "normal"));
    
    VERIFY(glLinkProgram(_program));
    
    GLint isLinked = 0;
    VERIFY(glGetProgramiv(_program, GL_LINK_STATUS, &isLinked));
    if (isLinked == GL_FALSE)
    {
        //return false;
    }
    
    VERIFY(glDetachShader(_program, _vertexProgram));
    VERIFY(glDeleteShader(_vertexProgram));
    
    VERIFY(glDetachShader(_program, _fragmentProgram));
    VERIFY(glDeleteShader(_fragmentProgram));

    //initialize parameters
    _mvp            = glGetUniformLocation(_program, "mvp");
    _lightdir1      = glGetUniformLocation(_program, "lightdir1");
    _lightdir2      = glGetUniformLocation(_program, "lightdir2");
    _lightdir3      = glGetUniformLocation(_program, "lightdir3");
    _camerapos      = glGetUniformLocation(_program, "camerapos");
    _diffuse        = glGetUniformLocation(_program, "diffuse");
    _ambient        = glGetUniformLocation(_program, "ambient");
    _specular       = glGetUniformLocation(_program, "specular");
    _shininess      = glGetUniformLocation(_program, "shininess");
    _transparency   = glGetUniformLocation(_program, "transparency");
    _plane1         = glGetUniformLocation(_program, "plane1");
    _plane2         = glGetUniformLocation(_program, "plane2");
    _plane3         = glGetUniformLocation(_program, "plane3");
    _plane4         = glGetUniformLocation(_program, "plane4");
    _plane5         = glGetUniformLocation(_program, "plane5");
    _plane6         = glGetUniformLocation(_program, "plane6");
    
    //create mesh
    VERIFY(glGenVertexArrays(1, &_vao));
    
    //create vertex buffer
    VERIFY(glGenBuffers(1, &_vertexBuffer));

    VERIFY(glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer));
    
    unsigned int _verticesSizeInBytes = sizeof(float) * 18;
    
    VERIFY(glBufferData(GL_ARRAY_BUFFER,
                        static_cast<GLsizeiptr>(_verticesSizeInBytes),
                        nullptr,
                        GL_STATIC_DRAW));

    //set _vertices
    _vertices = new float[18];
    _vertices[0] = 0.0f;
    _vertices[1] = 10.0f;
    _vertices[2] = 0.0f;
    _vertices[3] = 0.0f;
    _vertices[4] = 0.0f;
    _vertices[5] = 1.0f;
    
    _vertices[6] = 10.0f;
    _vertices[7] = -10.0f;
    _vertices[8] = 0.0f;
    _vertices[9] = 0.0f;
    _vertices[10] = 0.0f;
    _vertices[11] = 1.0f;
    
    _vertices[12] = -10.0f;
    _vertices[13] = -10.0f;
    _vertices[14] = 0.0f;
    _vertices[15] = 0.0f;
    _vertices[16] = 0.0f;
    _vertices[17] = 1.0f;
    
    VERIFY(glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer));
    VERIFY(glBufferSubData(GL_ARRAY_BUFFER,
                           static_cast<GLintptr>(0),
                           static_cast<GLsizeiptr>(_verticesSizeInBytes),
                           (void*)_vertices));
    
    //create index buffer
    unsigned int indicesSizeInBytes = sizeof(uint32_t) * 3;
    
    VERIFY(glGenBuffers(1, &_indexBuffer));
    VERIFY(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer));
    VERIFY(glBufferData(GL_ELEMENT_ARRAY_BUFFER,
                        static_cast<GLsizeiptr>(indicesSizeInBytes),
                        nullptr,
                        GL_STATIC_DRAW));
    
    //set indices
    _indices = new uint32_t[3];
    _indices[0] = 0;
    _indices[1] = 1;
    _indices[2] = 2;
    
    VERIFY(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer));
    VERIFY(glBufferSubData(GL_ELEMENT_ARRAY_BUFFER,
                           static_cast<GLintptr>(0),
                           static_cast<GLsizeiptr>(indicesSizeInBytes),
                           (void*)_indices));

    
    //set vertex buffer
    VERIFY(glBindVertexArray(_vao));
    
    VERIFY(glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer));
    
    VERIFY(glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) 0));
    
    VERIFY(glVertexAttribPointer(1,
                                 3,
                                 GL_FLOAT,
                                 GL_FALSE,
                                 sizeof(Vertex),
                                 (void*) (3 * sizeof(float))));
    
    VERIFY(glEnableVertexAttribArray(0));
    VERIFY(glEnableVertexAttribArray(1));
    
    VERIFY(glBindVertexArray(0));

    
    //set index buffer
    VERIFY(glBindVertexArray(_vao));
    
    VERIFY(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer));
    
    VERIFY(glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) 0));
    VERIFY(glVertexAttribPointer(1,
                                 3,
                                 GL_FLOAT,
                                 GL_FALSE,
                                 sizeof(Vertex),
                                 (void*) (3 * sizeof(float))));
    
    VERIFY(glEnableVertexAttribArray(0));
    VERIFY(glEnableVertexAttribArray(1));
    
    VERIFY(glBindVertexArray(0));
    
    _matrix = new GLfloat[16];
    _matrix[0] = 1.112385f;
    _matrix[1] = 0.000000f;
    _matrix[2] = 0.000000f;
    _matrix[3] = 0.000000f;
    _matrix[4] = 0.000000f;
    _matrix[5] = 1.732051f;
    _matrix[6] = 0.000000f;
    _matrix[7] = 0.000000f;
    _matrix[8] = 0.000000f;
    _matrix[9] = 0.000000f;
    _matrix[10] = -1.000100f;
    _matrix[11] = -1.000000f;
    _matrix[12] = -2.780963f;
    _matrix[13] = -1.991858f;
    _matrix[14] = 13.950269f;
    _matrix[15] = 14.148864f;
}

-(void) Deinitialize
{
    VERIFY(glBindVertexArray(0));
    
    VERIFY(glDeleteVertexArrays(1, &_vao));
    
    VERIFY(glDeleteBuffers(1, &_indexBuffer));
    VERIFY(glDeleteBuffers(1, &_vertexBuffer));
    
    VERIFY(glDeleteProgram(_program));
    
    delete [] _vertices;
    delete [] _indices;
    
    delete [] _matrix;
}

-(void) Draw
{
    //clear buffers
    static const GLfloat white[] = { 1.0f, 1.0f, 1.0f, 1.0f };
    static const GLfloat one = 1.0f;
    
    VERIFY(glClearBufferfv(GL_COLOR, 0, white));
    VERIFY(glClearBufferfv(GL_DEPTH, 0, &one));

    //opaque objects
    VERIFY(glDisable(GL_BLEND));
    VERIFY(glDepthMask(GL_TRUE));
    
    //bind mesh
    VERIFY(glBindVertexArray(_vao));
    
    //use shader
    VERIFY(glUseProgram(_program));

    //feed parameters to shader
    VERIFY(glUniform4f(_plane1, 0.0f, 0.0f, 0.0f, 0.0f));
    VERIFY(glUniform4f(_plane2, 0.0f, 0.0f, 0.0f, 0.0f));
    VERIFY(glUniform4f(_plane3, 0.0f, 0.0f, 0.0f, 0.0f));
    VERIFY(glUniform4f(_plane4, 0.0f, 0.0f, 0.0f, 0.0f));
    VERIFY(glUniform4f(_plane5, 0.0f, 0.0f, 0.0f, 0.0f));
    VERIFY(glUniform4f(_plane6, 0.0f, 0.0f, 0.0f, 0.0f));
    
    VERIFY(glUniformMatrix4fv(_mvp, 1, GL_FALSE, _matrix));
    
    VERIFY(glUniform3f(_lightdir1, -0.52654082f, -0.57357651f, -0.62750691f));
    VERIFY(glUniform3f(_lightdir2,  0.71984643f,  0.34202009f,  0.60402268f));
    VERIFY(glUniform3f(_lightdir3,  0.45451951f, -0.76604438f,  0.45451951f));
    VERIFY(glUniform3f(_camerapos, 0, 0, -200));
    
    VERIFY(glUniform4f(_diffuse, 1.0f, 0.0f, 0.0f, 0.0f));
    VERIFY(glUniform4f(_ambient, 1.0f, 0.0f, 0.0f, 0.0f));
    VERIFY(glUniform4f(_specular, 1.0f, 1.0f, 1.0f, 1.0f));
    
    VERIFY(glUniform1f(_shininess, 10.0f));
    
    VERIFY(glUniform1f(_transparency, 0.5f));
    
    //render indexed geometry
    VERIFY(glDrawElementsBaseVertex(GL_TRIANGLES,
                                    3,
                                    GL_UNSIGNED_INT,
                                    (GLvoid*)0,
                                    0));

    
    //unbind mesh
    VERIFY(glBindVertexArray(0));
    
    
    //transparent objects
    VERIFY(glEnable(GL_BLEND));
    VERIFY(glDepthMask(GL_FALSE));
    
    
    VERIFY(glDisable(GL_BLEND));
    VERIFY(glDepthMask(GL_TRUE));
    
    //swap buffers
    glFlush();
}

-(void) Resize:(float)width :(float)height
{
    glViewport(0, 0, width, height);
}

@end

Please do use [noparse]

...

or

...

[/noparse] blocks around your source code. It makes your code much more readable.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.