C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[73482] c++debug오류에 대해
opengl [] 4706 읽음    2016-03-25 14:31
c++로 opengl 이용해 삼각형 그리는 프로그램 만드는데 컴파일에러가 없는데 프로그램을 돌릴라 치면 디버그 에러가 뜹니다.
Unhandled exception at 0x00FC574E in ConsoleApplication2.exe: 0xC0000005: Access violation reading location 0x00000000.
이런 디버그에러가뜨는데요 구글링해보니까 포인터 초기화관련문제라는데
어디가 문제인지 모르겠습니다
밑에가 제가 쓴 메인코드입니다.

#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 < n; ++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();
}
이건 헤더파일입니다.
#ifndef _triangle_h
#define _triangle_h

void readFile(float** inputlist);

#endif _triangle_h
이 파일은 파일 출력하기 위해 만든 소스입니다.
#include<fstream>
#include"triangle.h"

void readFile(float** inputlist){
    std::ifstream ifs("input.txt");
}
메인 소스 어디가 문제가 생겨서 debug오류가 자꾸생길까요???

+ -

관련 글 리스트
73482 c++debug오류에 대해 opengl 4706 2016/03/25
73484     Re:c++debug오류에 대해 kylix 4523 2016/03/25
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.