Update of /cvsroot/playerstage/code/player/client_libs/libplayerc/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv351

Modified Files:
        Makefile.am test.c 
Added Files:
        test_graphics3d.c 
Log Message:
added graphics3d test

Index: test.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/test/test.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** test.c      19 Apr 2007 16:59:44 -0000      1.48
--- test.c      19 Jun 2007 02:01:08 -0000      1.49
***************
*** 132,135 ****
--- 132,140 ----
  
        // gripper device
+       case PLAYER_GRAPHICS3D_CODE:
+       test_graphics3d(client, client->devinfos[i].addr.index);
+       break;
+ 
+       // gripper device
        case PLAYER_GRIPPER_CODE:
        test_gripper(client, client->devinfos[i].addr.index);

--- NEW FILE: test_graphics3d.c ---
/***************************************************************************
 * Desc: Tests for the graphics3d device
 * Author: Richard Vaughan
 * Date: 15 June 2007
 # CVS: $Id: test_graphics3d.c,v 1.1 2007/06/19 02:01:08 rtv Exp $
 **************************************************************************/

#include <unistd.h>
#include <math.h>

#include "test.h"
#include "playerc.h"

#define RAYS 64

// Basic test for graphics3d device.
int test_graphics3d(playerc_client_t *client, int index)
{
  int t;
  void *rdevice;
  playerc_graphics3d_t *device;

  printf("device [graphics3d] index [%d]\n", index);

  device = playerc_graphics3d_create(client, index);

  TEST("subscribing (read/write)");
  if (playerc_graphics3d_subscribe(device, PLAYER_OPEN_MODE) < 0)
  {
    FAIL();
    return -1;
  }
  PASS();

  
  player_point_3d_t pts[RAYS];
  
  double r;
  for( r=0; r<1.0; r+=0.05 )
    {
      TEST("drawing points");
      
      int p;
      for( p=0; p<RAYS; p++ )
        {
          pts[p].px = 100 * r * cos(p * M_PI/(RAYS/2));
          pts[p].py = 100 * r * sin(p * M_PI/(RAYS/2));
          pts[p].pz = 0;

          printf( "vertex [%.2f,%.2f,%.2f]\n",
                  pts[p].px,
                  pts[p].py,
                  pts[p].pz );
        }       
      
      if( playerc_graphics3d_draw(device, 
                                  PLAYER_DRAW_POINTS, 
                                  pts, RAYS) < 0)
        FAIL();
      else
        PASS();

      usleep(100000);
    }
  
  TEST("changing color");
  player_color_t col;
  col.red = 0;
  col.green = 255;
  col.blue = 0;
  col.alpha = 0;

  if(playerc_graphics3d_setcolor(device, col) < 0)
    FAIL();
  else
    PASS();

  TEST("drawing polyline");
  
  if(playerc_graphics3d_draw(device, 
                             PLAYER_DRAW_LINE_LOOP,
                             pts, RAYS) < 0)
    FAIL();
  else
    PASS();
  
  usleep(500000);
  
  TEST("changing color");      
  col.red = 0;
  col.green = 128;
  col.blue = 255;
  col.alpha = 0;
  
  if(playerc_graphics3d_setcolor(device, col) < 0)
    FAIL();
  else
    PASS();

  for( r=1.0; r>0; r-=0.1 )
    {
      TEST("drawing polygon");
      
      player_point_3d_t pts[4];
      pts[0].px = -r;
      pts[0].py = -r;
      pts[0].pz = 0;
      pts[1].px = r;
      pts[1].py = -r;
      pts[1].pz = 0;
      pts[2].px = r;
      pts[2].py = r;
      pts[2].pz = 0;
      pts[3].px = -r;
      pts[3].py = r;
      pts[3].pz = 0;
      
      if(playerc_graphics3d_draw(device, 
                                 PLAYER_DRAW_POLYGON,
                                 pts, 4 ) < 0)
        FAIL();
      else
        PASS();
      
      usleep(100000);
    }

  sleep(2);


  TEST("clearing");
  
  if(playerc_graphics3d_clear(device) < 0)
    FAIL();
  else
    PASS();


  TEST("unsubscribing");
  if (playerc_graphics3d_unsubscribe(device) != 0)
  {
    FAIL();
    return -1;
  }
  PASS();
  
  playerc_graphics3d_destroy(device);
  
  return 0;
}


Index: Makefile.am
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/client_libs/libplayerc/test/Makefile.am,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** Makefile.am 19 Apr 2007 16:59:44 -0000      1.44
--- Makefile.am 19 Jun 2007 02:01:08 -0000      1.45
***************
*** 18,21 ****
--- 18,22 ----
        test_camera.c \
        test_graphics2d.c \
+       test_graphics3d.c \
        test_gripper.c \
        test_laser.c \


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to