FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC

Développement d'applications avec le langage Panoramic
 
AccueilAccueil  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  MembresMembres  Connexion  
Derniers sujets
» Logiciel de planétarium.
[english]Inline assembler convert real to float and OpenGL Emptypar Pedro Aujourd'hui à 8:08

» Un autre pense-bête...
[english]Inline assembler convert real to float and OpenGL Emptypar Froggy One Jeu 21 Nov 2024 - 15:54

» Récupération du contenu d'une page html.
[english]Inline assembler convert real to float and OpenGL Emptypar Pedro Sam 16 Nov 2024 - 14:04

» Décompilation
[english]Inline assembler convert real to float and OpenGL Emptypar JL35 Mar 12 Nov 2024 - 19:57

» Un album photos comme du temps des grands-mères
[english]Inline assembler convert real to float and OpenGL Emptypar jjn4 Mar 12 Nov 2024 - 17:23

» traitement d'une feuille excel
[english]Inline assembler convert real to float and OpenGL Emptypar jjn4 Jeu 7 Nov 2024 - 3:52

» Aide-mémoire mensuel
[english]Inline assembler convert real to float and OpenGL Emptypar jjn4 Lun 4 Nov 2024 - 18:56

» Des incomprèhension avec Timer
[english]Inline assembler convert real to float and OpenGL Emptypar Klaus Mer 30 Oct 2024 - 18:26

» KGF_dll - nouvelles versions
[english]Inline assembler convert real to float and OpenGL Emptypar Klaus Mar 29 Oct 2024 - 17:58

» instructions panoramic
[english]Inline assembler convert real to float and OpenGL Emptypar maelilou Lun 28 Oct 2024 - 19:51

» Figures fractales
[english]Inline assembler convert real to float and OpenGL Emptypar Marc Ven 25 Oct 2024 - 12:18

» Panoramic et Scanette
[english]Inline assembler convert real to float and OpenGL Emptypar Yannick Mer 25 Sep 2024 - 22:16

» Editeur d étiquette avec QR évolutif
[english]Inline assembler convert real to float and OpenGL Emptypar JL35 Lun 23 Sep 2024 - 22:40

» BUG QR Code DelphiZXingQRCode
[english]Inline assembler convert real to float and OpenGL Emptypar Yannick Dim 22 Sep 2024 - 11:40

» fichier.exe
[english]Inline assembler convert real to float and OpenGL Emptypar leclode Ven 20 Sep 2024 - 19:02

Navigation
 Portail
 Index
 Membres
 Profil
 FAQ
 Rechercher
Rechercher
 
 

Résultats par :
 
Rechercher Recherche avancée
Novembre 2024
LunMarMerJeuVenSamDim
    123
45678910
11121314151617
18192021222324
252627282930 
CalendrierCalendrier
Le deal à ne pas rater :
Smartphone Xiaomi 14 – 512 Go- 6,36″ 5G Double SIM à 599€
599 €
Voir le deal

 

 [english]Inline assembler convert real to float and OpenGL

Aller en bas 
3 participants
AuteurMessage
d.j.peters

d.j.peters


Nombre de messages : 77
Age : 60
Localisation : Germany
Date d'inscription : 31/07/2010

[english]Inline assembler convert real to float and OpenGL Empty
MessageSujet: [english]Inline assembler convert real to float and OpenGL   [english]Inline assembler convert real to float and OpenGL EmptyLun 30 Avr 2018 - 12:24

Normally Panoramic can't call DLL's with float as parameter
but with a litle bit inline assembler it's posible now :-)

Only for fun as a short test I created a OpenGL render context
where the OpenGL command glClearColor needs 4 float values.

glClearColor red, green, blue, alpha

Of course you can use Float() for other DLL's also.

But see self my friends.

DJ
Code:
LIBRARY 1,"kernel32"
' params: dstAddress%, srcAddress%, nBytes%
COMMAND "copy","RtlMoveMemory",1,"III","stdcall"

LIBRARY 2,"user32"
' params: pProcAddress%, hWin%, hMSG%, wParam%, lParam%
COMMAND "CallWindowProc","CallWindowProcA",2,"IIIII","stdcall"
' params: hWIN%, hDC%
COMMAND "ReleaseDC","ReleaseDC",2,"II","stdcall"

LIBRARY 3,"gdi32"
' params: hDC%
COMMAND "SwapBuffers","SwapBuffers",3,"I","stdcall"
' params: hDC%, nFormat%, adr(PIXELFORMATDESCRIPTOR)
COMMAND "SetPixelFormat","SetPixelFormat",3,"III","stdcall"

LIBRARY 4,"opengl32"
' params: hDC%, hRC%
COMMAND "wglMakeCurrent","wglMakeCurrent",4,"II","stdcall"
' params: hRC%
COMMAND "wglDeleteContext" ,"wglDeleteContext",4,"I","stdcall"
' params: left%, bottom%, width%, height%
COMMAND "glViewport" ,"glViewport",4,"IIII","stdcall"
' params: (float) red, green, blue, alpha
COMMAND "glClearColor","glClearColor",4,"IIII","stdcall"
' params: GL_XXX_BUFFER_BITS (color,depth,stencil ...)
COMMAND "glClear","glClear",4,"I","stdcall"
' params: GL_XXX
COMMAND "glEnable","glEnable",4,"I","stdcall"
' params: GL_XXX
COMMAND "glDisable","glDisable",4,"I","stdcall"

' params: primitive% GL_XXX (points,lines,triangles,quads, ...
COMMAND "glBegin","glBegin",4,"I","stdcall"
' params: none
COMMAND "glEnd","glEnd",4,"","stdcall"
' params: real x,y,z
COMMAND "glVertex3d","glVertex3d",4,"RRR","stdcall"

LIBRARY 5,"winmm"
' params adr(adr("file.wav")), flag%
COMMAND "sndPlaySound","sndPlaySoundA",5,"II","stdcall"

label labRealToFloat,main,timerProc
label resize,close


labRealToFloat:    : ' convert a Panoramic real (double) to float
data "55"          : ' push  ebp
data "89","e5"      : ' mov    ebp,esp
data "8b","75","0c" : ' mov    esi,DWORD PTR [ebp+0xc]
data "dd","06"      : ' fld    QWORD PTR [esi]
data "8b","75","08" : ' mov    esi,DWORD PTR [ebp+0x8]
data "d9","1e"      : ' fstp  DWORD PTR [esi]
data "5d"          : ' pop    ebp
data "c2","10","00" : ' ret    0x10
data ""

dim opcode$,asmRealToFloat$,pRealToFloat%

' put the hex opcodes from data lines
' in string asmRealToFloat$
restore_label labRealToFloat
read opcode$
while len(opcode$)>0
  asmRealToFloat$ = asmRealToFloat$ + chr$(hex(opcode$))
  read opcode$
end_while
' get address of the assembler code p =*p
pRealToFloat% = adr(asmRealToFloat$)
copy adr(pRealToFloat%),pRealToFloat%,4

' jump over the functions
goto main

' convert a real number to float and store it as integer
fnc Float(real)
  dim_local float%
  CallWindowProc pRealToFloat%,adr(float%),adr(real),0,0
  result float%
end_fnc

' create OpenGL render context hRC% from device context hDC%
' with 24 bit color buffer 24 bit depth buffer and 8 bit stencil buffer
fnc InitOpenGL(hDC%)
  dim_local res%,hRC%,type$,p%,ptr%
  if hDC%<>0
    type$ = string$(40,chr$(0))
    p% = adr(type$)
    copy adr(ptr%), p%, 4      : ' ptr = *p
   
    poke ptr%,40 : ptr%=ptr% + 2 : ' WORD  wSize sizeof(tagPIXELFORMATDESCRIPTOR)
    poke ptr%, 1 : ptr%=ptr% + 2 : ' WORD  wVersion
    poke ptr%,37 : ptr%=ptr% + 4 : ' DWORD dwFlag  DOUBLEBUFFER 1 or DRAW_TO_WINDOW 4 or SUPPORT_OPENGL 32
    poke ptr%, 0 : ptr%=ptr% + 1 : ' BYTE  iPixelType  PFD_TYPE_RGBA
    poke ptr%,24 : ptr%=ptr% +14 : ' BYTE  cColorBits
    poke ptr%,24 : ptr%=ptr% + 1 : ' BYTE  cDepthBits
    poke ptr%, 8 : ptr%=ptr% + 2 : ' BYTE  cStencilBits
    poke ptr%, 0 : ptr%=ptr% + 1 : ' BYTE  iLayerType PFD_MAIN_PLANE
         
    copy adr(ptr%), p%, 4 : ' ptr = *p
    dll_on "gdi32"
      res% = dll_Call2("ChoosePixelFormat",hDC%,ptr%)
    dll_off 
    if res%<>0
      SetPixelFormat hDC%,res%,ptr%
      dll_on "opengl32"
        hRC% = dll_call1("wglCreateContext",hDC%)
      dll_off
      if hRC%<>0
        wglMakeCurrent hDC%,hRC%
      end_if
    end_if       
  end_if
 
  result hRC%
 
end_fnc

'
' main
'
main:
dim Form%
on_resize Form%,resize
on_close  Form%,close

 
' full_space Form%

dim hWIN%,hDC%,hRC%

dim RederTarget% : RederTarget% = number_objects+1
' container RederTarget%
panel RederTarget% 
gosub resize
   
dim Button% : Button% = number_objects+1
button Button% : parent Button%,RederTarget%
left Button%,50
top  Button%,50
caption Button%,"OpenGL"

hWIN% = handle(RederTarget%)
dll_on "user32"
  hDC% = dll_call1("GetDC",hWIN%)
dll_off
if hDC% = 0 then stop : ' TERMINATE

' init OpenGL render context from device context
hRC% = InitOpenGL(hDC%)
if hRC%=0 then stop : ' TERMINATE

glViewport 0,0,width(RederTarget%),height(RederTarget%)
SwapBuffers hDC%

dim tmr% : tmr% = number_objects+1
timer tmr%
timer_interval tmr%,1000/60
on_timer      tmr%,timerProc

dim w

' go in main message loop
end

close:
  ' unbind the OpenGL render context
  wglMakeCurrent 0,0
  ' delete the render context
  wglDeleteContext hRC%
  ' release the device context
  ReleaseDC hWIN%,hDC%
  return 

resize:
  left  RederTarget%,50
  top    RederTarget%,50
  width  RederTarget%,width_client(Form%)-100
  height RederTarget%,height_client(Form%)-100
  return

timerProc:
  glClearColor Float(0.5 + sin(w)*0.5),0,0,Float(1.0)
  glClear hex("4000") : ' GL_COLOR_BUFFER_BITS 
  SwapBuffers hDC%
  w = w + 0.1
  return


Dernière édition par d.j.peters le Lun 30 Avr 2018 - 18:32, édité 2 fois
Revenir en haut Aller en bas
http://shiny3d.de
silverman

silverman


Nombre de messages : 970
Age : 52
Localisation : Picardie
Date d'inscription : 18/03/2015

[english]Inline assembler convert real to float and OpenGL Empty
MessageSujet: Re: [english]Inline assembler convert real to float and OpenGL   [english]Inline assembler convert real to float and OpenGL EmptyLun 30 Avr 2018 - 12:39

hello

Not work : error 70, label not defined at line 44

EDIT : work now Wink
Impressive!
Revenir en haut Aller en bas
papydall

papydall


Nombre de messages : 7017
Age : 74
Localisation : Moknine (Tunisie) Entre la chaise et le clavier
Date d'inscription : 03/03/2012

[english]Inline assembler convert real to float and OpenGL Empty
MessageSujet: Re: [english]Inline assembler convert real to float and OpenGL   [english]Inline assembler convert real to float and OpenGL EmptyLun 30 Avr 2018 - 17:05

Hi d.j.peters.

I am very happy to see you back on the Forum after a few years of absence.
You do beautiful things even if I can't understand everything.

Integrate assembler code into Panoramic code!
That's an excellent perspective!

Well done.
I look forward to reading to you again.
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Contenu sponsorisé





[english]Inline assembler convert real to float and OpenGL Empty
MessageSujet: Re: [english]Inline assembler convert real to float and OpenGL   [english]Inline assembler convert real to float and OpenGL Empty

Revenir en haut Aller en bas
 
[english]Inline assembler convert real to float and OpenGL
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» English versions of the EliP 5 and EliP 6 editor.
» HViever - comment gérer les attributs CSS inline ?
» [english] SYNEDIT How to set the keywords ?
» [solved english]PANORAMIC_EDITOR.exe does not work anymore !
» [solved english] color = 2d_point(x,y) ?

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC :: PANORAMIC :: Vos sources, vos utilitaires à partager-
Sauter vers: