Invalid display and invalid context


#1

Hi,
I’m trying to use an OpenGLContext, but I get the errors:
invalid display
invalid context
coming out of the program.
This happens in my juce demo too.
I’m using a mac and juce_1.50.
I’m compiling the library for juce in xcode or by hand and still getting the same results.
Likewise for the juce demo.
Also, I can get OpenGL to work in a separate folder Mesa-7.2/progs/demos/ such as gears.
Anyone have any ideas for me?
Sean


#2

I don’t understand - you say you’re using a mac, but those sound like linux GL problems?


#3

Right, I don’t understand either.


#4

you say the errors “come out of the program”… what does that mean? Which function calls actually produce these errors?


#5

I’m not sure how to tell that for sure. Here is what happens when I run the program from a terminal where I can see the output and copy it:
SeanBench:/Contents/MacOS/$ls
nucleosome_modeller
SeanBench:/Contents/MacOS/$pwd
/Users/smcguffee/MCGUFFEE_LAB/PROGRAMS/NUCLEOSOME_MODELLER/nucleosome_modeller.app/Contents/MacOS
SeanBench:/Contents/MacOS/ls nucleosome_modeller SeanBench:/Contents/MacOS/./nucleosome_modeller
2010-02-26 09:28:56.065 nucleosome_modeller[40990:10b] invalid display
2010-02-26 09:28:56.066 nucleosome_modeller[40990:10b] invalid context
2010-02-26 09:28:56.170 nucleosome_modeller[40990:10b] invalid display
2010-02-26 09:28:56.171 nucleosome_modeller[40990:10b] invalid context

Are the bracketed 40990:10b’s indicators of the function calls?
I get the feeling this happens every time the internal paint function is called from my class that inherits OpenGLComponent.
I can have the errors spit out every time I resize the window.

How does Mac manage OpenGL? Are there environmental variables that I might have broken somewhere?

Thanks for your help,

Sean


#6

Also, it might be more useful to you to see what happens from juce demo straight out of the juce_1_50.zip package:
SeanBench:/MacOS/$./jucedemo
JUCE v1.50
Time and date: 26 Feb 2010 9:42:57 am
Operating system: Mac OS X
CPU vendor: GenuineIntel
CPU speed: 2260MHz

Number of CPUs: 16
CPU has MMX: yes
CPU has SSE: yes
CPU has SSE2: yes
CPU has 3DNOW: no
Memory size: 12288MB
Found network card MAC address: 00-ee-4d-d7-00-00
Current executable file: /Users/smcguffee/TEMP/juce/extras/juce demo/build/macosx/build/Release/jucedemo.app/Contents/MacOS/./jucedemo
Current application file: /Users/smcguffee/TEMP/juce/extras/juce demo/build/macosx/build/Release/jucedemo.app/Contents/MacOS/./jucedemo
User home directory: /Users/smcguffee
User documents directory: /Users/smcguffee/Documents
User application data directory: /Users/smcguffee/Library
Common application data directory: /Library
Temp directory: /Users/smcguffee/Library/Caches/jucedemo

2010-02-26 09:43:20.315 jucedemo[44549:10b] invalid display
2010-02-26 09:43:20.316 jucedemo[44549:10b] invalid context
2010-02-26 09:43:20.319 jucedemo[44549:10b] invalid display
2010-02-26 09:43:20.319 jucedemo[44549:10b] invalid context
2010-02-26 09:43:20.328 jucedemo[44549:10b] invalid display


#7

Please try it with the tip - there have been a lot of changes since the 1.50 release.


#8

Sure thing. It took me a while to get “git” to get the “tip” because that sourceforge link seems a bit unreliable. Anyway, here is what I get from the juce demo from the “tip” :

SeanBench:/MacOSX/$cd build/Debug/JuceDemo.app/Contents/MacOS/
SeanBench:/MacOS/$ls
JuceDemo

SeanBench:/MacOS/$./JuceDemo
JUCE v1.51.6
Time and date: 26 Feb 2010 12:44:06 pm
User logon name: smcguffee
Full user name: Sean Robert McGuffee
Operating system: Mac OS X
CPU vendor: GenuineIntel
CPU speed: 2260MHz

Number of CPUs: 16
CPU has MMX: yes
CPU has SSE: yes
CPU has SSE2: yes
CPU has 3DNOW: no
Memory size: 12288MB
Found network card MAC address: 00-25-00-ee-4d-d7
Found network card MAC address: 00-25-00-ee-64-ca
Found network card MAC address: 00-1c-42-00-00-08
Found network card MAC address: 00-1c-42-00-00-09
Found network card MAC address: 00-25-00-c5-7e-6f
Current executable file: /Users/smcguffee/MCGUFFEE_LAB/PROGRAMS/juce/extras/juce demo/Builds/MacOSX/build/Debug/JuceDemo.app/Contents/MacOS/./JuceDemo
Current application file: /Users/smcguffee/MCGUFFEE_LAB/PROGRAMS/juce/extras/juce demo/Builds/MacOSX/build/Debug/JuceDemo.app/Contents/MacOS/./JuceDemo
Current working directory: /Users/smcguffee/MCGUFFEE_LAB/PROGRAMS/juce/extras/juce demo/Builds/MacOSX/build/Debug/JuceDemo.app/Contents/MacOS
User home directory: /Users/smcguffee
User documents directory: /Users/smcguffee/Documents
User application data directory: /Users/smcguffee/Library
Common application data directory: /Library
Temp directory: /Users/smcguffee/Library/Caches/JuceDemo

2010-02-26 12:44:12.410 JuceDemo[63608:10b] invalid display
2010-02-26 12:44:12.412 JuceDemo[63608:10b] invalid context
2010-02-26 12:44:12.424 JuceDemo[63608:10b] invalid display
2010-02-26 12:44:12.425 JuceDemo[63608:10b] invalid context


#9

A more specific question might help me:
What include directory and libraries are supposed to be used for programming OpenGL on a mac?
I’m able to make the program crash when I change them around–there are so many various versions on this mac.

for example:

find /Developer/ -name gl.h
/Developer//Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES2/gl.h
/Developer//Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES2/gl.h
/Developer//Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES2/gl.h
/Developer//Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES1/gl.h
/Developer//Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/System/Library/Frameworks/OpenGLES.framework/Headers/ES2/gl.h
/Developer//SDKs/MacOSX10.3.9.sdk/System/Library/Frameworks/AGL.framework/Versions/A/Headers/gl.h
/Developer//SDKs/MacOSX10.3.9.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/gl.h
/Developer//SDKs/MacOSX10.3.9.sdk/usr/X11R6/include/GL/gl.h
/Developer//SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/AGL.framework/Versions/A/Headers/gl.h
/Developer//SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/gl.h
/Developer//SDKs/MacOSX10.4u.sdk/usr/X11R6/include/GL/gl.h
/Developer//SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AGL.framework/Versions/A/Headers/gl.h
/Developer//SDKs/MacOSX10.5.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/gl.h
/Developer//SDKs/MacOSX10.5.sdk/usr/X11/include/GL/gl.h

find /usr -name gl.h
/usr/local/include/GL/gl.h
/usr/X11/include/GL/gl.h

find /opt/ -name gl.h
/opt//OLD/local/include/GL/gl.h
/opt//OLD/local/var/macports/software/mesa/7.4.3_0+hw_render/opt/local/include/GL/gl.h

find ~/ -name gl.h
/Users/smcguffee//WHITEHOUSE_LAB/PROGRAMS/MESA/Mesa-7.0.3/include/GL/gl.h
/Users/smcguffee//WHITEHOUSE_LAB/PROGRAMS/MESA/Mesa-7.2/include/GL/gl.h
/Users/smcguffee//WHITEHOUSE_LAB/PROGRAMS/MESA/Mesa-7.2-g++/include/GL/gl.h
/Users/smcguffee//WHITEHOUSE_LAB/PROGRAMS/MESA/Mesa-7.2-gcc/include/GL/gl.h
/Users/smcguffee//WHITEHOUSE_LAB/PROGRAMS/MESA/Mesa-7.2-icc/include/GL/gl.h
/Users/smcguffee//WHITEHOUSE_LAB/PROGRAMS/MESA/Mesa-7.2-icc-DRI/include/GL/gl.h
/Users/smcguffee//WHITEHOUSE_LAB/PROGRAMS/MESA/Mesa-7.2-icc-original/include/GL/gl.h
/Users/smcguffee//WHITEHOUSE_LAB/PROGRAMS/MESA/Mesa-7.2-icc-TEST/include/GL/gl.h
/Users/smcguffee//WHITEHOUSE_LAB/PROGRAMS/MESA/Mesa-7.2-icpc/include/GL/gl.h


#10

Beats me. You never actually said whether the GL display actually works despite these messages…? If it works, these might just be internal cocoa debug messages that can be ignored.


#11

It is a blank black screen–not working though.
Can you tell me what your DYLD_LIBRARY_PATH is on a mac where your code works?


#12

Sounds like you might be including the X11 gl headers instead of the OSX ones.


#13

Another idea:

I started debugging inside the library, just to see if I could find out anything.
Here’s what I found:
when createContextForWindow is called, my mac-specific code is not being called, so basically, this is a blank function.
How do I make sure the mac specific code is compiled?

Sean


#14

I ended up finding that if I put:
#define JUCE_INCLUDED_FILE 1
#define JUCE_OPENGL 1
in the juce_Config.h, then I could call the mac_specific code.
However, this didn’t solve my problem.
Still debugging on my end…


#15

None of the things you’re trying would ever be necessary - you’re just tying yourself in knots.

It’d be impossible to link your app if the mac-specific code was missing. You’ve probably just got a weird header search path set up, or maybe XCode is installed badly or something. You certainly don’t need to mess with any juce source code or definitions to make it work.


#16

Ok, now I’m getting somewhere.
The errors seem to occur inside of some objective c operations.
More details in a bit…


#17

this is the line that is causing the errors:

renderContext = [[[NSOpenGLContext alloc] initWithFormat: format shareContext: sharedContext] autorelease];

I’m not sure why this might cause a problem.

Any guesses?

Also, did I read something about objective C suffixes?
Should I maybe be calling a function like this with a 3 at the end of it?
I’ve never understood some aspects of objective C and C relationships.

Sean


#18

Ok, I agree, but I’m narrowing in on where I have things set up wrong:

this is the line that is causing the errors:

renderContext = [[[NSOpenGLContext alloc] initWithFormat: format shareContext: sharedContext] autorelease];

I’m not sure why this might cause a problem.

Any guesses?

Also, did I read something about objective C suffixes?
Should I maybe be calling a function like this with a 3 at the end of it?
I’ve never understood some aspects of objective C and C relationships.

Sean


#19

Ok, I agree, but I’m narrowing in on where I have things set up wrong:

this is the line that is causing the errors:

renderContext = [[[NSOpenGLContext alloc] initWithFormat: format shareContext: sharedContext] autorelease];

I’m not sure why this might cause a problem.

Any guesses?

Also, did I read something about objective C suffixes?
Should I maybe be calling a function like this with a 3 at the end of it?
I’ve never understood some aspects of objective C and C relationships.

Sean


#20

Welcome to modern Mac programming. Link to the OpenGl Framework. You should find it in the SDK you’re working with. It has all the correct headers and the libraries too.

OpenGL.framework, I think. The jucedemo includes it - you must have removed it?

If you’re doing a command line thing, I think you can still link to a framework on the Mac, probably something like -framework.

Bruce