Giter Club home page Giter Club logo

Comments (3)

nsajko avatar nsajko commented on July 30, 2024

xref #51962?

from julia.

jishnub avatar jishnub commented on July 30, 2024

It's probably a different issue, as cconvert is defined for a ReinterpretArray and a pointer may be obtained from it, but a direct unsafe_convert isn't defined anymore. It may simply be a matter of redefining the method, but I wonder if it was removed for a reason.

from julia.

vchuravy avatar vchuravy commented on July 30, 2024

I ran into this just now as well.

 Error: Error in render loop!
│   exception = conversion to pointer not defined for Base.ReinterpretArray{ColorTypes.RGB{Float32}, 2, Float32, Array{Float32, 3}, true}
└ @ NeuralGraphicsGL ~/.julia/packages/NeuralGraphicsGL/5ny5N/src/NeuralGraphicsGL.jl:285

Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] unsafe_convert(::Type{Ptr{ColorTypes.RGB{Float32}}}, a::Base.ReinterpretArray{ColorTypes.RGB{Float32}, 2, Float32, Array{Float32, 3}, true})
    @ Base ./pointer.jl:68
  [3] unsafe_convert(::Type{Ptr{Nothing}}, a::Base.ReinterpretArray{ColorTypes.RGB{Float32}, 2, Float32, Array{Float32, 3}, true})
    @ Base ./pointer.jl:66
  [4] glTexImage2D(target::UInt32, level::Int64, internalformat::UInt32, width::UInt32, height::UInt32, border::Int64, format::UInt32, type_::UInt32, pixels::Base.ReinterpretArray{ColorTypes.RGB{Float32}, 2, Float32, Array{Float32, 3}, true})
    @ ModernGL ~/.julia/packages/ModernGL/yNrOu/src/functionloading.jl:64
  [5] macro expansion
    @ ~/.julia/packages/NeuralGraphicsGL/5ny5N/src/NeuralGraphicsGL.jl:72 [inlined]
  [6] set_data!(t::NeuralGraphicsGL.Texture, data::Base.ReinterpretArray{ColorTypes.RGB{Float32}, 2, Float32, Array{Float32, 3}, true})
    @ NeuralGraphicsGL ~/.julia/packages/NeuralGraphicsGL/5ny5N/src/texture.jl:89
  [7] set_data!
    @ ~/.julia/packages/NeuralGraphicsGL/5ny5N/src/quad.jl:77 [inlined]
  [8] render!(ngui::NerfGUI.NGUI)
    @ NerfGUI ~/src/NerfGUI/src/NerfGUI.jl:206
  [9] loop!(ngui::NerfGUI.NGUI)
    @ NerfGUI ~/src/NerfGUI/src/NerfGUI.jl:446
 [10] #32
    @ ~/src/NerfGUI/src/NerfGUI.jl:213 [inlined]
 [11] render_loop(draw_function::NerfGUI.var"#32#33"{NerfGUI.NGUI}, c::NeuralGraphicsGL.Context; destroy_context::Bool)
    @ NeuralGraphicsGL ~/.julia/packages/NeuralGraphicsGL/5ny5N/src/NeuralGraphicsGL.jl:281
 [12] render_loop
    @ ~/.julia/packages/NeuralGraphicsGL/5ny5N/src/NeuralGraphicsGL.jl:278 [inlined]
 [13] launch!
    @ ~/src/NerfGUI/src/NerfGUI.jl:211 [inlined]
 [14] main()
    @ NerfGUI ~/src/NerfGUI/src/NerfGUI.jl:487

Weirdly enough there is no direct call to unsafe_convert in sight.

https://github.com/JuliaGL/ModernGL.jl/blob/90200d81d1d0194f9855163524ecb499b8f2c881/src/functionloading.jl#L64

julia> @macroexpand ModernGL.@glfunc glTexImage2D(target::GLenum, level::GLint, internalformat::GLint, width::GLsizei, height::GLsizei, border::GLint, format::GLenum, type_::GLenum, pixels::Ptr{Cvoid})::Cvoid
quote
    #= /home/vchuravy/.julia/packages/ModernGL/yNrOu/src/functionloading.jl:59 =#
    const var"##glTexImage2D_func_pointer#231" = Ref{Ptr{Cvoid}}(C_NULL)
    #= /home/vchuravy/.julia/packages/ModernGL/yNrOu/src/functionloading.jl:60 =#
    function glTexImage2D(target, level, internalformat, width, height, border, format, type_, pixels)
        #= /home/vchuravy/.julia/packages/ModernGL/yNrOu/src/functionloading.jl:60 =#
        #= /home/vchuravy/.julia/packages/ModernGL/yNrOu/src/functionloading.jl:61 =#
        if var"##glTexImage2D_func_pointer#231"[]::Ptr{Cvoid} == C_NULL
            #= /home/vchuravy/.julia/packages/ModernGL/yNrOu/src/functionloading.jl:62 =#
            var"##glTexImage2D_func_pointer#231"[]::Ptr{Cvoid} = getprocaddress_e("glTexImage2D")
        end
        #= /home/vchuravy/.julia/packages/ModernGL/yNrOu/src/functionloading.jl:64 =#
        result = ccall(var"##glTexImage2D_func_pointer#231"[]::Ptr{Cvoid}, Cvoid, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, Ptr{Cvoid}), target, level, internalformat, width, height, border, format, type_, pixels)
        #= /home/vchuravy/.julia/packages/ModernGL/yNrOu/src/functionloading.jl:65 =#
        ()
        #= /home/vchuravy/.julia/packages/ModernGL/yNrOu/src/functionloading.jl:66 =#
        result
    end
    #= /home/vchuravy/.julia/packages/ModernGL/yNrOu/src/functionloading.jl:68 =#
    export glTexImage2D
end

-- edit:

cconvert

cconvert(::Type{Ptr{T}}, a::ReinterpretArray{T,N,S} where N) where {T,S} = cconvert(Ptr{S}, a.parent)
is only defined for Ptr{T}

from julia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.