<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>openGL归档 - 萌米库的小窝</title>
	<atom:link href="https://blog.moemiku.com/category/opengl/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.moemiku.com/category/opengl/</link>
	<description>Want to do some amazing things</description>
	<lastBuildDate>Wed, 06 Apr 2016 15:53:54 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.5</generator>

<image>
	<url>https://blog.moemiku.com/wp-content/uploads/2015/10/cropped-321-32x32.jpg</url>
	<title>openGL归档 - 萌米库的小窝</title>
	<link>https://blog.moemiku.com/category/opengl/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">122264502</site>	<item>
		<title>Windows上Opengl开发UI遇到的两个坑</title>
		<link>https://blog.moemiku.com/2016/04/windows%e4%b8%8aopengl%e5%bc%80%e5%8f%91ui%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%a4%e4%b8%aa%e5%9d%91/</link>
					<comments>https://blog.moemiku.com/2016/04/windows%e4%b8%8aopengl%e5%bc%80%e5%8f%91ui%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%a4%e4%b8%aa%e5%9d%91/#respond</comments>
		
		<dc:creator><![CDATA[wudijimao]]></dc:creator>
		<pubDate>Wed, 06 Apr 2016 15:53:54 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[openGL]]></category>
		<category><![CDATA[UI库]]></category>
		<category><![CDATA[GUI开发]]></category>
		<category><![CDATA[陷阱]]></category>
		<guid isPermaLink="false">http://blog.moemiku.com/?p=164</guid>

					<description><![CDATA[<p>一、GLEW初始化后并不支持新版的opengl函数。 原因是piexlFormart选择了支持向BitMap绘 &#8230; <a href="https://blog.moemiku.com/2016/04/windows%e4%b8%8aopengl%e5%bc%80%e5%8f%91ui%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%a4%e4%b8%aa%e5%9d%91/" class="more-link">继续阅读<span class="screen-reader-text">Windows上Opengl开发UI遇到的两个坑</span></a></p>
<p><a href="https://blog.moemiku.com/2016/04/windows%e4%b8%8aopengl%e5%bc%80%e5%8f%91ui%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%a4%e4%b8%aa%e5%9d%91/">Windows上Opengl开发UI遇到的两个坑</a>最先出现在<a href="https://blog.moemiku.com">萌米库的小窝</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>一、GLEW初始化后并不支持新版的opengl函数。 <span style="color: #ff0000;">原因是piexlFormart选择了支持向BitMap绘制</span>，这样会使当前opengl环境只支持OpenGL 1.1。</p>
<p>顺便记录一下GLEW使用的几个注意点：</p>
<p>1、头文件要在最前引用 不要在其前边引用gl.h文件 会导致错误。</p>
<p>2、初始化要在wglCreateContext   MakeCurrent之后初始化。并检查返回值是否是 GLEW_OK</p>
<p>3、支持的opengl版本判断使用if(GL_VERSION_x_x) {} （GL_VERSION_4_0）来判断</p>
<pre class="lang:default decode:true " title="windows下初始化opengl环境">int bits = 32;
		static	PIXELFORMATDESCRIPTOR pfd =				// pfd Tells Windows How We Want Things To Be
		{
			sizeof(PIXELFORMATDESCRIPTOR),				// Size Of This Pixel Format Descriptor
			1,											// Version Number
			PFD_DRAW_TO_WINDOW |						// Format Must Support Window
			//PFD_DRAW_TO_BITMAP |
			PFD_SUPPORT_OPENGL,				// Format Must Support OpenGL
			//PFD_DOUBLEBUFFER,							// Must Support Double Buffering
			PFD_TYPE_RGBA,								// Request An RGBA Format
			bits,										// Select Our Color Depth
			0, 0, 0, 0, 0, 0,							// Color Bits Ignored
			0,											// No Alpha Buffer
			0,											// Shift Bit Ignored
			0,											// No Accumulation Buffer
			0, 0, 0, 0,									// Accumulation Bits Ignored
			16,											// 16Bit Z-Buffer (Depth Buffer)  
			0,											// No Stencil Buffer
			0,											// No Auxiliary Buffer
			PFD_MAIN_PLANE,								// Main Drawing Layer
			0,											// Reserved
			0, 0, 0										// Layer Masks Ignored
		};
		int piexelFormat = ChoosePixelFormat(mHDC, &amp;pfd);
		if (!SetPixelFormat(mHDC, piexelFormat, &amp;pfd)) {
			return false;
		}

		_context = wglCreateContext(mHDC);

		if (!wglMakeCurrent(mHDC, _context)) {
			return false;
		}

		GLenum err = glewInit();
		if (GLEW_OK != err)
		{
			return false;
		}</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>二、Opengl可以直接向DIB的DC（设备无关）上绘制，但透明度始终为0.导致updateLayeredWindows时将产生一种特殊的混合效果。（重点：透明度为零，其他颜色数据不为0时 update效果不是纯透明）这将导致误会，实际上只是没有透明度数据引起的。【注：这里的误会是指GDI+函数DrawRectangle  填充色为255时也会引起此效果，设置为254即可，这两个机制不知是否相同，有时间的同学可以试试 然后结果给大家分享一下】</p>
<p><a href="https://blog.moemiku.com/2016/04/windows%e4%b8%8aopengl%e5%bc%80%e5%8f%91ui%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%a4%e4%b8%aa%e5%9d%91/">Windows上Opengl开发UI遇到的两个坑</a>最先出现在<a href="https://blog.moemiku.com">萌米库的小窝</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.moemiku.com/2016/04/windows%e4%b8%8aopengl%e5%bc%80%e5%8f%91ui%e9%81%87%e5%88%b0%e7%9a%84%e4%b8%a4%e4%b8%aa%e5%9d%91/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">164</post-id>	</item>
	</channel>
</rss>
