nsopenglview

NSTextField over NSOpenGLView

 ̄綄美尐妖づ 提交于 2020-01-01 02:29:12
问题 I have made a window with an NSOpenGLView that I am rendering openGL content into. I want to add some buttons and text fields to the view: I can add NSTextFields and NSButtons using interface builder (or code) but they do not appear. NSOpenGLView is documented as not being able to have sub views, so I then made my own CustomGLView by deriving directly from NSView and implementing the code to create and use a NSOpenGLContext in it. But the subviews are still not appearing :- the OpenGL context

How to share textures between an NSOpenGLView and a full screen context in Mac OS?

社会主义新天地 提交于 2019-12-13 14:42:10
问题 I am working on an app that uses 2D textures to create animated kaleidoscopes. It starts out displaying to an NSOpenGLView. I am adding an option to switch to full-screen mode. I would prefer to use the OS 10.5 approach to full screen so I can support 10.5, but I think I would face the same issue if I was using the approach described in the docs under "Creating a Full-Screen Application in Mac OS X v10.6". The NSOpenGLContext init method initWithFormat:shareContext: takes an optional pointer

FBO: render to texture, wrong texture mapping when drawing rendered texture

大兔子大兔子 提交于 2019-12-12 21:38:37
问题 I'm using OpengGL on a Mac OS X application to draw texture on a NSOpenGLView . The app is a movie player. It decodes movie frames into CVOpenGLTextureRef (which are OpenGL texture) and I draw them directly to the view using GL_QUAD . Everything works correctly. Below is the relevant part of the code. // "image" is the CVOpenGLTextureRef containing the movie frame as texture GLenum textureTarget = CVOpenGLTextureGetTarget(image); GLuint textureName = CVOpenGLTextureGetName(image); glEnable

OpenGL Render to texture

风流意气都作罢 提交于 2019-12-08 14:03:51
问题 I know this has been asked before (I did search) but I promise you this one is different. I am making an app for Mac OS X Mountain Lion, but I need to add a little bit of a bloom effect. I need to render the entire scene to a texture the size of the screen, reduce the size of the texture, pass it through a pixel buffer, then use it as a texture for a quad. I ask this again because a few of the usual techniques do not seem to function. I cannot use the #version , layout , or out in my fragment

Unable to retrieve an error message from glGetShaderInfoLog

孤街浪徒 提交于 2019-12-06 06:02:38
问题 I am attempting to build a simple OpenGL 3.2 program which consists of a single fragment shader, but I do not seem to be able to actually compile the shader. I'm fairly sure that my shader syntax is correct, but even if it's not, I am unable to retrieve an error message using glGetShaderInfoLog . I have developed a short program that shows this in action: GLuint shader = glCreateShader(GL_FRAGMENT_SHADER); const char *shaderData = "#version 120\n" "void main()\n" "{\n" " gl_FragColor = gl

Draw from a separate thread with NSOpenGLLayer

此生再无相见时 提交于 2019-12-04 13:49:03
问题 I'm working on an app which needs to draw with OpengGL at a refresh rate at least equal to the refresh rate of the monitor. And I need to perform the drawing in a separate thread so that drawing is never locked by intense UI actions. Actually I'm using a NSOpenGLView in combination with CVDisplayLink and I'm able to achive 60-80FPS without any problem. Since I need also to display some cocoa controls on top of this view I tried to subclass NSOpenGLView and make it layer-backed, following

Unable to retrieve an error message from glGetShaderInfoLog

两盒软妹~` 提交于 2019-12-04 10:03:01
I am attempting to build a simple OpenGL 3.2 program which consists of a single fragment shader, but I do not seem to be able to actually compile the shader. I'm fairly sure that my shader syntax is correct, but even if it's not, I am unable to retrieve an error message using glGetShaderInfoLog . I have developed a short program that shows this in action: GLuint shader = glCreateShader(GL_FRAGMENT_SHADER); const char *shaderData = "#version 120\n" "void main()\n" "{\n" " gl_FragColor = gl_Color;\n" "}\n"; glShaderSource(shader, 1, &shaderData, NULL); GLint status; glGetShaderiv(shader, GL

Layer-backed OpenGLView redraws only if window is resized

只谈情不闲聊 提交于 2019-12-04 08:09:56
问题 I have a window with a main view of type NSView and a subview which is a subclass of NSOpenGLView whose name is CustomOpenGLView . The subclass of NSOpenGLView is obtained through a Custom View in Interface Builder and by setting its class to CustomOpenGLView . This is made according to the Apple Sample Code Layer Backed OpenGLView. The app is made to draw something to the OpenGLContext every, let's say, 0.05 seconds. With Core Animation Layer disabled I am able to see the moving object in

Assist me to understand OpenGL glGenBuffers()

对着背影说爱祢 提交于 2019-12-03 13:50:39
问题 Here is the deal: If I leave the code with glGenBuffers(1, vertexBuffers) , the code compiles and works. But, I thought that it should be 2 since vertexBuffers is of size two. Am I missing something? Code below: -(void)drawRect:(NSRect)dirtyRect { // get program ID for shader program GLuint programID = [self loadShaders]; // get new dimensions NSSize dim = [self frame].size; // clear the background with color glClearColor(0.0, 0.0, 0.0, 0.4); glDepthRange(0.1, 100.0); glViewport(0, 0, dim

Draw from a separate thread with NSOpenGLLayer

帅比萌擦擦* 提交于 2019-12-03 08:48:09
I'm working on an app which needs to draw with OpengGL at a refresh rate at least equal to the refresh rate of the monitor. And I need to perform the drawing in a separate thread so that drawing is never locked by intense UI actions. Actually I'm using a NSOpenGLView in combination with CVDisplayLink and I'm able to achive 60-80FPS without any problem. Since I need also to display some cocoa controls on top of this view I tried to subclass NSOpenGLView and make it layer-backed, following LayerBackedOpenGLView Apple example. The result isn't satisfactory and I get a lot of artifacts. Therefore