0
\$\begingroup\$

I am currently trying to create a terrain generation system (for my 3D game) with OpenGL 2.1.

The way I am doing it requires the creation of a massive 2D square that consists of multiple smaller squares. After the flat square is generated, the points are randomly offset in the y axis, making it into a 3D structure.

But I can't seem to figure out how to generate this using GL_QUAD_STRIP. Can someone please help me figure this out?

Thanks!

P.s. I know my method may not be the best, but I would like to get it to work anyway as it suits my game

\$\endgroup\$
  • \$\begingroup\$ Can I ask why do you need quad strips? They're deprecated. Just use simple triangles. \$\endgroup\$ – Bálint Apr 7 '16 at 6:49
  • \$\begingroup\$ Oh ok. I was using quad strips because I thought would be easier to do the terrain generation (to me atleast). \$\endgroup\$ – 0x22fe Apr 7 '16 at 21:06
-1
\$\begingroup\$

How about drawing a quad strip for each row in your grid of quads?

I guess it depends on how you're representing your data. One way could be to have a 2D array of 3D coordinates for the grid's vertices. To start, the Y component can be zero and then you can assign random Y values while maintaining the X and Z values intact. Then you would draw a GL_QUAD_STRIP using two rows of coordinates at a time from the 2D array: the first strip uses rows 0 and 1, the second strip uses rows 1 and 2 (row 1 is common to the first two strips) and so on... Does that fit your need?

\$\endgroup\$
  • \$\begingroup\$ I originally tried that, but I need all the squares in the grid to be connected, for the purpose of altering the y axis smoothly. But if you can specify a way to draw the quads while sharing the same points, that would be great! \$\endgroup\$ – 0x22fe Apr 5 '16 at 21:53
  • \$\begingroup\$ I guess it depends on how you're representing your data. One way could be to have a 2D array of 3D coordinates for the grid's vertices. To start, the Y component can be zero and then you can assign random Y values while maintaining the X and Z values intact. Then you would draw a GL_QUAD_STRIP using two rows of coordinates at a time from the 2D array: the first strip uses rows 0 and 1, the second strip uses rows 1 and 2 (row 1 is common to the first two strips) and so on... Does that fit your need? \$\endgroup\$ – Leon Apr 6 '16 at 4:43
  • \$\begingroup\$ Yes! I was already doing something like this, but you helped point me in the exact direction. This is perfect! Put this in your current answer so others can see it and I will mark it as the answer. Thanks a lot! \$\endgroup\$ – 0x22fe Apr 7 '16 at 5:06
  • \$\begingroup\$ Hey I'm glad that helped! I've pasted my comment into the answer so you can accept it. Thanks! \$\endgroup\$ – Leon Apr 7 '16 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.