Advertisement
ANevsky

GraphFacetRender.cpp

Feb 12th, 2024 (edited)
984
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1.             _coo_gl_arpointer* tri = triangles_pointer;
  2.             _coo_gl_arpointer* norm = normals_pointer;
  3.             float* vert = new float[tri_count * 3 * 6];
  4.  
  5.  
  6.             for (unsigned i = 0; i < tri_count; ++i)
  7.             {
  8.                 unsigned ipos = i * 9;
  9.                 std::copy(norm + ipos, norm + ipos + 3, vert + ipos * 2);
  10.                 std::copy(tri + ipos, tri + ipos + 3, vert + ipos * 2 + 3);
  11.  
  12.                 std::copy(norm + ipos + 3, norm + ipos + 6, vert + ipos * 2 + 6);
  13.                 std::copy(tri + ipos + 3, tri + ipos + 6, vert + ipos * 2 + 9);
  14.  
  15.                 std::copy(norm + ipos + 6, norm + ipos + 9, vert + ipos * 2 + 12);
  16.                 std::copy(tri + ipos + 6, tri + ipos + 9, vert + ipos * 2 + 15);
  17.             }
  18.  
  19.  
  20.             int facesCount, stride, * sharpInd;
  21.             std::vector<float> points;
  22.             StlRend srend;
  23.             srend.create(tri_count, vert);
  24.             srend.getMesh(90, facesCount, stride, points, sharpInd);
  25.             glEnableClientState(GL_VERTEX_ARRAY);
  26.             glEnableClientState(GL_NORMAL_ARRAY);
  27.             glDisableClientState(GL_COLOR_ARRAY);
  28.             glVertexPointer(3, GL_FLOAT, stride * sizeof(points[0]), points.data() + 3);
  29.             glNormalPointer(GL_FLOAT, stride * sizeof(points[0]), points.data());
  30.  
  31.             glDrawArrays(GL_TRIANGLES, 0, facesCount * 3);
Advertisement
Comments
  • Vvardenfell
    165 days (edited)
    # text 0.54 KB | 0 0
    1. the opengl functions that you use have been deprecated for nearly 15 years. the fixed function pipeline should only be used by legacy code. if you write new code, you should consider switching to modern opengl, that is opengl 3.1 or above. you can find a really good introduction to modern opengl on learnopengl.com for example. glenableclientstate, gldisableclientstate, glvertexpointer and glnormalpointer are all part of the fixed function pipeline and shouldn't be used nowadays. in case that what you pasted is indeed legacy code, excuse my comment
Add Comment
Please, Sign In to add comment
Advertisement