地味にずっと悩んでた事をひがさんに教えてもらったので備忘録メモ。
oFでのアンチエイリアスっていうと
ofEnableSmoothing();
辺りを使えばいいんですよねとなるのだけど、
いや全然綺麗になんない。。みたいなことが常で、これまではいろいろぐぐった結果、
main.cpp の ofSetupOpenGL に ofAppGlutWindow とか ofAppGLFWWindow を渡してやって、
そいつにsample数を指定してやることでアンチエイリアス効かせてたんだけど今回は全然効かず。。なぜ。。
#include "ofAppGLFWWindow.h"
#include "ofAppGlutWindow.h"
int main(int argc, const char** argv)
{
ofAppGLFWWindow window;
window.setNumSamples(4);
// or
// ofAppGlutWindow window;
// window.setGlutDisplayString("rgba double depth alpha samples>=4");
ofSetupOpenGL(&window, 1280, 720, OF_WINDOW);
ofRunApp(new ofApp);
return 0;
}
openGLのglHintとか使っても今回は全然ダメ。。
んでひがさんに質問してみたらFbo使ってね?FboにはFboのsample数がsettingsにあるよーと。
なるほど!
んで見てみると、一番最後にありますね。
struct Settings {
int width; // width of images attached to fbo
int height; // height of images attached to fbo
int numColorbuffers; // how many color buffers to create
vector colorFormats; // format of the color attachments for MRT.
bool useDepth; // whether to use depth buffer or not
bool useStencil; // whether to use stencil buffer or not
bool depthStencilAsTexture; // use a texture instead of a renderbuffer for depth (useful to draw it or use it in a shader later)
GLenum textureTarget; // GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB
GLint internalformat; // GL_RGBA, GL_RGBA16F_ARB, GL_RGBA32F_ARB, GL_LUMINANCE32F_ARB etc.
GLint depthStencilInternalFormat; // GL_DEPTH_COMPONENT(16/24/32)
int wrapModeHorizontal; // GL_REPEAT, GL_MIRRORED_REPEAT, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER etc.
int wrapModeVertical; // GL_REPEAT, GL_MIRRORED_REPEAT, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER etc.
int minFilter; // GL_NEAREST, GL_LINEAR etc.
int maxFilter; // GL_NEAREST, GL_LINEAR etc.
int numSamples; // number of samples for multisampling (set 0 to disable)
Settings();
bool operator!=(const Settings & other);
};
なのでallocate時にnumSamples指定したsettings渡しで行けました。
あと、ofFbo::allocateの第4引数がnumSamplesになってて、ここで設定してやればsettingsじゃなくてもいけました。
ofFbo::allocate(int width, int height, int internalformat, int numSamples)
FboのnumSamplesとノーマルの描画のnumSamplesは設定場所が違うってお話でした。
これでようやくいつでも綺麗に書ける。。
you