本文整理汇总了Golang中github.com/chsc/gogl/gl21.Sizei函数的典型用法代码示例。如果您正苦于以下问题:Golang Sizei函数的具体用法?Golang Sizei怎么用?Golang Sizei使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sizei函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: initWithString
func (s *Shader) initWithString(vert_shader string, frag_shader string) {
s.initShader(gl.VERTEX_SHADER, vert_shader, &s.vert_shader)
s.initShader(gl.FRAGMENT_SHADER, frag_shader, &s.frag_shader)
s.program = gl.CreateProgram()
gl.AttachShader(s.program, s.vert_shader)
gl.AttachShader(s.program, s.frag_shader)
gl.LinkProgram(s.program)
var (
status gl.Int
info_length gl.Int
message *gl.Char
)
gl.GetProgramiv(s.program, gl.LINK_STATUS, &status)
if status == gl.FALSE {
fmt.Println("Error linking program")
gl.GetProgramiv(s.program, gl.INFO_LOG_LENGTH, &info_length)
message = gl.GLStringAlloc(gl.Sizei(info_length))
gl.GetProgramInfoLog(s.program, gl.Sizei(info_length), nil, message)
fmt.Println(gl.GoString(message))
gl.GLStringFree(message)
}
s.initAttributes()
s.initUniforms()
}
开发者ID:drasich,项目名称:ridley,代码行数:31,代码来源:shader.go
示例2: InitViewport
func InitViewport() {
gl.Viewport(0, 0, gl.Sizei(Width), gl.Sizei(Height))
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
x := gl.Double(float64(Height) / float64(Width))
gl.Frustum(-1./2., 1./2., -x/2, x/2, 10, 100)
}
开发者ID:shenyp09,项目名称:mx3,代码行数:7,代码来源:input.go
示例3: resize
// resize resizes the window to the specified dimensions.
func resize(width, height int) {
gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
gl.MatrixMode(gl.MODELVIEW)
}
开发者ID:travis1230,项目名称:RosettaCodeData,代码行数:8,代码来源:opengl.go
示例4: run
func (w *Window) run() {
runtime.LockOSThread()
glfw.MakeContextCurrent(w.w)
defer glfw.MakeContextCurrent(nil)
// glfw should fire initial resize events to avoid this duplication (https://github.com/glfw/glfw/issues/62)
width, height := w.w.Size()
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Ortho(0, gl.Double(width), 0, gl.Double(height), -1, 1)
Resize(w, Pt(float64(width), float64(height)))
width, height = w.w.FramebufferSize()
gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
gl.Enable(gl.BLEND)
gl.Enable(gl.POINT_SMOOTH)
gl.Enable(gl.LINE_SMOOTH)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
for !w.close {
select {
case f := <-w.do:
f()
case <-w.paint:
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
w.base().paint()
w.w.SwapBuffers()
}
}
}
开发者ID:gordonklaus,项目名称:flux,代码行数:33,代码来源:window.go
示例5: initShader
func (s *Shader) initShader(t gl.Enum, str string, shader *gl.Uint) {
*shader = gl.CreateShader(t)
if *shader == 0 {
fmt.Println("error creating shader of type ", t)
}
src := gl.GLStringArray(str)
defer gl.GLStringArrayFree(src)
gl.ShaderSource(*shader, 1, &src[0], nil)
gl.CompileShader(*shader)
var (
status gl.Int
info_length gl.Int
message *gl.Char
)
gl.GetShaderiv(*shader, gl.COMPILE_STATUS, &status)
if status == gl.FALSE {
fmt.Println("Error compiling shader")
gl.GetShaderiv(*shader, gl.INFO_LOG_LENGTH, &info_length)
message = gl.GLStringAlloc(gl.Sizei(info_length))
gl.GetShaderInfoLog(*shader, gl.Sizei(info_length), nil, message)
fmt.Println(gl.GoString(message))
gl.GLStringFree(message)
}
}
开发者ID:drasich,项目名称:ridley,代码行数:29,代码来源:shader.go
示例6: createTexture
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.NRGBA)
if !ok {
return 0, errors.New("texture must be an NRGBA 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:sserafimescu,项目名称:gogl,代码行数:29,代码来源:gopher.go
示例7: 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
示例8: 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
示例9: windowResizeCallback
func windowResizeCallback(window *glfw.Window, width, height int) {
paunchWindow.width = width
paunchWindow.height = height
for _, eventManager := range paunchWindow.eventManagers {
eventManager.RunWindowResizeEvent(width, height)
}
gl.Viewport(0, 0, gl.Sizei(width), gl.Sizei(height))
}
开发者ID:velovix,项目名称:paunch,代码行数:11,代码来源:window.go
示例10: 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
示例11: RenderLocalEditor
func (g *Game) RenderLocalEditor(region g2.Region) {
g.editor.Lock()
defer g.editor.Unlock()
g.editor.region = region
g.editor.camera.regionDims = linear.Vec2{float64(region.Dims.Dx), float64(region.Dims.Dy)}
levelDims := linear.Vec2{float64(g.Level.Room.Dx), float64(g.Level.Room.Dy)}
g.editor.camera.StandardRegion(levelDims.Scale(0.5), levelDims)
g.editor.camera.approachTarget()
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
gl.LoadIdentity()
defer gl.PopMatrix()
gl.PushAttrib(gl.VIEWPORT_BIT)
gl.Viewport(gl.Int(region.X), gl.Int(region.Y), gl.Sizei(region.Dx), gl.Sizei(region.Dy))
defer gl.PopAttrib()
current := &g.editor.camera.current
gl.Ortho(
gl.Double(current.mid.X-current.dims.X/2),
gl.Double(current.mid.X+current.dims.X/2),
gl.Double(current.mid.Y+current.dims.Y/2),
gl.Double(current.mid.Y-current.dims.Y/2),
gl.Double(1000),
gl.Double(-1000),
)
defer func() {
gl.MatrixMode(gl.PROJECTION)
gl.PopMatrix()
gl.MatrixMode(gl.MODELVIEW)
}()
gl.MatrixMode(gl.MODELVIEW)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
g.renderWalls()
g.renderEdges()
g.renderBases()
g.renderEntsAndAbilities()
g.renderProcesses()
g.editor.renderPathing(&g.Level.Room, g.local.pathingData)
switch g.editor.action {
case editorActionNone:
case editorActionPlaceBlock:
g.editor.renderPlaceBlock(g)
default:
base.Error().Printf("Unexpected editorAction: %v", g.editor.action)
}
}
开发者ID:runningwild,项目名称:jota,代码行数:53,代码来源:editor_graphics.go
示例12: 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
示例13: initScene
func initScene(width, height int, init func()) (err error) {
gl.Disable(gl.DEPTH_TEST)
gl.ClearColor(0.5, 0.5, 0.5, 0.0)
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, 0, 1)
gl.MatrixMode(gl.MODELVIEW)
init()
return
}
开发者ID:jaredly,项目名称:rocks,代码行数:15,代码来源:draw.go
示例14: Draw
// Draw draws the Sprite object.
func (sprite *Sprite) Draw(frame int) error {
gl.BindBuffer(gl.ARRAY_BUFFER, sprite.shape.vertexBuffer)
gl.VertexAttribPointer(gl.Uint(0), 2, gl.FLOAT, gl.FALSE, 0, gl.Offset(nil, 0))
gl.BindAttribLocation(paunchEffect.program, gl.Uint(0), gl.GLString("position"))
gl.BindBuffer(gl.ARRAY_BUFFER, 0)
if sprite.texcoordBuffer != 0 {
gl.ActiveTexture(gl.TEXTURE0)
gl.BindBuffer(gl.ARRAY_BUFFER, sprite.texcoordBuffer)
gl.VertexAttribPointer(gl.Uint(1), 2, gl.FLOAT, gl.FALSE, 0, gl.Offset(nil, 0))
gl.BindAttribLocation(paunchEffect.program, gl.Uint(0), gl.GLString("texcoord"))
gl.BindBuffer(gl.ARRAY_BUFFER, 0)
gl.BindTexture(gl.TEXTURE_2D, sprite.texture[frame])
gl.EnableVertexAttribArray(gl.Uint(1))
}
gl.EnableVertexAttribArray(gl.Uint(0))
gl.DrawArrays(gl.TRIANGLES, 0, gl.Sizei(sprite.shape.size))
gl.DisableVertexAttribArray(gl.Uint(0))
gl.DisableVertexAttribArray(gl.Uint(1))
gl.BindTexture(gl.TEXTURE_2D, 0)
return checkForErrors()
}
开发者ID:velovix,项目名称:paunch,代码行数:29,代码来源:sprite.go
示例15: 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
示例16: Screenshot
func Screenshot() {
log.Println("screenshot")
img := image.NewNRGBA(image.Rect(0, 0, Width, Height))
gl.ReadPixels(0, 0, gl.Sizei(Width), gl.Sizei(Height), gl.RGBA, gl.UNSIGNED_INT_8_8_8_8, gl.Pointer(&img.Pix[0]))
// reverse byte order, opengl seems to use little endian.
pix := img.Pix
for i := 0; i < len(pix); i += 4 {
pix[i+0], pix[i+1], pix[i+2], pix[i+3] = pix[i+3], pix[i+2], pix[i+1], pix[i+0]
}
fname := fmt.Sprintf("frame%04d.png", scroti)
scroti++
f, err := os.OpenFile(fname, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0666)
core.Fatal(err)
defer f.Close()
core.Fatal(png.Encode(f, img))
}
开发者ID:shenyp09,项目名称:mx3,代码行数:16,代码来源:screenshot.go
示例17: OnResize
func (a *app) OnResize(w, h int) {
oaspect := float64(a.imgW()) / float64(a.imgH())
haspect := float64(w) / float64(h)
vaspect := float64(h) / float64(w)
var scx, scy float64
if oaspect > haspect {
scx = 1
scy = haspect / oaspect
} else {
scx = vaspect * oaspect
scy = 1
}
gl.Viewport(0, 0, gl.Sizei(w), gl.Sizei(h))
gl.LoadIdentity()
gl.Scaled(gl.Double(scx), gl.Double(scy), 1)
}
开发者ID:jacereda,项目名称:webmplay,代码行数:16,代码来源:webmplay.go
示例18: SetUpCamera
func SetUpCamera(
screenWidth int32,
screenHeight int32,
lb *LevelBlueprint,
playerIndex int32) {
pb := &lb.Players[playerIndex]
// Calculate the distance between the near plane and the camera. We want
// (PaddleAreaWidth / 2) / cameraDist = tan(CameraHorzFovDegrees / 2)
t := math.Tan(math.Pi * Config.CameraHorzFovDegrees / 360)
cameraDist := pb.PaddleAreaWidth / (2 * t)
cameraPos := pb.PaddleAreaCenter.Minus(
pb.Orientation.Forward.Times(cameraDist))
// Set up the projection matrix.
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gl.Viewport(0, 0, gl.Sizei(screenWidth), gl.Sizei(screenHeight))
gl.Frustum(
gl.Double(-pb.PaddleAreaWidth/2), gl.Double(pb.PaddleAreaWidth/2),
gl.Double(-pb.PaddleAreaHeight/2), gl.Double(pb.PaddleAreaHeight/2),
gl.Double(cameraDist), gl.Double(cameraDist+Config.ViewDepth))
// Set up the modelview matrix.
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
transformation := [16]gl.Double{
gl.Double(pb.Orientation.Right.X),
gl.Double(pb.Orientation.Up.X),
gl.Double(-pb.Orientation.Forward.X),
gl.Double(0.0),
gl.Double(pb.Orientation.Right.Y),
gl.Double(pb.Orientation.Up.Y),
gl.Double(-pb.Orientation.Forward.Y),
gl.Double(0.0),
gl.Double(pb.Orientation.Right.Z),
gl.Double(pb.Orientation.Up.Z),
gl.Double(-pb.Orientation.Forward.Z),
gl.Double(0.0),
gl.Double(0.0), gl.Double(0.0), gl.Double(0.0), gl.Double(1.0)}
gl.MultMatrixd(&transformation[0])
gl.Translated(
gl.Double(-cameraPos.X),
gl.Double(-cameraPos.Y),
gl.Double(-cameraPos.Z))
}
开发者ID:runningwild,项目名称:arkanoid,代码行数:46,代码来源:level-blueprint.go
示例19: RenderLocalGame
func (g *Game) RenderLocalGame(region g2.Region) {
g.local.Camera.regionDims = linear.Vec2{float64(region.Dims.Dx), float64(region.Dims.Dy)}
// func (g *Game) renderLocalHelper(region g2.Region, local *LocalData, camera *cameraInfo, side int) {
g.local.Camera.FocusRegion(g, 0)
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
gl.LoadIdentity()
// Set the viewport so that we only render into the region that we're supposed
// to render to.
// TODO: Check if this works on all graphics cards - I've heard that the opengl
// spec doesn't actually require that viewport does any clipping.
gl.PushAttrib(gl.VIEWPORT_BIT)
gl.Viewport(gl.Int(region.X), gl.Int(region.Y), gl.Sizei(region.Dx), gl.Sizei(region.Dy))
defer gl.PopAttrib()
current := &g.local.Camera.current
gl.Ortho(
gl.Double(current.mid.X-current.dims.X/2),
gl.Double(current.mid.X+current.dims.X/2),
gl.Double(current.mid.Y+current.dims.Y/2),
gl.Double(current.mid.Y-current.dims.Y/2),
gl.Double(1000),
gl.Double(-1000),
)
defer func() {
gl.MatrixMode(gl.PROJECTION)
gl.PopMatrix()
gl.MatrixMode(gl.MODELVIEW)
}()
gl.MatrixMode(gl.MODELVIEW)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
level := g.Level
zoom := current.dims.X / float64(region.Dims.Dx)
level.ManaSource.Draw(zoom, float64(level.Room.Dx), float64(level.Room.Dy))
g.renderWalls()
g.renderEdges()
g.renderBases()
g.renderEntsAndAbilities()
g.renderProcesses()
g.RenderLosMask()
}
开发者ID:runningwild,项目名称:jota,代码行数:45,代码来源:game_graphics.go
示例20: 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
注:本文中的github.com/chsc/gogl/gl21.Sizei函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论