실행파일 작동이 중지됩니다
글쓴이: jyleepine / 작성시간: 목, 2016/03/24 - 11:50오후
opengl 이용해서 코딩하는데
컴파일 오류는 없는데 자꾸.exe의 작동이 중지되었습니다가 나옵니다
구글링하니까 동적할당 메모리 문제일확률이 가장크다고 하는데 뭐가 문제인가요??
헤더도 잡고 함수정의도했습니다.
#include<iostream> #include<fstream> #include"triangle.h" #include<GL/glut.h> //implement here - include header files float** position; //data to save vertices position. void renderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(1, 1, 1, 1); glBegin(GL_TRIANGLES); glVertex3f(position[0][0], position[0][1], position[0][2]); glVertex3f(position[1][0], position[1][1], position[1][2]); glVertex3f(position[2][0], position[2][1], position[2][2]); glEnd(); //implement here - draw triangle, glutSwapBuffers(); } void main(int argc, char **argv) { int m = 3, n = 3; float** position = new float*[m]; for (int i = 0; i < m; ++i){ position[i] = new float[n]; } //implement here - position is 3x3 array, allocate the memory. readFile(position); for (int i = 0; i < m; ++i) delete[]position[i]; delete[]position; // init GLUT and create Window glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100, 100); glutInitWindowSize(320, 320); glutCreateWindow("practice_03!"); // register callbacks glutDisplayFunc(renderScene); // enter GLUT event processing cycle glutMainLoop(); }
Forums:
댓글 달기