Closed KubaP closed 3 years ago
Thanks for raising an issue. The problem here is the vertex type V
cannot be inferred by the compiler in your usage. This type is generic to accommodate generating & caching any kind of vertex data.
This works in the examples because rustc can infer the vertex type from the process_queued
call, as this includes a vertex generator function.
(This is similar to let mut vec = Vec::new();
not working until you add a vec.push(123_u32);
line to inform rustc the generic type.)
GlyphBrush
has 4 generic types, which is a lot. It's more complex than I'd like but it's grown this way so as to be a more flexible tool.
The most direct fix for you would to be provide the vertex & "extra" types to the builder that cannot be inferred.
type Vertex = (); // todo
let mut glyph_brush = GlyphBrushBuilder::using_font(typeface).build::<Vertex, Extra>();
It sounds like we can improve the documentation of these generic types, do you think this would help?
How about #136?
I've added documentation for each of the generic types & provided the above workaround in the previously sparse GlyphBrushBuilder::build
docs.
Yeah, that does clear a few things up. I didn't realise that the V
generic is meant to be my own type; I thought it was something part of the crate. Regarding documentation, I think the example could be more clearly documented, because it's a fair mix of this crates apis, your own types, and some basic opengl abstractions, which gets a bit confusing to understand.
I'll further get back on this topic once I've gotten a basic example working; I'm using glow
rather than gl-rs
so I'm having to adapt some of the opengl stuff which is taking time.
That's fair. Having a low-level opengl example has proved useful and fairly easy to maintain, however there is a lot of complexity there as opengl is fundamentally quite complex. I'd be happy to accept doc improvements there or anywhere else.
No, definitely. I'll submit some improvements at some point; once I've figured out how to translate that example into my own codebase/opengl abstraction and fully understood what's going on. Turns out font rendering is pretty complex huh.
I'll preface this by saying that I could be doing something wrong, but I've approached this just like any other crate; include it, build it, and then try to get an example working.
This is the point I've gotten stuck at, loading a font: line 65 of example.
I've written the following:
And I get the following error:
That example doesn't include any type annotations at all. I have looked through the docs, and for the life of me I cannot figure out the type annotation required. There are no examples aside from this one.
I've managed to get something to compile by using a
FontArc
instead of aFontRef
, and type annotatingGlyphBrush<GlyphVertex>
but that isn't what the example is showing. What's going wrong?