当前位置: 首页>>代码示例>>Golang>>正文


Golang gl.ShadeModel函数代码示例

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


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

示例1: initGL

func initGL() {
	gl.ShadeModel(gl.SMOOTH)
	gl.ClearColor(0, 0, 0, 0)
	gl.ClearDepth(1)
	gl.Enable(gl.DEPTH_TEST)
	gl.DepthFunc(gl.LEQUAL)
	gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
}
开发者ID:nightkidfifa,项目名称:poly2tri.golang,代码行数:8,代码来源:main.go

示例2: initGL

// general OpenGL initialization
func initGL() {
	LoadGLTexture("data/star.bmp")

	gl.Enable(gl.TEXTURE_2D)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE)
	gl.ShadeModel(gl.SMOOTH)
	gl.ClearColor(0.0, 0.0, 0.0, 0.5)
	gl.ClearDepth(1.0)
	gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:12,代码来源:lesson09.go

示例3: init_

func init_() {
	//pos := []float64{5.0, 5.0, 10.0, 0.0}

	colors := map[string][]float32{
		"0": {0.7, 0.7, 0.7, 1.0},
		"1": {1.0, 0.0, 0.0, 1.0},
		"2": {1.0, 0.6, 0.0, 1.0},
		"3": {1.0, 1.0, 0.0, 1.0},
		"4": {0.0, 1.0, 0.0, 1.0},
		"5": {0.0, 0.0, 1.0, 1.0},
		"6": {0.0, 0.6, 1.0, 1.0},
		"7": {1.0, 0.0, 1.0, 1.0},
		"8": {1.0, 1.0, 1.0, 1.0},
		"9": {0.3, 0.3, 0.3, 1.0},
	}

	fetchChunks(2, 2)

	gl.ShadeModel(gl.SMOOTH)
	gl.ClearColor(0.2, 0.2, 0.6, 0.0)
	gl.ClearDepth(1.0)

	gl.Enable(gl.DEPTH_TEST)
	gl.DepthFunc(gl.LEQUAL)
	gl.Enable(gl.COLOR_MATERIAL)
	gl.Enable(gl.CULL_FACE)
	gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
	gl.Hint(gl.LINE_SMOOTH_HINT, gl.NICEST)

	gl.Lightfv(gl.LIGHT0, gl.AMBIENT, lightAmbient)
	gl.Lightfv(gl.LIGHT0, gl.DIFFUSE, lightDiffuse)
	gl.Lightfv(gl.LIGHT0, gl.POSITION, lightPosition)
	gl.Enable(gl.LIGHT0)
	gl.Enable(gl.LIGHTING)

	for name, color := range colors {
		/* make a cube */
		cubes[name] = gl.GenLists(1)
		gl.NewList(cubes[name], gl.COMPILE)
		cube(color)
		gl.EndList()
	}

	if *printInfo {
		print("GL_RENDERER   = ", gl.GetString(gl.RENDERER), "\n")
		print("GL_VERSION    = ", gl.GetString(gl.VERSION), "\n")
		print("GL_VENDOR     = ", gl.GetString(gl.VENDOR), "\n")
		print("GL_EXTENSIONS = ", gl.GetString(gl.EXTENSIONS), "\n")
	}

}
开发者ID:yohcop,项目名称:cubopolis.go,代码行数:51,代码来源:main.go

示例4: SetupVideo

func SetupVideo() {

	if sdl.Init(sdl.INIT_VIDEO) < 0 {
		panic("Couldn't initialize sdl")
	}

	w := WinW
	h := WinH

	var screen = sdl.SetVideoMode(w, h, 32, SDL_FLAGS)

	//	var screen = sdl.SetVideoMode(w, h, 32, sdl.OPENGLBLIT | sdl.DOUBLEBUF | sdl.HWSURFACE)
	//	var screen = sdl.SetVideoMode(w, h, 32, sdl.OPENGL)

	if screen == nil {
		panic("sdl error")
	}

	if ttf.Init() != 0 {
		panic("ttf init error")
	}

	if gl.Init() != 0 {
		panic("Couldn't init gl")
	}

	ResizeWindow(screen.W, screen.H)

	gl.ClearColor(0, 0, 0, 0)
	//	gl.ClearColor(1, 1, 1, 0)
	gl.ClearDepth(1.0)
	gl.DepthFunc(gl.LEQUAL)
	gl.Enable(gl.DEPTH_TEST)
	gl.ShadeModel(gl.SMOOTH)
	gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)

	/*
		if gl.Init() != 0 {
			panic("glew error")
		}
	*/
	//	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT )

	// gl.Clear(gl.COLOR_BUFFER_BIT)

	// initGL

	// gl.Ortho(0, gl.GLdouble(screen.W), gl.GLdouble(screen.H), 0, -1.0, 1.0)

}
开发者ID:jcd,项目名称:go-gamelib,代码行数:50,代码来源:video.go

示例5: initGL

// general OpenGL initialization
func initGL() {
  gl.Enable(gl.TEXTURE_2D)
  gl.ShadeModel(gl.SMOOTH)
  gl.ClearColor(0.0, 0.0, 0.0, 0.5)
  gl.ClearDepth(1.0)
  gl.Enable(gl.DEPTH_TEST)
  gl.DepthFunc(gl.LEQUAL)
  gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)

  // Setup the light
  gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient[:]) // ambient lighting
  gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse[:]) // make it diffuse
  gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition[:]) // and place it
  gl.Enable(gl.LIGHT1) // and finally turn it on.

  gl.Color4f(1.0, 1.0, 1.0, 0.5) // Full Brightness, 50% Alpha ( NEW )
  gl.BlendFunc(gl.SRC_ALPHA, gl.ONE) // Blending Function For Translucency Based On Source Alpha Value ( NEW )
}
开发者ID:shogg,项目名称:opengl-go-tutorials,代码行数:19,代码来源:lesson08.go

示例6: initGL

// general OpenGL initialization
func initGL() {
	// enable smooth shading
	gl.ShadeModel(gl.SMOOTH)

	// Set the background to black
	gl.ClearColor(0.0, 0.0, 0.0, 0.0)

	// Depth buffer setup
	gl.ClearDepth(1.0)

	// Enable depth testing
	gl.Enable(gl.DEPTH_TEST)

	// The type of test
	gl.DepthFunc(gl.LEQUAL)

	// Nicest perspective correction
	gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:20,代码来源:lesson01.go

示例7: initGL

// general OpenGL initialization
func initGL() {
	LoadGLTextures("data/mud.bmp")

	gl.Enable(gl.TEXTURE_2D)
	gl.ShadeModel(gl.SMOOTH)
	gl.ClearColor(0.0, 0.0, 0.0, 0.0)
	gl.ClearDepth(1.0)
	gl.Enable(gl.DEPTH_TEST)
	gl.DepthFunc(gl.LEQUAL)
	gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)

	gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient[:])
	gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse[:])
	gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition[:])
	gl.Enable(gl.LIGHT1)

	gl.Color4f(1.0, 1.0, 1.0, 0.5)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE)
}
开发者ID:PragmaticCypher,项目名称:opengl-go-tutorials,代码行数:20,代码来源:lesson10.go

示例8: initGL

// general OpenGL initialization
func initGL() {
	gl.Enable(gl.TEXTURE_2D)
	gl.ShadeModel(gl.SMOOTH)
	gl.ClearColor(0.0, 0.0, 0.0, 0.5)
	gl.ClearDepth(1.0)
	gl.Enable(gl.DEPTH_TEST)
	gl.DepthFunc(gl.LEQUAL)
	gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)

	// Setup the light
	gl.Lightfv(gl.LIGHT1, gl.AMBIENT, lightAmbient1[:])   // ambient lighting
	gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, lightDiffuse1[:])   // make it diffuse
	gl.Lightfv(gl.LIGHT1, gl.POSITION, lightPosition1[:]) // and place it
	gl.Enable(gl.LIGHT1)                                  // and finally turn it on.

	gl.Lightfv(gl.LIGHT2, gl.AMBIENT, lightAmbient2[:])   // ambient lighting
	gl.Lightfv(gl.LIGHT2, gl.DIFFUSE, lightDiffuse2[:])   // make it diffuse
	gl.Lightfv(gl.LIGHT2, gl.POSITION, lightPosition2[:]) // and place it
	gl.Enable(gl.LIGHT2)                                  // and finally turn it on.
}
开发者ID:shogg,项目名称:opengl-go-tutorials,代码行数:21,代码来源:lesson07.go

示例9: gear

func gear(inner_radius, outer_radius, width float64, teeth int, tooth_depth float64) {
	var i int
	var r0, r1, r2 float64
	var angle, da float64
	var u, v, len float64

	r0 = inner_radius
	r1 = outer_radius - tooth_depth/2.0
	r2 = outer_radius + tooth_depth/2.0

	da = 2.0 * math.Pi / float64(teeth) / 4.0

	gl.ShadeModel(gl.FLAT)

	gl.Normal3d(0.0, 0.0, 1.0)

	/* draw front face */
	gl.Begin(gl.QUAD_STRIP)
	for i = 0; i <= teeth; i++ {
		angle = float64(i) * 2.0 * math.Pi / float64(teeth)
		gl.Vertex3d(r0*math.Cos(angle), r0*math.Sin(angle), width*0.5)
		gl.Vertex3d(r1*math.Cos(angle), r1*math.Sin(angle), width*0.5)
		if i < teeth {
			gl.Vertex3d(r0*math.Cos(angle), r0*math.Sin(angle), width*0.5)
			gl.Vertex3d(r1*math.Cos(angle+3*da), r1*math.Sin(angle+3*da), width*0.5)
		}
	}
	gl.End()

	/* draw front sides of teeth */
	gl.Begin(gl.QUADS)
	da = 2.0 * math.Pi / float64(teeth) / 4.0
	for i = 0; i < teeth; i++ {
		angle = float64(i) * 2.0 * math.Pi / float64(teeth)

		gl.Vertex3d(r1*math.Cos(angle), r1*math.Sin(angle), width*0.5)
		gl.Vertex3d(r2*math.Cos(angle+da), r2*math.Sin(angle+da), width*0.5)
		gl.Vertex3d(r2*math.Cos(angle+2*da), r2*math.Sin(angle+2*da), width*0.5)
		gl.Vertex3d(r1*math.Cos(angle+3*da), r1*math.Sin(angle+3*da), width*0.5)
	}
	gl.End()

	gl.Normal3d(0.0, 0.0, -1.0)

	/* draw back face */
	gl.Begin(gl.QUAD_STRIP)
	for i = 0; i <= teeth; i++ {
		angle = float64(i) * 2.0 * math.Pi / float64(teeth)
		gl.Vertex3d(r1*math.Cos(angle), r1*math.Sin(angle), -width*0.5)
		gl.Vertex3d(r0*math.Cos(angle), r0*math.Sin(angle), -width*0.5)
		if i < teeth {
			gl.Vertex3d(r1*math.Cos(angle+3*da), r1*math.Sin(angle+3*da), -width*0.5)
			gl.Vertex3d(r0*math.Cos(angle), r0*math.Sin(angle), -width*0.5)
		}
	}
	gl.End()

	/* draw back sides of teeth */
	gl.Begin(gl.QUADS)
	da = 2.0 * math.Pi / float64(teeth) / 4.0
	for i = 0; i < teeth; i++ {
		angle = float64(i) * 2.0 * math.Pi / float64(teeth)

		gl.Vertex3d(r1*math.Cos(angle+3*da), r1*math.Sin(angle+3*da), -width*0.5)
		gl.Vertex3d(r2*math.Cos(angle+2*da), r2*math.Sin(angle+2*da), -width*0.5)
		gl.Vertex3d(r2*math.Cos(angle+da), r2*math.Sin(angle+da), -width*0.5)
		gl.Vertex3d(r1*math.Cos(angle), r1*math.Sin(angle), -width*0.5)
	}
	gl.End()

	/* draw outward faces of teeth */
	gl.Begin(gl.QUAD_STRIP)
	for i = 0; i < teeth; i++ {
		angle = float64(i) * 2.0 * math.Pi / float64(teeth)

		gl.Vertex3d(r1*math.Cos(angle), r1*math.Sin(angle), width*0.5)
		gl.Vertex3d(r1*math.Cos(angle), r1*math.Sin(angle), -width*0.5)
		u = r2*math.Cos(angle+da) - r1*math.Cos(angle)
		v = r2*math.Sin(angle+da) - r1*math.Sin(angle)
		len = math.Sqrt(u*u + v*v)
		u /= len
		v /= len
		gl.Normal3d(v, -u, 0.0)
		gl.Vertex3d(r2*math.Cos(angle+da), r2*math.Sin(angle+da), width*0.5)
		gl.Vertex3d(r2*math.Cos(angle+da), r2*math.Sin(angle+da), -width*0.5)
		gl.Normal3d(math.Cos(angle), math.Sin(angle), 0.0)
		gl.Vertex3d(r2*math.Cos(angle+2*da), r2*math.Sin(angle+2*da), width*0.5)
		gl.Vertex3d(r2*math.Cos(angle+2*da), r2*math.Sin(angle+2*da), -width*0.5)
		u = r1*math.Cos(angle+3*da) - r2*math.Cos(angle+2*da)
		v = r1*math.Sin(angle+3*da) - r2*math.Sin(angle+2*da)
		gl.Normal3d(v, -u, 0.0)
		gl.Vertex3d(r1*math.Cos(angle+3*da), r1*math.Sin(angle+3*da), width*0.5)
		gl.Vertex3d(r1*math.Cos(angle+3*da), r1*math.Sin(angle+3*da), -width*0.5)
		gl.Normal3d(math.Cos(angle), math.Sin(angle), 0.0)
	}

	gl.Vertex3d(r1*math.Cos(0), r1*math.Sin(0), width*0.5)
	gl.Vertex3d(r1*math.Cos(0), r1*math.Sin(0), -width*0.5)

	gl.End()
//.........这里部分代码省略.........
开发者ID:DeedleFake,项目名称:Go-OpenGL,代码行数:101,代码来源:gogears.go


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