Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - dunkedbiscuit

Pages: 1 [2]
16
Support / Orientating a car object to face a point
« on: November 23, 2011, 12:31:58 am »
Hello,

I would like a function which makes one object face another object, in that object A "points towards" object B. This would allow me to make some racing car pathfinding, since they need to move in the direction of successive point vectors to simulate driving along a road. I suppose I should be more precise with "pointing"; maybe the vertical axis of object A should be aligned with a vector travelling from the centre of object A to the centre of object B?

Many thanks!

17
Support / Re: Accessing openGL object
« on: November 17, 2011, 09:23:18 pm »
Success!  ;D I've removed the paintComponent method from the JPanel I extended, and passed it the canvas object instead of the framebuffer. Thanks to the example I also found the right way to get it to draw: use fb.updateGLOnly() and then canvas.repaint(). Everything else regarding key and mouse events on the JPanel works as before (once I changed the listeners to work on the canvas rather than the JPanel itself). Thanks for your help!!!

But er... one last thing  ;) You wouldn't happen to know how to get the Graphics drawing functions to work on top of the canvas? See, I get the Graphics object from the canvas during the render method, and when I try to run drawString at any point, I cannot see the text. I suppose this has to do with the fb.updateGLOnly() bit.

18
Support / Re: Accessing openGL object
« on: November 17, 2011, 03:08:57 pm »
Certainly. This is run from NetBeans if that helps...

Code: [Select]
run:
Java version is: 1.6.0_24
-> support for BufferedImage
Version helper for 1.5+ initialized!
-> using BufferedImage
Software renderer (OpenGL mode) initialized
Using LWJGL's AWTGLCanvas
Loading Texture...box.jpg
New WorldProcessor created using 1 thread(s) and granularity of 1!
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.awt.EventQueue.invokeAndWait(EventQueue.java:1043)
        at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1326)
        at racer.Main.loop(Main.java:171)
        at racer.Main.main(Main.java:64)
Caused by: java.lang.NullPointerException
        at racer.Main$5.init(Main.java:268)
        at com.threed.jpct.FrameBuffer.runPostProcessors(Unknown Source)
        at racer.Main.render(Main.java:278)
        at racer.Main$4.run(Main.java:185)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
        at java.awt.EventQueue.access$000(EventQueue.java:85)
        at java.awt.EventQueue$1.run(EventQueue.java:603)
        at java.awt.EventQueue$1.run(EventQueue.java:601)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

19
Support / Re: Accessing openGL object
« on: November 17, 2011, 09:17:48 am »
I suppose I am using LWJGL since I am using the openGL renderer? Hm.

Anyway, here is the code for my render function:

Code: [Select]
fb.clear();

        world.renderScene(fb);
        world.draw(fb);
        fb.update();

        fb.addPostProcessor( new IPostProcessor() {

            private boolean initialised = false;

            public boolean isInitialized()
            {
                return initialised;
            }

            public void dispose()
            {

            }

            public void process()
            {

            }

            public void init( FrameBuffer buffer )
            {
                boolean FBOEnabled = GLContext.getCapabilities().GL_EXT_framebuffer_object;
                System.out.println( FBOEnabled );
            }
        });

        fb.runPostProcessors();

The error comes in the first line of public void init: null pointer error.

20
Support / Accessing openGL object
« on: November 16, 2011, 09:24:53 pm »
Greetings!

I'm writing a level editor using Swing and JPCT. I make a JFrame, and then fill it with a JPanel. The JPanel is provided with a reference to the framebuffer so that it draws its contents whenever it's time to update:

Code: [Select]
@Override
    public void paintComponent( Graphics g )
    {
        this.fb.display( g );
    }

The framebuffer seems to be initialising an openGL context, since I start it like so:

Code: [Select]
canvas = fb.enableGLCanvasRenderer();
My question is: how do I then access the openGL object? Reason being, whenever I call openGL code in the IPostProcessor I have attached to the framebuffer, I get a null pointer error. Any thoughts?

Pages: 1 [2]