Message board for the users of flat assembler.
> Linux > GLFW example
I just wrote my first ELF64 file that uses GLFW to create a window
I used as a template the example included with fasm located at './examples/elfexe/dynamic/hello64.asm' and used as reference the example code available at https://www.glfw.org/documentation.html.
format ELF64 executable 3 entry start include 'import64.inc' interpreter '/lib64/ld-linux-x86-64.so.2' needed 'libc.so.6' needed 'libGL.so' needed 'libglfw.so' import printf,exit,glfwInit,glfwCreateWindow,glfwTerminate,glfwMakeContextCurrent,glfwWindowShouldClose,glClear,glfwSwapBuffers,glfwPollEvents segment readable executable start: call [glfwInit] cmp rax,1 jne error mov r8,0 mov rcx,0 lea rdx,[msg] mov rsi,480 mov rdi,640 call [glfwCreateWindow] cmp rax,0 je error mov [window], rax mov rdi,[window] call [glfwMakeContextCurrent] waitforclose: mov rdi,[window] ;when using "lea" glfwWindowShouldClose always returned 0 call [glfwWindowShouldClose] cmp rax,0 jne terminate mov rdi,16384 ;GL_COLOR_BUFFER_BIT call [glClear] mov rdi,[window] call [glfwSwapBuffers] call [glfwPollEvents] jmp waitforclose error: lea rdi,[emsg] xor eax,eax call [printf] terminate: call [glfwTerminate] quit: call [exit] segment readable writeable msg db 'a window',0 emsg db 'error',0xa,0 window dq ?
I tried the X11 examples available in the forum but I was getting "segmentation fault" related to 'libxcb.so' and I couldn't identify the issue. That's why I decided to try with that example once I understood what I had to do.
Thanks to the videos that Tomasz uploaded to Youtube I've been able to understand a lot of things that I hadn't until now. I hope he keeps uploading new content!
Any feedback about the code is appreciated. It helps me to learn something new and understand better what's going on
Edit by revolution: Fix documentation link
|29 Feb 2020, 14:05||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.
Website powered by rwasa.