Hello everyone
The members of the Forum helped me To find
a solution to the problem of transparency with GDIPLUS in :http://masm32.com/board/index.php?topic=2513.msg26303#msg26303
I express my thanks to all members of the forum to provide assistance
so
I want to do the same job but with OpenGL
I found some of the ideas in
http://users.freebasic-portal.de/volta/window9/Beispiele_7.html
http://www.codeproject.com/Tips/141076/Transparent-OpenGL-window
http://www.rsdn.ru/article/opengl/layeredopengl.xml
Can anyone help me in converting The idea to MASM32, Because I failed to do this
thanks ...
(http://www.rsdn.ru/article/opengl/layeredopengl%5Ctransp_teapot.PNG)
Transparency on OpenGL can be done by enabling the GL_MATERIAL_COLOR and using glColor4f where you set the transparency value to the alpha value. The problem on OpenGL is, the transparent vertex should be drawn last after all vertex is drawn.
Quote from: Farabi on January 03, 2014, 08:51:23 PM
Transparency on OpenGL can be done by enabling the GL_MATERIAL_COLOR and using glColor4f where you set the transparency value to the alpha value. The problem on OpenGL is, the transparent vertex should be drawn last after all vertex is drawn.
Hy Farabi
I use ( glEnable, GL_BLEND)+(glBlendFunc) and (glColor4b) for transparency
(http://drive.google.com/uc?export=view&id=0B5q3H3sB5u6QamFxYXduNjJsVTA)
invoke glLoadIdentity
invoke glEnable, GL_BLEND
invoke glDisable, GL_DEPTH_TEST
invoke glBegin,GL_POLYGON
invoke glBlendFunc,GL_SRC_ALPHA, GL_ZERO
invoke glColor4b,CA_,0,127,CA_
invoke glVertex3f,0,3f800000h,0c0800000h
invoke glColor4b,127,127,0,CB_
invoke glVertex3f,0bf800000h,0,0c0800000h
invoke glColor4b,127,0,127,CC_
invoke glVertex3f,3f800000h,0,0c0800000h
invoke glEnd
invoke glBegin,GL_POLYGON
invoke glBlendFunc,GL_SRC_ALPHA, GL_ONE
invoke glColor4b,0,0,127,CC_
invoke glVertex3f,0,0,0c0800000h
invoke glColor4b,127,0,0,CA_
invoke glVertex3f,3f800000h,3f000000h,0c0800000h
invoke glColor4b,0,127,0,CB_
invoke glVertex3f,0bf800000h,3f000000h,0c0800000h
invoke glEnd
invoke SwapBuffers,MainHDC
But I'm looking for transparency in the background with Desktop
For example (But this is by GDIPLUS)
(http://drive.google.com/uc?export=view&id=0B5q3H3sB5u6QNUxpRXk1aU15N3c)
The layered window is still descried through a memory DC thus you only need to replace the GDI+ stuff with OGL (something like SetPixelFormat,hMemDC,...). For per-pixel alpha values, the DC must be filled with premultiplied ARGB (http://msdn.microsoft.com/en-us/library/windows/desktop/dd183393%28v=vs.85%29.aspx) values (probably glBlendFunc (http://msdn.microsoft.com/en-us/library/windows/desktop/dd318368%28v=vs.85%29.aspx)(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)).
Remained half the work :redface:
ok - i see 1 thing that is about the program, in general
i removed these lines
.386
.387
.model flat,stdcall
option casemap:none
and i replaced this line
include masm32rt.inc
with this line
include \masm32\include\masm32rt.inc
as for the layered window, i found 2 problems
1) you should call SetLayeredWindowAttributes BEFORE initializing OpenGL, not AFTER
.ELSEIF uMsg==WM_CREATE
invoke SetLayeredWindowAttributes,hWnd,0,0,LWA_COLORKEY
invoke InitGl,hWnd
; invoke SetLayeredWindowAttributes,hWnd, 0, 0,LWA_COLORKEY
2) you should not call glClearColor between glBegin and glEnd
in fact, you only need to call it once during InitGl
remove this line in the DrawScene PROC
; invoke glClearColor, FP4(0.0),FP4(0.0),FP4(0.0),FP4(0.0)
and add it to the InitGl PROC
invoke glEnable, GL_DEPTH_TEST
invoke glClearColor,FP4(0.0),FP4(0.0),FP4(0.0),FP4(0.0)
NoPixelFmt:
xor eax,eax
ret
(http://img35.imageshack.us/img35/3566/b14w.png)
when the program is first executed, a white background flashes before the image shows up
so, you may want to call glClearColor earlier in the InitGl proc
and - you may have to change the order some other things are executed in InitGl, as well
i'll let you play with that :P