top pour une présentation...
bon je te met le code qui fonctionne chez moi texte sur opengl via StartDrawing(WindowOutput(#Windows))
Code : Tout sélectionner
;##################################################################
; Ecriture sur window(0) qui apparait sur OpenGLGadget
;##################################################################
Enumeration
#Windows
#Openglgadget
EndEnumeration
#fond = 0 ; couleur de fond de la fenetre
#ligne = 20 ; Taille format saut de ligne avec Drawtext
#DecaleText_X = 300 ; valeur de la position X du texte sur OpengelGadget
#DecaleText_Y = 28 ; valeur de la position Y du texte sur OpengelGadget
#DecaleTitre_X = 400 ; valeur de la position X du Titre sur la Fenetre 0
#DecaleTitre_Y = 12 ; valeur de la position Y du texte sur la Fenetre 0
Procedure Opengl_Key_Pause()
key = 0
Repeat
Event = WaitWindowEvent()
If EventType() = #PB_EventType_KeyDown
key = GetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_Key)
If key = #PB_Shortcut_Escape : End : EndIf
If key = #PB_Shortcut_Space : EndIf ;#PB_Shortcut_Space
EndIf
Until key = #PB_Shortcut_Space
EndProcedure
Procedure help()
StartDrawing(WindowOutput(#Windows))
;Box(WindowWidth(0) - #DecaleText_X, WindowX(0) + #DecaleText_Y-1, 265, 360, #Red) ; #DecaleTitre_X - 180, #DecaleTitre_Y
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 0 , "' 1 >< 2 ' = Rouge + 0.01 / Rouge - 0.01" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 1 , "' 3 >< 4 ' = Vert + 0.01 / Vert - 0.01" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 2 , "' 5 >< 6 ' = Bleu + 0.01 / Bleu - 0.01" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 3 , "' + >< - ' = Alpha + 0.01 / Alpha - 0.01" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 4 , "' 7 ' = Rouge 0.5 " , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 5 , "' 8 ' = Vert 0.5 " , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 6 , "' 9 ' = Bleu 0.5 " , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 7 , "' * >< / ' = Alpha / NO Alpha" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 8 , "' p ' = Piquer Couleur sur image de Fond" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 9 , "' h ' = Active/Desactive dernier 'Triangle'" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 10 , "' m ' = Model ON/OFF" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 11 , "' k ' = Kill le dernier Polygone" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 12 , "' i ' = Afficher l'image de fond" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 13 , "' c ' = Continuer sur un Model" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 14 , "' z ' = Zoom ON/OFF" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 15 , "' a ' = Tout mettre en Alpha ON/OFF" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 16 , "' F1 ' = Couleur précédente en memoire" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 17 , "' F2 ' = Couleur suivante en memoire" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 18 , "' F3 ' = Model précédent" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 19 , "' F4 ' = Model suivant" , #White , fond)
DrawText(WindowWidth(#Windows) - #DecaleText_X, WindowX(#Windows) + #DecaleText_Y + #ligne * 20 , "' F5 ' = Sauve les polygones" , #White , fond)
StopDrawing()
Delay(25)
EndProcedure
Procedure Titre()
StartDrawing(WindowOutput(#Windows))
DrawText(WindowWidth(#Windows) - #DecaleTitre_X, WindowX(#Windows) + #DecaleTitre_Y , " ", #Black, fond)
DrawText(WindowWidth(#Windows) - #DecaleTitre_X - 40, WindowX(#Windows) + #DecaleTitre_Y , "RVBA( " + Str(rouge * 255) + " , " + Str(vert * 255) + " , " + Str(bleu * 255) + " , " + Str(alpha * 255) + " )" , #White, fond)
DrawText(WindowWidth(#Windows) - #DecaleTitre_X + 100, WindowX(#Windows) + #DecaleTitre_Y , "AIDE = Touche Espace ON / OFF" , #Green, #Black)
StopDrawing()
Delay(25)
EndProcedure
If OpenWindow(#Windows, 0, 0, DesktopResolutionX(), DesktopResolutionY(), "", #PB_Window_Maximize|#PB_Window_BorderLess)
SetWindowColor(#Windows, #Black)
;OpenGLGadget(#OpenGLGadget, 0, 28, WindowWidth(#Windows), WindowHeight(#Windows) -28, #PB_OpenGL_Keyboard)
OpenGLGadget(#OpenGLGadget, 0, 0, WindowWidth(#Windows), WindowHeight(#Windows), #PB_OpenGL_Keyboard)
;Titre() ; affiche code RGBA couleur sur windows(0) et OpenGLGadget plus bas de 28 pixels
; pour afficher le titre direct sur OpenGLGaget mettre Titre() dans la boucle repeat et modifier X et H d' OpenGLGadget
SetActiveGadget(#OpenGLGadget) ; Focus OpenGlGadget
Repeat
Titre() ; affiche code RGBA couleur sur OpenGLGadget avec delay pour syntillement pour cela modifier taille et emplacement d'openGLGadget
Event = WaitWindowEvent()
If EventType() = #PB_EventType_KeyDown
Keyf = GetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_Modifiers)
key = GetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_Key)
If Keyf = #PB_OpenGL_Control
If key = #PB_Shortcut_R : Debug "ctrl + R": EndIf ; mode combinaison avec controle + r
Else
If key = #PB_Shortcut_R : Debug "r": EndIf ; mode touche r
EndIf
If key = #PB_Shortcut_Escape : End : EndIf
If key = #PB_Shortcut_Space : help() : Opengl_Key_Pause() : EndIf
EndIf
SetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_FlipBuffers, #True)
Until key = #PB_Shortcut_Escape
EndIf