• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang glutil.CreateProgram函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中golang.org/x/mobile/exp/gl/glutil.CreateProgram函数的典型用法代码示例。如果您正苦于以下问题:Golang CreateProgram函数的具体用法?Golang CreateProgram怎么用?Golang CreateProgram使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CreateProgram函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: onStart

func onStart(glctx gl.Context) {
	var err error
	program, err = glutil.CreateProgram(glctx, vertexShader, fragmentShader)
	if err != nil {
		log.Printf("[ERR] Failed creating GL program: %v", err)
		return
	}

	buf = glctx.CreateBuffer()
	glctx.BindBuffer(gl.ARRAY_BUFFER, buf)
	glctx.BufferData(gl.ARRAY_BUFFER, triangleData, gl.STATIC_DRAW)

	position = glctx.GetAttribLocation(program, "position")
	color = glctx.GetUniformLocation(program, "color")
	offset = glctx.GetUniformLocation(program, "offset")

	images = glutil.NewImages(glctx)
	fps = debug.NewFPS(images)

	statusFont, statusFace, err = exfont.LoadAsset("Tuffy.ttf", statusFaceOpt)
	if err != nil {
		log.Printf("[ERR] Failed to load status font: %v", err)
	}
	statusPainter = rexdemo.NewStatusPainter(demo, statusFont, statusBG, images)

	ifaces, err := net.Interfaces()
	if err != nil {
		log.Printf("[ERR] Failed to retreived interfaces")
	} else {
		log.Printf("[DEBUG] %d network interfaces", len(ifaces))
		for _, iface := range ifaces {
			log.Printf("[DEBUG] IFACE %d %s", iface.Index, iface.Name)
		}
	}
}
开发者ID:gophergala2016,项目名称:rex,代码行数:35,代码来源:main.go


示例2: NewButton

func NewButton(ctx gl.Context, x, y float32, w, h float32) *Button {
	btn := &Button{r: 1, g: 1, b: 1, a: 1}

	btn.x = (-(-1 - x)) / 2
	btn.y = (1 - y) / 2
	btn.w, btn.h = (w)/2, (-h)/2

	btn.verts = []float32{
		x, y, 0,
		x + w, y, 0,
		x, y + h, 0,
		x, y + h, 0,
		x + w, y, 0,
		x + w, y + h, 0,
	}

	btn.data = make([]byte, len(btn.verts)*4)

	var err error
	btn.program, err = glutil.CreateProgram(ctx, vertexShader, fragmentShader)
	if err != nil {
		panic(fmt.Errorf("error creating GL program: %v", err))
	}

	// create and alloc hw buf
	btn.buf = ctx.CreateBuffer()
	ctx.BindBuffer(gl.ARRAY_BUFFER, btn.buf)
	ctx.BufferData(gl.ARRAY_BUFFER, make([]byte, len(btn.verts)*4), gl.STATIC_DRAW)

	btn.position = ctx.GetAttribLocation(btn.program, "position")
	btn.color = ctx.GetUniformLocation(btn.program, "color")
	return btn
}
开发者ID:rakyll,项目名称:GCSolutions,代码行数:33,代码来源:waveform.go


示例3: onStart

func onStart(glctx gl.Context, sz size.Event) {
	log.Printf("creating GL program")
	var err error
	keystate = map[touch.Sequence]int{}
	program, err = glutil.CreateProgram(glctx, vertexShader, fragmentShader)
	if err != nil {
		log.Printf("error creating GL program: %v", err)
		return
	}

	glctx.Enable(gl.DEPTH_TEST)

	position = glctx.GetAttribLocation(program, "position")
	texCordIn = glctx.GetAttribLocation(program, "texCordIn")
	color = glctx.GetUniformLocation(program, "color")
	drawi = glctx.GetUniformLocation(program, "drawi")
	projection = glctx.GetUniformLocation(program, "projection")
	camera = glctx.GetUniformLocation(program, "camera")

	loadTexture(glctx)
	glctx.UseProgram(program)

	projectionMat := mgl32.Perspective(mgl32.DegToRad(75.0), float32(1), 0.5, 40.0)
	glctx.UniformMatrix4fv(projection, projectionMat[:])

	cameraMat := mgl32.LookAtV(mgl32.Vec3{0.5, 0, 1.5}, mgl32.Vec3{0, 0, 0}, mgl32.Vec3{0, 1, 0})
	glctx.UniformMatrix4fv(camera, cameraMat[:])

	board = NewBoard(glctx, float32(0.05), 10)

	numKeys := len(board.bigKeys) + len(board.smallKeys)

	InitializeSound(numKeys)
}
开发者ID:rakyll,项目名称:GCSolutions,代码行数:34,代码来源:main.go


示例4: NewWaveform

// TODO just how many samples do we want/need to display something useful?
func NewWaveform(ctx gl.Context, n int, in Sound) (*Waveform, error) {
	wf := &Waveform{Sound: in}

	wf.outs = make([][]float64, n)
	for i := range wf.outs {
		wf.outs[i] = make([]float64, in.BufferLen()*in.Channels())
	}
	wf.samples = make([]float64, in.BufferLen()*in.Channels()*n)
	// wf.aligned = make([]float64, in.BufferLen()*in.Channels()*n)

	wf.verts = make([]float32, len(wf.samples)*3)
	wf.data = make([]byte, len(wf.verts)*4)

	if ctx == nil {
		return wf, nil
	}

	var err error
	wf.program, err = glutil.CreateProgram(ctx, vertexShader, fragmentShader)
	if err != nil {
		return nil, fmt.Errorf("error creating GL program: %v", err)
	}

	// create and alloc hw buf
	wf.buf = ctx.CreateBuffer()
	ctx.BindBuffer(gl.ARRAY_BUFFER, wf.buf)
	ctx.BufferData(gl.ARRAY_BUFFER, make([]byte, len(wf.samples)*12), gl.STREAM_DRAW)

	wf.position = ctx.GetAttribLocation(wf.program, "position")
	wf.color = ctx.GetUniformLocation(wf.program, "color")
	return wf, nil
}
开发者ID:rakyll,项目名称:GCSolutions,代码行数:33,代码来源:waveform.go


示例5: onStart

func onStart() {
	var err error
	program, err = glutil.CreateProgram(vertexShader, fragmentShader)
	if err != nil {
		log.Printf("error creating GL program: %v", err)
		return
	}

	//创建一个WebGLBuffer对象,把它绑定到顶点缓冲上,并把顶点数据载入到顶点冲。
	buf = gl.CreateBuffer()
	gl.BindBuffer(gl.ARRAY_BUFFER, buf)
	gl.BufferData(gl.ARRAY_BUFFER, lineData, gl.STATIC_DRAW)

	/*opengl中三种变量
	  uniform变量是外部application程序传递给(vertex和fragment)shader的变量。因此它是application通过函数glUniform**()函数赋值的。
	  在(vertex和fragment)shader程序内部,uniform变量就像是C语言里面的常量(const ),它不能被shader程序修改。(shader只能用,不能改)

	  attribute变量是只能在vertex shader中使用的变量。(它不能在fragment shader中声明attribute变量,也不能被fragment shader中使用)
	  一般用attribute变量来表示一些顶点的数据,如:顶点坐标,法线,纹理坐标,顶点颜色等。
	  在application中,一般用函数glBindAttribLocation()来绑定每个attribute变量的位置,然后用函数glVertexAttribPointer()为每个attribute变量赋值。

	  varying变量是vertex和fragment shader之间做数据传递用的。一般vertex shader修改varying变量的值,然后fragment shader使用该varying变量的值。
	  因此varying变量在vertex和fragment shader二者之间的声明必须是一致的。application不能使用此变量。
	*/
	position = gl.GetAttribLocation(program, "position") //获取位置对象(索引)
	color = gl.GetUniformLocation(program, "color")      // 获取颜色对象(索引)
	scan = gl.GetUniformLocation(program, "scan")        // 获取偏移对象(索引)
	// fmt.Println(position.String(),color.String(),offset.String())//Attrib(0) Uniform(1) Uniform(0)
	// TODO(crawshaw): the debug package needs to put GL state init here
	// Can this be an event.Register call now??
}
开发者ID:lovexiaov,项目名称:gomobileapp,代码行数:31,代码来源:main.go


示例6: onStart

func onStart(glctx gl.Context) {
	var err error
	program, err = glutil.CreateProgram(glctx, vertexShader, fragmentShader)
	if err != nil {
		log.Printf("[ERR] Failed creating GL program: %v", err)
		return
	}

	buf = glctx.CreateBuffer()
	glctx.BindBuffer(gl.ARRAY_BUFFER, buf)
	glctx.BufferData(gl.ARRAY_BUFFER, triangleData, gl.STATIC_DRAW)

	position = glctx.GetAttribLocation(program, "position")
	color = glctx.GetUniformLocation(program, "color")
	offset = glctx.GetUniformLocation(program, "offset")

	images = glutil.NewImages(glctx)
	fps = debug.NewFPS(images)

	statusFont, statusFace, err = exfont.LoadAsset("Tuffy.ttf", statusFaceOpt)
	if err != nil {
		log.Printf("[ERR] Failed to load status font: %v", err)
	}
	statusPainter = rexdemo.NewStatusPainter(demo, statusFont, _color.White, images)
}
开发者ID:bmatsuo,项目名称:rex,代码行数:25,代码来源:main.go


示例7: createProgram

func createProgram(vShaderPath, fShaderPath string) gl.Program {
	// loading vertex shader
	vShader, e := loadSource(vShaderPath)
	def_check(e)
	// loading fragment shader
	fShader, e := loadSource(fShaderPath)
	def_check(e)
	// linking program
	program, e := glutil.CreateProgram(string(vShader), string(fShader))
	crash_check(e)
	return program
}
开发者ID:gitter-badger,项目名称:bukkake,代码行数:12,代码来源:loader.go


示例8: LoadProgram

// LoadProgram reads shader sources from the asset repository, compiles, and
// links them into a program.
func LoadProgram(vertexAsset, fragmentAsset string) (p gl.Program, err error) {
	vertexSrc, err := loadAsset(vertexAsset)
	if err != nil {
		return
	}

	fragmentSrc, err := loadAsset(fragmentAsset)
	if err != nil {
		return
	}

	p, err = glutil.CreateProgram(string(vertexSrc), string(fragmentSrc))
	return
}
开发者ID:lomoalbert,项目名称:gomobileapp,代码行数:16,代码来源:main.go


示例9: onStart

func onStart(glctx gl.Context) {
	var err error
	frameData.Program, err = glutil.CreateProgram(glctx, vertexShader, fragmentShader)
	if err != nil {
		log.Printf("error creating GL program: %v", err)
		return
	}

	frameData.Position = glctx.GetAttribLocation(frameData.Program, "position")
	frameData.Color = glctx.GetUniformLocation(frameData.Program, "color")
	frameData.Offset = glctx.GetUniformLocation(frameData.Program, "offset")
	manager = layers.NewLayerManager(glctx)
	manager.StartLayers()

}
开发者ID:rakyll,项目名称:GCSolutions,代码行数:15,代码来源:main.go


示例10: onStart

func onStart(glctx gl.Context) {
	var err error
	program, err = glutil.CreateProgram(glctx, vertexShader, fragmentShader)
	if err != nil {
		log.Printf("error creating GL program: %v", err)
		return
	}
	buf = glctx.CreateBuffer()
	glctx.BindBuffer(gl.ARRAY_BUFFER, buf)
	glctx.BufferData(gl.ARRAY_BUFFER, triangleData, gl.STATIC_DRAW)
	position = glctx.GetAttribLocation(program, "position")
	color = glctx.GetUniformLocation(program, "color")
	offset = glctx.GetUniformLocation(program, "offset")
	images = glutil.NewImages(glctx)
	fps = debug.NewFPS(images)
}
开发者ID:lomoalbert,项目名称:gomobileapp,代码行数:16,代码来源:main.go


示例11: onStart

func onStart() {
	var err error
	program, err = glutil.CreateProgram(vertexShader, fragmentShader)
	if err != nil {
		log.Printf("error creating GL program: %v", err)
		return
	}

	buf = gl.CreateBuffer()
	gl.BindBuffer(gl.ARRAY_BUFFER, buf)
	gl.BufferData(gl.ARRAY_BUFFER, rectData, gl.STATIC_DRAW)

	position = gl.GetAttribLocation(program, "position")
	color = gl.GetUniformLocation(program, "color")
	offset = gl.GetUniformLocation(program, "offset")
}
开发者ID:natasharomanoff,项目名称:blinker,代码行数:16,代码来源:main.go


示例12: NewGL

// NewGL returns a GL. ctx can be nil and the returned value can be nil, which
// is okay, a nil *GL functions correctly and doesn't crash.
func NewGL(ctx gl.Context) (*GL, error) {
	if ctx == nil {
		return nil, nil
	}
	program, err := glutil.CreateProgram(ctx, vertexShader, fragmentShader)
	if err != nil {
		return nil, err
	}
	g := &GL{
		ctx:      ctx,
		program:  program,
		buf:      ctx.CreateBuffer(),
		position: ctx.GetAttribLocation(program, "position"),
		color:    ctx.GetUniformLocation(program, "color"),
		offset:   ctx.GetUniformLocation(program, "offset"),
	}
	return g, nil
}
开发者ID:asimshankar,项目名称:triangles,代码行数:20,代码来源:gl.go


示例13: onStart

func onStart(glctx gl.Context) {
	var err error
	program, err = glutil.CreateProgram(glctx, vertexShader, fragmentShader)
	if err != nil {
		log.Printf("error creating GL program: %v", err)
		return
	}

	glctx.Enable(gl.DEPTH_TEST)

	triBuf = glctx.CreateBuffer()
	glctx.BindBuffer(gl.ARRAY_BUFFER, triBuf)
	glctx.BufferData(gl.ARRAY_BUFFER, triangleData, gl.STATIC_DRAW)

	position = glctx.GetAttribLocation(program, "vPos")
	color = glctx.GetAttribLocation(program, "vCol")
	normals = glctx.GetAttribLocation(program, "vNorm")

	projection = glctx.GetUniformLocation(program, "proj")
	view = glctx.GetUniformLocation(program, "view")
	model = glctx.GetUniformLocation(program, "model")
	tint = glctx.GetUniformLocation(program, "tint")
	normalMatrix = glctx.GetUniformLocation(program, "normalMatrix")
	lightIntensity = glctx.GetUniformLocation(program, "light.intensities")
	lightPos = glctx.GetUniformLocation(program, "light.position")

	arcball = NewArcBall(mgl32.Vec3{0, 0, 0}, mgl32.Vec3{0, 10, 10}, mgl32.Vec3{0, 1, 0})

	white = mgl32.Vec4{1.0, 1.0, 1.0, 1.0}
	red = mgl32.Vec4{1.0, 0.0, 0.0, 1.0}

	lastUpdate = time.Now()

	images = glutil.NewImages(glctx)
	fps = debug.NewFPS(images)

	err = al.OpenDevice()
	if err != nil {
		log.Printf("Err: %+v", err)
	}
	al.SetListenerPosition(al.Vector{0, 0, 0})
	al.SetListenerGain(1.0)
	piano = NewPiano()
}
开发者ID:rakyll,项目名称:GCSolutions,代码行数:44,代码来源:main.go


示例14: onStart

func onStart(glctx gl.Context) {
	var err error
	program, err = glutil.CreateProgram(glctx, vertexShader, fragmentShader)
	if err != nil {
		log.Printf("error creating GL program: %v", err)
		return
	}

	triangleData = genCircleTriangles(0.0, 0.0, 0.5)

	buf = glctx.CreateBuffer()

	position = glctx.GetAttribLocation(program, "position")
	color = glctx.GetUniformLocation(program, "color")
	offset = glctx.GetUniformLocation(program, "offset")

	images = glutil.NewImages(glctx)
	fps = debug.NewFPS(images)
}
开发者ID:richiebful,项目名称:ptime,代码行数:19,代码来源:.main.go


示例15: onStart

func onStart() {
	var err error
	program, err = glutil.CreateProgram(vertexShader, fragmentShader)
	if err != nil {
		log.Printf("error creating GL program: %v", err)
		return
	}

	buf = gl.CreateBuffer()
	gl.BindBuffer(gl.ARRAY_BUFFER, buf)
	gl.BufferData(gl.ARRAY_BUFFER, triangleData, gl.STATIC_DRAW)

	position = gl.GetAttribLocation(program, "position")
	color = gl.GetUniformLocation(program, "color")
	offset = gl.GetUniformLocation(program, "offset")

	// TODO(crawshaw): the debug package needs to put GL state init here
	// Can this be an app.RegisterFilter call now??
}
开发者ID:paulhankin,项目名称:mobile,代码行数:19,代码来源:main.go


示例16: appStart

func appStart(glctx gl.Context) {
	println("Starting")
	program, err = glutil.CreateProgram(glctx, vertexShader, fragmentShader)
	if err != nil {
		panic("error creating GL program: " + err.Error())
		return
	}

	buf = glctx.CreateBuffer()
	glctx.BindBuffer(gl.ARRAY_BUFFER, buf)
	glctx.BufferData(gl.ARRAY_BUFFER, triangleData, gl.STATIC_DRAW)

	position = glctx.GetAttribLocation(program, "position")
	color = glctx.GetUniformLocation(program, "color")
	offset = glctx.GetUniformLocation(program, "offset")
	images = glutil.NewImages(glctx)
	fps = debug.NewFPS(images)

	SetScene(currentScene.Name)
}
开发者ID:pyros2097,项目名称:spike,代码行数:20,代码来源:spike.go


示例17: Start

func (s *Screen) Start() {
	for i, c := range playerColors {
		playerColors[i] = Color{c.R / 255.0, c.G / 255.0, c.B / 255.0}
	}

	s.buf = s.glctx.CreateBuffer()
	s.glctx.BindBuffer(gl.ARRAY_BUFFER, s.buf)
	triangleData = makeTriangleData()

	s.glctx.BufferData(gl.ARRAY_BUFFER, triangleData, gl.STATIC_DRAW)

	var err error
	s.program, err = glutil.CreateProgram(s.glctx, vertexShader, fragmentShader)
	if err != nil {
		log.Printf("Error in screen.Start: %v", err)
		return
	}
	s.position = s.glctx.GetAttribLocation(s.program, "jrPosition")
	s.color = s.glctx.GetUniformLocation(s.program, "jrColor")
	s.offset = s.glctx.GetUniformLocation(s.program, "jrOffset")
	s.glctx.UseProgram(s.program)
}
开发者ID:monopole,项目名称:volley,代码行数:22,代码来源:screen.go



注:本文中的golang.org/x/mobile/exp/gl/glutil.CreateProgram函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang glutil.NewImages函数代码示例发布时间:2022-05-28
下一篇:
Golang f32.Affine类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap