# shaqb4

Member

19

469 Neutral

• Rank
Member
1. ## OpenGL when to add a VBO to a VAO

Thanks a lot for the explanations. This entire discussion made was very clear and easy to understand. :)
2. ## OpenGL when to add a VBO to a VAO

I think I understand. So the call to VertexAttribPointer only affects the currently bound ARRAY_BUFFER VBO and no other type?
3. ## OpenGL when to add a VBO to a VAO

That makes so much more sense, thank you! :)   Just to make sure I understand what's happening, though.   First, you create the 2 VBOs. Then You create the VAO. By binding the VBOs while the VAO is bound, they are added to the VAO. The Attrib calls allow the vertices to be used for rendering. Is that correct or close?
4. ## OpenGL when to add a VBO to a VAO

I just started learning OpenGL and decided to use the LWJGL in java to begin. I'm following the tutorials on their wiki, but I'm confused about something in the DrawElements tutorial.   In the tutorial, they create a VBO containing the vertices (four corners) of a rectangle and add it to a VAO. Then they create a VBO that contains the order the vertices are to be drawn, but this one isn't added to the VAO.     Here's the code where they're created: float[] vertices = { -0.5f, 0.5f, 0.0f, -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f, 0.5f, 0.5f, 0.0f }; vertexCount = vertices.length; FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertexCount); verticesBuffer.put(vertices); verticesBuffer.flip(); byte[] indices = { 0, 1, 2, 2, 3, 0 }; indicesCount = indices.length; ByteBuffer indicesBuffer = BufferUtils.createByteBuffer(indicesCount); indicesBuffer.put(indices); indicesBuffer.flip(); vaoId = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vaoId); addedVBO = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, addedVBO); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0); //Vbo is added to Vao GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); GL30.glBindVertexArray(0); unaddedVBO = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, unaddedVBO); GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_STATIC_DRAW); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);     Here's the code where they're rendered: GL30.glBindVertexArray(vaoId); GL20.glEnableVertexAttribArray(0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, unaddedVBO); GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount, GL11.GL_UNSIGNED_BYTE, 0); GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0); GL20.glDisableVertexAttribArray(0); GL30.glBindVertexArray(0);   Is there a reason one VBO is added to the VAO and one isn't? Would it make a difference if it was added?Also, it occurs to me as I write this that maybe adding one to the VAO allows you to use both VBOs at the same time during rendering?
5. ## Need to change code copied from a tutorial

Thanks for the replies, everybody. :)   I'd like to put it on github because one.) I figure being able to use github would be a useful skill and 2.) It would make it easier to get feedback on my code.   Also, my next game will probably need a timer also, so I might as well change the code now. The problem I'm having is that I don't know what I could change. I could get rid of some  member functions, change names, etc. I looked up other implementations for a Timer class, but they were mostly just slight variations of the one I have now. Any suggestions? (I'm not trying to ask you to change the code for me, I just want ideas for what I could change).
6. ## Need to change code copied from a tutorial

A few weeks ago, I finished  a pong clone with SDL and planned on putting it up on github. Some of my code is taken directly from the Lazyfoo tutorials found at http://lazyfoo.net/SDL_tutorials/index.php.   Specifically, I used the Timer class taught on the following page, as well as the apply_surface functions found in the first few starting tutorials. http://lazyfoo.net/SDL_tutorials/lesson13/index.php   In his FAQ he states    Q: Can I use your code to make a game? "Q: Can I use your code to make a game?   A: Basically my rules are: 1) If you're using it for a closed source program, go nuts. 2) If you're using it for an open source program, please cite the chunks of code you used with something like:   /*This piece of code was originally from Lazy Foo' Productions (http://lazyfoo.net/)*/   3) I you're using it for a GPL, LGPL or other such program which gives public rights to the code, I'm going to have to say no. 4) If you're using it for a tutorial, you're going to have to use your own original code."     You still need contact me and show me specifically the code you plan to use and what you're going to do with it so I can approve."         I contacted him, but after a few weeks there hasn't been a reply. So my question is what should I do now? As far as I can tell, my options are to either wait for a response or change the code. I can't think what I could change in the Timer class, though. It's pretty straight forward, with start, stop, pause etc. I assume just changing the variable names wouldn't count as making it my own?   Any recommendations for how I could make the code my own would be appreciated. (such as other ways to implement a Timer).
7. ## Best Way to Share Projects/Code

Thanks, that was a great answer. It cleared it up perfectly.
8. ## Best Way to Share Projects/Code

Thanks, I think I'm gonna go with github for now. This is a little off topic, but how do you actually build or compile a project that's on github. Do you just open up he project in an IDE and build it? For example, i saw that torque3d was on there, so if I wanted to turn that repository/source into a usable product/executable, is that how I'd do it (I know that most of these projects have places to download binaries and such, but I'm just curious)?   Sorry if this is a stupid question.
9. ## Best Way to Share Projects/Code

I finally finished my first game, a pong clone, and would like to share it and get some feedback. I'm not sure what the best way is to do that though. Should I use github or a similar service, make my own website/portfolio or are there other alternatives I could use? I can't wait to see what people think and thanks for the answers in advance!
10. ## How to implement gamestates

Thanks, all the answers are great! I don't think I'll need the more complicated state machines for a while, but it's nice to at least have an idea of how people do it. I can see from the responses that there're a lot of ways to implement game states. Are there reasons to use one way over another in specific situations, or is it more just a matter of preference?
11. ## How to implement gamestates

I'm making a pong game with c++ that currently has two states, GameState and MenuState. The way it is now, both states are methods of the Game class. The Game class has all the instance data that both methods/states use (so paddles, ball, menu buttons, etc). Is it bad practice to make a gamestate a method rather than its own class?   This is how my main function is right now   #include "Game.h" int main( int argc, char* args[] ) { Game game; game.Run(); return 0; }   And the Run function   int Game::Run() { if (error) { return 1; } //The frame rate regulator, passed to GameState Basic_SDL::Timer fps; //Which player scored (left or right), passed to GameState int scoreKeeper = 0; rightPaddle.setAI(true); //While the suer hasn't quit while (quit == false) { if (!paused) { GameState(fps, scoreKeeper); } else { MenuState(); } } //Clean up clean_up(); } It works fine this way, I'm just not sure if making each state a method is looked down upon. Any other advice on how to implement game states would be appreciated also .
12. ## Unity Game Studio A8?

Should I post this in a different place?
13. ## Unity Game Studio A8?

I was recently given the 3D Game Studio A8 game engine as a gift. I was just wondering how it compares to other engines such as Torque 3d, unity, udk and other well known engines. Is it good? Strengths and weaknesses? I'd just like to get an idea of whether it's considered to be a good engine or not.
14. ## Trouble with copy constructor

Thanks rip-off, it works great.
15. ## Trouble with copy constructor

Thanks, I finally got it to work with the following modified constructor. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] [CODE] Lobby::Lobby(const Lobby& l) { if (l.m_pHead != 0) { m_pHead = new Player; *m_pHead = *l.m_pHead; Player* pIter = m_pHead; Player* pHeap; while (pIter->GetNext() != 0) { pHeap = new Player; *pHeap = *pIter->GetNext(); pIter->SetNext(pHeap); pIter = pIter->GetNext(); } } else { m_pHead = 0; } } [/CODE] Your explanations helped a lot.