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

Golang gl21.Pointer函数代码示例

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

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



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

示例1: Render

func (vb *VertexBuffer) Render(position Point3) {
	gl.PushMatrix()
	gl.Translated(
		gl.Double(position.X),
		gl.Double(position.Y),
		gl.Double(position.Z))

	gl.VertexPointer(
		gl.Int(3),
		gl.DOUBLE,
		0,
		gl.Pointer(&vb.VertexData[0]))
	gl.ColorPointer(
		gl.Int(4),
		gl.DOUBLE,
		0,
		gl.Pointer(&vb.ColorData[0]))
	gl.TexCoordPointer(
		gl.Int(2),
		gl.DOUBLE,
		0,
		gl.Pointer(&vb.TexCoordData[0]))

	for i := range vb.RenderSteps {
		rs := &vb.RenderSteps[i]
		gl.DrawElements(
			rs.Mode,
			gl.Sizei(len(rs.Indices)),
			gl.UNSIGNED_INT,
			gl.Pointer(&rs.Indices[0]))
	}
	gl.PopMatrix()
}
开发者ID:runningwild,项目名称:arkanoid,代码行数:33,代码来源:gl-geometry.go


示例2: Draw

func (ms *ManaSource) Draw(local *LocalData, zoom float64, dx float64, dy float64) {
	if local.nodeTextureData == nil {
		//		gl.Enable(gl.TEXTURE_2D)
		local.nodeTextureData = make([]byte, ms.options.NumNodeRows*ms.options.NumNodeCols*3)
		gl.GenTextures(1, &local.nodeTextureId)
		gl.BindTexture(gl.TEXTURE_2D, local.nodeTextureId)
		gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
		gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
		gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
		gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
		gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
		gl.TexImage2D(
			gl.TEXTURE_2D,
			0,
			gl.RGB,
			gl.Sizei(ms.options.NumNodeRows),
			gl.Sizei(ms.options.NumNodeCols),
			0,
			gl.RGB,
			gl.UNSIGNED_BYTE,
			gl.Pointer(&local.nodeTextureData[0]))
	}
	for i := range ms.rawNodes {
		for c := 0; c < 3; c++ {
			color_frac := ms.rawNodes[i].Mana[c] * 1.0 / ms.options.NodeMagnitude
			color_range := float64(ms.options.MaxNodeBrightness - ms.options.MinNodeBrightness)
			local.nodeTextureData[i*3+c] = byte(
				color_frac*color_range + float64(ms.options.MinNodeBrightness))
		}
	}
	gl.Enable(gl.TEXTURE_2D)
	//gl.ActiveTexture(gl.TEXTURE0)
	gl.BindTexture(gl.TEXTURE_2D, local.nodeTextureId)
	gl.TexSubImage2D(
		gl.TEXTURE_2D,
		0,
		0,
		0,
		gl.Sizei(ms.options.NumNodeRows),
		gl.Sizei(ms.options.NumNodeCols),
		gl.RGB,
		gl.UNSIGNED_BYTE,
		gl.Pointer(&local.nodeTextureData[0]))

	base.EnableShader("nodes")
	base.SetUniformI("nodes", "width", ms.options.NumNodeRows*3)
	base.SetUniformI("nodes", "height", ms.options.NumNodeCols*3)
	base.SetUniformI("nodes", "drains", 1)
	base.SetUniformI("nodes", "tex0", 0)
	base.SetUniformI("nodes", "tex1", 1)
	base.SetUniformF("nodes", "zoom", float32(zoom))
	gl.ActiveTexture(gl.TEXTURE0)
	gl.BindTexture(gl.TEXTURE_2D, local.nodeTextureId)

	// I have no idea why this value for move works, but it does.  So, hooray.
	move := (dx - dy) / 2
	texture.RenderAdvanced(move, -move, dy, dx, 3.1415926535/2, true)
	base.EnableShader("")
	gl.Disable(gl.TEXTURE_2D)
}
开发者ID:runningwild,项目名称:magnus,代码行数:60,代码来源:mana_source.go


示例3: NewSprite

// NewSprite creates a new Sprite object using the given data, which is
// expected to be in RGBA format. If you use PNG image files, you can use the
// NewSpriteFromImage shortcut function instead.
func NewSprite(x, y, width, height float64, data []byte, clip int) (*Sprite, error) {

	verticies := []float64{
		x, y,
		x + width, y,
		x, y + height,

		x + width, y + height,
		x + width, y,
		x, y + height}

	shape, err := NewShape(gl.TRIANGLES, verticies)
	if err != nil {
		return nil, err
	}

	sprite := &Sprite{texcoordBuffer: 0, texture: nil, shape: shape}

	texCoords := []float32{
		0, 0,
		1, 0,
		0, 1,

		1, 1,
		1, 0,
		0, 1}

	gl.GenBuffers(1, &sprite.texcoordBuffer)
	gl.BindBuffer(gl.ARRAY_BUFFER, gl.Uint(sprite.texcoordBuffer))
	gl.BufferData(gl.ARRAY_BUFFER, gl.Sizeiptr(len(texCoords)*4), gl.Pointer(&texCoords[0]), gl.STREAM_DRAW)
	gl.BindBuffer(gl.ARRAY_BUFFER, 0)

	sprite.texture = make([]gl.Uint, clip)
	gl.GenTextures(gl.Sizei(clip), &sprite.texture[0])

	clips := make([][]byte, clip)
	for i := range clips {
		clips[i] = data[i*(len(data)/len(clips)) : (i+1)*(len(data)/len(clips))]
		gl.BindTexture(gl.TEXTURE_2D, sprite.texture[len(clips)-1-i])
		gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
		gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
		gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
		gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
		gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA,
			gl.Sizei(width), gl.Sizei(height),
			0, gl.RGBA, gl.UNSIGNED_BYTE,
			gl.Pointer(&clips[i][0]))
	}

	gl.BindTexture(gl.TEXTURE_2D, 0)

	return sprite, checkForErrors()
}
开发者ID:velovix,项目名称:paunch,代码行数:56,代码来源:sprite.go


示例4: draw

func (m *Model) draw() {
	m.shader.use()

	gl.ActiveTexture(gl.TEXTURE0)
	gl.BindTexture(gl.TEXTURE_2D, m.texture_id)
	gl.Uniform1i(m.shader.uniform_texture, 0)

	//texcoord
	if m.has_uv {
		gl.BindBuffer(gl.ARRAY_BUFFER, m.texcoord)
		gl.EnableVertexAttribArray(m.shader.attribute_texcoord)
		gl.VertexAttribPointer(
			m.shader.attribute_texcoord,
			2,
			gl.FLOAT,
			gl.FALSE,
			0,
			gl.Pointer(nil))
	}

	gl.BindBuffer(gl.ARRAY_BUFFER, m.buffer)
	gl.EnableVertexAttribArray(m.shader.attribute_vertex)
	gl.VertexAttribPointer(
		m.shader.attribute_vertex,
		3,
		gl.FLOAT,
		gl.FALSE,
		0,
		gl.Pointer(nil))

	gl.BindBuffer(gl.ARRAY_BUFFER, m.normal_buf)
	gl.EnableVertexAttribArray(m.shader.attribute_normal)
	gl.VertexAttribPointer(
		m.shader.attribute_normal,
		3,
		gl.FLOAT,
		gl.FALSE,
		0,
		gl.Pointer(nil))

	gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, m.index)
	gl.DrawElements(gl.TRIANGLES, gl.Sizei(len(m.indices)), gl.UNSIGNED_INT, gl.Pointer(nil))

	gl.BindBuffer(gl.ARRAY_BUFFER, 0)
	gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, 0)
	gl.DisableVertexAttribArray(m.shader.attribute_vertex)
	gl.DisableVertexAttribArray(m.shader.attribute_normal)
	if m.has_uv {
		gl.DisableVertexAttribArray(m.shader.attribute_texcoord)
	}

}
开发者ID:drasich,项目名称:ridley,代码行数:52,代码来源:model.go


示例5: initquad

func initquad() {
	ver := []gl.Float{-1, 1, 1, 1, -1, -1, 1, -1}
	gl.BindBuffer(gl.ARRAY_BUFFER, 1)
	gl.BufferData(gl.ARRAY_BUFFER, gl.Sizeiptr(4*len(ver)),
		gl.Pointer(&ver[0]), gl.STATIC_DRAW)
	gl.VertexPointer(2, gl.FLOAT, 0, nil)
	tex := []gl.Float{0, 0, 1, 0, 0, 1, 1, 1}
	gl.BindBuffer(gl.ARRAY_BUFFER, 2)
	gl.BufferData(gl.ARRAY_BUFFER, gl.Sizeiptr(4*len(tex)),
		gl.Pointer(&tex[0]), gl.STATIC_DRAW)
	gl.TexCoordPointer(2, gl.FLOAT, 0, nil)
	gl.EnableClientState(gl.VERTEX_ARRAY)
	gl.EnableClientState(gl.TEXTURE_COORD_ARRAY)
}
开发者ID:jacereda,项目名称:webmplay,代码行数:14,代码来源:webmplay.go


示例6: createTexture

/*
Uses the image library to turn a PNG into a gl texture
*/
func createTexture(r io.Reader) (textureId gl.Uint, err error) {
	img, err := png.Decode(r)
	if err != nil {
		return 0, err
	}

	rgbaImg, ok := img.(*image.RGBA)
	if !ok {
		return 0, errors.New("texture must be an RGBA image")
	}

	gl.GenTextures(1, &textureId)
	gl.BindTexture(gl.TEXTURE_2D, textureId)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)

	// flip image: first pixel is lower left corner
	imgWidth, imgHeight := img.Bounds().Dx(), img.Bounds().Dy()
	data := make([]byte, imgWidth*imgHeight*4)
	lineLen := imgWidth * 4
	dest := len(data) - lineLen
	for src := 0; src < len(rgbaImg.Pix); src += rgbaImg.Stride {
		copy(data[dest:dest+lineLen], rgbaImg.Pix[src:src+rgbaImg.Stride])
		dest -= lineLen
	}
	gl.TexImage2D(gl.TEXTURE_2D, 0, 4, gl.Sizei(imgWidth), gl.Sizei(imgHeight), 0, gl.RGBA,
		gl.UNSIGNED_BYTE, gl.Pointer(&data[0]))

	return textureId, nil
}
开发者ID:kelly-ry4n,项目名称:glGalaxy,代码行数:33,代码来源:texloader.go


示例7: Move

// Move moves the Shape object a specified distance.
func (shape *Shape) Move(x, y float64) {

	var verticies []float32

	for i := 0; i < len(shape.verticies); i += 2 {
		shape.verticies[i] += float32(x)
		shape.verticies[i+1] += float32(y)
	}

	if shape.scaleX != 1 || shape.scaleY != 1 {
		verticies = make([]float32, len(shape.verticies))

		xTransform := shape.verticies[0] - (shape.verticies[0] * float32(shape.scaleX))
		yTransform := shape.verticies[1] - (shape.verticies[1] * float32(shape.scaleY))

		for i := range verticies {
			if i%2 == 0 {
				verticies[i] = shape.verticies[i] * float32(shape.scaleX)
				verticies[i] += xTransform
			} else {
				verticies[i] = shape.verticies[i] * float32(shape.scaleY)
				verticies[i] += yTransform
			}
		}
	} else {
		verticies = shape.verticies
	}

	gl.BindBuffer(gl.ARRAY_BUFFER, shape.vertexBuffer)
	gl.BufferSubData(gl.ARRAY_BUFFER, 0, gl.Sizeiptr(len(verticies)*4), gl.Pointer(&verticies[0]))
	gl.BindBuffer(gl.ARRAY_BUFFER, 0)
}
开发者ID:velovix,项目名称:paunch,代码行数:33,代码来源:shape.go


示例8: loadCubeToGPU

func loadCubeToGPU() {
	newNormal(0, 0, 1)
	newVertex(-1, -1, 1)
	newVertex(1, -1, 1)
	newVertex(1, 1, 1)
	newVertex(-1, 1, 1)

	newNormal(0, 0, -1)
	newVertex(-1, -1, -1)
	newVertex(-1, 1, -1)
	newVertex(1, 1, -1)
	newVertex(1, -1, -1)

	newNormal(0, 1, 0)
	newVertex(-1, 1, -1)
	newVertex(-1, 1, 1)
	newVertex(1, 1, 1)
	newVertex(1, 1, -1)

	newNormal(0, -1, 0)
	newVertex(-1, -1, -1)
	newVertex(1, -1, -1)
	newVertex(1, -1, 1)
	newVertex(-1, -1, 1)

	newNormal(1, 0, 0)
	newVertex(1, -1, -1)
	newVertex(1, 1, -1)
	newVertex(1, 1, 1)
	newVertex(1, -1, 1)

	newNormal(-1, 0, 0)
	newVertex(-1, -1, -1)
	newVertex(-1, -1, 1)
	newVertex(-1, 1, 1)
	newVertex(-1, 1, -1)

	gl.GenBuffers(1, &gVBO)
	gl.BindBuffer(gl.ARRAY_BUFFER, gVBO)
	gl.BufferData(gl.ARRAY_BUFFER, gl.Sizeiptr(unsafe.Sizeof(Vertex{})*24), gl.Pointer(&Vertices[0]), gl.STATIC_DRAW)

	gl.EnableClientState(gl.VERTEX_ARRAY)
	gl.EnableClientState(gl.NORMAL_ARRAY)
	gl.VertexPointer(3, gl.FLOAT, 24, nil)
	tmpStruct := Vertex{}
	gl.NormalPointer(gl.FLOAT, gl.Sizei(unsafe.Sizeof(Vertex{})), gl.Pointer(unsafe.Offsetof(tmpStruct.normal)))
}
开发者ID:ReneSac,项目名称:ParticleBench,代码行数:47,代码来源:Go.go


示例9: upload

func upload(id gl.Uint, data []byte, stride int, w int, h int) {
	gl.BindTexture(gl.TEXTURE_2D, id)
	gl.PixelStorei(gl.UNPACK_ROW_LENGTH, gl.Int(stride))
	gl.PixelStorei(gl.UNPACK_ALIGNMENT, 1)
	gl.TexImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE,
		gl.Sizei(w), gl.Sizei(h), 0,
		gl.LUMINANCE, gl.UNSIGNED_BYTE, gl.Pointer(&data[0]))
}
开发者ID:jacereda,项目名称:webmplay,代码行数:8,代码来源:webmplay.go


示例10: init

func (m *Model) init() (err error) {
	m.shader.init("shader/simple.vert", "shader/simple.frag")

	/*
	  gl.GenBuffers(1, &m.buffer)
	  gl.BindBuffer(gl.ARRAY_BUFFER, m.buffer);
	  gl.BufferData(
	    gl.ARRAY_BUFFER,
	    gl.Sizeiptr(len(m.vertices)* int(unsafe.Sizeof(m.vertices[0]))),
	    gl.Pointer(&m.vertices[0]),
	    gl.STATIC_DRAW);
	*/

	m.initBufferFloat(&m.buffer, gl.ARRAY_BUFFER, &m.vertices)

	gl.GenBuffers(1, &m.index)
	gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, m.index)
	gl.BufferData(
		gl.ELEMENT_ARRAY_BUFFER,
		gl.Sizeiptr(len(m.indices)*int(unsafe.Sizeof(m.indices[0]))),
		gl.Pointer(&m.indices[0]),
		gl.STATIC_DRAW)

	gl.GenBuffers(1, &m.normal_buf)
	gl.BindBuffer(gl.ARRAY_BUFFER, m.normal_buf)
	gl.BufferData(
		gl.ARRAY_BUFFER,
		gl.Sizeiptr(len(m.normals)*int(unsafe.Sizeof(m.normals[0]))),
		gl.Pointer(&m.normals[0]),
		gl.STATIC_DRAW)

	m.initTexture()

	if m.has_uv {
		gl.GenBuffers(1, &m.texcoord)
		gl.BindBuffer(gl.ARRAY_BUFFER, m.texcoord)
		gl.BufferData(
			gl.ARRAY_BUFFER,
			gl.Sizeiptr(len(m.uvs)*int(unsafe.Sizeof(m.uvs[0]))),
			gl.Pointer(&m.uvs[0]),
			gl.STATIC_DRAW)
	}

	return
}
开发者ID:drasich,项目名称:ridley,代码行数:45,代码来源:model.go


示例11: initBufferFloat

func (m *Model) initBufferFloat(buffer *gl.Uint, t gl.Enum, data *[]gl.Float) {
	gl.GenBuffers(1, buffer)
	gl.BindBuffer(t, *buffer)
	gl.BufferData(
		t,
		gl.Sizeiptr(len(*data)*int(unsafe.Sizeof((*data)[0]))),
		gl.Pointer(&(*data)[0]),
		gl.STATIC_DRAW)
}
开发者ID:drasich,项目名称:ridley,代码行数:9,代码来源:model.go


示例12: glInit

func glInit(width, height int) {
	gl.Init()
	gl.Enable(gl.TEXTURE_2D)
	gl.PixelStorei(gl.UNPACK_ALIGNMENT, 1)
	gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, gl.Double(width), gl.Double(height), 0, -1, 1)
	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	gl.EnableClientState(gl.VERTEX_ARRAY)
	gl.EnableClientState(gl.COLOR_ARRAY)
	gl.EnableClientState(gl.TEXTURE_COORD_ARRAY)
	gl.VertexPointer(2, gl.FLOAT, 0, gl.Pointer(&vs[0]))
	gl.ColorPointer(3, gl.UNSIGNED_BYTE, 0, gl.Pointer(&cs[0]))
	gl.TexCoordPointer(2, gl.FLOAT, 0, gl.Pointer(&ts[0]))
}
开发者ID:ajhager,项目名称:rog,代码行数:20,代码来源:backend.go


示例13: makeErrorTexture

func makeErrorTexture() {
	gl.Enable(gl.TEXTURE_2D)
	gl.GenTextures(1, (*gl.Uint)(&error_texture))
	gl.BindTexture(gl.TEXTURE_2D, error_texture)
	gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
	pink := []byte{255, 0, 255, 255}
	gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.BYTE, gl.Pointer(&pink[0]))
}
开发者ID:runningwild,项目名称:jbot,代码行数:12,代码来源:texture_devel.go


示例14: reuploadTexture

func reuploadTexture(tex *gl.Uint, w, h int, data []byte) {
	if *tex > 0 {
		gl.BindTexture(gl.TEXTURE_2D, *tex)
		gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.Sizei(w), gl.Sizei(h), 0,
			gl.RGBA, gl.UNSIGNED_BYTE, gl.Pointer(&data[0]))
		if gl.GetError() != gl.NO_ERROR {
			gl.DeleteTextures(1, tex)
			panic("Failed to reupload texture")
		}
		return
	}
	*tex = uploadTexture_RGBA32(w, h, data)
}
开发者ID:nsf,项目名称:gomandel,代码行数:13,代码来源:gomandel.go


示例15: NewShapeFromShape

// NewShapeFromShape creates a copy of an existing Shape object.
func NewShapeFromShape(copyShape *Shape) (*Shape, error) {

	shape := &Shape{mode: copyShape.mode, size: copyShape.size, verticies: make([]float32, len(copyShape.verticies)),
		scaleX: copyShape.scaleX, scaleY: copyShape.scaleY}

	copy(shape.verticies, copyShape.verticies)

	gl.GenBuffers(1, &shape.vertexBuffer)
	gl.BindBuffer(gl.ARRAY_BUFFER, shape.vertexBuffer)
	gl.BufferData(gl.ARRAY_BUFFER, gl.Sizeiptr(len(shape.verticies)*4), gl.Pointer(&shape.verticies[0]), gl.DYNAMIC_DRAW)
	gl.BindBuffer(gl.ARRAY_BUFFER, 0)

	return shape, checkForErrors()
}
开发者ID:velovix,项目名称:paunch,代码行数:15,代码来源:shape.go


示例16: screenShot

func screenShot() {
	b := make([]uint8, Width*Height*4)
	gl.ReadPixels(0, 0, Width, Height, gl.RGBA, gl.UNSIGNED_BYTE, gl.Pointer(&b[0]))
	rect := image.Rect(0, 0, Width, Height)
	im := image.NRGBA{
		Pix:    b,
		Stride: Width * 4,
		Rect:   rect,
	}

	if f, err := os.Create("screenshot.png"); err == nil {
		defer f.Close()
		png.Encode(f, &im)
	}
}
开发者ID:jayschwa,项目名称:groke,代码行数:15,代码来源:bspview.go


示例17: NewShape

// NewShape creates a new Shape object based on the verticies and shape type.
func NewShape(shapeType ShapeType, verticies []float64) (*Shape, error) {

	verticies32 := make([]float32, len(verticies))
	for i, val := range verticies {
		verticies32[i] = float32(val)
	}

	shape := &Shape{mode: gl.Enum(shapeType), size: len(verticies), vertexBuffer: 0, verticies: verticies32,
		scaleX: 1, scaleY: 1}

	gl.GenBuffers(1, &shape.vertexBuffer)
	gl.BindBuffer(gl.ARRAY_BUFFER, gl.Uint(shape.vertexBuffer))
	gl.BufferData(gl.ARRAY_BUFFER, gl.Sizeiptr(shape.size*4), gl.Pointer(&shape.verticies[0]), gl.DYNAMIC_DRAW)
	gl.BindBuffer(gl.ARRAY_BUFFER, 0)

	return shape, checkForErrors()
}
开发者ID:velovix,项目名称:paunch,代码行数:18,代码来源:shape.go


示例18: initTexture

func (m *Model) initTexture() {
	//file, err := os.Open("model/test.png")
	file, err := os.Open("model/ceil.png")
	if err != nil {
		log.Fatal(err)
	}
	defer file.Close()

	img, _, err := image.Decode(file)
	if err != nil {
		log.Fatal(err)
	}

	rgbaImg, ok := img.(*image.NRGBA)
	if !ok {
		//return 0, errors.New("texture must be an NRGBA image")
		log.Fatal("image is not rgba")
	}

	gl.GenTextures(1, &m.texture_id)
	gl.BindTexture(gl.TEXTURE_2D, m.texture_id)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
	gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)

	// flip image: first pixel is lower left corner
	img_width, img_height := img.Bounds().Dx(), img.Bounds().Dy()
	data := make([]byte, img_width*img_height*4)
	line_len := img_width * 4
	dest := len(data) - line_len
	for src := 0; src < len(rgbaImg.Pix); src += rgbaImg.Stride {
		copy(data[dest:dest+line_len], rgbaImg.Pix[src:src+rgbaImg.Stride])
		dest -= line_len
	}
	gl.TexImage2D(
		gl.TEXTURE_2D,
		0,
		gl.RGBA, //4,
		gl.Sizei(img_width),
		gl.Sizei(img_height),
		0,
		gl.RGBA,
		gl.UNSIGNED_BYTE,
		gl.Pointer(&data[0]))

}
开发者ID:drasich,项目名称:ridley,代码行数:45,代码来源:model.go


示例19: uploadTexture_RGBA32

func uploadTexture_RGBA32(w, h int, data []byte) gl.Uint {
	var id gl.Uint
	gl.GenTextures(1, &id)
	gl.BindTexture(gl.TEXTURE_2D, id)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
	gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_R, gl.CLAMP_TO_EDGE)
	gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.Sizei(w), gl.Sizei(h), 0, gl.RGBA,
		gl.UNSIGNED_BYTE, gl.Pointer(&data[0]))

	if gl.GetError() != gl.NO_ERROR {
		gl.DeleteTextures(1, &id)
		panic("Failed to load a texture")
	}
	return id
}
开发者ID:nsf,项目名称:gomandel,代码行数:18,代码来源:gomandel.go


示例20: LoadSprite

func (m *Manager) LoadSprite(path string) (*Sprite, error) {
	// We can't run this during an init() function because it will get queued to
	// run before the opengl context is created, so we just check here and run
	// it if we haven't run it before.
	gen_tex_once.Do(func() {
		render.Queue(func() {
			gl.Enable(gl.TEXTURE_2D)
			gl.GenTextures(1, &error_texture)
			gl.BindTexture(gl.TEXTURE_2D, error_texture)
			gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
			gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR)
			gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
			gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
			gl.TexParameterf(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
			pink := []byte{255, 0, 255, 255}
			gl.TexImage2D(
				gl.TEXTURE_2D,
				0,
				gl.RGBA,
				1,
				1,
				0,
				gl.RGBA,
				gl.UNSIGNED_INT,
				gl.Pointer(&pink[0]))
		})
	})

	path = filepath.Clean(path)
	err := m.loadSharedSprite(path)
	if err != nil {
		return nil, err
	}
	var s Sprite
	m.mutex.Lock()
	s.shared = m.shared[path]
	m.mutex.Unlock()
	s.anim_node = s.shared.anim_start
	s.state_node = s.shared.state_start
	return &s, nil
}
开发者ID:runningwild,项目名称:glop,代码行数:41,代码来源:sprite.go



注:本文中的github.com/chsc/gogl/gl21.Pointer函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang gl21.Sizei函数代码示例发布时间:2022-05-23
下一篇:
Golang gl21.MatrixMode函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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