コード例 #1
0
ファイル: SIMPLER.C プロジェクト: irondukepublishing/sigTOOL
main(void)
{
    printf("\nFile name to read > ");               /* ask for file by name */
    scanf(" %s",fName);                               /* read name supplied */
    handle = OpenCFSFile(fName,   /* attempt to open named file as CFS V2.0 */
                         0,                           /* open for read only */
                         1);          /* store data section table in memory */
    if (handle<0)                       /* if not sucessful report and fail */
    {
        printf("\nError %d File not opened",handle); 
        return 0;
    }
                                         /* Report general file information */
    ret = DisplayFileInfo(handle);  /* identify file by its CFS file handle */
    if (ret == 0)
        return 0;                                          /* fail if error */

    MyDelay(4000);
    for (i = 0;i < fileVars;i ++)
    {
         ret = DisplayVar(handle,i,FILEVAR,0);
         if (ret == 0) 
             return 0;
    }
    MyDelay(4000);
                                                   /* For each data section */
                                    /* Report on each data section variable */
    for (DSLoop = 1;DSLoop <= dataSections;DSLoop ++)
    {
        printf("\nData Section %3d\n",DSLoop);
                                             /* display data section number */
        for (i = 0;i < DSVars;i ++)
        {        
             ret = DisplayVar(handle,i,DSVAR,DSLoop);
             if (ret == 0)
                 return 0;                                 /* fail if error */
        };
       /* Report an all channel info including 1st 40 value of each channel */      
        for (i = 0;i < channels;i ++)
        {     
             ret = DisplayChan(handle,i,DSLoop);
             if (ret == 0)
                 return 0;                                 /* fail if error */
        };
        DSFlags(handle,DSLoop,(short)0,&flagSet);  /* get DS flags if exist */
        for (i = 0;i <= 15 ;i ++)
            if ((flagSet & DSFlagValue(i)) != 0) /* if valid flag, print it */
                printf("\nFlag exists %u \n",(flagSet & DSFlagValue(i)));
        MyDelay(4000);
    };

    ret = CloseCFSFile(handle);       /* Close CFS file and realease handle */
    if (ret != 0)
        printf("\nError. File closing failed\n");
    return 0;
};
コード例 #2
0
ファイル: Main.cpp プロジェクト: mwaltman/3D-FPS-Engine
// The complete display function. Gets called each frame
void Display() {
	// Updates fps
	fps += 1.0;
	frames2 += 1;
	if (frames2 == prevListStep)
		frames2 = 0;

	// Debug info
	char buffer[1024];
	sprintf_s(buffer, "Pos = %.2f, %.2f, %.2f; Angles = %.2f, %.2f; Velocity = %.1f, %.1f, %.1f; Direction = %d, %d; Ground = %.1f", posX, posY, posZ, angleX, angleY, velocityX, velocityY, velocityZ, direction.first, direction.second, groundHeight);
	glutSetWindowTitle(buffer);

	// Checks inputs
	CheckInputs();

	// Initialize drawing
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	///// Begin 3D
	glPushMatrix();
	glRotatef(angleY, 1.0f, 0.0f, 0.0f);
	glRotatef(angleX, 0.0f, 1.0f, 0.0f);
	glRotatef(180.0, 0.0f, 0.0f, 1.0f);
	glTranslatef(posX, posY, posZ);

	// Draws the maps
	// TODO: drawing multiple maps is not doable. Better: load and unload single maps
	//for (LevelMap* map : activeMaps) {
	//	DrawMap(map->layout);
	//}
	DrawMap(currentMap->layout);

	// Updates and draws prevPosList
	glColor3f(1.0, 0.0, 0.0); // Red
	if (frames2 == 0) {
		prevPosList.pop_front();
		prevPosList.push_back(new Vector3(posX, posY, posZ));
	}
	if (showRedLine) {
		DrawPosDeq(prevPosList);
	}

	///// End 3D
	glPopMatrix();

	///// Begin 2D
	glPushMatrix();
	glTranslatef(0.0, 0.0, -fMin);

	// Draws HUD
	glColor3f(0.5, 0.0, 0.5); // Purple
	char controls[200], whiteLine[10];
	DisplayString(controls, "Use WASD to walk and use the mouse to move the camera. Jump with the spacebar. Crouch with Ctrl. Fly with F. Show red line with R. Exit with Esc.");
	DisplayString(whiteLine, "");
	char jump[100], crouch[100], fly[100], air[100], red[100];
	DisplayVar("Jumping = ", jumping, jump);
	DisplayVar("Crouching = ", crouching, crouch);
	DisplayVar("In Air = ", inAir, air);
	DisplayVar("Flying = ", flying, fly);
	DisplayVar("Red Line = ", showRedLine, red);
	stringvec hud = { controls, whiteLine, jump, crouch, air, fly, red };
	DrawText2Pix(hud, 20, 20);

	// Draws crosshairs
	glColor3f(0.0, 1.0, 0.0); // Green
	DrawCrosshairs(5, 3);

	///// End 2D
	glPopMatrix();

	// Swaps buffers
	glutSwapBuffers();
}