Click here to Skip to main content
13,050,904 members (63,980 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Another question : ^^

How do I draw two object in OpenGL ES 2?
For example, I need to draw Triangle and Rectangle in which solid Triangle is overlapped by transparent Rectangle.

Thanks in advance
Posted 23-Apr-12 15:43pm
Richard MacCutchan 24-Apr-12 3:48am
Draw the triangle, fill it with the solid colour, then draw the rectangle on top.
Amar Tivari 25-Apr-12 2:21am
Add alpha component in the "glcolor4f" for coloring rectangle. 0 is completly transparent and 1 is opaque
satrio_budidharmawan 25-Apr-12 2:36am
glcolor4f and it's like is not recognize anymore in OpenGLES 2
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Not sure if you mean this, but, referring to your previous post about the rainbow triangle, you basically do this:
glVertexAttribPointer(attPosition, 3, GL_FLOAT, GL_FALSE, 0, vVertices);
glVertexAttribPointer(attColor, 4, GL_FLOAT, GL_FALSE, 0, warna);

with a different set of vertices and colors.
satrio_budidharmawan 24-Apr-12 4:02am
Oh yes, I have solved it though so.
But I have another question,
How to make rectangle i created become tranparent (using GL_BLEND i think).
But nothing happened.
How's that?
Code-o-mat 24-Apr-12 4:15am
I think you have to handle blending in the pixel shader, or fragment shader or what's the term for that in OpenGL.
satrio_budidharmawan 24-Apr-12 4:19am
here's the code line
glEnable (GL_BLEND);

I'm not sure abaout which enum (in glBlendFunc) should i use to make my blue rectangle transparent
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Next time I'll post the solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 24 Apr 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100