当前位置: 首页 > news >正文

【golang/g3n】3D游戏引擎G3N的windows安装与测试

目录

  • 说在前面
  • 安装
  • 测试

说在前面

  • 操作系统:win 11
  • go version:go1.21.5 windows/amd64
  • g3n版本:github.com/g3n/engine v0.2.0
  • 其他:找了下golang 3d相关的库,目前好像就这个比较活跃

安装

  • 按照官方教程所说,需要mingw环境,首先按照教程去下载

    We tested the Windows build using the mingw-w64 toolchain (you can download this file in particular).

  • 下载后将文件解压,并添加环境变量(主要是binincludelib)
    在这里插入图片描述
    在这里插入图片描述
  • 然后下载g3n源代码
    git clone https://github.com/g3n/engine g3n-engine
    
    同样添加下环境变量
    在这里插入图片描述
  • 重启
  • 然后可以开始install
    cd g3n-engine
    go install ./...
    

测试

  • 创建一个空文件加,创建一个main.go 文件
    package mainimport ("time""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"
    )func main() {// 创建appa := app.App()// 创建scenescene := core.NewNode()// 设置gui控制器gui.Manager().Set(scene)// 创建相机cam := camera.New(1)cam.SetPosition(0, 0, 3)scene.Add(cam)// 初始化相机控制器camera.NewOrbitControl(cam)// 设置窗口回调onResize := func(evname string, ev interface{}) {// Get framebuffer size and update viewport accordinglywidth, height := a.GetSize()a.Gls().Viewport(0, 0, int32(width), int32(height))// Update the camera's aspect ratiocam.SetAspect(float32(width) / float32(height))}a.Subscribe(window.OnWindowSize, onResize)onResize("", nil)// 添加一个蓝色甜甜圈geom := geometry.NewTorus(1, .4, 12, 32, math32.Pi*2)mat := material.NewStandard(math32.NewColor("DarkBlue"))mesh := graphic.NewMesh(geom, mat)scene.Add(mesh)// 添加一个改变甜甜圈颜色的按钮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)// 添加光照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)// 添加坐标系显示scene.Add(helper.NewAxes(0.5))// 设置灰色背景色a.Gls().ClearColor(0.5, 0.5, 0.5, 1.0)// 运行应用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)})
    }
    
  • 初始化
    go mod init test
    go mod tidy
    
  • 运行
    go run main.go
    
    在这里插入图片描述
  • 内存和cpu
    在这里插入图片描述
http://www.lryc.cn/news/262248.html

相关文章:

  • sap table 获取 valuation class MBEW 查表获取
  • 介绍一些操作系统—— Ubuntu 系统
  • React中props 和 state异同初探
  • spring-kakfa依赖管理之org/springframework/kafka/listener/CommonErrorHandler错误
  • 基于go语言开发的海量用户及时通讯系统
  • 19.Oracle 中count(1) 、count(*) 和count(列名) 函数的区别
  • C 库函数 - time()
  • 基于Python数据可视化的网易云音乐歌单分析系统
  • Jenkins----基于 CentOS 或 Docker 安装部署Jenkins并完成基础配置
  • flume系列之:监控flume agent channel的填充百分比
  • 信息安全和网络安全的区别
  • 【开源项目】WPF 扩展 -- 多画面视频渲染组件
  • risc-v system instruction
  • 08 v-text指令
  • vite基本知识
  • 考研真题c语言
  • neuq-acm预备队训练week 9 P8604 [蓝桥杯 2013 国 C] 危险系数
  • 【BIG_FG_CSDN】*VMware17pro*Linux*Redhit6网络管理(个人向——学习笔记)
  • Nginx location+Nginx rewrite(重写)(新版)
  • uniapp实现地图电子围栏功能
  • LeetCode第376场周赛
  • 数据仓库与数据挖掘小结
  • ensp创建配置环境,实现全网互访
  • 智能优化算法应用:基于JAYA算法3D无线传感器网络(WSN)覆盖优化 - 附代码
  • ripro后台登录后转圈和图标不显示的原因及解决方法
  • android 源码编译android 12
  • CSS第二天导读
  • scroll-behavior属性使用方法
  • Python Django 连接 PostgreSQL 操作实例
  • 5.实现简化版raft协议完成选举