Jump to content

  • Log In with Google      Sign In   
  • Create Account

VBO unable to push data


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Plerion   Members   -  Reputation: 367

Like
0Likes
Like

Posted 20 October 2012 - 10:41 AM

Hello everybody

I create a buffer with my buffer class:
[source lang="cpp"] Buffer::Buffer() { ext::glGenBuffers(1, &mBufferID); } Buffer::~Buffer() { ext::glDeleteBuffers(1, &mBufferID); } void Buffer::updateResource(const void* data, uint64 numBytes) { ext::glBindBuffer(GL_ARRAY_BUFFER, mBufferID); ext::glBufferData(GL_ARRAY_BUFFER, numBytes, data, GL_STATIC_DRAW); ext::glBindBuffer(GL_ARRAY_BUFFER, 0); }[/source]

The VertexBuffer class inherits from Buffer and for a test puts some floats to the buffer:
[source lang="cpp"] class VertexBuffer : Buffer { private: std::list<VertexElement> mElements; public: VertexBuffer() { float superAwesomePosition[] = { 0, 0, 0 }; updateResource(superAwesomePosition, sizeof(superAwesomePosition)); } void addElement(const VertexElement& elem); };[/source]

That VertexBuffer is as a test created after OpenGL is initialized.

Well, now i have the following problem:
glBufferData seems to corrupt my state, because the next time i use glFlush or glClear i get an exception from my graphics driver:
Unhandled exception at 0x68DC930D (atioglxx.dll) in OGL.exe: 0xC0000005: Access violation reading location 0xBAADF0ED.

Well, if they use the same convention as the microsoft compiler this means that there is uninitialized memory on the heap used. From "heap" i thought, well, maybe it has to be on the heap and changed superAwesomePosition to be allocated by new and sizeof to 12. Still the same result.

Fun fact: When glBufferData is used with size = 0 and data = nullptr to reset it there is no problem, only when i supply data.

Greetings
Plerion

Sponsor:

#2 Waterlimon   Crossbones+   -  Reputation: 2562

Like
0Likes
Like

Posted 20 October 2012 - 10:53 AM

Could the sizeof be returning the size of the pointer and not the array?

Try making the array static or const...?

Edited by Waterlimon, 20 October 2012 - 10:54 AM.

o3o


#3 Plerion   Members   -  Reputation: 367

Like
0Likes
Like

Posted 20 October 2012 - 03:38 PM

Hey

Thanks for your advise but sadly that was not the problem.

After further investigations i wanted to turn on debug outputs because the default error providing API of OpenGL is completely useless compared to its DirectX counterpart but ive seen that i need to use wglCreateContextAttribsARB to set the debug bit. I did this with the following:
[source lang="cpp"] int attribs[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 4, WGL_CONTEXT_MINOR_VERSION_ARB, 1, WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0 };[/source]

And see there now it works and i have absolutely no clue why... I guess ill just go back to DirectX, that short trip to OpenGL wasnt a good idea :D

Greetings
Plerion

#4 Plerion   Members   -  Reputation: 367

Like
0Likes
Like

Posted 20 October 2012 - 06:23 PM

Just a little update:
Without the wglCreateContextAttribsARB function there is no way to get the code working on my system as far as i could test it. But as soon as i change from my AMD car to NVIDIA on my laptop it works like a charm...




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS