Sign in to follow this  
pkiskool

Display List Help!

Recommended Posts

I'm developing a software for my master's degree, where I basically simulate a 2D fluid flow in a cavity. I have a question regarding the graphics side of my program, which I need to improve the fps of my software using the Display List. I currently draw things in the ordinary slow way, but someone has told me that DL is a good way to improve fps and remove some lags. My program is very choppy at the moment and I really need to improve this... but I'm not too sure how to implement the DL. I've tried following a tutorial but failed miserably. Someone please give me a help... Here is source code for the GRAPHICS section (I won't include the math section).
//HEADER FILES
#include "glut.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <string>
#include <stdlib.h>

#define TINY 1.0e-20;
#define NRANSI
#define GL_PI 3.1415f

#include "nrutil.h"	//NR
#include "nrutil.cpp"	//NR
#include "ludcmp.h"	//NR
#include "lubksb.h" //NR

#include "matcalc2.h" 
#include "matcalc3.h" 
#include "front.h"

// Rotation amounts
static GLdouble xRot = 0.0f;
static GLdouble yRot = 0.0f;
static GLdouble zRot = 0.0f;

static GLdouble eyeX = 0.0f;
static GLdouble eyeY = -1.0f;
static GLdouble eyeZ = 2500.0f;

static GLdouble centerX = 0.0f;
static GLdouble centerY = 0.0f;
static GLdouble centerZ = 0.0f;

static GLdouble upX = 0.0f;
static GLdouble upY = 0.0f;
static GLdouble upZ = 1.0f;

static GLdouble scale = 1.0f;

bool GeometryFlag;
bool ZoomInFlag;
bool ZoomOutFlag;
bool NumFlag;
bool LegendFlag=true;
int numb=0;
GLdouble y, x;	
double gridspace = 12.0f;
unsigned int now, last;

#pragma warning( disable : 4996 )


////////////////////////////////////////////
// Text rendering function//
//////////////////////////////////////////

void render_text(float x, float y, char* s)
{
	glRasterPos2f(x,y);
	for ( unsigned int i=0; i < strlen( s ); i++ )
		glutBitmapCharacter(GLUT_BITMAP_9_BY_15,s[i]);
}


///////////////////////////////////////////////////////////
// Setup the rendering state
//////////////////////////////////////////////////////////
// Called to draw scene

void RenderScene(void)
	{
		/*now = GetTickCount();		//comment THIS (only // parts) out TO GO MANAUL////////////////////////////////////////////////////////////////////////////////
		if (now-last>100){			//THE NUMBER HERE CONTROLS THE SPEED - 1000 IS 1 SECOND
			last = now;				//
			front();				//
			if (SolutionFlag==true) {//
					matcalc3();			//
					SolutionFlag=false; //
			}							//
		}							//*/

		int i, j;
		int Gc = gridspace*(n-1)/2, Gt = (gridspace * n)/2-(gridspace/2);

		double k;

		GLdouble fCurrSize;			// Save current size

		// Clear the window with current clearing color
		glClear(GL_COLOR_BUFFER_BIT);

		// Save matrix state and do the rotation
		glPushMatrix();
		glRotatef(xRot, 1.0f, 0.0f, 0.0f);
		glRotatef(yRot, 0.0f, 1.0f, 0.0f);
		glRotatef(zRot, 0.0f, 0.0f, 1.0f);

		char text_buffer[100]; // should be big enough
		_snprintf(text_buffer, 40, "FILL TIME %d SEC", filltime );
		glColor3f(1.0f, 1.0f, 1.0f);
		render_text( 50-Gc, 5+Gc, text_buffer );


		// Set up x lines	

		for(y = - Gc; y <= (gridspace * n)/2-(gridspace/2); y += gridspace) {

			// Set the line width
			glLineWidth(2);

			// Draw the upper line
			glBegin(GL_LINES);
			glColor3f(0.1843f, 0.3098f, 0.1843f);
			glVertex3f( - Gc, y, 0);
			glVertex3f(- Gc + gridspace*(m-1), y, 0);	

			// Draw the lower line
			glColor3f(0.1843f, 0.3098f, 0.1843f);
			glVertex3f( - Gc, y, - 5);
			glVertex3f(- Gc + gridspace*(m-1), y, - 5);	

		}

		// Set up y lines	
		for(x = - Gc; x <= - Gc + gridspace*(m-1); x += gridspace) {

			// Draw the upper line
			glColor3f(0.1843f, 0.3098f, 0.1843f);
			glVertex3f(x, - Gc, 0);
			glVertex3f(x, Gc, 0);	

			// Draw the lower line
			glBegin(GL_LINES);
			glColor3f(0.1843f, 0.3098f, 0.1843f);
			glVertex3f(x, - Gc, -5);
			glVertex3f(x, Gc, -5);	

		}

		//1D case
		if (n==1) {

			for(x = - Gc; x <= - Gc + gridspace*(m-1); x += gridspace) {
				// Set the line width

				// Draw the upper line
				glColor3f(0.1843f, 0.3098f, 0.1843f);
				glVertex3f(x, - ((gridspace * (n+1)*0.3)/2-(gridspace/2)), 0);
				glVertex3f(x, ((gridspace * (n+1)*0.3)/2-(gridspace/2)), 0);	

				// Draw the lower line
				glColor3f(0.1843f, 0.3098f, 0.1843f);
				glVertex3f(x, - ((gridspace * (n+1)*0.3)/2-(gridspace/2)), -5);
				glVertex3f(x, ((gridspace * (n+1)*0.3)/2-(gridspace/2)), -5);	

			}
		}

		// Set up z lines (4 corners) - thickness to the plate

		glColor3f(0.1843f, 0.3098f, 0.1843f);
		glVertex3f( - Gc, - Gc, 0);
		glVertex3f( - Gc, - Gc, -5);	

		glColor3f(0.1843f, 0.3098f, 0.1843f);
		glVertex3f( - Gc, (gridspace * n)/2-(gridspace/2), 0);
		glVertex3f( - Gc, (gridspace * n)/2-(gridspace/2), -5);	

		glColor3f(0.1843f, 0.3098f, 0.1843f);
		glVertex3f(- Gc + gridspace*(m-1), - Gc, 0);
		glVertex3f(- Gc + gridspace*(m-1), - Gc, -5);	

		glColor3f(0.1843f, 0.3098f, 0.1843f);
		glVertex3f(- Gc + gridspace*(m-1), (gridspace * n)/2-(gridspace/2), 0);
		glVertex3f(- Gc + gridspace*(m-1), (gridspace * n)/2-(gridspace/2), -5);	
		glEnd();
		

		//Draw circle (last wetted node)
		for (i=0; i<=n-1; i++)
			{    
				for (j=1; j<=m; j++) 
					{
						if (type[i*m+j]==1) { //'o' - display with a hollow white circle
							
							/*glBegin(GL_LINE_LOOP);			//De-bug mode for flow fronts			
							glColor3f(0.000f, 0.000f, 1.000f);

							for (k=0; k<=360; k+=15)
								{
									glVertex2f( (-(gridspace * n)/2-(gridspace/2)+j*gridspace) + sin(k*0.0174) * 3.5, ( ((gridspace * n)/2-(gridspace/2) - (i*gridspace)) + cos(k*0.0174) * 3.5) );
								}*/

							glBegin(GL_TRIANGLE_FAN);
							glColor3f(0.000f, 0.000f, 1.000f);

							for (k=0; k<=360; k+=15)
								{
									glVertex2f( (-(gridspace * n)/2-(gridspace/2)+j*gridspace) + sin(k*0.0174) * 3.5, ( ((gridspace * n)/2-(gridspace/2) - (i*gridspace)) + cos(k*0.0174) * 3.5) );
								}

							glEnd();		
						}

						else if (type[i*m+j]==0) { //'i' - display with a red circle
							
							glBegin(GL_TRIANGLE_FAN);
								
							glColor3f(1.0f, 0.0f, 0.0f);	//Red

							for (k=0; k<=360; k+=15) {
								glVertex2f( (-(gridspace * n)/2-(gridspace/2)+j*gridspace) + sin(k*0.0174) * 3.5, ( ((gridspace * n)/2-(gridspace/2) - (i*gridspace)) + cos(k*0.0174) * 3.5) );
							}
			
							glEnd();
						}

						else if (type[i*m+j]==2) { //'x' - display with a white filled circle

							glBegin(GL_TRIANGLE_FAN);

								//COLOR CODE

								if (pres[i*m+j] >= 0 && pres[i*m+j] < inpres*1000/12*1)  
									glColor3f(0.000f, 0.000f, 1.000f);	//Slate Blue

								if (pres[i*m+j] >= inpres*1000/12*1 && pres[i*m+j] < inpres*1000/12*2)  
									glColor3f(0.000f, 0.5000f, 1.000f);	//Sky Blue

								if (pres[i*m+j] >= inpres*1000/12*2 && pres[i*m+j] < inpres*1000/12*3)  
									glColor3f(0.000f, 0.800f, 1.000f);	//Medium Torquoise

								if (pres[i*m+j] >= inpres*1000/12*3 && pres[i*m+j] < inpres*1000/12*4)  
									glColor3f(0.000f, 1.000f, 1.000f);	//Aquamarine

								if (pres[i*m+j] >= inpres*1000/12*4 && pres[i*m+j] < inpres*1000/12*5)  
									glColor3f(0.000f, 1.000f, 0.600f);	//Spring Green

								if (pres[i*m+j] >= inpres*1000/12*5 && pres[i*m+j] < inpres*1000/12*6)  
									glColor3f(0.000f, 1.000f, 0.000f);	//Lime Green

								if (pres[i*m+j] >= inpres*1000/12*6 && pres[i*m+j] < inpres*1000/12*7)  
									glColor3f(0.500f, 0.900f, 0.0f);	//Green

								if (pres[i*m+j] >= inpres*1000/12*7 && pres[i*m+j] < inpres*1000/12*8)  
									glColor3f(0.800f, 0.900f, 0.000f);	//Medium Spring Green

								if (pres[i*m+j] >= inpres*1000/12*8 && pres[i*m+j] < inpres*1000/12*9)  
									glColor3f(1.000f, 1.000f, 0.000f);

								if (pres[i*m+j] >= inpres*1000/12*9 && pres[i*m+j] < inpres*1000/12*10)  			
									glColor3f(1.000f, 0.800f, 0.000f);	//Coral

								if (pres[i*m+j] >= inpres*1000/12*10 && pres[i*m+j] < inpres*1000/12*11)  
									glColor3f(1.000f, 0.500f, 0.000f);

								if (pres[i*m+j] >= inpres*1000/12*11 && pres[i*m+j] < inpres*1000/12*12)  									
									glColor3f(1.0f, 0.0f, 0.0f); //changed to Red


							for (k=0; k<=360; k+=15)
								{
									glVertex2f( (-(gridspace * n)/2-(gridspace/2)+j*gridspace) + sin(k*0.0174) * 3.5, ( ((gridspace * n)/2-(gridspace/2) - (i*gridspace)) + cos(k*0.0174) * 3.5) );
								}

							glEnd();	
						}

						else if (type[i*m+j]==4) { //'+' - display with a white cube

							glColor3f(0.9882f, 0.9882f, 0.9882f);
			
							glRectf((-(gridspace * n)/2-(gridspace/2)+j*gridspace) - 4, ( ((gridspace * n)/2-(gridspace/2) - i*gridspace)  ) -4, (-(gridspace * n)/2-(gridspace/2)+j*gridspace) + 4, ( ((gridspace * n)/2-(gridspace/2) - i*gridspace)  ) +4);

							glEnd();	
						}

					}//end of for j

				}//end of for i
						
		for (i=0; i<=n-1; i++) {

				for (j=1; j<=m; j++) {

						//Flow front display
						if (xseg[i*m+j] <= 0.999 && xseg[i*m+j] >= -0.01) { //xseg has a value

							if (type[i*m+j]==3 && (type[i*m+j+1]==1 || type[i*m+j+1]==0 || type[i*m+j+1]==2)) {

								//glBegin(GL_LINE_LOOP);
								glBegin(GL_TRIANGLE_FAN);

								glColor3f(0.000f, 0.000f, 1.000f);	//Blue
								
								for (k=0; k<=360; k+=15)
								{
									glVertex2f( -(gridspace * n)/2-(gridspace/2)+(j+1)*gridspace - (gridspace*xseg[i*m+j]) + sin(k*0.0174) * 3.5,  ((gridspace * n)/2 - (gridspace/2) - i*gridspace) + cos(k*0.0174) * 3.5);
								}

								glEnd();

							}

							else if ((type[i*m+j]==1 || type[i*m+j]==0 || type[i*m+j]==2) && type[i*m+j+1]==3) {
							
								
								//glBegin(GL_LINE_LOOP);
								glBegin(GL_TRIANGLE_FAN);
								
								glColor3f(0.000f, 0.000f, 1.000f);	//Blue
								
								for (k=0; k<=360; k+=15)
								{
									glVertex2f( -(gridspace * n)/2-(gridspace/2)+j*gridspace + (gridspace*xseg[i*m+j]) + sin(k*0.0174) * 3.5,  ((gridspace * n)/2-(gridspace/2) - i*gridspace) + cos(k*0.0174) * 3.5);
								}

								glEnd();

							}
						}
					}//end of for j
				}//end of for i

		
			for (i=0; i<=n-2; i++) {

				for (j=1; j<=m; j++) {

					 if (yseg[i*m+j] <= 0.999 && yseg[i*m+j] >= -0.01) { //yseg has a value

							if (type[i*m+j]==3 && (type[i*m+j+m]==1 || type[i*m+j+m]==0 || type[i*m+j+m]==2)) {

								glBegin(GL_TRIANGLE_FAN);		
								glColor3f(0.000f, 0.000f, 1.000f);	//Blue
								
							for (k=0; k<=360; k+=15)
								{
									glVertex2f( (-(gridspace * n)/2-(gridspace/2)+j*gridspace) + sin(k*0.0174) * 3.5 ,  ((gridspace * n)/2-(gridspace/2) - (i+1)*gridspace) + (gridspace*yseg[i*m+j]) + cos(k*0.0174) * 3.5);
								}

								glEnd();

							}

							else if ( (type[i*m+j]==1 || type[i*m+j]==0 || type[i*m+j]==2) && type[i*m+j+m]==3) {
							
								//glBegin(GL_LINE_LOOP);
								glBegin(GL_TRIANGLE_FAN);
								 
								glColor3f(0.000f, 0.000f, 1.000f);	//Blue
						
								for (k=0; k<=360; k+=15)
								{
									glVertex2f( (-(gridspace * n)/2-(gridspace/2)+j*gridspace) + sin(k*0.0174) * 3.5,  ((gridspace * n)/2-(gridspace/2) - i*gridspace) - (gridspace * yseg[i*m+j]) + cos(k*0.0174) * 3.5);
								}

								glEnd();

							}
						}
					
				}
		}

			if (NumFlag == true) {

			//Set up node number fonts
				int nodecount=0;
				for (y = (gridspace * n)/2-(gridspace/2); y >= - Gc; y -= gridspace) {

					for (x = - Gc ; x <= - Gc + gridspace*(m-1); x += gridspace) {

						nodecount += 1;			
						glColor3f(1.0f, 1.0f, 1.0f);
						_snprintf(text_buffer, 40, "%d", nodecount );
						render_text( x-2.5,y, text_buffer );
					}
				}				

			}

			if (LegendFlag == true) {

				int in, la, dv;

				glBegin(GL_LINES);
				glLineWidth(0.5);
				glColor3f(1.0f, 1.0f, 1.0f);

				for (la = 8; la <= 104; la += 8) {

					glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - la);
					glVertex2f(- Gc - 43, (gridspace * n)/2-(gridspace/2) - la);
					
				}

				glEnd();

				in = inpres * 1000;

				for (dv = 12, la = 8; dv >= 0 && la <= 104; dv --, la += 8) {

					_snprintf(text_buffer, 40, "%d", in * dv/12);
					render_text( - Gc - 39, (gridspace * n)/2-(gridspace/2) - la, text_buffer );
				
				}
				

				glBegin(GL_QUADS);
				glColor3f(1.000f, 0.000f, 0.000f);	//Red
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 8);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 8);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 16);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 16);

				glColor3f(1.000f, 0.500f, 0.000f);	//Orange Red
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 16);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 16);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 24);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 24);

				glColor3f(1.000f, 0.800f, 0.000f);	//Coral
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 24);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 24);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 32);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 32);

				glColor3f(1.000f, 1.000f, 0.000f);	//Yellow
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 32);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 32);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 40);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 40);

				glColor3f(0.800f, 0.900f, 0.000);	//Medium Spring Green
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 40);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 40);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 48);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 48);

				glColor3f(0.5f, 0.9f, 0.0f);	//Green
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 48);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 48);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 56);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 56);

				glColor3f(0.000f, 1.000f, 0.000f);	//Lime Green
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 56);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 56);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 64);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 64);

				glColor3f(0.000f, 1.000f, 0.498f);	//Spring Green
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 64);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 64);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 72);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 72);

				glColor3f(0.0f, 1.0f, 1.0f);	//Aquamarine
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 72);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 72);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 80);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 80);

				glColor3f(0.0f, 0.8f, 1.0f);	//Medium Torquoise
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 80);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 80);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 88);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 88);

				glColor3f(0.0f, 0.5f, 1.0f);	//Sky Blue
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 88);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 88);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 96);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 96);

				glColor3f(0.0f, 0.0f, 1.0f);	//Slate Blue
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 96);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 96);
				glVertex2f(- Gc - 45, (gridspace * n)/2-(gridspace/2) - 104);
				glVertex2f(- Gc - 50, (gridspace * n)/2-(gridspace/2) - 104);
				glEnd();

				_snprintf(text_buffer, 40, "UNIT: Pa");
				glColor3f(1.000f, 1.000f, 1.000f);
				render_text( - Gc - 50, (gridspace * n)/2-(gridspace/2) - 116, text_buffer );
	
			}

				// Restore transformations
				glPopMatrix();

				// Flush drawing commands
				glutSwapBuffers();
				glutPostRedisplay();

				//change buffer, 2 buffers enables smooth drawing in one go
				glMatrixMode(GL_MODELVIEW);
				glLoadIdentity();
				gluLookAt(eyeX,eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);

	}

	void SetupRC(void)
    {
		// Black background
		glClearColor(0.0f, 0.0f, 0.0f, 1.0f );

    }

void ChangeSize(int w, int h)
	{
		GLfloat fAspect;

		// Prevent a divide by zero
		if(h == 0)
			h = 1;

		// Set Viewport to window dimensions
		glViewport(0, 0, w, h);

		fAspect = (GLfloat)w/(GLfloat)h;

		// Reset coordinate system
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();

		// Produce the perspective projection
		gluPerspective(5.0f, fAspect, 1.0, 6000.0);

	}

void OtherKeys(unsigned char key, int z, int a)
	{	

		if(key == 't')	{	// 't' starts the flow during manual mode
			if (GeometryFlag==false)
				GeometryFlag=true;

			else if (GeometryFlag==true)
				GeometryFlag=false;
		}

		if (GeometryFlag==true) {
			front();
		}
						
		if (SolutionFlag==true) {
			matcalc3();
			SolutionFlag=false;
		}	

	}


void SpecialKeys(int key, int x, int y)
	{
		if(key == GLUT_KEY_UP) {	//rotates about x
			xRot -= 5.0f;
		}

		if(key == GLUT_KEY_DOWN) {
			xRot += 5.0f;
		}

		if(key == GLUT_KEY_LEFT) {	//rotates about y
			yRot -= 5.0f;
		}

		if(key == GLUT_KEY_RIGHT) {
			yRot += 5.0f;
		}

		if(key == GLUT_KEY_HOME) {	//rotates about z
			zRot -= 5.0f;
		}

		if(key == GLUT_KEY_END) {
			zRot += 5.0f;
		}

		if(key == GLUT_KEY_F1) {	//Zoom in with F1
			eyeZ += 25;
		}

		if(key == GLUT_KEY_F2) {	//Zoom out with F2
			eyeZ -= 25;
		}

		if(key == GLUT_KEY_F3)	{	//Toggle node numbers with F3
			if (NumFlag==false)
				NumFlag=true;

			else if (NumFlag==true)
				NumFlag=false;
		}

		if (key == GLUT_KEY_F4) {	//Toggle legend on and off with F4
			if (LegendFlag==false)
				LegendFlag=true;

			else if (LegendFlag==true)
				LegendFlag=false;
		}

		if(key == GLUT_KEY_F5)	{	// Pause with F5
			cout << "Paused." << "\n";
			system ("pause");
		}

		if (key == GLUT_KEY_F12) {	//Increase time step with F12
			t += 1;
		}

		if (key == GLUT_KEY_F11) {	//Decrease time step with F11
			t += -1;
		}

		if(key == GLUT_KEY_PAGE_UP) {	//pans along x-positive
			eyeX -= 5.0f;
			centerX -= 5.0f;

		}

		if(key == GLUT_KEY_INSERT) {	//pans along x-negative
			eyeX += 5.0f;
			centerX += 5.0f;

		}

		if(zRot > 356.0f)
				zRot = 0.0f;

		if(zRot < -1.0f)
				zRot = 355.0f;

		if(xRot > 356.0f)
				xRot = 0.0f;

		if(xRot < -1.0f)
				xRot = 355.0f;

		if(yRot > 356.0f)
				yRot = 0.0f;

		if(yRot < -1.0f)
				yRot = 355.0f;

	}



int main (int argc, char **argv)
{
	//last = GetTickCount();	//Comment THIS out TO GO MANUAL/////////////////////////////////////////////

	cout << "Enter distance between the nodes (m): ";
	cin >> del_x;
	cout << "\n";

	cout << "Enter time step (s): ";
	cin >> t;
	cout << "\n";

	cout << "Enter viscosity of resin: ";
	cin >> visco;
	cout << "\n";

	cout << "Enter porosity of fibre: ";
	cin >> poro;
	cout << "\n";

	matcalc2();

	//Draw after each time step

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
	glutInitWindowSize(1152,864);
	glutCreateWindow("Simulation of VARTM Resin Impregnation Process");
	glutReshapeFunc(ChangeSize);
	glutSpecialFunc(SpecialKeys);
	glutDisplayFunc(RenderScene);
	glutKeyboardFunc(OtherKeys)
	SetupRC();
	glutMainLoop();

}


Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this