Create and manage OpenGL rendering contexts for use in macOS, and perform operations on drawable objects.

Posts under OpenGL tag

46 Posts

Post

Replies

Boosts

Views

Activity

How to Show current GPU usage via METAL®
on macOS silicon where memory is unified its now important to see how much memory is being used by the GPU, but unlike OpenGL which has been depreciated for some time, metal doesnt seem to have any "Driver Monitor Parameters" to be able to display this information. Example of OpenGL Parameters: https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/OpenGLDriverMonitorUserGuide/Glossary/Glossary.html Im looking for an equivalent for METAL® but haven't been able to find any, unless im overlooking everything in how metal is laid out idk. any ideas or sense of direction would be ideal. thanks for anyone who can help.
0
0
916
Apr ’23
MTLLoadActionClear does not respect ScissorRect
In OpenGL, If Scissor test is enabled then glClear() call only clears the Scissor rect region. and does not clear whole texture. From documentation of Metal, MTLLoadActionClear, It seems like Metal does render pass does not respect scissor rect while clearing the rtt. Is this understanding correct ? Please suggest how to achieve the OpenGL like functionality. in this respect.
2
0
935
Mar ’23
Issue with the GLSL Compiler on M1 OpenGL driver?
Hello, I am doing a cross-platform project that uses C++ and OpenGL ( I know I should be using MoltenVK or Metal, but OpenGL is nice and simple for starting out and is cross platform). I am also doing most of my development on a M1 Macbook Pro, which supports up to OpenGL 4.1. The M1 also only supports up to 16 active fragment shader samplers ( maximum number of supported image units) I am currently working on a batch rendering system that uses an array of textures thats uploaded to the GPU and the shader can switch based off of the index into a sampler array. Heres the shader that I am using ( the vertex and fragment shaders are combined, but the program parses them separately) : #type vertex #version 410 core layout(location = 0) in vec3 a_Position; layout(location = 1) in vec4 a_Color; layout(location = 2) in vec2 a_TexCoord; layout(location = 3) in float a_TexIndex; layout(location = 4) in float a_TilingFactor; uniform mat4 u_ViewProjection; out vec4 v_Color; out vec2 v_TexCoord; out float v_TexIndex; out float v_TilingFactor; void main() { v_Color = a_Color; v_TexCoord = a_TexCoord; v_TexIndex = a_TexIndex; v_TilingFactor = a_TilingFactor; gl_Position = u_ViewProjection * vec4(a_Position, 1.0); } #type fragment #version 410 core layout(location = 0) out vec4 color; in vec4 v_Color; in vec2 v_TexCoord; in float v_TexIndex; in float v_TilingFactor; uniform sampler2D u_Textures[16]; void main() { color = texture(u_Textures[int(v_TexIndex)], v_TexCoord * v_TilingFactor) * v_Color; } However, when the program runs I get this message: UNSUPPORTED (log once): POSSIBLE ISSUE: unit 2 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable I double and triple checked my code and im binding everything correctly to the shader (if im not feel free to point it out :), and the only thing I found on the web relating to this error was saying that it was an error within the GLSL compiler on the new M1s. Is this true? Or is it a code issue? Thanks side note: I am using EMACS to run Cmake and do C++ development, so if you try and test my project on Xcode and it doesnt include the shaders its most likely a Cmake/Xcode copy issue.
6
1
8.1k
Mar ’23
OpenGL Support M2 Pro
Hello, I am interested in the new MacBook Pro with the M2 Pro Processor. However, I need OpenGL on the laptop I am getting. Therefore, I wanted to ask which version of OpenGL is supported on this Mac and what might happen in the future.
1
1
3.4k
Jan ’23
Issue running openGL via headless mac mini
I am currently trying to use EC2 mac instances to run a CI/CD pipeline which involves running tests with electron/selenium. In order to run these tests openGL needs to be available. Im currently getting there error on line 49 of https://chromium.googlesource.com/chromium/src/+/8f066ff5113bd9d348f0aaf7ac6adc1ca1d1cd31/ui/gl/init/gl_initializer_mac.cc. With the output on the instance giving: 2022-06-09 19:38:25.937 Electron[52243:188559] +[NSXPCSharedListener endpointForReply:withListenerName:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted [52245:0609/193826.555969:ERROR:gl_initializer_mac.cc(65)] Error choosing pixel format. [52245:0609/193826.556035:ERROR:gl_initializer_mac.cc(193)] GLSurfaceCGL::InitializeOneOff failed. [52245:0609/193826.664827:ERROR:viz_main_impl.cc(188)] Exiting GPU process due to errors during initialization The root cause of this is there is no display connected to the mac mini. Using vnc to screen share with the host (which creates a display) fixes allows openGL to work as expected. Unfortunately this is not a solution/workaround for my use case as I will need to restart/reboot these instances after each run. I have tested this multiple times and after rebooting the instance the display is no longer present. (I have verified the displays being recognized / not being recognized with displayplacer list) Is there any way to make the mac mini host think that it has a display without relying on physical workarounds (I dont have physical access to the machine) or use software like BetterDummy that I can't run in a script.
1
1
1.9k
Jan ’23
Java OpenGL/LWJGL Development Support
If I purchase a MacBook Pro M1 Max, MacBook Air M1, MacBook Air M2, MacBook Pro M1 Pro...-any Apple Silicon MacBook, will OpenGL be supported? I'm currently developing an application with the following software versions and libs: JDK 17.0.2 IntelliJ Ultimate (this isn't very relevant though, but I got it for free from school) LWJGL 3.2.3 (includes OpenGL) JOML 1.9.23 I have not been able to run the application on my MacBook Air, which contains an Intel processor. It did not occur to me until hours of research that OpenGL (Java) has been deprecated since MacOS Mojave. However, I heard that it does work on Apple Silicon/ARM based computers. I don't see how this would work, since both Intel and Apple Silicon run computers still run MacOS where OpenGL is deprecated. Therefore, I would like to double check whether OpenGL (running the previous software specifications) would indeed be compatible with any of the Apple Silicon MacBooks listed above (despite OpenGL being deprecated). Alternatively, I have had to run Windows 10 on Boot Camp in order to test my games and run them abroad, which does not run at desirable speeds... If there are any alternatives that allow OpenGL support on my Intel processor based MacBook Air, please let me know. Otherwise, if anyone could point me towards a discount or deal I could strike for a Apple Silicon MacBook discount for High School students, it would be greatly appreciated (yes, I'm still in High School so I'm trying to do anything possible to avoid buying a new MacBook or at the very least not one at full price).
0
0
1.3k
Jul ’22
callDisplayLists() do not show
Hi, I have different displayLists (dL) to create, 8 lists have a own name, the work fine. Then I have a dynamic structure of dLs, they are stored in c-arrays. After i noticed that they are not shown, I made 2 dLs which differ in color and vertices. drawRect: glCallLists(2,GL_UNSIGNED_INT, test); This is my list-array: if(contentState[0] == 1) {       glCallLists(contentCount,GL_FLOAT, curveList);   } contentCount = 8 and the declaration is GLfloat curveList[20]  curveList has 8 display indices. I hope I made a mistake and you find it :) Uwe
1
0
1k
Jun ’22
IOS 15 + Safari + Video = :-(
Both standard mp4 files and streaming HLS files are experiencing substantial playback and rendering issues on iOS 15. This includes: Safari immediately crashes Video displays only black (occasional audio can be heard) Video is frozen on 1st frame despite time updating Substantial load times (10+ seconds). Should be immediate. GPU Process:Media has been disabled yet issues persist. Safari immediately crashes with GPU Process: WebGL enabled. These videos are being rendered via WebGL (threejs) None of these issues were present on iOS 14. I’m on an iPad Pro 12.9 2020.
3
0
7.3k
Apr ’22
How to use IOSurface instead of NSOpenGLPixelBuffer on Mac? How to use GL_EXT_framebuffer_object instead?
I used to have a project that used Quartz Composer and OpenGL, but Xcode 13 has deprecated these two components, which caused me to fail to get off-screen images during video production. The previous code to create the OpenGLContext is as follows: (id) initOffScreenOpenGLPixelsWide:(unsigned)width pixelsHigh:(unsigned)height { //Check parameters - Rendering at sizes smaller than 16x16 will likely produce garbage if((width < 16) || (height < 16)) { [self release]; return nil; } self = [super init]; if(self != nil) {         NSOpenGLPixelFormatAttribute pixattributes[] = {             NSOpenGLPFADoubleBuffer,             NSOpenGLPFANoRecovery,             NSOpenGLPFAAccelerated,             NSOpenGLPFADepthSize, 24,             (NSOpenGLPixelFormatAttribute) 0         };         _pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixattributes]; //Create the OpenGL context to render with (with color and depth buffers) _openGLContext = [[NSOpenGLContext alloc] initWithFormat:_pixelFormat shareContext:nil]; if(_openGLContext == nil) { DDLogInfo(@"Cannot create OpenGL context"); [self release]; return nil; }                  //Create the OpenGL pixel buffer to render into         NSOpenGLPixelBuffer* glPixelBuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:GL_TEXTURE_RECTANGLE_EXT    textureInternalFormat:GL_RGBA textureMaxMipMapLevel:0 pixelsWide:width pixelsHigh:height];         if(glPixelBuffer == nil) {             DDLogInfo(@"Cannot create OpenGL pixel buffer");             [self release];             return nil;         }         [_openGLContext setPixelBuffer:glPixelBuffer cubeMapFace:0 mipMapLevel:0 currentVirtualScreen:[_openGLContext currentVirtualScreen]];                  //Destroy the OpenGL pixel buffer         [glPixelBuffer release];          NSMutableDictionary* attributes = [NSMutableDictionary dictionary];         [attributes setObject:[NSNumber numberWithUnsignedInt:k32BGRAPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; [attributes setObject:[NSNumber numberWithUnsignedInt:width] forKey:(NSString*)kCVPixelBufferWidthKey]; [attributes setObject:[NSNumber numberWithUnsignedInt:height] forKey:(NSString*)kCVPixelBufferHeightKey]; //Create buffer pool to hold our frames OSErr theError = CVPixelBufferPoolCreate(kCFAllocatorDefault, NULL, (CFDictionaryRef)attributes, &_bufferPool); if(theError != kCVReturnSuccess)  { DDLogInfo(@"CVPixelBufferPoolCreate() failed with error %i", theError); [self release]; return nil; } }     /*      *A context is current on a per-thread basis. Multiple threads must serialize calls into the same context object.      */     [self.openGLContext makeCurrentContext]; return self; } By creating an NSOpenGLPixelBuffer object, and then setting the pixelbuffer of NSOpenGLContext, but in Xcode13, NSOpenGLPixelBuffer cannot be created successfully. Looking at the help documentation, it is recommended to use GL_EXT_framebuffer_object instead. So I tried the following code::         //RGBA8 RenderBuffer, 24 bit depth RenderBuffer, 256x256         glGenFramebuffersEXT(1, &fb);         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);         //Create and attach a color buffer                  glGenRenderbuffersEXT(1, &color_rb);         //We must bind color_rb before we call glRenderbufferStorageEXT         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, color_rb);         //The storage format is RGBA8         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, width, height);         //Attach color buffer to FBO         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, color_rb);         //-------------------------                  glGenRenderbuffersEXT(1, &depth_rb);         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);         //-------------------------         //Attach depth buffer to FBO         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);         //-------------------------         //Does the GPU support current FBO configuration?         GLenum status;         status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);         switch(status)         {             case GL_FRAMEBUFFER_COMPLETE_EXT:                 DDLogInfo(@"gl no problem");                 break;             default:                 DDLogInfo(@"error");                 break;         }                  //-------------------------         //and now you can render to the FBO (also called RenderBuffer)         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); When running the program we can get the 'gl no problem' log. However, when reading off-screen image data, although glGetError does not return an error code, I can only read a black image. In previous versions, a QCRenderer rendered image could be successfully obtained. Reading off-screen images is implemented as follows: (CVPixelBufferRef) readPixelBuffer {     // Create pixel buffer from pixel buffer pool     CVPixelBufferRef bufferRef;     OSErr theError = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, _bufferPool, &bufferRef);     if(theError) {         DDLogInfo(@"CVPixelBufferPoolCreatePixelBuffer() failed with error %i", theError);         return nil;     }     theError = CVPixelBufferLockBaseAddress(bufferRef, 0); if(theError) { DDLogInfo(@"CVPixelBufferLockBaseAddress() failed with error %i", theError); return nil; } void* bufferPtr = CVPixelBufferGetBaseAddress(bufferRef);     size_t width = CVPixelBufferGetWidth(bufferRef);     size_t height = CVPixelBufferGetHeight(bufferRef); size_t bufferRowBytes = CVPixelBufferGetBytesPerRow(bufferRef);     CGLContextObj cgl_ctx = [_openGLContext CGLContextObj]; CGLLockContext(cgl_ctx);     //Read pixels back from the OpenGL pixel buffer in ARGB 32 bits format - For extra safety, we save / restore the OpenGL states we change     GLint save; glGetIntegerv(GL_PACK_ROW_LENGTH, &save); glPixelStorei(GL_PACK_ROW_LENGTH, (int)bufferRowBytes / 4); glReadPixels(0, 0, (GLsizei)width, (GLsizei)height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, bufferPtr);     flipImage(bufferPtr, width, height, bufferRowBytes);     glPixelStorei(GL_PACK_ROW_LENGTH, save); CGLUnlockContext(cgl_ctx);     GLenum code = glGetError(); if(code) return nil; CVPixelBufferUnlockBaseAddress(bufferRef, 0);     return bufferRef; } Ask an expert how to solve this problem.
0
0
1.3k
Apr ’22
Applying OpenGL Shader to Screen or Window
Hi! I'm looking to create a system utility to apply an openGL shader (or Metal?) to the window that the user is focused on (or the screen), ideally with a keyboard shortcut. From what I can tell, applying OpenGL shaders or pixel level modifications to the whole screens at a time is possible (e.g. BlackLight by Michel Fortin). Any pointers to this kind of thing would be great. Combining Automator workflows with some system-level code seems like it would do the trick but I'm not sure where to start. Update: It looks like CGColorSpace might be helpful for applying color transforms to windows. Perhaps there's a way to make a swift app similar to Rectangle that could modify these CoreGraphics elements instead of the coordinates / transform ones? Thanks for the help, Jack
0
0
2.1k
Apr ’22
Xcode boilerplate openGL build produces error: "error finding potential wrapper bundle for node <FSNode 0x100a09910>"
I am working on compiling a simple openGL program in Xcode on my M1 Mac running Monterey 12.2.1. The build succeeds, but I get this nasty error 2022-04-05 09:54:18.959203-0500 opengl[24908:835152] [default] error finding potential wrapper bundle for node <FSNode 0x100a09910> { isDir = ?, path = '/Users/liamwhite/Library/Developer/Xcode/DerivedData/opengl-awawpgevgzpjofbrfmzvucbfrzpp/Build/Products/Debug' }: Error Domain=NSOSStatusErrorDomain Code=-10811 "kLSNotAnApplicationErr: Item needs to be an application, but is not" UserInfo={_LSLine=1579, _LSFunction=wrapperBundleNodeForWrappedNode} 2022-04-05 09:54:18.959276-0500 opengl[24908:835152] [default] error finding potential wrapper bundle for node <FSNode 0x100a09910> { isDir = ?, path = '/Users/liamwhite/Library/Developer/Xcode/DerivedData/opengl-awawpgevgzpjofbrfmzvucbfrzpp/Build/Products/Debug' }: Error Domain=NSOSStatusErrorDomain Code=-10811 "kLSNotAnApplicationErr: Item needs to be an application, but is not" UserInfo={_LSLine=1579, _LSFunction=wrapperBundleNodeForWrappedNode} 2022-04-05 09:54:18.959308-0500 opengl[24908:835152] [default] error finding potential wrapper bundle for node <FSNode 0x100a09910> { isDir = ?, path = '/Users/liamwhite/Library/Developer/Xcode/DerivedData/opengl-awawpgevgzpjofbrfmzvucbfrzpp/Build/Products/Debug' }: Error Domain=NSOSStatusErrorDomain Code=-10811 "kLSNotAnApplicationErr: Item needs to be an application, but is not" UserInfo={_LSLine=1579, _LSFunction=wrapperBundleNodeForWrappedNode} 2022-04-05 09:54:19.019242-0500 opengl[24908:835152] [default] error finding potential wrapper bundle for node <FSNode 0x100a09910> { isDir = ?, path = '/Users/liamwhite/Library/Developer/Xcode/DerivedData/opengl-awawpgevgzpjofbrfmzvucbfrzpp/Build/Products/Debug' }: Error Domain=NSOSStatusErrorDomain Code=-10811 "kLSNotAnApplicationErr: Item needs to be an application, but is not" UserInfo={_LSLine=1579, _LSFunction=wrapperBundleNodeForWrappedNode} 2022-04-05 09:54:19.054172-0500 opengl[24908:835152] Metal API Validation Enabled Program ended with exit code: 0 A potential fix is proposed in this SO post, but I am new to Xcode and the answer is too vague for me. I expect a window to pop up and display a simple triangle. Instead I see my system attempt to open a window (for a fraction of a second) before quitting the window and giving me the above error. Below is my code, if it is of any consequence: #include <iostream> #include <string> #define GLEW_STATIC #include <GL/glew.h> #include <GLFW/glfw3.h> static unsigned int CompileShader(unsigned int type, const std::string& source) {   unsigned int id = glCreateShader(type);   const char* src = source.c_str();   glShaderSource(id, 1, &src, nullptr);   glCompileShader(id);       int result;   glGetShaderiv(id, GL_COMPILE_STATUS, &result);   if(!result)   {     int length;     glGetShaderiv(id, GL_INFO_LOG_LENGTH, &length);     char* message = static_cast<char*>(alloca(length * sizeof(char))); // alloca is from C. it allows dynamic stack allocation!     glGetShaderInfoLog(id, length, &length, message);     std::cout << "Failed to compile " << (type == GL_VERTEX_SHADER ? "vertex" : "fragment") << " shader" << std::endl;     std::cout << message << std::endl;           return 0;   }       return id; } static unsigned int CreateShader(const std::string& vertexShader, const std::string& fragmentShader) {   unsigned int program = glCreateProgram();   unsigned int vs = CompileShader(GL_VERTEX_SHADER, vertexShader);   unsigned int fs = CompileShader(GL_FRAGMENT_SHADER, fragmentShader);       glAttachShader(program, vs);   glAttachShader(program, fs);   glLinkProgram(program);   glValidateProgram(program);       glDeleteShader(vs);   glDeleteShader(fs);       return program; } int main() {   GLFWwindow* window;   /* Initialize the library */   if (!glfwInit())     return -1;      glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);   glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);   glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);   glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);   /* Create a windowed mode window and its OpenGL context */   window = glfwCreateWindow(640, 480, "", NULL, NULL);   if (!window)   {     glfwTerminate();     return -1;   }   /* Make the window's context current */   glfwMakeContextCurrent(window);       if(!glewInit())     return 0;           float positions[6] = {     -0.5f, -0.5f,      0.0f, 0.5f,      0.5f, -0.5f   };       unsigned int vao;   glGenVertexArrays(1, &vao);   glBindVertexArray(vao);       unsigned int buffer;   glGenBuffers(1, &buffer);   glBindBuffer(GL_ARRAY_BUFFER, buffer);       glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), positions, GL_STATIC_DRAW);       // Below is specifying the layout of our buffer (positions, above)   glEnableVertexAttribArray(0);   glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0);       std::string vertexShader =     "#version 330 core\n"     "layout(location = 0) in vec4 position;\n"     "void main()\n"     "{\n"     "gl_Position = position;\n"     "}\n";       std::string fragmentShader =     "#version 330 core\n"     "layout(location = 0) out vec4 color;\n"     "void main()\n"     "{\n"     "color = vec4(1.0, 0.0, 0.0, 0.0, 1.0);\n"     "}\n";       unsigned int shader = CreateShader(vertexShader, fragmentShader);       glUseProgram(shader);       /* Loop until the user closes the window */   while (!glfwWindowShouldClose(window))   {     /* Render here */     glClear(GL_COLOR_BUFFER_BIT);           glDrawArrays(GL_TRIANGLES, 0, 3);           /* Swap front and back buffers */     glfwSwapBuffers(window);     /* Poll for and process events */     glfwPollEvents();   }   glfwTerminate();   return 0; }
0
0
1.1k
Apr ’22
Shared OpenGL context leads to crash moving window between screens
We are developing a graphics app that uses OpenGL extensively. We've developed a crash issue since we switched to CALayer-based OpenGL rendering per Apple sample code CALayerEssentials. When certain of our OpenGL layer-containing windows are moved between two screens, the app crashes (on Catalina). I replicated the issue in a pared-down, updated version of CALayerEssentials. In our version, because we will have multiple OpenGL views sharing resources, we use a shared context. Is there something we can do differently to avoid the crash while still sharing OpenGL resources? // You would typically override this method if you needed to specify a share context to share OpenGL resources. // This is also an ideal location to do any initialization that is necessary for the context returned -(CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat { #if 0 // ORIGINAL SAMPLE CODE // Default handling is fine for this demonstration. CGLContextObj superContext = [super copyCGLContextForPixelFormat:pixelFormat]; return superContext; #else // OUR VERSION TO SHARE OPENGL RESOURCES // THIS LEADS TO CRASH WHEN WINDOW IS MOVED BETWEEN SCREENS if (!_dfContext) { _dfContext = [super copyCGLContextForPixelFormat:pixelFormat]; } return _dfContext; #endif } Our pared-down and updated version of CALayerEssentials source may be downloaded here. Here's the backtrace: Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 GLEngine 0x00007fff3eb701a2 gleLookupHashObject + 13 1 GLEngine 0x00007fff3eb6fe3e gleBindTexture + 59 2 GLEngine 0x00007fff3eb6fdc6 glBindTexture_Exec + 405 3 com.apple.QuartzCore 0x00007fff3fbd8a0c CA::(anonymous namespace)::IOSurface::framebuffer() + 84 4 com.apple.QuartzCore 0x00007fff3fbd8907 CA::(anonymous namespace)::IOSurface::attach() + 83 5 com.apple.QuartzCore 0x00007fff3fbd8461 CAOpenGLLayerDraw(CAOpenGLLayer*, double, CVTimeStamp const*, unsigned int) + 1868 6 com.apple.QuartzCore 0x00007fff3fbd7b3a -[CAOpenGLLayer _display] + 580 7 com.apple.QuartzCore 0x00007fff3fb3bcad CA::Layer::display_if_needed(CA::Transaction*) + 757 8 com.apple.QuartzCore 0x00007fff3fb19fca CA::Context::commit_transaction(CA::Transaction*, double) + 334 9 com.apple.QuartzCore 0x00007fff3fb18bb4 CA::Transaction::commit() + 644 10 com.apple.AppKit 0x00007fff315f42f1 __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 266 11 com.apple.AppKit 0x00007fff31d12c20 ___NSRunLoopObserverCreateWithHandler_block_invoke + 41 12 com.apple.CoreFoundation 0x00007fff341f17bc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 13 com.apple.CoreFoundation 0x00007fff341f16ec __CFRunLoopDoObservers + 457 14 com.apple.CoreFoundation 0x00007fff341f0c84 __CFRunLoopRun + 884 15 com.apple.CoreFoundation 0x00007fff341f02b3 CFRunLoopRunSpecific + 466 16 com.apple.HIToolbox 0x00007fff32e0baad RunCurrentEventLoopInMode + 292
0
0
919
Jan ’22
OpenGL Support
I am currently shopping for a new laptop and have been researching whether or not the new Apple M1 Pro Laptop would meet my requirements. I contacted Apple support, but they were unable to provide me with the answers to my questions and directed me to this forum. I am joining a CS program that is requiring OpenGL support in their hardware documentation. The school's hardware docs state: "Support for OpenGL Required - Support for OpenGL requires a graphics co-processor. This may be a dedicated graphics card, a co-processor imbedded on the motherboard, or integrated in the main cpu." My concern is I've read that OpenGL support was deprecated? Does anyone know whether or not the new M1 Pro Laptops (specifically, the 14"/16" models) support OpenGL for the purposes of education or if there's a suitable workaround?
1
0
1.9k
Jan ’22
How to Show current GPU usage via METAL®
on macOS silicon where memory is unified its now important to see how much memory is being used by the GPU, but unlike OpenGL which has been depreciated for some time, metal doesnt seem to have any "Driver Monitor Parameters" to be able to display this information. Example of OpenGL Parameters: https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/OpenGLDriverMonitorUserGuide/Glossary/Glossary.html Im looking for an equivalent for METAL® but haven't been able to find any, unless im overlooking everything in how metal is laid out idk. any ideas or sense of direction would be ideal. thanks for anyone who can help.
Replies
0
Boosts
0
Views
916
Activity
Apr ’23
MTLLoadActionClear does not respect ScissorRect
In OpenGL, If Scissor test is enabled then glClear() call only clears the Scissor rect region. and does not clear whole texture. From documentation of Metal, MTLLoadActionClear, It seems like Metal does render pass does not respect scissor rect while clearing the rtt. Is this understanding correct ? Please suggest how to achieve the OpenGL like functionality. in this respect.
Replies
2
Boosts
0
Views
935
Activity
Mar ’23
Issue with the GLSL Compiler on M1 OpenGL driver?
Hello, I am doing a cross-platform project that uses C++ and OpenGL ( I know I should be using MoltenVK or Metal, but OpenGL is nice and simple for starting out and is cross platform). I am also doing most of my development on a M1 Macbook Pro, which supports up to OpenGL 4.1. The M1 also only supports up to 16 active fragment shader samplers ( maximum number of supported image units) I am currently working on a batch rendering system that uses an array of textures thats uploaded to the GPU and the shader can switch based off of the index into a sampler array. Heres the shader that I am using ( the vertex and fragment shaders are combined, but the program parses them separately) : #type vertex #version 410 core layout(location = 0) in vec3 a_Position; layout(location = 1) in vec4 a_Color; layout(location = 2) in vec2 a_TexCoord; layout(location = 3) in float a_TexIndex; layout(location = 4) in float a_TilingFactor; uniform mat4 u_ViewProjection; out vec4 v_Color; out vec2 v_TexCoord; out float v_TexIndex; out float v_TilingFactor; void main() { v_Color = a_Color; v_TexCoord = a_TexCoord; v_TexIndex = a_TexIndex; v_TilingFactor = a_TilingFactor; gl_Position = u_ViewProjection * vec4(a_Position, 1.0); } #type fragment #version 410 core layout(location = 0) out vec4 color; in vec4 v_Color; in vec2 v_TexCoord; in float v_TexIndex; in float v_TilingFactor; uniform sampler2D u_Textures[16]; void main() { color = texture(u_Textures[int(v_TexIndex)], v_TexCoord * v_TilingFactor) * v_Color; } However, when the program runs I get this message: UNSUPPORTED (log once): POSSIBLE ISSUE: unit 2 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable I double and triple checked my code and im binding everything correctly to the shader (if im not feel free to point it out :), and the only thing I found on the web relating to this error was saying that it was an error within the GLSL compiler on the new M1s. Is this true? Or is it a code issue? Thanks side note: I am using EMACS to run Cmake and do C++ development, so if you try and test my project on Xcode and it doesnt include the shaders its most likely a Cmake/Xcode copy issue.
Replies
6
Boosts
1
Views
8.1k
Activity
Mar ’23
VideoDecompressionSession for H.265 (hevc)
The sources that I have seen for VideoDecompressionSession use H.264 as the example decoder. I suspect that H.265 could also be decoded with VideoDecompressionSession. Can anyone confirm that?
Replies
1
Boosts
0
Views
1k
Activity
Feb ’23
Please help with xcode application and download windows on mac
Hello, I am a student and I use a Macbook Air, and I am facing a problem when writing codes in the xcode ‘GL/glut.h’ file not found application. When I change the system of my device to the Windows system, will the program run? Note that when writing the codes, I use the C++ language and 3 libraries opengl glut freeglut
Replies
1
Boosts
0
Views
1.1k
Activity
Jan ’23
OpenGL Support M2 Pro
Hello, I am interested in the new MacBook Pro with the M2 Pro Processor. However, I need OpenGL on the laptop I am getting. Therefore, I wanted to ask which version of OpenGL is supported on this Mac and what might happen in the future.
Replies
1
Boosts
1
Views
3.4k
Activity
Jan ’23
Issue running openGL via headless mac mini
I am currently trying to use EC2 mac instances to run a CI/CD pipeline which involves running tests with electron/selenium. In order to run these tests openGL needs to be available. Im currently getting there error on line 49 of https://chromium.googlesource.com/chromium/src/+/8f066ff5113bd9d348f0aaf7ac6adc1ca1d1cd31/ui/gl/init/gl_initializer_mac.cc. With the output on the instance giving: 2022-06-09 19:38:25.937 Electron[52243:188559] +[NSXPCSharedListener endpointForReply:withListenerName:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted [52245:0609/193826.555969:ERROR:gl_initializer_mac.cc(65)] Error choosing pixel format. [52245:0609/193826.556035:ERROR:gl_initializer_mac.cc(193)] GLSurfaceCGL::InitializeOneOff failed. [52245:0609/193826.664827:ERROR:viz_main_impl.cc(188)] Exiting GPU process due to errors during initialization The root cause of this is there is no display connected to the mac mini. Using vnc to screen share with the host (which creates a display) fixes allows openGL to work as expected. Unfortunately this is not a solution/workaround for my use case as I will need to restart/reboot these instances after each run. I have tested this multiple times and after rebooting the instance the display is no longer present. (I have verified the displays being recognized / not being recognized with displayplacer list) Is there any way to make the mac mini host think that it has a display without relying on physical workarounds (I dont have physical access to the machine) or use software like BetterDummy that I can't run in a script.
Replies
1
Boosts
1
Views
1.9k
Activity
Jan ’23
Problem with GL in xcode
Please help me here in xcode app it shows an error in ‘GL/glut.h’ file not found What is the solution?on MacBook Air
Replies
3
Boosts
0
Views
2.4k
Activity
Jan ’23
OpenGL crashes (iOS 16)
OpenGL crashes when I call 'presentRenderBuffer' in iOS 16 beta. It works fine with iOS 15 or below.
Replies
4
Boosts
0
Views
2.6k
Activity
Oct ’22
How to update OpenGL on Macbook
Intel Iris Plus Graphics 655 1536 MB OpenGL version 2.1 mac OS Monterey 12.6 (21G115) I had update the mac OS to the lastest version, but it still hadn't update the openGL Anyone know how to deal with it ????
Replies
1
Boosts
1
Views
1.9k
Activity
Oct ’22
Java OpenGL/LWJGL Development Support
If I purchase a MacBook Pro M1 Max, MacBook Air M1, MacBook Air M2, MacBook Pro M1 Pro...-any Apple Silicon MacBook, will OpenGL be supported? I'm currently developing an application with the following software versions and libs: JDK 17.0.2 IntelliJ Ultimate (this isn't very relevant though, but I got it for free from school) LWJGL 3.2.3 (includes OpenGL) JOML 1.9.23 I have not been able to run the application on my MacBook Air, which contains an Intel processor. It did not occur to me until hours of research that OpenGL (Java) has been deprecated since MacOS Mojave. However, I heard that it does work on Apple Silicon/ARM based computers. I don't see how this would work, since both Intel and Apple Silicon run computers still run MacOS where OpenGL is deprecated. Therefore, I would like to double check whether OpenGL (running the previous software specifications) would indeed be compatible with any of the Apple Silicon MacBooks listed above (despite OpenGL being deprecated). Alternatively, I have had to run Windows 10 on Boot Camp in order to test my games and run them abroad, which does not run at desirable speeds... If there are any alternatives that allow OpenGL support on my Intel processor based MacBook Air, please let me know. Otherwise, if anyone could point me towards a discount or deal I could strike for a Apple Silicon MacBook discount for High School students, it would be greatly appreciated (yes, I'm still in High School so I'm trying to do anything possible to avoid buying a new MacBook or at the very least not one at full price).
Replies
0
Boosts
0
Views
1.3k
Activity
Jul ’22
callDisplayLists() do not show
Hi, I have different displayLists (dL) to create, 8 lists have a own name, the work fine. Then I have a dynamic structure of dLs, they are stored in c-arrays. After i noticed that they are not shown, I made 2 dLs which differ in color and vertices. drawRect: glCallLists(2,GL_UNSIGNED_INT, test); This is my list-array: if(contentState[0] == 1) {       glCallLists(contentCount,GL_FLOAT, curveList);   } contentCount = 8 and the declaration is GLfloat curveList[20]  curveList has 8 display indices. I hope I made a mistake and you find it :) Uwe
Replies
1
Boosts
0
Views
1k
Activity
Jun ’22
OpenGLView frame moves from [-1,-1,1] to [0,0,0];
Hi, I have no idea what happened, I got no warnings, no error. When I used the Sandbox I got a GL_INVALID_VALUE  error. Please have I look at the attachments for illustration.
Replies
1
Boosts
0
Views
1.1k
Activity
Jun ’22
IOS 15 + Safari + Video = :-(
Both standard mp4 files and streaming HLS files are experiencing substantial playback and rendering issues on iOS 15. This includes: Safari immediately crashes Video displays only black (occasional audio can be heard) Video is frozen on 1st frame despite time updating Substantial load times (10+ seconds). Should be immediate. GPU Process:Media has been disabled yet issues persist. Safari immediately crashes with GPU Process: WebGL enabled. These videos are being rendered via WebGL (threejs) None of these issues were present on iOS 14. I’m on an iPad Pro 12.9 2020.
Replies
3
Boosts
0
Views
7.3k
Activity
Apr ’22
How to use IOSurface instead of NSOpenGLPixelBuffer on Mac? How to use GL_EXT_framebuffer_object instead?
I used to have a project that used Quartz Composer and OpenGL, but Xcode 13 has deprecated these two components, which caused me to fail to get off-screen images during video production. The previous code to create the OpenGLContext is as follows: (id) initOffScreenOpenGLPixelsWide:(unsigned)width pixelsHigh:(unsigned)height { //Check parameters - Rendering at sizes smaller than 16x16 will likely produce garbage if((width < 16) || (height < 16)) { [self release]; return nil; } self = [super init]; if(self != nil) {         NSOpenGLPixelFormatAttribute pixattributes[] = {             NSOpenGLPFADoubleBuffer,             NSOpenGLPFANoRecovery,             NSOpenGLPFAAccelerated,             NSOpenGLPFADepthSize, 24,             (NSOpenGLPixelFormatAttribute) 0         };         _pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixattributes]; //Create the OpenGL context to render with (with color and depth buffers) _openGLContext = [[NSOpenGLContext alloc] initWithFormat:_pixelFormat shareContext:nil]; if(_openGLContext == nil) { DDLogInfo(@"Cannot create OpenGL context"); [self release]; return nil; }                  //Create the OpenGL pixel buffer to render into         NSOpenGLPixelBuffer* glPixelBuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:GL_TEXTURE_RECTANGLE_EXT    textureInternalFormat:GL_RGBA textureMaxMipMapLevel:0 pixelsWide:width pixelsHigh:height];         if(glPixelBuffer == nil) {             DDLogInfo(@"Cannot create OpenGL pixel buffer");             [self release];             return nil;         }         [_openGLContext setPixelBuffer:glPixelBuffer cubeMapFace:0 mipMapLevel:0 currentVirtualScreen:[_openGLContext currentVirtualScreen]];                  //Destroy the OpenGL pixel buffer         [glPixelBuffer release];          NSMutableDictionary* attributes = [NSMutableDictionary dictionary];         [attributes setObject:[NSNumber numberWithUnsignedInt:k32BGRAPixelFormat] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey]; [attributes setObject:[NSNumber numberWithUnsignedInt:width] forKey:(NSString*)kCVPixelBufferWidthKey]; [attributes setObject:[NSNumber numberWithUnsignedInt:height] forKey:(NSString*)kCVPixelBufferHeightKey]; //Create buffer pool to hold our frames OSErr theError = CVPixelBufferPoolCreate(kCFAllocatorDefault, NULL, (CFDictionaryRef)attributes, &_bufferPool); if(theError != kCVReturnSuccess)  { DDLogInfo(@"CVPixelBufferPoolCreate() failed with error %i", theError); [self release]; return nil; } }     /*      *A context is current on a per-thread basis. Multiple threads must serialize calls into the same context object.      */     [self.openGLContext makeCurrentContext]; return self; } By creating an NSOpenGLPixelBuffer object, and then setting the pixelbuffer of NSOpenGLContext, but in Xcode13, NSOpenGLPixelBuffer cannot be created successfully. Looking at the help documentation, it is recommended to use GL_EXT_framebuffer_object instead. So I tried the following code::         //RGBA8 RenderBuffer, 24 bit depth RenderBuffer, 256x256         glGenFramebuffersEXT(1, &fb);         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);         //Create and attach a color buffer                  glGenRenderbuffersEXT(1, &color_rb);         //We must bind color_rb before we call glRenderbufferStorageEXT         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, color_rb);         //The storage format is RGBA8         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, width, height);         //Attach color buffer to FBO         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, color_rb);         //-------------------------                  glGenRenderbuffersEXT(1, &depth_rb);         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth_rb);         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, width, height);         //-------------------------         //Attach depth buffer to FBO         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);         //-------------------------         //Does the GPU support current FBO configuration?         GLenum status;         status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);         switch(status)         {             case GL_FRAMEBUFFER_COMPLETE_EXT:                 DDLogInfo(@"gl no problem");                 break;             default:                 DDLogInfo(@"error");                 break;         }                  //-------------------------         //and now you can render to the FBO (also called RenderBuffer)         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); When running the program we can get the 'gl no problem' log. However, when reading off-screen image data, although glGetError does not return an error code, I can only read a black image. In previous versions, a QCRenderer rendered image could be successfully obtained. Reading off-screen images is implemented as follows: (CVPixelBufferRef) readPixelBuffer {     // Create pixel buffer from pixel buffer pool     CVPixelBufferRef bufferRef;     OSErr theError = CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, _bufferPool, &bufferRef);     if(theError) {         DDLogInfo(@"CVPixelBufferPoolCreatePixelBuffer() failed with error %i", theError);         return nil;     }     theError = CVPixelBufferLockBaseAddress(bufferRef, 0); if(theError) { DDLogInfo(@"CVPixelBufferLockBaseAddress() failed with error %i", theError); return nil; } void* bufferPtr = CVPixelBufferGetBaseAddress(bufferRef);     size_t width = CVPixelBufferGetWidth(bufferRef);     size_t height = CVPixelBufferGetHeight(bufferRef); size_t bufferRowBytes = CVPixelBufferGetBytesPerRow(bufferRef);     CGLContextObj cgl_ctx = [_openGLContext CGLContextObj]; CGLLockContext(cgl_ctx);     //Read pixels back from the OpenGL pixel buffer in ARGB 32 bits format - For extra safety, we save / restore the OpenGL states we change     GLint save; glGetIntegerv(GL_PACK_ROW_LENGTH, &save); glPixelStorei(GL_PACK_ROW_LENGTH, (int)bufferRowBytes / 4); glReadPixels(0, 0, (GLsizei)width, (GLsizei)height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, bufferPtr);     flipImage(bufferPtr, width, height, bufferRowBytes);     glPixelStorei(GL_PACK_ROW_LENGTH, save); CGLUnlockContext(cgl_ctx);     GLenum code = glGetError(); if(code) return nil; CVPixelBufferUnlockBaseAddress(bufferRef, 0);     return bufferRef; } Ask an expert how to solve this problem.
Replies
0
Boosts
0
Views
1.3k
Activity
Apr ’22
Applying OpenGL Shader to Screen or Window
Hi! I'm looking to create a system utility to apply an openGL shader (or Metal?) to the window that the user is focused on (or the screen), ideally with a keyboard shortcut. From what I can tell, applying OpenGL shaders or pixel level modifications to the whole screens at a time is possible (e.g. BlackLight by Michel Fortin). Any pointers to this kind of thing would be great. Combining Automator workflows with some system-level code seems like it would do the trick but I'm not sure where to start. Update: It looks like CGColorSpace might be helpful for applying color transforms to windows. Perhaps there's a way to make a swift app similar to Rectangle that could modify these CoreGraphics elements instead of the coordinates / transform ones? Thanks for the help, Jack
Replies
0
Boosts
0
Views
2.1k
Activity
Apr ’22
Xcode boilerplate openGL build produces error: "error finding potential wrapper bundle for node <FSNode 0x100a09910>"
I am working on compiling a simple openGL program in Xcode on my M1 Mac running Monterey 12.2.1. The build succeeds, but I get this nasty error 2022-04-05 09:54:18.959203-0500 opengl[24908:835152] [default] error finding potential wrapper bundle for node <FSNode 0x100a09910> { isDir = ?, path = '/Users/liamwhite/Library/Developer/Xcode/DerivedData/opengl-awawpgevgzpjofbrfmzvucbfrzpp/Build/Products/Debug' }: Error Domain=NSOSStatusErrorDomain Code=-10811 "kLSNotAnApplicationErr: Item needs to be an application, but is not" UserInfo={_LSLine=1579, _LSFunction=wrapperBundleNodeForWrappedNode} 2022-04-05 09:54:18.959276-0500 opengl[24908:835152] [default] error finding potential wrapper bundle for node <FSNode 0x100a09910> { isDir = ?, path = '/Users/liamwhite/Library/Developer/Xcode/DerivedData/opengl-awawpgevgzpjofbrfmzvucbfrzpp/Build/Products/Debug' }: Error Domain=NSOSStatusErrorDomain Code=-10811 "kLSNotAnApplicationErr: Item needs to be an application, but is not" UserInfo={_LSLine=1579, _LSFunction=wrapperBundleNodeForWrappedNode} 2022-04-05 09:54:18.959308-0500 opengl[24908:835152] [default] error finding potential wrapper bundle for node <FSNode 0x100a09910> { isDir = ?, path = '/Users/liamwhite/Library/Developer/Xcode/DerivedData/opengl-awawpgevgzpjofbrfmzvucbfrzpp/Build/Products/Debug' }: Error Domain=NSOSStatusErrorDomain Code=-10811 "kLSNotAnApplicationErr: Item needs to be an application, but is not" UserInfo={_LSLine=1579, _LSFunction=wrapperBundleNodeForWrappedNode} 2022-04-05 09:54:19.019242-0500 opengl[24908:835152] [default] error finding potential wrapper bundle for node <FSNode 0x100a09910> { isDir = ?, path = '/Users/liamwhite/Library/Developer/Xcode/DerivedData/opengl-awawpgevgzpjofbrfmzvucbfrzpp/Build/Products/Debug' }: Error Domain=NSOSStatusErrorDomain Code=-10811 "kLSNotAnApplicationErr: Item needs to be an application, but is not" UserInfo={_LSLine=1579, _LSFunction=wrapperBundleNodeForWrappedNode} 2022-04-05 09:54:19.054172-0500 opengl[24908:835152] Metal API Validation Enabled Program ended with exit code: 0 A potential fix is proposed in this SO post, but I am new to Xcode and the answer is too vague for me. I expect a window to pop up and display a simple triangle. Instead I see my system attempt to open a window (for a fraction of a second) before quitting the window and giving me the above error. Below is my code, if it is of any consequence: #include <iostream> #include <string> #define GLEW_STATIC #include <GL/glew.h> #include <GLFW/glfw3.h> static unsigned int CompileShader(unsigned int type, const std::string& source) {   unsigned int id = glCreateShader(type);   const char* src = source.c_str();   glShaderSource(id, 1, &src, nullptr);   glCompileShader(id);       int result;   glGetShaderiv(id, GL_COMPILE_STATUS, &result);   if(!result)   {     int length;     glGetShaderiv(id, GL_INFO_LOG_LENGTH, &length);     char* message = static_cast<char*>(alloca(length * sizeof(char))); // alloca is from C. it allows dynamic stack allocation!     glGetShaderInfoLog(id, length, &length, message);     std::cout << "Failed to compile " << (type == GL_VERTEX_SHADER ? "vertex" : "fragment") << " shader" << std::endl;     std::cout << message << std::endl;           return 0;   }       return id; } static unsigned int CreateShader(const std::string& vertexShader, const std::string& fragmentShader) {   unsigned int program = glCreateProgram();   unsigned int vs = CompileShader(GL_VERTEX_SHADER, vertexShader);   unsigned int fs = CompileShader(GL_FRAGMENT_SHADER, fragmentShader);       glAttachShader(program, vs);   glAttachShader(program, fs);   glLinkProgram(program);   glValidateProgram(program);       glDeleteShader(vs);   glDeleteShader(fs);       return program; } int main() {   GLFWwindow* window;   /* Initialize the library */   if (!glfwInit())     return -1;      glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);   glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);   glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);   glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);   /* Create a windowed mode window and its OpenGL context */   window = glfwCreateWindow(640, 480, "", NULL, NULL);   if (!window)   {     glfwTerminate();     return -1;   }   /* Make the window's context current */   glfwMakeContextCurrent(window);       if(!glewInit())     return 0;           float positions[6] = {     -0.5f, -0.5f,      0.0f, 0.5f,      0.5f, -0.5f   };       unsigned int vao;   glGenVertexArrays(1, &vao);   glBindVertexArray(vao);       unsigned int buffer;   glGenBuffers(1, &buffer);   glBindBuffer(GL_ARRAY_BUFFER, buffer);       glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), positions, GL_STATIC_DRAW);       // Below is specifying the layout of our buffer (positions, above)   glEnableVertexAttribArray(0);   glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0);       std::string vertexShader =     "#version 330 core\n"     "layout(location = 0) in vec4 position;\n"     "void main()\n"     "{\n"     "gl_Position = position;\n"     "}\n";       std::string fragmentShader =     "#version 330 core\n"     "layout(location = 0) out vec4 color;\n"     "void main()\n"     "{\n"     "color = vec4(1.0, 0.0, 0.0, 0.0, 1.0);\n"     "}\n";       unsigned int shader = CreateShader(vertexShader, fragmentShader);       glUseProgram(shader);       /* Loop until the user closes the window */   while (!glfwWindowShouldClose(window))   {     /* Render here */     glClear(GL_COLOR_BUFFER_BIT);           glDrawArrays(GL_TRIANGLES, 0, 3);           /* Swap front and back buffers */     glfwSwapBuffers(window);     /* Poll for and process events */     glfwPollEvents();   }   glfwTerminate();   return 0; }
Replies
0
Boosts
0
Views
1.1k
Activity
Apr ’22
Shared OpenGL context leads to crash moving window between screens
We are developing a graphics app that uses OpenGL extensively. We've developed a crash issue since we switched to CALayer-based OpenGL rendering per Apple sample code CALayerEssentials. When certain of our OpenGL layer-containing windows are moved between two screens, the app crashes (on Catalina). I replicated the issue in a pared-down, updated version of CALayerEssentials. In our version, because we will have multiple OpenGL views sharing resources, we use a shared context. Is there something we can do differently to avoid the crash while still sharing OpenGL resources? // You would typically override this method if you needed to specify a share context to share OpenGL resources. // This is also an ideal location to do any initialization that is necessary for the context returned -(CGLContextObj)copyCGLContextForPixelFormat:(CGLPixelFormatObj)pixelFormat { #if 0 // ORIGINAL SAMPLE CODE // Default handling is fine for this demonstration. CGLContextObj superContext = [super copyCGLContextForPixelFormat:pixelFormat]; return superContext; #else // OUR VERSION TO SHARE OPENGL RESOURCES // THIS LEADS TO CRASH WHEN WINDOW IS MOVED BETWEEN SCREENS if (!_dfContext) { _dfContext = [super copyCGLContextForPixelFormat:pixelFormat]; } return _dfContext; #endif } Our pared-down and updated version of CALayerEssentials source may be downloaded here. Here's the backtrace: Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 GLEngine 0x00007fff3eb701a2 gleLookupHashObject + 13 1 GLEngine 0x00007fff3eb6fe3e gleBindTexture + 59 2 GLEngine 0x00007fff3eb6fdc6 glBindTexture_Exec + 405 3 com.apple.QuartzCore 0x00007fff3fbd8a0c CA::(anonymous namespace)::IOSurface::framebuffer() + 84 4 com.apple.QuartzCore 0x00007fff3fbd8907 CA::(anonymous namespace)::IOSurface::attach() + 83 5 com.apple.QuartzCore 0x00007fff3fbd8461 CAOpenGLLayerDraw(CAOpenGLLayer*, double, CVTimeStamp const*, unsigned int) + 1868 6 com.apple.QuartzCore 0x00007fff3fbd7b3a -[CAOpenGLLayer _display] + 580 7 com.apple.QuartzCore 0x00007fff3fb3bcad CA::Layer::display_if_needed(CA::Transaction*) + 757 8 com.apple.QuartzCore 0x00007fff3fb19fca CA::Context::commit_transaction(CA::Transaction*, double) + 334 9 com.apple.QuartzCore 0x00007fff3fb18bb4 CA::Transaction::commit() + 644 10 com.apple.AppKit 0x00007fff315f42f1 __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 266 11 com.apple.AppKit 0x00007fff31d12c20 ___NSRunLoopObserverCreateWithHandler_block_invoke + 41 12 com.apple.CoreFoundation 0x00007fff341f17bc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 13 com.apple.CoreFoundation 0x00007fff341f16ec __CFRunLoopDoObservers + 457 14 com.apple.CoreFoundation 0x00007fff341f0c84 __CFRunLoopRun + 884 15 com.apple.CoreFoundation 0x00007fff341f02b3 CFRunLoopRunSpecific + 466 16 com.apple.HIToolbox 0x00007fff32e0baad RunCurrentEventLoopInMode + 292
Replies
0
Boosts
0
Views
919
Activity
Jan ’22
OpenGL Support
I am currently shopping for a new laptop and have been researching whether or not the new Apple M1 Pro Laptop would meet my requirements. I contacted Apple support, but they were unable to provide me with the answers to my questions and directed me to this forum. I am joining a CS program that is requiring OpenGL support in their hardware documentation. The school's hardware docs state: "Support for OpenGL Required - Support for OpenGL requires a graphics co-processor. This may be a dedicated graphics card, a co-processor imbedded on the motherboard, or integrated in the main cpu." My concern is I've read that OpenGL support was deprecated? Does anyone know whether or not the new M1 Pro Laptops (specifically, the 14"/16" models) support OpenGL for the purposes of education or if there's a suitable workaround?
Replies
1
Boosts
0
Views
1.9k
Activity
Jan ’22
WKWebView global animation failed
Multiple calls to [UIView drawViewHierarchyInRect:afterScreenUpdates:] invalidates the WKWebView global animation To be more precise, the transition property animation fails But with [CALayer renderInContext:] don't have this problem
Replies
0
Boosts
0
Views
927
Activity
Jan ’22