C/Visual C - Error Excepción producida en 0x1000C759 (glut32.dll)

 
Vista:
sin imagen de perfil
Val: 2
Ha disminuido su posición en 28 puestos en C/Visual C (en relación al último mes)
Gráfica de C/Visual C

Error Excepción producida en 0x1000C759 (glut32.dll)

Publicado por jhon (1 intervención) el 14/04/2021 17:54:00
Hola chicos, estoy aprendiendo a usar la librería de open GL en c++, el programa estaba funcionando bien, lo cerre y al abrirlo nuevamente me comenzó a mostrar el error: Excepción producida en 0x1000C759 (glut32.dll) en Menu_Funcional_C++.exe: 0xC0000005: Infracción de acceso al leer la ubicación 0x42555010.

Agradecería si me ayudan a solucionarlo.

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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
//Llamado de librerías
#include<iostream>
#include "glut.h"
#include <math.h>
 
using namespace std;
#define PI 3.14159265
 
double a = ((9.0 + 8.0) / 2.0), righ = 2 * a, lef = -2 * a, top = 2 * a, bottom = -2 * a; //promedio código últimos dos dígitos del estudiante
double COP[3] = { 5.0, 3 * a, 5.0 }, at[3] = { 0,0,0 }, up[3] = { 0,1,0 }, ang = 60, near = 1, far = 300, h = 500, w = 500, asprat = w / h;//matrices y angulos dados
double pi[4][4] = { a, 1, 0, 0, 1, 0, 0, 0, 0, a, 0, 0 }; //puntos a gráficar
//N corresponde ala matriz final de n, u matriz final de U, abcd son variables necesarias para algunos calculos; donde b y d coresponden a las raices o valores absolutos
double n[3] = { 0 }, N[3] = { 0 }, b = 0, c = 0, d = 0, e = 0, u[3] = { 0 }, U[3] = { 0 }, V[3] = { 0 }, arr[16] = { 0 }, arrp[16] = { 0 }, arro[16] = { 0 };
double x = COP[0], y = COP[1], z = COP[2], ux = 0, uy = 0, uz = 0, vx = 0, vy = 0, vz = 0, nx = 0, ny = 0, nz = 0;
//Mv matriz de vista / matriz traslacción
double Mv[4][4] = { 0 }, Tcop[4][4] = { 1, 0, 0, -x,  0, 1, 0, -y,  0, 0, 1, -z,  0, 0, 0, 1 };
int k = 0, l = 0, m = 0, op = 1;
double Mp[4][4] = { 1 / (asprat * (tan((ang * PI) / (2 * 180)))), 0, 0, 0,  0, (1 / (tan(ang * PI / (2 * 180)))), 0, 0,  0, 0, -((far + near) / (far - near)), -((2 * far * near) / (far - near)),  0, 0, -1, 0 };
double Mo[4][4] = { (2 / (righ - lef)), 0, 0, -((righ + lef) / (righ - lef)),  0, ((2) / (top - bottom)), 0, -((top + bottom) / (top - bottom)),  0, 0, -((2) / (far - near)), -((far + near) / (far - near)), 0, 0, 0, 1 };
 
void CalM(void)
{
	for (int i = 0; i < 3; i++)
	{
		n[i] = COP[i] - at[i];
		cout << n[i] << " ";
		b += pow(n[i], 2);
		c = sqrt(b);
	}
 
	cout << endl << "Mostramos N" << endl << endl;
 
	for (int i = 0; i < 3; i++)
	{
		(N[i] = n[i] / c);
		nx = N[0];
		ny = N[1];
		nz = N[2];
		cout << N[i] << " ";
	}
 
 
	cout << endl << endl;
	for (int i = 0; i < 3; i++)
	{
		if (i == 0)
		{
			U[i] = ((up[1] * N[2]) - (N[1] * up[2]));
		}
 
		else
		{
			if (i == 1)
			{
				U[i] = ((up[2] * N[0]) - (N[2] * up[0]));
			}
 
			else
			{
				U[i] = ((up[0] * N[1]) - (N[0] * up[1]));
			}
		}
 
		cout << U[i] << " ";
	}
 
	for (int i = 0; i < 3; i++)
	{
		d += pow(U[i], 2);
		e = sqrt(d);
	}
 
	cout << endl << e << " " << endl << endl;
	cout << endl << endl << "Mostramos U" << endl << endl;
 
	for (int i = 0; i < 3; i++)
	{
		u[i] = U[i] / e;
		ux = u[0];
		uy = u[1];
		uz = u[2];
		cout << u[i] << " ";
	}
 
	cout << endl << endl << endl;
	cout << endl << endl << "Mostramos V" << endl << endl;
 
	for (int i = 0; i < 3; i++)
	{
		if (i == 0)
		{
			V[i] = ((N[1] * u[2]) - (u[1] * N[2]));
		}
 
		else
		{
			if (i == 1)
			{
				V[i] = ((N[2] * u[0]) - (u[2] * N[0]));
			}
 
			else
			{
				V[i] = ((N[0] * u[1]) - (u[0] * N[1]));
			}
		}
 
		vx = V[0];
		vy = V[1];
		vz = V[2];
		cout << V[i] << " ";
	}
 
	cout << endl << endl;
 
	/*for (int i=0; i<4; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			cout << Tcop[i][j] << " ";
		}
		cout << endl;
	}*/
 
	cout << endl << endl;
	double rot[4][4] = { ux, uy, uz, 0, vx, vy, vz, 0, nx, ny, nz, 0, 0, 0, 0, 1 };
 
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			cout << rot[i][j] << "  ";
		}
		cout << endl;
	}
 
	cout << endl << endl;
	cout << endl << endl << "Mostramos Matriz de visualización:" << endl << endl;
 
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			for (int k = 0; k < 4; k++)
			{
				Mv[i][j] += (rot[i][k] * Tcop[k][j]);
			}
 
			cout << Mv[i][j] << " ";
		}
		cout << endl;
	}
 
	cout << endl << endl;
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			arr[k] = Mv[j][i];
			cout << arr[k] << " ";
			k++;
		}
		cout << endl;
	}
 
	cout << endl << endl;
 
}
 
void calP(void)
{
	//Matriz de perspectiva.
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			arrp[l] = Mp[j][i];
			cout << Mp[i][j] << "  ";
			l++;
		}
		cout << endl;
	}
 
	cout << endl << endl;
 
	for (int i = 0; i < 16; i++)
	{
		cout << arrp[i] << " ";
	}
	cout << endl;
}
 
void Calo(void)
{
	cout << endl << endl;
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			arro[m] = Mo[j][i];
			cout << Mo[i][j] << "  ";
			m++;
		}
		cout << endl;
	}
 
 
	cout << endl << endl;
 
	for (int i = 0; i < 16; i++)
	{
		cout << arro[i] << " ";
	}
	cout << endl;
}
 
void init(void) //Función de inicialización.
{
	glClearColor(0.0, 0.0, 0.0, 0.0);
	glShadeModel(GL_FLAT);
}
 
 
void OpcMenu(int opción)
{
	GLfloat Mxxp[16] = { 0 }; GLfloat Mxxo[16] = { 0 };
	switch (opción)
	{
	case 1:
		CalM();
		gluPerspective(60.0, (float)w / (float)h, 1.0, 300.0);
		break;
 
	case 2:
		calP();
		for (int i = 0; i < 16; i++)
		{
			Mxxp[i] = arrp[i];
		}
		glLoadMatrixf(Mxxp);
		break;
 
	case 3:
		Calo();
		for (int i = 0; i < 16; i++)
		{
			Mxxo[i] = arro[i];
		}
		glLoadMatrixf(Mxxo);
		break;
 
	case 4:
		cout << " Programa Finalizado";
		break;
	}
	glutPostRedisplay();
}
 
void Menu(void)
{
	int matriz = glutCreateMenu(OpcMenu);
	glutAddMenuEntry("MATRIZ DE VISUALIZACIÓN", 1);
	glutAddMenuEntry("MATRIZ DE PERSPECTIVA", 2);
	glutAddMenuEntry("MATRIZ DE ORTOGONAL", 3);
	glutAddMenuEntry("Salir", 4);
	glutCreateMenu(OpcMenu);
	glutAddSubMenu("Opciones Matrices", matriz);
	glutAddSubMenu("Salir", 4);
	glutAttachMenu(GLUT_RIGHT_BUTTON);
}
 
void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glColor3f(1.0, 0.0, 0.0);
	glLoadIdentity();
	CalM();
	//Vista de camara / centro de vista / vector en y
	/*gluLookAt(copx, copy, copz, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);*/
	GLfloat Mxx[16] = { 0 };
	for (int i = 0; i < 16; i++)
	{
		Mxx[i] = arr[i];
	}
	glLoadMatrixf(Mxx);
 
	//simetría de objetos en escena
	glBegin(GL_QUADS);
	glVertex3f(a, 1, 0);
	glVertex3d(0, 1, 0);
	glVertex3f(0, 0, 0);
	glVertex3f(a, 0, 0);
	glEnd();
	glFlush();
}
 
////adaptador de imagen para cambios de tamaño de la ventana
void reshape(int w, int h)
{
	glViewport(0, 0, (GLsizei)w, (GLsizei)h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	Menu();
 
	glFlush();
}
 
void main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutInitWindowSize(w, h); //tamaño de ventana
	glutInitWindowPosition(100, 100);//posicion de ventana
	glutCreateWindow(argv[0]); //crear y nombrar la ventana
	init();
	glutDisplayFunc(display); //llamar función
	glutReshapeFunc(reshape);
	glutMainLoop();
} //final Funcion
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder