winapi - Setting up a Win32 OpenGL Window with a GL_RGBA Color Buffer -
i trying set opengl window alpha channel in color buffer. unfortunately, current setup creating gl_rgb , front end buffer (as reported gdebugger, , shown experiments).
i set window so:
pixelformatdescriptor pfd; zeromemory(&pfd,sizeof(pfd)); pfd.nsize = sizeof(pfd); pfd.nversion = 1; pfd.dwflags = pfd_draw_to_window | pfd_support_opengl | pfd_doublebuffer; pfd.ipixeltype = pfd_type_rgba; pfd.ccolorbits = 24; //note docs alpha doesn't go here (though putting 32 changes nothing) pfd.cdepthbits = 24; pfd.ilayertype = pfd_main_plane; i have tried more specifically:
pixelformatdescriptor pfd = { sizeof(pixelformatdescriptor), 1, pfd_draw_to_window | pfd_support_opengl | pfd_doublebuffer, pfd_type_rgba, 24, 8,0, 8,8, 8,16, 8,24, //a guess lil endian; these 0 (making them 0 doesn't help) 0, 0,0,0,0, 24, //depth 8, //stencil 0, //aux pfd_main_plane, 0, 0, 0, 0 }; my understanding when phone call choosepixelformat later, it's returning format without alpha channel (though why, don't know).
i should clarify when alpha buffer, mean simple alpha buffer rendering purposes (each color has alpha value fragments can tested against, , on). not mean semi-transparent window or other effect. [edit: no, not @ time interested in making window transparent. want alpha channel default framebuffer.]
[edit: part of cross-platform windowing backend i'm writing. code portable. not using library provides functionality since need more control.]
there 2 key points consider here:
you can default framebuffer. however, need request properly. windows's default selection mechanism doesn't seem weight having rgba highly. best course of study seems to enumerate possible pixelmodes , select 1 want "manually" were. doing this, able specify wanted 24 bit depth buffer, accumulation buffer, , 8-bit stencil buffer.
the opengl context must valid alpha blending, depth testing, , remotely advanced techniques work. curiously, able rendered triangles without having valid opengl context, leading confusion! maybe beingness emulated in software? figured out when glewinit (not mention making few vbos) failed miserably. key point opengl context must valid. in case, wasn't setting properly.
this problem in context of writing lightweight cross-platform windowing toolkit. currently, supports windows through win32 api, linux through x11, , started porting mac os through x11.
at request of in comments, hereby nowadays humble effort thereof others may benefit. mac back upwards doesn't work yet, menus aren't implemented on linux, , user input on linux half-there. of 1/18/2013, may temporarily found here (people of future, may have set new versions on my website (look "portcullis")).
winapi opengl window rgba
No comments:
Post a Comment