8

よくわかりません。WindowsのOpenGL1.xでフレームバッファオブジェクト拡張機能(FBO)を使用するには、次のうちどれを使用しますか?

wglGetProcAddress("glGenFramebuffers");
// or
wglGetProcAddress("glGenFramebuffersEXT");

異なるハードウェアを使用しているユーザーからのレポートからわかる限り、一部のドライバーは、どちらも、2つのうちの一方、または両方のすべての組み合わせをサポートしています。

どちらを使用するのが適切ですか?一部のドライバーは実際に一方をサポートしていますが、もう一方はサポートしていませんか?見つからない場合は、一方から他方にフォールバックしようとするのは正しいですか?


編集: ATIRadeonカードとその周辺のコードでまだ深刻な問題があります。このコード(www.scirra.com)を使用して商用エディターを起動しました。FBOを使用するために使用するコードの組み合わせに関係なく、ユーザーのいくつかの異なる組み合わせでは、何も表示されない(つまり、何もレンダリングされない)と報告されます。

これは、ARB関数(サフィックスなし)を使用するか、EXTサフィックス関数を使用するかを検出するコードです。これは起動時に実行されます:

gl_extensions = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
gl_vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
gl_renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
gl_version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
gl_shading_language = reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION));

// If OpenGL version >= 3, framebuffer objects are core - enable regardless of extension
// (the flags are initialised to false)
if (atof(gl_version) >= 3.0)
{
    support_framebuffer_object = true;
    support_framebuffer_via_ext = false;
}
else
{
    // Detect framebuffer object support via ARB (for OpenGL version < 3) - also uses non-EXT names
    if (strstr(gl_extensions, "ARB_framebuffer_object") != 0)
    {
        support_framebuffer_object = true;
        support_framebuffer_via_ext = false;
    }
    // Detect framebuffer object support via EXT (for OpenGL version < 3) - uses the EXT names
    else if (strstr(gl_extensions, "EXT_framebuffer_object") != 0)
    {
        support_framebuffer_object = true;
        support_framebuffer_via_ext = true;
    }
}

その後、起動時に、テクスチャへのレンダリングを見越してFBOを作成します。

// Render-to-texture support: create a frame buffer object (FBO)
if (support_framebuffer_object)
{
    // If support is via EXT (OpenGL version < 3), add the EXT suffix; otherwise functions are core (OpenGL version >= 3)
    // or ARB without the EXT suffix, so just get the functions on their own.
    std::string suffix = (support_framebuffer_via_ext ? "EXT" : "");

    glGenFramebuffers = (glGenFramebuffers_t)wglGetProcAddress((std::string("glGenFramebuffers") + suffix).c_str());
    glDeleteFramebuffers = (glDeleteFramebuffers_t)wglGetProcAddress((std::string("glDeleteFramebuffers") + suffix).c_str());
    glBindFramebuffer = (glBindFramebuffer_t)wglGetProcAddress((std::string("glBindFramebuffer") + suffix).c_str());
    glFramebufferTexture2D = (glFramebufferTexture2D_t)wglGetProcAddress((std::string("glFramebufferTexture2D") + suffix).c_str());
    glCheckFramebufferStatus = (glCheckFramebufferStatus_t)wglGetProcAddress((std::string("glCheckFramebufferStatus") + suffix).c_str());
    glGenerateMipmap = (glGenerateMipmap_t)wglGetProcAddress((std::string("glGenerateMipmap") + suffix).c_str());

    // Create a FBO in anticipation of render-to-texture
    glGenFramebuffers(1, &fbo);
}

私はこのコードの多くのバリエーションを経験してきましたが、すべての人にそれを機能させることはできません。何もレンダリングされないと報告するユーザーのグループは常に存在します。ATIRadeonHDカードは特に問題があるようです。ドライバーのバグが関係しているかどうかはわかりませんが、上記のコードが誤った仮定をしている可能性が高いと思います。

500 repの報奨金があり、何が問題なのかを知っている人には無料のビジネスライセンスを送ります。(99ポンド相当)


編集2:いくつかの詳細。これが失敗することが知られているカードのリストは次のとおりです。

ATI Mobility Radeon HD 5650

ATI Radeon X1600 Pro

ATI Mobility Radeon HD 4200

テクスチャへのレンダリングは実際には行われません。呼び出しだけで、これらのカードでのレンダリングがglGenFramebuffers完全に停止するようです。FBOの作成を、テクスチャへのレンダリングが実際に行われる最初の時間まで延期することもできますが、おそらく、レンダリングが再び停止するだけです。

GLEWを使用することはできますが、コードで使用できないのは何ですか?ソースを調べたところ、同様のリストを使用しているようですwglGetProcAddress。私の場合、メソッドが返されます。そうでない場合はglGenFramebuffersNULLになり、クラッシュします。何か案は...?

4

2 に答える 2

10

拡張子GL_EXT_framebuffer_objectが存在する場合は、を使用できますwglGetProcAddress("glGenFramebuffersEXT");

OpenGLのバージョンが3.0以上の場合(このバージョンではFBO拡張機能がコアに追加されています)、を使用できますwglGetProcAddress("glGenFramebuffers");

于 2011-08-02T13:45:54.697 に答える
4

含めたコードは問題ではありません。もちろん、バインディングポイントはあなたがすでに行っているように取得されなければなりません。

ARB_framebuffer_objectがサポートされている場合、 EXTサフィックスのないエントリポイントを使用します。EXT_framebuffer_objectがサポートされている場合、 EXTサフィックスが付いたエントリポイントを使用します。両方がサポートされている場合は、適切なバインディングポイントを取得して実装を選択できます。

私はこの問題に非常に興味があります(あなたのために同様の疑問を持っていたので)。

ARB仕様とEXT仕様を比較すると、多くの違いに気付くでしょう。

ここでは、このトピックに関する最も興味深いARB仕様の段落を引用します。

仕様は非常に長いですが、ARBバリアントには、EXT互換性の問題に関する多くの議論が含まれています。アプリケーションを実行しているので、エントリポイントはおそらく正しいものであり、エラー(Nicolas Bolasによって提案された)はフレームバッファの完全性にある可能性があります。

可能なすべてのチェックを導入し、実装を2回再チェックします(1つはARB仕様を念頭に置き、もう1つはEXT仕様を念頭に置いています)。


この拡張機能には、EXT_framebuffer_objectにどのような追加機能が含まれていますか?

   Currently we incorporate the following layered extensions:

     * EXT_framebuffer_multisample
     * EXT_framebuffer_blit
     * EXT_packed_depth_stencil

また、次の機能もあります。

     * Permit attachments with different width and height (mixed
       dimensions)

     * Permit color attachments with different formats (mixed
       formats).

     * Render to 1 and 2 component R/RG formats that are provided
       via the ARB_texture_rg extension. L/A/LA/I will be
       left for a separate (trivial) extension.

     * Gen'ed names must be used for framebuffer objects and
       renderbuffers.

     * Added FramebufferTextureLayer.
  ...

EXT_framebuffer_objectとのその他の違いは何ですか。

     * Framebuffer completeness only considers the attachments named
       by DRAW_BUFFERi and READ_BUFFER.  Any other attachments do
       not affect framebuffer completeness.  (In
       EXT_framebuffer_object, all attachments affected framebuffer
       completeness, independent of the DRAW_BUFFERi and READ_BUFFER
       state.)
     * Added new queries for the sizes of the bit planes for color, 
       depth and stencil attachments at a framebuffer attachment point.
     * Added new queries for framebuffer attachment component type and
       color encoding.
     * Many other minor tweaks to synchronize with the GL3 framebuffer
       objects.
     * ARB FBOs are not shareable.

この拡張機能とEXT_framebuffer_objectには、どちらも「バインドフレームバッファ」関数(BindFramebufferとBindFramebufferEXT)があります。2つの機能の間に機能の違いはありますか?

    RESOLVED: Yes. Both extensions will create a new framebuffer object
    if called with an unused name. However, BindFramebuffer defined in
    this extension will generate an INVALID_OPERATION error if the name
    provided has not been generated by GenFramebuffer. That error did
    not exist in EXT_framebuffer_object, and this extension does not
    modify the behavior of BindFramebufferEXT. This difference also
    applies to BindRenderbuffer from this extension vs.
    BindRenderbufferEXT from EXT_framebuffer_object.
于 2011-08-26T09:15:37.020 に答える