flat assembler
Message board for the users of flat assembler.

Index > Windows > I want to make a graph, OpenGL?

Author
Thread Post new topic Reply to topic
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 29 Apr 2010, 23:09
I read about Collatz conjecture a few weeks ago and have made a few programs for printing out various stats, but I want to make a prog that can make a graph similar to
[img]http://upload.wikimedia.org/wikipedia/commons/b/b9/Collatz-stopping-time.svg[/img]. What should I use, and how what functions should I look up? I'm really only looking for a way to make a simple 2d graph that can be dynamically updated as I find stopping times for different numbers.
Post 29 Apr 2010, 23:09
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 30 Apr 2010, 00:13
That's a 2D graph. Use native win32 api functions or a 2D library such as Cairo.
Post 30 Apr 2010, 00:13
View user's profile Send private message Yahoo Messenger Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 30 Apr 2010, 06:54
To setup Win32::OpenGL and plot a pixel in FASM...
http://board.flatassembler.net/download.php?id=4578
Post 30 Apr 2010, 06:54
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 30 Apr 2010, 09:39
Ok, so here is very basic way to use GDI to set pixel color...
Code:

format PE GUI 4.0
entry WinMain

include 'WIN32A.INC'

section '.code' code readable executable

   WinMain:

        invoke  GetModuleHandle,NULL
        mov     [wndclass.hInstance],eax
        invoke  LoadIcon,0,IDI_APPLICATION
        mov     [wndclass.hIcon],eax
        invoke  LoadCursor,NULL,IDC_ARROW
        mov     [wndclass.hCursor],eax
        invoke  RegisterClassEx,wndclass

        invoke  CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,szAppName,szAppName,\
                  WS_OVERLAPPEDWINDOW+WS_VISIBLE,CW_USEDEFAULT,CW_USEDEFAULT,\
                  CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,[wndclass.hInstance],NULL

  .mainloop:
        invoke  GetMessage,msg,NULL,0,0
        cmp     eax,0
        jle     .finished
        invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
        jmp     .mainloop

  .finished:
        invoke  ExitProcess,[msg.wParam]

proc WindowProc hwnd,umsg,wparam,lparam
  local ps:PAINTSTRUCT
        mov     eax,[umsg]
        cmp     eax,WM_PAINT
        je      .wmpaint
        cmp     eax,WM_DESTROY
        je      .wmdestroy
  .defwndproc:
        invoke  DefWindowProc,[hwnd],[umsg],[wparam],[lparam]
        jmp     .finish
  .wmpaint:
        lea     eax,[ps]
        invoke  BeginPaint,[hwnd],eax
        invoke  SetPixel,[ps.hdc],10,10,0x00000000 ; paint black pixel at [x,y]
        lea     eax,[ps]
        invoke  EndPaint,[hwnd],eax
        jmp     .zfinish
  .wmdestroy:
        invoke  PostQuitMessage,0
  .zfinish:
        xor     eax,eax
  .finish:
        ret
endp

section '.data' data readable writeable

  szAppName db 'dib',0

  wndclass WNDCLASSEX sizeof.WNDCLASSEX,CS_OWNDC,WindowProc,\
    0,0,NULL,NULL,NULL,(COLOR_WINDOW+1),NULL,szAppName,NULL

  msg MSG

section '.idata' import data readable

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

  include 'API\KERNEL32.INC'
  include 'API\USER32.INC'
  include 'API\GDI32.INC'
    
Post 30 Apr 2010, 09:39
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 30 Apr 2010, 11:02
Image
Post 30 Apr 2010, 11:02
View user's profile Send private message Visit poster's website Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 01 May 2010, 02:55
edfed, how did you do that?
Post 01 May 2010, 02:55
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 01 May 2010, 04:41
He copied it off the Wiki...
Post 01 May 2010, 04:41
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.