• Create Account

Some advice on this code (code works but because of the coordinates, does not draw).

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

#1Enerjak  Members

277
Like
0Likes
Like

Posted 27 April 2013 - 11:46 AM

You know the book "Beginning DirectX 11 programming" by Allen Sherrdd and Wendy jones? Well, there's a section about making a quad based on the width and height of the incoming texture now I used something like it for mine:

float halfWidth = mTexture->getWidth() / 2.0f;
float halfHeight = mTexture->getHeight() / 2.0f;

v[0] = new VertexPT();
v[0]->setVertex(-halfWidth, -halfWidth,0);
v[0]->setTexCoord(1.0,0.0);
v[0]->setColor(1,0,0,1);

v[1] = new VertexPT();
v[1]->setVertex(-halfWidth, halfHeight,0);
v[1]->setTexCoord(1.0,1.0);
v[1]->setColor(0,1,0,1);

v[2] = new VertexPT();
v[2]->setVertex(halfWidth, -halfHeight,0);
v[2]->setTexCoord(0.0,1.0);

// second face.
v[3] = new VertexPT();
v[3]->setVertex(halfWidth, -halfHeight,0);
v[3]->setTexCoord(0.0, 1.0);
v[3]->setColor(0,1,1,1);

v[4] = new VertexPT();
v[4]->setVertex(halfWidth,halfHeight,0);
v[4]->setTexCoord(0.0,0.0);
v[4]->setColor(1,0,1,1);

v[5] = new VertexPT();
v[5]->setVertex(-halfWidth, -halfHeight, 0);
v[5]->setTexCoord(1.0,0.0);
v[5]->setColor(1.0,0.0,1.0,1.0);


Maybe the coordinates aren't right? I might need some explanation of how OpenGL's coordinate system set up when gluOrth2D is

gluOrtho2d(-y,x,y,-x)

and gluOrtho2d(0,width, height,0);

#2Inukai  Members

1297
Like
0Likes
Like

Posted 27 April 2013 - 01:56 PM

v[0]->setVertex(-halfWidth, -halfWidth,0);

I guess the second value should be halfHeight and not Width ;)

Edited by Inukai, 27 April 2013 - 01:57 PM.

#3Enerjak  Members

277
Like
0Likes
Like

Posted 27 April 2013 - 08:37 PM

Thank you.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.