Jump to content
  • Advertisement
Sign in to follow this  
Enerjak

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

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

If you intended to correct an error in the post then please contact us.

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

 

any advice will gladly be accepted.

Share this post


Link to post
Share on other sites
Advertisement

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

 

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

Edited by Inukai

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!