Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

{ OpenGL ] Bufor ramki

Ostatnio zmodyfikowano 2016-02-25 10:31
Autor Wiadomość
squeak
Temat założony przez niniejszego użytkownika
{ OpenGL ] Bufor ramki
» 2016-02-25 10:31:24
Witam !
Utworzyłem bufor ramki i mam problem ze zmianą danych.
Czyszczenie działa, natomiast nie mogę namalować trójkąta z jedną składową ( 32-u bitową zmienną składowej czerwonej ).
Co robię źle ?

Poniżej podaję fragment kodu:

void Create() {
  RECT rc;
  GetClientRect(h3dView, &rc);

  int width  = (rc.bottom-rc.top);
  int height = (rc.right-rc.left);

  if ( width == 0 || height == 0 ) return;

  static bool created = false;

  if ( created ) return;

  created = true;

    glClearColor( 1.0f, 1.0f, 1.0f, 1.0f );

    glGenTextures( RENDER_TEXTURE_SIZE, renderTexture );

    glBindTexture( GL_TEXTURE_2D, renderTexture[COLOR0] );
    glTexImage2D( GL_TEXTURE_2D, 0, GL_R32UI, FRAME_WIDTH, FRAME_HEIGHT, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, NULL );
    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

    glGenFramebuffers( 1, &frameBuffer );
    glBindFramebuffer( GL_DRAW_FRAMEBUFFER, frameBuffer );
    glFramebufferTexture( GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, renderTexture[COLOR0], 0 );

    GLenum error = glCheckFramebufferStatus( GL_DRAW_FRAMEBUFFER );
    if( error != GL_FRAMEBUFFER_COMPLETE ) {
        MessageBoxA( hWnd, "Niepoprawny obiekt bufora renderingu", "", 0 );
        PostQuitMessage( 0 );
    }
    return ;
}

void Display( int width, int height ) {
    char string[100];

    glBindFramebuffer( GL_READ_FRAMEBUFFER, frameBuffer );

    GLenum bufs[1] = { GL_COLOR_ATTACHMENT0 };
    glDrawBuffers( 1, bufs );

    glViewport( 0, 0, FRAME_WIDTH, FRAME_HEIGHT );

    glClear( GL_DEPTH_BUFFER_BIT );

    GLint color2[4] = { 11111, 0, 0, 0 };

    glClearBufferiv( GL_COLOR, 0, color2 );

    glDrawBuffers( 1, &bufs[0] );

    glViewport( 0, 0, width, height );

    glMatrixMode( GL_PROJECTION );
   
    glLoadIdentity();
   
    gluOrtho2D( 0, 1, 0, 1 );

    glMatrixMode( GL_MODELVIEW );
   
    glLoadIdentity();
   
    if( dithering == GL_TRUE ) glEnable( GL_DITHER );
   
    glShadeModel( shadinmodel );

    glBegin( GL_TRIANGLES );
   
        glColor3ui( 255, 0, 0xFFFFFFFF );
        //glIndexi( 255 );
        glVertex2f( 0.0, 0.0 );
   
        glColor3ui( 200, 0, 0xFFFFFFFF );
        //glIndexi( 200 );
        glVertex2f( 0.0, 1.0 );
   
        glColor3ui( 100, 0, 0xFFFFFFFF );
        //glIndexi( 100 );
        glVertex2f( 1.0, 1.0 );

    glEnd();

    glDisable( GL_DITHER );

    glReadBuffer( GL_COLOR_ATTACHMENT0 );

    glReadPixels( Point.x, Point.y, 1, 1, GL_RED_INTEGER, GL_UNSIGNED_INT, &Index );

    SwapBuffers( hDC );
}
P-145280
« 1 »
  Strona 1 z 1