Skip to main content
gamedev.net
🔒 Locked

Rendering a grid...

Started by kc_0045 2 replies 1.3k views
Original Post
kc_0045
kc_0045
Hello, im trying to make water for my game. but im having problems trying to figured out a way to render if. all I need to do is render a "grid" of quads 100*100 getting the z out of an array and each x,y is 1 away from the other. GL_QUAD_STRIP would be the best way to render this(i think) but i just cant seem to get my mind around how to use it to do what I want in a for loop. any ideas? :S
NickGravelyn
NickGravelyn
I'm just kinda writing this in here, so don't get too mad if it's not 100% perfect. I'm not sure how to make a single quad strip, so I just render each "row" of quads as a strip. Not as efficient as it could be, but better than drawing each one separately.

int x, y;for(x = 0; x < 100; x++){   glBegin(GL_QUAD_STRIP);   for(y = 0; y < 100; y++)   {      glVertex3f(x, y, z[y * 100 + x]);      glVertex3f(x + 1, y, z[y * 100 + x + 1]);    }   glEnd();}


I'm pretty sure that'll do the trick. If you're using a 2D array, just use z[x][y] and then z[x+1][y] and you'll be all set. Hopefully that works or at least gets you started. :)
kc_0045
kc_0045
Quote:
Original post by NickGravelyn
I'm just kinda writing this in here, so don't get too mad if it's not 100% perfect. I'm not sure how to make a single quad strip, so I just render each "row" of quads as a strip. Not as efficient as it could be, but better than drawing each one separately.

*** Source Snippet Removed ***

I'm pretty sure that'll do the trick. If you're using a 2D array, just use z[x][y] and then z[x+1][y] and you'll be all set. Hopefully that works or at least gets you started. :)


ok thanks alot there was an error in your code ( j needed to be y, just a typo) other then that it works, Thanks alot!
NickGravelyn
NickGravelyn
*scrambles to edit last post*

What are you talking about? ;)

Glad it worked for you.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.