'Could not find valid pixel format' when samples=8 & i have latest video driver

I am this error with a RADEON X300se on my work PC.  I updated the drivers to the latest version yesterday and I am still seeing the error.  I have determined that the application runs fine when I comment out the line samples = 8; in my constructor so therein lies a clue. With that line uncommented, the game runs fine with anti-aliasing on my home PC and on a coworkers PC.  Any clues?  Here's my error log:



(p.s. I started a new thread because I don't want to hijack the other thread in the graphics forum.)



<?xml version="1.0" encoding="windows-1252" standalone="no"?>

<!DOCTYPE log SYSTEM "logger.dtd">

<log>

<record>

  <date>2008-04-15T13:32:52</date>

  <millis>1208284372484</millis>

  <sequence>0</sequence>

  <logger>com.sun.deploy</logger>

  <level>FINE</level>

  <class>com.sun.deploy.util.LoggerTraceListener</class>

  <method>print</method>

  <thread>10</thread>

  <message>Exception in thread "Thread-2" java.lang.OutOfMemoryError: unable to create new native thread

</message>

</record>

<record>

  <date>2008-04-15T13:32:52</date>

  <millis>1208284372500</millis>

  <sequence>1</sequence>

  <logger>com.sun.deploy</logger>

  <level>FINE</level>

  <class>com.sun.deploy.util.LoggerTraceListener</class>

  <method>print</method>

  <thread>10</thread>

  <message>  at java.lang.Thread.start0(Native Method)

</message>

</record>

<record>

  <date>2008-04-15T13:32:52</date>

  <millis>1208284372500</millis>

  <sequence>2</sequence>

  <logger>com.sun.deploy</logger>

  <level>FINE</level>

  <class>com.sun.deploy.util.LoggerTraceListener</class>

  <method>print</method>

  <thread>10</thread>

  <message>  at java.lang.Thread.start(Unknown Source)

</message>

</record>

<record>

  <date>2008-04-15T13:32:52</date>

  <millis>1208284372500</millis>

  <sequence>3</sequence>

  <logger>com.sun.deploy</logger>

  <level>FINE</level>

  <class>com.sun.deploy.util.LoggerTraceListener</class>

  <method>print</method>

  <thread>10</thread>

  <message>  at com.sun.javaws.LaunchDownload.updateCheck(Unknown Source)

</message>

</record>

<record>

  <date>2008-04-15T13:32:52</date>

  <millis>1208284372500</millis>

  <sequence>4</sequence>

  <logger>com.sun.deploy</logger>

  <level>FINE</level>

  <class>com.sun.deploy.util.LoggerTraceListener</class>

  <method>print</method>

  <thread>10</thread>

  <message>  at com.sun.javaws.LaunchDownload.isUpdateAvailable(Unknown Source)

</message>

</record>

<record>

  <date>2008-04-15T13:32:52</date>

  <millis>1208284372500</millis>

  <sequence>5</sequence>

  <logger>com.sun.deploy</logger>

  <level>FINE</level>

  <class>com.sun.deploy.util.LoggerTraceListener</class>

  <method>print</method>

  <thread>10</thread>

  <message>  at com.sun.javaws.Launcher$RapidUpdateCheck.run(Unknown Source)

</message>

</record>

<record>

  <date>2008-04-15T13:32:57</date>

  <millis>1208284377781</millis>

  <sequence>7</sequence>

  <logger>com.sun.deploy</logger>

  <level>FINE</level>

  <class>com.sun.deploy.util.LoggerTraceListener</class>

  <method>print</method>

  <thread>10</thread>

  <message>Apr 15, 2008 1:32:57 PM com.jme.system.PropertiesIO load

WARNING: Could not load properties. Creating a new one.

</message>

</record>

<record>

  <date>2008-04-15T13:33:05</date>

  <millis>1208284385078</millis>

  <sequence>9</sequence>

  <logger>com.sun.deploy</logger>

  <level>FINE</level>

  <class>com.sun.deploy.util.LoggerTraceListener</class>

  <method>print</method>

  <thread>10</thread>

  <message>Apr 15, 2008 1:33:05 PM com.jme.system.lwjgl.LWJGLDisplaySystem initDisplay

SEVERE: Cannot create window

</message>

</record>

<record>

  <date>2008-04-15T13:33:05</date>

  <millis>1208284385078</millis>

  <sequence>12</sequence>

  <logger>com.sun.deploy</logger>

  <level>FINE</level>

  <class>com.sun.deploy.util.LoggerTraceListener</class>

  <method>print</method>

  <thread>10</thread>

  <message>Apr 15, 2008 1:33:05 PM class com.jme.system.lwjgl.LWJGLDisplaySystem initDisplay()

SEVERE: Exception

org.lwjgl.LWJGLException: Could not find a valid pixel format

  at org.lwjgl.opengl.WindowsPeerInfo.nChoosePixelFormat(Native Method)

  at org.lwjgl.opengl.WindowsPeerInfo.choosePixelFormat(WindowsPeerInfo.java:52)

  at org.lwjgl.opengl.WindowsDisplayPeerInfo.initDC(WindowsDisplayPeerInfo.java:54)

  at org.lwjgl.opengl.WindowsDisplay.createWindow(WindowsDisplay.java:150)

  at org.lwjgl.opengl.Display.createWindow(Display.java:260)

  at org.lwjgl.opengl.Display.create(Display.java:742)

  at org.lwjgl.opengl.Display.create(Display.java:694)

  at com.jme.system.lwjgl.LWJGLDisplaySystem.initDisplay(Unknown Source)

  at com.jme.system.lwjgl.LWJGLDisplaySystem.createWindow(Unknown Source)

  at com.jme.app.BaseSimpleGame.initSystem(Unknown Source)

  at game.TestGame.initSystem(TestGame.java:115)

  at com.jme.app.BaseGame.start(Unknown Source)

  at game.TestGame$2.run(TestGame.java:346)

  at java.lang.Thread.run(Unknown Source)

  at game.TestGame.main(TestGame.java:347)

  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at com.sun.javaws.Launcher.executeApplication(Unknown Source)

  at com.sun.javaws.Launcher.executeMainClass(Unknown Source)

  at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)

  at com.sun.javaws.Launcher.run(Unknown Source)

  at java.lang.Thread.run(Unknown Source)

</message>

</record>

<record>

  <date>2008-04-15T13:33:05</date>

  <millis>1208284385078</millis>

  <sequence>13</sequence>

  <logger>com.sun.deploy</logger>

  <level>FINE</level>

  <class>com.sun.deploy.util.LoggerTraceListener</class>

  <method>print</method>

  <thread>10</thread>

  <message>Apr 15, 2008 1:33:05 PM com.jme.app.BaseSimpleGame initSystem

SEVERE: Could not create displaySystem

com.jme.system.JmeException: Cannot create window: Could not find a valid pixel format

  at com.jme.system.lwjgl.LWJGLDisplaySystem.initDisplay(Unknown Source)

  at com.jme.system.lwjgl.LWJGLDisplaySystem.createWindow(Unknown Source)

  at com.jme.app.BaseSimpleGame.initSystem(Unknown Source)

  at game.TestGame.initSystem(TestGame.java:115)

  at com.jme.app.BaseGame.start(Unknown Source)

  at game.TestGame$2.run(TestGame.java:346)

  at java.lang.Thread.run(Unknown Source)

  at game.TestGame.main(TestGame.java:347)

  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

  at java.lang.reflect.Method.invoke(Unknown Source)

  at com.sun.javaws.Launcher.executeApplication(Unknown Source)

  at com.sun.javaws.Launcher.executeMainClass(Unknown Source)

  at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)

  at com.sun.javaws.Launcher.run(Unknown Source)

  at java.lang.Thread.run(Unknown Source)

</message>

</record>

</log>

I looked up your card specs on the following page:

http://ati.amd.com/products/radeonx300/specs.html



It would appear that the sample modes your card can support are 2x/4x/6x, so try using one of those for your sample count instead of 8x.

I will try that.  I did see that as well and I wondered if the 2x, meant it supports samples=2, but I was not sure.  So, from a design point of view, should one use try catch statements (in a BaseGame scenerio) to try sample settings and move down until there is no exception thrown so the game will run on the most possible configurations?  Or is there generally another method of handling this that gets employed?



Thanks so much for your answer and clarification on that.  I will let you know how it goes.

Doing some research, I found that when writing native code you need to use ChoosePixelFormat on your pixel parameters until it succeeds in finding a pixel format, then the window is initialized with the working pixel format parameters. LWJGL doesn't seem to provide this kind of facility; you need to call Display.create, catch the exceptions and change the pixel format until it works.

Yep, I wish they would provide something a little nicer in this area.  Of course, if someone wants to simply write a good example of this in jME, it would make a nice addition.

It's going in the right direction, but we probably need something where we can say "here's the display params I think I want… give me the closest working match.  Oh, and here's the params you CAN'T touch. (usually just width and height I'd guess)"  Maybe even say that the order we give the params defines its priority.

Yea, I think my biggest concern with finding the closest match when using multiple parameters is priority (what do we reduce first).  Even with the properties prioritized, we may need a flag to indicate how reduction should be done (e.g. take the first priority down to the lowest step and the move on to the next property, or reduce each by one step in the order of priority and repeat).  Does that make sense?



Also, regarding the order we give parameters, are you thinking something like a hash map or an array (which would be indexed so I can see order)?  Maybe a custom object for display properties all together?  Or did you have something else in mind?



I assume the only properties we need to concern ourselves with are width, height, depth, frequency, full screen, depthBits, stencilBits, alphaBits and samples.  I also assume that only even numbers are truly valid for samples, and I will need to research the rest a bit (I don't even know what some of them are/do).



I am unfortunately kind of a newb to java and definitely a newb to jME (only a few weeks here) so if you are willing to help guide me, I'd love to contribute.  :smiley:





EDIT:  Just got another idea, and maybe this is better, I don't know.  You pass in a property list in what ever format.  All properties are set to minimal values except for the current one being tested.  Then test each property until a display can be created.  This would get the maximum allowable property value for each, but there may be some conflicts in combinations of values I guess (like how 1600x1200 may be supported at 60hz, but 640x480 can run 100hz, 1600x1200 at 100hz may be returned).  Food for thought  :expressionless:

Actually, you don't have write access, so don't worry about messing anything up.  :slight_smile:



Generally you'd post it up here and everyone would eval it and then one of the devs would brush it up and check it in.



Can't look too deep at this now, but keep going!