Skip to content

Added GLFW specific functionality from GLWindow.jl#118

Closed
louisponet wants to merge 6 commits into
JuliaGL:masterfrom
louisponet:pull-request/f3a3b2ce
Closed

Added GLFW specific functionality from GLWindow.jl#118
louisponet wants to merge 6 commits into
JuliaGL:masterfrom
louisponet:pull-request/f3a3b2ce

Conversation

@louisponet

@louisponet louisponet commented Dec 28, 2017

Copy link
Copy Markdown
Contributor
  • 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

@jayschwa jayschwa left a comment

Copy link
Copy Markdown
Member

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

louisponet commented Dec 28, 2017

Copy link
Copy Markdown
Contributor Author

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

@jayschwa

Copy link
Copy Markdown
Member

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

Comment thread 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
Copy Markdown
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

@jayschwa jayschwa left a comment

Copy link
Copy Markdown
Member

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.

Comment thread src/glfw3.jl Outdated
@@ -1,4 +1,4 @@
#************************************************************************
************************************************************************

Copy link
Copy Markdown
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 #.

Comment thread src/glfw3.jl Outdated

function poll_glfw()
PollEvents()
end

Copy link
Copy Markdown
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.

Comment thread 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
Copy Markdown
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.

Comment thread src/glfw3.jl Outdated
KEY_UP == b && return :up
end
return :nothing
end No newline at end of file

Copy link
Copy Markdown
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.

Comment thread src/glfw3.jl Outdated

MakeContextCurrent(window)

debugging && glDebugMessageCallbackARB(_openglerrorcallback, C_NULL)

Copy link
Copy Markdown
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.

Comment thread src/glfw3.jl Outdated
window.handle == C_NULL && return
SwapBuffers(window)
return
end

Copy link
Copy Markdown
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.

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

Copy link
Copy Markdown
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.

Comment thread src/glfw3.jl Outdated

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

Copy link
Copy Markdown
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.

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

Copy link
Copy Markdown
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
Copy Markdown
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.

@jayschwa jayschwa left a comment

Copy link
Copy Markdown
Member

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.

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

Copy link
Copy Markdown
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.

Comment thread src/glfw3.jl Outdated
Base.show(io::IO, m::Monitor) = write(io, "Monitor($(m.handle == C_NULL ? m.handle : GetMonitorName(m)))")

const WindowHandle = Ptr{Void}

Copy link
Copy Markdown
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.

Comment thread src/glfw3.jl
Base.showerror(io::IO, e::GLFWError) = print(io, "GLFWError ($(e.code)): ", e.description)

#Came from GLWindow.jl/types.jl
struct MonitorProperties

Copy link
Copy Markdown
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
Copy Markdown
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

jayschwa commented Jan 3, 2018

Copy link
Copy Markdown
Member

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

jayschwa commented Jan 5, 2018

Copy link
Copy Markdown
Member

Merged via #122. Thanks for the contribution!

@louisponet

Copy link
Copy Markdown
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