Update of /cvsroot/playerstage/code/player/examples/plugins/exampledriver
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3155/examples/plugins/exampledriver

Modified Files:
        example.cfg exampledriver.cc 
Log Message:
re-adde global argc and argv vars

Index: exampledriver.cc
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/examples/plugins/exampledriver/exampledriver.cc,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** exampledriver.cc    23 Aug 2007 19:58:41 -0000      1.12
--- exampledriver.cc    22 Feb 2008 20:51:50 -0000      1.13
***************
*** 1,8 ****
  /*
   *  Player - One Hell of a Robot Server
!  *  Copyright (C) 2003  
!  *     Brian Gerkey
   *                      
-  * 
   *  This program is free software; you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
--- 1,8 ----
  /*
   *  Player - One Hell of a Robot Server
!  *  glutgraphics.cc: GLUT-based graphics3d + 2d driver
!  *  Copyright (C) 2007  
!  *     Brian Gerkey, Richard Vaughan
   *                      
   *  This program is free software; you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
***************
*** 39,42 ****
--- 39,152 ----
  #include <libplayercore/playercore.h>
  
+ #include <GLUT/glut.h>
+ #include <stdio.h>
+ #include <math.h>
+ 
+ 
+ GLfloat light0_ambient[] =
+ {0.2, 0.2, 0.2, 1.0};
+ GLfloat light0_diffuse[] =
+ {0.0, 0.0, 0.0, 1.0};
+ GLfloat light1_diffuse[] =
+ {1.0, 0.0, 0.0, 1.0};
+ GLfloat light1_position[] =
+ {1.0, 1.0, 1.0, 0.0};
+ GLfloat light2_diffuse[] =
+ {0.0, 1.0, 0.0, 1.0};
+ GLfloat light2_position[] =
+ {-1.0, -1.0, 1.0, 0.0};
+ float s = 0.0;
+ GLfloat angle1 = 0.0, angle2 = 0.0;
+ 
+ void 
+ output(GLfloat x, GLfloat y, char *text)
+ {
+   char *p;
+ 
+   glPushMatrix();
+   glTranslatef(x, y, 0);
+   for (p = text; *p; p++)
+     glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);
+   glPopMatrix();
+ }
+ 
+ void 
+ display(void)
+ {
+   static GLfloat amb[] =
+   {0.4, 0.4, 0.4, 0.0};
+   static GLfloat dif[] =
+   {1.0, 1.0, 1.0, 0.0};
+ 
+   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+   glEnable(GL_LIGHT1);
+   glDisable(GL_LIGHT2);
+   amb[3] = dif[3] = cos(s) / 2.0 + 0.5;
+   glMaterialfv(GL_FRONT, GL_AMBIENT, amb);
+   glMaterialfv(GL_FRONT, GL_DIFFUSE, dif);
+ 
+   glPushMatrix();
+   glTranslatef(-0.3, -0.3, 0.0);
+   glRotatef(angle1, 1.0, 5.0, 0.0);
+   glCallList(1);        /* render ico display list */
+   glPopMatrix();
+ 
+   glClear(GL_DEPTH_BUFFER_BIT);
+   glEnable(GL_LIGHT2);
+   glDisable(GL_LIGHT1);
+   amb[3] = dif[3] = 0.5 - cos(s * .95) / 2.0;
+   glMaterialfv(GL_FRONT, GL_AMBIENT, amb);
+   glMaterialfv(GL_FRONT, GL_DIFFUSE, dif);
+ 
+   glPushMatrix();
+   glTranslatef(0.3, 0.3, 0.0);
+   glRotatef(angle2, 1.0, 0.0, 5.0);
+   glCallList(1);        /* render ico display list */
+   glPopMatrix();
+ 
+   glPushAttrib(GL_ENABLE_BIT);
+   glDisable(GL_DEPTH_TEST);
+   glDisable(GL_LIGHTING);
+   glMatrixMode(GL_PROJECTION);
+   glPushMatrix();
+   glLoadIdentity();
+   gluOrtho2D(0, 1500, 0, 1500);
+   glMatrixMode(GL_MODELVIEW);
+   glPushMatrix();
+   glLoadIdentity();
+   /* Rotate text slightly to help show jaggies. */
+   glRotatef(4, 0.0, 0.0, 1.0);
+   output(200, 225, "This is antialiased.");
+   glDisable(GL_LINE_SMOOTH);
+   glDisable(GL_BLEND);
+   output(160, 100, "This text is not.");
+   glPopMatrix();
+   glMatrixMode(GL_PROJECTION);
+   glPopMatrix();
+   glPopAttrib();
+   glMatrixMode(GL_MODELVIEW);
+ 
+   glutSwapBuffers();
+ }
+ 
+ void 
+ idle(void)
+ {
+   angle1 = (GLfloat) fmod(angle1 + 0.8, 360.0);
+   angle2 = (GLfloat) fmod(angle2 + 1.1, 360.0);
+   s += 0.05;
+   glutPostRedisplay();
+ }
+ 
+ void 
+ visible(int vis)
+ {
+   if (vis == GLUT_VISIBLE)
+     glutIdleFunc(idle);
+   else
+     glutIdleFunc(NULL);
+ }
+ 
+ 
  
////////////////////////////////////////////////////////////////////////////////
  // The class for the driver
***************
*** 107,112 ****
    // configure a serial port.
  
!   printf("Was foo option given in config file? %d\n", this->foop);
      
    puts("Example driver ready");
  
--- 217,258 ----
    // configure a serial port.
  
!   //printf("Was foo option given in config file? %d\n", this->foop);
      
+   glutInit( 0, NULL);
+   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
+   glutCreateWindow("blender");
+   glutDisplayFunc(display);
+   glutVisibilityFunc(visible);
+ 
+   glNewList(1, GL_COMPILE);  /* create ico display list */
+   glutSolidIcosahedron();
+   glEndList();
+ 
+   glEnable(GL_LIGHTING);
+   glEnable(GL_LIGHT0);
+   glLightfv(GL_LIGHT0, GL_AMBIENT, light0_ambient);
+   glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
+   glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
+   glLightfv(GL_LIGHT1, GL_POSITION, light1_position);
+   glLightfv(GL_LIGHT2, GL_DIFFUSE, light2_diffuse);
+   glLightfv(GL_LIGHT2, GL_POSITION, light2_position);
+   glEnable(GL_DEPTH_TEST);
+   glEnable(GL_CULL_FACE);
+   glEnable(GL_BLEND);
+   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+   glEnable(GL_LINE_SMOOTH);
+   glLineWidth(2.0);
+ 
+   glMatrixMode(GL_PROJECTION);
+   gluPerspective( /* field of view in degree */ 40.0,
+   /* aspect ratio */ 1.0,
+     /* Z near */ 1.0, /* Z far */ 10.0);
+   glMatrixMode(GL_MODELVIEW);
+   gluLookAt(0.0, 0.0, 5.0,  /* eye is at (0,0,5) */
+     0.0, 0.0, 0.0,      /* center is at (0,0,0) */
+     0.0, 1.0, 0.);      /* up is in positive Y direction */
+   glTranslatef(0.0, 0.6, -1.0);
+ 
+ 
    puts("Example driver ready");
  
***************
*** 143,146 ****
--- 289,296 ----
    // If you handle the message successfully, return 0.  Otherwise,
    // return -1, and a NACK will be sent for you, if a response is required.
+ 
+   // call this from the driver's private thread - on a timer?
+   // receive messages and do drawing
+ 
    return(0);
  }
***************
*** 152,164 ****
  void ExampleDriver::Main() 
  {
    // The main loop; interact with the device here
!   for(;;)
!   {
      // test if we are supposed to cancel
!     pthread_testcancel();
  
      // Process incoming messages.  ExampleDriver::ProcessMessage() is
      // called on each message.
!     ProcessMessages();
  
      // Interact with the device, and push out the resulting data, using
--- 302,319 ----
  void ExampleDriver::Main() 
  {
+   printf( "entering main loop" );
+   glutMainLoop();
+ 
+   //return 0;             /* ANSI C requires main to return int. */
+ 
    // The main loop; interact with the device here
!   //for(;;)
!   //{
      // test if we are supposed to cancel
!     //pthread_testcancel();
  
      // Process incoming messages.  ExampleDriver::ProcessMessage() is
      // called on each message.
!     //ProcessMessages();
  
      // Interact with the device, and push out the resulting data, using
***************
*** 166,171 ****
  
      // Sleep (you might, for example, block on a read() instead)
!     usleep(100000);
!   }
  }
  
--- 321,325 ----
  
      // Sleep (you might, for example, block on a read() instead)
!     //usleep(100000);
  }
  

Index: example.cfg
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/examples/plugins/exampledriver/example.cfg,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** example.cfg 10 Apr 2006 13:27:47 -0000      1.10
--- example.cfg 22 Feb 2008 20:51:50 -0000      1.11
***************
*** 5,10 ****
  (
    name "exampledriver"
!   plugin "libexampledriver"
!   provides ["position2d:0"] 
    foo 1 
  )
--- 5,10 ----
  (
    name "exampledriver"
!   plugin "libexampledriver.dylib"
!   provides ["graphics3d:0"] 
    foo 1 
  )


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to