Jump to content

  • Log In with Google      Sign In   
  • Create Account

Draw filled 2d landscape


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
4 replies to this topic

#1 steg   Members   -  Reputation: 164

Like
0Likes
Like

Posted 29 May 2011 - 08:54 AM

Hi,

Quite new to OpenGL but using OpenGL ES on mobile. Now I know it doesn't support GL_POLYGON so I thought maybe I can just use GL_TRIANGLE_STRIP. I want to create a
random 2d landscape for a side scroller, think of the old arcade game Defender, but I want the landscape filled in. Now I am guessing that I will need to create a lot of quads to do this and
fill each of them in? Is this the best approach?

Thanks,
Steve
As I get older, my mind becomes more cluttered.[3d Game development]

Sponsor:

#2 V-man   Members   -  Reputation: 805

Like
0Likes
Like

Posted 29 May 2011 - 07:15 PM

GL_POLYGON is dead meat in GL 3.0 as well.
For GL ES, use GL_TRIANGLE_STRIP or GL_TRIANGLES with glDrawElements.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

#3 steg   Members   -  Reputation: 164

Like
0Likes
Like

Posted 30 May 2011 - 06:53 AM

Thanks,

Was thinking of using glDrawArray?...

Would I have to draw each part of the landscape as a series of triangles that make a quad in order to fill them?

Many thanks,
Steve


As I get older, my mind becomes more cluttered.[3d Game development]

#4 V-man   Members   -  Reputation: 805

Like
0Likes
Like

Posted 30 May 2011 - 09:43 AM

With GL_TRIANGLES and glDrawElements you can render the entire terrain with a single call.

With GL_TRIANGLE_STRIP and glDrawElements, it depends. You would either have to render each strip, one by one.
Or you can use NULL triangles and use a single call to glDrawElements. You would have to research the hardware capabilities of your target platform if it handles NULL triangles well.

I won't make performance recommendations since I don't program for embedded systems.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

#5 steg   Members   -  Reputation: 164

Like
0Likes
Like

Posted 30 May 2011 - 03:59 PM

Thanks for the info.

I've now generated the landscape using GL_TRIANGLE_FAN. Landscape kind of like the old moon patrol game if you know it? Would love to know how to create 'curved' landscape that is filled in, I guess you need some form of triangulator to do this? Was thinking of generating the curve with some simple math, but dunno how you would triangulate it?!

Thanks,
Steve

Landscape on iPhone



As I get older, my mind becomes more cluttered.[3d Game development]




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.



PARTNERS