Jump to content

  • Log In with Google      Sign In   
  • Create Account

Yasaswi Srikanth

Member Since 28 Feb 2012
Offline Last Active Jun 09 2012 07:44 PM

Posts I've Made

In Topic: OpenGL game development - chris sheddon

08 June 2012 - 11:21 PM

The link wordware.com/files/openglgd is redirecting to http://www.jblearning.com/ .

But the book OpenGL game development is not present in their entire list .
can anyone give the link in the web where the source is available.

In Topic: Bloxorz game in OpenGL.

08 June 2012 - 01:58 AM

hello ,

Thanks dpadam450 for the answer.
I have some how managed to draw the floor and a block on it. by taking two functions like this :

drawFloor present in Floor class outside main :

void Floor::drawFloor()
{



glRotatef(45.5f,1.0f,1.0f,0.0f);

//Draw floor
for(int i = 1;i<6;i++)
{


for(int j = 1;j<6;j++)
{

//For hole to appear at 3,3
if(i == 3 && j==3)
{
glTranslatef(1.0f,0.0f,0.0f);
continue;
}


glBegin(GL_QUADS);

// Top Face
glColor3f(1.0f,0.0f,0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.500f,0.500f,-0.500f); //top left
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.500f,0.500f,0.500f); //bottom left
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.500f,0.50f,0.50f); //bottom right
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,0.50f,-0.50f);//top right

//Left Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f, 0.50f, -0.50f); //Top front
glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f, 0.30f, -0.50f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f, 0.30f, 0.50f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f, 0.50f, 0.50f);

// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(0.50f,0.50f, 0.50f); //top right
glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,0.50f); // top left
glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,0.30f, 0.50f); //bottom left
glTexCoord2f(0.0f, 1.0f); glVertex3f(0.50f,0.30f, 0.50f); //bottom right


// Bottom Face
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,0.30f,0.50f); // top right
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f,0.30f,0.50f); // top left
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f,0.30f,-0.50f); // bottom left
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f,0.30f, -0.50f); //bottom right



// Back Face
glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,-0.50f); // top left
glTexCoord2f(1.0f, 1.0f); glVertex3f(0.50f, 0.50f,-0.50f); //top right
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, 0.30f,-0.50f); //bottom right
glTexCoord2f(0.0f, 0.0f); glVertex3f( -0.50f,0.30f, -0.50f);//bottom left




// Right face

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f, 0.50f, -0.50f); // Top right
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f, 0.50f, 0.50f); // top left
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, 0.30f, 0.50f); //bottom right
glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.50f, 0.30f, -0.50f); //bottom left



glEnd();

glTranslatef(1.0f,0.0f,0.0f);


}
glTranslatef(-5.0f,0.0f,-1.0f);

}

drawCube present in Cube class :

void Cube::drawCube()
{


glBegin(GL_QUADS);

// Top Face
glColor3f(0.0f,1.0f,0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.500f,0.500f,-0.500f); //top left
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.500f,0.500f,0.500f); //bottom left
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.500f,0.50f,0.50f); //bottom right
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,0.50f,-0.50f);//top right


//Left Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f, 0.50f, -0.50f); //Top right
glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,-0.5f, -0.50f); //top left
glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f, 0.50f, 0.50f); //bottom right

// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(0.50f,0.50f, 0.50f); //top right
glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,0.50f); // top left
glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left
glTexCoord2f(0.0f, 1.0f); glVertex3f(0.50f,-0.5f, 0.5f); //bottom right


// Bottom Face
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,-0.50f,0.50f); // top right
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f,-0.50f,0.50f); // top left
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f,-0.50f,-0.50f); // bottom left
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f,-0.50f, -0.50f); //bottom right



// Back Face
glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,-0.50f); // top left
glTexCoord2f(1.0f, 1.0f); glVertex3f(0.50f, 0.50f,-0.50f); //top right
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f,-0.50f,-0.50f); //bottom right
glTexCoord2f(0.0f, 0.0f); glVertex3f( -0.50f,-0.50f, -0.50f);//bottom left




// Right face

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f, 0.50f, -0.50f); // Top left
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f, 0.50f, 0.50f); // bottom left
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, -0.50f, 0.50f); //bottom right
glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.50f, -0.5f, -0.50f); //top right



glEnd();


}


I have placed the hole at 3,3 position look on drawing floor.
My main problem is moving the block left and right . For that I have taken a structure called

typedef struct
{
public:

float x_pos;
float y_pos;
float z_pos;
float radian;
}cube_param;

I created an object like cube_param cube_pos;
while left key is pressed :

case WM_KEYDOWN: // Is A Key Being Held Down?
{
keys[wParam] = TRUE; // If So, Mark It As TRUE

switch(wParam)
{
case VK_LEFT:
{

cube_pos.x_pos = - 1.0f ;
cube_pos.y_pos = -1.0f;
cube_pos.z_pos = 0.0f;
cube_pos.radian = -90.0f;

cube->drawCube(cube_pos);



}
}

return 0;



}

where drawCube(cube_pos); contains the same code as drawCube() but it has to move it.
Here does the structure cube_pos goes away with values to drawCube(cube_param cube_pos)

Look at it :

// For movement of cube
void Cube::drawCube(cube_param cube_pos)
{



float x_pos = cube_pos.x_pos;
float y_pos = cube_pos.y_pos;
float z_pos = cube_pos.z_pos;
float radian = cube_pos.radian;


//glTranslatef(1.0f,1.0f,0.0f);


glRotatef(radian,x_pos,0.0f,0.0f);


glBegin(GL_QUADS);

// Top Face
glColor3f(0.0f,1.0f,0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.5f + x_pos,0.5f + y_pos,-0.5f); //top left
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.5f + x_pos,0.5f + y_pos,0.5f); //bottom left
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.5f + x_pos,0.5f + y_pos,0.5f); //bottom right
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.5f + x_pos,0.5f + y_pos,-0.5f);//top right


//Left Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f, 0.50f, -0.50f); //Top right
glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,-0.5f, -0.50f); //top left
glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f, 0.50f, 0.50f); //bottom right

// Front Face
glTexCoord2f(0.0f, 0.0f); glVertex3f(0.50f,0.50f, 0.50f); //top right
glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,0.50f); // top left
glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.50f,-0.5f, 0.50f); //bottom left
glTexCoord2f(0.0f, 1.0f); glVertex3f(0.50f,-0.5f, 0.5f); //bottom right


// Bottom Face
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f,-0.50f,0.50f); // top right
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.50f,-0.50f,0.50f); // top left
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.50f,-0.50f,-0.50f); // bottom left
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f,-0.50f, -0.50f); //bottom right



// Back Face
glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.50f,0.50f,-0.50f); // top left
glTexCoord2f(1.0f, 1.0f); glVertex3f(0.50f, 0.50f,-0.50f); //top right
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f,-0.50f,-0.50f); //bottom right
glTexCoord2f(0.0f, 0.0f); glVertex3f( -0.50f,-0.50f, -0.50f);//bottom left




// Right face

glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.50f, 0.50f, -0.50f); // Top left
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.50f, 0.50f, 0.50f); // bottom left
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.50f, -0.50f, 0.50f); //bottom right
glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.50f, -0.5f, -0.50f); //top right



glEnd();




}


My idea is when left key is pressed i want to translate each and every vertex by adding or subtracting the x_pos,y_pos,z_pos present in cube_param structure
and then translate and rotate it. will it ultimately work for each and every move ?
If so how to do it.

In Topic: Bloxorz game in OpenGL.

07 June 2012 - 01:04 AM

Hi , I want to design the floor of the bloxorz game in photoshop. is it a good idea to design the entire floor as one bmp file and load it ? If so I don't know how to create this floor in photoshop. can anyone please guide me?

In Topic: Bloxorz game in OpenGL.

31 May 2012 - 10:11 PM

The http://nehe.gamedev.net/ . Yes I have seen them.
Do you mean the Legacy Tutorials?
I think these are very old like in 2000 . Will it be still useful for beginners in OpenGL to follow them?

PARTNERS