bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win32] opengl - not NSWindow


From: Julien Isorce
Subject: [win32] opengl - not NSWindow
Date: Fri, 13 Feb 2009 01:17:31 +0100

Hi,

The following minimal code fails.
I got the error:

 w32_GLcontext.m:112  Assertion failed in Win32Subwindow(instance), method initWithView:.
 request of a window attachment on a view that is not on a NSWindow.

I tried to debug it in parsing gnustep gui and backend sources.
I found that it fails when setting the opengl context, just before calling  CreateWindow (win32 function).
It exactly fails on this:  [glview window], I mean it returns nil.
I think maybe something is wrong in NSView::initWithFrame, the _window member is not initialized.
mhh I was not able to find where this _window member of NSView is initialized.

Maybe I have (again) not initialized something.

Any idea ? (sample code at the end of this mail)

Sincerely

Julien

------------------------------------------------------------- test.m ------------------------------
#include <Cocoa/Cocoa.h>
#include <Foundation/NSAutoreleasePool.h>

int
main (void)
{
  CREATE_AUTORELEASE_POOL(pool);
  [NSApplication sharedApplication];

  NSOpenGLPixelFormatAttribute attribs[] = {
    NSOpenGLPFAAccelerated,
    NSOpenGLPFANoRecovery,
    NSOpenGLPFADoubleBuffer,
    NSOpenGLPFAColorSize, 24,
    NSOpenGLPFAAlphaSize, 8,
    NSOpenGLPFADepthSize, 24,
    NSOpenGLPFAWindow,
    0
  };

  NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
     
  if (fmt == nil)
    NSLog(@"fail create pixel format");
   
   
  NSRect rect;
  rect.origin.x = 0;
  rect.origin.y = 0;
  rect.size.width = 320;
  rect.size.height = 240;

  NSOpenGLView* glview = [[NSOpenGLView alloc] initWithFrame:rect pixelFormat:fmt];
 
  if (glview == nil)
    NSLog(@"fail to create opengl view");
 
  NSOpenGLContext* glcontext = [glview openGLContext];
 
  if (glcontext == nil)
    NSLog(@"fail to retrieve gl context");
 
  DESTROY(pool);
 
  return 0;
}

------------------------------------------------------

my GNUmakefile::

include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = test
test_OBJC_FILES = test.m

ADDITIONAL_OBJC_LIBS += -lgnustep-gui

include $(GNUSTEP_MAKEFILES)/tool.make

reply via email to

[Prev in Thread] Current Thread [Next in Thread]