Demo Problem

Questions and answers about 3Dconnexion devices on Windows.

Moderator: Moderators

Post Reply
Archana
Posts: 1
Joined: Fri Jan 05, 2007 12:25 am

Demo Problem

Post by Archana »

Hello,

I have tried to compile one of the demo programs.
1.3DxTsTmfc
2.3DxTest32
An error occured which is
Command line error D2021 : invalid numeric argument '/Wp64'

After this step i tried to write my own program making use of the methods used in the demo code (with OpenGL). The following is the implemented code.

Code: Select all

/**********************************************************/
 
//openGL files
#include <windows.h>
#include <GL\glut.h>

//openGL files
//#include "isense.h"
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>

enum tmpRetVal {};
/* SpaceWare Specific Includes */

#include <SP\spwmacro.h>  /* Common macros used by SpaceWare functions. */
#include <SP\si.h>        /* Required for any SpaceWare support within an app.*/
#include <SP\siapp.h>     /* Required for siapp.lib symbols */

/* Program Specific Includes */
#include "3DxTest32.h"

/* Members */
SiHdl       m_DevHdl;       /* Handle to Spaceball Device */
HWND m_hWnd;
int WM_SPACEBALL = RegisterWindowMessage ("SpaceWareMessage00");
WPARAM wParam;
LPARAM lParam;

//Tracker var
int  res;            /* SbInits result..if>0 it worked, if=0 it didnt work   */ 
float fov, fAspectRatio,NearPlane,farPlane;

int TX,TY,TZ,RX,RY,RZ;
char buff0[20];                            /* text buffer for TX */
char buff1[20];                            /* text buffer for TY */
char buff2[20];                            /* text buffer for TZ */
char buff3[20];                            /* text buffer for RX */
char buff4[20];                            /* text buffer for RY */
char buff5[20];                            /* text buffer for RZ */ 



// functions called from header files  *******
//SiSpwEvent *pEvent;



//user defined function declare here
void callSpacePilotData(int val);
void Display(void);
void RenderScene(void);

void RenderScene(void)
{
   	GLUquadricObj *pObj;    // Quadric Object
	pObj = gluNewQuadric();   // Create and initialize Quadric
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glShadeModel(GL_SMOOTH);
	glEnable(GL_NORMALIZE);
	glPushMatrix();		
		glColor3f(1.0f, 0.0f, 0.0f);
		glTranslatef(0.0f, 0.0f, -10.0f);
		glRotatef(-90.0f, 0.0f, 1.0f, 1.0f);			
		gluCylinder(pObj, 0.5f, 0.5f, 6.0f, 16.0f, 16.0f);			
	glPopMatrix();
	glutSwapBuffers();
}

void SetupRC()
{
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f );
}

void ChangeSize(int w, int h)
{
    if(h == 0)
        h = 1;
    glViewport(0, 0, w, h);    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();	
    gluPerspective(fov, fAspectRatio,NearPlane,farPlane);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();	
}

void Display(void)
{   
	glPushMatrix();		
        glRotatef(RY, 0, 1, 0);
        glRotatef(-RX, 1, 0, 0);
        glRotatef(RZ, 0, 0, 1);    
		//gluLookAt(0, 0, 0, 0, 0, -1, 0, 1, 0);	
		gluLookAt(TX, TY, TZ, 0, 0, -1, 0, 1, 0);	
		RenderScene();
    glPopMatrix(); 
}

int SbInit()
{
  int res;                                 //result of SiOpen, to be returned  
  SiOpenData oData;                        //OS Independent data to open ball  
  
	if (SiInitialize() == SPW_DLL_LOAD_ERROR)   //init the SpaceWare input library
	{
		MessageBox(NULL,"Error: Could not load SiAppDll dll files", NULL, MB_ICONEXCLAMATION);
	}
	SiOpenWinInit (&oData, m_hWnd);          //init Win. platform specific data  
	SiSetUiMode(&m_DevHdl, SI_UI_ALL_CONTROLS); //Config SoftButton Win Display 
	//open data, which will check for device type and return the device handle
	// to be used by this function  
	if ( (m_DevHdl = SiOpen ("test1", SI_ANY_DEVICE, SI_NO_MASK,SI_EVENT, &oData)) == NULL )
	{
		SiTerminate();  //called to shut down the SpaceWare input library 
		res = 0;        //could not open device
		return res; 
	}
	else
    {
		res = 1;        //opened device succesfully
		return res;  
    }  
}

void callSpacePilotInit()
{    
     /* intitialize spaceball */
	  res = SbInit();
	  /* if SpaceBall was not detected then print error, close win., exit prog. */
	  if (res < 1)
		{
			MessageBox(NULL,"Sorry - No supported Spacetec IMC device available.\n",NULL, MB_OK);
		}
	  printf("Init function called");
}



void callSpacePilotData(int val)
{

	
//	int            num;      /* number of button returned */
//	SiSpwEvent     Event;    /* SpaceWare Event */ 
//	SiGetEventData EData;    /* SpaceWare Event Data */
//	LONG cSP;

//	printf("\n 1 times Space Pilot Data function called");
    /* init Window platform specific data for a call to SiGetEvent */
   int            num;      /* number of button pressed */
   MSG            msg;      /* incoming message to be evaluated */
   BOOL           handled;  /* is message handled yet */ 
   SiSpwEvent     Event;    /* SpaceWare Event */ 
   SiGetEventData EData;    /* SpaceWare Event Data */

   handled = SPW_FALSE;     /* init handled */	
	
   while ( GetMessage( &msg, NULL, 0, 0 ) )
   {
	   handled = SPW_FALSE;
	   SiGetEventWinInit(&EData, msg.message, msg.wParam, msg.lParam);
      /* check whether msg was a Spaceball event and process it */
	  printf("\n 2 times Space Pilot Data function called");
	  //cSP=OnSpaceball(wParam,lParam);
	 
	 if (SiGetEvent(m_DevHdl, 0, &EData, &Event)==SI_IS_EVENT)
     {
		printf("\nm_devHandle = %u",m_DevHdl);
		printf("\n EData = %u",EData.msg );
		printf("\n Event Type = %u",Event.type  );
		printf("\n 3 times Space Pilot Data function called");
		/*switch (Event.type)
		{
			printf("\n 4 times Space Pilot Data function called");
			case SI_MOTION_EVENT:
					SbMotionEvent(&Event);  /
					break;
			
		} 
        */
	 } /* end SiGetEvent */
	 
   }
	Display();
	glutTimerFunc(100, callSpacePilotData, 1);
}

void SbMotionEvent(SiSpwEvent *pEvent)
{	
  
   //int len0,len1,len2,len3,len4,len5;	      /* length of each buffer */
    /* put the actual ball data into the buffers 
	len0= sprintf( buff0, "TX: %d         ", pEvent->u.spwData.mData[SI_TX] );
	len1= sprintf( buff1, "TY: %d         ", pEvent->u.spwData.mData[SI_TY] );
	len2= sprintf( buff2, "TZ: %d         ", pEvent->u.spwData.mData[SI_TZ] );
	len3= sprintf( buff3, "RX: %d         ", pEvent->u.spwData.mData[SI_RX] );
	len4= sprintf( buff4, "RY: %d         ", pEvent->u.spwData.mData[SI_RY] );
	len5= sprintf( buff5, "RZ: %d         ", pEvent->u.spwData.mData[SI_RZ] );*/
		printf("\n1 time motion function called");
		TX = pEvent->u.spwData.mData[SI_TX];//len0;
		TY= pEvent->u.spwData.mData[SI_TY];//len1;
		TZ= pEvent->u.spwData.mData[SI_TZ];//len2;
		RX= pEvent->u.spwData.mData[SI_RX];//len3;
		RY= pEvent->u.spwData.mData[SI_RY];//len4;
		RZ= pEvent->u.spwData.mData[SI_RZ];//len5;

		printf( "TX: %d         ", TX );
		printf( "TY: %d         ", TY );
		printf( "TZ: %d         ", TZ );
		printf( "RX: %d         ", RX );
		printf( "RY: %d         ", RY );
		printf( "RZ: %d         ", RZ );
	printf("2 time motion function called");
/*	printf( "TX: %d         ", len0 );
	printf( "TY: %d         ", len1 );
	printf( "TZ: %d         ", len2 );
	printf( "RX: %d         ", len3 );
	printf( "RY: %d         ", len4 );
	printf( "RZ: %d         ", len5 );*/

}

int main(int argc, char* argv[])
{

	fov=90;
	fAspectRatio=1.46;
	NearPlane=5;
	farPlane=100;
	
	callSpacePilotInit();
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);	
	glutCreateWindow("Simple Demo");
	glutDisplayFunc(RenderScene); 
	glutReshapeFunc(ChangeSize);	
	SetupRC();
	glutTimerFunc(100, callSpacePilotData, 1);
	glutMainLoop();

	return 0;
}
/*******************************************************/


Is there an error in the code
I tried to evaluate 'void callSpacePilotData(int val)'. But found that
the code after the 'if' statement i.e.
'if (SiGetEvent(m_DevHdl, 0, &EData, &Event)==SI_IS_EVENT)'
is not being executed.

Please do reply regarding this.
Regards,
Archana
jwick
Moderator
Moderator
Posts: 3374
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Post by jwick »

For building the demos, make sure you are building the x86 solution target, not the x64 target. You can change compiler switches as necessary to get the solution to build with the version of the compiler you have.

On your code, m_hWnd has to be initialized to the hwnd of the OpenGL window. This probably is only available after you initialize OGL.
Post Reply