Hello Guest

Pixel format cannot be set randomly

  • 0 Replies
  • 125 Views
Pixel format cannot be set randomly
« on: September 26, 2019, 09:25:59 »
Hi,

i am having a very tedious problem with my java application where the context cannot be created because the PixelFormat cannot be set. This happens absolutely random.
Like sometimes i start and close the rendering window 100 times and it works perfectly. Other times it happens on the first atempt.

It is a swing application which uses jawt to connect lwjgl and opengl.
Problem appears with function:

GDI32.SetPixelFormat(hDC, pixelFormat, pfd);
The last error is 2000 -> The pixel format is invalid.

I discovered that everytime it succedes to set the pixel format is when the hDC has no pixel format set before. And when it fails the hDC has a pixel format set with index 186 and description 220.

I dont know why suddenly that window has a pixel format set.

I discovered that passing -Dsun.java2d.opengl=false as vm argument to the java application solves this particular problem, but then my swing GUI has some weird scaling problems, which is no solution for me.

Sadly i cannot reproduce it with a simple test project :(.

So here goes my cry for help:
How can it happen that a drawing surface has already a PixelFormat set, which impedes me from setting it one?
And most importantly how can i solve it?

Background info:
Currently using LWGL 3.1.6, tried using the 3.2.3 with same result
AWT connection based on Kai Burjack's implementation -> https://github.com/httpdigest/lwjgl3-awt/
Using Java JDK 1.8
GraphicCard: GeForce RTX2070 with latest driver 436.30

Thx a lot in advance.

Roland