zak
28-03-2010, 09:46
Hi
here is my version of casting multiple textures over the cube faces.
it is based on the nehe lesson 6 here:
http://community.thinbasic.com/index.php?topic=678.0
if there is another solution please tell me
i have displayed nehe pic twice, rabbit pic twice, tbgl pic twice, it is working but not sure if this is the only way
included the modified file with the pictures
P.S i found another way to do this in blitzbasic, i have to study it:
http://www.blitzbasic.com/Community/posts.php?topic=43543
' NeHe Lesson 06
uses "UI" ' MessageBox Functions
Uses "TBGL" ' ThinBASIC OpenGL Library
' Create MessageBox
dim fullScreen as long
fullScreen = msgbox(0, "Would you like to Run in Fullscreen Mode?", %MB_YESNO or %MB_ICONINFORMATION, "Start FullScreen?")
select case fullScreen
' Create FullScreen Display, Return Handle.
case %IDYES
dim hWnd as dword
hWnd = tbgl_createwindowex("", 1024, 768, 32, 1)
' Create Windowed Display, Return Handle.
case %IDNO
dim hWnd as dword
hWnd = tbgl_createwindowex("NeHe Lesson 06 - Press 'Esc' to Quit", 640, 480, 16, 0)
end select
' Declare Variables here
Dim rquad as Single ' Cube Rotation
dim xRot, yRot, zRot as single ' X, Y & Z-Axis Rotation.
dim frameRate as integer ' Timing Variable
TBGL_ShowWindow ' Show Display
TBGL_GetAsyncKeyState(-1) ' Reset all Keys
' Load Texture, Apply it.
TBGL_LoadTexture APP_SourcePath + "NeHe.bmp", 1, %TBGL_TEX_MIPMAP
TBGL_LoadTexture APP_SourcePath + "thinbasic.bmp", 2, %TBGL_TEX_MIPMAP
TBGL_LoadTexture APP_SourcePath + "rabbit.bmp", 3, %TBGL_TEX_MIPMAP
'TBGL_UseTexture 1 : TBGL_BindTexture 1
' Start Main Loop
While tbgl_isWindow(hWnd)
frameRate = tbgl_getframerate
TBGL_ClearFrame ' Clear Display
TBGL_Camera 0,0,1,0,0,0 ' Default Camera, View From 0,0,1 To 0,0,0.
TBGL_Translate 0.0, 0.0, -5.0 ' Move Into Screen -5 Units
TBGL_Rotate Xrot, 1.0, 0.0, 0.0 ' Rotate on X-Axis
tbgl_rotate Yrot, 0.0, 1.0, 0.0 ' Rotate on Y-Axis
tbgl_rotate Zrot, 0.0, 0.0, 1.0 ' Rotate on Z-Axis
TBGL_UseTexture 2 : TBGL_BindTexture 2
TBGL_BeginPoly %GL_QUADS ' Drawing using Quads
' Front Face
tbgl_texcoord2d 0.0, 0.0 : TBGL_Vertex -1.0, -1.0, 1.0 ' Bottom Left of Texture and Quad
tbgl_TexCoord2d 1.0, 0.0 : tbgl_Vertex 1.0, -1.0, 1.0 ' Bottom Right
TBgl_TexCoord2d 1.0, 1.0 : tbgl_Vertex 1.0, 1.0, 1.0 ' Top Right
TBGL_TexCoord2D 0.0, 1.0 : TBGL_Vertex -1.0, 1.0, 1.0 ' Top Left
TBGL_EndPoly
TBGL_UseTexture 3 : TBGL_BindTexture 3
TBGL_BeginPoly %GL_QUADS
' Back Face
tbgl_TexCoord2d 1.0, 0.0 : tbgl_Vertex -1.0, -1.0, -1.0 ' Bottom Right of Texture and Quad
TBgl_TexCoord2d 1.0, 1.0 : tbgl_Vertex -1.0, 1.0, -1.0 ' Top Right
tbgl_TexCoord2d 0.0, 1.0 : tbgl_Vertex 1.0, 1.0, -1.0 ' Top Left
TBgl_TexCoord2D 0.0, 0.0 : tbgl_Vertex 1.0, -1.0, -1.0 ' Bottom Left
TBGL_EndPoly
TBGL_UseTexture 2 : TBGL_BindTexture 2
TBGL_BeginPoly %GL_QUADS
' Top Face
TBgl_TexCoord2d 0.0, 1.0 : tbgl_Vertex -1.0, 1.0, -1.0 ' Top Left of Texture and Quad
tbgl_TexCoord2d 0.0, 0.0 : tbgl_Vertex -1.0, 1.0, 1.0 ' Bottom Left
tbgl_TexCoord2d 1.0, 0.0 : tbgl_Vertex 1.0, 1.0, 1.0 ' Bottom Right
tbgl_TexCoord2d 1.0, 1.0 : tbgl_Vertex 1.0, 1.0, -1.0 ' Top Right
TBGL_EndPoly
TBGL_UseTexture 1 : TBGL_BindTexture 1
TBGL_BeginPoly %GL_QUADS
' Bottom Face
tbgl_texcoord2d 1.0, 1.0 : tbgl_vertex -1.0, -1.0, -1.0 ' Top Right of Texture and Quad
tbgl_texcoord2d 0.0, 1.0 : tbgl_vertex 1.0, -1.0, -1.0 ' Top Left
tbgl_texcoord2d 0.0, 0.0 : tbgl_vertex 1.0, -1.0, 1.0 ' Bottom Left
tbgl_texcoord2d 1.0, 0.0 : tbgl_vertex -1.0, -1.0, 1.0 ' Bottom Right
TBGL_EndPoly
TBGL_BeginPoly %GL_QUADS
' Right Face
tbgl_texcoord2d 1.0, 0.0 : tbgl_vertex 1.0, -1.0, -1.0 ' Bottom Right of Texture and Quad
tbgl_texcoord2d 1.0, 1.0 : tbgl_vertex 1.0, 1.0, -1.0 ' Top Right
tbgl_texcoord2d 0.0, 1.0 : tbgl_vertex 1.0, 1.0, 1.0 ' Top Left
tbgl_texcoord2d 0.0, 0.0 : tbgl_vertex 1.0, -1.0, 1.0 ' Bottom Left
TBGL_EndPoly
TBGL_UseTexture 3 : TBGL_BindTexture 3
TBGL_BeginPoly %GL_QUADS
' Left Face
tbgl_texcoord2d 0.0, 0.0 : tbgl_vertex -1.0, -1.0, -1.0 ' Bottom Left of Texture and Quad
tbgl_texcoord2d 1.0, 0.0 : tbgl_vertex -1.0, -1.0, 1.0 ' Bottom Right
tbgl_texcoord2d 1.0, 1.0 : tbgl_vertex -1.0, 1.0, 1.0 ' Top Right
tbgl_texcoord2d 0.0, 1.0 : tbgl_vertex -1.0, 1.0, -1.0 ' Top Left
TBGL_EndPoly
Xrot += ( 54.0 / frameRate ) ' X-Axis Rotation
Yrot += ( 36.0 / frameRate ) ' Y-Axis Rotation
Zrot += ( 72.0 / frameRate ) ' Z-Axis Rotation
TBGL_DrawFrame ' Display anything
If tbgl_GetAsyncKeyState(%VK_ESCAPE) then Exit While
Wend
TBGL_DestroyWindow ' Closes Display
here is my version of casting multiple textures over the cube faces.
it is based on the nehe lesson 6 here:
http://community.thinbasic.com/index.php?topic=678.0
if there is another solution please tell me
i have displayed nehe pic twice, rabbit pic twice, tbgl pic twice, it is working but not sure if this is the only way
included the modified file with the pictures
P.S i found another way to do this in blitzbasic, i have to study it:
http://www.blitzbasic.com/Community/posts.php?topic=43543
' NeHe Lesson 06
uses "UI" ' MessageBox Functions
Uses "TBGL" ' ThinBASIC OpenGL Library
' Create MessageBox
dim fullScreen as long
fullScreen = msgbox(0, "Would you like to Run in Fullscreen Mode?", %MB_YESNO or %MB_ICONINFORMATION, "Start FullScreen?")
select case fullScreen
' Create FullScreen Display, Return Handle.
case %IDYES
dim hWnd as dword
hWnd = tbgl_createwindowex("", 1024, 768, 32, 1)
' Create Windowed Display, Return Handle.
case %IDNO
dim hWnd as dword
hWnd = tbgl_createwindowex("NeHe Lesson 06 - Press 'Esc' to Quit", 640, 480, 16, 0)
end select
' Declare Variables here
Dim rquad as Single ' Cube Rotation
dim xRot, yRot, zRot as single ' X, Y & Z-Axis Rotation.
dim frameRate as integer ' Timing Variable
TBGL_ShowWindow ' Show Display
TBGL_GetAsyncKeyState(-1) ' Reset all Keys
' Load Texture, Apply it.
TBGL_LoadTexture APP_SourcePath + "NeHe.bmp", 1, %TBGL_TEX_MIPMAP
TBGL_LoadTexture APP_SourcePath + "thinbasic.bmp", 2, %TBGL_TEX_MIPMAP
TBGL_LoadTexture APP_SourcePath + "rabbit.bmp", 3, %TBGL_TEX_MIPMAP
'TBGL_UseTexture 1 : TBGL_BindTexture 1
' Start Main Loop
While tbgl_isWindow(hWnd)
frameRate = tbgl_getframerate
TBGL_ClearFrame ' Clear Display
TBGL_Camera 0,0,1,0,0,0 ' Default Camera, View From 0,0,1 To 0,0,0.
TBGL_Translate 0.0, 0.0, -5.0 ' Move Into Screen -5 Units
TBGL_Rotate Xrot, 1.0, 0.0, 0.0 ' Rotate on X-Axis
tbgl_rotate Yrot, 0.0, 1.0, 0.0 ' Rotate on Y-Axis
tbgl_rotate Zrot, 0.0, 0.0, 1.0 ' Rotate on Z-Axis
TBGL_UseTexture 2 : TBGL_BindTexture 2
TBGL_BeginPoly %GL_QUADS ' Drawing using Quads
' Front Face
tbgl_texcoord2d 0.0, 0.0 : TBGL_Vertex -1.0, -1.0, 1.0 ' Bottom Left of Texture and Quad
tbgl_TexCoord2d 1.0, 0.0 : tbgl_Vertex 1.0, -1.0, 1.0 ' Bottom Right
TBgl_TexCoord2d 1.0, 1.0 : tbgl_Vertex 1.0, 1.0, 1.0 ' Top Right
TBGL_TexCoord2D 0.0, 1.0 : TBGL_Vertex -1.0, 1.0, 1.0 ' Top Left
TBGL_EndPoly
TBGL_UseTexture 3 : TBGL_BindTexture 3
TBGL_BeginPoly %GL_QUADS
' Back Face
tbgl_TexCoord2d 1.0, 0.0 : tbgl_Vertex -1.0, -1.0, -1.0 ' Bottom Right of Texture and Quad
TBgl_TexCoord2d 1.0, 1.0 : tbgl_Vertex -1.0, 1.0, -1.0 ' Top Right
tbgl_TexCoord2d 0.0, 1.0 : tbgl_Vertex 1.0, 1.0, -1.0 ' Top Left
TBgl_TexCoord2D 0.0, 0.0 : tbgl_Vertex 1.0, -1.0, -1.0 ' Bottom Left
TBGL_EndPoly
TBGL_UseTexture 2 : TBGL_BindTexture 2
TBGL_BeginPoly %GL_QUADS
' Top Face
TBgl_TexCoord2d 0.0, 1.0 : tbgl_Vertex -1.0, 1.0, -1.0 ' Top Left of Texture and Quad
tbgl_TexCoord2d 0.0, 0.0 : tbgl_Vertex -1.0, 1.0, 1.0 ' Bottom Left
tbgl_TexCoord2d 1.0, 0.0 : tbgl_Vertex 1.0, 1.0, 1.0 ' Bottom Right
tbgl_TexCoord2d 1.0, 1.0 : tbgl_Vertex 1.0, 1.0, -1.0 ' Top Right
TBGL_EndPoly
TBGL_UseTexture 1 : TBGL_BindTexture 1
TBGL_BeginPoly %GL_QUADS
' Bottom Face
tbgl_texcoord2d 1.0, 1.0 : tbgl_vertex -1.0, -1.0, -1.0 ' Top Right of Texture and Quad
tbgl_texcoord2d 0.0, 1.0 : tbgl_vertex 1.0, -1.0, -1.0 ' Top Left
tbgl_texcoord2d 0.0, 0.0 : tbgl_vertex 1.0, -1.0, 1.0 ' Bottom Left
tbgl_texcoord2d 1.0, 0.0 : tbgl_vertex -1.0, -1.0, 1.0 ' Bottom Right
TBGL_EndPoly
TBGL_BeginPoly %GL_QUADS
' Right Face
tbgl_texcoord2d 1.0, 0.0 : tbgl_vertex 1.0, -1.0, -1.0 ' Bottom Right of Texture and Quad
tbgl_texcoord2d 1.0, 1.0 : tbgl_vertex 1.0, 1.0, -1.0 ' Top Right
tbgl_texcoord2d 0.0, 1.0 : tbgl_vertex 1.0, 1.0, 1.0 ' Top Left
tbgl_texcoord2d 0.0, 0.0 : tbgl_vertex 1.0, -1.0, 1.0 ' Bottom Left
TBGL_EndPoly
TBGL_UseTexture 3 : TBGL_BindTexture 3
TBGL_BeginPoly %GL_QUADS
' Left Face
tbgl_texcoord2d 0.0, 0.0 : tbgl_vertex -1.0, -1.0, -1.0 ' Bottom Left of Texture and Quad
tbgl_texcoord2d 1.0, 0.0 : tbgl_vertex -1.0, -1.0, 1.0 ' Bottom Right
tbgl_texcoord2d 1.0, 1.0 : tbgl_vertex -1.0, 1.0, 1.0 ' Top Right
tbgl_texcoord2d 0.0, 1.0 : tbgl_vertex -1.0, 1.0, -1.0 ' Top Left
TBGL_EndPoly
Xrot += ( 54.0 / frameRate ) ' X-Axis Rotation
Yrot += ( 36.0 / frameRate ) ' Y-Axis Rotation
Zrot += ( 72.0 / frameRate ) ' Z-Axis Rotation
TBGL_DrawFrame ' Display anything
If tbgl_GetAsyncKeyState(%VK_ESCAPE) then Exit While
Wend
TBGL_DestroyWindow ' Closes Display