1. Post #281
    MoustacheSpy's Avatar
    August 2015
    183 Posts
    My opengl application works like this: The entire thing is in a class, where all variables are defined as private members and are then initialized in the constructor and updated in the update member function.

    I am currently working on a shader class. I need to make it so the following process works out fine:

    1. construct with constructor without parameters (init with 0)
    2. In the apps constructor make a temporary object that uses the 2nd shader constructor to load the shader files
    3. using a overloadet operator= or a copy-constructor, copy everything from the temporary object to the member variable.
    4. destruct temporary object.

    I have the destructor done (just a simple glUseProgram(0) and glDeleteProgram)
    I have all the constructors done (except copy constructor)
    My question now is: How can I correctly copy a shader program so that I can safely delete the old one.

  2. Post #282
    Gold Member
    Karmah's Avatar
    December 2007
    6,600 Posts
    I don't recall there being a shader copying function, but if you still have the ID's for the fragment and vertex shaders then you can use them to generate another functionally equivalent shader program - though it won't have any of the uniforms set from the previous one.

  3. Post #283
    Gold Member
    cartman300's Avatar
    April 2011
    3,175 Posts
    If you use newer OpenGL, you can use glProgramBinary and glGetProgramBinary to basically copy one shader into another.
    Reply With Quote Edit / Delete Reply Windows 10 Firefox Croatia Show Events Useful Useful x 1 (list)

  4. Post #284
    Gold Member
    Karmah's Avatar
    December 2007
    6,600 Posts
    I'm looking to support faces for my brush-based geometry that have more than 3 points.
    I've discovered the Delaunay triangulation algorithm, however it seems to generate points in 2D.

    This doesn't sound like it should be a problem, since triangles can define a 2D plane between the 3D points; however I'm having a brain fart and can't think of an ideal solution to transforming the input points to 2D (in a way that I can convert them back into 3D after).

    The only way I can think of to use this algorithm would be to transform my point list by the inverse of a TBN matrix, generate the modified triangles for the face in tangent space, and then transform the resulting points back.
    However, I would like a solution that doesn't require using tangent space, lest I ever want to triangulate faces that aren't UV wrapped...

  5. Post #285
    Gold Member

    November 2012
    1,718 Posts
    Reply With Quote Edit / Delete Reply Mac Safari United States Show Events Dumb Dumb x 1 (list)

  6. Post #286
    Ask me about
    the stick
    up my ass
    Alice3173's Avatar
    April 2010
    11,316 Posts
    I'd try starting with something only two levels deep and adding a whole lot of logging to try and narrow it down.
    That's a really stupid oversight on my end actually. I should've thought of doing this long before, lol. I'll give that a try later when I get some time.