本文整理汇总了Golang中github.com/banthar/gl.ShadeModel函数的典型用法代码示例。如果您正苦于以下问题:Golang ShadeModel函数的具体用法?Golang ShadeModel怎么用?Golang ShadeModel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ShadeModel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: initGL
func (this *Window) initGL() {
runtime.LockOSThread()
if gl.Init() != 0 {
panic("gl init error")
}
gl.ShadeModel(gl.SMOOTH)
gl.CullFace(gl.BACK)
gl.FrontFace(gl.CCW)
gl.Enable(gl.CULL_FACE)
gl.Enable(gl.DEPTH_TEST)
gl.Enable(gl.LIGHTING)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Enable(gl.TEXTURE_2D)
gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
var magFilter, minFilter = gl.LINEAR, gl.LINEAR
if globals.CreateMipmaps {
minFilter = gl.LINEAR_MIPMAP_LINEAR
}
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter)
gl.Enable(gl.NORMALIZE)
gl.ClearColor(.1, .1, .1, 1)
this.setGLViewport()
}
示例2: initGL
func (this *Window) initGL() {
gl.ShadeModel(gl.SMOOTH) //SMOOTH or FLAT
gl.CullFace(gl.BACK)
gl.FrontFace(gl.CCW)
gl.Enable(gl.CULL_FACE)
gl.Enable(gl.DEPTH_TEST)
gl.Enable(gl.LIGHTING)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
/*gl.Enable(gl.FOG)
gl.Fogi(gl.FOG_MODE, gl.EXP)
gl.Fogfv(gl.FOG_COLOR, []float32{0.5,0.5,0.5,1.0})
gl.Fogf(gl.FOG_DENSITY, 0.0035)
gl.Hint(gl.FOG_HINT, gl.DONT_CARE)
gl.Fogf(gl.FOG_START, 1.0)
gl.Fogf(gl.FOG_END , 5000.0)//*/
gl.Enable(gl.TEXTURE_2D)
gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE) //before: decal, std: modulate
//gl.TexParameteri(gl.TEXTURE_2D, gl.GENERATE_MIPMAP, true) //mipmaps (dont use it!, its bad!)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT)
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR) //GL_LINEAR or GL_NEAREST, no mipmap here
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR) //*/
gl.ClearColor(.1, .1, .1, 1)
//gl.Enable(gl.PRIMITIVE_RESTART)
//gl.PrimitiveRestartIndex()
this.setGLViewport()
}
示例3: main
func main() {
var err error
if err = glfw.Init(); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
defer glfw.Terminate()
if err = glfw.OpenWindow(Width, Height, 8, 8, 8, 8, 0, 8, glfw.Windowed); err != nil {
fmt.Fprintf(os.Stderr, "[e] %v\n", err)
return
}
defer glfw.CloseWindow()
glfw.SetSwapInterval(1)
glfw.SetWindowTitle(Title)
glfw.SetWindowSizeCallback(onResize)
glfw.SetKeyCallback(onKey)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0, 0, 0, 0)
gl.ClearDepth(1)
gl.Enable(gl.TEXTURE_2D)
for running && glfw.WindowParam(glfw.Opened) == 1 {
update()
draw()
}
}
示例4: 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)
}
示例5: initGL
func initGL() {
gl.EnableClientState(gl.VERTEX_ARRAY)
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0, 0, 0, 0)
gl.ClearDepth(1)
gl.DepthFunc(gl.LEQUAL)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
gl.Enable(gl.DEPTH_TEST)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
}
示例6: 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)
}
示例7: initGL
func initGL() (err error) {
if err = loadTextures(); err != nil {
return
}
gl.ShadeModel(gl.SMOOTH)
gl.ClearColor(0, 0, 0, 0)
gl.ClearDepth(1)
gl.DepthFunc(gl.LEQUAL)
gl.Hint(gl.PERSPECTIVE_CORRECTION_HINT, gl.NICEST)
gl.Enable(gl.DEPTH_TEST)
gl.Enable(gl.TEXTURE_2D)
return
}
示例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, 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 )
}
示例9: 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)
}
示例10: 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)
}
示例11: setup_opengl
func setup_opengl(width, height int) {
ratio := float64(width) / float64(height)
gl.ShadeModel(gl.SMOOTH)
gl.CullFace(gl.BACK)
gl.FrontFace(gl.CCW)
gl.Enable(gl.CULL_FACE)
gl.ClearColor(0, 0, 0, 0)
gl.Viewport(0, 0, width, height)
gl.MatrixMode(gl.PROJECTION)
gl.LoadIdentity()
gluPerspective := func(fovy, aspect, zNear, zFar float64) {
top := math.Tan(fovy*0.5) * zNear
bottom := -top
left := aspect * bottom
right := -left
gl.Frustum(left, right, bottom, top, zNear, zFar)
}
gluPerspective(60.0, ratio, 1.0, 1024.0)
}
示例12: 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)
globalState.light[0] = 0
globalState.light[1] = 20
globalState.light[2] = -10
globalState.light[3] = 1
gl.Lightfv(gl.LIGHT1, gl.AMBIENT, []float32{1, 1, 1})
gl.Lightfv(gl.LIGHT1, gl.DIFFUSE, []float32{1, 1, 1})
gl.Lightfv(gl.LIGHT1, gl.POSITION, globalState.light[:])
gl.Enable(gl.LIGHT1)
gl.Enable(gl.LIGHTING)
}
示例13: 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.
}
示例14: 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()
//.........这里部分代码省略.........
示例15: main
func main() {
w := 500
h := 500
fov := 45.0
clip_min := 0.1
clip_max := 1000.0
aspect_ratio := float64(w) / float64(h)
glfw.Init()
glfw.OpenWindow(w, h, 8, 8, 8, 8, 8, 0, glfw.Windowed)
glfw.SetWindowTitle("Shader Test")
glfw.SetWindowSizeCallback(resize_window)
glfw.SetKeyCallback(key_callback)
gl.ClearColor(0.3, 0.3, 0.3, 1.0)
gl.ShadeModel(gl.SMOOTH)
size_window(w, h, fov, aspect_ratio, clip_min, clip_max)
//Testing sprites
test_sprite := sprite{height: 1.0, width: 1.0}
test_sprite.tex = texture("./assets/hedge.gif")
test_sprite.Y = 3
new_guy := sprite{height: 0.5, width: 0.5}
new_guy.tex = texture("./assets/red2.png")
new_guy.Y = 5
renderees := new(list.List)
renderees.PushBack(&new_guy)
renderees.PushBack(&test_sprite)
my_camera.init(Vector{0.0, -1.0, 0.0})
my_camera.front = Vector{0.0, 1.0, 0.0}
my_camera.top = Vector{0.0, 0.0, 1.0}
//End testing sprites
physics_objects := new(list.List)
physics_objects.PushBack(my_camera)
dt, err := time.ParseDuration("16.67ms")
if err != nil {
die(err)
}
fmt.Println("Timestep: ", dt)
var t float64 = 0
running := true
for running {
t0 := time.Now()
update(physics_objects, float64(dt.Nanoseconds())/1e6)
t += 0.025
new_guy.X = math.Cos(t)
new_guy.Y = math.Sin(t) + 3.0
//my_camera.point_at(Vector{new_guy.X, new_guy.Y, new_guy.Z})
general_render(renderees, my_camera)
glfw.SwapBuffers()
dt = time.Since(t0)
rate := time.Microsecond * 16670
if dt < rate {
time.Sleep((rate - dt))
//fmt.Println("This frame took", float64(dt.Nanoseconds())/1000000, "ms to render.")
}
running = glfw.Key(glfw.KeyEsc) == 0 && glfw.WindowParam(glfw.Opened) != 0
}
}