nsopenglview

NSTextField over NSOpenGLView

白昼怎懂夜的黑 提交于 2019-12-03 06:52:05
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 paints over them. On Windows this problem does not exist:- Windows used to host OpenGL MUST have the

Assist me to understand OpenGL glGenBuffers()

僤鯓⒐⒋嵵緔 提交于 2019-12-03 03:40:28
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.width, dim.height); glClear(GL_COLOR_BUFFER_BIT); // vertex data GLfloat vertexPositionData[] = {-dim

Layer-backed OpenGLView redraws only if window is resized

≡放荡痞女 提交于 2019-12-02 21:06:50
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 the view, which is the consequence of the continuous redrawing of the view. And everything works

Creating an OpenGL View without Interface Builder

醉酒当歌 提交于 2019-11-30 07:56:24
So im trying to create an openGL view (in my window). Im making a Cocoa app. Ive managed to create one through Interface Builder, but for educational purposes i want to go on and make one without it. Just on papers. And here is the point im telling you im struggling with it. So what ive basically done-tried so far is this: I ve created a new class "MyOpenGLView.h/m" inheriting from NSOpenGLView. I ve added no private vars or methods to it just the class name. The only thing i did, was override initWithFrame: (adding a self = [super initWithFrame:pixelFormat:] inside it.) I read about it on the

Creating an OpenGL View without Interface Builder

混江龙づ霸主 提交于 2019-11-29 03:56:55
问题 So im trying to create an openGL view (in my window). Im making a Cocoa app. Ive managed to create one through Interface Builder, but for educational purposes i want to go on and make one without it. Just on papers. And here is the point im telling you im struggling with it. So what ive basically done-tried so far is this: I ve created a new class "MyOpenGLView.h/m" inheriting from NSOpenGLView. I ve added no private vars or methods to it just the class name. The only thing i did, was