登录 用户中心() [退出] 后台管理 注册
   
您的位置: 首页 >> SoftHub关联区 >> 主题: [golang] G3N 游戏引擎     [回主站]     [分站链接]
[golang] G3N 游戏引擎
clq
浏览(463) - 2023-08-25 12:13:14 发表 编辑

关键字:

[2023-08-25 12:41:30 最后更新]
[golang] G3N 游戏引擎

https://www.5axxw.com/wiki/content/xzom8d

--------------------------------------------------------
https://github.com/g3n/engine/blob/master/gls/glapi2go/template.go
有一段有趣的代码

static int open_libgl(void) {

libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_GLOBAL);
if (!libgl) {
return -1;
}
return 0;
}

也就是说 macos 下其实也是加载 dll (动态库)的。

--------------------------------------------------------

Engine: Go 3D游戏引擎

( 如需查看英文版本,请 点击这里 )

G3N-Go 3D游戏引擎

G3N(发音为“gen”)是一个用Go编写的OpenGL 3D游戏引擎。它可以用来编写cross-platformGo应用程序,显示丰富和动态的三维表示,而不仅仅是游戏。基本图形用户界面(basic GUI)是通过OpenAL提供的。
要看到G3N在行动,请尝试G3N演示或Gokoban获奖游戏。

G3ND In Action
Highlighted Projects Using G3N

Gokoban-3D益智游戏(2017年Gopher Game Jam第一名)
go-tsne(降维特别适合于可视化high-dimensional数据集)
G3N Server-Side Rendering

Dependencies

需要Go 1.8+。该引擎还要求系统具有OpenGL驱动程序和GCC-compatibleC编译器。

在Unix-based系统上,引擎依赖于一些可以使用适当的分发包管理器安装的C库。有关操作系统的具体要求,请参见下文。
Ubuntu/Debian-like

$ sudo apt-get install xorg-dev libgl1-mesa-dev libopenal1 libopenal-dev libvorbis0a libvorbis-dev libvorbisfile3

Fedora

$ sudo dnf -y install xorg-x11-proto-devel mesa-libGL mesa-libGL-devel openal-soft openal-soft-devel libvorbis libvorbis-devel glfw-devel libXi-devel

CentOS 7

启用EPEL存储库:

$ sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

然后安装与Fedora相同的包-记住在包安装命令中使用yum而不是dnf。
Windows

我们使用mingw-w64工具链测试了Windows构建(您可以特别下载这个文件)。

提供了必要的音频DLL,需要将其添加到您的路径中。如果您想自己构建DLL,可以在这里找到库的源代码和构建说明。
macOS

使用Homebrew安装OpenAL和Vorbis的开发文件:

brew install libvorbis openal-soft

Installation

以下命令集将下载并安装引擎及其所有Go依赖项:

git clone https://github.com/g3n/engine g3n-engine
cd g3n-engine
go install ./...

Features

Cross-platform:Windows、Linux和macOS。(WebAssembly已完成90%)
集成GUI(图形用户界面)和许多小部件
层次场景图-节点可以包含其他节点
通过OpenAL(.wav、.ogg)实现的三维空间音频
Real-time照明:环境光、定向光、点光源和聚光灯
Physically-based渲染:菲涅耳反射,几何遮挡,微区分布
模型加载器:glTF(.gltf、.glb)、波前OBJ(.obj)、COLLADA(.dae)
几何生成器:长方体、球体、圆柱体、圆环体等。。。
几何体支持变形目标和多重材质
支持基于精灵表的动画精灵
透视相机和人像照相机
文本图像生成及对TrueType字体的支持
图像纹理可以从GIF、PNG或JPEG文件加载
用于对象的位置、旋转和缩放的动画框架
支持user-createdGLSL着色器:顶点、片段和几何体着色器
综合基础物理引擎(实验/未完成)
支持HiDPI显示

G3N Banner
Hello G3N

下面的代码是一个基本的“hello world”应用程序(hellog3n),它显示一个蓝色的圆环体和一个按钮,当单击该按钮时,圆环体变为红色:

package main

import (
"github.com/g3n/engine/app"
"github.com/g3n/engine/camera"
"github.com/g3n/engine/core"
"github.com/g3n/engine/geometry"
"github.com/g3n/engine/gls"
"github.com/g3n/engine/graphic"
"github.com/g3n/engine/gui"
"github.com/g3n/engine/light"
"github.com/g3n/engine/material"
"github.com/g3n/engine/math32"
"github.com/g3n/engine/renderer"
"github.com/g3n/engine/util/helper"
"github.com/g3n/engine/window"
"time"
)

func main() {

// Create application and scene
a := app.App()
scene := core.NewNode()

// Set the scene to be managed by the gui manager
gui.Manager().Set(scene)

// Create perspective camera
cam := camera.New(1)
cam.SetPosition(0, 0, 3)
scene.Add(cam)

// Set up orbit control for the camera
camera.NewOrbitControl(cam)

// Set up callback to update viewport and camera aspect ratio when the window is resized
onResize := func(evname string, ev interface{}) {
// Get framebuffer size and update viewport accordingly
width, height := a.GetSize()
a.Gls().Viewport(0, 0, int32(width), int32(height))
// Update the camera's aspect ratio
cam.SetAspect(float32(width) / float32(height))
}
a.Subscribe(window.OnWindowSize, onResize)
onResize("", nil)

// Create a blue torus and add it to the scene
geom := geometry.NewTorus(1, .4, 12, 32, math32.Pi*2)
mat := material.NewStandard(math32.NewColor("DarkBlue"))
mesh := graphic.NewMesh(geom, mat)
scene.Add(mesh)

// Create and add a button to the scene
btn := gui.NewButton("Make Red")
btn.SetPosition(100, 40)
btn.SetSize(40, 40)
btn.Subscribe(gui.OnClick, func(name string, ev interface{}) {
mat.SetColor(math32.NewColor("DarkRed"))
})
scene.Add(btn)

// Create and add lights to the scene
scene.Add(light.NewAmbient(&math32.Color{1.0, 1.0, 1.0}, 0.8))
pointLight := light.NewPoint(&math32.Color{1, 1, 1}, 5.0)
pointLight.SetPosition(1, 0, 2)
scene.Add(pointLight)

// Create and add an axis helper to the scene
scene.Add(helper.NewAxes(0.5))

// Set background color to gray
a.Gls().ClearColor(0.5, 0.5, 0.5, 1.0)

// Run the application
a.Run(func(renderer *renderer.Renderer, deltaTime time.Duration) {
a.Gls().Clear(gls.DEPTH_BUFFER_BIT | gls.STENCIL_BUFFER_BIT | gls.COLOR_BUFFER_BIT)
renderer.Render(scene, cam)
})
}

hellog3n Screenshot

您可以通过以下方式下载并安装hellog3n:

go get -u github.com/g3n/demos/hellog3n

对于更复杂的演示,请参阅G3N演示程序。
Documentation

完整的引擎API引用可以在以下位置找到:。

还有入门指南的开头,以及新创建的指南和教程列表:

Getting Started
指南和教程

除此之外,学习如何使用这个引擎的一个好方法是看看G3ND的源代码-G3N演示。
Contributing

如果你发现了一个bug或者创建了一个新特性,我们鼓励你发送请求请求!
Community

加入我们的Gophers Slack频道(点击此处注册Gophers Slack)。这是一个让G3N社区快速回答您的问题的好方法。


总数:0 页次:1/0 首页 尾页  
总数:0 页次:1/0 首页 尾页  


所在合集/目录



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2020 clq, All Rights Reserved
版权所有
桂ICP备15002303号-1