3

テクスチャ付きの QUADS をレンダリングするために、かなり単純な方法で OpenGL を使用するアプリケーションがあります。

ローカルで実行している場合は問題なく動作しますが、リモート (Microsoft リモート デスクトップ) で実行している場合は、空白の白いウィンドウが表示されます。

私が行った構成のいくつかがその直接的な理由なのか、それとも表示リストなどを使用するなど、別のアプローチによってのみ解決できるより基本的なものなのか疑問に思っていました.

私のコードは次のとおりです。次のようにコンテキストを初期化します。

void InitWindow(HWND *hWnd, HDC *hDC, HGLRC *hRC)
{
    *hDC = GetDC(*hWnd);

    // set the pixel format for the DC
    PIXELFORMATDESCRIPTOR pfd;
    ZeroMemory(&pfd, sizeof(pfd));
    pfd.nSize = sizeof(pfd);
    pfd.nVersion = 1;
    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | 
            PFD_DOUBLEBUFFER;

    pfd.iPixelType = PFD_TYPE_RGBA;
    pfd.cColorBits = 24;
    //      pfd.cRedBits = 8;   
    //      pfd.cGreenBits = 8;
    //      pfd.cBlueBits = 8;
    pfd.cAlphaBits = 0;
    pfd.cDepthBits = 0;
    pfd.iLayerType = PFD_MAIN_PLANE;

    int format = ChoosePixelFormat(*hDC, &pfd);
    SetPixelFormat(*hDC, format, &pfd);

    // create and enable the render context (RC)
    *hRC = wglCreateContext(*hDC);

    // make current context current 
    wglMakeCurrent(*hDC, *hRC);
}

そして、次のように画面に描画します。

int Render(HWND hWnd, Raster* raster)
{
    Size RasterSize = raster->GetSize();

    HDC hDC = NULL;
    HGLRC hRC = NULL;

    // acquire DC, HGLRC for the window & make current
    InitWindow(&hWnd, &hDC, &hRC);

    GLenum raster_pixel_format = GL_BGRA_EXT;
    GLint internal_format = GL_RGBA;

    if (s_ClearBeforeDraw)
    {
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT);
    }

    GLuint texture;
    // allocate a texture name
    glGenTextures(1, &texture);
    glBindTexture (GL_TEXTURE_2D, texture);

    glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

    glTexImage2D (GL_TEXTURE_2D, 0, internal_format, 
            RasterSize.width, RasterSize.height,
            0, raster_pixel_format, GL_UNSIGNED_BYTE,
            raster->GetData());

    glBindTexture(GL_TEXTURE_2D, texture);

    RECT wndRect;
    ::GetClientRect(hWnd, &wndRect);
    GLsizei wndWidth = wndRect.right;
    GLsizei wndHeight = wndRect.bottom;

    glEnable(GL_TEXTURE_2D);

    // this is usually stated in window coordinates,
    // but since we know the raster gets its size from 
    // the window - we can use raster coordinates
    glViewport(0, 0, RasterSize.width, RasterSize.height);

    glBegin( GL_QUADS );    

    glTexCoord2d(0.0,0.0); glVertex2d(-1.0,+1.0);
    glTexCoord2d(1.0,0.0); glVertex2d(+1.0,+1.0);
    glTexCoord2d(1.0,1.0); glVertex2d(+1.0,-1.0);
    glTexCoord2d(0.0,1.0); glVertex2d(-1.0,-1.0);

    glEnd();

    glDisable(GL_TEXTURE_2D);

    glBindTexture(GL_TEXTURE_2D, 0);
    glDeleteTextures(1, &texture);

    SwapBuffers(hDC);
    wglMakeCurrent(NULL, NULL);

    // Release the context handles if they aren't cached
    wglDeleteContext(hRC);
    ReleaseDC(hWnd, hDC);

    return SUCCESS;
}
4

1 に答える 1

4

RDP では、通常、GPU アクセラレーションはありません。MesaGL ソフトウェア ラスタライザーの Windows ビルドを入手し、RDP 接続を使用しているかどうかに応じて、PATH 環境変数を設定して、代替の opengl32.dll を見つけて、優れたソフトウェア レンダラーを使用することをお勧めします。

于 2013-09-20T19:31:55.143 に答える