コード例 #1
0
ファイル: widget.cpp プロジェクト: RSATom/Qt
void Widget::renderWindowReady()
{
    QOpenGLContext *context = QOpenGLContext::currentContext();
    Q_ASSERT(context);

    QString vendor, renderer, version, glslVersion;
    const GLubyte *p;
    QOpenGLFunctions *f = context->functions();
    if ((p = f->glGetString(GL_VENDOR)))
        vendor = QString::fromLatin1(reinterpret_cast<const char *>(p));
    if ((p = f->glGetString(GL_RENDERER)))
        renderer = QString::fromLatin1(reinterpret_cast<const char *>(p));
    if ((p = f->glGetString(GL_VERSION)))
        version = QString::fromLatin1(reinterpret_cast<const char *>(p));
    if ((p = f->glGetString(GL_SHADING_LANGUAGE_VERSION)))
        glslVersion = QString::fromLatin1(reinterpret_cast<const char *>(p));

    m_output->append(tr("*** Context information ***"));
    m_output->append(tr("Vendor: %1").arg(vendor));
    m_output->append(tr("Renderer: %1").arg(renderer));
    m_output->append(tr("OpenGL version: %1").arg(version));
    m_output->append(tr("GLSL version: %1").arg(glslVersion));

    m_output->append(tr("\n*** QSurfaceFormat from context ***"));
    printFormat(context->format());

    m_output->append(tr("\n*** QSurfaceFormat from window surface ***"));
    printFormat(m_surface->format());

    m_output->append(tr("\n*** Qt build information ***"));
    const char *gltype[] = { "Desktop", "GLES 2", "GLES 1" };
    m_output->append(tr("Qt OpenGL configuration: %1")
                     .arg(QString::fromLatin1(gltype[QOpenGLContext::openGLModuleType()])));
    m_output->append(tr("Qt OpenGL library handle: %1")
                     .arg(QString::number(qintptr(QOpenGLContext::openGLModuleHandle()), 16)));

    QList<QByteArray> extensionList = context->extensions().toList();
    std::sort(extensionList.begin(), extensionList.end());
    m_extensions->append(tr("Found %1 extensions:").arg(extensionList.count()));
    Q_FOREACH (const QByteArray &ext, extensionList)
        m_extensions->append(QString::fromLatin1(ext));

    m_output->moveCursor(QTextCursor::Start);
    m_extensions->moveCursor(QTextCursor::Start);
}
コード例 #2
0
ファイル: Logging.cpp プロジェクト: AndrewBiz/wave_gen
void Logging::print(const char *format, va_list args) {
  for (; *format != 0; ++format) {
    if (*format == '%') {
      ++format;
      printFormat(*format, &args);
    } else {
      Serial.print(*format);
    }
  }
}
コード例 #3
0
ファイル: NetworkStack.cpp プロジェクト: NetDimes/dimes-agent
JNIEXPORT jbyteArray JNICALL Java_dimes_measurements_nio_MacLevelNetworkStack_getDestMac
(JNIEnv *env, jobject)
{
	#ifdef DIMES_WINDOWS
	printf("Getting dest mac... : ");printFormat( macLevelStack.destMAC.data , 6) ; printf("\n");
	fflush(stdout);
	jbyteArray result = env->NewByteArray(6);
	env->SetByteArrayRegion(result , 0 , 6 , (const jbyte*) macLevelStack.destMAC.data);
	return result;
	#else
	//return env->NewByteArray(0);
	#endif
}
コード例 #4
0
ファイル: Logging.cpp プロジェクト: AndrewBiz/wave_gen
void Logging::print(const __FlashStringHelper *format, va_list args) {
  PGM_P p = reinterpret_cast<PGM_P>(format);
  char c = pgm_read_byte(p++);
  for(;c != 0; c = pgm_read_byte(p++)){
    if (c == '%') {
      c = pgm_read_byte(p++);
      printFormat(c, &args);
    } else {
      Serial.print(c);
    }
  }

}
コード例 #5
0
ファイル: main.cpp プロジェクト: huxiyu/OpenglFrame
int main(int argc, char **argv)
{
    QGuiApplication app(argc, argv);

    if (!QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::ThreadedOpenGL)) {
        QQuickView view;
        view.setSource(QUrl("qrc:///scenegraph/textureinthread/error.qml"));
        view.show();
        return app.exec();
    }

    qmlRegisterType<ThreadRenderer>("SceneGraphRendering", 1, 0, "Renderer");
    int execReturn = 0;

    {
        QQuickView view;

        // Rendering in a thread introduces a slightly more complicated cleanup
        // so we ensure that no cleanup of graphics resources happen until the
        // application is shutting down.
        view.setPersistentOpenGLContext(true);
        view.setPersistentSceneGraph(true);

        setContext(view);
        qDebug() << "\n*** QSurfaceFormat from window surface ***";
        printFormat(view.format());

        view.setResizeMode(QQuickView::SizeRootObjectToView);
        view.setSource(QUrl("qrc:///scenegraph/textureinthread/main.qml"));
        view.show();

        execReturn = app.exec();
    }

    // As the render threads make use of our QGuiApplication object
    // to clean up gracefully, wait for them to finish before
    // QGuiApp is taken off the heap.
    foreach (QThread *t, ThreadRenderer::threads) {
        t->wait();
        delete t;
    }
コード例 #6
0
bool instruction::matchSpecial2()
{
	if (binaryCode.substr(0, 6) != "011100")
		return false;

	if (binaryCode.substr(21, 11) == "00000000010")
	{
		opcode = "MUL";
		rs = Util::binaryToDecimal(binaryCode.substr(6, 5));
		rt = Util::binaryToDecimal(binaryCode.substr(11, 5));
		rd = Util::binaryToDecimal(binaryCode.substr(16, 5));

		//MUL rd, rs, rt
		printFormat();
		string instrText = opcode + "\t" + "R" + Util::int2string(rd) + ", R" + Util::int2string(rs) + ", R" + Util::int2string(rt);
		disassemblyFile << instrText << '\n';
		this->instr_text = instrText;
		return true;
	}
	return false;
}
コード例 #7
0
bool instruction::matchCategory2()
{
	//Æ¥ÅäCategory2
	string first6 = binaryCode.substr(0, 6);
	if (first6 != "110000" && first6 != "110001" && first6 != "100001" && first6 != "110010" && first6 != "110011" && first6 != "110101")
		return false;
	else
		category = 2;

	if (first6 == "110000")
		functionCode = "ADD";

	if (first6 == "110001")
		functionCode = "SUB";

	if (first6 == "100001")
		functionCode = "MUL";

	if (first6 == "110010")
		functionCode = "AND";

	if (first6 == "110011")
		functionCode = "NOR";

	if (first6 == "110101")
		functionCode = "SLT";

	opcode = functionCode;
	rs = Util::binaryToDecimal(binaryCode.substr(6, 5));
	rt = Util::binaryToDecimal(binaryCode.substr(11, 5));
	immediate = Util::binaryToDecimal(binaryCode.substr(16, 16));
	printFormat();

	string instrText = functionCode + "\t"+"R" + Util::int2string(rt) + ", R" + Util::int2string(rs) + ", #" + Util::int2string(immediate);
	disassemblyFile << instrText<<'\n';
	this->instr_text = instrText;
	return true;
}
コード例 #8
0
/********************
 *
 * Query for all the interfaces and find their parameters.
 *
 */
__declspec(dllexport) void AdapterManager::getInterfaces(LPADAPTER_INTERFACE adaptersArray , int* numberOfInterfaces){
	PIP_ADAPTER_INFO pAdapterInfo;
	LPADAPTER adapter;
	PIP_ADAPTER_INFO pAdapter = NULL;
	DWORD dwRetVal = 0;
	ULONG ulOutBufLen;
	int maxInterfaces = *numberOfInterfaces;

	// allocate memory :
	pAdapterInfo = (IP_ADAPTER_INFO *) malloc( sizeof(IP_ADAPTER_INFO) );
	 ulOutBufLen = sizeof(IP_ADAPTER_INFO);

	// Make an initial call to GetAdaptersInfo to get
	// the necessary size into the ulOutBufLen variable
	if (GetAdaptersInfo( pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
		free(pAdapterInfo);
		pAdapterInfo = (IP_ADAPTER_INFO *) malloc (ulOutBufLen); 
	}

	if ((dwRetVal = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen)) == NO_ERROR) {
		int adapterCounter = 0;
		pAdapter = pAdapterInfo;		
		// For Each queried adapter :
		while (pAdapter && adapterCounter<maxInterfaces) 
		{
			LPADAPTER_INTERFACE currentInterface = &adaptersArray[adapterCounter];

			//PIP_ADDR_STRING gateways = &pAdapter->GatewayList;
			//do
			//{
			//	printf("Gateway : %s\n",gateways->IpAddress.String);
			//	gateways = gateways->Next;
			//}
			//while (gateways != NULL);
			
			// copy the given parameters from the LPADAPTER_INTERFACE struct :
			strcpy(currentInterface->adapterName , pAdapter->AdapterName);
			strcpy(currentInterface->gatewayAddress , pAdapter->GatewayList.IpAddress.String);
			strcpy(currentInterface->ipAddress , pAdapter->IpAddressList.IpAddress.String);
			strcpy(currentInterface->description , pAdapter->Description);
			// set the driver name as requested by windows drivers :
			sprintf(currentInterface->protocolDriverName,"DIMESPACKET_%s",pAdapter->AdapterName);
			currentInterface->type = pAdapter->Type;

			// Open adapter for query :
			adapter = DimesPacketOpenAdapter(currentInterface->protocolDriverName);
			if (adapter != NULL)
			{
				// query source MAC :
				currentInterface->srcMacValid = getSrcMAC(adapter , &(currentInterface->srcMAC[0]));
				printf("Source MAC :");printFormat(currentInterface->srcMAC , 6);printf("\n");
				// get the dest MAC
				void *destMacPtr = (void*)&(currentInterface->destMAC[0]);
				unsigned int *destMacPtrUI8 = (unsigned int *)destMacPtr;
				currentInterface->destMacValid = getDestMAC(currentInterface->gatewayAddress ,destMacPtrUI8 );			
JavaLog::javalogf(LEVEL_INFO , "gateway address : %s\n",currentInterface->gatewayAddress);
				currentInterface->isPPPOE = false;
				// try and find out if the device is PPP :
				if (!currentInterface->destMacValid)
				{				
					JavaLog::javalog(LEVEL_INFO , "--->Listening for PPP dest MAC...\n");	
					DimesPacketSetHwFilter(adapter,NDIS_PACKET_TYPE_PROMISCUOUS);
					DimesPacketSetBuff(adapter , 2048);
					char packetBuffer[2048];
					DimesPacketSetReadTimeout(adapter , 2500);
					LPPACKET receviedPacket =  DimesPacketAllocatePacket();
					DimesPacketInitPacket(receviedPacket , &packetBuffer , 2048);
					// TODO :generate some traffic :					
					DimesPacketReceivePacket(adapter , receviedPacket , TRUE);						
					JavaLog::javalogf(LEVEL_INFO ,"Packet Size : %d" , receviedPacket->ulBytesReceived );
					
					// IF a packet was intercepted : check the parameters ...
					if (receviedPacket->ulBytesReceived >=24)
					{
						unsigned char* srcMac = (unsigned char*)(packetBuffer+20);
						unsigned char* destMac = (unsigned char*)(packetBuffer+26);
						u8 ppp[2] = { 0X00 , 0x21};
						u8 pppoeFrameType[2] = { 0x11 , 0x00 };
						unsigned char* pppFrameBegining = (unsigned char*)(packetBuffer+34);
						//printf("idial : "); printFormat(pppoeFrameType,2);printf("\n");
						//printf("actual: ");printFormat((unsigned char*)pppFrameBegining,2);printf("\n"); 
						if (memicmp(pppFrameBegining,pppoeFrameType,2) == 0)
						{
							JavaLog::javalog(LEVEL_FINE , "Euricka!!!!! - found ppp device!");
							currentInterface->isPPPOE = true;
							memcpy(currentInterface->pppoeFrame , packetBuffer+34 , 8);
						}						

						//printFormat(srcMac,6);printf("\n");
						
						printFormat((unsigned char*)receviedPacket->Buffer , receviedPacket->ulBytesReceived);
						if (memicmp(currentInterface->srcMAC , packetBuffer+20,6) == 0)
							memcpy(currentInterface->destMAC  , packetBuffer+26 , 6);
						else
							if (memicmp(currentInterface->srcMAC , packetBuffer+26,6) == 0)
								memcpy(currentInterface->destMAC , packetBuffer+20 , 6);
						currentInterface->destMacValid=true;
						//currentInterface->
						//printf("dest mac:");printFormat(currentInterface->destMAC,6);printf("\n");
						//system("pause");
					}
					DimesPacketFreePacket(receviedPacket);				
				}				
				DimesPacketCloseAdapter(adapter);
			}


			pAdapter = pAdapter->Next;
			adapterCounter++;
		}
		*numberOfInterfaces = adapterCounter;
	}
	else 
	{
		JavaLog::javalogf(LEVEL_SEVERE , "Call to GetAdaptersInfo failed.");
	}
	free(pAdapterInfo);
	fflush(stdout);
}
コード例 #9
0
	void Graphics::draw() {
		resetFormat();
		
		if (!isScreenChanged()) return; // if nothing is changed do not draw anything
		
		// preserve preovious terminal text
		for (int i = 0; i < terminalSizeY - lastTerminalSizeY; i++) {
			printf("\n");
		}
		
		printf("\033[H");// reset terminal to top left corner
		
		std::string textToPrint[terminalSizeX][terminalSizeY];
		
		// set background
		for (int y = 0; y < terminalSizeY; y++) { // Y axis
			for (int x = 0; x < terminalSizeX; x++) { // X axis
				textToPrint[x][y] = "\033[0m ";
			}
		}
		
		// look what should be drawn on scren
		for (int i = 0; i < screen.size(); i++) {
			if( (screen[i].x >= currentCamera->getX() &&
			     screen[i].x < terminalSizeX + currentCamera->getX()) &&
			    (screen[i].y >= currentCamera->getY() &&
			     screen[i].y < terminalSizeY + currentCamera->getY())
			){
				textToPrint[screen[i].x - currentCamera->getX()][screen[i].y - currentCamera->getY()] = printFormat(screen[i].format) + screen[i].ch;
			}
		}
		
		// draw frame
		for (int y = terminalSizeY - 1; y >= 0; y--) { // Y axis
			for (int x = 0; x < terminalSizeX; x++) { // X axis
				printf("%s", textToPrint[x][y].c_str());
			}
			if(y > 0) printf("\n");
		}
		
		lastTerminalSizeX = terminalSizeX;
		lastTerminalSizeY = terminalSizeY;
		lastScreen = screen;
		screen.clear();
		currentFormat.clear();
	}
コード例 #10
0
ファイル: dtox.c プロジェクト: johndavid5/utils
int main(int argc, char *argv[])
{
   int i;

   char *inputFileName; 
   char *outputFileName; 
    
   FILE *inputFilePtr; 
   FILE *outputFilePtr; 

   int c, d;

   GBArgvZero = argv[0];
   GBProgName = argv[0];
    
   inputFileName = NULL; 
   outputFileName = NULL; 
   for(i=1; i<argc; i++) 
   { 
       if(argv[i][0] == '-') 
       { 
           if(argv[i][1] == '?') 
           { 
               printFormat(stderr); 
               exit(1); 
           } 
           else if(tolower(argv[i][1]) == 'o') 
           { 
               if((i+1) < argc) 
               { 
                  outputFileName = argv[++i]; 
               } 
               else 
               { 
                   printFormat(stderr); 
                   exit(1); 
               } 
           } 
           else if(tolower(argv[i][1]) == 'i') 
           { 
               if((i+1) < argc) 
               { 
                  inputFileName = argv[++i]; 
               } 
               else 
               { 
                   printFormat(stderr); 
                   exit(1); 
               } 
           } 
       } 
       else 
       { 
           inputFileName = argv[i]; 
       } 
 
   } 
   
   if(inputFileName != NULL)
      fprintf(stderr, "input_file = \"%s\".\n", inputFileName);
      
   if(outputFileName != NULL)
      fprintf(stderr, "output_file = \"%s\".\n", outputFileName);
      
   if(inputFileName != NULL) 
   { 
      inputFilePtr = fopen(inputFileName, "rb");
      if ( inputFilePtr == NULL )
      {
          fprintf(stderr, 
             "%s: Can't open file \"%s\" for reading [%d: %s].\n", 
             argv[0], inputFileName, errno, strerror(errno) );
          exit(1);
      }
   }
   else
   {
      inputFilePtr = stdin;
   }
   
   if(outputFileName != NULL) 
   { 
      outputFilePtr = fopen(outputFileName, "wb");
      if ( outputFilePtr == NULL )
      {
          fprintf(stderr, 
             "%s: Can't open file \"%s\" for writing [%d: %s].\n", 
             argv[0], outputFileName, errno, strerror(errno) );
          exit(1);
      }
   }
   else
   {
      outputFilePtr = stdout;
   }

   while ( (c = getc(inputFilePtr))  != EOF )
   {
      if (c == '\r')
      {
         /* We may have a "\r\n" here! */
         if((d = getc(inputFilePtr)) == EOF)
         {
            /* Just output your char and close up shop now. */
            putc(c, outputFilePtr);
            exit(0);
         }
         else if( d == '\n')
         {
            /* We got a live one! */
            putc('\n', outputFilePtr); 
         }
         else
         {
            /* False alarm. */
            fprintf(outputFilePtr, "%c%c", c, d);
         }
      }/* END "if(c == '\r')" */
      else
      {
         putc(c, outputFilePtr);
      }

   }/* END while ( (c = getc(inputFilePtr))  != EOF ) */

   exit(0);
   return 0;

} /* END main() */
コード例 #11
0
bool instruction::matchSpecial()
{
	if (binaryCode.substr(0, 6) != "000000")
		return false;

	if (binaryCode.substr(0,32) == "00000000000000000000000000000000")
	{
		disassemblyFile << binaryCode << '\t' << line << ' ' << 0<<'\n';
		return true;
	}

	if (binaryCode.substr(26, 6) == "001101")
	{
		opcode = "BREAK";
		printFormat();
		string instrText = opcode;
		disassemblyFile << instrText<<'\n';
		this->instr_text = instrText;
		isBreak = true;
		return true;
	}

	if (binaryCode.substr(11, 10) == "0000000000" && binaryCode.substr(26, 6) == "001000")
	{
		rs = Util::binaryToDecimal(binaryCode.substr(6, 5));
		opcode = "JR";
		printFormat();
		string instrText = opcode + "\t"+"R" + Util::int2string(rs);
		disassemblyFile << instrText << '\n';
		this->instr_text = instrText;

		return true;
	}

	if (binaryCode.substr(21, 11) == "00000100000" || binaryCode.substr(21, 11) == "00000100010")
	{
		if (binaryCode.substr(21, 11) == "00000100000")
			opcode = "ADD";
		else
			opcode = "SUB";

		rs = Util::binaryToDecimal(binaryCode.substr(6, 5));
		rt = Util::binaryToDecimal(binaryCode.substr(11, 5));
		rd = Util::binaryToDecimal(binaryCode.substr(16, 5));

		printFormat();
		string instrText = opcode + "\t" + "R" + Util::int2string(rd) + ", R" + Util::int2string(rs) + ", R" + Util::int2string(rt);
		disassemblyFile << instrText << '\n';
		this->instr_text = instrText;
		return true;
	}

	if (binaryCode.substr(6, 5) == "00000" && (binaryCode.substr(26, 6) == "000000" || binaryCode.substr(26, 6) == "000010" || binaryCode.substr(26, 6) == "000011"))
	{
		if (binaryCode.substr(26, 6) == "000000")
			opcode = "SLL";
		else if (binaryCode.substr(26, 6) == "000010")
			opcode = "SRL";
		else
			opcode = "SRA";

		rt = Util::binaryToDecimal(binaryCode.substr(11, 5));
		rd = Util::binaryToDecimal(binaryCode.substr(16, 5));
		sa = Util::binaryToDecimal(binaryCode.substr(21, 5));

		//SLL rd, rt, sa ; SRL rd, rt, sa ; SRA rd, rt, sa
		printFormat();
		string instrText = opcode + "\t"+"R" + Util::int2string(rd) + ", R" + Util::int2string(rt) + ", #" + Util::int2string(sa);
		disassemblyFile << instrText << '\n';
		this->instr_text = instrText;
		return true;
	}

	return false;
}
コード例 #12
0
bool instruction::matchOthers()
{
	if (binaryCode.substr(0, 6) == "000010")
	{
		//J target
		opcode = "J";
		target_instr_index = 4 * (Util::binaryToDecimal(binaryCode.substr(6, 26)));
		printFormat();
		string instrText = opcode + "\t" + "#" + Util::int2string(target_instr_index);
		disassemblyFile << instrText << '\n';
		this->instr_text = instrText;

		return true;
	}
	if (binaryCode.substr(0, 6) == "100011" || binaryCode.substr(0, 6) == "101011")
	{
		if (binaryCode.substr(0, 6) == "100011")
			opcode = "LW";
		else
			opcode = "SW";

		base = Util::binaryToDecimal(binaryCode.substr(6, 5));
		rt = Util::binaryToDecimal(binaryCode.substr(11, 5));
		offset = Util::binaryToDecimal(binaryCode.substr(16, 16));

		//SW rt, offset(base) ; LW rt, offset(base)
		printFormat();
		string instrText = opcode + "\t" + "R" + Util::int2string(rt) + ", " + Util::int2string(offset) + "(R" + Util::int2string(base) + ")";
		disassemblyFile << instrText << '\n';
		this->instr_text = instrText;
		return true;
	}
	if (binaryCode.substr(0, 6) == "000100")
	{
		opcode = "BEQ";
		rs = Util::binaryToDecimal(binaryCode.substr(6, 5));
		rt = Util::binaryToDecimal(binaryCode.substr(11, 5));
		offset = (Util::binaryToDecimal(binaryCode.substr(16, 16))) * 4;

		//BEQ rs, rt, offset
		printFormat();
		string instrText = opcode + "\t" + "R" + Util::int2string(rs) + ", R" + Util::int2string(rt) + ", #" + Util::int2string(offset);
		disassemblyFile << instrText << '\n';
		this->instr_text = instrText;
		return true;
	}
	if (binaryCode.substr(11, 5) == "00000" && (binaryCode.substr(0, 6) == "000001"  || binaryCode.substr(0, 6) == "000111"))
	{
		if (binaryCode.substr(0, 6) == "000001")
			opcode = "BLTZ";
		else
			opcode = "BGTZ";

		rs = Util::binaryToDecimal(binaryCode.substr(6, 5));
		offset = (Util::binaryToDecimal(binaryCode.substr(16, 16))) * 4;

		//BLTZ rs, offset ; BGTZ rs, offset
		printFormat();
		string instrText = opcode + "\t" + "R" + Util::int2string(rs) + ", #" + Util::int2string(offset);
		disassemblyFile << instrText << '\n';
		this->instr_text = instrText;
		return true;
	}
	return false;
}