flat assembler
Message board for the users of flat assembler.
Index
> Windows > Troubles with openGL |
Author |
|
Fred 27 Feb 2011, 20:16
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. Can someone help me?
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. |
|||
27 Feb 2011, 20:16 |
|
Xorpd! 28 Feb 2011, 07:17
You have to handle the WM_SIZE message and set your viewport there.
|
|||
28 Feb 2011, 07:17 |
|
Fred 28 Feb 2011, 13:26
Quote: 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. Oh, didn't think of that! ...It works now! Thank you! I probably wouldn't have come up with that myself. Quote: You have to handle the WM_SIZE message and set your viewport there. Ok. Doesn't work... strange. It should work... Anyway, resizing the window isn't important at the moment, but could come in handy later. *general praise to awesome fasm board users* |
|||
28 Feb 2011, 13:26 |
|
Xorpd! 28 Feb 2011, 20:22
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?
|
|||
28 Feb 2011, 20:22 |
|
Fred 28 Feb 2011, 21:34
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. |
|||
28 Feb 2011, 21:34 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.