Exemplo n.º 1
0
func drawSelection(p1, p2 Point) {
	min, max := minMaxPoints(p1, p2)

	gl.Color3ub(255, 0, 0)
	gl.Begin(gl.LINES)
	gl.Vertex2i(int(min.X), int(min.Y))
	gl.Vertex2i(int(max.X), int(min.Y))

	gl.Vertex2i(int(min.X), int(min.Y))
	gl.Vertex2i(int(min.X), int(max.Y))

	gl.Vertex2i(int(max.X), int(max.Y))
	gl.Vertex2i(int(max.X), int(min.Y))

	gl.Vertex2i(int(max.X), int(max.Y))
	gl.Vertex2i(int(min.X), int(max.Y))
	gl.End()
	gl.Color3ub(255, 255, 255)
}
Exemplo n.º 2
0
func (s *Display) drawFrame(screenData *types.Screen) {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	gl.Disable(gl.DEPTH_TEST)
	gl.PointSize(float32(s.ScreenSizeMultiplier) + 1.0)
	gl.Begin(gl.POINTS)
	for y := 0; y < SCREEN_HEIGHT; y++ {
		for x := 0; x < SCREEN_WIDTH; x++ {
			var pixel types.RGB = screenData[y][x]
			gl.Color3ub(pixel.Red, pixel.Green, pixel.Blue)
			gl.Vertex2i(x*s.ScreenSizeMultiplier, y*s.ScreenSizeMultiplier)
		}
	}

	gl.End()
	glfw.SwapBuffers()
}
Exemplo n.º 3
0
func (h *Hex) Render(alpha float32, drawFromCenter bool) {
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	if h.Kind == HexFlower {
		gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.REPLACE)
		starTex.Bind(gl.TEXTURE_2D)
	} else {
		gl.TexEnvf(gl.TEXTURE_ENV, gl.TEXTURE_ENV_MODE, gl.MODULATE)
		hexTex.Bind(gl.TEXTURE_2D)
		gl.GetError()
		var r, g, b uint8
		r = uint8(colors.Colors[h.Kind-1][0])
		g = uint8(colors.Colors[h.Kind-1][1])
		b = uint8(colors.Colors[h.Kind-1][2])
		if alpha < 1 {
			gl.Color4ub(r, g, b, uint8(alpha*255))
		} else {
			gl.Color3ub(r, g, b)
		}
	}
	gl.Begin(gl.QUADS)
	gl.TexCoord2f(0, 0)
	if drawFromCenter {
		gl.Vertex2i(HEX_WIDTH/2, HEX_HEIGHT/2)
	} else {
		gl.Vertex2i(HEX_WIDTH, HEX_HEIGHT)
	}
	gl.TexCoord2f(0, 1)
	if drawFromCenter {
		gl.Vertex2i(HEX_WIDTH/2, -HEX_HEIGHT/2)
	} else {
		gl.Vertex2i(HEX_WIDTH, 0)
	}
	gl.TexCoord2f(1, 1)
	if drawFromCenter {
		gl.Vertex2i(-HEX_WIDTH/2, -HEX_HEIGHT/2)
	} else {
		gl.Vertex2i(0, 0)
	}
	gl.TexCoord2f(1, 0)
	if drawFromCenter {
		gl.Vertex2i(-HEX_WIDTH/2, HEX_HEIGHT/2)
	} else {
		gl.Vertex2i(0, HEX_HEIGHT)
	}
	gl.End()
}
Exemplo n.º 4
0
func render(g *Game) {
	gl.Clear(gl.COLOR_BUFFER_BIT)

	// Background
	renderBackground()

	// Reinit blocks as not renderered
	for i := 0; i < len(g.level.blocks); i++ {
		for j := 0; j < len(g.level.blocks[i]); j++ {
			if g.level.blocks[i][j] != nil {
				g.level.blocks[i][j].Rendered = false
			}
		}
	}

	// Render first the rotating switch if there's one
	if g.level.rotating != nil {
		renderSwitchBlocks(g.level.rotating)
	}
	// Render the remaining switches
	for _, s := range g.level.switches {
		if s != g.level.rotating {
			renderSwitchBlocks(s)
		}
	}

	// render the switches
	for _, s := range g.level.switches {
		renderSwitch(s)
	}

	renderDashboard()

	if g.level.Win() {
		fontInd++
		if fontInd >= len(fonts) {
			fontInd = 0
		}
		gl.LoadIdentity()
		gl.Color3ub(107, 142, 35)
		fonts[fontInd].Printf(float32(WindowWidth/2)-100, float32(WindowHeight/2), "GAGNE !!")
	}

	window.SwapBuffers()
}
Exemplo n.º 5
0
func setColor(color ColorDef) {
	switch color {
	case Red:
		gl.Color3ub(239, 14, 84)
	case Yellow:
		gl.Color3ub(255, 218, 58)
	case Blue:
		gl.Color3ub(100, 149, 237)
	case Green:
		gl.Color3ub(88, 164, 0)
	case Pink:
		gl.Color3ub(255, 178, 255)
	case Orange:
		gl.Color3ub(243, 122, 17)
	case LightBlue:
		gl.Color3ub(98, 222, 255)
	}
}
Exemplo n.º 6
0
func drawProgress(w, h, percents, pending int) {
	switch pending {
	case None:
		gl.Color3ub(200, 0, 0)
		drawQuad(0, h-BarSize, w, BarSize, 0, 0, 1, 1)
		gl.Color3ub(255, 255, 255)
		return
	case Small:
		gl.Color3ub(200, 200, 0)
	case Big:
		gl.Color3ub(200, 200, 0)
		drawQuad(0, h-BarSize, w, BarSize, 0, 0, 1, 1)
		gl.Color3ub(200, 0, 0)
	}
	step := float32(w) / 100
	drawQuad(0, h-BarSize, int(float32(percents)*step), BarSize, 0, 0, 1, 1)
	gl.Color3ub(255, 255, 255)
}
Exemplo n.º 7
0
// Used in classic render mode.
// Defines vertex colors.
func (a *Attr) color(i int) {
	i *= a.size

	switch a.size {
	case 3:
		switch v := a.data.(type) {
		case []int8:
			gl.Color3b(v[i], v[i+1], v[i+2])
		case []uint8:
			gl.Color3ub(v[i], v[i+1], v[i+2])
		case []int16:
			gl.Color3s(v[i], v[i+1], v[i+2])
		case []int32:
			gl.Color3i(int(v[i]), int(v[i+1]), int(v[i+2]))
		case []float32:
			gl.Color3f(v[i], v[i+1], v[i+2])
		case []float64:
			gl.Color3d(v[i], v[i+1], v[i+2])
		}
	case 4:
		switch v := a.data.(type) {
		case []int8:
			gl.Color4b(v[i], v[i+1], v[i+2], v[i+3])
		case []uint8:
			gl.Color4ub(v[i], v[i+1], v[i+2], v[i+3])
		case []int16:
			gl.Color4s(v[i], v[i+1], v[i+2], v[i+3])
		case []int32:
			gl.Color4i(int(v[i]), int(v[i+1]), int(v[i+2]), int(v[i+3]))
		case []float32:
			gl.Color4f(v[i], v[i+1], v[i+2], v[i+3])
		case []float64:
			gl.Color4d(v[i], v[i+1], v[i+2], v[i+3])
		}
	}
}