VBO doesn't draw anything

后端 未结 2 424
情话喂你
情话喂你 2021-01-24 07:48

I am trying to draw a square with VBO in my native blackberry 10 application. My implementation is,

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    g         


        
相关标签:
2条回答
  • 2021-01-24 08:39

    It has transpired in the comments that tileCoordList and tileTextureCoordListare pointers to Square3D structures.

    This means that the sizeof operator will give you the size of a pointer, not the size of the struct.

    You could use e.g.

    glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(*tileCoordList), tileCoordList);
    

    instead.

    0 讨论(0)
  • 2021-01-24 08:47

    You are doing something weird to your buffer. Without knowing what tileCoordList is it's hard to say if you are adding the data correctly.

    In general, regarding both of your concerns here: VBOs store the data for you. It is not only possible, but encouraged to do:

    vbo_1, vbo_2;
    
    vbo1.LoadData(data_1);
    vbo2.LoadData(data_2);
    
    main_loop {
        vbo1.Bind();
        Draw();
        vbo2.Bind();
        Draw();
    }
    

    I have used pseudocode here, but you should get the idea. I don't understand what the SubData call is supposed to do; in general, one simple glBufferData should be enough. Bind call sets the buffer as an active one.

    This line made me cringe - why is VBOId public? Smells like a poorly designed abstraction to me:

    glGenBuffers(1,&decompressTileImage->VBOId);
    

    And oh, please don't use this->. The only thing it does here is worsen readability.

    0 讨论(0)
提交回复
热议问题