Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: VBO Problems

  1. #11
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    11
    glColorMaterial

  2. #12
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    Yeah, I meant more like the actual values...

    EDIT: BTW, why do you have blending enabled anyway? I can't see wglUseFontOutlines doing that.

  3. #13
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    11
    glColorMaterial

  4. #14
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    Dude, glColorMaterial is a state setting command taking only GL defined compile time constants. It says nothing about actual color values specified for the allowed parameters.

    The reason I want to know is because you call glColor4ubv before calling the font lists.

  5. #15
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    11
    I cannot follow you, I hand a rgba value to the function that holds the base color of the text.
    whats wrong with it??
    I thought a vbo whose vertics color alpha value is 255 can never be transparent, no matter who the lightning or material setup is....wrong???

  6. #16
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    How can I know if you have defined a vertex color array that sets the vertices color values when rendering? I know nothing about your VBO setup, I know nothing about state settings you have done at init time or somewhere else, I know nothing about how you render vertex data and I know nothing about what what color values you pass to glColor4ubv.

    So, tell me, how am I supposed to help you if you won't even supply me with information I'm specifically asking for?

    All I can deduce is that you probably have blending enabled, maybe have not specified a vertex color array and that you don't reset the the state of GL_CURRENT_COLOR to whatever value it's supposed to have after glColor4ubv...

  7. #17
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    11
    My vbos keep koordinates, normals and colors for each Vertex - no textures.
    There is no need to specify any color, if I want a different I modify the color fileds of the vbo vertices.
    The display lists as delivered from wgl... hold only polygon vertics - so the color must be defined external.
    Sorry if my description was incomplete.
    Hope this helps - somehow the execution of the lists changes the opengl state - as I told you before the first frame is ok,
    on the second frame the vbo color is transparent.
    If I only work with vbos everything works perfect.
    Maybe I should define the characters as vbos.

  8. #18
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    somehow the execution of the lists changes the opengl state
    Yes, that's definitely possible. However, they would have to enable GL_BLEND for blending to happen - unless you don't enable it somewhere else yourself. And even if it was enabled, if you have a valid color array used when rendering with correctly setup VBO, color state should be pulled from the VBOs. Please post your VBO and array (gl*Pointer() ) setup code and Draw_VBO().

  9. #19
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    11
    I use 3 function for every primitive - example here ( I cut out the other planes ) VBO_Quad -> creates the data in the machines memory
    Upload_VBO transfers everything to GPU memory
    Draw_VBO displays it

    Code :
    extern  VBO_Struct* VBO_Quad( GLfloat lg_x, GLfloat lg_y, GLfloat lg_z, RGBA_Struct* base_col  )
    {
      VBO_Struct*               vbo;  
      VBO_Index_Buffer_Struct*  ib;
      VBO_Data_Struct*          vdr;  
      int                       c1;
     
      lg_x /= 2.0f;  lg_y /= 2.0f;  lg_z /= 2.0f;
     
      vbo = Create_VBO_Struct();                                   // Erzeuge das VOB_1_Struct 
      Init_VBO_Struct( vbo, 24, 1 );                               // Initialisiere es mit 8 vboertices und 1 Indexbuffer
      vbo->idb_ptr[ 0 ] = Init_VBO_Index_Buffer_Struct( 24 );      // ein Indexbuffer mit 24 Einträgen
     
      vdr = vbo->vb;
     
      /*************************************/
      /*   Vertics Vorderseite <> 0 -- 3   */
      /*************************************/ 
      vdr->vx.x = -lg_x;  vdr->vx.y = -lg_y;  vdr->vx.z =  lg_z;      memcpy( &vdr->v_norm, &_z_plus_norm, vertex_struct_size );      memcpy( &vdr->col, base_col, rgba_struct_size );  vdr++; 
      vdr->vx.x =  lg_x;  vdr->vx.y = -lg_y;  vdr->vx.z =  lg_z;      memcpy( &vdr->v_norm, &_z_plus_norm, vertex_struct_size );      memcpy( &vdr->col, base_col, rgba_struct_size );  vdr++; 
      vdr->vx.x =  lg_x;  vdr->vx.y =  lg_y;  vdr->vx.z =  lg_z;      memcpy( &vdr->v_norm, &_z_plus_norm, vertex_struct_size );      memcpy( &vdr->col, base_col, rgba_struct_size );  vdr++; 
      vdr->vx.x = -lg_x;  vdr->vx.y =  lg_y;  vdr->vx.z =  lg_z;      memcpy( &vdr->v_norm, &_z_plus_norm, vertex_struct_size );      memcpy( &vdr->col, base_col, rgba_struct_size );  vdr++; 
     
     
      ib = vbo->idb_ptr[ 0 ];
      ib->draw_id = 8;                                       // Quads
      for( c1 = 0; c1 < 24; c1++ ) ib->i_ptr[ c1 ] = c1;
     
      return( vbo );
     
    }
     
    extern int32_t  VBO_Upload( VBO_Struct* vbo )
    {
      VBO_Index_Buffer_Struct*  v_idb;
      uint32_t                  c1;
     
       glGenBuffers( 1, &vbo->id );                                                                                   
      glBindBuffer( GL_ARRAY_BUFFER, vbo->id );                                                
      glBufferData( GL_ARRAY_BUFFER, vbo->vb_size, vbo->vb, GL_DYNAMIC_DRAW );                   
     
       for( c1 = 0; c1 < vbo->idb_numb; c1++ )
      {
        v_idb = vbo->idb_ptr[ c1 ];                                                                              
        glGenBuffers( 1, &v_idb->id );                                                          
        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, v_idb->id );                                    
        glBufferData( GL_ELEMENT_ARRAY_BUFFER, v_idb->size, v_idb->i_ptr, GL_STATIC_DRAW );    
      }
      return( 1 );
    }
     
     
    extern void Draw_VBO( VBO_Struct* vbo )
    {
      VBO_Index_Buffer_Struct*  v_ib;
      uint32_t                  c1;
     
      glBindBuffer( GL_ARRAY_BUFFER, vbo->id );               
      glColorPointer ( 4, GL_UNSIGNED_BYTE, vbo->stride, vbo->col_offset    );   // Colorpointer setzen
      glVertexPointer( 3, GL_FLOAT,         vbo->stride, vbo->vertex_offset );   // Vertexpointer setzen
      glNormalPointer(    GL_FLOAT,         vbo->stride, vbo->normal_offset );   // Normalenpointer setzen
     
      for( c1 = 0; c1 < vbo->idb_numb; c1++ )
      {
        v_ib = vbo->idb_ptr[ c1 ];                                            // Pointer auf Indexbuffer
        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, v_ib->id );                 // Indexbuffer aktivieren 
        switch( v_ib->draw_id )
        {
     
        case 2:  // GL_LINE_STRIP
          {
            glDrawElements( GL_LINE_STRIP, v_ib->numb, GL_UNSIGNED_INT, NULL  );  // TRIANGLES zeichnen
            break;
          }
     
        case 4:  // GL_TRIANGLES
          {
            glDrawElements( GL_TRIANGLES, v_ib->numb, GL_UNSIGNED_INT, NULL  );  // TRIANGLES zeichnen
            break;
          }
     
        case 5:  // TRIANGLE_FAN
          {
            glDrawElements( GL_TRIANGLE_FAN, v_ib->numb, GL_UNSIGNED_INT, NULL  );  // TRIANGLE_FAN zeichnen
            break;
          }
     
        case 7:  // POLYGON
          {
            glDrawElements( GL_POLYGON, v_ib->numb, GL_UNSIGNED_INT, NULL  );        // POLYGON zeichnen
            break;
          }
     
        case 8:  // GL_QUADS
          {
            glDrawElements( GL_QUADS, v_ib->numb, GL_UNSIGNED_INT, NULL );          // QUADS zeichnen
            break;
          }
     
        case 9:  // GL_STRIP
          {
            glDrawElements( GL_QUAD_STRIP, v_ib->numb, GL_UNSIGNED_INT, NULL );     // QUADS_STRIP zeichnen
            break;
          }
     
     
        }  // Ende des switch Blocks
     
     
      }
     
      glBindBuffer( GL_ARRAY_BUFFER, 0 );
      glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
     
    }

  10. #20
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    Maybe it's just me, but other than finding your code extremely hard to read, I'm not yet able to see how your complete data is put into the VBO data store. Aside from that, if your data is all in one buffer, I doubt that a single vbo->stride argument will suffice because it looks to me as if you try to interleave your data and thus a single stride parameter cannot be appropriate. Please post the definitions of:

    Code :
    VBO_Struct* vbo;
    VBO_Index_Buffer_Struct* ibM
    VBO_Data_Struct* vdr;

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •