flat assembler
Message board for the users of flat assembler.

Index > Windows > OPENGL STATS DISPLAYER

Author
Thread Post new topic Reply to topic
cubeoid



Joined: 22 Jan 2007
Posts: 19
cubeoid 18 Jul 2007, 01:12
Hi can someone help me with the function glgetstring its becoming a bit of a problem. Thanks in advanced.

Code:

format PE GUI 4.0
entry WINMAIN

include '%fasminc%\win32a.inc'
include '%fasminc%\equates\kernel32.inc'
include '%fasminc%\equates\gdi32.inc'
include '%fasminc%\equates\user32.inc'
include '%fasminc%\equates\opengl32.inc'

ID_VENDOR = 101
ID_RENDERER = 102
ID_VERSION = 103

section '.data' data readable writeable

  
section '.code' code readable executable

proc WINMAIN  hinstance, hprevinstance, lpcmdline, ncmdshow
     invoke  GetModuleHandle, 0
     invoke  DialogBoxParam, eax, 37, HWND_DESKTOP, DialogProc, 0
      invoke  ExitProcess, 0
endp



proc DialogProc hwnddlg, msg, wparam, lparam
     local hdc:DWORD, ps:PAINTSTRUCT

     .if     [msg], e, WM_INITDIALOG
      
            ;duno wat todo here please help(whats below is wrong) 
              ;invoke glGetString,GL_VENDOR
           ;invoke SetDlgItemText ,[hwnddlg], ID_VENDOR,eax
                ;invoke glGetString,GL_RENDERER
         ;invoke SetDlgItemText ,[hwnddlg], ID_RENDERER,eax
              ;invoke glGetString,GL_VERSION
              ;invoke SetDlgItemText ,[hwnddlg], ID_VERSION,eax
       ret

     .elseif [msg], e, WM_CLOSE
          invoke  EndDialog,[hwnddlg],0
       return  0
     .endif

     return  0
endp

section '.rsrc' resource data readable

  directory RT_DIALOG, dialogs, RT_MANIFEST, manifest

  resource dialogs, 37, LANG_ENGLISH + SUBLANG_DEFAULT, demonstration
  resource  manifest, 1, LANG_NEUTRAL, xpstyle

  dialog demonstration,'Information',70,70,254, 67,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME,\
  NULL, NULL, "Tahoma", 8
     dialogitem 'BUTTON','OpenGL Info',-1,7,7,240,53,WS_VISIBLE+BS_GROUPBOX
        
    dialogitem 'STATIC','Vendor:',-1,13,19,26,8,WS_VISIBLE
      dialogitem 'STATIC','Renderer:',-1,13,32,32,8,WS_VISIBLE
    dialogitem 'STATIC','GL Version:',-1,13,44,38,8,WS_VISIBLE
  
    dialogitem 'STATIC',ID_VENDOR,-1,62,19,130,8,WS_VISIBLE
   dialogitem 'STATIC',ID_RENDERER,-1,62,32,134,8,WS_VISIBLE
         dialogitem 'STATIC',ID_VERSION,-1,62,44,131,8,WS_VISIBLE
  enddialog

  resdata xpstyle
    file '%fasminc%\winxpstyle.xml'
  endres

section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
      user32,'USER32.DLL',\
    gdi32,'GDI32.DLL'

  include '%fasminc%\apia\kernel32.inc'
  include '%fasminc%\apia\user32.inc'
  include '%fasminc%\apia\gdi32.inc'
  include '%fasminc%\apia\opengl32.inc'
    


o and i am using madmatts include's.
Thanks again
Post 18 Jul 2007, 01:12
View user's profile Send private message Reply with quote
cubeoid



Joined: 22 Jan 2007
Posts: 19
cubeoid 18 Jul 2007, 11:32
here is what it looks like in c

Code:
SetDlgItemText(hwnddlg, ID_VENDOR, (const char *)glGetString(GL_VENDOR));    


i dont know how to convert this into asm
Post 18 Jul 2007, 11:32
View user's profile Send private message Reply with quote
FrozenKnight



Joined: 24 Jun 2005
Posts: 128
FrozenKnight 18 Jul 2007, 11:51
cubeoid wrote:
here is what it looks like in c

Code:
SetDlgItemText(hwnddlg, ID_VENDOR, (const char *)glGetString(GL_VENDOR));    


i dont know how to convert this into asm


i think it's done like this.
Code:
push  dword 0x1F00 ;GL_VENDOR value looked up from msvc++ 6.0 gl.h
call  [glGetString]
push  eax
push  ID_VENDOR
push  hwnddlg
call  [SetDlgItemText]    
Post 18 Jul 2007, 11:51
View user's profile Send private message Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 138
SFeLi 18 Jul 2007, 13:03
cubeoid, afaik, you cannot use any OpenGL function without creating OpenGL rendering context first.
Post 18 Jul 2007, 13:03
View user's profile Send private message Reply with quote
cubeoid



Joined: 22 Jan 2007
Posts: 19
cubeoid 18 Jul 2007, 13:29
It still doesnt work??? thanks though

Code:
; DialogBox example
format PE GUI 4.0
entry WINMAIN

include 'C:\fasm\INCLUDE\win32a.inc'
include 'C:\fasm\INCLUDE\equates\kernel32.inc'
include 'C:\fasm\INCLUDE\equates\gdi32.inc'
include 'C:\fasm\INCLUDE\equates\user32.inc'
include 'C:\fasm\INCLUDE\equates\opengl32.inc'

ID_VENDOR = 501
ID_RENDERER = 502
ID_VERSION = 503

;ID_WINDOWRES = 601
section '.data' data readable writeable

   pfd PIXELFORMATDESCRIPTOR ,0,1,PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER,PFD_TYPE_RGBA,32,0,0,0,0,0,0,0,0,0,0,0,16,8,0,0,0,0,0,0

   hdc        dd ?
   hrc  dd ?
   npf  dd ?
  align 4
  
section '.code' code readable executable

proc WINMAIN  hinstance, hprevinstance, lpcmdline, ncmdshow
     invoke  GetModuleHandle, 0
     invoke  DialogBoxParam, eax, 37, HWND_DESKTOP, DialogProc, 0
     invoke  ExitProcess, 0
endp



proc DialogProc hwnddlg, msg, wparam, lparam
     local hdc:DWORD, ps:PAINTSTRUCT

     .if     [msg], e, WM_INITDIALOG
      
    invoke GetDC,[hwnddlg]  
    mov    [hdc],eax
    mov    edi,pfd
      mov    ecx,sizeof.PIXELFORMATDESCRIPTOR shr 2
       xor    eax,eax
      rep    stosd
        mov    [pfd.nSize],sizeof.PIXELFORMATDESCRIPTOR
     invoke ChoosePixelFormat,[hdc],pfd
  invoke SetPixelFormat,[hdc],eax,pfd
         invoke wglCreateContext,[hdc]
       mov    [hrc],eax
    invoke wglMakeCurrent,[hdc],[hrc]
   
    ;invoke SetDlgItemText,hwnddlg,GL_VENDOR,[glGetString,GL_VENDOR]
    push  dword 0x1F00 ;GL_VENDOR value looked up from msvc++ 6.0 gl.h
  call  [glGetString]
         push  eax
   push  ID_VENDOR
     push  [hwnddlg]
     call  [SetDlgItemText]
      
            ;duno wat todo here please help(whats below is wrong) 
              ;invoke glGetString,GL_VENDOR
           ;invoke SetDlgItemText ,[hwnddlg], ID_VENDOR,0
          ;invoke glGetString,GL_RENDERER
         ;invoke SetDlgItemText ,[hwnddlg], ID_RENDERER,eax
              ;invoke glGetString,GL_VERSION
              ;invoke SetDlgItemText ,[hwnddlg], ID_VERSION,eax
       ret

     .elseif [msg], e, WM_CLOSE
          invoke  EndDialog,[hwnddlg],0
       return  0
     .endif

     return  0
endp

section '.rsrc' resource data readable

  directory RT_DIALOG, dialogs, RT_MANIFEST, manifest

  resource dialogs, 37, LANG_ENGLISH + SUBLANG_DEFAULT, demonstration
  resource  manifest, 1, LANG_NEUTRAL, xpstyle

  dialog demonstration,'Settings',70,70,254, 67,WS_CAPTION+WS_POPUP+WS_SYSMENU+DS_MODALFRAME,\
     NULL, NULL, "Tahoma", 8
     dialogitem 'BUTTON','OpenGL Info',-1,7,7,240,53,WS_VISIBLE+BS_GROUPBOX
        
    dialogitem 'STATIC','Vendor:',-1,13,19,26,8,WS_VISIBLE
      dialogitem 'STATIC','Renderer:',-1,13,32,32,8,WS_VISIBLE
    dialogitem 'STATIC','GL Version:',-1,13,44,38,8,WS_VISIBLE
  
    dialogitem 'STATIC',ID_VENDOR,-1,62,19,130,8,WS_VISIBLE
   dialogitem 'STATIC',ID_RENDERER,-1,62,32,134,8,WS_VISIBLE
         dialogitem 'STATIC',ID_VERSION,-1,62,44,131,8,WS_VISIBLE
  
    ;dialogitem 'BUTTON','Resolution Settings',-1,7,65,175,50,WS_VISIBLE+BS_GROUPBOX
        ;dialogitem 'STATIC','Windowed:',-1,13,80,38,8,WS_VISIBLE
   ;dialogitem  "COMBOBOX", -1, ID_WINDOWRES, 62,78,90,8, WS_VISIBLE or CBS_DROPDOWN or CBS_SORT or WS_VSCROLL or WS_TABSTOP, 0 
  enddialog

  resdata xpstyle
    file 'C:\fasm\INCLUDE\winxpstyle.xml'
  endres

section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
     user32,'USER32.DLL',\
    opengl32,'OPENGL32.DLL',\
        gdi32,'GDI32.DLL'

  include 'C:\fasm\INCLUDE\apia\kernel32.inc'
  include 'C:\fasm\INCLUDE\apia\user32.inc'
  include 'C:\fasm\INCLUDE\apia\gdi32.inc'
  include 'C:\fasm\INCLUDE\apia\opengl32.inc'
    


here ill post the c example aswell

Code:
case WM_INITDIALOG:
                    {
            int nPF;
            HDC hDC;                        // Dialogs device context
            HGLRC hRC;
            DEVMODE devMode;
                   unsigned int iMode;
                 unsigned int nWidth;    // Current settings
                 unsigned int nHeight;
                       char cBuffer[64];
                   HWND hListBox;
                      
                    PIXELFORMATDESCRIPTOR pfd = {   // Not going to be too picky
                   sizeof(PIXELFORMATDESCRIPTOR),
                      1,
                  PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
                 PFD_TYPE_RGBA,          // Full color
                       32,                                     // Color depth
                      0,0,0,0,0,0,0,          // Ignored
                  0,0,0,0,                    // Accumulation buffer
                  16,                                     // Depth bits
                       8,                                      // Stencil bits
                     0,0,0,0,0,0 };             // Some used, some not


            // Initialize render options
                  startupOptions.bFSAA = FALSE;
                       startupOptions.bFullScreen = FALSE;
                 startupOptions.bVerticalSync = FALSE;

                   // Create a "temporary" OpenGL rendering context
                  hDC = GetDC(hDlg);
          
                    // Set pixel format one time....
                    nPF = ChoosePixelFormat(hDC, &pfd);
                     SetPixelFormat(hDC, nPF, &pfd);
                 DescribePixelFormat(hDC, nPF, sizeof(PIXELFORMATDESCRIPTOR), &pfd);

                 // Create the GL context
                    hRC = wglCreateContext(hDC);
                        wglMakeCurrent(hDC, hRC);

                       // Set text in dialog
                       SetDlgItemText(hDlg, IDC_VENDOR, (const char *)glGetString(GL_VENDOR));
                     SetDlgItemText(hDlg, IDC_RENDERER, (const char *)glGetString(GL_RENDERER));
                 SetDlgItemText(hDlg, IDC_VERSION, (const char *)glGetString(GL_VERSION));
    
Post 18 Jul 2007, 13:29
View user's profile Send private message Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 138
SFeLi 18 Jul 2007, 18:27
Code:
;Look at macro/resource.inc:
macro dialogitem class,title,id,x,y,cx,cy,style,exstyle
;so, line
dialogitem 'STATIC',ID_VENDOR,-1,62,19,130,8,WS_VISIBLE
;must be
dialogitem 'STATIC','',ID_VENDOR,62,19,130,8,WS_VISIBLE
    


Description: Here is working source. It compiles with latest fasm, but you MUST set INCLUDE= in your fasmw.ini.
Download
Filename: gl_info.zip
Filesize: 2.29 KB
Downloaded: 220 Time(s)

Post 18 Jul 2007, 18:27
View user's profile Send private message Reply with quote
cubeoid



Joined: 22 Jan 2007
Posts: 19
cubeoid 19 Jul 2007, 01:56
Thank You so much SFeLi.

That solves that.

It still amazes me that with all complicated code (not that this is complicated)
bugs are created from the most basic things.

I cant thank you enough.
Post 19 Jul 2007, 01:56
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.