Re: Threading problems

Olivier Michel <[email protected]> Wed, 17 Mar 2004 15:21:46 +0100
Newsgroups gmane.comp.cybernetics.webot.contest
Organization Cyberbotics Ltd.
Message-ID <[email protected]>
Anders Lyhagen wrote:

>Hi,
>
>Does anyone know why this code yields a "cannot activate openGL context"
>error?
>
I recently made the Webots API MT-safe, but this was not enough to fix 
that problem. It seems that the OpenGL context is not inherited in 
subsequent Java Threads. I will try to sort that out as it is becoming a 
recurrent question... Thanks for the source code which is very simple 
and shows nicely the problem.

-Olivier

>import com.cyberbotics.webots.Controller;
>public abstract class Judoka0 extends Controller {
>    static int camera;
>
>    public static void reset() {
>        camera = robot_get_device("camera");
>    }
>
>    public static void main() {
>        camera_enable(camera, 64);
>
>        Sensors sensors = new Sensors();
>        sensors.setPriority(Thread.MIN_PRIORITY);
>        sensors.start();
>
>        while(true)
>            robot_step(64);
>    }
>
>    static class Sensors extends Thread {
>         public void run() {
>            while(true) {
>                int[] img = camera_get_image(camera);
>                try {
>                    thread.sleep(200);
>                }
>                catch(Exception e){}
>            }
>        }
>    }
>}
>
>Best regards,
>Anders.L
>  
>


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/webots-contest/

<*> To unsubscribe from this group, send an email to:
     [email protected]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/