c++openglsdlc++builderc++builder-10-seattle

openGL - Access Violation when calling glMatrixMode(...)


I am currently using SDL 1.2.4 and C++Builder 10.0 Seattle. I have set up a simple test program to check if everything is working correctly.

The following code compiles with no warning or errors, but gives me a runtime error:

Exception-Klasse $C0000005 mit Meldung 'access violation at 0x68cc46f5: read of address 0x00001701'. Prozess Project1.exe (2624)

int _tmain(int argc, _TCHAR* argv[]) {

    SDL_Init(SDL_INIT_VIDEO);
    SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(70,(double)640/480,1,1000);

    while (true) {
        SDL_PumpEvents();
    }

    return 0;
}

If I remove glMatrixMode(...), the code "works", meaning a window pops up but displays nothing. So the MatrixMode seems to be the problem here.


Solution

  • In case anyone finds this thread via google:

    I downloaded opengl32.lib and gl32.lib for Borland compilers. Those files were broken apperently. Don't know the source anymore, but be cautious when using a file called bc_libs.zip

    I created the .lib myself with the .dll found in windows/system32.