primo
19-10-2017, 09:42
a painting by Hans Holbein https://en.wikipedia.org/wiki/The_Ambassadors_(Holbein)
have many symbolism and hidden meanings , one of the best is the strange figure at the painting bottom, it is in fact a deformed skull, we can't see a skull until we look at it from the side: look this excellent 1 minute demo Zhttps://www.youtube.com/watch?v=sNlgLSRZaos
the skull should be like this:
https://en.wikipedia.org/wiki/File:Holbein_Skull.jpg
now how we can simulate it with thinbasic TBGL ?
the simplest approach is to texture a quad (mostly quad) and then adjust the camera like in the youtube demo
i have used this picture 779x768 :
https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Hans_Holbein_the_Younger_-_The_Ambassadors_-_Google_Art_Project.jpg/779px-Hans_Holbein_the_Younger_-_The_Ambassadors_-_Google_Art_Project.jpg
but i changed it to 768x768 to make a square texture and then converting it to bmp (until Petr find a way to use the original 779x768)
and this is the unchanged bmp 779x768
http://wikisend.com/download/346254/Ambassadors.rar
this is my best camera approach, you need the ambassadors bmp file attached below (768x768)
Uses "TBGL"
DIM hWnd AS Dword
hWnd = TBGL_CreateWindowEx("press Esc to quit", 800, 600, 32, %TBGL_WS_WINDOWED) ' Creates OpenGL window, it returns handle
tbgl_ShowWindow ' Shows the window
TBGL_LoadTexture APP_SourcePath+"The_Ambassadors2.bmp", 1, %TBGL_TEX_MIPMAP ' Loads texture as #1, with high quality
tbgl_UseTexturing %TRUE ' I want to use textures
tbgl_BindTexture 1 ' We will use texture #1 in whole program
TBGL_GetAsyncKeyState(-1) ' Reset status of the all keys to prevent immediate quit
while TBGL_isWindow(hWnd)
tbgl_ClearFrame ' Prepares clear frame
'TBGL_Camera 1.5,0.0,0.2,0,-0.5,0
TBGL_Camera 0.8,-0.3,0.5, 0,-0.7,0 'Look from position 0.8,-0.3,0.5 to 0,-0.7,0
tbgl_Color 255,255,255
tbgl_BeginPoly %GL_QUADS ' Starts polygon definition based on 4 vertexes
TBGL_Color 255,255,255
TBGL_TexCoord2D 0,0' Sets texture coordinate
TBGL_Vertex -1,-0.9859,0 ' Adds vertex
TBGL_TexCoord2D 1,0
TBGL_Vertex 1,-0.9859,0
TBGL_Color 255,255,255
TBGL_TexCoord2D 1,1
TBGL_Vertex 1, 0.9859,0
TBGL_TexCoord2D 0,1
TBGL_Vertex -1, 0.9859,0
tbgl_EndPoly ' Ends polygon definition
TBGL_ResetMatrix
tbgl_DrawFrame ' Swaps the buffers - displays rendered image
if TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) THEN exit while
wend
tbgl_DestroyWindow ' Closes OpenGL window
the other approach is to mix the camera move with the painting scaling and move and rotate
Uses "TBGL"
DIM hWnd AS Dword
hWnd = TBGL_CreateWindowEx("press Esc to quit", 800, 600, 32, %TBGL_WS_WINDOWED) ' Creates OpenGL window, it returns handle
tbgl_ShowWindow ' Shows the window
TBGL_LoadTexture APP_SourcePath+"The_Ambassadors2.bmp", 1, %TBGL_TEX_MIPMAP ' Loads texture as #1, with high quality
tbgl_UseTexturing %TRUE ' I want to use textures
tbgl_BindTexture 1 ' We will use texture #1 in whole program
TBGL_GetAsyncKeyState(-1) ' Reset status of the all keys to prevent immediate quit
while TBGL_isWindow(hWnd)
tbgl_ClearFrame ' Prepares clear frame
TBGL_Camera 0,0,0.5,0,0,0 ' Setups camera to look from 0,0,5 to 0,0,0
tbgl_Color 255,255,255
TBGL_Translate 0.1, 0.7, 0
TBGL_Scale 0.2,1,1
TBGL_Rotate -25,0,0
tbgl_BeginPoly %GL_QUADS ' Starts polygon definition based on 4 vertexes
TBGL_Color 255,255,255
TBGL_TexCoord2D 0,0' Sets texture coordinate
TBGL_Vertex -1,-0.9859,0 ' Adds vertex
TBGL_TexCoord2D 1,0
TBGL_Vertex 1,-0.9859,0
TBGL_Color 255,255,255
TBGL_TexCoord2D 1,1
TBGL_Vertex 1, 0.9859,0
TBGL_TexCoord2D 0,1
TBGL_Vertex -1, 0.9859,0
tbgl_EndPoly ' Ends polygon definition
TBGL_ResetMatrix
tbgl_DrawFrame ' Swaps the buffers - displays rendered image
if TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) THEN exit while
wend
tbgl_DestroyWindow ' Closes OpenGL window
the skull here is more clear since it is compressed from its sides (TBGL_Scale 0.2,1,1)
but my main purpose is to see the optimum skull as seen here:
https://en.wikipedia.org/wiki/File:Holbein_Skull.jpg
and to use the original texture dimentions without squaring it
i have read about TBGL_TexturingQuery but don't know how to use it exactly in this subject context
Hope you enjoy the practical usage of a simple programming code in real Life problem
Note: i have used the tutorial about texturing from http://psch.thinbasic.com/old/tbgl_tut_b.html
have many symbolism and hidden meanings , one of the best is the strange figure at the painting bottom, it is in fact a deformed skull, we can't see a skull until we look at it from the side: look this excellent 1 minute demo Zhttps://www.youtube.com/watch?v=sNlgLSRZaos
the skull should be like this:
https://en.wikipedia.org/wiki/File:Holbein_Skull.jpg
now how we can simulate it with thinbasic TBGL ?
the simplest approach is to texture a quad (mostly quad) and then adjust the camera like in the youtube demo
i have used this picture 779x768 :
https://upload.wikimedia.org/wikipedia/commons/thumb/8/88/Hans_Holbein_the_Younger_-_The_Ambassadors_-_Google_Art_Project.jpg/779px-Hans_Holbein_the_Younger_-_The_Ambassadors_-_Google_Art_Project.jpg
but i changed it to 768x768 to make a square texture and then converting it to bmp (until Petr find a way to use the original 779x768)
and this is the unchanged bmp 779x768
http://wikisend.com/download/346254/Ambassadors.rar
this is my best camera approach, you need the ambassadors bmp file attached below (768x768)
Uses "TBGL"
DIM hWnd AS Dword
hWnd = TBGL_CreateWindowEx("press Esc to quit", 800, 600, 32, %TBGL_WS_WINDOWED) ' Creates OpenGL window, it returns handle
tbgl_ShowWindow ' Shows the window
TBGL_LoadTexture APP_SourcePath+"The_Ambassadors2.bmp", 1, %TBGL_TEX_MIPMAP ' Loads texture as #1, with high quality
tbgl_UseTexturing %TRUE ' I want to use textures
tbgl_BindTexture 1 ' We will use texture #1 in whole program
TBGL_GetAsyncKeyState(-1) ' Reset status of the all keys to prevent immediate quit
while TBGL_isWindow(hWnd)
tbgl_ClearFrame ' Prepares clear frame
'TBGL_Camera 1.5,0.0,0.2,0,-0.5,0
TBGL_Camera 0.8,-0.3,0.5, 0,-0.7,0 'Look from position 0.8,-0.3,0.5 to 0,-0.7,0
tbgl_Color 255,255,255
tbgl_BeginPoly %GL_QUADS ' Starts polygon definition based on 4 vertexes
TBGL_Color 255,255,255
TBGL_TexCoord2D 0,0' Sets texture coordinate
TBGL_Vertex -1,-0.9859,0 ' Adds vertex
TBGL_TexCoord2D 1,0
TBGL_Vertex 1,-0.9859,0
TBGL_Color 255,255,255
TBGL_TexCoord2D 1,1
TBGL_Vertex 1, 0.9859,0
TBGL_TexCoord2D 0,1
TBGL_Vertex -1, 0.9859,0
tbgl_EndPoly ' Ends polygon definition
TBGL_ResetMatrix
tbgl_DrawFrame ' Swaps the buffers - displays rendered image
if TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) THEN exit while
wend
tbgl_DestroyWindow ' Closes OpenGL window
the other approach is to mix the camera move with the painting scaling and move and rotate
Uses "TBGL"
DIM hWnd AS Dword
hWnd = TBGL_CreateWindowEx("press Esc to quit", 800, 600, 32, %TBGL_WS_WINDOWED) ' Creates OpenGL window, it returns handle
tbgl_ShowWindow ' Shows the window
TBGL_LoadTexture APP_SourcePath+"The_Ambassadors2.bmp", 1, %TBGL_TEX_MIPMAP ' Loads texture as #1, with high quality
tbgl_UseTexturing %TRUE ' I want to use textures
tbgl_BindTexture 1 ' We will use texture #1 in whole program
TBGL_GetAsyncKeyState(-1) ' Reset status of the all keys to prevent immediate quit
while TBGL_isWindow(hWnd)
tbgl_ClearFrame ' Prepares clear frame
TBGL_Camera 0,0,0.5,0,0,0 ' Setups camera to look from 0,0,5 to 0,0,0
tbgl_Color 255,255,255
TBGL_Translate 0.1, 0.7, 0
TBGL_Scale 0.2,1,1
TBGL_Rotate -25,0,0
tbgl_BeginPoly %GL_QUADS ' Starts polygon definition based on 4 vertexes
TBGL_Color 255,255,255
TBGL_TexCoord2D 0,0' Sets texture coordinate
TBGL_Vertex -1,-0.9859,0 ' Adds vertex
TBGL_TexCoord2D 1,0
TBGL_Vertex 1,-0.9859,0
TBGL_Color 255,255,255
TBGL_TexCoord2D 1,1
TBGL_Vertex 1, 0.9859,0
TBGL_TexCoord2D 0,1
TBGL_Vertex -1, 0.9859,0
tbgl_EndPoly ' Ends polygon definition
TBGL_ResetMatrix
tbgl_DrawFrame ' Swaps the buffers - displays rendered image
if TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) THEN exit while
wend
tbgl_DestroyWindow ' Closes OpenGL window
the skull here is more clear since it is compressed from its sides (TBGL_Scale 0.2,1,1)
but my main purpose is to see the optimum skull as seen here:
https://en.wikipedia.org/wiki/File:Holbein_Skull.jpg
and to use the original texture dimentions without squaring it
i have read about TBGL_TexturingQuery but don't know how to use it exactly in this subject context
Hope you enjoy the practical usage of a simple programming code in real Life problem
Note: i have used the tutorial about texturing from http://psch.thinbasic.com/old/tbgl_tut_b.html