예제 #1
0
func (c *Context) GetUniformLocation(p Program, location string) UniformLocation {
	u := UniformLocation(gl.GetUniformLocation(uint32(p), gl.Str(location+"\x00")))
	if u == -1 {
		panic("invalid uniform location: " + location)
	}
	return u
}
예제 #2
0
파일: gg.go 프로젝트: dmac/gg
func (*backend) GetUniformLocation(p *gg.Program, name string) (*gg.Uniform, error) {
	u := gl.GetUniformLocation(p.Value.(uint32), gl.Str(name+"\x00"))
	if u < 0 {
		return nil, fmt.Errorf("gg: no uniform named " + name)
	}
	return &gg.Uniform{Value: u}, nil
}
예제 #3
0
func (c *Context) getUniformLocationImpl(p Program, location string) uniformLocation {
	uniform := uniformLocation(gl.GetUniformLocation(uint32(p), gl.Str(location+"\x00")))
	if uniform == -1 {
		panic("opengl: invalid uniform location: " + location)
	}
	return uniform
}
예제 #4
0
func initResources() uint32 {
	vs := CreateShader("triangle.v.glsl", gl.VERTEX_SHADER)
	fs := CreateShader("triangle.f.glsl", gl.FRAGMENT_SHADER)

	var linkOk int32
	program := gl.CreateProgram()
	gl.AttachShader(program, vs)
	gl.AttachShader(program, fs)
	gl.LinkProgram(program)
	gl.GetProgramiv(program, gl.LINK_STATUS, &linkOk)
	if linkOk == 0 {
		log.Fatal("gl.LinkProgram")
	}

	gl.GenBuffers(1, &vboTriangle)
	gl.BindBuffer(gl.ARRAY_BUFFER, vboTriangle)
	gl.BufferData(gl.ARRAY_BUFFER, floatSize*len(triangleAttributes), gl.Ptr(triangleAttributes), gl.STATIC_DRAW)

	attributeCoord2d = gl.GetAttribLocation(program, gl.Str("coord2d\x00"))
	if attributeCoord2d == -1 {
		log.Fatal("failed to bind attribute")
	}

	attributeVColor = gl.GetAttribLocation(program, gl.Str("v_color\x00"))
	if attributeVColor == -1 {
		log.Fatal("could not bind attribute v_color")
	}

	uniformFade = gl.GetUniformLocation(program, gl.Str("fade\x00"))
	if uniformFade == -1 {
		log.Fatal("could not bind uniform fade")
	}

	return program
}
예제 #5
0
func (s *Shader) addUniform(uniformName string) error {
	uniformLocation := gl.GetUniformLocation(s.program, gl.Str(uniformName+"\000"))

	if uniformLocation == -1 {
		return fmt.Errorf("could not find uniform: %s", uniformName)
	}

	s.uniforms[uniformName] = uniformLocation
	return nil
}
예제 #6
0
파일: shader.go 프로젝트: gdm85/wolfengo
func (s *Shader) addUniform(uniformName string) error {
	csource, free := gl.Strs(uniformName + "\000")
	defer free()
	uniformLocation := gl.GetUniformLocation(s.program, *csource)

	if uniformLocation == -1 {
		return fmt.Errorf("could not find uniform: %s", uniformName)
	}

	s.uniforms[uniformName] = uniformLocation
	return nil
}
예제 #7
0
파일: program.go 프로젝트: PieterD/crap
func uniforms(id uint32) map[string]Uniform {
	var maxlength int32
	gl.GetProgramiv(id, gl.ACTIVE_UNIFORM_MAX_LENGTH, &maxlength)
	var numuniforms int32
	gl.GetProgramiv(id, gl.ACTIVE_UNIFORMS, &numuniforms)
	buf := make([]byte, maxlength)
	m := make(map[string]Uniform)
	for index := uint32(0); index < uint32(numuniforms); index++ {
		name, dt, siz := uniform(id, index, buf)
		loc := gl.GetUniformLocation(id, &buf[0])
		if loc == -1 {
			panic(fmt.Errorf("Expected location for indexed uniform '%s'", name))
		}
		m[name] = Uniform{
			name:     name,
			location: loc,
			typ:      dt,
			siz:      siz,
		}
	}
	return m
}
예제 #8
0
파일: gl_opengl.go 프로젝트: tanema/amore
// GetUniformLocation returns the location of a uniform variable.
//
// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetUniformLocation.xhtml
func GetUniformLocation(p Program, name string) Uniform {
	return Uniform{Value: gl.GetUniformLocation(p.Value, gl.Str(name+"\x00"))}
}
예제 #9
0
파일: gl_gl2.go 프로젝트: EngoEngine/gl
func (c *Context) GetUniformLocation(program *Program, name string) *UniformLocation {
	return &UniformLocation{gl.GetUniformLocation(program.uint32, gl.Str(name+"\x00"))}
}
예제 #10
0
func (c *Context) GetUniformLocation(program *Program, name string) *UniformLocation {
	strptr, free := gl.Strs(name + "\x00")
	defer free()
	return &UniformLocation{gl.GetUniformLocation(program.uint32, *strptr)}
}