Author Topic: non standard window size and OPENGL renderer?  (Read 2507 times)

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
non standard window size and OPENGL renderer?
« on: December 26, 2015, 04:02:52 pm »
hello i just started to try jpct the desktop version. so far i created a non fullscreen window with non standard size , but can't get OPENGL hardward renderer.
another problem is, if i set the window size to a standard size, the OPENGL renderer opens another window that i don't want.
how to setup the window correctly?

my current code is like this:

GraphicsEnvironment e=GraphicsEnvironment.getLocalGraphicsEnvironment();
gDevice=e.getDefaultScreenDevice(); GraphicsConfiguration gc=gDevice.getDefaultConfiguration();
gwin=new Frame(gc); gwin.setUndecorated(true); gwin.setIgnoreRepaint(true); gwin.setResizable(false);
gwin.pack(); Dimension d=new Dimension(1280,766); gwin.setSize(d);
gwin.setVisible(true); gfx=gwin.getGraphics();
gbuf=new FrameBuffer(1280,766,FrameBuffer.SAMPLINGMODE_NORMAL);
gbuf.enableRenderer(IRenderer.RENDERER_OPENGL); gbuf.optimizeBufferAccess();

and in the mainloop:
gbuf.clear(); gbuf.update(); gbuf.display(gfx);

note that i want the window to have no border/title, and sized 1280x766 (766=800-34, the height of taskbar)
in my experience at other 3D engine, non standard window size is achievable.
i am new to java and jpct, so can't find out what's wrong in my code. could someone help me? thanks.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: non standard window size and OPENGL renderer?
« Reply #1 on: December 26, 2015, 05:14:57 pm »
You are mixing several things here. You create an AWT Frame and a native OpenGL window at the same time and then you are enabling the GL renderer but not disabling the software renderer.
The easiest way, as long as you don't need an AWT Frame, is to just scrap that part...begin at the new FrameBuffer...line and add a line that disables the software renderer.
If you have to render into an AWT Frame for whatever reason, you can do that as well, but you then have to use the enableGLCanvasRenderer-method instead and add the returned Canvas to your Frame. But I would prefer the native GL window if possible.
« Last Edit: December 26, 2015, 05:18:22 pm by EgonOlsen »

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
Re: non standard window size and OPENGL renderer?
« Reply #2 on: December 27, 2015, 05:11:50 am »
i tried adding the Canvas to Frame, also disabled software renderer, but still a new GL window showed up, i thought GL should render into the Canvas which was added into Frame.
i use Frame because i don't know how to manipulate the window created by FrameBuffer, for example change the style, size, position. and fullscreen mode is not good during development so i always prefer windowed mode. and java doesn't expose HWND so i can't even use DLL calls to change the window.
could you tell me how to create an opengl window without border and sized 1280x766? in pseudo code?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: non standard window size and OPENGL renderer?
« Reply #3 on: December 27, 2015, 04:24:19 pm »
You can manipulate the GL window by the means that LWJGL offers in it's Display class (make sure to look at the LWJGL 2.x docs, not the ones of the 3.0 behemoth. jPCT itself doesn't allow for a resolution that the driver doesn't report and these usually don't include custom ones. But you can do something like this:

Code: [Select]
    buffer = new FrameBuffer(640, 480, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
    buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
    buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
    // Resize the window
    Display.setDisplayMode(new DisplayMode(511, 577));
    buffer.resize(511, 577);

I'm not sure about the window decorations. Maybe it's possible with Display as well, but I really don't know.

Anyway, if you want to stick with AWTGLRenderer and are still getting two windows, you are still doing it wrong. Have a look at the HelloWorld examples that come with jPCT. There's one that shows how to initialize that renderer correctly.

Hopet this helps...


Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
Re: non standard window size and OPENGL renderer?
« Reply #4 on: December 27, 2015, 06:04:25 pm »
it helps. thank you.
right now i use JNA to call FindWindow & SetWindowLong in user32.dll in order to hide the decoration. so far the program seems working correctly.