Hehe, I made it and at last it is working!!
Nice to use that damn modern video hardware.
Here is the source if somebody interested:
Code: Select all
/*
** textured rotated rectangle
*/
@REQUIRE "glgalore"
/*
** Define four displays
*/
@DISPLAY {Sizeable = True, Title = "texture"}
;@BRUSH 1,"rotatebitmap.jpg"
@BRUSH 1,"hollywood:Examples/Hollywood/3DCube/03.jpg"
ScaleBrush(1,256,256)
Function p_DrawGL()
gl.ClearColor( 0, 0, 0, 0 )
gl.Clear( #GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT )
gl.MatrixMode( #GL_PROJECTION )
gl.LoadIdentity()
;gl.Ortho( -2, 2, -2, 2, -1, 1 )
gl.MatrixMode( #GL_MODELVIEW )
gl.LoadIdentity()
gl.Color( 1, 1, 1 )
gl.BindTexture( #GL_TEXTURE_2D, texid[ 0 ] )
;gl.Translate(0, 0, -10)
;gl.Rotate(r, 0, 1, 0)
;gl.Rotate(r, 1, 1, 1)
gl.rotate(r,0,0,1)
gl.Begin(#GL_QUADS)
gl.TexCoord( 0, 0 )
gl.Vertex( 1, 1, 1)
gl.TexCoord( 1, 0 )
gl.Vertex(-1, 1, 1)
gl.TexCoord( 1, 1 )
gl.Vertex(-1, -1, 1)
gl.TexCoord( 0, 1 )
gl.Vertex( 1, -1, 1)
gl.End()
r = r + 0.1
EndFunction
/* new window size */
Function p_Reshape(msg)
; initialize GL context
gl.ClearColor(0, 0, 0, 0)
gl.Enable(#GL_TEXTURE_2D)
gl.MatrixMode(#GL_PROJECTION)
gl.LoadIdentity()
glu.Perspective(20, msg.width / msg.height, 5, 15)
gl.Viewport(0, 0, msg.width, msg.height)
gl.MatrixMode(#GL_MODELVIEW)
;gl.MatrixMode(#GL_TEXTURE)
EndFunction
;init
gl.Enable( #GL_TEXTURE_2D )
texid=gl.GenTextures( 1 )
gl.BindTexture( #GL_TEXTURE_2D, texid[ 0 ] )
gl.TexImagefrombrush(0, 1 )
gl.TexParameter( #GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_NEAREST )
gl.TexParameter( #GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_NEAREST )
p_Reshape({Width = 640, Height = 640})
InstallEventHandler({
SizeWindow = Function(msg) p_Reshape(msg) EndFunction,
ModeSwitch = Function(msg) p_Reshape(msg) EndFunction})
; start hardware double-buffering for window
BeginDoubleBuffer(True)
EscapeQuit(True)
; main loop
Repeat
; draw next cube frame
p_DrawGL()
; flip buffer into view
Flip
CheckEvent
Forever