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

This topic is 2058 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites

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

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

Edited by Inukai

Thank you.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013598
×