cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : Windows Programming : running speed
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programm...
Articles
Lounge
Jobs

-

post  running speed

Nandor (83)
This is a function which draws a GLscene and it runs slowly on video cards which aren,t powerfull...Does anyone know how to make it faster?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
void Draw(void)													// Draw Our Scene
{
	char *income,*gold,*stone,*pop;
	selection=" ";
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear Screen And Depth Buffer
	glLoadIdentity();											// Reset The Modelview Matrix
	RECT window;												// Storage For Window Dimensions
	GetClientRect (g_window->hWnd,&window);						// Get Window Dimensions
	glMatrixMode(GL_PROJECTION);								// Select The Projection Matrix
	glPushMatrix();												// Store The Projection Matrix
	glLoadIdentity();											// Reset The Projection Matrix
	glOrtho(0,window.right,0,window.bottom,-1,1);				// Set Up An Ortho Screen
	glMatrixMode(GL_MODELVIEW);									// Select The Modelview Matrix
	glTranslated(mouse_x,window.bottom-mouse_y,0.0f);			
	Object(16,16,8);
	if(mouse_y<704-Bcursor[curbuilding].h/2&&mouse_y>66+Bcursor[curbuilding].h/2&&mouse_x>196+Bcursor[curbuilding].w/2-5&&mouse_x<833-Bcursor[curbuilding].w/2-5&&buildmode)
	{
		Object(Bcursor[curbuilding].w,Bcursor[curbuilding].h,Bcursor[curbuilding].nmb);
	}
	glTranslated(-mouse_x,-window.bottom+mouse_y,0.0f);
	if(loadscreen)
	{
		glPrint(385,500,"Username:%s",name);
		glPrint(385,480,"Password:%s",hiddenpass);;		
		glPrint(380,530,"Enter username and password");		
		glPrint(485,455,"Login");
		if(loginfailure)
		{
			glPrint(425,425,"Authentication Failed!");
		}
		glTranslated(512,384,-0.1f);
		Object(520,400,50);
		glTranslated(-512,-384,0.1f);
		glTranslated(510,500,-0.1f);
		Object(200,60,6);
		glTranslated(-510,-500,0.1f);
		if(mouse_y<317&&mouse_y>290&&mouse_x>482&&mouse_x<553&&loadscreen)
		{
			
			glTranslated(517,464,-0.1f);
			Object(34,13,7);
			glTranslated(-517,-464,0.1f);
			
		}
	}
	if(gamescreen)
	{
    glTranslated(512,384,-0.2f);
	Object(520,400,51);
	glTranslated(-512,-384,0.2f);
	glTranslated(85,760,-0.1f);
	Object(10,10,38);
	glTranslated(-85,-760,0.1f);
	glTranslated(175,760,-0.1f);
	Object(10,10,37);
	glTranslated(-175,-760,0.1f);
	glTranslated(265,760,-0.1f);
	Object(10,10,36);
	glTranslated(-265,-760,0.1f);
	glTranslated(355,760,-0.1f);
	Object(10,10,39);
	glTranslated(-355,-760,0.1f);
	glTranslated(445,760,-0.1f);
	Object(10,10,40);
	glTranslated(-445,-760,0.1f);
	glPrint(10,750,"%6u   %6u   %6u   %6u   %6u   Population:%5u/%u",coins,oil,iron,ciment,asfalt,population,popmax);
	glTranslated(1004,20,-0.1f);
	Object(20,20,10);
	glTranslated(-1004,-20,0.1f);
		if(mouse_y<766&&mouse_y>728&&mouse_x>983&&mouse_x<1024)
		{
				glTranslated(1004,20,-0.1f);
				Object(20,20,11);
				glTranslated(-1004,-20,0.1f);
		}
	}
	glTranslated(1004,749,-0.1f);
	Object(20,20,10);
	glTranslated(-1004,-749,0.1f);
	glTranslated(1004,749,-0.0f);
	Object(20,20,2);
	glTranslated(-1004,-749,0.0f);
	if(mouse_y<48&&mouse_y>0&&mouse_x>983&&mouse_x<1024)
	{
			glTranslated(1004,749,-0.1f);
			Object(20,20,11);
			glTranslated(-1004,-749,0.1f);
	}
	glPrint(420,10,"Test");	
	glPrint(10,10,"%i",mouse_x);							
	glPrint(45,10,"%i ",mouse_y);
	if(buildmode) 
	{	
		glTranslated(512,384,-1.0f);
		Object(520,400,52);
		glTranslated(-512,-384,1.0f);
		glTranslated(512,380,-0.1f);
		Object(330,330,5);
		glTranslated(-512,-380,0.1f);
		glColor3f(1.0f,1.0f,1.0f);
		glTranslated(85,760,-0.1f);
		Object(10,10,38);
		glTranslated(-85,-760,0.1f);
		glTranslated(175,760,-0.1f);
		Object(10,10,37);
		glTranslated(-175,-760,0.1f);
		glTranslated(265,760,-0.1f);
		Object(10,10,36);
		glTranslated(-265,-760,0.1f);
		glTranslated(355,760,-0.1f);
		Object(10,10,39);
		glTranslated(-355,-760,0.1f);
		glTranslated(445,760,-0.1f);
		Object(10,10,40);
		glTranslated(-445,-760,0.1f);
		glPrint(10,750,"%6u   %6u   %6u   %6u   %6u   Population:%5u/%u",coins,oil,iron,ciment,asfalt,population,popmax);
		glPrint(420,725,"1 2 3 4 5 6 7 8 9");		
		glTranslated(100,700,-1.0f);
		Object(20,20,10);		
		glTranslated(-100,-700,1.0f);
		glTranslated(100,700,-0.0f);
		Object(17,17,20);		
		glTranslated(-100,-700,0.0f);
		if(mouse_x>80&&mouse_x<120&&mouse_y>50&&mouse_y<90||ArsenalB)
		{
			selection="Arsenal";
			gold="50";
			pop="0";
			stone="100 c";
			income="25";
			glTranslated(100,700,-1.0f);
			Object(20,20,11);		
			glTranslated(-100,-700,1.0f);
		}
		//...16 more
		glTranslated(140,420,-1.0f);
		Object(20,20,10);		
		glTranslated(-140,-420,1.0f);		
		glTranslated(140,420,0.0f);
		Object(17,17,35);		
		glTranslated(-140,-420,0.0f);
		if(mouse_x>120&&mouse_x<160&&mouse_y>330&&mouse_y<370||HQB)
		{
			selection="Union HQ";
			glTranslated(140,420,-1.0f);
			Object(20,20,11);		
			glTranslated(-140,-420,1.0f);
		}
		glTranslated(930,600,-0.1f);
		Object(80,80,1);
		glTranslated(-930,-600,0.1f);		
		glTranslated(930,400,-0.1f);
		Object(80,80,1);
		glTranslated(-930,-400,0.1f);
		glPrint(860,460,"Income:%s",income);
		glPrint(860,440,"Pop:%s",pop);
		glPrint(860,420,"$:%s",gold);
		glPrint(860,400,"Special:%s",stone);
		glPrint(50,730,"%s",selection);
		for(int aux=0;aux<blimit;aux++)
		{
			if(buildID[aux].built)
			glTranslated(buildID[aux].x,buildID[aux].y,-0.1f);
			Object(buildID[aux].w,buildID[aux].h,buildID[aux].building+100);
			glTranslated(-buildID[aux].x,-buildID[aux].y,0.1f);
		}

	}
}
|
Zaita (1607)
This is a function which draws a GLscene and it runs slowly on video cards which aren,t powerfull...Does anyone know how to make it faster?


Errr...

What is the Object(X,Y,Z); call do?

You are also doing all of your work in intermediate mode. It'd be very easy to optimize this code by using display lists. Grab a book called "The OpenGL Bible" and you should be set. You can find it online @ www.opengl.org
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2009 - All rights reserved - v2.2
Spotted an error? contact us