Question: Is there some way to find out what values are legal for the GLCapabilities.setNumSamples(int) method? There used to be some “trick”
that I got from NEHE’s tutorials, that relied on the wglChoosePixelFormatARB method, but I don’t see WGL anymore in the javadoc.
Of course I would prefer a simple and straightforward query method in a class like GLCapabilities.
If you request multisampling in your GLCapabilities (setSampleBuffers(true)) and choose say 2 samples per pixel, the GLCapabilities[] passed to the GLCapabilitiesChooser should reflect all of the available multisampling options. This is true at least on Windows and X11 platforms. Therefore you should be able to write your own GLCapabilitiesChooser which examines the available ones and chooses one appropriately. On Mac OS X the GLCapabilitiesChooser currently doesn’t work due to how pixel formats are chosen and the fact that it isn’t possible to enumerate the available pixel formats for a given renderer (to the best of my knowledge). We’re still thinking about how to fix this.
It would be great if it was possible to ask a drawable for its GLCapabilies after it has been creating.
Since I lack this, I had to create a decorator of DefaultGLCapabilityChooser which stores the choosen capability for later use.
This is not fully satisfying since it make me maintains a parallel data structure for this, leading to a “not that clean” design of my engine.
Vincent
Ok, I try this:
GLCapabilities cap = new GLCapabilities();
cap.setSampleBuffers(true);
cap.setNumSamples(2);
GLCapabilitiesChooser capChooser = new GLCapabilitiesChooser() {
public int chooseCapabilities(GLCapabilities cap, GLCapabilities[] available, int recommended) {
System.out.println("choose..");
for (int c=0; c<available.length; c++) {
int ns = available[c].getNumSamples();
System.out.println("Numsamples = " + ns);
}
return recommended;
}
};
glCanvas = new GLCanvas(cap, capChooser, null, null);
But nothing is printed, not even “choose…”. So it appears that my GLCapabilitiesChooser is ignored by “new GLCanvas” ?
Did you actually show the GLCanvas? On Windows the pixel format isn’t chosen until the widget is realized.
Ok, I didn’t show the glCanvas, and when I do, chooseCapabilities is called. That solves part of my problem, but not completely. The idea was to present a selection screen where one can choose things like screen resolution etc, including antialiasing settings. But when I make the glCanvas visible, the AWT background is already showing, and it is a little late to present that selection screen. The original idea was to create a a GLCanvas, without showing it, just in order to obtain the available settings, then throw it away and create a new one with user selected settings.
You can do this by making a small (1x1 or so) undecorated Frame and adding a GLCanvas to it, showing it briefly and disposing of it as soon as it’s shown and you’ve made your queries.
With the previous JSR231 release (beta01, October 2005), this form of querying worked. But with the new release (JSR231 beta02), the antialiasing demo reports: WARNING: antialiasing will be disabled because none of the available pixel formats had it to offer
Despite the warning, antialiasing works without any problem. It appears that the GLCapabilities[] passed to the MultisampleChooser in the antialiasing demo has all identical copies: caps.getSampleBuffers() is false, caps.getNumSamples() = 2
Could you please file an Issue about this? Perhaps something got broken in beta 2.
Thanks for filing Issue 193. It was accidentally introduced during a refactoring of JOGL’s multisample support to support multisampled pbuffers. The next nightly build should contain the fix. The build last night didn’t succeed but we’ll either push one manually or just allow tomorrow’s to be generated automatically.
Helloheya, I went bak to recompile my glcapdemo i abandoned and it doesn’t work. i found out that my tablet’s ati x600se has 54 available glcaps but some are null. so the default chooser detect this? result and source included…
print out:
Available 0: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAccel
erated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8
, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0 ]
Available 1: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAccel
erated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8
, Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16 ]
Available 2: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAccel
erated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8
...//cutting this short
Available 47: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAcce
lerated: false, DepthBits: 16, StencilBits: 8, Red: 3, Green: 3, Blue: 2, Alpha:
0, Red Accum: 0, Green Accum: 0, Blue Acnull index: 6
null index: 7
null index: 8
null index: 9
null index: 10
null index: 11
null index: 12
null index: 13
null index: 14
null index: 15
null index: 16
null index: 17
cum: 0, Alpha Accum: 0 ]
Available 48: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAcce
lerated: false, DepthBits: 32, StencilBits: 8, Red: 1, Green: 1, Blue: 1, Alpha:
0, Red Accum: 5, Green Accum: 6, Blue Accum: 5, Alpha Accum: 0 ]
Available 49: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAcce
lerated: false, DepthBits: 16, StencilBits: 8, Red: 1, Green: 1, Blue: 1, Alpha:
0, Red Accum: 5, Green Accum: 6, Blue Accum: 5, Alpha Accum: 0 ]
Available 50: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAcce
lerated: false, DepthBits: 32, StencilBits: 8, Red: 1, Green: 1, Blue: 1, Alpha:
8, Red Accum: 4, Green Accum: 4, Blue Accum: 4, Alpha Accum: 4 ]
Available 51: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAcce
lerated: false, DepthBits: 16, StencilBits: 8, Red: 1, Green: 1, Blue: 1, Alpha:
8, Red Accum: 4, Green Accum: 4, Blue Accum: 4, Alpha Accum: 4 ]
Available 52: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAcce
lerated: false, DepthBits: 32, StencilBits: 8, Red: 1, Green: 1, Blue: 1, Alpha:
0, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0 ]
Available 53: GLCapabilities [DoubleBuffered: false, Stereo: false, HardwareAcce
lerated: false, DepthBits: 16, StencilBits: 8, Red: 1, Green: 1, Blue: 1, Alpha:
0, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0 ]
source:
import javax.media.opengl.*;
import javax.swing.JFrame;
/*******************************************************************************
* @author kiet
******************************************************************************/
public class PrintGLCaps
extends DefaultGLCapabilitiesChooser
{
/**
*/
public PrintGLCaps()
{
super();
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args)
{
PrintGLCaps demo = new PrintGLCaps();
GLCanvas canvas = new GLCanvas(null, demo, null, null);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(512, 128);
frame.setLocationRelativeTo(null);
frame.add(canvas);
frame.setVisible(true);
System.out.println(com.sun.opengl.util.Version.getVersion());
}
// override
public int chooseCapabilities(GLCapabilities desired,
GLCapabilities[] available,
int windowSystemRecommendedChoice)
{
for (int i = 0; i < available.length; i++)
{
if ( available[ i ] != null ) System.out
.println("--> Available " + i + ": " + available[ i ]);
else System.err.println("null index: " + i);
}
return super.chooseCapabilities(desired, available,
windowSystemRecommendedChoice);
}
}
also, the version string should include the nightly build date. – ak77 Ka-El
I can tell from the GLCapabilities printing that this is the version of the code without the bug fix. Could you please try the current build on the JOGL page dated 1/21 or later?
Thanks for the suggestion. I’ve filed Issue 194 to track this.
i’ve just updated my jogl environment to today’s build (in jdk/jre/ext, jdk/jre/bin, and windows/system32). and still i have null capabilities from the available capabilities.
the code below is the same as before, except for printout details.
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import javax.swing.JFrame;
/*******************************************************************************
* @author kiet
******************************************************************************/
public class PrintGLCaps
extends DefaultGLCapabilitiesChooser
{
/**
*/
public PrintGLCaps()
{
super();
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args)
{
PrintGLCaps demo = new PrintGLCaps();
GLCanvas canvas = new GLCanvas(null, demo, null, null);
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(512, 128);
frame.setLocationRelativeTo(null);
frame.add(canvas);
frame.setVisible(true);
System.out.println(com.sun.opengl.util.Version.getVersion());
}
// override
public int chooseCapabilities(GLCapabilities desired,
GLCapabilities[] available,
int windowSystemRecommendedChoice)
{
System.out.println("DESIRED: " + desired.toString() + "\n\nCHOSEN: "
+ available[ windowSystemRecommendedChoice ]
+ "\n\nLISTING: ");
for (int i = 0; i < available.length; i++)
{
if ( available[ i ] != null ) System.out
.println("--> Available " + i + ": " + available[ i ]);
else System.err.println("null index: " + i);
}
return super.chooseCapabilities(desired, available,
windowSystemRecommendedChoice);
}
}//
SHould that be turning up–the null caps? if so, i’ll need to rework my proggie. – ka-el
Yes, the null capabilities are possible. For example, some of the pixel formats don’t support drawing to a window so they aren’t offered as possible choices.
Hey peeps, here’s a demo on using GLCapabilities interface, DefaultGLCapabilitiesChooser. Proggie consists of two windows: the main window has a text area to display capabilities info and index number with controls for traversing the index and recreating a child window with the new capabilities for the canvas.
If you don’t see the spinning gears then the capabilities that you have selected is not supported or only works for another display depth (or color bits, whichh can be set in display panel and try again–child window is closable w/O quiting the main window).
try it out, tell me what you think. btw, Ken, can put this program in the demo package? attach: PrintGLCaps2.java.txt; you’ll need to remove the Gears inner class and import demos.gears.Gears. bye. – ak
Thanks for the demo. Do you think you could modify it to use a JTable instead of a JTextArea to store the data in a little more clear fashion? Something like NVidia’s NVPixelFormat. If you don’t have time to do this then please file an Enhancement with the jogl-demos Issue Tracker, attach your current sources, and we’ll try to take care of it later.
I just looked @above nvpixel format demo (huge, 11MB). i commenced mimicking that familarity w/ jtable and hopefully by the week’s end i’ll resubmit. (school isa starting monday. :-X)
;D All done. where there are null caps a cap w/ zeros and false are set and store in a list/table. usage: select a row and spawn a junior to display the rotating gears. please try out and report and problems here. file attach. – ka-el
This looks almost perfect. Could you take care of a couple of remaining issues?
The table is huge – it takes up the entire screen. Could you do something about that? Instead of “true”/“false”, perhaps “y”/“n” could help make the columns less wide.
Do you think you could embed the GLCanvas inside the JFrame or something similar so that you don’t have to deal with two windows? Making the subordinate window appear right next to the table’s window might also work IMO.
Thanks. Also, could you clarify the license in the comments at the top? I’m hoping you’ll make it BSD-licensed like the rest of the JOGL sources.
i concor, the table is shorter than NVpixelformat demo, but i can make it short as you suggested.
embedding canvas inside jframe, possible. it was annoying have to have a subwin around so u can see what was chosen under.
as for license, ken, you have my permission to changed to BSD. i’ll be return to his post in the weekend with new code. – ka-el