Giter Club home page Giter Club logo

Comments (8)

emberian avatar emberian commented on August 16, 2024

We could use libc::uintptr_t/libc::intptr_t instead of hardcoding
GLsizeiptr ourselves. It's just a typedef for i32/i64 but you can cast
to it and it will Just Work.

On Mon, Aug 25, 2014 at 4:00 AM, Cameron Hart [email protected]
wrote:

I've written some code that uses gl::BufferData. On Linux 64 bit the
buffer size parameter is i64 but on Windows 32 bit it's i32. It seems like
the size parameter should actually be int (or uint even) so that calling
code is portable between 32 and 64 bit architectures.


Reply to this email directly or view it on GitHub
#148.

http://octayn.net/

from gl-rs.

bitshifter avatar bitshifter commented on August 16, 2024

On further investigation this looks like a Rust issue. This is the relevant bug rust-lang/rust#11447. As detailed in the bug, I can work around it by casting to GLsizeiptr which ends up being the right size on 32 and 64 bit platforms. It's just a bit confusing because Rust's error message doesn't mention GLsizeiptr at all if you're using the wrong type, it will say i32 or i64 depending on platform which means the first thing you try is cast to i32 or i64 only to discover it breaks when you cross compile.

The code in question where I was having this problem looks like so:

gl::BufferData(gl::ELEMENT_ARRAY_BUFFER, index_data_size as GLsizeiptr, mem::transmute(index_data.as_ptr()), gl::STATIC_DRAW);

In my case index_data_size was a uint. The error I would get without the cast was "error: mismatched types: expected i64 but found uint (expected i64 but found uint)". Thus my confusion.

I guess this isn't a bug, it's more of a usability problem. You are probably best off sticking with Rust's ptrdiff_t for the same reasons they've stuck with it.

from gl-rs.

bitshifter avatar bitshifter commented on August 16, 2024

Sorry @cmr I didn't see your comment before replying. I found what seems like an acceptable work around to me, it might be nice if the Rust compile error was less misleading.

from gl-rs.

brendanzab avatar brendanzab commented on August 16, 2024

@cmr perhaps we need conditional compilation there?

from gl-rs.

brendanzab avatar brendanzab commented on August 16, 2024

It is currently set to c_int: https://github.com/bjz/gl-rs/blob/master/src/gl_generator/ty.rs#L262

from gl-rs.

emberian avatar emberian commented on August 16, 2024

c_int itself is conditionally defined, it's probably fine as long as you
cast to it. still annoying...

On Tue, Aug 26, 2014 at 9:53 AM, Brendan Zabarauskas <
[email protected]> wrote:

It is currently set to c_int:
https://github.com/bjz/gl-rs/blob/master/src/gl_generator/ty.rs#L262


Reply to this email directly or view it on GitHub
#148 (comment).

http://octayn.net/

from gl-rs.

brendanzab avatar brendanzab commented on August 16, 2024

Yeah, the issue is the error that mentions the base type, and not the alias. When I work with C APIs I always do as libc::c_foo, but I see plenty of PRs that instead cast to i32 etc....

from gl-rs.

emberian avatar emberian commented on August 16, 2024

Yeah. I think this is just a Rust bug. It "erases" the type definition too
soon for nice errors.

On Tue, Aug 26, 2014 at 10:17 AM, Brendan Zabarauskas <
[email protected]> wrote:

Yeah, the issue is the error that mentions the base type, and not the
alias.


Reply to this email directly or view it on GitHub
#148 (comment).

http://octayn.net/

from gl-rs.

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.