Coder Social home page Coder Social logo

g3n / engine Goto Github PK

View Code? Open in Web Editor NEW
2.7K 89.0 289.0 13.03 MB

Go 3D Game Engine (http://g3n.rocks)

Home Page: https://discord.gg/NfaeVr8zDg

License: BSD 2-Clause "Simplified" License

C 25.80% Go 72.44% GLSL 1.76%
golang go game-engine opengl 3d-game-engine 3d-graphics 3d-engine 3d-rendering-engine go-library

engine's People

Contributors

amyadzuki avatar cedarmora avatar countcb avatar cove avatar danaugrs avatar danjpar avatar dobegor avatar etherealmachine avatar fakke avatar innoviox avatar joaoofreitas avatar jordan4ibanez avatar justinclift avatar leonsal avatar leylandski avatar lian avatar mat007 avatar maugre avatar metalim avatar moethu avatar mrwaggel avatar oflebbe avatar quillaja avatar robert-e-davidson3 avatar testwill avatar tgreiser avatar uzudil avatar vasilevp avatar wolfgarnet avatar zyxkad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

engine's Issues

GUI Window Widget Wishlist

I don't know if you get notifications for comments on closed issues, so just a quick note, I replied to #61 and #62 in the comments.

First of all, I am very happy with the current set of functionality, so these are all low priority suggestions. But if you are reworking the window class, I feel like now is the time for me to mention a few ideas I had.

  1. Add an easy way to add an "X" close button widget in the upper right corner of the title bar of a window, on a per-window basis.

    1. Allow us to register our own callback function to run when that close button is clicked, so that we can configure the behavior to not just close the window (maybe we want to ask them to save changes or something).
  2. You mentioned custom cursors for move and resize actions in #62 and I really like that idea! You said you already added it so maybe it doesn't belong on a wishlist...

  3. Add a way to close all open windows programmatically.

    1. Perhaps additionally, a way to toggle all windows visible/invisible would be helpful too. Maybe.
  4. Add methods to easily set the background color of the title bar and of the content area, without having to customize everything at once by using styles.

Ok that's all I could come up with, do with them as you see fit. Thanks for all your hard work on g3n! I really appreciate everything you do :3

[enhancement] Consider adding userdata to Application

rather than the end user embedding an Application in their own struct, it would probably simpler and more accessible to the novice user, to be able to simply add their own blob of info to the Application structure. (similar to Node's userdata)

Can't play Ogg Vorbis file

Hi,

I have an Ogg Vorbis audio file:

% file test.ogg
test.ogg: Ogg data, Vorbis audio, stereo, 48000 Hz, ~160000 bps, created by: Xiph.Org libVorbis I

It plays fine with mpv:

% mpv test.ogg 
Playing: test.ogg
 (+) Audio --aid=1 (vorbis 2ch 48000Hz)
File tags:
 Artist: Vårsol
AO: [pulse] 48000Hz stereo 2ch float
A: 00:00:01 / 00:05:24 (0%)
[...]
Exiting... (Quit)
^C

However, when playing the file with these lines of code, I get a panic:

	// Load Ogg Vorbis library
	err = vorbis.Load()
	if err != nil {
		panic(err)
	}
	fmt.Println(vorbis.VersionString())

	// Load audio
	player, err := audio.NewPlayer("test.ogg")
	if err != nil {
		panic(err)
	}

	// Play audio
	err = player.Play()
	if err != nil {
		panic(err)
	}

This is the output

Xiph.Org libVorbis 1.3.5
panic: Unsuported file type

This is on 64-bit Arch Linux with Go 1.8 and libvorbis 1.3.5 (comes with libvorbisfile: /usr/lib/libvorbisfile.so.3.3.7).

Don't link -ldl on FreeBSD

I'm trying to get any of the demos to work on FreeBSD. I'm pretty new to golang so I can't submit a PR, but linking against -ldl breaks the build on FreeBSD. On Linux, the dynamic loader is in a separate library called libdl but on FreeBSD it is built into the C standard library. I am guessing that the problem is this: in g3n/engine/gls/build.go:12

// #cgo freebsd LDFLAGS: -ldl

should be changed to

// #cgo freebsd LDFLAGS: 

Minor README.md bug?

Reading over the example on the README.md quickly, before trying it out (probably later today), one of the comments seems outdated:

// OpenGL functions must be executed in the same thread where
// the context was created (by window.New())
	runtime.LockOSThread()

On the second line it mentions window.New(), however there isn't a call to window.New() in the example. Should that be window.Manager()?

Small example program showing just a button

Any chance of creating a small example program that just puts a button on the screen, or maybe a line of text?

I have been trying to piece together something like this using the demo program on the g3n git page and pulling in code from the button demo on the demo program git page, but I know nothing about opengl so I have no idea what I'm doing. So far, my attempts at doing this have failed. Since I am mainly interested in using this library for gui programming, I would love to see a simple example program that just throws a button or a label on the screen that would show me how to use just the gui parts of this library.

[enhancement, major] Accordion-style tree GUI widget

  1. Let us mark a tree GUI widget as "accordion style" where only one TreeNode can be opened at a time. Opening a TreeNode when another one is already opened in the same Tree automatically closes the previous one.

  2. It would be especially nice if we could .Subscribe to the opening of a TreeNode and have a callback that we specify called when that TreeNode is opened. I would use this in my character designer to zoom in on the face when you open a TreeNode related to customizing a part of the face (such as "Eyes") and zoom out to show the full character when you open a TreeNode related to the body (such as, well, "Body").

The program does not render examples

I use windows 64. Downloaded the engine from the gitnab and try to run the examples, such as "HelloG3n" or "gopher3d". But only new window appears and shows nothing. Nothing exept the background color. After I close the window programm ends with exit-code:0.

I do not understand what's the matter!
Please,I need your help!

additionaly, the first time it got error, that it don't may use type int as argument of glfw.CreateStandartCursor in "glfw.go". This fragment introduced below:
// Preallocate standard cursors
w.arrowCursor = glfw.CreateStandardCursor(int(glfw.ArrowCursor))
w.ibeamCursor = glfw.CreateStandardCursor(int(glfw.IBeamCursor))
w.crosshairCursor = glfw.CreateStandardCursor(int(glfw.CrosshairCursor))
w.handCursor = glfw.CreateStandardCursor(int(glfw.HandCursor))
w.hresizeCursor = glfw.CreateStandardCursor(int(glfw.HResizeCursor))
w.vresizeCursor = glfw.CreateStandardCursor(int(glfw.VResizeCursor))
After this I remove all int from showed strings. But I don't think that it's reason...

MacOS: GLAPI Error

When I try to run the demo, it gives the error as follow:

GLAPI Error: 1281 calling: glLineWidth

385579c5 broke raycasts on indexed meshes

It looks like raycasts were partially broken by 385579c: while the hit info contains the correct world position and graphic, the Index is off.

I've made a small gist that demonstrates this.
Run it against 8ff00c4 and raycasts will work properly, i.e. the green arrow will point in the direction of the normal of the face we hit and the red ball will be at a vertex that belongs to that face.
Run it against the very next commit, 385579c or later, and this will no longer be the case: the ball and arrow will jump around, seemingly at random.

P.S. Sorry for the gist being this big, I had to include the same mesh building logic I use in my game to reliably reproduce this.

Ready for a game?

I've been using Love2D to write a MMORPG with some RTS features but I've been noticing a huge performance drop just drawing around 100x100 tilegrids on a larger display... I would love to switch to a Go-based option, but I'm having trouble finding something that I like and that works. Should I use this or would I be better off just using something else? (I may use OpenGL since I don't really need anything to complex... just textures, some lighting/blurring shaders and text)

obj decoder doesn't load texture

dcdr, err := obj.Decode("piece.obj", "piece.mtl")
if err != nil {
    log.Fatal("Error:%s loading obj (piece)", err)
}
msh,err := dcdr.NewMesh(&dcdr.Objects[0])
if err != nil {
    panic(err)
}

where piece.mtl points to a texture file in the same directory

even "manually" adding a texture to the mesh doesn't work

tex1, err := texture.NewTexture2DFromImage("warrior.png")
if err != nil {
    log.Fatal("Error:%s loading warrior.png texture", err)
}
mat1 := material.NewStandard(math32.NewColor(1, 1, 1))
mat1.AddTexture(tex1)
msh.AddMaterial(mat1,0,1)`

The object is well lit and appears plain white.

[question] Custom shaders with many uniforms

I feel like I'm missing something obvious here, but how do I make a material for a custom shader that needs lots of uniforms? I'm implementing my human skin shader, and it needs uniforms for the bones to implement skeletal animation, as well as some values specific to my use case, such as skin color in a vec3, etc. Sorry if I missed something obvious.

Thanks,
Amy

P.S. Exposing a ModelMatrix uniform would grant access to the position in world space of the current fragment inside fragment shaders, which might be helpful for things like texture tiling or fixed-location objects, etc. I don't need it because in my one use case it just happens that the model matrix was constant, but I thought I should mention it.

After installing dependencies, codec.h not found, vorbisfile.h not found... etc (MacOSX)

g3nd demo works fine. I got the dependencies to work perfectly. But when I am trying to run gokoban, I am getting errors.

JoeMBP:gokoban joealai$ go run *.go

# Game/gokoban/vendor/github.com/g3n/engine/audio/vorbis
vendor/github.com/g3n/engine/audio/vorbis/vorbis.go:15:11: fatal error: 'codec.h' file not found
 #include "codec.h"
          ^~~~~~~~~
1 error generated.
# Game/gokoban/vendor/github.com/g3n/engine/audio/ov
vendor/github.com/g3n/engine/audio/ov/vorbisfile.go:16:11: fatal error: 'vorbisfile.h' file not found
 #include "vorbisfile.h"
          ^~~~~~~~~~~~~~
1 error generated.
# Game/gokoban/vendor/github.com/g3n/engine/audio/al
vendor/github.com/g3n/engine/audio/al/al.go:19:10: fatal error: 'al.h' file not found
#include "al.h"
         ^~~~~~
1 error generated.

AND

JoeMBP:gokoban joealai$ go get -u github.com/danaugrs/gokoban

# github.com/danaugrs/gokoban/vendor/github.com/g3n/engine/audio/vorbis
../../github.com/danaugrs/gokoban/vendor/github.com/g3n/engine/audio/vorbis/vorbis.go:15:11: fatal error: 'codec.h' file not found
 #include "codec.h"
          ^~~~~~~~~
1 error generated.
# github.com/danaugrs/gokoban/vendor/github.com/g3n/engine/audio/ov
../../github.com/danaugrs/gokoban/vendor/github.com/g3n/engine/audio/ov/vorbisfile.go:16:11: fatal error: 'vorbisfile.h' file not found
 #include "vorbisfile.h"
          ^~~~~~~~~~~~~~
1 error generated.
# github.com/danaugrs/gokoban/vendor/github.com/g3n/engine/audio/al
../../github.com/danaugrs/gokoban/vendor/github.com/g3n/engine/audio/al/al.go:19:10: fatal error: 'al.h' file not found
#include "al.h"
         ^~~~~~
1 error generated.

using with SDL

I am wanting to composite a g3n 3d view with a webview and an SDL view.

I know this is pretty difficult but i figured its worth asking about.

For webview i use this: https://github.com/zserge/webview

The golang library for SDL is pretty strong and with SDL you can use just the bits you need. SO the Audio can keep using the g3n audio lib.
https://github.com/veandco/go-sdl2-examples/blob/master/examples/opengl3/opengl3.go

The whole idea here to provide some flexibility in the way you bring together different software.
Hey you can can it micro-gui ( like micro services ) :)

Serious graphical glitch involving resizing near the title bar of a GUI window widget

I have come across a really difficult-to-describe graphical glitch that I think occurs when you attempt to resize a GUI window widget near the title bar.

It is easiest to reproduce by resizing the top of a window downward in a short, rapid motion. After the glitch is triggered, the window "runs away" from the mouse pointer whenever the mouse cursor approaches the title bar.

Another way to trigger the glitch is to resize the height from the bottom border of a GUI window widget as small as it gets, release the mouse button, and then enlarge the height back again in a short, rapid downward drag of the mouse. Like before, after triggering it, the window "runs away" from the cursor whenever it approaches the title bar.

This glitch is serious because it causes GUI window widgets to "run off the screen" where they cannot be interacted with anymore. Please let me know if you have any difficulty reproducing it and I will try to be more clear and/or supply example code as needed.

Tested on:
FreeBSD 10.3 amd64

remove dep on golang.org/x/image

hi team:

each time when I go get g3n, I need to copy golang.org's pkg by hand, can we find a way to remove them? many thanks!

BR - fino

$ go get -v -u github.com/g3n/engine/...
github.com/g3n/engine (download)
github.com/go-gl/glfw (download)
github.com/golang/freetype (download)
Fetching https://golang.org/x/image/math/fixed?go-get=1

https fetch failed: Get https://golang.org/x/image/math/fixed?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
package github.com/g3n/engine/gui
imports golang.org/x/image/math/fixed: unrecognized import path "golang.org/x/image/math/fixed" (https fetch: Get https://golang.org/x/image/math/fixed?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
Fetching https://golang.org/x/image/font?go-get=1
https fetch failed: Get https://golang.org/x/image/font?go-get=1: dial tcp 216.239.37.1:443: i/o timeout
package github.com/g3n/engine/gui
imports golang.org/x/image/font: unrecognized import path "golang.org/x/image/font" (https fetch: Get https://golang.org/x/image/font?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
Fetching https://gopkg.in/yaml.v2?go-get=1
Parsing meta tags from https://gopkg.in/yaml.v2?go-get=1 (status code 200)
get "gopkg.in/yaml.v2": found meta tag get.metaImport{Prefix:"gopkg.in/yaml.v2", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v2"} at https://gopkg.in/yaml.v2?go-get=1
gopkg.in/yaml.v2 (download)

Animation Support

Loading collada/gltf2.0 animations, is this on the roadmap?
How difficult would this be to implement?

This is perhaps the only thing missing from this engine 👍

Support normal mapping

Right now it doesn't appear to be a supported feature. I can`t find any documentation on "shaman" or what is needed to add custom shaders properly.

material blending

Hi. I try to use material blending by example from your demo-programm. I want to create sun shine imitation. This is my code:

//CREATION OF SUN SHINE
		tex, err := texture.NewTexture2DFromImage("data/images/lensflare0_alpha.png")
		if err != nil {
			log.Fatal("Error loading texture: %s", err)
		}
	geo1 := geometry.NewPlane(10, 10, 1, 1)
	defer geo1.Dispose()

			material := material.NewPhong(math32.NewColor(1, 1, 1))
			material.SetOpacity(1)
			material.AddTexture(tex)
			material.SetBlending(2)
			mesh := graphic.NewMesh(geo1.Incref(), material)
			mesh.SetPosition(0, 0, -10)
			scene.Add(mesh)

but I have next result:
default
If I change blending to various values from 0 up to 4, it shows a black square with or without shine.
I need the square to become transparent and I only saw the sun. How can i do this

an .obj loader problem

Hello! Now I try to use your example "gopher3d" to experiment with loading other 3d models. I only change this string:
85 dec, err := obj.Decode("gopher.obj", "gopher.mtl")

I write other names of other models, for example:

85 dec, err := obj.Decode("KazSat2.obj", "KazSat2.mtl")
or
85 dec, err := obj.Decode("BasicCriypticman.obj", "BasicCriypticman.mtl") , etc.

There is this models
5721-osnovnoy-kriptitsmen.zip
KazSat2.zip
vanquish.zip
3D-redactors opens them, it is ok!

But during copmilation errors occur:

GOROOT=C:/go
GOPATH=C:/GoProjects
C:/go\bin\go.exe build -i -o "C:\Users\ASUS\AppData\Local\Temp\Build main.go and rungo" C:/GoProjects/src/github.com/g3n/demos/gopher3d/main.go
"C:\Program Files (x86)\JetBrains\Gogland 171.3780.106\bin\runnerw.exe" "C:\Users\ASUS\AppData\Local\Temp\Build main.go and rungo"
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x38 pc=0x580df6]

goroutine 1 [running, locked to thread]:
github.com/g3n/engine/loader/obj.(*Decoder).parseUsemtl(0xc042094000, 0xc042089970, 0x1, 0x1, 0xc042089900, 0x2)
	C:/GoProjects/src/github.com/g3n/engine/loader/obj/obj.go:472 +0xb6
github.com/g3n/engine/loader/obj.(*Decoder).parseObjLine(0xc042094000, 0xc042089920, 0x11, 0xc042089920, 0x11)
	C:/GoProjects/src/github.com/g3n/engine/loader/obj/obj.go:305 +0x8db
github.com/g3n/engine/loader/obj.(*Decoder).(github.com/g3n/engine/loader/obj.parseObjLine)-fm(0xc042089920, 0x11, 0x649364, 0x4)
	C:/GoProjects/src/github.com/g3n/engine/loader/obj/obj.go:121 +0x45
github.com/g3n/engine/loader/obj.(*Decoder).parse(0xc042094000, 0x777520, 0xc042082038, 0xc042063dc8, 0x0, 0x0)
	C:/GoProjects/src/github.com/g3n/engine/loader/obj/obj.go:265 +0x182
github.com/g3n/engine/loader/obj.DecodeReader(0x777520, 0xc042082038, 0x777520, 0xc042082040, 0x0, 0x2, 0x3)
	C:/GoProjects/src/github.com/g3n/engine/loader/obj/obj.go:121 +0x27e
github.com/g3n/engine/loader/obj.Decode(0x64ef0e, 0x14, 0x64eefa, 0x14, 0x0, 0x0, 0x0)
	C:/GoProjects/src/github.com/g3n/engine/loader/obj/obj.go:104 +0x13d
main.main()
	C:/GoProjects/src/github.com/g3n/demos/gopher3d/main.go:85 +0xa8d

Process finished with exit code 2

Error compiling Fragment Shader

Getting crashes with messages like:

15:44:13.673492:F:G3ND:Render error: Error compiling Fragment Shader: 0:42(26): error: sampler arrays indexed with non-constant expressions are forbidden in GLSL 1.30 and later

The code around line 42 is:

37:    // Combine all texture colors and opacity
38:    for (int i = 0; i < 1; i++) {
39:        if (MatTexVisible[i] == false) {
40:            continue;
41:        }
42:        vec4 texcolor = texture(MatTexture[i], FragTexcoord * MatTexRepeat[i] + MatTexOffset[i]);
43:        if (i == 0) {
44:            texCombined = texcolor;
45:        } else {
46:            texCombined = mix(texCombined, texcolor, texcolor.a);
47:        }
48:    }

The fix is probably to unroll the loop. But this will require re-working the template code to use {{range}} which is more than I can get into right now.

exit status 3221225781

If you attempt to run a g3n program without installing the audio drivers on windows, it will give you this error: exit status 3221225781, which means that a DLL can't be found. It can be solved by properly completing the instructions.

This isn't an issue so much as a breadcrumb trail for people like me who forget to complete the whole installation and then wonder why the software isn't working, feel free to close it.

Minor Enhancement: Could we have a SelectedAt() func on gui.DropDown?

In larger applications dropdowns will typically be populated from arrays/slices.

It would require a lot less code in the application if we could simply get the row number back from a selected dropdown.

We should take care of the case where a selection has not been made by returning either nil or -1 as the authors prefer.

[bug] incorrect preprocessor directive

g3n/engine commit: 1947ea87d4dc4603f0ecb3e14aadbcdee649c839

Hello, I have a glsl compilation error whenever I try the latest version of g3n/g3nd or the sample application g3n/demos/hellog3n.
I've not yet tested previous version of the engine but it seems related to the recent modifications of the glsl bone directives.

OS: 64bit Mac OS X 10.13.6 17G65
Kernel: x86_64 Darwin 17.7.0
GPU: Intel Iris Pro / NVIDIA GeForce GT 750M

I'm currently looking into it and but it might take me some time to make a working PR.
I'm using a modified version of the g3n/demos/hello3gn where I added an error check to app.Run()

$ go run main.go 
13:39:14.317947:I::OpenGL version: 4.1 NVIDIA-10.32.0 355.11.10.10.40.102
panic: error compiling Vertex Shader: ERROR: 0:84: '' : syntax error: incorrect preprocessor directive
ERROR: 0:84: '' : syntax error: unexpected tokens following #if preprocessor directive - expected a newline
ERROR: 0:128: '' : syntax error: incorrect preprocessor directive
ERROR: 0:128: '' : syntax error: unexpected tokens following #if preprocessor directive - expected a newline
ERROR: 0:131: '' : syntax error: incorrect preprocessor directive
ERROR: 0:131: '' : syntax error: unexpected tokens following #if preprocessor directive - expected a newline
ERROR: 0:133: '' : syntax error: incorrect preprocessor directive
ERROR: 0:133: '' : syntax error: unexpected tokens following #if preprocessor directive - expected a newline
ERROR: 0:135: '' : syntax error: incorrect preprocessor directive
ERROR: 0:135: '' : syntax error: unexpected tokens following #if preprocessor directive - expected a newline
001:#version 330 core
002:#define AMB_LIGHTS 1
003:#define DIR_LIGHTS 0
004:#define POINT_LIGHTS 1
005:#define SPOT_LIGHTS 0
006:#define MAT_TEXTURES 0
007://
008:// Vertex Shader
009://
010:
011://
012:// Vertex attributes
013://
014:layout(location = 0) in  vec3  VertexPosition;
015:layout(location = 1) in  vec3  VertexNormal;
016:layout(location = 2) in  vec3  VertexColor;
017:layout(location = 3) in  vec2  VertexTexcoord;
018:layout(location = 4) in  float VertexDistance;
019:layout(location = 5) in  vec4  VertexTexoffsets;
020:
021:
022:// Model uniforms
023:uniform mat4 ModelViewMatrix;
024:uniform mat3 NormalMatrix;
025:uniform mat4 MVP;
026:
027:
028://
029:// Material properties uniform
030://
031:
032:// Material parameters uniform array
033:uniform vec3 Material[6];
034:// Macros to access elements inside the Material array
035:#define MatAmbientColor             Material[0]
036:#define MatDiffuseColor     Material[1]
037:#define MatSpecularColor    Material[2]
038:#define MatEmissiveColor    Material[3]
039:#define MatShininess        Material[4].x
040:#define MatOpacity          Material[4].y
041:#define MatPointSize        Material[4].z
042:#define MatPointRotationZ   Material[5].x
043:
044:#if MAT_TEXTURES > 0
045:    // Texture unit sampler array
046:    uniform sampler2D MatTexture[MAT_TEXTURES];
047:    // Texture parameters (3*vec2 per texture)
048:    uniform vec2 MatTexinfo[3*MAT_TEXTURES];
049:    // Macros to access elements inside the MatTexinfo array
050:    #define MatTexOffset(a)         MatTexinfo[(3*a)]
051:    #define MatTexRepeat(a)         MatTexinfo[(3*a)+1]
052:    #define MatTexFlipY(a)          bool(MatTexinfo[(3*a)+2].x)
053:    #define MatTexVisible(a)        bool(MatTexinfo[(3*a)+2].y)
054:#endif
055:
056:// GLSL 3.30 does not allow indexing texture sampler with non constant values.
057:// This macro is used to mix the texture with the specified index with the material color.
058:// It should be called for each texture index. It uses two externally defined variables:
059:// vec4 texColor
060:// vec4 texMixed
061:#define MIX_TEXTURE(i)                                                                       \
062:    if (MatTexVisible(i)) {                                                                  \
063:        texColor = texture(MatTexture[i], FragTexcoord * MatTexRepeat(i) + MatTexOffset(i)); \
064:        if (i == 0) {                                                                        \
065:            texMixed = texColor;                                                             \
066:        } else {                                                                             \
067:            texMixed = mix(texMixed, texColor, texColor.a);                                  \
068:        }                                                                                    \
069:    }
070:
071:// TODO for alpha blending dont use mix use implementation below (similar to one in panel shader)
072:            //vec4 prevTexPre = texMixed;                                                      \
073:            //prevTexPre.rgb *= prevTexPre.a;                                                  \
074:            //vec4 currTexPre = texColor;                                                      \
075:            //currTexPre.rgb *= currTexPre.a;                                                  \
076:            //texMixed = currTexPre + prevTexPre * (1 - currTexPre.a);                         \
077:            //texMixed.rgb /= texMixed.a;
078:
079:#ifdef MORPHTARGETS
080:    uniform float morphTargetInfluences[MORPHTARGETS];
081:    
082:#endif
083:
084:#if BONE_INFLUENCERS > 0
085:    uniform mat4 mBones[TOTAL_BONES];
086:    in vec4 matricesIndices;
087:    in vec4 matricesWeights;
088://    #if BONE_INFLUENCERS > 4
089://        in vec4 matricesIndicesExtra;
090://        in vec4 matricesWeightsExtra;
091://    #endif
092:#endif
093:// Output variables for Fragment shader
094:out vec4 Position;
095:out vec3 Normal;
096:out vec3 CamDir;
097:out vec2 FragTexcoord;
098:
099:void main() {
100:
101:    // Transform this vertex position to camera coordinates.
102:    Position = ModelViewMatrix * vec4(VertexPosition, 1.0);
103:
104:    // Transform this vertex normal to camera coordinates.
105:    Normal = normalize(NormalMatrix * VertexNormal);
106:
107:    // Calculate the direction vector from the vertex to the camera
108:    // The camera is at 0,0,0
109:    CamDir = normalize(-Position.xyz);
110:
111:    // Flips texture coordinate Y if requested.
112:    vec2 texcoord = VertexTexcoord;
113:#if MAT_TEXTURES>0
114:    if (MatTexFlipY(0)) {
115:        texcoord.y = 1 - texcoord.y;
116:    }
117:#endif
118:    FragTexcoord = texcoord;
119:    vec3 vPosition = VertexPosition;
120:    mat4 finalWorld = mat4(1.0);
121:    
122:#ifdef MORPHTARGETS
123:
124:    
125:
126:#endif
127:
128:#if BONE_INFLUENCERS > 0
129:
130:    mat4 influence = mBones[int(matricesIndices[0])] * matricesWeights[0];
131:    #if BONE_INFLUENCERS > 1
132:        influence += mBones[int(matricesIndices[1])] * matricesWeights[1];
133:        #if BONE_INFLUENCERS > 2
134:            influence += mBones[int(matricesIndices[2])] * matricesWeights[2];
135:            #if BONE_INFLUENCERS > 3
136:                influence += mBones[int(matricesIndices[3])] * matricesWeights[3];
137://                #if BONE_INFLUENCERS > 4
138://                    influence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];
139://                    #if BONE_INFLUENCERS > 5
140://                        influence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];
141://                        #if BONE_INFLUENCERS > 6
142://                            influence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];
143://                            #if BONE_INFLUENCERS > 7
144://                                influence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];
145://                            #endif
146://                        #endif
147://                    #endif
148://                #endif
149:            #endif
150:        #endif
151:    #endif
152:
153:    finalWorld = finalWorld * influence;
154:
155:#endif
156:gl_Position = MVP * finalWorld * vec4(vPosition, 1.0);
157:}
158:
159:


goroutine 1 [running, locked to thread]:
main.check(0x4229520, 0xc420010aa0)
        /Users/rdantzer/GO/src/github.com/raphy42/playground/main.go:14 +0x4a
main.main()
        /Users/rdantzer/GO/src/github.com/raphy42/playground/main.go:45 +0x2c6
exit status 2

gui: Default font metrics

Is there a recommended way of getting the default font metrics for a piece of text? Possible I've missed it somewhere but I see font.MeasureText which would work but how to get the default font in use?

Audio dependency names for CentOS 7

Just read the audio dependencies for CentOS in the README.md, so decided to investigate quickly:

For CentOS/Fedora-like Linux distributions, install libopenal1 and libvorbisfile3 (to be verified)

On my CentOS 7 x64 desktop, the needed package for OpenAL seems to be called "openal-soft" (available in the standard EPEL repo) instead of "libopenal1". There is a matching "openal-soft-devel" package too, but it doesn't seem to be needed when testing just now.

For testing, I compiled g3nplay and ran it with the demo .ogg and .wav files.

  • Without openal-soft installed, an error message Error trying to load OpenAL library is displayed.
  • With just openal-soft installed (without the -devel package too) the .wav files (only) play back fine.
  • Adding the openal-soft-devel didn't seem to change anything. The .wav files played back fine again.

For the .ogg demo files though, nothing seemed to work. Both the libvorbis and libogg packages were already installed on my desktop, but the .ogg files refused to play. As in, the g3nplay application proceeded as if there were... but no sound of any sort. Add the libogg-devel and libvorbis-devel packages then recompiling g3nplay didn't change anything.

So... for at least the OpenAL stuff the package name is pretty clear. Not real sure about the libvorbis bits though. 😉

Add ToolTip functionality

Many GUI elements would benefit from having a .SetToolTip(string) method whereby if the user holds the mouse over the element for more than, say half a second, a tip or hint pops up.

macOS: Rendering issues

So I've managed to build all the libraries required (ogg.framework and Vorbis.framework) and launched g3nd.

I've to add

glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)

in window initialization code (glfw.go: newGLFW) to launch it.

$ go run main.go
12:18:49.443939:I:G3ND:G3N Demo v0.2 starting
12:18:49.444835:I:G3ND:Using data directory:data
12:18:49.558976:I:G3ND:OpenGL version: 4.1 ATI-1.51.8
12:18:49.582352:I:G3ND:Apple Computer Inc. version: 1.1
12:18:49.582555:W:G3ND:Error loading libvorbisfile shared library/dll

So far vorbis didn't load, but I've got another issue:
screen shot 2017-08-08 at 15 21 47

node.SetVisible() state ignored

Just noticed something that seems weird.

If a scene has several nodes (eg 3 boxes), then the node.SetVisible() call doesn't work as expected when all of the nodes have their visibility turned off.

If only some of the nodes in the scene have their visibility turned off, then things work as expected. Those nodes disappear visually, and only the remaining nodes can be seen.

However, when all nodes have their visibility turned off... none of them disappear. eg it's as if the several calls to node.SetVisible() are being ignored.

Is this expected behaviour?

Only asking because I'm noticing this while mucking around with engine/gui and buttons. The action of one is set to toggle visibility of various elements, and I noticed this seeming-edge-case. If this is behaviour as intended, then no worries. It's just a test button anyway. 😄

windoze - setup.

I cant seem to get it setup for windows. I am a mac person normally.
heres where i am:

gedw9@DESKTOP-6Q0VG3G MINGW64 /c
$ go get -u github.com/g3n/engine/...
# github.com/g3n/engine/audio/al
exec: "gcc": executable file not found in %PATH%
# github.com/g3n/engine/audio/ov
exec: "gcc": executable file not found in %PATH%
# github.com/g3n/engine/gls
exec: "gcc": executable file not found in %PATH%
# github.com/g3n/engine/audio/vorbis
exec: "gcc": executable file not found in %PATH%
# github.com/go-gl/glfw/v3.2/glfw
exec: "gcc": executable file not found in %PATH%

I have git for windows installed and this seems to also setup the ming64 env for me.
Its gotten alot better lately.

But i dont have make or its gcc, etc

did some googling but i got completely confused..

On windows i actually use mage, which is a pure golang replacement for make.
On windows i do:

go get github.com/magefile/mage
go get github.com/golang/dep/cmd/dep
go get github.com/mattn/goveralls
go get -u github.com/jteeuwen/go-bindata/...

then you can call mage blah, just like your woudl make blah.
anyway..

Add "FixedSize" to Application Options

Enhancement Request:

Could you add either a FixedSize option, or a SetResizable() func to the application type?

Sometimes we don't want the pesky users playing around with the main window size ;-)

Does "graphic.Skybox" work?

I tried using graphic.Skybox (made via NewSkybox()) and I couldn't figure out how to make it work. It displays the images as expected, but cuts off the other geometry in the scene (in this case some terrain). I tried increasing the size via SetScale() but that didn't change anything.

The demo in g3nd creates the skybox manually instead of using the one supplied in the engine.

Thanks

Can't install the engine

Hi after running "go get -u github.com/g3n/engine/...", it throws error like this:

# github.com/go-gl/glfw/v3.2/glfw
In file included from go/src/github.com/go-gl/glfw/v3.2/glfw/c_glfw_linbsd.go:24:0:
go/src/github.com/go-gl/glfw/v3.2/glfw/glfw/src/linux_joystick.c: In function ‘_glfwInitJoysticksLinux’:
go/src/github.com/go-gl/glfw/v3.2/glfw/glfw/src/linux_joystick.c:224:42: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 9 [-Wformat-truncation=]
             snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
                                          ^~~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from /usr/include/X11/Xcursor/Xcursor.h:26,
                 from go/src/github.com/go-gl/glfw/v3.2/glfw/glfw/src/x11_platform.h:39,
                 from go/src/github.com/go-gl/glfw/v3.2/glfw/glfw/src/internal.h:169,
                 from go/src/github.com/go-gl/glfw/v3.2/glfw/glfw/src/x11_init.c:28,
                 from go/src/github.com/go-gl/glfw/v3.2/glfw/c_glfw_linbsd.go:19:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 12 and 267 bytes into a destination of size 20
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I did install all the necessary packages, I am running Ubuntu 18.04 LTS, Go 1.10.1 in VirtualBox.

Should loader.Decode() support .obj files without a corresponding material?

Asking because although the example files (eg gopher.obj, gopher.mtl) work fine, I have several .obj files without materials (generated by CAD programs).

Was kind of thinking to import the obj files using loader.Decode(), then manually create + apply a material to each imported one.

At the moment, loader.Decode() treats a missing material file as an error. Am kind of thinking it might be useful to allow it to proceed instead, and pass (say) nil to loader.DecodeReader() which would skip attempting to parse the missing material too.

Can make a PR, which shouldn't suck too hard code wise. 😉

Thoughts? 😄

Build errors on macOS 10.12.6.

After applying patch #15 still remain some errors. Unfortunately I don't know how to fix it.

% go build ./...
# github.com/g3n/engine/audio/vorbis
audio/vorbis/loader.c:90:15: warning: implicit declaration of function 'open_libvb' is invalid in C99 [-Wimplicit-function-declaration]
audio/vorbis/loader.c:99:54: warning: implicit declaration of function 'get_proc' is invalid in C99 [-Wimplicit-function-declaration]
audio/vorbis/loader.c:99:31: warning: cast to 'LPVORBISVERSIONSTRING' (aka 'const char *(*)(void)') from smaller integer type 'int' [-Wint-to-pointer-cast]
# github.com/g3n/engine/audio/vorbis
Undefined symbols for architecture x86_64:
  "_get_proc", referenced from:
      _vorbis_load in loader.o
  "_open_libvb", referenced from:
      _vorbis_load in loader.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
# github.com/g3n/engine/audio/ov
audio/ov/loader.c:60:2: error: use of undeclared identifier 'GL3WglProc'
audio/ov/loader.c:63:2: error: use of undeclared identifier 'res'
audio/ov/loader.c:63:9: error: use of undeclared identifier 'GL3WglProc'
audio/ov/loader.c:65:9: error: use of undeclared identifier 'res'
# github.com/g3n/engine/audio/al
audio/al/loader.c:56:2: error: use of undeclared identifier 'GL3WglProc'
audio/al/loader.c:59:2: error: use of undeclared identifier 'res'
audio/al/loader.c:59:9: error: use of undeclared identifier 'GL3WglProc'
audio/al/loader.c:61:9: error: use of undeclared identifier 'res'
# github.com/g3n/engine/gls
Undefined symbols for architecture x86_64:
  "_CFBundleCreate", referenced from:
      _glapiLoad in glapi.o
  "_CFBundleGetFunctionPointerForName", referenced from:
      _glapiLoad in glapi.o
  "_CFRelease", referenced from:
      _glapiLoad in glapi.o
  "_CFStringCreateWithCString", referenced from:
      _glapiLoad in glapi.o
  "_CFURLCreateWithFileSystemPath", referenced from:
      _glapiLoad in glapi.o
  "___CFConstantStringClassReference", referenced from:
      CFString in glapi.o
  "_kCFAllocatorDefault", referenced from:
      _glapiLoad in glapi.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
% system_profiler SPSoftwareDataType | grep Version
      System Version: macOS 10.12.6 (16G29)
      Kernel Version: Darwin 16.7.0

Obtain monitor resolution

Is there a way to ask for the monitor resolution using your library?

That way, on high definition monitors, I could have my program scale up the window size and all the text sizes.

Thanks!

Jamey

Problem creating a window outside of main.go

Hey Guys,

I can't seem to create a window outside of main.go.
Operating System: Linux Mint 18.3

If I copy and paste the sample it works perfectly.
When I remove everything except the window it works perfectly
If I move the window code into a package and run it I get the following error

# command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: cannot open file /usr/local/go/pkg/linux_amd64/github.com/g3n/engine/window.a: open /usr/local/go/pkg/linux_amd64/github.com/g3n/engine/window.a: no such file or directory

Does not work
selection_038
selection_039

Works just fine
selection_040

Consider moving AddDefaultShaders inside NewRenderer

Hi,

I've just spend a couple of hours trying to figure out why a particular shader wasn't loaded. In the end it turned out my app didn't call AddDefaultShaders.

On the up-side, I now understand GoLang a lot better and I figured out the logger system 👍 But, since it is supposed to register the defaults, let's make it default - batteries included.

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.