getDeviceName(argv[3]); } String VideoCapture::getDeviceName(S32 deviceID) { CVVidCapture::VIDCAP_DEVICE devInfo; i"> ConsoleMethod, strings & char arrays | Torque Game Engine | Forums | Community | GarageGames.com

Game Development Community

ConsoleMethod, strings & char arrays

by Paul Griffiths · in Torque Game Engine · 07/09/2006 (4:09 am) · 10 replies

ConsoleMethod( VideoCapture, getDeviceName, TypeString, 3, 3, "(int index) Get device name at index")
{
	return object->getDeviceName(argv[3]);
	
}


String VideoCapture::getDeviceName(S32 deviceID)
{

	CVVidCapture::VIDCAP_DEVICE devInfo;
	if ((vidCap != NULL) && (CVSUCCESS(vidCap->GetDeviceInfo(deviceID,devInfo))))
	{
		Con::printf("Device %d: %s\n",deviceID,devInfo.DeviceString);
		return devInfo.DeviceString; // DeviceString is a char array
	}
	return NULL;
}

Can anyone spot my mistakes?

My consoleMethod is not compiling.

In function getDeviceName I wish to return a string but devInfo.DeviceString is a char array.

Any ideas? Thanks.

#1
07/09/2006 (4:20 am)
It should be
ConsoleMethod( VideoCapture, getDeviceName, const char*, 3, 3, "(int index) Get device name at index")
{
	return object->getDeviceName( dAtoi(argv[2]) );
	
}

const char* VideoCapture::getDeviceName(S32 deviceID)
{

	CVVidCapture::VIDCAP_DEVICE devInfo;
	if ((vidCap != NULL) && (CVSUCCESS(vidCap->GetDeviceInfo(deviceID,devInfo))))
	{
		Con::printf("Device %d: %s\n",deviceID,devInfo.DeviceString);
		return devInfo.DeviceString; // DeviceString is a char array
	}
	return NULL;
}

I think.
#2
07/09/2006 (4:30 am)
Thanks Michael, not working though.

Errors are:

C:\Torque\SDK\engine\TMessenger\VideoCapture.cc(44): error C2440: 'return' : cannot convert from 'S32' to 'const char *'
C:\Torque\SDK\engine\TMessenger\VideoCapture.cc(125): error C2556: 'const char *VideoCapture::getDeviceName(S32)' : overloaded function differs only by return type from 'S32 VideoCapture::getDeviceName(S32)'
C:\Torque\SDK\engine\TMessenger\VideoCapture.cc(125): error C2040: 'VideoCapture::getDeviceName' : 'const char *(S32)' differs in levels of indirection from 'S32 (S32)'
#3
07/09/2006 (4:33 am)
Oops, forgot my header file. Compiles now, thanks.
#5
07/09/2006 (6:30 am)
Glad I could help :)
#6
07/09/2006 (6:44 am)
Wow! That looks really cool! I could see something like this being revolutionary in online gaming. Are you planning on releasing a webcam resource?
#7
07/09/2006 (7:24 am)
It would be pretty cool to project onto a face of a character... could have a little screen showing what your webcam is picking up with an outline to show where you should be sitting for best effect.
#8
07/09/2006 (10:56 am)
Quote:Are you planning on releasing a webcam resource?
Yes pretty soon ill release a resource.
#9
07/09/2006 (11:05 am)
Ha ha, penguins !