0

私はゲーム エンジンを作成しており、単純な openGL ウィンドウの作成から始めています。Visual Studio 2013 を使用しており、エンジンは dll としてビルドされています。これは、openGL を初期化する dll のコードです。

bool AsGraphicsManager::Initialize(AsWindowCreateStruct pWindow)
{

    //first create the error handler
    glfwSetErrorCallback(error::glfw_error_callback);


    //Initialize the library
    if (!glfwInit())
        return 0;



    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
#ifdef _DEBUG
    glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
#endif /* _DEBUG */
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_SAMPLES, 0);
    glfwWindowHint(GLFW_STEREO, GL_TRUE);
    glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
    glfwWindowHint(GLFW_DEPTH_BITS, 16);


    mWindow = new AsWindow(pWindow);

    //make the first window the current
    glfwMakeContextCurrent(mWindow->mWindow);

    //make sure to do this to enable new opengl
    glewExperimental = GL_TRUE;

    //now initialize glew
    GLenum res = glewInit();
    if (res != GLEW_OK)
    {
        printf("Error code: %s While Initializing Glew \n",   glewGetErrorString(res));

        return false;
    }

    //input handler
    glfwSetKeyCallback(mWindow->mWindow, input::key_callback);
    glfwSetScrollCallback(mWindow->mWindow, input::scroll_callback);
    glfwSetMouseButtonCallback(mWindow->mWindow, input::mouse_callback);
    glfwSetCursorPosCallback(mWindow->mWindow, input::mouse_position_callback);

    //nothing went wrong
    return true;
}

AsWindowCreateStruct は、次のように定義された構造体です。

struct ASGE_API AsWindowCreateStruct
{
    GLushort mHeight;
    GLushort mWidth;
    GLushort mXPos;
    GLushort mYPos;

    std::string mWindowTitle;

    bool mFullscrean;

    AsWindowCreateStruct(GLushort pWindowHeight, GLushort pWindowWidth, GLushort pWindowXPosition, GLushort pWindowYPosition, std::string pWindowTitle, bool pIsFullscrean = false) :
        mHeight(pWindowHeight), mWidth(pWindowWidth), mXPos(pWindowXPosition), mYPos(pWindowYPosition), mWindowTitle(pWindowTitle), mFullscrean(pIsFullscrean){}

};

これは、ウィンドウの作成に渡すいくつかのパラメーターとして機能するだけです。mWindow は AsWindow のオブジェクトです。このクラスの定義は重要ではありませんが、使用中のコンストラクターは次のように定義されています。

    mHeight = pCreateStruct.mHeight;
    mWidth = pCreateStruct.mWidth;
    mXPos = pCreateStruct.mXPos;
    mYPos = pCreateStruct.mYPos;
    mWindowTitle = pCreateStruct.mWindowTitle;
    mFullscrean = pCreateStruct.mFullscrean;
    mWindow = 0;

    //now create the window
    if (mFullscrean)
    {
        mWindow = glfwCreateWindow(mHeight, mWidth, mWindowTitle.c_str(), glfwGetPrimaryMonitor(), nullptr);

        if (!mWindow)
        {
            printf("Error initializing Window \n");
            glfwTerminate();
        }

    }
    else
    {
        mWindow = glfwCreateWindow(mHeight, mWidth, mWindowTitle.c_str(), nullptr, nullptr);

        //this needs to happen before seting window position
        if (!mWindow)
        {
            printf("Error initializing Window \n");
            glfwTerminate();
        }
        else
        {
            //as long as it isn't fullscrean, change the position
            glfwSetWindowPos(mWindow, mXPos, mYPos);
        }
    };

    //make the window visible
    glfwShowWindow(mWindow);

ここで、pCreateStruct は AsWindowCreateStruct のインスタンスです。

ここで、すべてのコードはさておき、問題は glfwCreateWindow() が常に 0 を返すことです。コンソールに「WGL: 適切なピクセル形式が見つかりませんでした」というエラーが表示されました。約 1 時間デバッグし、ファイル wgl_context.c の 357 行目で呼び出された関数 choosePixelFormat までトレースしました。関数の定義は wgl_context.c の 144 行目にあります。これはすべて GLFW 3.0.4 にあります。このような他の記事を見ましたが、役に立ちませんでした。NVidia GTX 650ti を使用しており、Nvidia の Geforce エクスペリエンスを使用してドライバーを最新の状態に保っています。Windowsはそれらをインストールしていません。ウェブサイトwww.glfw.orgにある GLFW の簡単なプログラムを実行してみましたが、問題なく動作します。これがDLLで実行されていることに関係していると確信していますが、どこから始めればよいかわかりません

さらに情報が必要な場合は、喜んでお知らせします。

編集:

問題は

glfwWindowHint(GL_STEREO, GL_TRUE);
4

1 に答える 1

2

GL_STEREO複数のグラフィックカードへの出力を有効にしません。スワップ チェーンのバッファ数を 2 倍にして、ステレオスコピック 3D レンダリングを有効にします (左右の画像を分離するなど)。一部のサークルでは、クワッド バッファリングと呼ばれることがあるかもしれません。

通常、Microsoft Windows の OpenGL で機能を公開するには、Radeon HD 6xxx+ コンシューマー GPU またはワークステーション クラスの NV/AMD GPU が必要です。OS X では、高価なワークステーション ハードウェアなしで入手できます。

NV のドライバーの新しいバージョンは、Microsoft Windows の OpenGL でこの機能を公開すると言われています。これを確認することはできませんが、最新の GPU に対してのみ有効にする可能性があります。それ以外の場合、Microsoft Windows でコンシューマ レベルの NV カードでクワッド バッファリングを行うには、D3D を使用する必要があります。

Doom 3 BFG Edition が NV のポリシー変更の理由である可能性が高く、これは立体視レンダリングを使用する最初の主要な OpenGLゲームです。

于 2013-11-10T23:12:33.123 に答える