www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: me520 on April 05, 2010, 12:49:24 pm
-
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
-
Are you using the software or the hardware renderer?
-
use hardware accelerated rendering using OpenGL,maybe i need to use software?
-
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.
-
OK ,thanks
-
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 ?
-
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?
-
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
-
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 (http://pureswing.advel.cz/). it's a mature project but a bit big in size and requires a fairly decent video card
-
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?
-
You can use raft's GLFont for this: http://www.jpct.net/forum2/index.php/topic,1074.0.html (http://www.jpct.net/forum2/index.php/topic,1074.0.html)
-
thanks
give me some time ;D
-
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 (http://pureswing.advel.cz/). 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
-
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..