WGL.wglGetCurrentDC() crash
Prashant Saxena <[email protected]> Sun, 20 Mar 2016 14:34:01 +0000 (UTC)
| Newsgroups | gmane.comp.python.opengl.user |
|---|---|
| Message-ID | <[email protected]> |
--===============8471246986265686661==
Content-Type: multipart/alternative;
boundary="----=_Part_1233934_1769126705.1458484441833"
Content-Length: 12913
------=_Part_1233934_1769126705.1458484441833
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hi,
Windows 7 x64Python 2.7.11 x64PyOpenGL 3.1.1b1
In a simple program attached here, I am getting crash while getting wglGetC=
urrentDC(). How ever it's working fine in an another simple program whereI'=
m drawing a simple glutSphere. It's printing a long but then program is get=
ting crashed.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from OpenGL.arrays import vbo
from OpenGL import platform as gl_platform
import numpy
import sys
width =3D 800
height =3D 600
num_particles =3D 10000
time_step =3D .005
mouse_down =3D False
mouse_old =3D {'x': 0., 'y': 0.}
rotate =3D {'x': 0., 'y': 0., 'z': 0.}
translate =3D {'x': 0., 'y': 0., 'z': 0.}
initial_translate =3D {'x': 0., 'y': 0., 'z': -2.5}
def glut_window():
=C2=A0=C2=A0=C2=A0 glutInit(sys.argv)
=C2=A0=C2=A0=C2=A0 glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH=
)
=C2=A0=C2=A0=C2=A0 glutInitWindowSize(width, height)
=C2=A0=C2=A0=C2=A0 glutInitWindowPosition(0, 0)
=C2=A0=C2=A0=C2=A0 window =3D glutCreateWindow("Particle Simulation")
=C2=A0=C2=A0=C2=A0 glutDisplayFunc(on_display)=C2=A0 # Called by GLUT every=
frame
=C2=A0=C2=A0=C2=A0 glutKeyboardFunc(on_key)
=C2=A0=C2=A0=C2=A0 glutMouseFunc(on_click)
=C2=A0=C2=A0=C2=A0 glutMotionFunc(on_mouse_move)
=C2=A0=C2=A0=C2=A0 glutTimerFunc(10, on_timer, 10)=C2=A0 # Call draw every =
30 ms
=C2=A0=C2=A0=C2=A0 glViewport(0, 0, width, height)
=C2=A0=C2=A0=C2=A0 glMatrixMode(GL_PROJECTION)
=C2=A0=C2=A0=C2=A0 glLoadIdentity()
=C2=A0=C2=A0=C2=A0 gluPerspective(60., width / float(height), .1, 1000.)
=C2=A0=C2=A0=C2=A0=20
=C2=A0=C2=A0=C2=A0 return(window)
def initial_buffers(num_particles):
=C2=A0=C2=A0=C2=A0=20
=C2=A0=C2=A0=C2=A0 np_position =3D numpy.ndarray((num_particles, 4), dtype=
=3Dnumpy.float32)
=C2=A0=C2=A0=C2=A0 np_color =3D numpy.ndarray((num_particles, 4), dtype=3Dn=
umpy.float32)
=C2=A0=C2=A0=C2=A0 np_velocity =3D numpy.ndarray((num_particles, 4), dtype=
=3Dnumpy.float32)
=C2=A0=C2=A0=C2=A0 np_position[:,0] =3D numpy.sin(numpy.arange(0., num_part=
icles) * 2.001 * numpy.pi / num_particles)=20
=C2=A0=C2=A0=C2=A0 np_position[:,0] *=3D numpy.random.random_sample((num_pa=
rticles,)) / 3. + .2
=C2=A0=C2=A0=C2=A0 np_position[:,1] =3D numpy.cos(numpy.arange(0., num_part=
icles) * 2.001 * numpy.pi / num_particles)=20
=C2=A0=C2=A0=C2=A0 np_position[:,1] *=3D numpy.random.random_sample((num_pa=
rticles,)) / 3. + .2
=C2=A0=C2=A0=C2=A0 np_position[:,2] =3D 0.
=C2=A0=C2=A0=C2=A0 np_position[:,3] =3D 1.
=C2=A0=C2=A0=C2=A0 np_color[:,:] =3D [1.,1.,1.,1.] # White particles
=C2=A0=C2=A0=C2=A0 np_velocity[:,0] =3D np_position[:,0] * 2.
=C2=A0=C2=A0=C2=A0 np_velocity[:,1] =3D np_position[:,1] * 2.
=C2=A0=C2=A0=C2=A0 np_velocity[:,2] =3D 3.
=C2=A0=C2=A0=C2=A0 np_velocity[:,3] =3D numpy.random.random_sample((num_par=
ticles, ))
=C2=A0=C2=A0=C2=A0=20
=C2=A0=C2=A0=C2=A0 gl_position =3D vbo.VBO(data=3Dnp_position, usage=3DGL_D=
YNAMIC_DRAW, target=3DGL_ARRAY_BUFFER)
=C2=A0=C2=A0=C2=A0 gl_position.bind()
=C2=A0=C2=A0=C2=A0 gl_color =3D vbo.VBO(data=3Dnp_color, usage=3DGL_DYNAMIC=
_DRAW, target=3DGL_ARRAY_BUFFER)
=C2=A0=C2=A0=C2=A0 gl_color.bind()
=C2=A0=C2=A0=C2=A0=20
=C2=A0=C2=A0=C2=A0 return (np_position, np_velocity, gl_position, gl_color)
def on_timer(t):
=C2=A0=C2=A0=C2=A0 glutTimerFunc(t, on_timer, t)
=C2=A0=C2=A0=C2=A0 glutPostRedisplay()
def on_key(*args):
=C2=A0=C2=A0=C2=A0 if args[0] =3D=3D '\033' or args[0] =3D=3D 'q':
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sys.exit()
def on_click(button, state, x, y):
=C2=A0=C2=A0=C2=A0 mouse_old['x'] =3D x
=C2=A0=C2=A0=C2=A0 mouse_old['y'] =3D y
def on_mouse_move(x, y):
=C2=A0=C2=A0=C2=A0 rotate['x'] +=3D (y - mouse_old['y']) * .2
=C2=A0=C2=A0=C2=A0 rotate['y'] +=3D (x - mouse_old['x']) * .2
=C2=A0=C2=A0=C2=A0 mouse_old['x'] =3D x
=C2=A0=C2=A0=C2=A0 mouse_old['y'] =3D y=C2=A0=C2=A0=C2=A0=20
def on_display():
=C2=A0=C2=A0=C2=A0 """Render the particles"""=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=20
=C2=A0=C2=A0=C2=A0 glFlush()
=C2=A0=C2=A0=C2=A0 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
=C2=A0=C2=A0=C2=A0 glMatrixMode(GL_MODELVIEW)
=C2=A0=C2=A0=C2=A0 glLoadIdentity()
=C2=A0=C2=A0=C2=A0 # Handle mouse transformations
=C2=A0=C2=A0=C2=A0 glTranslatef(initial_translate['x'], initial_translate['=
y'], initial_translate['z'])
=C2=A0=C2=A0=C2=A0 glRotatef(rotate['x'], 1, 0, 0)
=C2=A0=C2=A0=C2=A0 glRotatef(rotate['y'], 0, 1, 0) #we switched around the =
axis so make this rotate_z
=C2=A0=C2=A0=C2=A0 glTranslatef(translate['x'], translate['y'], translate['=
z'])
=C2=A0=C2=A0=C2=A0 # Render the particles
=C2=A0=C2=A0=C2=A0 glEnable(GL_POINT_SMOOTH)
=C2=A0=C2=A0=C2=A0 glPointSize(1)
=C2=A0=C2=A0=C2=A0 glEnable(GL_BLEND)
=C2=A0=C2=A0=C2=A0 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
=C2=A0=C2=A0=C2=A0 # Set up the VBOs
=C2=A0=C2=A0=C2=A0 gl_color.bind()
=C2=A0=C2=A0=C2=A0 glColorPointer(4, GL_FLOAT, 0, gl_color)
=C2=A0=C2=A0=C2=A0 gl_position.bind()
=C2=A0=C2=A0=C2=A0 glVertexPointer(4, GL_FLOAT, 0, gl_position)
=C2=A0=C2=A0=C2=A0 glEnableClientState(GL_VERTEX_ARRAY)
=C2=A0=C2=A0=C2=A0 glEnableClientState(GL_COLOR_ARRAY)
=C2=A0=C2=A0=C2=A0 # Draw the VBOs
=C2=A0=C2=A0=C2=A0 glDrawArrays(GL_POINTS, 0, num_particles)
=C2=A0=C2=A0=C2=A0 glDisableClientState(GL_COLOR_ARRAY)
=C2=A0=C2=A0=C2=A0 glDisableClientState(GL_VERTEX_ARRAY)
=C2=A0=C2=A0=C2=A0 glDisable(GL_BLEND)
=C2=A0=C2=A0=C2=A0 glutSwapBuffers()
window =3D glut_window()
(np_position, np_velocity, gl_position, gl_color) =3D initial_buffers(num_p=
articles)
print gl_platform.GetCurrentContext()
from OpenGL import WGL
print WGL.wglGetCurrentDC()
glutMainLoop()
CheersPrashant
------=_Part_1233934_1769126705.1458484441833
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html><head></head><body><div style=3D"color:#000; background-color:#fff; f=
ont-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, =
Sans-Serif;font-size:16px"><div id=3D"yui_3_16_0_ym18_1_1458484188611_2198"=
>Hi,</div><div><br></div><div>Windows 7 x64</div><div id=3D"yui_3_16_0_ym18=
_1_1458484188611_2656">Python 2.7.11 x64</div><div id=3D"yui_3_16_0_ym18_1_=
1458484188611_2621">PyOpenGL 3.1.1b1</div><div id=3D"yui_3_16_0_ym18_1_1458=
484188611_2674"><br></div><div id=3D"yui_3_16_0_ym18_1_1458484188611_2691" =
dir=3D"ltr">In a simple program attached here, I am getting crash while get=
ting wglGetCurrentDC(). How ever it's working fine in an another simple pro=
gram where</div><div id=3D"yui_3_16_0_ym18_1_1458484188611_2764" dir=3D"ltr=
">I'm drawing a simple glutSphere. It's printing a long but then program is=
getting crashed.</div><div dir=3D"ltr"><br></div><div id=3D"yui_3_16_0_ym1=
8_1_1458484188611_2779" dir=3D"ltr">#!/usr/bin/env python<br># -*- coding: =
utf-8 -*-<br><br>from OpenGL.GL import *<br>from OpenGL.GLU import *<br>fro=
m OpenGL.GLUT import *<br>from OpenGL.arrays import vbo<br>from OpenGL impo=
rt platform as gl_platform<br>import numpy<br>import sys<br><br>width =3D 8=
00<br>height =3D 600<br>num_particles =3D 10000<br>time_step =3D .005<br>mo=
use_down =3D False<br>mouse_old =3D {'x': 0., 'y': 0.}<br>rotate =3D {'x': =
0., 'y': 0., 'z': 0.}<br>translate =3D {'x': 0., 'y': 0., 'z': 0.}<br>initi=
al_translate =3D {'x': 0., 'y': 0., 'z': -2.5}<br><br>def glut_window():<br=
> glutInit(sys.argv)<br> glutInitDispla=
yMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)<br> glutInitW=
indowSize(width, height)<br> glutInitWindowPosition(0, 0)=
<br> window =3D glutCreateWindow("Particle Simulation")<b=
r><br> glutDisplayFunc(on_display) # Called by GLUT=
every frame<br> glutKeyboardFunc(on_key)<br> =
glutMouseFunc(on_click)<br> glutMotionFunc(on_mous=
e_move)<br> glutTimerFunc(10, on_timer, 10) # Call =
draw every 30 ms<br><br> glViewport(0, 0, width, height)<=
br> glMatrixMode(GL_PROJECTION)<br> glL=
oadIdentity()<br> gluPerspective(60., width / float(heigh=
t), .1, 1000.)<br> <br> return(window)<=
br><br>def initial_buffers(num_particles):<br> <br> =
np_position =3D numpy.ndarray((num_particles, 4), dtype=3Dnump=
y.float32)<br> np_color =3D numpy.ndarray((num_particles,=
4), dtype=3Dnumpy.float32)<br> np_velocity =3D numpy.nda=
rray((num_particles, 4), dtype=3Dnumpy.float32)<br><br> n=
p_position[:,0] =3D numpy.sin(numpy.arange(0., num_particles) * 2.001 * num=
py.pi / num_particles) <br> np_position[:,0] *=3D numpy.r=
andom.random_sample((num_particles,)) / 3. + .2<br> np_po=
sition[:,1] =3D numpy.cos(numpy.arange(0., num_particles) * 2.001 * numpy.p=
i / num_particles) <br> np_position[:,1] *=3D numpy.rando=
m.random_sample((num_particles,)) / 3. + .2<br> np_positi=
on[:,2] =3D 0.<br> np_position[:,3] =3D 1.<br><br> &=
nbsp; np_color[:,:] =3D [1.,1.,1.,1.] # White particles<br><br> =
np_velocity[:,0] =3D np_position[:,0] * 2.<br> &nbs=
p; np_velocity[:,1] =3D np_position[:,1] * 2.<br> np_velo=
city[:,2] =3D 3.<br> np_velocity[:,3] =3D numpy.random.ra=
ndom_sample((num_particles, ))<br> <br> =
gl_position =3D vbo.VBO(data=3Dnp_position, usage=3DGL_DYNAMIC_DRAW, targe=
t=3DGL_ARRAY_BUFFER)<br> gl_position.bind()<br> &nbs=
p; gl_color =3D vbo.VBO(data=3Dnp_color, usage=3DGL_DYNAMIC_DRAW, tar=
get=3DGL_ARRAY_BUFFER)<br> gl_color.bind()<br>  =
; <br> return (np_position, np_velocity, gl_positio=
n, gl_color)<br><br>def on_timer(t):<br> glutTimerFunc(t,=
on_timer, t)<br> glutPostRedisplay()<br><br>def on_key(*=
args):<br> if args[0] =3D=3D '\033' or args[0] =3D=3D 'q'=
:<br> sys.exit()<br><br>def on_cl=
ick(button, state, x, y):<br> mouse_old['x'] =3D x<br>&nb=
sp; mouse_old['y'] =3D y<br><br>def on_mouse_move(x, y):<br>&nb=
sp; rotate['x'] +=3D (y - mouse_old['y']) * .2<br> &=
nbsp; rotate['y'] +=3D (x - mouse_old['x']) * .2<br> mous=
e_old['x'] =3D x<br> mouse_old['y'] =3D y &nbs=
p; <br><br>def on_display():<br> """Render the particles"=
"" <br><br> glF=
lush()<br> glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_=
BIT)<br> glMatrixMode(GL_MODELVIEW)<br> =
glLoadIdentity()<br> # Handle mouse transformations<br>&=
nbsp; glTranslatef(initial_translate['x'], initial_translate['y=
'], initial_translate['z'])<br> glRotatef(rotate['x'], 1,=
0, 0)<br> glRotatef(rotate['y'], 0, 1, 0) #we switched a=
round the axis so make this rotate_z<br> glTranslatef(tra=
nslate['x'], translate['y'], translate['z'])<br> # Render=
the particles<br> glEnable(GL_POINT_SMOOTH)<br> &nb=
sp; glPointSize(1)<br> glEnable(GL_BLEND)<br> =
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)<br> &nb=
sp; # Set up the VBOs<br> gl_color.bind()<br> =
glColorPointer(4, GL_FLOAT, 0, gl_color)<br> =
gl_position.bind()<br> glVertexPointer(4, GL_FLOAT, 0, g=
l_position)<br> glEnableClientState(GL_VERTEX_ARRAY)<br>&=
nbsp; glEnableClientState(GL_COLOR_ARRAY)<br> =
# Draw the VBOs<br> glDrawArrays(GL_POINTS, 0, num_parti=
cles)<br> glDisableClientState(GL_COLOR_ARRAY)<br> &=
nbsp; glDisableClientState(GL_VERTEX_ARRAY)<br> glD=
isable(GL_BLEND)<br> glutSwapBuffers()<br><br><br>window =
=3D glut_window()<br>(np_position, np_velocity, gl_position, gl_color) =3D =
initial_buffers(num_particles)<br><br>print gl_platform.GetCurrentContext()=
<br>from OpenGL import WGL<br>print WGL.wglGetCurrentDC()<br><br>glutMainLo=
op()</div><div id=3D"yui_3_16_0_ym18_1_1458484188611_2796" dir=3D"ltr"><br>=
</div><div dir=3D"ltr">Cheers</div><div dir=3D"ltr">Prashant<br></div></div=
></body></html>
------=_Part_1233934_1769126705.1458484441833--
--===============8471246986265686661==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
--===============8471246986265686661==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyopengl-users
--===============8471246986265686661==--