from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from OpenGL.GL.ARB.texture_cube_map import *
import Image
import sys
#after I import all module , I set some vars
angle = 0.1
texture = 0
#this var set the type of reflection
reflMode = GL_REFLECTION_MAP_ARB
#this load the texture
def loadTexture ( fileName ):
image = Image.open ( fileName )
width = image.size [0]
height = image.size [1]
image = image.tostring ( "raw", "RGBX", 0, -1 )
texture = glGenTextures ( 1 )
glBindTexture ( GL_TEXTURE_2D, texture )
glPixelStorei ( GL_UNPACK_ALIGNMENT,1 )
glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT )
glTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT )
glTexParameteri ( GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR )
glTexParameteri ( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR )
gluBuild2DMipmaps ( GL_TEXTURE_2D, 3, width, height, GL_RGBA, GL_UNSIGNED_BYTE, image )
return texture
#this load a cube map of six images
def loadCubemap ( faces, path = "" ):
texture = glGenTextures ( 1 )
target_map = GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
glBindTexture ( GL_TEXTURE_CUBE_MAP_ARB, texture )
glPixelStorei ( GL_PACK_ALIGNMENT,1 )
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT )
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT )
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR )
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR )
glEnable ( GL_TEXTURE_CUBE_MAP_ARB )
for face in faces:
if path != "":
file = path + "/" + f
else:
file = face
image = Image.open ( file )
width = image.size [0]
height = image.size [1]
image = image.tostring ( "raw", "RGBX", 0, -1 )
gluBuild2DMipmaps ( target_map, 3, width, height, GL_RGBA, GL_UNSIGNED_BYTE, image )
target_map = target_map + 1
return texture
#this check if is working OpenGL ARB extension
def extensionInit ():
if not glInitTextureCubeMapARB ():
print "ARB_texture_cubemap not working !"
sys.exit ( 1 )
#this is default init of opengl
def init ():
glClearColor ( 1.0, 1.0, 1.0, 0.0 )
glClearDepth ( 1.0 )
glDepthFunc ( GL_LEQUAL )
glEnable ( GL_DEPTH_TEST )
glHint ( GL_POLYGON_SMOOTH_HINT, GL_NICEST )
glHint ( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST )
#this help us when resize the window
def reshape ( width, height ):
glViewport ( 0, 0, width, height )
glMatrixMode ( GL_PROJECTION )
glLoadIdentity ()
gluPerspective ( 55.0, float(width)/float (height), 1.0, 60.0 )
glMatrixMode ( GL_MODELVIEW )
glLoadIdentity ()
gluLookAt ( 0.0, 6.0, 0.0, 4.0, -4.0, 4.0, 0.0, 0.5, 0.0 )
def display ():
global texture, reflMode
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )
glEnable ( GL_TEXTURE_CUBE_MAP_ARB )
glEnable ( GL_TEXTURE_GEN_S )
glEnable ( GL_TEXTURE_GEN_T )
glEnable ( GL_TEXTURE_GEN_R )
glTexGeni ( GL_S, GL_TEXTURE_GEN_MODE, reflMode )
glTexGeni ( GL_T, GL_TEXTURE_GEN_MODE, reflMode )
glTexGeni ( GL_R, GL_TEXTURE_GEN_MODE, reflMode )
glBindTexture ( GL_TEXTURE_CUBE_MAP_ARB, texture )
glPushMatrix ()
glTranslatef ( 2, 2, 2 )
glRotatef ( angle, 0, 10, 0 )
glutSolidTeapot ( 1.5 )
glPopMatrix ()
glutSwapBuffers ()
#this test the keyboard
def keyPressed ( *args ):
global reflMode
key = args [0]
if key == '\033':
sys.exit ()
elif key == 'n' or key == 'N':
reflMode = GL_NORMAL_MAP_ARB
elif key == 'r' or key == 'R':
reflMode = GL_REFLECTION_MAP_ARB
#this will animate , is a idle function
def animate ():
global angle
angle = 0.01 * glutGet ( GLUT_ELAPSED_TIME )
glutPostRedisplay ()
#... and the main function
def main ():
global texture
glutInit ( sys.argv )
glutInitDisplayMode ( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH )
glutInitWindowSize ( 600, 400 )
glutInitWindowPosition ( 0, 0 )
glutCreateWindow ( "ARB_texture_cubemap demo" )
glutDisplayFunc ( display )
glutIdleFunc ( animate )
glutReshapeFunc ( reshape )
glutKeyboardFunc ( keyPressed )
init ()
extensionInit ();
texture = loadCubemap ( ( "111.JPG", "111.JPG", "111.JPG", "111.JPG", "111.JPG", "111.JPG" ), "" )
print texture
glutMainLoop()
print "Hit ESC key to quit."
main()
2D, 3D, game, games, online game, game development, game engine, programming, OpenGL, Open AI, math, graphics, design, graphic, graphics, game development, game engine, programming, web development, web art, web graphic, arts, tutorial, tutorials,
luni, 21 mai 2012
Python , OpenGL and cube map OpenGL ARB
luni, 30 aprilie 2012
Overview of Blender 2.63 by blendercookie
This is a new video created by blendercookie about Blender 2.63 features.
Thank you for share us.
Blender 2.63 - new release
This is the new release of Blender 3D team and it comes with very useful features.
One is Cycles Render Engine and it is still under development is still available since Blender 2.61.
If you use linux OS then requires glibc 2.7, includes Python 3.2 and FFmpeg.
If you want to learn more , try this online manual.
duminică, 29 aprilie 2012
New version of NeoAxis Game Engine
You can read more here.
NeoAxis Group is pleased to announce that new version of its all-purpose 3D game engine NeoAxis 1.2 was released.
New version features numerous enhancements in different areas, including new tools in Map Editor and Resource Editor, extended localization support, ability to directly import new 3D file formats, full support for Intel HD Graphics integrated video cards, new post-processing effects
marți, 17 aprilie 2012
CryENGINE 3 Free SDK
The official website announced:
Anyone can now download a full version of the best All-In-One Game Development Engine, for free and use it without charge for non-commercial game development. You can try out the fastest toolset for creating game worlds and use the power of CryENGINE 3 in your own games
I could not test it because it requires hardware requirements.
The minimum hardware resources are:
• CPU: Intel Core 2 Duo 2GHz, AMD Athlon 64 X2 2GHz or better (a multi-core processor is strongly recommended)
• Memory: 1 GB RAM (2 GB recommended)
• Video Card: nVidia 8800GT 512MB RAM, ATI 3850HD 512MB RAM or better (SM 3.0 minimum)
Bellow is a video, also you can find on internet.
luni, 9 aprilie 2012
New Format Makes Digital Superhero Books More Cinematic
- dialogue box transitions
- blacked-out pages
- cinematic cuts