
Hierfür have I a while used, there it no Documentations for Funktionsumfang of OpenGL in XProfan gives. i'm dran, too Access to akuellere OpenGL functions to obtain, by then but here the oldschool example 
usually resolve to the Rendern on a Textur by glBindFramebuffer, I go whom detour over glReadPixels and point The in each Frame the Textur To.
circa with this engineering Szenen To spiegeln How z.B. on of/ one Wasseroberfläche bräuchte it to my understanding the following: Kamera in same stood off and umgekehrten Winkel under The spiegelnde surface, Textur as Projektion - latter have myself not yet correctly hinbekommen.
Declare tex&[5]
Declare xrot!, yrot!, zrot!, xpos!, ypos!, zpos!,xsrot!,ysrot!,zsrot!,xspos!,yspos!,zspos!
Declare smooth%,mb&,mousestartx%,mousestarty%,mousex%,mousey%
Declare end%,hPic&
Declare x&, y&, bytes&,mem#,size&,mem&,light#,t&,fps&,mod&
Proc MouseKeyboard
mousex% = %MouseX
mousey% = %MouseY
if mb& = 0
case isKey(1) : mb& = 1
case isKey(2) : mb& = 2
endif
if (hardship(isKey(2)) & hardship(isKey(1)))
'Startposition for rotate and Zoomwen again nobodies
mb& = 0
mousestartx% = %mousex
mousestarty% = %mousey
xsrot! = xrot!
ysrot! = yrot!
zspos! = zpos!
endif
'Tastaturrotation
case isKey(37) : yrot! = yrot! - 1.0
case isKey(39) : yrot! = yrot! + 1.0
case isKey(38) : xrot! = xrot! + 1.0
case isKey(40) : xrot! = xrot! - 1.0
'Mausrotation
if (mb& = 1)
yrot! = ysrot! - (mousestartx% - %mousex) * 0.4
xrot! = xsrot! - (mousestarty% - %mousey) * 0.4
endif
'Mauszoom
if (mb& = 2) & (abs(mousestarty% - %mousey) > 10)
zpos! = zspos! + (mousestarty% - %mousey) * 0.03
endif
'other Tastatureingaben
case IsKey(27) : end% = 1
Endproc
declare txID&
Proc DrawGLScene
'scene for Textur rendern (roter die)
oGL("glClearColor",1.0,1.0,0.0,1.0)
oGL("glClear", ~GL_COLOR_BUFFER_BIT | ~GL_DEPTH_BUFFER_BIT)
ogl("Origin",0,0,-0.2)'Objects the Size "1" are here exakt so high How the Viewport
oGL("Move", xpos!, ypos!, zpos!)
oGL("Rotate", xrot!,yrot!,zrot!)
oGL("Texture",0, 1)
oGL("Color", 1,0,0,1)
ogl("Cuboid",2,2,2)
'Screenshot in memory lay
oGL("glReadPixels", 210,20,520,520,~GL_RGB,~GL_UNSIGNED_BYTE,mem#)
'Textur create, from Perfomancegründen, under no circumstance Mipmaps
ogl("glBindTexture",~GL_TEXTURE_2D,txID&)
ogl("glTexEnvi",~GL_TEXTURE_ENV, ~GL_TEXTURE_ENV_MODE, ~GL_MODULATE)
ogl("glTexImage2D",~GL_TEXTURE_2D,0,~GL_RGBA,520, 520,0,~GL_RGB,~GL_UNSIGNED_BYTE,mem#)
ogl("glTexParameteri",~GL_TEXTURE_2D, ~GL_TEXTURE_MAG_FILTER, ~GL_LINEAR)
ogl("glTexParameteri",~GL_TEXTURE_2D, ~GL_TEXTURE_MIN_FILTER, ~GL_LINEAR)
'Visible scene rendern and Show
oGL("glClearColor",1.0,1.0,1.0,1.0)
oGL("glClear", ~GL_COLOR_BUFFER_BIT | ~GL_DEPTH_BUFFER_BIT)
oGL("Texture",txID&, 1)
oGL("Color", 1,1,1,1)
ogl("Cuboid",2,2,2)
oGL("Show")
Endproc
' Hauptprogramm
' -------------
windowstyle 1+2+4+8+16
windowtitle "render to texture"
window (%maxx * 0.5 -480), (%maxy * 0.5 - 300) - 960,600'kompatible spelling
UseIcon "Gesicht"
Dim mem#, 520*520*3'x * y * bpp
'oGL iitialisieren, Textur preparing
oGL("Init", %hWnd, 1,1,1,1)
oGL("PosMode",1)
oGL("glEnable", ~GL_CULL_FACE)
ogl("glGenTextures",1,addr(txID&))
'little more light!
dim light#,16
long light#,0 = single(0.5),single(0.5),single(0.5),single(1.0)
oGL("glLightfv",~GL_LIGHT0 ,~GL_AMBIENT,light#)'GL_AMBIENT
'Startposition
zpos! = -5
xrot! = 0
yrot! = 0
WhileNot end%
MouseKeyboard()
DrawGLScene()
EndWhile
oGL("Done")
End
|