Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
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
Comments
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    
No,
glcolor4f and it's like is not recognize anymore in OpenGLES 2

Not sure if you mean this, but, referring to your previous post about the rainbow triangle, you basically do this:
C++
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.
 
Share this answer
 
Comments
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?
Thanks
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);
glBlendFunc (GL_SRC_ALPHA, GL_SRC_ALPHA);

I'm not sure abaout which enum (in glBlendFunc) should i use to make my blue rectangle transparent
Next time I'll post the solution
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900