Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

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

4: Adsense

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.


  • You cannot reply to this topic
2 replies to this topic

#1 Enerjak   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);

 

any advice will gladly be accepted.



#2 Inukai   Members   

1322
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.


#3 Enerjak   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.