• Paladin of the Pegasos
    Paladin of the Pegasos
    Jupp3
    Posts: 1192 from 2003/2/24
    From: Helsinki, Finland
    Quote:

    eliot wrote:
    It was wrong ordering of glBegin()/glEnd() and glMaterialv().


    According to docs:
    Quote:

    glMaterial can be called between a call to glBegin and the corresponding call to glEnd.

    I think it SHOULD work?

    Quote:


    When I am using VBOs or vertex arrays, I have to redesign data structures a lot.
    At the moment I am facing two problems:

    1. I need access to the complete model for glTranslate etc.

    In this, vertex arrays and vbo's work exactly like immediate mode & display lists, so I can't see what would be the problem? Both use "previous" transformation, and if your code allows it, can have own "local" transformations for any "sub-models".
    Quote:


    2. I have to spilt the model and draw the parts of the models to set the materials and normals.

    Usually (if using lighting), you should definitely use per-vertex normals. Same for colors, if you re-define it per-vertex (which I do extremely rarely)

    If you are after an easy way to enable vertex & normal & texture arrays at once, you could take a look at glInterleavedArrays(), which enables & disables & setups interleaved pointers for specified format.

    f.ex. GL_N3F_V3F expects data to be in format:
    Normal0 (3 floats), Vertex0 (3 floats),
    Normal1 (3 floats), Vertex1 (3 floats) ...

    stride is the space used by single vertex (Normal0 & Vertex0 from above example, can include some padding too)

    Color is whatever was previously set, and so are texture coordinates. If you use format with color, it will be defined per-vertex.

    Interleaving different values in this way is generally faster than having N0, N1, ... Nn, V0, V1, ... Vn

    NOTE: This function doesn't exist in OpenGL ES1! (if that matters to you)

    However, the function isn't really THAT complex, and you can always just write a replacement from scratch, if needed.

    Quote:


    I will thing about it and redesign my data structures.


    Really good idea! Ask away, if you have any problems / questions. I was asking myself the same questions years ago, never looked back after the switch.

    Quote:

    First I will switch to Display Lists and Vertex Arrays, because as far as I know not all amiga systems
    support VBOs at the moment. Am I right?

    I think at least minigl lacks VBO support completely (at least currently).

    However, it's very close to vertex arrays in general, you can quite easily make it build-time / run-time. AFAIK, minigl supports vertex arrays just fine. Might be wrong though. Common sense says it should be easier than immediate mode, if anything.

    Also, with vertex arrays, you gain access to indexed modes. Here, in addition to array defining vertices, you have array defining indexes. Then you just do array, in which you define the order, you want to connect them, making it easy to re-use duplicate vertices.

    In addition to that, you could f.ex. have filled geometry in one index array, and wireframe in another (that skips some indexes & vertex elements).
  • »16.10.16 - 18:05
    Profile Visit Website