Hi Lionheart008,
as described in this answer:
https://community.khronos.org/t/rotating-text/19910/2
...you cannot draw tilted text using the approach with wglUseFontBitmaps.
Petr
Hello Petr..
Perhaps you can Help for my example.
I only want to rotate a Font about 90.0 degrees.
Something is wrong or Missing in my Code example. Would be good If you can Check my NeHe 13 example. Thanks in advance.. regards Frank
'-- NeHe Lesson 13: Bitmap Fonts ' -- how to rotate a font in openGL ? ' #COMPILE EXE #DIM ALL ' // Include files #INCLUDE ONCE "glu.inc" $WindowCaption = "DDT OpenGL: NeHe Lesson 13" GLOBAL pGL AS IDDTOpenGL ' ======================================================================================= ' OpenGL class ' ======================================================================================= CLASS CDDTOpenGL INSTANCE m_hdc AS DWORD ' // Device context INSTANCE m_hrc AS DWORD ' // Rendering context INSTANCE m_hDlg AS DWORD ' // Dialog handle INSTANCE m_hFont, m_hOldFont, m_FontBase AS DWORD INSTANCE m_cnt1, m_cnt2 AS SINGLE INSTANCE m_szText AS ASCIIZ * 256 CLASS METHOD DESTROY ' // Release the device and rendering contexts IF m_hdc THEN wglMakeCurrent m_hdc, 0 ' // Delete the rendering context IF m_hrc THEN wglDeleteContext m_hrc ' // Release the device context IF m_hdc THEN ReleaseDC m_hDlg, m_hdc ' // Delete the lists glDeleteLists m_FontBase, 96 END METHOD ' ===================================================================================== INTERFACE IDDTOpenGL : INHERIT IUNKNOWN ' ===================================================================================== ' ===================================================================================== ' Initializes OpenGL ' ===================================================================================== METHOD InitOpenGL (BYVAL hDlg AS DWORD) AS LONG IF hDlg = 0 THEN EXIT METHOD m_hDlg = hDlg ' // Get the device context m_hdc = GetDC(m_hDlg) IF m_hdc = 0 THEN EXIT METHOD ' // Bits per pixel LOCAL nBitsPerPel AS LONG nBitsPerPel = GetDeviceCaps(m_hdc, %BITSPIXEL) ' // Depth bits LOCAL cDepthBits AS LONG cDepthBits = nBitsPerPel - 8 IF cDepthBits < 16 THEN cDepthBits = 16 ' // Pixel format LOCAL pfd AS PIXELFORMATDESCRIPTOR pfd.nSize = SIZEOF(PIXELFORMATDESCRIPTOR) pfd.nVersion = 1 pfd.dwFlags = %PFD_DRAW_TO_WINDOW OR %PFD_SUPPORT_OPENGL OR %PFD_DOUBLEBUFFER pfd.iPixelType = %PFD_TYPE_RGBA pfd.cColorBits = nBitsPerPel pfd.cDepthBits = cDepthBits ' // Find a matching pixel format LOCAL pf AS LONG pf = ChoosePixelFormat(m_hdc, pfd) IF ISFALSE pf THEN MessageBox(m_hDlg, "Can't find a suitable pixel format", FUNCNAME$, %MB_OK OR %MB_ICONINFORMATION) EXIT METHOD END IF ' // Set the pixel format IF ISFALSE SetPixelFormat(m_hdc, pf, pfd) THEN MessageBox(m_hDlg, "Can't set the pixel format", FUNCNAME$, %MB_OK OR %MB_ICONINFORMATION) EXIT METHOD END IF ' // Create a new OpenGL rendering context m_hrc = wglCreateContext(m_hdc) IF m_hrc = 0 THEN MessageBox m_hDlg, "Can't create an OpenGL rendering context", FUNCNAME$, %MB_OK OR %MB_ICONEXCLAMATION SendMessage m_hDlg, %WM_CLOSE, 0, 0 EXIT METHOD END IF ' // Make it current IF ISFALSE wglMakeCurrent(m_hdc, m_hrc) THEN MessageBox m_hDlg, "Can't activate the OpenGL rendering context", FUNCNAME$, %MB_OK OR %MB_ICONEXCLAMATION SendMessage m_hDlg, %WM_CLOSE, 0, 0 EXIT METHOD END IF ' // Return success METHOD = %TRUE END METHOD ' ===================================================================================== ' ===================================================================================== ' All the setup goes here ' ===================================================================================== METHOD SetupScene ' Select smooth shading glShadeModel %GL_SMOOTH ' Specify clear values for the color buffers glClearColor 0.0!, 0.0!, 0.0!, 0.0! ' Specify the clear value for the depth buffer glClearDepth 1.0! ' Enable depth comparisons and update the depth buffer glEnable %GL_DEPTH_TEST ' Specify the value used for depth-buffer comparisons glDepthFunc %GL_LEQUAL ' Really nice perspective calculations glHint %GL_PERSPECTIVE_CORRECTION_HINT, %GL_NICEST ' Storage for 96 characters m_FontBase = glGenLists(96) ' Build the font m_hFont = CreateFont(-24, _ ' Height of the font 0, _ ' Width of the font 0, _ ' Angle of escapement 0, _ ' Orientation angle %FW_BOLD, _ ' Font weight 0, _ ' Italic 0, _ ' Underline 0, _ ' Strikeout %ANSI_CHARSET, _ ' Character set identifier %OUT_TT_PRECIS, _ ' Output precision %CLIP_DEFAULT_PRECIS, _ ' Clipping precision %ANTIALIASED_QUALITY, _ ' Output quality %FF_DONTCARE OR %DEFAULT_PITCH, _ ' Family and pitch "Courier New") ' Font name ' Select our font m_hOldFont = SelectObject(m_hdc, m_hFont) ' Builds 96 characters starting at character 32 wglUseFontBitmaps m_hdc, 32, 96, m_FontBase ' Select previous font SelectObject m_hdc, m_hOldFont ' Delete the font DeleteObject m_hFont END METHOD ' ===================================================================================== ' ===================================================================================== ' Resize the scene ' ===================================================================================== METHOD ResizeScene (BYVAL nWidth AS LONG, BYVAL nHeight AS LONG) ' // Prevent divide by zero making height equal one IF nHeight = 0 THEN nHeight = 1 ' // Reset the current viewport glViewport 0, 0, nWidth, nHeight ' // Select the projection matrix glMatrixMode %GL_PROJECTION ' // Reset the projection matrix glLoadIdentity ' // Calculate the aspect ratio of the window gluPerspective 45.0!, nWidth / nHeight, 0.1!, 100.0! ' // Select the model view matrix glMatrixMode %GL_MODELVIEW ' // Reset the model view matrix glLoadIdentity END METHOD ' ===================================================================================== ' ======================================================================================= ' Render the scene ' ======================================================================================= METHOD RenderScene DIM angle AS STATIC SINGLE 'angle=80.0 ' Clear the screen buffer glClear %GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT ' Reset the view glLoadIdentity angle=80.0 ' Move one unit into the screen glpushmatrix() glTranslatef 0.0!, 0.0!, -1.0! glRotatef(angle,0.0!, 0.0!,1.0!) ' Pulsing colors based on text position glColor3f 1.0! * COS(m_cnt1), 1.0! * SIN(m_cnt2), 1.0! - 0.5! * COS(m_cnt1 + m_cnt2) ' Position the text on the screen glRasterPos2f -0.45! + 0.05! * COS(m_cnt1), 0.32! * SIN(m_cnt2) ' Print GL text to the screen 'm_szText = "Active OpenGL Text With NeHe - " & FORMAT$(m_cnt1, "#.00") m_szText = "Active OpenGL Text With Powerbasic - " & FORMAT$(m_cnt1, "#.00") 'm_cnt1 glpopmatrix() ' Pushes the display list bits glPushAttrib %GL_LIST_BIT ' Sets the base character to 0 glListBase m_FontBase - 32 ' Draws the display list text glCallLists LEN(m_szText), %GL_UNSIGNED_BYTE, m_szText ' Pops the display list bits glPopAttrib ' Increase counters 'm_cnt1 '= m_cnt1 + 0.051! 'm_cnt2 '= m_cnt2 + 0.005! ' // Exchange the front and back buffers SwapBuffers m_hdc END METHOD ' ======================================================================================= ' ==================================================================================== ' Processes keystrokes ' ==================================================================================== METHOD ProcessKeys (BYVAL hDlg AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) SELECT CASE wMsg CASE %WM_KEYDOWN SELECT CASE LO(WORD, wParam) CASE %VK_ESCAPE ' // Send a message to close the application DIALOG SEND hDlg, %WM_CLOSE, 0, 0 END SELECT END SELECT END METHOD ' ==================================================================================== END INTERFACE END CLASS ' ======================================================================================= ' ======================================================================================== ' Main ' ======================================================================================== FUNCTION PBMAIN () AS LONG ' // Create the dialog LOCAL hDlg AS DWORD DIALOG NEW PIXELS, 0, $WindowCaption, , , 600, 400, %WS_OVERLAPPEDWINDOW TO hDlg ' // Create an instance of the DX9 class pGL = CLASS "CDDTOpenGL" IF ISNOTHING(pGL) THEN EXIT FUNCTION ' // Initialize OpenGL IF ISFALSE pGL.InitOpenGL(hDlg) THEN EXIT FUNCTION ' // Display and activate the dialog DIALOG SHOW MODELESS hDlg, CALL DlgProc ' // Set the timer SetTimer(hDlg, 1, 0, %NULL) ' // Message loop LOCAL uMsg AS tagMsg WHILE GetMessage(uMsg, %NULL, 0, 0) TranslateMessage uMsg DispatchMessage uMsg WEND ' // Kill the timer KillTimer(hDlg, 1) END FUNCTION ' ======================================================================================== ' ======================================================================================== ' Main Dialog procedure ' ======================================================================================== CALLBACK FUNCTION DlgProc() AS LONG SELECT CASE CB.MSG CASE %WM_SYSCOMMAND ' // Disable the Windows screensaver IF (CB.WPARAM AND &HFFF0) = %SC_SCREENSAVE THEN FUNCTION = 1 ' // Close the window IF (CB.WPARAM AND &HFFF0) = %SC_CLOSE THEN DIALOG SEND CB.HNDL, %WM_CLOSE, 0, 0 CASE %WM_INITDIALOG ' // Set up the scene pGL.SetupScene CASE %WM_TIMER ' // Render the scene pGL.RenderScene CASE %WM_SIZE ' // Resize the scene pGL.ResizeScene LO(WORD, CB.LPARAM), HI(WORD, CB.LPARAM) CASE %WM_KEYDOWN ' // Process keystrokes pGL.ProcessKeys CB.HNDL, CB.MSG, CB.WPARAM, CB.LPARAM CASE %WM_CLOSE ' // Post a message to end the application DIALOG SEND CB.HNDL, %WM_DESTROY, 0, 0 CASE %WM_DESTROY ' // End the application ' // Use this method instead of DIALOG END with modeless dialogs PostQuitMessage 0 END SELECT END FUNCTION ' ========================================================================================
you can't always get what you want, but if you try sometimes you might find, you get what you need
Hi Lionheart008,
as described in this answer:
https://community.khronos.org/t/rotating-text/19910/2
...you cannot draw tilted text using the approach with wglUseFontBitmaps.
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Thank you petr for Infos and reply..
I will try another approach with
CreateFontIndirectA
WglUseFontoutlinesA
Thanks, frank
you can't always get what you want, but if you try sometimes you might find, you get what you need
Dear Frank,
I think you would run into the same issue. The ultimate solution should be:
https://nehe.gamedev.net/tutorial/fr..._opengl/24001/
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Hello Petr..
I have built the solution :-)
I have used NeHe 17 example. There you can find Method glprint() .. and here's the solution too.. I have marked.
I was looking nearly five days for this solution and studied a Lot of examples you can Imagine.
All you can find in *.rar folder
' --> Nehe example 17, here with Rotating FONT text GO :-) ' --> powerbasic, frank bruebach, 12-07-2024 ' #COMPILE EXE #DIM ALL ' // Include files #INCLUDE ONCE "glu.inc" #INCLUDE ONCE "GDIPUTILS.INC" $WindowCaption = "DDT OpenGL: NeHe Lesson 17" GLOBAL pGL AS IDDTOpenGL ' CLASS CDDTOpenGL INSTANCE m_hdc AS DWORD ' // Device context INSTANCE m_hrc AS DWORD ' // Rendering context INSTANCE m_hDlg AS DWORD ' // Dialog handle INSTANCE m_TextureHandles() AS DWORD INSTANCE m_FontBase AS DWORD INSTANCE m_cnt1 AS SINGLE INSTANCE m_cnt2 AS SINGLE CLASS METHOD DESTROY ' // Release the device and rendering contexts IF m_hdc THEN wglMakeCurrent m_hdc, 0 ' // Delete the rendering context IF m_hrc THEN wglDeleteContext m_hrc ' // Release the device context IF m_hdc THEN ReleaseDC m_hDlg, m_hdc ' // Delete the textures glDeleteTextures(2, m_TextureHandles(0)) ' // Delete the lists glDeleteLists m_FontBase, 256 END METHOD ' ===================================================================================== INTERFACE IDDTOpenGL : INHERIT IUNKNOWN ' ===================================================================================== METHOD InitOpenGL (BYVAL hDlg AS DWORD) AS LONG IF hDlg = 0 THEN EXIT METHOD m_hDlg = hDlg ' // Get the device context m_hdc = GetDC(m_hDlg) IF m_hdc = 0 THEN EXIT METHOD ' // Bits per pixel LOCAL nBitsPerPel AS LONG nBitsPerPel = GetDeviceCaps(m_hdc, %BITSPIXEL) ' // Depth bits LOCAL cDepthBits AS LONG cDepthBits = nBitsPerPel - 8 IF cDepthBits < 16 THEN cDepthBits = 16 ' // Pixel format LOCAL pfd AS PIXELFORMATDESCRIPTOR pfd.nSize = SIZEOF(PIXELFORMATDESCRIPTOR) pfd.nVersion = 1 pfd.dwFlags = %PFD_DRAW_TO_WINDOW OR %PFD_SUPPORT_OPENGL OR %PFD_DOUBLEBUFFER pfd.iPixelType = %PFD_TYPE_RGBA pfd.cColorBits = nBitsPerPel pfd.cDepthBits = cDepthBits ' // Find a matching pixel format LOCAL pf AS LONG pf = ChoosePixelFormat(m_hdc, pfd) IF ISFALSE pf THEN MessageBox(m_hDlg, "Can't find a suitable pixel format", FUNCNAME$, %MB_OK OR %MB_ICONINFORMATION) EXIT METHOD END IF ' // Set the pixel format IF ISFALSE SetPixelFormat(m_hdc, pf, pfd) THEN MessageBox(m_hDlg, "Can't set the pixel format", FUNCNAME$, %MB_OK OR %MB_ICONINFORMATION) EXIT METHOD END IF ' // Create a new OpenGL rendering context m_hrc = wglCreateContext(m_hdc) IF m_hrc = 0 THEN MessageBox m_hDlg, "Can't create an OpenGL rendering context", FUNCNAME$, %MB_OK OR %MB_ICONEXCLAMATION SendMessage m_hDlg, %WM_CLOSE, 0, 0 EXIT METHOD END IF ' // Make it current IF ISFALSE wglMakeCurrent(m_hdc, m_hrc) THEN MessageBox m_hDlg, "Can't activate the OpenGL rendering context", FUNCNAME$, %MB_OK OR %MB_ICONEXCLAMATION SendMessage m_hDlg, %WM_CLOSE, 0, 0 EXIT METHOD END IF ' // Return success METHOD = %TRUE END METHOD ' ------------------------------------------------------------------------------------------------------------------------------------------------- // METHOD glPrint (BYVAL x AS LONG, BYVAL y AS LONG, BYREF szText AS ASCIIZ, BYVAL nSet AS LONG, BYVAL FontBase AS DWORD, BYREF TextureHandle AS DWORD) ' for Petr here is the solution :-) ' IF nSet > 1 THEN nSet = 1 glBindTexture %GL_TEXTURE_2D, TextureHandle ' Select our font texture glDisable %GL_DEPTH_TEST ' Disables depth testing glMatrixMode %GL_PROJECTION ' Select the projection matrix glPushMatrix ' Store the projection matrix glLoadIdentity ' Reset the projection matrix glOrtho 0, 640, 0, 480, -1, 1 ' Set up an ortho screen glMatrixMode %GL_MODELVIEW ' Select the modelview matrix glPushMatrix ' Store the modelview matrix glLoadIdentity ' Reset the modelview matrix glTranslated x, y, 0 ' Position the text (0,0 - bottom left) ' important glRotatef 90,0,0,1 '------------------------> GOGO :-) ' solution glListBase FontBase - 32 + (128 * nSet) ' Choose the font set (0 or 1) glCallLists LEN(szText), %GL_UNSIGNED_BYTE, szText ' Write the text to the screen glMatrixMode %GL_PROJECTION ' Select the projection matrix glPopMatrix ' Restore the old projection matrix glMatrixMode %GL_MODELVIEW ' Select the modelview matrix glPopMatrix ' Restore the old projection matrix glEnable %GL_DEPTH_TEST ' Enables depth testing END METHOD '---------------- // METHOD SetupScene '---------------- // LOCAL hr AS LONG LOCAL i AS LONG LOCAL cx, cy AS SINGLE DIM m_TextureHandles(1) AS INSTANCE DWORD DIM TextureWidth(1) AS LONG DIM TextureHeight(1) AS LONG DIM strTextureData(1) AS STRING ' Load textures from disk hr = GdiPlusLoadTexture("Font.bmp", TextureWidth(0), TextureHeight(0), strTextureData(0), %TRUE) hr = GdiPlusLoadTexture("Bumps.bmp", TextureWidth(1), TextureHeight(1), strTextureData(1), %TRUE) ' Create two textures glGenTextures 2, m_TextureHandles(0) FOR i = 0 TO 1 glBindTexture %GL_TEXTURE_2D, m_TextureHandles(i) glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR glTexImage2D %GL_TEXTURE_2D, 0, 3, TextureWidth(i), TextureHeight(i), 0, _ %GL_RGBA, %GL_UNSIGNED_BYTE, BYVAL STRPTR(strTextureData(i)) NEXT DIM angle AS SINGLE angle = 90.0 ' Create 256 display lists m_FontBase = glGenLists(256) glRotatef (angle,0.0,0.0,1.0) ' Select our font texture glBindTexture %GL_TEXTURE_2D, m_TextureHandles(0) FOR i = 0 TO 255 ' x position of current character cx = (i MOD 16) / 16.0! ' y position of current character cy = (i \ 16) / 16.0! ' Start building a list glNewList m_FontBase + i, %GL_COMPILE ' Use a quad for each character glBegin %GL_QUADS ' Texture coordinate (bottom left) glTexCoord2f cx, 1 - cy - 0.0625! ' Vertex coordinate (bottom left) glVertex2i 0,0 ' Texture coordinate (bottom right) glTexCoord2f cx + 0.0625!, 1 - cy - 0.0625! ' Vertex coordinate (bottom right) glVertex2i 16, 0 ' Texture coordinate (top right) glTexCoord2f cx + 0.0625!, 1 - cy ' Vertex coordinate (top right) glVertex2i 16,16 ' Texture coordinate (top left) glTexCoord2f cx, 1 - cy ' Vertex coordinate (top left) glVertex2i 0, 16 ' Done building our quad character glEnd ' Move to the right of the character glTranslated 10,0,0 ' Done building the display list glEndList NEXT ' Specify clear values for the color buffers glClearColor 0.0!, 0.0!, 0.0!, 0.0! ' Enables clearing of the depth buffer glClearDepth 1.0! ' Type of depth test to do glDepthFunc %GL_LEQUAL ' Select the type of blending glBlendFunc %GL_SRC_ALPHA, %GL_ONE ' Enables smooth color shading glShadeModel %GL_SMOOTH ' Enable 2D texture mapping glEnable %GL_TEXTURE_2D END METHOD '-------------------------------------------------------------- // METHOD ResizeScene (BYVAL nWidth AS LONG, BYVAL nHeight AS LONG) ' // Prevent divide by zero making height equal one IF nHeight = 0 THEN nHeight = 1 ' // Reset the current viewport glViewport 0, 0, nWidth, nHeight ' // Select the projection matrix glMatrixMode %GL_PROJECTION ' // Reset the projection matrix glLoadIdentity ' // Calculate the aspect ratio of the window gluPerspective 45.0!, nWidth / nHeight, 0.1!, 100.0! ' // Select the model view matrix glMatrixMode %GL_MODELVIEW ' // Reset the model view matrix glLoadIdentity END METHOD '----------------- // METHOD RenderScene '----------------- // ' Clear the screen buffer glClear %GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT ' Reset the view glLoadIdentity glBindTexture %GL_TEXTURE_2D, m_TextureHandles(1) glTranslatef 0.0!, 0.0!, -5.0! glRotatef 45.0!, 0.0!, 0.0!, 1.0! glRotatef m_cnt1 * 30.0!, 1.0!, 1.0!, 0.0! glDisable %GL_BLEND glColor3f 1.0!, 1.0!, 1.0! glBegin %GL_QUADS glTexCoord2d 0.0!, 0.0! glVertex2f -1.0!, 1.0! glTexCoord2d 1.0!, 0.0! glVertex2f 1.0!, 1.0! glTexCoord2d 1.0!, 1.0! glVertex2f 1.0!, -1.0! glTexCoord2d 0.0!, 1.0! glVertex2f -1.0!, -1.0! glEnd glRotatef 90.0!, 1.0!, 1.0!, 0.0! glBegin %GL_QUADS glTexCoord2d 0.0!, 0.0! glVertex2f -1.0!, 1.0! glTexCoord2d 1.0!, 0.0! glVertex2f 1.0!, 1.0! glTexCoord2d 1.0!, 1.0! glVertex2f 1.0!, -1.0! glTexCoord2d 0.0!, 1.0! glVertex2f -1.0!, -1.0! glEnd glEnable %GL_BLEND ' Reset the view glLoadIdentity ' Pulsing colors based on text position glColor3f 1.0! * COS(m_cnt1),1.0! * SIN(m_cnt2), 1.0! - 0.5! * COS(m_cnt1 + m_cnt2) ' Print GL text to the screen ME.glPrint(280 + 250 * COS(m_cnt1), 235 + 200 * SIN(m_cnt2), "NeHe", 0, m_FontBase, m_TextureHandles(0)) ' Pulsing colors based on text position glColor3f 1.0! * SIN(m_cnt2), 1.0! - 0.5! * COS(m_cnt1 + m_cnt2), 1.0! * COS(m_cnt1) ' Print GL text to the screen ME.glPrint(280 + 230 * COS(m_cnt2), 235 + 200 * SIN(m_cnt1), "OpenGL", 1, m_FontBase, m_TextureHandles(0)) DIM angle AS SINGLE angle = 90.0 glPushMatrix() ' Create 256 display lists 'm_FontBase = glGenLists(256) angle = 90.0 glRotatef (angle,0.0,0.0,1.0+m_FontBase) '0.0) ' Pulsing colors based on text position glColor3f 1.0! * SIN(m_cnt2), 1.0! - 0.5! * COS(m_cnt1 + m_cnt2), 1.0! * COS(m_cnt1) ' Print GL text to the screen ME.glPrint(180 + 130 * COS(m_cnt2), 135 + 100 * SIN(m_cnt1), "PowerBasic", 1, m_FontBase, m_TextureHandles(0)) glPopMatrix() ' Set color to blue glColor3f 0.0!, 0.0!, 1.0! ' Print GL text to the screen ME.glPrint(240 + 200 * COS((m_cnt2 + m_cnt1) / 5), 2, "Giuseppe D'Agata", 0, m_FontBase, m_TextureHandles(0)) ' Set color to white glColor3f 1.0!, 1.0!, 1.0! ' Print GL text to the screen ME.glPrint(242 + 200 * COS((m_cnt2 + m_cnt1) / 5), 2, "Giuseppe D'Agata", 0, m_FontBase, m_TextureHandles(0)) m_cnt1 = m_cnt1 + 0.01! ' Increase the first counter m_cnt2 = m_cnt2 + 0.0081! ' Increase the second counter ' // Exchange the front and back buffers SwapBuffers m_hdc END METHOD ' -------------------------------------------------------------------------------------------------------- // METHOD ProcessKeys (BYVAL hDlg AS DWORD, BYVAL wMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) SELECT CASE wMsg CASE %WM_KEYDOWN SELECT CASE LO(WORD, wParam) CASE %VK_ESCAPE ' // Send a message to close the application DIALOG SEND hDlg, %WM_CLOSE, 0, 0 END SELECT END SELECT END METHOD END INTERFACE END CLASS '------------------------- // FUNCTION PBMAIN () AS LONG ' // Create the dialog LOCAL hDlg AS DWORD DIALOG NEW PIXELS, 0, $WindowCaption, , , 600, 400, %WS_OVERLAPPEDWINDOW TO hDlg ' // Create an instance of the DX9 class pGL = CLASS "CDDTOpenGL" IF ISNOTHING(pGL) THEN EXIT FUNCTION ' // Initialize OpenGL IF ISFALSE pGL.InitOpenGL(hDlg) THEN EXIT FUNCTION ' // Display and activate the dialog DIALOG SHOW MODELESS hDlg, CALL DlgProc ' // Set the timer SetTimer(hDlg, 1, 0, %NULL) ' // Message loop LOCAL uMsg AS tagMsg WHILE GetMessage(uMsg, %NULL, 0, 0) TranslateMessage uMsg DispatchMessage uMsg WEND ' // Kill the timer KillTimer(hDlg, 1) END FUNCTION '---------------------------------- // CALLBACK FUNCTION DlgProc() AS LONG '---------------------------------- // SELECT CASE CB.MSG CASE %WM_SYSCOMMAND ' // Disable the Windows screensaver IF (CB.WPARAM AND &HFFF0) = %SC_SCREENSAVE THEN FUNCTION = 1 ' // Close the window IF (CB.WPARAM AND &HFFF0) = %SC_CLOSE THEN DIALOG SEND CB.HNDL, %WM_CLOSE, 0, 0 CASE %WM_INITDIALOG ' // Set up the scene pGL.SetupScene CASE %WM_TIMER ' // Render the scene pGL.RenderScene CASE %WM_SIZE ' // Resize the scene pGL.ResizeScene LO(WORD, CB.LPARAM), HI(WORD, CB.LPARAM) CASE %WM_KEYDOWN ' // Process keystrokes pGL.ProcessKeys CB.HNDL, CB.MSG, CB.WPARAM, CB.LPARAM CASE %WM_CLOSE ' // Post a message to end the application DIALOG SEND CB.HNDL, %WM_DESTROY, 0, 0 CASE %WM_DESTROY ' // End the application ' // Use this method instead of DIALOG END with modeless dialogs PostQuitMessage 0 END SELECT END FUNCTION ' end
Last edited by Lionheart008; 12-07-2024 at 23:10.
you can't always get what you want, but if you try sometimes you might find, you get what you need
Really nice,
thanks for sharing!
You can design your custom "cool" font using this tool:
https://www.thinbasic.com/community/...t=font+creator
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Bookmarks