flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Fred
Been toying with openGL and trying to do 2D tile drawing and looked at this page for tips. According to this dood I can use gluOrtho2D (or glOrtho i guess) to set up a nice coordinate system thing on my window. But... well. It's not working. Setting glOrtho to anything but a square makes the screen go black and setting it to a square does nothing (screen coords remain as -1 to 1). I have no idea how to fix it.
![]() The reason i'm posting about openGL problems here is because I'm not sure if the error springs from my unawesome asm code or if my openGL knowledge is lacking... help is appreciated. ![]() Here's my current code: http://pastebin.com/g6H8nVnS (glOrtho is on line 123, and most of my other openGL code is around there too) And if you want to run it: used includes and the image. Just put the folder in the fasm include folder and yeah.raw in the same folder as the code. I have ninja'd code from various places (but mostly from here). And I'll say this now... I have never used openGL before. ![]() |
|||
![]() |
|
SFeLi
Both gluOrtho2D and glOrtho accept double arguments and you're passing floats. Include win32ax.inc instead of win32a.inc and prefix arguments with 'double' keyword.
|
|||
![]() |
|
Xorpd!
You have to handle the WM_SIZE message and set your viewport there.
|
|||
![]() |
|
Xorpd!
Your reply has piqued my curiosity: did you finally come up with something that worked but yet did not handle the WM_SIZE message? Could you post your working example?
|
|||
![]() |
|
Fred
Hmm, well, all I did was copying the openGL example:
Code: cmp [wmsg],WM_CREATE je .wmcreate cmp [wmsg],WM_SIZE je .wmsize [...] .wmcreate: invoke GetDC,[hwnd] mov [hdc],eax mov edi,pfd mov ecx,sizeof.PIXELFORMATDESCRIPTOR shr 2 xor eax,eax rep stosd mov [pfd.nSize],sizeof.PIXELFORMATDESCRIPTOR mov [pfd.nVersion],1 mov [pfd.dwFlags],PFD_SUPPORT_OPENGL+PFD_DOUBLEBUFFER+PFD_DRAW_TO_WINDOW mov [pfd.iLayerType],PFD_MAIN_PLANE mov [pfd.iPixelType],PFD_TYPE_RGBA mov [pfd.cColorBits],16 mov [pfd.cDepthBits],16 mov [pfd.cAccumBits],0 mov [pfd.cStencilBits],0 invoke ChoosePixelFormat,[hdc],pfd invoke SetPixelFormat,[hdc],eax,pfd invoke wglCreateContext,[hdc] mov [hrc],eax invoke wglMakeCurrent,[hdc],[hrc] invoke GetClientRect,[hwnd],rc invoke glViewport,0,0,[rc.right],[rc.bottom] invoke GetTickCount mov [clock],eax xor eax,eax jmp .finish .wmsize: invoke GetClientRect,[hwnd],rc invoke glViewport,0,0,[rc.right],[rc.bottom] xor eax,eax jmp .finish [...] Since the viewport is set up in .wmcreate i went ahead and removed the .wmsize section. For some reason I can't resize the window, so .wmsize would do nothing anyway. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.