gltext icon indicating copy to clipboard operation
gltext copied to clipboard

Library is untested and has no examples

Open pwaller opened this issue 9 years ago • 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 https://github.com/go-gl/gltext/issues/18 https://github.com/go-gl/gltext/issues/19 https://github.com/go-gl/gltext/issues/20 https://github.com/go-gl/gl/issues/58

pwaller avatar Jul 28 '16 08:07 pwaller

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

ghost avatar Jul 28 '16 16:07 ghost

Anyone got an working example of this yet?

fanmanpro avatar Nov 22 '16 16:11 fanmanpro

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

pwaller avatar Nov 26 '16 14:11 pwaller

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.

cmaglie avatar Feb 26 '17 16:02 cmaglie

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

ghost avatar Mar 16 '17 16:03 ghost

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

4ydx avatar May 17 '17 01:05 4ydx

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 https://github.com/go-gl/example/issues/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.

dmitshur avatar May 24 '17 17:05 dmitshur

Agreed.

pwaller avatar May 24 '17 18:05 pwaller

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.

4ydx avatar May 30 '17 05:05 4ydx

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).

dmitshur avatar May 30 '17 22:05 dmitshur

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

4ydx avatar May 31 '17 05:05 4ydx

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.

4ydx avatar Jun 27 '17 04:06 4ydx

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

jakecoffman avatar Mar 07 '18 14:03 jakecoffman