@emil i personaly (cant speak fot rbraz though) use push and pop becasue i think its good to keep a record of what in the modelview its handy for me because i load my camera matrices in the modelveiw at the start of a new frame and just mutiply them by each of my model matrices pushing and poping as i go down.
@rbraz i think vain was after a render to texture like this mate not sure though.
#Include "GenioGl\GenioGl.bi"
GenioGraphics( 800 , 600 , 32 , WINDOWED )
Type KeyTracker
Key As Ubyte ptr
Esckey as Uinteger
Up As uinteger
Down As Uinteger
KLeft As Uinteger
KRight As Uinteger
Z As Uinteger
End Type
Declare sub GenioCheckKeys ( Keys As KeyTracker )
Declare Function CreateTextureBuffer ( Byval TWidth As Double , Byval THeight As Double ) As GLuByte PTR
Declare Function CopyTexture ( Destination As GLuint , Byval Source As GLuint PTR )
Dim Shared As GLuByte PTR TextureBuffer
Dim Shared As GLuint Texture
TextureBuffer = CreateTextureBuffer( 512 , 512 )
glGenTextures( 1, @Texture )
glBindTexture( GL_TEXTURE_2D , Texture )
glTexParameteri( GL_TEXTURE_2D , GL_TEXTURE_WRAP_T, GL_CLAMP)
glTexParameterf( GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri( GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glTexImage2D( GL_TEXTURE_2D , 0 , GL_RGB , 512 , 512 , 0 , GL_RGB , GL_UNSIGNED_byte, 0)
Dim Shared Key As KeyTracker
Do
GenioClear()
GenioCheckKeys( Key )
For Y = 0 To (512 * 512 * 3) Step 3
TextureBuffer[Y] = Rnd(1)*255
TextureBuffer[Y+1] = Rnd(1)*255
TextureBuffer[Y+2] = Rnd(1)*255
Next
glBindTexture( GL_TEXTURE_2D , Texture )
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 512, 512 , GL_RGB , GL_UNSIGNED_byte, TextureBuffer)
GenioBltSprite( Texture , 0 , 0 , 800 , 600 )
GenioRender()
LOOP WHILE Key.esckey <> 1
If ( TextureBuffer ) Then Deallocate( TextureBuffer )
Function CreateTextureBuffer( Byval TWidth As Double , Byval THeight As Double ) As GLuByte PTR
Dim Ddata as GLuByte ptr
Ddata = callocate ( ( TWidth * THeight ) * 3 * Len( integer ) )
Return Ddata
End Function
sub GenioCheckKeys( Keys As KeyTracker )
SDL_PumpEvents
Keys.Key = SDL_GetKeyState(0)
Keys.Esckey = Peek( Keys.Key + SDLK_ESCAPE )
Keys.Up = peek( Keys.Key + SDLK_UP )
Keys.Down = peek( Keys.Key + SDLK_DOWN )
Keys.KLeft = peek( Keys.Key + SDLK_LEFT )
Keys.KRight = peek( Keys.Key + SDLK_RIGHT )
Keys.Z = peek( Keys.Key + SDLK_Z )
end sub
this wont compile as ive not included my engine but it would be easy to make it work.
ive only just banged this up for something im working on so dont go mad if its not right lol.
here is the exe.