How to blit components in 3D app based on jPCT

Started by me520, April 05, 2010, 12:49:24 PM

Previous topic - Next topic

me520

HI ,I am back...

First I've to say thanks for this great 3D engine.

but after some tests i got a problem in jPCT Car demo

I want to know how could i add a JTextField or JTextArea in scene of Car demo to accept user's input?

e.g.
there have two textfield "input" and "show"
I input some text in "input" textfield,and when press "send" button,the message was display on "show" textfield

EgonOlsen

Are you using the software or the hardware renderer?

me520

use hardware accelerated rendering using OpenGL,maybe i need to use software?

EgonOlsen

Well, you can't render Swing or AWT components on top of a native OpenGL output. You can try to use FrameBuffer.enableGLCanvasRenderer() (don't forget to disable the software renderer in addition), which will return a Canvas. This (heavyweight) Canvas can be combined with Swing/AWT components to a degree. You should find some information about this when searching the forums.


me520

Quote from: EgonOlsen on April 06, 2010, 07:07:28 AM
Well, you can't render Swing or AWT components on top of a native OpenGL output. You can try to use FrameBuffer.enableGLCanvasRenderer() (don't forget to disable the software renderer in addition), which will return a Canvas. This (heavyweight) Canvas can be combined with Swing/AWT components to a degree. You should find some information about this when searching the forums.

well,as you say ,I get a AWTGLCanvas which i can put this canvas into a JFrame,but the KeyMapper is wrong, i implements a KeyListener(java.awt.event.KeyListener;),but it seemes not work

my code such as
public class Test implements KeyListener {
        frame = new JFrame("test");
        panel = new JPanel();
        frame.setLayout(new GridLayout(1,1));
   frame.setSize(width, height);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.add(panel);
        frame.setVisible(true);
   buffer = new FrameBuffer(panel.getWidth(),panel.getHeight(),FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
   buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
   //buffer.enableRenderer(IRenderer.RENDERER_OPENGL, IRenderer.MODE_OPENGL);
   canvas = buffer.enableGLCanvasRenderer();
   panel.add(canvas,new GridLayout(1,1));
   canvas.addKeyListener(this);
   frame.addKeyListener(this);
}

public void keyTyped(KeyEvent e){
   System.out.println("ley d");
}
public void keyPressed(KeyEvent e){
   System.out.println("ley d");
}
public void keyReleased(KeyEvent e){
   System.out.println("ley d");
}

the game loop is
buffer.clear();
theWorld.renderScene(buffer);
theWorld.draw(buffer);
buffer.update();
buffer.displayGLOnly();
canvas.repaint();

Is there something I can change to allow the mapper to be correctly ?

EgonOlsen

Looks fine to me at first glance. I can't remember exactly if it has to be added to the frame or the canvas...you are doing both. Maybe doing just one of them will make it work?

me520

Quote from: EgonOlsen on April 08, 2010, 01:06:35 PM
Looks fine to me at first glance. I can't remember exactly if it has to be added to the frame or the canvas...you are doing both. Maybe doing just one of them will make it work?

hi,
i did as you said,but keylisten still not work... :'(

now i am seeking other way...

i used the project powered by raft http://www.jpct.net/forum2/index.php/topic,1338.0.html,everything is run well,but JScrollPanel and JTextArea can't work
i don't konw what's wrong,so give it up

now,i find a GUI API (FengGUI),i will do some test with it later,could you give me more info about it,or other gui project like FengGui :P

this thread will update,if something run, i will let you know first ;D

raft

Quote from: me520
i used the project powered by raft http://www.jpct.net/forum2/index.php/topic,1338.0.html,everything is run well,but JScrollPanel and JTextArea can't work
swing-gl is not a completed project. for example keyboard events are not dispatched so it's normal that JTextArea doesn't work.

you may want to have a look at PureSwing. it's a mature project but a bit big in size and requires a fairly decent video card

Achim

is there a ready made code snippet and associated texture with numbers and letters which I could use to display simple strings when using the HW renderer?


me520


me520

Quote from: raft on April 13, 2010, 03:53:25 PM
swing-gl is not a completed project. for example keyboard events are not dispatched so it's normal that JTextArea doesn't work.

you may want to have a look at PureSwing. it's a mature project but a bit big in size and requires a fairly decent video card

Hi,raft,

I have in trouble and need your help

If i write my keyboard events,how could I do ,give tips please

raft

if you ask for swing-gl, i dont know :-\ my swing knowledge is not that good. that's why i shared the project and asked for help..