Jump to content

  • Log In with Google      Sign In   
  • Create Account


Neosettler

Member Since 17 Nov 2011
Offline Last Active Apr 09 2013 10:28 AM

Posts I've Made

In Topic: glPolygonMode GL_LINE and GL_POINT performance drop!

17 March 2013 - 09:04 AM

Thank you for your input guys,

well I have probably the most powerful video card on the market right now, NVidia 690 GTX that can render millions of polygon without any trouble but once in LINE or POINT mode it goes down to 1 FPS... there is clearly something fishy with these features. Even with all the recommendation suggested.


In Topic: glPolygonMode slows down[solved]

15 March 2013 - 08:34 AM

Hello Mars, excuse me to bring this thread from the grave but I'm having a major performance drop while rendering in GL_Line mode. I try to find information on how to disable the user clipping and I couldn't find anything so far... so my question is, how do you disable the user clipping?


In Topic: Delete VBOs at run time?

27 January 2013 - 09:55 AM

Why are you checking the validity of the object and uploading data almost everywhere in the code?

 

The validity check comes from:

 

- In the old days, resizing a window was emptying the video memory. (Not a valid argument anymore)

- I'm using a mixture of SFML and QT and for some reason, it does prevent me from creating buffer at initialization of my API as there is a switch GL context or some funny stuff similar to this. (I will start by investigate this.)

- I have the option of resetting programs at run time. (I'll make re-initialization on reset() instead.)

 

The uploading data is rather tricky, as my approach supports multi-materials, I have 2 different techniques that I would like to debate:

 

- Geometries hold vertex attributes and meshes.

- Meshes hold face ids.

 

For each geometry:

1 - One VBO for the vertex attributes and one VBO for each mesh(i).

2 - One VBO for the vertex attributes and one VBO for all mesh(i) using buffer offset.

 

Surprisingly, number 2 is giving better performance even if it has to call subData every draw.

 

To resume, You are right, I'm in the process of redesign and I'd love some insights.


In Topic: Delete VBOs at run time?

27 January 2013 - 01:01 AM

My apologies, I find pasting code here very painful, I guess I tried cutting corners in my explanation but my code
looks more like this:
 
void OpenGL::SetVertexBuffer(VertexBuffer *in_buffer)

{

    UInt &l_id = in_buffer->GetArrayId();


    if (l_id == 0)

    {

        glGenBuffers(1, &l_id);

    }

    glBindBuffer(GL_ARRAY_BUFFER, l_id);


    if (in_buffer->IsUpdated())

    {

        glBufferData(GL_ARRAY_BUFFER, in_buffer->GetArraySize(), NULL, gl_BufferTypes[in_buffer->GetType()]);

    }

}


template <class T> void OpenGL::SetVertexData(ArrayBuffer<T> &in_array)

{

    if (in_array.IsValid())

    {

        glBufferSubData(GL_ARRAY_BUFFER, in_array.GetOffset(), in_array.GetSize(), in_array.GetData());

    }

}


template <class T> void OpenGL::SetVertexAttribute(ArrayBuffer<T> &in_array)

{

    if (in_array.IsValid())

    {

        e_VertexAttributes &l_index = in_array.GetIndex();

        glVertexAttribPointer(l_index, gl_AttributeSizes[l_index], gl_AttributeTypes[l_index], gl_AttributeNormalized[l_index], gl_AttributeStrides[l_index], (void*) in_array.GetOffset());


        glEnableVertexAttribArray(l_index);

    }

    else

        glDisableVertexAttribArray(in_array.GetIndex());

}


template <class T> void OpenGL::Draw(VertexBuffer *in_buffer, ArrayBuffer<T> &in_indices, UInt in_offset, const e_RenderTypes &in_type)

{

    UInt &l_id = in_buffer->GetElementId();


    if (l_id == 0)

    {

        glGenBuffers(1, &l_id);

    }

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, l_id);


    if (in_buffer->IsUpdated())

    {

        in_buffer->SetUpdated(false);

        glBufferData(GL_ELEMENT_ARRAY_BUFFER, in_indices.GetSize(), in_indices.GetData(), gl_BufferTypes[in_buffer->GetType()]); /// Only if reseted.

    }

    glDrawRangeElements(gl_RenderTypes[in_type], in_offset, in_offset + in_indices.GetSize(), in_indices.GetSize(), GL_UNSIGNED_INT, (void*) in_indices.GetOffset());   

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);



If my understanding is correct, unbinding any subData attached to the buffers was my missing link before deletion at run time.

 

void OpenGL::DeleteVertexBuffer(UInt &in_id)
{
if (in_id != 0)
{
  glBindBuffer(GL_ARRAY_BUFFER, in_id);

  for (UInt i = 0; i < 16; ++i)
  {
   glDisableVertexAttribArray(i);
  }
  glBindBuffer(GL_ARRAY_BUFFER, 0);
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
  glDeleteBuffers(1, &in_id);
  in_id = 0;
}
}


In Topic: Delete VBOs at run time?

26 January 2013 - 06:25 PM

Thank you for your input Bob,  I used this to delete the VBO now:

glBindBuffer(GL_ARRAY_BUFFER, in_id); 
        for (UInt i = 0; i < 16; ++i) 
        { 
            glDisableVertexAttribArray(i); 
        } 
        glBindBuffer(GL_ARRAY_BUFFER, 0); 
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); 
        glDeleteBuffers(1, &in_id);

The crash is gone but I'm still not sure if this is the right way of doing it.

PARTNERS