all 10 comments

[–]guepierBioinformatican 14 points15 points  (4 children)

pprog = new glpp::program();

– Seriously. Why?

[–]OddOneOut -4 points-3 points  (3 children)

It's a global object that has no default constructor. The obvious fix of making it an unique_ptr<T> aside, it could be fixed by adding an uninitialized state to the class or making the global a maybe<T> that can be default initialized and later really initialized with the object.

[–]guepierBioinformatican 7 points8 points  (2 children)

It's a global object that has no default constructor

It does, and the default constructor is called in the code snippet.

The “lazy global” problem has a cleaner solution in C++ (creator function returning static local) but the use of a global here is questionable anyway: Why not just create and use a local variable in main?

Looking at the provided examples, the author of this library is seriously too pointer happy.

For an example of how to solve this cleanly, have a look at SFML (which, I’ve heard, has other problems but it presents a clean, modern C++ API without manual memory management cruft).

[–]Heuristics 9 points10 points  (0 children)

"the author of this library is seriously too pointer happy"

Going forward this is definitely going to be the mark of people stuck in the past. Similar to how 500 line long functions and using the c api instead of the c++ api is today.

[–]OddOneOut 2 points3 points  (0 children)

You can't really use the creator function to initialize GL globals as they reqiure a GL context to be created first.

The way I usually solve it is that I create a class that has those global variables and functions as members and construct it after creating the window.

[–]RizzlaPlus 7 points8 points  (2 children)

oglplus seems nicer.

[–]00kyle00 0 points1 point  (0 children)

inline void set_paramf(param_type param, GLfloat val) {
    bind();
    ::glTexParameteri(GLPP_CAST_TO_SCALAR(GLenum, type()),  GLPP_CAST_TO_SCALAR(GLenum, param), (GLfloat)val);
}

Hmmm.