Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 02 Aug 2012
Offline Last Active Jul 17 2014 03:09 PM

Topics I've Started

when to add a VBO to a VAO

29 June 2013 - 09:41 AM

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);
byte[] indices =
	0, 1, 2,
	2, 3, 0
indicesCount = indices.length;
ByteBuffer indicesBuffer = BufferUtils.createByteBuffer(indicesCount);
vaoId = GL30.glGenVertexArrays();
	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);
unaddedVBO = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, unaddedVBO);
	GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_STATIC_DRAW);

Here's the code where they're rendered:

		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);

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?  

Need to change code copied from a tutorial

18 April 2013 - 03:58 PM

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.



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
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). 

Best Way to Share Projects/Code

17 March 2013 - 04:50 PM

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!

How to implement gamestates

13 March 2013 - 02:05 PM

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;


    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;

	//While the suer hasn't quit
	while (quit == false)
		if (!paused)
			GameState(fps, scoreKeeper);
    //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 smile.png

Game Studio A8?

28 January 2013 - 08:16 PM

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.