Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ OpenGL
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 23-Apr-12 16:43pm
Comments
Richard MacCutchan at 24-Apr-12 3:48am
   
Draw the triangle, fill it with the solid colour, then draw the rectangle on top.
Amar Tivari at 25-Apr-12 2:21am
   
Add alpha component in the "glcolor4f" for coloring rectangle. 0 is completly transparent and 1 is opaque
satrio_budidharmawan at 25-Apr-12 2:36am
   
No,
glcolor4f and it's like is not recognize anymore in OpenGLES 2
Rate this: bad
good
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.
  Permalink  
Comments
satrio_budidharmawan at 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 at 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 at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Next time I'll post the solution
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 205
3 DamithSL 165
4 Tomas Takac 144
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 24 Apr 2012
Copyright © CodeProject, 1999-2014
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