I want to update my NSOpenGLView window when texture size is changed. Thats OK. I register event when that happens, but I can’t resize OpenGLView. Value witch is being changed is w and h.
-(void)initOpenGL {
NSSize size = {w, h};
[self setFrameSize:size];
NSOpenGLContext *glcontext;
glcontext = [self openGLContext];
[glcontext makeCurrentContext];
glMatrixMode(GL_PROJECTION);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glOrtho(0.0, h, 0.0, w, -1.0, 10.0);
}
When application starts it works OK, but when I do [self initOpenGL] after any of these size changed, OpenGL view is getting black, and not working any more.
If anyone will meet this problem just add
glLoadIdentity();at the beginning of OpenGL initialization.