Пример #1
0
void RenderSceneAnim()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// increment frame
	frame++;
	time=glutGet(GLUT_ELAPSED_TIME);
	if (time - timebase > ((int)1000/htr.NumFPS())) 
	{
		/*
		sprintf(s,"FPS:%4.2f",frame*1000.0/(time-timebase));
		timebase = time;		
		frame = 0;
		*/
		cframe = cframe + 1;
		if(cframe == htr.NumFrames())
			cframe = 0;

		timebase = time;
	}

	// display something on view
	glColor3f(0.0f,1.0f, 0.0f);
	SetOrthographicProjection();
	glPushMatrix();
	glLoadIdentity();
	RenderBitmapString(10,15,(void *)font,"HTR Mocap Data Viewer"); 
	RenderBitmapString(10,35,(void *)font,"Loaded Animation Data");
	glPopMatrix();
	ResetPerspectiveProjection();
	

	glutPostRedisplay();
//	glutSwapBuffers();
}
Пример #2
0
void RenderScene(void) 
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	/*
	glPushMatrix();
		glColor3f(0.0f,0.0f, 0.0f);
		glutSolidCube(0.02);		
		
		glTranslatef(-0.5*2, 0.0, -0.5*2);
		glutSolidCube(0.02);
		
		glTranslatef(1.0*2, 0.0, 0.0);
		glutSolidCube(0.02);
		
		glTranslatef(0.0, 0.0, 1.0*2);
		glutSolidCube(0.02);
		
		glTranslatef(-1.0*2, 0.0, 0.0);
		glutSolidCube(0.02);
	glPopMatrix();

	glPushMatrix();
		glColor3f(0.0f,0.0f, 0.0f);
		glTranslatef(0.0, 2.0, 0.0);
		glutSolidCube(0.02);		
		
		glTranslatef(-0.5*2, 0.0, -0.5*2);
		glutSolidCube(0.02);
		
		glTranslatef(1.0*2, 0.0, 0.0);
		glutSolidCube(0.02);
		
		glTranslatef(0.0, 0.0, 1.0*2);
		glutSolidCube(0.02);
		
		glTranslatef(-1.0*2, 0.0, 0.0);
		glutSolidCube(0.02);
	glPopMatrix();
	*/

	printf("Current Frame to draw %d\n", cframe);
	htr.DrawFrame(cframe);

	// display something on view
	glColor3f(0.0f,1.0f, 0.0f);
	SetOrthographicProjection();
	glPushMatrix();
	glLoadIdentity();
	RenderBitmapString(10,15,(void *)font,"HTR Mocap Data Viewer"); 
	//RenderBitmapString(10,35,(void *)font,"Base Pose Rendering");
	glPopMatrix();
	ResetPerspectiveProjection();
	

	glutSwapBuffers();
}
Пример #3
0
static void DrawFps()
{
	glPushMatrix();
	glLoadIdentity();
	SetOrthographicProjection();

	glColor3f(0.0f, 0.0f, 0.0f);
	RenderQuad(25, 6, 50, 12);

	glColor3f(1.0f, 1.0f, 1.0f);
	RenderBitmapString(5, 10, GLUT_BITMAP_TIMES_ROMAN_10, FpsString);

	glPopMatrix();
	RestorePerspectiveProjection();
}
Пример #4
0
void RenderNoteAnchor (FloatNote * psNote, NotesPersist * psNotesData) {
	// Render the note to the screen
	float fFade;
	GLuint uTexture;
	GLfloat afVertices[6];
	Vector3 vsBoxTopLeft;
	Vector3 vsBoxBottomRight;

	if (psNote->szText->len > 0) {
		// Draw a transparent rectangle on the screen
		fFade = (1.0f - ((psNote->vsAnchor.fZ - psNotesData->fFocusFar + NOTE_FOCUSSHIFT) * NOTE_FOCUSFADE));
		if (psNote == psNotesData->psSelectedNote) {
			fFade = (1.0f / NOTE_BACKFADEMAX);
		}
		if ((fFade > 0.0f) && (fFade < 50.0f)) {
			if ((fFade > 1.0f) && (psNote != psNotesData->psSelectedNote)) {
				fFade = 1.0f;
			}
			glColor4f (1.0, 1.0, 1.0, fFade * NOTE_BACKFADEMAX);

			// Set the z position of the note
		  glDepthRange (psNote->vsAnchor.fZ, psNote->vsAnchor.fZ);

			// Render the floating note
			uTexture = GetTexture (TEXNAME_NOTES, NULL, psNotesData->psTexData);
			glBindTexture (GL_TEXTURE_2D, uTexture);
			glEnable (GL_TEXTURE_2D);
		  glEnableClientState (GL_TEXTURE_COORD_ARRAY);

			vsBoxTopLeft.fX = psNote->vsAnchor.fX + psNote->fMarginExternal + NOTE_XSHIFT;
			vsBoxTopLeft.fY = psNote->vsAnchor.fY + psNote->fMarginExternal + NOTE_YSHIFT;
			vsBoxTopLeft.fZ = psNote->vsAnchor.fZ;
			vsBoxBottomRight.fX = psNote->vsAnchor.fX + psNote->vsSize.fX - psNote->fMarginExternal + NOTE_XSHIFT;
			vsBoxBottomRight.fY = psNote->vsAnchor.fY + psNote->vsSize.fY - psNote->fMarginExternal + NOTE_YSHIFT;
			vsBoxBottomRight.fZ = psNote->vsAnchor.fZ;
			RenderBox (& vsBoxTopLeft, & vsBoxBottomRight, NOTE_BORDERWIDTH, uTexture);

			afVertices[0]  = psNote->vsAnchor.fX;
			afVertices[1]  = psNote->vsAnchor.fY;
			afVertices[2]  = NOTE_LAYER_ZPOS;
			afVertices[3]  = psNote->vsAnchor.fX + psNote->fMarginExternal + NOTE_XSHIFT;
			afVertices[4]  = psNote->vsAnchor.fY + psNote->fMarginExternal + NOTE_YSHIFT;
			afVertices[5]  = NOTE_LAYER_ZPOS;

			glDisable (GL_TEXTURE_2D);
		  glDisableClientState (GL_TEXTURE_COORD_ARRAY);
			glColor4f (0.5, 0.5, 1.0, fFade * NOTE_BACKFADEMAX);
			glVertexPointer (3, GL_FLOAT, 0, afVertices);
			glDrawArrays (GL_LINE_STRIP, 0, 2);

			if (psNotesData->boInverted) {
				glColor4f (0.0, 0.0, 0.0, fFade * NOTE_TEXTFADEMAX);
			}
			else {
				glColor4f (1.0, 1.0, 1.0, fFade * NOTE_TEXTFADEMAX);
			}
		  glDepthRange (0.0, 1.0);

			RenderBitmapString (psNote->vsAnchor.fX + psNote->fMarginInternal + psNote->fMarginExternal + NOTE_XSHIFT, psNote->vsAnchor.fY + psNote->vsSize.fY - psNote->fMarginExternal - psNote->fMarginInternal + NOTE_YSHIFT - NOTETEXT_LINEHEIGHT + 2.0f, psNote->vsAnchor.fZ, NOTETEXT_FONT, psNote->szText->str);
		}
	}
}
Пример #5
0
void SceneTutorial21::Draw()
{
    Scene::Draw();

    int width = 640;
    int height = 480;
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0f, width, height, 0.0f, -1.0f, 1.0f);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();


    
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
    glLoadIdentity();

    // rendering fonts
    {
        glColor3d(1.0f, 0.5f, 1.0f);
        RenderBitmapString(GLUT_BITMAP_HELVETICA_18, 207, 24, "GRID CRAZY");
        glColor3f(1.0f, 1.0f, 0.0f);
        RenderBitmapString(GLUT_BITMAP_HELVETICA_18, 20, 20, "Level:");
        RenderBitmapString(GLUT_BITMAP_HELVETICA_18, 20, 40, "Stage:");

        if( gameover ) {
            glColor3ub(rand()%255, rand()%255, rand()%255);
            RenderBitmapString(GLUT_BITMAP_HELVETICA_18, 472, 20, "GAME OVER");
            RenderBitmapString(GLUT_BITMAP_HELVETICA_18, 456, 40, "PRESS SPACE");
        }
        glColor3f(1.0f, 1.0f, 1.0f);
    }

    for (loop1=0; loop1<lives-1; loop1++)					// Loop Through Lives Minus Current Life
    {
        glLoadIdentity();									// Reset The View
        glTranslatef(490+(loop1*40.0f),40.0f,0.0f);			// Move To The Right Of Our Title Text
        glRotatef(-player.spin,0.0f,0.0f,1.0f);				// Rotate Counter Clockwise
        glColor3f(0.0f,1.0f,0.0f);							// Set Player Color To Light Green
        glBegin(GL_LINES);									// Start Drawing Our Player Using Lines
        glVertex2d(-5,-5);								// Top Left Of Player
        glVertex2d( 5, 5);								// Bottom Right Of Player
        glVertex2d( 5,-5);								// Top Right Of Player
        glVertex2d(-5, 5);								// Bottom Left Of Player
        glEnd();											// Done Drawing The Player
        glRotatef(-player.spin*0.5f,0.0f,0.0f,1.0f);		// Rotate Counter Clockwise
        glColor3f(0.0f,0.75f,0.0f);							// Set Player Color To Dark Green
        glBegin(GL_LINES);									// Start Drawing Our Player Using Lines
        glVertex2d(-7, 0);								// Left Center Of Player
        glVertex2d( 7, 0);								// Right Center Of Player
        glVertex2d( 0,-7);								// Top Center Of Player
        glVertex2d( 0, 7);								// Bottom Center Of Player
        glEnd();											// Done Drawing The Player
    }

    filled=true;											// Set Filled To True Before Testing
    glLineWidth(2.0f);										// Set Line Width For Cells To 2.0f
    glDisable(GL_LINE_SMOOTH);								// Disable Antialiasing
    glLoadIdentity();										// Reset The Current Modelview Matrix
    for (loop1=0; loop1<11; loop1++)						// Loop From Left To Right
    {
        for (loop2=0; loop2<11; loop2++)					// Loop From Top To Bottom
        {
            glColor3f(0.0f,0.5f,1.0f);						// Set Line Color To Blue
            if (hline[loop1][loop2])						// Has The Horizontal Line Been Traced
            {
                glColor3f(1.0f,1.0f,1.0f);					// If So, Set Line Color To White
            }

            if (loop1<10)									// Dont Draw To Far Right
            {
                if (!hline[loop1][loop2])					// If A Horizontal Line Isn't Filled
                {
                    filled=false;							// filled Becomes False
                }
                glBegin(GL_LINES);							// Start Drawing Horizontal Cell Borders
                glVertex2d(20+(loop1*60),70+(loop2*40));// Left Side Of Horizontal Line
                glVertex2d(80+(loop1*60),70+(loop2*40));// Right Side Of Horizontal Line
                glEnd();									// Done Drawing Horizontal Cell Borders
            }

            glColor3f(0.0f,0.5f,1.0f);						// Set Line Color To Blue
            if (vline[loop1][loop2])						// Has The Horizontal Line Been Traced
            {
                glColor3f(1.0f,1.0f,1.0f);					// If So, Set Line Color To White
            }
            if (loop2<10)									// Dont Draw To Far Down
            {
                if (!vline[loop1][loop2])					// If A Verticle Line Isn't Filled
                {
                    filled=false;							// filled Becomes False
                }
                glBegin(GL_LINES);							// Start Drawing Verticle Cell Borders
                glVertex2d(20+(loop1*60),70+(loop2*40));// Left Side Of Horizontal Line
                glVertex2d(20+(loop1*60),110+(loop2*40));// Right Side Of Horizontal Line
                glEnd();									// Done Drawing Verticle Cell Borders
            }

            glEnable(GL_TEXTURE_2D);						// Enable Texture Mapping
            glColor3f(1.0f,1.0f,1.0f);						// Bright White Color
            glBindTexture(GL_TEXTURE_2D, img->GetTexture());		// Select The Tile Image
            if ((loop1<10) && (loop2<10))					// If In Bounds, Fill In Traced Boxes
            {
                // Are All Sides Of The Box Traced?
                if (hline[loop1][loop2] && hline[loop1][loop2+1] && vline[loop1][loop2] && vline[loop1+1][loop2])
                {
                    glBegin(GL_QUADS);						// Draw A Textured Quad
                    glTexCoord2f(float(loop1/10.0f)+0.1f,1.0f-(float(loop2/10.0f)));
                    glVertex2d(20+(loop1*60)+59,(70+loop2*40+1));	// Top Right
                    glTexCoord2f(float(loop1/10.0f),1.0f-(float(loop2/10.0f)));
                    glVertex2d(20+(loop1*60)+1,(70+loop2*40+1));	// Top Left
                    glTexCoord2f(float(loop1/10.0f),1.0f-(float(loop2/10.0f)+0.1f));
                    glVertex2d(20+(loop1*60)+1,(70+loop2*40)+39);	// Bottom Left
                    glTexCoord2f(float(loop1/10.0f)+0.1f,1.0f-(float(loop2/10.0f)+0.1f));
                    glVertex2d(20+(loop1*60)+59,(70+loop2*40)+39);	// Bottom Right
                    glEnd();								// Done Texturing The Box
                }
            }
            glDisable(GL_TEXTURE_2D);						// Disable Texture Mapping
        }
    }
    glLineWidth(1.0f);										// Set The Line Width To 1.0f

    if (anti)												// Is Anti TRUE?
    {
        glEnable(GL_LINE_SMOOTH);							// If So, Enable Antialiasing
    }

    if (hourglass.fx==1)									// If fx=1 Draw The Hourglass
    {
        glLoadIdentity();									// Reset The Modelview Matrix
        glTranslatef(20.0f+(hourglass.x*60),70.0f+(hourglass.y*40),0.0f);	// Move To The Fine Hourglass Position
        glRotatef(hourglass.spin,0.0f,0.0f,1.0f);			// Rotate Clockwise
        glColor3ub(rand()%255,rand()%255,rand()%255);		// Set Hourglass Color To Random Color
        glBegin(GL_LINES);									// Start Drawing Our Hourglass Using Lines
        glVertex2d(-5,-5);								// Top Left Of Hourglass
        glVertex2d( 5, 5);								// Bottom Right Of Hourglass
        glVertex2d( 5,-5);								// Top Right Of Hourglass
        glVertex2d(-5, 5);								// Bottom Left Of Hourglass
        glVertex2d(-5, 5);								// Bottom Left Of Hourglass
        glVertex2d( 5, 5);								// Bottom Right Of Hourglass
        glVertex2d(-5,-5);								// Top Left Of Hourglass
        glVertex2d( 5,-5);								// Top Right Of Hourglass
        glEnd();											// Done Drawing The Hourglass
    }

    glLoadIdentity();										// Reset The Modelview Matrix
    glTranslatef(player.fx+20.0f,player.fy+70.0f,0.0f);		// Move To The Fine Player Position
    glRotatef(player.spin,0.0f,0.0f,1.0f);					// Rotate Clockwise
    glColor3f(0.0f,1.0f,0.0f);								// Set Player Color To Light Green
    glBegin(GL_LINES);										// Start Drawing Our Player Using Lines
    glVertex2d(-5,-5);									// Top Left Of Player
    glVertex2d( 5, 5);									// Bottom Right Of Player
    glVertex2d( 5,-5);									// Top Right Of Player
    glVertex2d(-5, 5);									// Bottom Left Of Player
    glEnd();												// Done Drawing The Player
    glRotatef(player.spin*0.5f,0.0f,0.0f,1.0f);				// Rotate Clockwise
    glColor3f(0.0f,0.75f,0.0f);								// Set Player Color To Dark Green
    glBegin(GL_LINES);										// Start Drawing Our Player Using Lines
    glVertex2d(-7, 0);									// Left Center Of Player
    glVertex2d( 7, 0);									// Right Center Of Player
    glVertex2d( 0,-7);									// Top Center Of Player
    glVertex2d( 0, 7);									// Bottom Center Of Player
    glEnd();												// Done Drawing The Player

    for (loop1=0; loop1<(stage*level); loop1++)				// Loop To Draw Enemies
    {
        glLoadIdentity();									// Reset The Modelview Matrix
        glTranslatef(enemy[loop1].fx+20.0f,enemy[loop1].fy+70.0f,0.0f);
        glColor3f(1.0f,0.5f,0.5f);							// Make Enemy Body Pink
        glBegin(GL_LINES);									// Start Drawing Enemy
        glVertex2d( 0,-7);								// Top Point Of Body
        glVertex2d(-7, 0);								// Left Point Of Body
        glVertex2d(-7, 0);								// Left Point Of Body
        glVertex2d( 0, 7);								// Bottom Point Of Body
        glVertex2d( 0, 7);								// Bottom Point Of Body
        glVertex2d( 7, 0);								// Right Point Of Body
        glVertex2d( 7, 0);								// Right Point Of Body
        glVertex2d( 0,-7);								// Top Point Of Body
        glEnd();											// Done Drawing Enemy Body
        glRotatef(enemy[loop1].spin,0.0f,0.0f,1.0f);		// Rotate The Enemy Blade
        glColor3f(1.0f,0.0f,0.0f);							// Make Enemy Blade Red
        glBegin(GL_LINES);									// Start Drawing Enemy Blade
        glVertex2d(-7,-7);								// Top Left Of Enemy
        glVertex2d( 7, 7);								// Bottom Right Of Enemy
        glVertex2d(-7, 7);								// Bottom Left Of Enemy
        glVertex2d( 7,-7);								// Top Right Of Enemy
        glEnd();											// Done Drawing Enemy Blade
    }

    glutSwapBuffers();
}
void Display()
{
	/**
	@Desc : Displays the cells and text in a window on screen
	*/

	// Display the cells using OpenGL
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0, g_windowWidth, g_windowHeight, 0);

	glClearColor(1, 1, 1, 1);
	glClear(GL_COLOR_BUFFER_BIT);
	glBegin(GL_QUADS);
	int _healthyCount = 0;
	int _cancerCount = 0;
	int _medicineCount = 0;
	for (int x = 0; x < g_windowWidth; x++)
	{
		for (int y = 0; y < g_windowHeight; y++)
		{
			if (g_quad[x][y] == HEALTHY)
			{
				// Healthy cells are green
				glColor3f(0, 0.5, 0);
				_healthyCount++;
			}
			else if (g_quad[x][y] == CANCER)
			{
				// Cancer cells are red
				glColor3f(1, 0, 0);
				_cancerCount++;
			}
			else if (g_quad[x][y] == MEDICINE)
			{
				// Medicine cells are yellow
				glColor3f(1, 1, 0);
				_medicineCount++;
			}
			glVertex2f(x, y);
			glVertex2f(x + 1, y);
			glVertex2f(x + 1, y + 1);
			glVertex2f(x, y + 1);
		}
	}
	glEnd();

	std::string _hCount = std::to_string(_healthyCount);
	const char * _hc = _hCount.c_str();
	std::string _cCount = std::to_string(_cancerCount);
	const char * _cc = _cCount.c_str();
	std::string _mCount = std::to_string(_medicineCount);
	const char * _mc = _mCount.c_str();

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	glColor3f(0, 0, 0);
	// Display the number of each type of cell
	RenderBitmapString(0, 30, (void *)g_font, "Healthy: ");
	RenderBitmapString(0, 50, (void *)g_font, _hc);
	RenderBitmapString(0, 100, (void*)g_font, "Cancer: ");
	RenderBitmapString(0, 120, (void *)g_font, _cc);
	RenderBitmapString(0, 170, (void *)g_font, "Medicine: ");
	RenderBitmapString(0, 190, (void *)g_font, _mc);
	glPopMatrix();

	glutSwapBuffers();
}