Click here to Skip to main content
11,790,021 members (58,084 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ OpenGL
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 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
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 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?
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);

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
0 OriginalGriff 1,029
1 Maciej Los 790
2 KrunalRohit 686
3 CPallini 606
4 Richard MacCutchan 460

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