简体   繁体   中英

OpenGL - Switching from C to C++

I'm learning to write OpenGL programs. So far, I've been using C, but I'm realizing as the programs get more involved, it might be nice to program in a more object oriented way, so I'm setting up a skeleton program in C++.

This program couldn't be any simpler. Except that I get this error:

No matching function for call to glutInit()

I've seen this error in other posts, and I've implemented the suggestions, but the error remains. What am I doing wrong? Thanks!

chess.h

#ifndef __chess1__chess1__
#define __chess1__chess1__

#include <iostream>
#include <GLUT/GLUT.h>    //edited
#endif /* defined(__chess1__chess1__) */

chess.cpp

#include "chess.h"
using namespace std;

int main(int argc, char * argv[]) {

    glutInit();
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(1000, 1000);
    glutCreateWindow("Chess Program");
    glutMainLoop();
    exit(0);
}

glutInit(int* argcp, char** argv) takes two parameters, one being a pointer to argc and the other being argv. It should be called as such: glutInit(&argc, argv) .

http://www.opengl.org/documentation/specs/glut/spec3/node10.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM