본문 바로가기

C++

Wireframe rendering with hidden line removal Source: 1. Advanced graphics programming using OpenGL (Morgan Kaufmann) 2. OpenGL porgramming guide (Addison-Wesley Professional) We assume that triangle mesh is rendered and then, we can draw the corresponding wireframe objects with their hidden lines removed as follows. 1. Disable writing to the color buffer with glColorMask. 2. Set the depth function to GL_LEQUAL. 3. Enable depth testing with.. 더보기
Friend functions and classes socure: C++ for dummies by Stephen Randy Davis Occasionally, you want a non-member function to have access to the protected members of a class. You do so by declaring the function to be a friend of the class by using the keyword friend. Sometimes, an external function can use direct access to a data member. I know this appears to break the strictly defined, well-sealed-off class interface positi.. 더보기
Virtual function with parameter types different from those of a base class (source: Effective C++, 2E | Item 50 by Scott Meyers) class Base { public: virtual void f(int x); }; class Derived: public Base { public: virtual void f(double *pd); }; Derived *pd = new Derived; pd->f(10); // error! The problem is that Derived::f hides Base::f, even though they take different parameter types, so compilers demand that the call to f take a double*, which the literal 10 most certa.. 더보기
Copy constructor and assignment operator of derived class (source: Effective C++, 2E | Item 16 by Scott Meyers) class Derived: public Base { public: Derived(int initialValue) : Base(initialValue), y(initialValue) {} Derived(const Derived& rhs) // erroneous copy : y(rhs.y) {} // constructor private: int y; }; // correct copy constructor class Derived: public Base { public: Derived(const Derived& rhs): Base(rhs), y(rhs.y) {} ... }; // erroneous assignmen.. 더보기