• An ever shorter loop is shown for Task 1 when the level is increased
    Likely problem: read the definition of glDrawElements carefully.
    You need a list of Indices that goes from 0 to maxIndex(level) !
    If you use drawArray, no larger Indices list is needed, and you specify maxIndex(level)
  • look at glPointSize https://registry.khronos.org/OpenGL-Refpages/gl4/html/glPointSize.xhtml
  • Q: In Task2, where we have to subdivide to refine the control points, how should we compute points P0 and P1 for the next iterations? Substituting i=0 in the given formulas requires points P-1 which doesn't exist.
    A: This is a closed curve so modulo N*2^k, where N = 10 and k = number of subdivision steps.
  • Q: When i+1 is greater than N I’m assuming you just ignore the control point components that fall outside the bounds?
    A: no! this is a closed loop. Look at your (analog) clock and see what happens when you increment beyond 12 or decrement below 1 (of course in C++ you have a 0)

  • You may want to update 1b vs Project 1a:
    void createVAOs(Vertex Vertices[], unsigned short Indices[], size_t BufferSize, size_t IdxBufferSize, int ObjectId) {
          NumVert[ObjectId] = IdxBufferSize / (sizeof GLubyte);

  • If you have not yet, add the Bindbuffer in
    glUseProgram(pickingProgramID);
    {
    :
    glBindVertexArray(VertexArrayId[0]);
    glBindBuffer(GL_ARRAY_BUFFER, VertexBufferId[0]);
    :
    }
  • glBufferSubData is different from glBufferData
  • glBufferSubData(GL_ARRAY_BUFFER, 0, last+1, ...
    should be
    glBufferSubData(GL_ARRAY_BUFFER, 0, (last+1)*sizeof(T1V[0][0]),...
    Note https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBufferSubData.xhtml
    size = BYTES of the data store region

  • You may want to have a variable sz = N*pow(2,k) entries
  • glDrawElements:     NumVert[0] is the wrong number of elements. You probably want "sz"

  • V1[5][320], how do I initialize it?
        #define MAXSIZE 320
        #define MAXLEVEL 5
        Vertex V1[MAXLEVEL+1][MAXSIZE];
        for (ii=0; ii < MAXSIZE; i++) copy Vertices to V1[0][ii]
        (a Vertex is a struct and you need to copy its elements XYZW[jj], and initialize RGBA[jj])

  • The sizeof() function is useful to return an integer that is the proper number of items

  • Q: when I call createVAOs(...,1) for a second buffer to draw lines I get a black screen
    A: you forgot to increase numObjects

  • Q: I’m considering making 6 different indices arrays and calling createVAOs() with them, but that feels like a lot of hard coding.
    You can use one index array initialized once in init and N*pow(2,k) entries

  • Q: When subdividing points, the new subdivided points past 2 refinements (k) would break the figure-8 arrangement and form a circle. What would cause that and what would a correct algorithm generate?
    A: (We actually subdivide the B-spline functions associated with the B-spline control points)
    If you correctly use the given formulas, you should just observe a fill-in: twice as many points on a figure 8 each time you run the algorithm.
  • How would I compute the tangent of a line through two points? I attempted to do this in my program for part 3 and got absolute nonsense curves with points being out of order.
    A: The instruction is to form the difference vector between the predecessor point and the successor point and attach this vector (scaled) at the point for use as tangent. Maybe you walk into the wrong direction along the tangent and so get lots of loops?