LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: jglover13 on July 07, 2004, 05:46:41

Title: alpha depth not great enough
Post by: jglover13 on July 07, 2004, 05:46:41
Guys,

Another newbie question.

I'm having a difficult time with the newest version (from CVS) of lwjgl.  I'm trying to port over the NeHe tutorial #10 to the newest version.  The problem is that Display and Window have been merged, and the interface isn't quite the same.  The old code was:

Window.create(windowTitle, 32, 0, 8, 0);

which I've replaced with this:

Display.create(new PixelFormat(32, 0, 8, 0));

The problem is I keep getting this error:

Current mode 1280 x 1024 x 32 @85Hz
org.lwjgl.LWJGLException: This application requires a greater alpha depth
       at org.lwjgl.opengl.Display.createContext(Native Method)
       at org.lwjgl.opengl.Display.create(Unknown Source)


Unfortunately, I don't understand what the alpha depth is enough to troubleshoot this on my own.  I've done some googling, but I really don't know what I'm looking for.  Has anyone else encountered this, or can anyone point me to where I can learn about alpha depth?

I also need to change this:

Window.create(windowTitle, 0, 0, 640, 480, 32, 0, 8, 0);
Title: alpha depth not great enough
Post by: elias on July 07, 2004, 08:30:39
The bpp (32) is taken from the current display mode, and not from the PixelFormat argument. The current constructors of PixelFormat are:

      public PixelFormat() {
               this(0, 0, 0);
       }

       public PixelFormat(int alpha, int depth, int stencil) {
               this(alpha, depth, stencil, 0);
       }

       public PixelFormat(int alpha, int depth, int stencil, int samples) {
               this(0, alpha, depth, stencil, samples);
       }

       public PixelFormat(int bpp, int alpha, int depth, int stencil, int samples) {
               this(bpp, alpha, depth, stencil, samples, 0, 0, 0, false);
       }

       public PixelFormat(int bpp, int alpha, int depth, int stencil, int samples, int num_aux_buffers, int accum_bpp, int accum_alpha, boolean stereo) {


So you'll need to use "new PixelFormat(alpha, depth, stencil)", or in your specific case:


Display.create(new PixelFormat(0, 8, 0));


Hope it helps,
- elias
Title: alpha depth not great enough
Post by: chriddel on July 08, 2004, 00:31:07
I updated my drivers and now I get the same error -
but only happens in window-mode (fullscreen works fine).

i dont fully understand how to fix this error...

do i erase the window.create() command and substitute it by the display.create() method??

chris
Title: alpha depth not great enough
Post by: elias on July 08, 2004, 06:45:03
Quote from: "chriddel"
do i erase the window.create() command and substitute it by the display.create() method??


Yes. A Display.create(new PixelFormat(0, 8, 0)) should be enough. After that, you can do a Display.setTitle("Nehe demo X").

- elias
Title: alpha depth not great enough
Post by: jglover13 on July 08, 2004, 17:06:42
I thought I had this figured out, but now I'm getting all confused again.  As you can see in this thread (http://puppygames.net/forums/posting.php?mode-reply&t=632) I am having problems creating a context.  

I've been able to list the modes available to me, but I am at a loss as to how to create a context with one of these modes.

416 x 312 x 16 @0Hz
360 x 200 x 16 @0Hz
640 x 400 x 16 @0Hz
800 x 600 x 16 @0Hz
640 x 350 x 16 @0Hz
320 x 240 x 16 @0Hz
832 x 624 x 16 @0Hz
320 x 200 x 16 @0Hz
1024 x 768 x 16 @0Hz
576 x 384 x 16 @0Hz
512 x 384 x 16 @0Hz
720 x 400 x 16 @0Hz
400 x 300 x 16 @0Hz
640 x 480 x 16 @0Hz
320 x 175 x 16 @0Hz
org.lwjgl.LWJGLException: Could not create a direct GLX context
at org.lwjgl.opengl.Display.createContext(Native Method)
at org.lwjgl.opengl.Display.create(Unknown Source)
at org.lwjgl.opengl.Display.create(Unknown Source)
at Lesson10.createWindow(Lesson10.java:268)
at Lesson10.init(Lesson10.java:287)
at Lesson10.run(Lesson10.java:94)
at Lesson10.main(Lesson10.java:88)


I used the following code to accomplish the listing (for others who are new and curious):

   DisplayMode d[] = Display.getAvailableDisplayModes();
for (int i = 0; i < d.length; i++) {
   System.out.println((d[i]).toString());
}


If I see any modes at all, that means I should be able to concievably get the thing running, correct?

The only available means I see to create a context are through Display.create() and Display.create(PixelFormat pixel_format).  Neither of these methods allow me to set a DisplayMode.  I am looking at the source code so I am sure I am seeing the most up-to-date information here.  Am I missing something?
Title: alpha depth not great enough
Post by: princec on July 08, 2004, 17:19:44
Those are just available DisplayModes. These are different from PixelFormats. You should in theory be able to pick any display mode from that list and change to it using Display.setDisplayMode(). Don't forget to try alternative modes if an Exception is thrown - we can't guarantee a returned DisplayMode will actually work.

To begin with you don't really need to change display modes to get up and running. The simplest possible LWJGL program init looks like this:

Display.create();

and that should get you a fullscreen display that uses the current display mode, with a minimum of 0 bits of alpha, minimum 16 bits of depth, and minimum 0 bits of stencil.


Cas :)
Title: alpha depth not great enough
Post by: jglover13 on July 08, 2004, 17:48:09
I think I'm getting this narrowed down.  

So, if I use simply Display.create(), it should work if it's ever going to work on this system?  The reason I ask is because I tried using just that code to create the context, and I still get the "org.lwjgl.LWJGLException: Could not create a direct GLX context" exception.

You mentioned that you could not guarantee a display mode which is found will work properly.  So it is possible that none of the listed display modes I see will work?

Thanks for your help.
Title: alpha depth not great enough
Post by: elias on July 08, 2004, 18:01:20
It sounds like you don't have a hardware accelerated X server. Try running 'glxinfo' and look for a line like:


elias@ip173:~> glxinfo | grep -i direct
direct rendering: Yes


Yes means you have hardware acceleration, No means you don't. To force lwjgl into using the software opengl drivers you need to specify


-Dorg.lwjgl.opengl.Window.allowSoftwareOpenGL=true


on the command line.

- elias
Title: alpha depth not great enough
Post by: jglover13 on July 08, 2004, 18:11:42
Well, yes, apparently you are correct.  I do not.  I was confused because I had run "glxgears" and it ran perfectly well at 85.4 fps.  I suppose it must be using software to run, though it seems a high number of fps for software rendering.  

In any case, I've added the argument and things are working now, if a little slow.  I guess I will just have to test my programs on my desktop and forget trying to use the laptop.

Thanks for your help.
Title: alpha depth not great enough
Post by: princec on July 08, 2004, 18:40:12
What chipset is in that laptop did you say?

Cas :)
Title: alpha depth not great enough
Post by: jglover13 on July 08, 2004, 18:51:05
It's an 8 MB ATI Rage Mobility.  It is listed as supporting OpenGL, so there must be a way to get this to work with Linux, but I've spent quite a bit of time already.  I'm running Fedora Core 2, with the 2.6.5 Linux Kernel, which I recently upgraded to.  When I was running Fedore Core 1 with the 2.4.x Kernel, the ATI card wouldn't run glxgears correctly, so I upgraded.

Of course I'd like to get it to work, but I didn't want to go asking all kinds of crazy Linux questions and clutter up your the pretty LWJGL forums.

The reason I am trying to get the laptop to work in the first place is that I'm in an open source development class at Portland State University this term and I chose to develop a game engine running on top of LWJGL for my project.  Since the class is mostly lab based, I wanted to be able to carry around my main development machine so I could set it up in class and work there.