Пример #1
0
void DesktopServerProto::readPixelFormat(PixelFormat *pf,
                                         BlockingGate *gate)
{
  pf->bitsPerPixel = gate->readUInt16();
  pf->colorDepth   = gate->readUInt16();
  pf->redMax       = gate->readUInt16();
  pf->greenMax     = gate->readUInt16();
  pf->blueMax      = gate->readUInt16();
  pf->redShift     = gate->readUInt16();
  pf->greenShift   = gate->readUInt16();
  pf->blueShift    = gate->readUInt16();
  checkPixelFormat(pf);
}
	virtual bool init() {
		// Work with luminance images
		setPixelFormat(ARToolKitPlus::PIXEL_FORMAT_LUM);
		if ( ! checkPixelFormat()) {	
			if (logger)
				logger->artLog("ARToolKitPlus: Invalid Pixel Format!");
			return false;
		}

		// Memory
		if (marker_infoTWO == NULL)
			marker_infoTWO = ARToolKitPlus::artkp_Alloc<ARToolKitPlus::ARMarkerInfo2>(32);

		// Camera
		Camera *camera = new Camera(screenWidth, screenHeight);
		setCamera(camera, 1, 1000);

		// const ARFloat* mat = getProjectionMatrix();
		// printf("Proj mat\n");
		// for(int j=0; j<4; j++) {
		// 	for(int i=0; i<4; i++) {
		// 		printf ("%f, ", mat[i*4 + j]);
		// 	}
		// 	printf ("\n");
		// }

		// Work at full res
		setImageProcessingMode(ARToolKitPlus::IMAGE_FULL_RES);

		// Set border
		setBorderWidth(0.125);

		// Set threshold and activate automatic threshold
		setThreshold(160);
		activateAutoThreshold(true);
		setNumAutoThresholdRetries(2);

		// Switch to BCH ID based markers
		setMarkerMode(ARToolKitPlus::MARKER_ID_BCH);

		// Choose pose estimator
		setPoseEstimator(ARToolKitPlus::
						 //POSE_ESTIMATOR_ORIGINAL);
						 //POSE_ESTIMATOR_ORIGINAL_CONT);
						 POSE_ESTIMATOR_RPP);

		return true;
	}
Пример #3
0
	bool Context::makeCurrent(GPU::RenderTarget *target)
	{
		// If the target is null, we are really making the target the hidden window.
		if ( nullptr == target )
			target = mHiddenWindow;

		// Check if the context is already cunrrent on the passed target.
		if ( mTarget == target && this == currentContext )
			return true;

		if ( nullptr != mTarget )
			doneCurrent();

		if ( false == checkPixelFormat(target) )
			return false;

		if ( TRUE == wglMakeCurrent(target->hdc(), mHGLRC) )
		{
			mTarget = target;
			currentContext = this;

			currentGLEW = &mGlewCtxt;
			currentWGLEW = &mWGlewCtxt;

			return true;
		}
		else
		{
			 LPVOID lpMsgBuf;
			 DWORD dw = GetLastError(); 

			 FormatMessage(
				FORMAT_MESSAGE_ALLOCATE_BUFFER | 
				FORMAT_MESSAGE_FROM_SYSTEM |
				FORMAT_MESSAGE_IGNORE_INSERTS,
				NULL,
				dw,
				MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
				(LPTSTR) &lpMsgBuf,
				0, NULL );

			// Display the error message and exit the process
			std::string strMessage((char*)lpMsgBuf);
			LocalFree(lpMsgBuf);
		}

		return false;
	}