Skip to content

Commit e99de14

Browse files
committed
🎉auto update by Gmeek action
1 parent c834995 commit e99de14

File tree

1 file changed

+101
-30
lines changed

1 file changed

+101
-30
lines changed

docs/post/WIN10-an-zhuang-pyopengl 64-wei.html

Lines changed: 101 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<meta property="og:url" content="https://blog.meekdai.com/post/WIN10-an-zhuang-pyopengl%2064-wei.html">
3232
<meta property="og:image" content="https://blog.meekdai.com/avatar.svg">
3333
<title>WIN10安装pyopengl 64位</title>
34-
34+
<link href="//unpkg.com/@wooorm/[email protected]/style/both.css" rel="stylesheet" />
3535

3636

3737
</head>
@@ -55,7 +55,17 @@
5555
body {padding: 8px;}
5656
.postTitle{font-size:24px;}
5757
}
58-
58+
.copy-feedback {
59+
display: none;
60+
position: absolute;
61+
top: 10px;
62+
right: 50px;
63+
color: var(--color-fg-on-emphasis);
64+
background-color: var(--color-fg-muted);
65+
border-radius: 3px;
66+
padding: 5px 8px;
67+
font-size: 12px;
68+
}
5969
</style>
6070

6171

@@ -88,39 +98,37 @@ <h1 class="postTitle">WIN10安装pyopengl 64位</h1>
8898
</div>
8999
<div id="content">
90100
<div class="markdown-body" id="postBody"><p>通过python的 <code class="notranslate">pip install pyopengl</code>指令在win10 64位的系统上安装后,运行官方茶壶的例子,会出现如下报错:</p>
91-
<pre lang="python" class="notranslate"><code class="notranslate">OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInitDisplayMode, check for bool(glutInitDisplayMode) before calling
92-
OpenGL.error.NullFunctionError: Attempt to call an undefined function
93-
</code></pre>
101+
<div class="highlight highlight-source-python"><pre class="notranslate"><span class="pl-v">OpenGL</span>.<span class="pl-s1">error</span>.<span class="pl-v">NullFunctionError</span>: <span class="pl-v">Attempt</span> <span class="pl-s1">to</span> <span class="pl-s1">call</span> <span class="pl-s1">an</span> <span class="pl-s1">undefined</span> <span class="pl-s1">function</span> <span class="pl-s1">glutInitDisplayMode</span>, <span class="pl-s1">check</span> <span class="pl-s1">for</span> <span class="pl-en">bool</span>(<span class="pl-s1">glutInitDisplayMode</span>) <span class="pl-s1">before</span> <span class="pl-s1">calling</span>
102+
<span class="pl-v">OpenGL</span>.<span class="pl-s1">error</span>.<span class="pl-v">NullFunctionError</span>: <span class="pl-v">Attempt</span> <span class="pl-s1">to</span> <span class="pl-s1">call</span> <span class="pl-s1">an</span> <span class="pl-s1">undefined</span> <span class="pl-s1">function</span></pre></div>
94103
<p>这些都是因为通过pip安装的版本是32位导致的,我看了很多网上的解决办法说是手动下载64位的包安装即可解决。但是我按要求下载64位的包后,通过 <code class="notranslate">pip install XXX.whl</code>本地安装的方式,却提示我64位的pyopengl已经安装,无需重复安装。让我在这个坑里面跳了好久没跳出来。</p>
95104
<p>最后的解决办法是,你需要先卸载已经安装好的pyopengl,再手动安装一下才行。所以在这里记录一下,以便有其他人遇到同样的坑。<br>
96105
这里给一下手动下载的地址:<a href="https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl" rel="nofollow">pyopengl</a></p>
97106
<p>也顺便贴一下官方的测试茶壶代码:</p>
98-
<pre lang="python" class="notranslate"><code class="notranslate">from OpenGL.GL import *
99-
from OpenGL.GLU import *
100-
from OpenGL.GLUT import *
107+
<div class="highlight highlight-source-python"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-v">OpenGL</span>.<span class="pl-v">GL</span> <span class="pl-k">import</span> <span class="pl-c1">*</span>
108+
<span class="pl-k">from</span> <span class="pl-v">OpenGL</span>.<span class="pl-v">GLU</span> <span class="pl-k">import</span> <span class="pl-c1">*</span>
109+
<span class="pl-k">from</span> <span class="pl-v">OpenGL</span>.<span class="pl-v">GLUT</span> <span class="pl-k">import</span> <span class="pl-c1">*</span>
101110

102-
def drawFunc():
103-
#清楚之前画面
104-
glClear(GL_COLOR_BUFFER_BIT)
105-
glRotatef(0.1, 5, 5, 0) #(角度,x,y,z)
106-
glutWireTeapot(0.5)
107-
#刷新显示
108-
glFlush()
111+
<span class="pl-k">def</span> <span class="pl-en">drawFunc</span>():
112+
<span class="pl-c">#清楚之前画面</span>
113+
<span class="pl-en">glClear</span>(<span class="pl-v">GL_COLOR_BUFFER_BIT</span>)
114+
<span class="pl-en">glRotatef</span>(<span class="pl-c1">0.1</span>, <span class="pl-c1">5</span>, <span class="pl-c1">5</span>, <span class="pl-c1">0</span>) <span class="pl-c">#(角度,x,y,z)</span>
115+
<span class="pl-en">glutWireTeapot</span>(<span class="pl-c1">0.5</span>)
116+
<span class="pl-c">#刷新显示</span>
117+
<span class="pl-en">glFlush</span>()
109118

110-
#使用glut初始化OpenGL
111-
glutInit()
112-
#显示模式:GLUT_SINGLE无缓冲直接显示|GLUT_RGBA采用RGB(A非alpha)
113-
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
114-
#窗口位置及大小-生成
115-
glutInitWindowPosition(0,0)
116-
glutInitWindowSize(400,400)
117-
glutCreateWindow(b"first")
118-
#调用函数绘制图像
119-
glutDisplayFunc(drawFunc)
120-
glutIdleFunc(drawFunc)
121-
#主循环
122-
glutMainLoop()
123-
</code></pre>
119+
<span class="pl-c">#使用glut初始化OpenGL</span>
120+
<span class="pl-en">glutInit</span>()
121+
<span class="pl-c">#显示模式:GLUT_SINGLE无缓冲直接显示|GLUT_RGBA采用RGB(A非alpha)</span>
122+
<span class="pl-en">glutInitDisplayMode</span>(<span class="pl-v">GLUT_SINGLE</span> <span class="pl-c1">|</span> <span class="pl-v">GLUT_RGBA</span>)
123+
<span class="pl-c">#窗口位置及大小-生成</span>
124+
<span class="pl-en">glutInitWindowPosition</span>(<span class="pl-c1">0</span>,<span class="pl-c1">0</span>)
125+
<span class="pl-en">glutInitWindowSize</span>(<span class="pl-c1">400</span>,<span class="pl-c1">400</span>)
126+
<span class="pl-en">glutCreateWindow</span>(<span class="pl-s">b"first"</span>)
127+
<span class="pl-c">#调用函数绘制图像</span>
128+
<span class="pl-en">glutDisplayFunc</span>(<span class="pl-s1">drawFunc</span>)
129+
<span class="pl-en">glutIdleFunc</span>(<span class="pl-s1">drawFunc</span>)
130+
<span class="pl-c">#主循环</span>
131+
<span class="pl-en">glutMainLoop</span>()</pre></div>
124132
<p>python的pyopengl配合pygame还是很香的,有空多学习学习。下面放一张最近做的一个小东西,具体是干嘛用的,之后应该会有文章详细介绍。@(滑稽)</p>
125133
<p><a target="_blank" rel="noopener noreferrer" href="https://github.com/Meekdai/meekdai.github.io/assets/11755104/3d227e8c-77ef-4044-9331-e2d7a77af4c2"><img src="https://github.com/Meekdai/meekdai.github.io/assets/11755104/3d227e8c-77ef-4044-9331-e2d7a77af4c2" alt="pyeuler" style="max-width: 100%;"></a></p></div>
126134
<div style="font-size:small;margin-top:8px;float:right;">❤️ 转载文章请注明出处,谢谢!❤️</div>
@@ -147,7 +155,7 @@ <h1 class="postTitle">WIN10安装pyopengl 64位</h1>
147155
</script></div>
148156
</body>
149157
<script>
150-
var IconList={'sun': 'M8 10.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5zM8 12a4 4 0 100-8 4 4 0 000 8zM8 0a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0V.75A.75.75 0 018 0zm0 13a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5A.75.75 0 018 13zM2.343 2.343a.75.75 0 011.061 0l1.06 1.061a.75.75 0 01-1.06 1.06l-1.06-1.06a.75.75 0 010-1.06zm9.193 9.193a.75.75 0 011.06 0l1.061 1.06a.75.75 0 01-1.06 1.061l-1.061-1.06a.75.75 0 010-1.061zM16 8a.75.75 0 01-.75.75h-1.5a.75.75 0 010-1.5h1.5A.75.75 0 0116 8zM3 8a.75.75 0 01-.75.75H.75a.75.75 0 010-1.5h1.5A.75.75 0 013 8zm10.657-5.657a.75.75 0 010 1.061l-1.061 1.06a.75.75 0 11-1.06-1.06l1.06-1.06a.75.75 0 011.06 0zm-9.193 9.193a.75.75 0 010 1.06l-1.06 1.061a.75.75 0 11-1.061-1.06l1.06-1.061a.75.75 0 011.061 0z', 'moon': 'M9.598 1.591a.75.75 0 01.785-.175 7 7 0 11-8.967 8.967.75.75 0 01.961-.96 5.5 5.5 0 007.046-7.046.75.75 0 01.175-.786zm1.616 1.945a7 7 0 01-7.678 7.678 5.5 5.5 0 107.678-7.678z', 'sync': 'M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z', 'home': 'M6.906.664a1.749 1.749 0 0 1 2.187 0l5.25 4.2c.415.332.657.835.657 1.367v7.019A1.75 1.75 0 0 1 13.25 15h-3.5a.75.75 0 0 1-.75-.75V9H7v5.25a.75.75 0 0 1-.75.75h-3.5A1.75 1.75 0 0 1 1 13.25V6.23c0-.531.242-1.034.657-1.366l5.25-4.2Zm1.25 1.171a.25.25 0 0 0-.312 0l-5.25 4.2a.25.25 0 0 0-.094.196v7.019c0 .138.112.25.25.25H5.5V8.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v5.25h2.75a.25.25 0 0 0 .25-.25V6.23a.25.25 0 0 0-.094-.195Z', 'github': 'M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z'};
158+
var IconList={'sun': 'M8 10.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5zM8 12a4 4 0 100-8 4 4 0 000 8zM8 0a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0V.75A.75.75 0 018 0zm0 13a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5A.75.75 0 018 13zM2.343 2.343a.75.75 0 011.061 0l1.06 1.061a.75.75 0 01-1.06 1.06l-1.06-1.06a.75.75 0 010-1.06zm9.193 9.193a.75.75 0 011.06 0l1.061 1.06a.75.75 0 01-1.06 1.061l-1.061-1.06a.75.75 0 010-1.061zM16 8a.75.75 0 01-.75.75h-1.5a.75.75 0 010-1.5h1.5A.75.75 0 0116 8zM3 8a.75.75 0 01-.75.75H.75a.75.75 0 010-1.5h1.5A.75.75 0 013 8zm10.657-5.657a.75.75 0 010 1.061l-1.061 1.06a.75.75 0 11-1.06-1.06l1.06-1.06a.75.75 0 011.06 0zm-9.193 9.193a.75.75 0 010 1.06l-1.06 1.061a.75.75 0 11-1.061-1.06l1.06-1.061a.75.75 0 011.061 0z', 'moon': 'M9.598 1.591a.75.75 0 01.785-.175 7 7 0 11-8.967 8.967.75.75 0 01.961-.96 5.5 5.5 0 007.046-7.046.75.75 0 01.175-.786zm1.616 1.945a7 7 0 01-7.678 7.678 5.5 5.5 0 107.678-7.678z', 'sync': 'M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z', 'home': 'M6.906.664a1.749 1.749 0 0 1 2.187 0l5.25 4.2c.415.332.657.835.657 1.367v7.019A1.75 1.75 0 0 1 13.25 15h-3.5a.75.75 0 0 1-.75-.75V9H7v5.25a.75.75 0 0 1-.75.75h-3.5A1.75 1.75 0 0 1 1 13.25V6.23c0-.531.242-1.034.657-1.366l5.25-4.2Zm1.25 1.171a.25.25 0 0 0-.312 0l-5.25 4.2a.25.25 0 0 0-.094.196v7.019c0 .138.112.25.25.25H5.5V8.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v5.25h2.75a.25.25 0 0 0 .25-.25V6.23a.25.25 0 0 0-.094-.195Z', 'github': 'M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z', 'copy': 'M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z', 'check': 'M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z'};
151159
var utterancesLoad=0;
152160

153161
let themeSettings={
@@ -220,7 +228,70 @@ <h1 class="postTitle">WIN10安装pyopengl 64位</h1>
220228
}
221229
}
222230

231+
document.addEventListener('DOMContentLoaded', () => {
232+
const createClipboardHTML = (codeContent, additionalClasses = '') => `
233+
<pre class="notranslate"><code class="notranslate">${codeContent}</code></pre>
234+
<div class="clipboard-container position-absolute right-0 top-0 ${additionalClasses}">
235+
<clipboard-copy class="ClipboardButton btn m-2 p-0" role="button" style="display: inherit;">
236+
<svg height="16" width="16" class="octicon octicon-copy m-2"><path d="${IconList["copy"]}"></path></svg>
237+
<svg height="16" width="16" class="octicon octicon-check color-fg-success m-2 d-none"><path d="${IconList["check"]}"></path></svg>
238+
</clipboard-copy>
239+
<div class="copy-feedback">Copied!</div>
240+
</div>
241+
`;
242+
243+
const handleCodeElements = (selector = '') => {
244+
document.querySelectorAll(selector).forEach(codeElement => {
245+
const codeContent = codeElement.innerHTML;
246+
const newStructure = document.createElement('div');
247+
newStructure.className = 'snippet-clipboard-content position-relative overflow-auto';
248+
newStructure.innerHTML = createClipboardHTML(codeContent);
249+
250+
const parentElement = codeElement.parentElement;
251+
if (selector.includes('highlight')) {
252+
parentElement.insertBefore(newStructure, codeElement.nextSibling);
253+
parentElement.removeChild(codeElement);
254+
} else {
255+
parentElement.parentElement.replaceChild(newStructure, parentElement);
256+
}
257+
});
258+
};
259+
260+
handleCodeElements('pre.notranslate > code.notranslate');
261+
handleCodeElements('div.highlight > pre.notranslate');
262+
263+
let currentFeedback = null;
264+
document.querySelectorAll('clipboard-copy').forEach(copyButton => {
265+
copyButton.addEventListener('click', () => {
266+
const codeContent = copyButton.closest('.snippet-clipboard-content').innerText;
267+
const tempTextArea = document.createElement('textarea');
268+
tempTextArea.value = codeContent;
269+
document.body.appendChild(tempTextArea);
270+
tempTextArea.select();
271+
document.execCommand('copy');
272+
document.body.removeChild(tempTextArea);
273+
274+
const copyIcon = copyButton.querySelector('.octicon-copy');
275+
const checkIcon = copyButton.querySelector('.octicon-check');
276+
const copyFeedback = copyButton.nextElementSibling;
277+
278+
if (currentFeedback && currentFeedback !== copyFeedback) {currentFeedback.style.display = 'none';}
279+
currentFeedback = copyFeedback;
280+
281+
copyIcon.classList.add('d-none');
282+
checkIcon.classList.remove('d-none');
283+
copyFeedback.style.display = 'block';
284+
copyButton.style.borderColor = 'var(--color-success-fg)';
223285

286+
setTimeout(() => {
287+
copyIcon.classList.remove('d-none');
288+
checkIcon.classList.add('d-none');
289+
copyFeedback.style.display = 'none';
290+
copyButton.style.borderColor = '';
291+
}, 2000);
292+
});
293+
});
294+
});
224295

225296
</script>
226297

0 commit comments

Comments
 (0)