Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 10 Apr 2005
Offline Last Active Oct 03 2015 11:44 PM

Posts I've Made

In Topic: Question on OpenGL

18 May 2015 - 11:21 PM

How does glVertexAttribPointer know where the buffer object is located?

In this case, you first tell the OpenGL what buffer (=memory) you want to activate (called binding):
glBindBuffer(GL_ARRAY_BUFFER, buffer);
When you call the vertex pointer assignment, the last parameter is set to 0 (nullptr), this tells OpenGL to use the currently active (bound) buffer:
 glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, nullptr);

Just to expand on that, this is why OpenGL is often described as a big global state machine, and it is one of the reasons many people think it is due for an overhaul. My understanding is that in the upcoming Vulkan, the first parameter to all entry points represents the state that is going to be changed with the function call.

In Topic: "defer": is this silly / broken?

09 December 2014 - 04:55 PM

I don't get people's problems in this thread. rolleyes.gif

All that needs to be said is that you reinvented scope exit. It has been proposed by Andrei Alexandrescu and it has made it into Facebooks folly library, so clearly some people find it valuable. There is nothing wrong with reinvention - and I think you're in good company with Andrei. Of course, as you can see in folly's implementation, a production quality version is a bit more involved, so ultimately it would be better to use that rather than roll your own.


In Topic: Critique my approach to writing RAII wrappers

08 September 2014 - 09:14 PM

So this thread went from "How is my RAII" to "What the hell is RAII". Interesting comments.

Yes, I contemplated whether I should step in, but I figured I will just let the discussion go. I don't really see the point of trying to (re-)define what RAII is. As SmkViper pointed out, the man who invented it has written extensively about it. Sure, there are nuances and different interpretations, but what I am interested in is a workable solution for wrapping C libraries like SDL, OpenGL, etc.

In Topic: Critique my approach to writing RAII wrappers

04 September 2014 - 07:09 PM

Initializtion does not mean resource allocation.  Initialization means a minimal empty valid state.

First, I wanted to highlight that I intentionally did not implement RAII in the Texture class. It is merely wraps a plain handle and adds convenience wrappers. I might as well have called it TextureHandle or something like that. The RAII comes into play when you use this class in conjunction with Unique, which puts the object into a valid initialised state on construction. To sum it up: int* is not RAII, but std::unique_ptr<int> is RAII. Similarly, Texture is not RAII, but Unique<Texture> is RAII.

Edit: Upon re-reading your post, I may have misinterpreted it the first time. Are you suggesting that it should be possible to create a Unique<Texture> without creating an OpenGL texture object? I must say I tend to agree. I suppose creating it in an empty state and having a makeUnique method which calls Texture::New similar to those in the standard library would be preferable.

In Topic: BMX Ride - Upcoming bmx game for the PC

20 July 2014 - 10:56 PM

That looks pretty sweet on the Rift. Level based on Danny MacAskill's Imaginate? Good work!