nicholaschan.net :D

23Jul/090

Vector lists/objects using pointers as elements (C++)

For those who are still struggling with pointers, here's a simple example program that shows how to use vector lists with pointers, how to access each element in the list, and how to erase specific pointers from the list.

#include <stdio.h>
#include <vector>
using namespace std;

void main()
{
	//create our number list using pointers
	//this one is using integer pointers
	vector<int*> numbers;

	//Create our pointers with data
	int *x = new int();
	int *y = new int();
	int *z = new int();
	int *a = new int();
	*x = 11;
	*y = 12;
	*z = 13;
	*a = 14;

	//Push them in order into the vector
	numbers.push_back(x);
	numbers.push_back(y);
	numbers.push_back(z);
	numbers.push_back(a);

	//To navigate through our vector, it needs to take in an iterator
	//think of it as a cursor/position for the vector
	//set at first element (at 0)
	vector<int*>::iterator iterate = numbers.begin();

	//specify a specific position
	int offset = 2;

	//erase the element at beginning + offset
	numbers.erase(iterate+offset);

	//Print the final vector list
	for(; iterate < numbers.end(); iterate++)
		printf("Position: %d Value: %d\n", (int)(iterate - numbers.begin()), **iterate);

	delete x;
	delete y;
	delete z;
	delete a;
}

Much better than using nasty fixed size arrays IMO. Just a note, you can also access the vector lists as if they are arrays as well (e.g. cout << numbers[3]).

Filed under: blog No Comments
23Jul/090

Slow but steady progress.

I was able to get more of a generic form for my visual objects in the scene. Instead of having the main OpenGL loop to call a bunch of Cube arrays to render, I can now stuff all types of visual objects into a single array (will change this to a vector/dynamic list) and have OpenGL to call each element in the array to render. This makes it much easier to handle than having a bunch of arrays to juggle. Though, I'm not sure if this is the way to go, it will be harder to manage if I were to want specific items to handle. I'll change it if it will cause problems later.

I think I got a handle on pointers now. I'll post a sample program in using pointers with Vector lists and how to add/erase elements to it.

Filed under: blog, eyght No Comments
20Jul/090

Tonight Show with Conan O’Brien…

Tonightshow with conan obrienClick to enlarge, there's me in the way back. :O

Filed under: blog No Comments
14Jul/090

Project Eyght progress.

I was in Vegas recently so I haven't done much to the game. I've gotten on-screen target detection working and a projectile system set up sort-of. I plan to move most of the level objects code to a scenemanager class which is what I should have done in the first place. Right now all the level code lies on a "renderLoop" function. It is going to be a problem since the only type of level objects I have in the scene are Cubes. I'm going to need to make a parent class that takes in a more generic object type so I can easily target any type of object I want and return its position coordinates to the projectile class for targeting.

Filed under: eyght No Comments
9Jul/090

gluProject function

So it took me a few hours to figure out why it wasn't returning the correct x/y screen coordinates. It turns out you have to update the matrices (model matrix, projection matrix, and the viewport matrix) after using the gluLookAt function. Just a tip for those who are out there having the same problem as I am.

7Jul/090

Google Chrome OS

http://googleblog.blogspot.com/2009/07/introducing-google-chrome-os.html

Exciting!

5Jul/090

Sticking with gluLookAt

I googled up and found this page which allows for the implementation of the gluLookAt on the iPhone SDK. So I'm going to go ahead and stick with using gluLookAt.

Filed under: eyght No Comments
4Jul/090

BIOS (Bio-Ship) game video.

I finally got the "stereo mix" feature fixed on Vista. I just needed to update my audio drivers and there it was in the sound control panel. Now I was able to record a clip with audio of the video game that my group worked on in CS 499.

For some reason, the GUI/onscreen display isn't showing up correctly on my computer. But it has worked on Michael's laptop (our main programmer).

Filed under: blog No Comments
4Jul/090

GLUT to SDL

I still can't figure out the tearing in the visuals. I'm about to try and force my display driver to turn on VSync and see if that fixes it. While my slow DSL connection is downloading the nVidia display drivers, I was busy translating my code to use SDL instead of GLUT for setting up the window. So far I got the rendering pipeline up, I just need to figure out how to translate the camera. I'm also going to see if SDL can manage my audio content so I won't need to pay FMOD royalties when I release the game.

Filed under: eyght No Comments
1Jul/090

No Progress…

This past few days, I've been stuck with this problem in my game. Whenever I move my mouse over the render window, the framerate becomes inconsistent and kinetic items in my scene "tears" visually. Even when I remove my mouse detection code, it still happens. I printed out every elapsed time frame and it shows that even frames render at around 0.03 seconds and odd frames render at around 0.0016 seconds. I'm not sure if the problem lies in GLUT or what...

Filed under: eyght No Comments

My Sites

Nick’s Tweets

Posts