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

Added GLFW specific functionality from GLWindow.jl #118

Closed
wants to merge 6 commits into from

Conversation

louisponet
Copy link
Contributor

@louisponet louisponet commented Dec 28, 2017

  • moved functions from glfw3.jl to functions.jl
  • moved types from glfw3.jl to types.jl
  • moved globals from glfw3.jl to constants.jl
  • move gl_createcontext out of GLWindow.jl/screen.jl to a constructor for Window.
  • Added a lot of Window related functionality from GLWindow.jl/screen.jl,types.jl,core.jl to types.jl.
  • Added MonitorProperties from GLWindow.jl/types.jl to types.jl
  • Changed MonitorProperties so it doesn't depend on GeometryTypes: Vec hit in performance shouldn't matter imo.
  • Added general GLFW.jl related functionality from GLWindow/screen.jl,core.jl to extensions.jl

Tests work, also ran the tests for the pullrequest in GLWindow.jl

General Idea: Firstly, splitting pure GLFW.jl related functionality from GLWindow.jl will allow it to be less backend specific, and act as a interface to different OpenGL window/context providers. This is in light of hopefully seperating Windowing functionality in 'GLWindow' from GLAbstraction.jl and provide more of an API experience.
Secondly, I understand this makes the package no-longer a barebones wrap around the GLFW library, but was it really purely that to begin with, and would people not use the added functionality that only depends on GLFW if it is there?

Made it so MonitorProperties doesn't depend on GeometryTypes, I think for performance its ok. If something constructs it without using the constructor there might be some trouble in current implementations
Copy link
Member

@jayschwa jayschwa left a comment

Choose a reason for hiding this comment

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

Reorganizing files makes it hard to review the functional changes. Please do either one or the other in this PR.

For file reorganization, I think it makes more sense to group things by functionality (e.g. context, input, window, etc) rather than by kind (e.g. functions, types, constants). http://www.glfw.org/docs/latest/modules.html groups API names by functionality and can probably inform a reorg.

@louisponet
Copy link
Contributor Author

louisponet commented Dec 28, 2017

I agree on functionality over "kind". Wouldn't this create a lot of very small files?

@jayschwa
Copy link
Member

Thanks for dialing back the file reorg. It will make the other changes easier to digest.

src/glfw3.jl Outdated
props = MonitorProperties(GetPrimaryMonitor())
w,h = props.videomode.width, props.videomode.height
# Vec(Int(w),Int(h))
Vector([Int(w),Int(h)])
Copy link
Member

Choose a reason for hiding this comment

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

Just return (Int(w), Int(h))

This should keep previous functionality without depending on GeometryTypes, with the same performace as well
Copy link
Member

@jayschwa jayschwa left a comment

Choose a reason for hiding this comment

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

Removing the ceremony from changing window properties and including saner defaults seems good. Some of the other additions aren't obvious wins to me, so I requested removal. I'm open to having them added in future PRs where they can be debated.

If this gets merged, I'll probably still tweak things a bit before cutting a new release.

src/glfw3.jl Outdated
@@ -1,4 +1,4 @@
#************************************************************************
************************************************************************
Copy link
Member

Choose a reason for hiding this comment

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

Fix comment by re-adding #.

src/glfw3.jl Outdated

function poll_glfw()
PollEvents()
end
Copy link
Member

Choose a reason for hiding this comment

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

Remove this function. It is not adding value.

src/glfw3.jl Outdated
Integer: The number of the Monitor to Select
Bool: if true, primary monitor gets fullscreen, false no fullscren (default)
GLFW.Monitor: Fullscreens on the passed monitor
"""
Copy link
Member

Choose a reason for hiding this comment

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

Remove this function. It appears to be unused.

src/glfw3.jl Outdated
KEY_UP == b && return :up
end
return :nothing
end
Copy link
Member

Choose a reason for hiding this comment

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

Remove this function. It appears to be unused.

src/glfw3.jl Outdated

MakeContextCurrent(window)

debugging && glDebugMessageCallbackARB(_openglerrorcallback, C_NULL)
Copy link
Member

Choose a reason for hiding this comment

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

glDebugMessageCallbackARB appears to be undefined. This line might need to be removed.

src/glfw3.jl Outdated
window.handle == C_NULL && return
SwapBuffers(window)
return
end
Copy link
Member

Choose a reason for hiding this comment

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

Remove this function. It's not adding enough value in my opinion.

src/glfw3.jl Outdated
(Symbol(last(split(string(f),"."))), f(window))
end
Dict{Symbol, Any}(tmp)
end
Copy link
Member

Choose a reason for hiding this comment

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

Remove this function (for now). I think it's a little too magical.

src/glfw3.jl Outdated

function Base.resize!(x::Window, w::Integer, h::Integer)
SetWindowSize(x, w, h)
end
Copy link
Member

Choose a reason for hiding this comment

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

Remove this function (for now). The documented description of resize! is for collections, so using it here seems a bit off. The alternative (calling SetWindowSize) isn't any longer.

src/glfw3.jl Outdated
function Base.isopen(window::Window)
window.handle == C_NULL && return false
!WindowShouldClose(window)
end
Copy link
Member

Choose a reason for hiding this comment

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

Remove this function (for now). "is open" and "should not close" are two different concepts in my opinion, and the alternative can still be done in one line.

I agree on all of the comments. Some of the functions aren't used/belong somewhere else like you correctly assessed! I will make sure to pay more attention to these things in the future.
@louisponet
Copy link
Contributor Author

I'm not against any tweaking on your part I'm sure you know better what to do with this package than I do. If you want I can also delete all the annotations I made, like where blocks of code originated from.

Copy link
Member

@jayschwa jayschwa left a comment

Choose a reason for hiding this comment

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

A few changes requested. The annotations don't need to be removed. I like seeing where they came from. Once tests are green, I'll merge and take it from there.

@@ -1,2 +1,3 @@
deps/*
!deps/build.jl

Copy link
Member

Choose a reason for hiding this comment

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

Remove this new line.

src/glfw3.jl Outdated
@@ -269,16 +269,103 @@ end
Base.show(io::IO, m::Monitor) = write(io, "Monitor($(m.handle == C_NULL ? m.handle : GetMonitorName(m)))")

const WindowHandle = Ptr{Void}

Copy link
Member

Choose a reason for hiding this comment

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

Remove this new line.

@@ -298,6 +385,39 @@ immutable GLFWError <: Exception
end
Base.showerror(io::IO, e::GLFWError) = print(io, "GLFWError ($(e.code)): ", e.description)

#Came from GLWindow.jl/types.jl
struct MonitorProperties
Copy link
Member

Choose a reason for hiding this comment

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

Change struct to immutable for Julia 0.5 compatibility.

Copy link
Member

Choose a reason for hiding this comment

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

This request was made irrelevant by #121. However, I couldn't get GitHub to resolve merges through it's UI, so I did it manually and push it to #122.

@jayschwa
Copy link
Member

jayschwa commented Jan 3, 2018

Also, not sure if you care, but GitHub is setting your name to "Unknown" as the author. I believe that can be changed under GitHub settings.

@jayschwa
Copy link
Member

jayschwa commented Jan 5, 2018

Merged via #122. Thanks for the contribution!

@louisponet
Copy link
Contributor Author

Very Good, thanks to you too!

@jayschwa jayschwa closed this Jan 9, 2018
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.

3 participants