Category: Graphics

Screenshots

Hi, here is a little Yule gift for all you GL junkies out there, it’s a short quick and easy tool for taking a screen shot into the tga format, sure it’s uncompressed and doesn’t increment the file name, but it’s pretty slick.


void screenshot (char filename[160],int x, int y)
{

// get the image data
long imageSize = x * y * 3;
unsigned char *data = new unsigned char[imageSize];
glReadPixels(0,0,x,y, GL_BGR,GL_UNSIGNED_BYTE,data);

// split x and y sizes into bytes
int xa= x % 256;
int xb= (x-xa)/256;

int ya= y % 256;
int yb= (y-ya)/256;

//assemble the header
unsigned char header[18]={0,0,2,0,0,0,0,0,0,0,0,0,(char)xa,(char)xb,(char)ya,(char)yb,24,0};

// write header and data to file
fstream File(filename, ios::out | ios::binary);
File.write (reinterpret_cast(header), sizeof (char)*18);
File.write (reinterpret_cast(data), sizeof (char)*imageSize);
File.close();

delete[] data;
data=NULL;
}

Usage: screenshot (“test.tga”,800,600);
Just call the function with the correct window size just before SwapBuffers and it will take a screen shot of everything in the frame buffer, easy.

Uncharted 2

I recently picked up a copy of Uncharted 2: among thieves, specifically one of those limited edition metal ones that is so popular these days. I really wanted to see if it was as good as promised, and with a meta score of 96 it better be.
But let get back to the beginning, two years ago the developer Naughty Dog released Uncharted: Drakes fortune, one of the greater games of -07, especially for the Playstation 3 which had almost no games available at that time and this was an exclusive. Read more »

Natalled

Earlier this year both Microsoft and Sony presented what they called the “Future of gaming” class of controllers, but whats really going on here.
To answer that we have to look at their technologies and then derive intent from that.
It’s two seemingly very different control schemes, but are they, one uses a time-of-flight (TOF) camera to sense it’s surroundings and most notably the depth of it, the other one uses a high res camera to sense it’s surroundings that while it can’t measure depth it can track certain objects on the z axis reasonably well, however it is augmented by a glowing ping pong ball on a stick for “sub pixel 3d tracking”, it also has buttons which are useful at times.
Both systems also have an array of microphones which makes it easier to track and filter out voices. Read more »

Running OpenGL3.0 – part3

In our third installment we are looking into replacing all the matrix math previously built into openGL, what I am going to show you replaces most of it almost exactly like openGL used to work, naturally if your doing something a bit more advanced like a game or so, I would suggest that you use your scene graph to generate new matrices.

It’s really quite simple though, and as with the previous part we have to do some changes a bit here and there, so I am going to start with the most generalized bit and work my way down, and finally end up with the classic rotating cube.
But first the prerequisites, I am assuming that you started where part 2 left off, we will also need the following functions made to work
glGetUniformLocation
glUniformMatrix4fv

Step 1 – the shader
it’s really not that much but after

in vec3 Normal;

add

uniform mat4 projMat;

this will be where we send our new matrix to.
Then later in the code you need to do something like this to use our matrix

gl_Position=projMat*pos;

You could use and I almost recommend that you use two matrices one for the camera and one for the model transformation, but I leave that task to you.
Please note that the order of the multiplication is important. Read more »

Running OpenGL3.0 – part2

In this part I will show you what you must do to render even the smallest speck of graphical garbage on the screen in the openGL 3.0 API, it’s somewhat simple once you have all the tools.
First you need a good GLSL shader implementation because nothing will render without it, you can use mine if you want but just remember that we are gonna modify it a bit so it can’t be to abstracted.
Next you need to take a look at the VAO tutorial since well be using that too, naturally since we are using VAO well also be using VBO and in this example I have 3 buffers with the vertex, texture and normal coordinates for a cube, you could use anything, but I am using a cube.
We are also going to use 4 new functions so go ahead am make them work as well.
glVertexAttribPointer
glBindAttribLocation
glDisableVertexAttribArray
glEnableVertexAttribArray
Finally remove anything that has to do with matrices, well discuss those in part 3, in fact remove or comment out any deprecated function (you can find them in part 1).

Now then, there are about four steps to this, that is there are 4 things you need to change in your already existing code for things to work, so I will explain them in order. Read more »

WordPress Themes