go-gl/gltext

Library is untested and has no examples

pwaller opened this issue ยท 13 comments

This repository is made by enthusiasts. Unfortunately it's not ready-to-ship code, and may require some expertise to use.

We should add some good examples. Unfortunately, neither me nor @jteeuwen (AFAIK) have time to work on this at the moment, so help is welcomed!

Feel free to ping this thread on a frequency less than once/month to show your interest.

Supercedes #18 #19 #20 go-gl/gl#58

Sorry for all the posts on the same matter, I was attempting to get in contact with someone and it seems it has worked. Last night I attempted to use this library and had little luck. I only used loadttffont and printf which is fairly simple but threw errors at runtime. I will continue to play around with the code and post any results

Anyone got an working example of this yet?

Not that I am aware, sorry. The situation is still the same as in the original post.

I'm not an OpenGL expert, I'm just playing a bit and wanted to share my discoveries, here what I've found after some trial-and-error:

To load a font

	fontFile, err := os.Open("Roboto-Light.ttf")
	if err != nil {
		log.Panicf("Open font file: %s", err)
	}
	defer fontFile.Close()
	font, err := gltext.LoadTruetype(fontFile, 25, 32, 127, gltext.LeftToRight)
	if err != nil {
		log.Panicf("LoadTruetype: %s", err)
	}

25 is the font size
32 and 127 are the first and last gliph that should be loaded into the texture used for later rendering (in this case the most common ASCII characters).

In the drawing loop I used the following lines:

	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()

	gl.Color4f(0, 0, 0, 1)
	font.Printf(0, 0, "Hello")

and indeed this is enough to print "Hello" in the top left corner of the screen.

There's also https://github.com/loov/zombies-on-ice containing a great reference on drawing images and font.

4ydx commented

If looking for another example of rendering golang text: https://github.com/4ydx/gltext/tree/master/example

It's been a while and no one stepped up to fix and maintain this library. It's in a poor shape, and without someone actively working on it, it won't get better.

To help maintain a high bar for packages in go-gl namespace, I propose we move this to go-gl-legacy. This will help future people who run into it, and accidentally expect it to be in good shape (e.g., see go-gl/example#63).

If someone wants to actively work on it, they can do so and we can consider moving it back when it's in a good shape.

Agreed.

4ydx commented

I have my own version of gltext at https://github.com/4ydx/gltext. I don't know if it meets expectations in terms of code, but I would be happy take responsibility using that as a starting point. It adds onto what go-gl/gltext does in ways that might not be standard given that I am a novice when it comes to opengl development.

I think for a package to (continue to) reside in go-gl namespace, it should, at minimum, have one active user, and one active maintainer. And when I say active, I mean that an issue or a PR that is posted should get a response within a month by someone willing to deal with it (even if to say "this feature request is out of scope" or "this is a valid bug that needs to be investigated/fixed").

When multiple months go by without any response/activity, that's no longer a package that should continue to be here IMO.

@4ydx, if you're actively using and maintaining your gltext version, we can definitely consider putting it here in place of this gltext. Because this gltext isn't actively maintained and we'll need to move it to go-gl-archive soon (at the current rate).

4ydx commented

Sure if you decide to move the current package into archive and find that mine is palatable then I will maintain it.

4ydx commented

I am eager to have my code be more broadly used as well as to be apart of group collaboration so if my code looks acceptable I would like to have it become the gltext package.

@shurcooL: I second using @4ydx's version, he is responsive to issues.