Sign in to follow this  

height map and loading bmp

This topic is 4068 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

hi, i have readed this article: www.gamedev.net/reference/articles/article1966.asp i think i have not understood one thing: i have a bmp greyscale image 64x64 pixel, i want to display it in opengl using a quad for each pixel for denugging reason, so i write this code: for(iz=0;iz<m_iSize;iz++){ glTranslatef(-2*m_iSize,2.0f,0.0f); for(ix=0;ix<m_iSize;ix++){ glTranslatef(2.0f,0.0f,0.0f); ucColor=getTrueHeightAtPoint(ix,iz); glColor3f(ucColor,ucColor,ucColor); glBegin(GL_QUADS); // Draw A Quad glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd(); } } class CTerrain{ public: Bitmap mappa; .... inline unsigned char getTrueHeightAtPoint( int ix, int iz){ return mappa.data[iz*m_iSize*3+ix*3]; } the image displyed is like expected except a line of different color that is orizontal and at 3/4 of height from the bottom of the image what do you think it could be? thanks [Edited by - sefiroths on October 22, 2006 6:37:06 AM]

Share this post


Link to post
Share on other sites
The image is like expected except.. ?
Are you sure. I only glanced over the code but from what I see the glTranslate calls are independent of ix and iz, hence you should only see one pixel, since you are drawing them all on top of eachother. You have to change those Translate calls.
On a side note, dont draw one quad per pixel. Just use the bitmap as texture and render that on one quad.

Hope I was of help.

-CProgrammer

Share this post


Link to post
Share on other sites
i wanted to do a height map, so i needed to know the color of each pixel to attrib to each pixel an altitude, the image displayed was as i wanted but only one row was not colored,
today i have reopened the project and everything seem work well, the translation don't depends on ix,iz because the display function modify the world matrix time after time without a glLoadIdentity or glPushMatrix:
translate(2,0,0)
glbegin(glquads)
ecc..
glend
translate(2,0,0)
glbegin(glquads)
ecc..
glend

produce 2 quads one near the other, i know it's horrible solution but was only for debug, fast to write :)

Share this post


Link to post
Share on other sites

This topic is 4068 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this