Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SDL2 backend #32

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

Srinivasa314
Copy link

@Srinivasa314 Srinivasa314 commented Aug 5, 2020

CzechBlueBear/NonEuclidean adds support for SDL2 backend but unfortunately it is has a lot of bugs. This pull request will merge changes from his repo with the following changes

  • Fix white screen due to error in shaders
  • Fix number key input
  • Fix windows build error
  • Add Esc and Alt-Enter keyboard shortcuts
  • Make mouse be grabbed and hidden
  • Do keypress handling in SDL eventloop
  • Updated README to include SDL
  • Use reference for cur_ticks
  • Remove redeclaration of SwapBuffers
  • Compile in release mode
  • Update .gitignore

@y4my4my4m
Copy link

@Srinivasa314 this compiles and runs with no problems, however:

  1. input delay / strange input behaviour

  2. the window doesnt open on the main monitor but at 0,0 coordinate and cant really be readjusted

@Srinivasa314
Copy link
Author

Srinivasa314 commented Sep 13, 2020

  1. input delay / strange input behaviour

I am not entirely sure. This is what I think.
The player continues to move for a while after input is stopped because it takes some time for friction to stop it. If you increase the friction value then the player stops immediately after input is stopped.

  1. the window doesnt open on the main monitor but at 0,0 coordinate and cant really be readjusted

Fixed it. Now window is centered.

@y4my4my4m
Copy link

  1. input delay / strange input behaviour

I am not entirely sure. This is what I think.
The player continues to move for a while after input is stopped because it takes some time for friction to stop it. If you increase the friction value then the player stops immediately after input is stopped.

  1. the window doesnt open on the main monitor but at 0,0 coordinate and cant really be readjusted

Fixed it. Now window is centered.

Centering works great now!

Initial input has a good 9 seconds delay though, but if this doesn't happen on your end it may just be my environment.

Copy link

@y4my4my4m y4my4my4m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Srinivasa314 LGTM! 👍

@HackerPoet

You should consider merging this PR! :)

@hamdav
Copy link

hamdav commented Mar 11, 2021

I found that compiling on mac I had to change the -lGL flag to -framework OpenGl. Even then though it compiled fine but I got segmentation fault when running it. Compiling on Arch linux worked fine, the only thing is that I could not move my mouse and walk at the same time.

@Srinivasa314
Copy link
Author

I found that compiling on mac I had to change the -lGL flag to -framework OpenGl

Fixed it

Even then though it compiled fine but I got segmentation fault when running it

I do not have a mac. Can you show the stacktrace?

Compiling on Arch linux worked fine, the only thing is that I could not move my mouse and walk at the same time.

I think it is because in some desktop environments you cannot use the keyboard and the mouse at the same time. If it is because of that then you can change that setting.

@hamdav
Copy link

hamdav commented Mar 14, 2021

No trace, just segmentation fault (core dumped) I think...

@Srinivasa314
Copy link
Author

You can use lldb or any other debugger to get the stack trace. Add -g to CXXFLAGS in the Makefile before compiling so that more information will be available to the debugger.

@hamdav
Copy link

hamdav commented Mar 14, 2021

It says

2021-03-14 19:16:24.091865+0100 NonEuclidean[62142:2193080] SecTaskLoadEntitlements failed error=22 cs_flags=20, pid=62142
2021-03-14 19:16:24.091957+0100 NonEuclidean[62142:2193080] SecTaskCopyDebugDescription: NonEuclidean[62142]/0#-1 LF=0
2021-03-14 19:16:24.350535+0100 NonEuclidean[62142:2193080] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x10052c560> F8BB1C28-BAE8-11D6-9C31-00039315CD46
Process 62142 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000000000000
error: memory read failed for 0x0
Target 0: (NonEuclidean) stopped.

I also have to add -std=c++11 for it to compile btw, it complains about a bunch of stuff otherwise and gives an error that

error: a space is required between consecutive
      right angle brackets (use '> >')

@Srinivasa314
Copy link
Author

I think I fixed it. Check if it works now.

rm ${OBJS}

${EXE}: ${OBJS}
${LINK} ${LINKFLAGS} $^ -o ${EXE}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After lone debug, In my ubuntu20, I found that L38 change to this could work.

	${LINK} $^ ${LINKFLAGS} -o ${EXE}

@rsmath
Copy link

rsmath commented Sep 10, 2022

Hello, where can I get the code that compiles and works on mac please? Thank you.

@rsmath
Copy link

rsmath commented Sep 11, 2022

@Srinivasa314 @Srikanth-M-02 could you please tell me how to get the code that will run on Mac?

@Srinivasa314
Copy link
Author

Srinivasa314 commented Sep 11, 2022

  1. Download xcode command line tools
  2. install glew and sdl2 (you can use brew install)
  3. git clone https://github.com/Srinivasa314/NonEuclidean then cd NonEuclidean/NonEuclidean
  4. export CPATH="/opt/homebrew/Cellar/glew/2.2.0_1/include/:/opt/homebrew/Cellar/sdl2/2.24.0/include/"
    export LIBRARY_PATH="/opt/homebrew/Cellar/sdl2/2.24.0/lib:/opt/homebrew/Cellar/glew/2.2.0_1/lib"
  5. change the above command depending on where glew and sdl2 were installed
  6. run make all
  7. ./NonEuclidean
    As of now scenes 4 and 7 dont work properly on my mac

@Srinivasa314
Copy link
Author

Is it working @ramanshsharma2806 ?

@Srinivasa314
Copy link
Author

Btw scene 4 works if I replace the bunny.obj and suzanne.obj with other obj files
and scene 7 works if I disable GL_LINEAR_MIPMAP_NEAREST and glGenerateMipmap

@Sussy-OS
Copy link

Would PR #26 work with this? Currently, if you were to put glew-2.1.0 in the directory with the .exe, it would fail to build. #26 fixes this. It would be handy, (with permission) to merge that PR into this one.

@ehx-v1
Copy link

ehx-v1 commented Nov 7, 2022

@Sussy-OS They're PRs for the same repo anyway, so the permission should already be implicitly there. Would definitely be great if this worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants