Code Monkey home page Code Monkey logo

pixel's Introduction

*****NOTICE*****

This repo is not under active development anymore and has been archived. Continued development has been migrated to Pixel2. A big thank you to faiface for creating this awesome library and for all the hard work put into it. We encourage old and new users to check out the new repo and contribute to it.

Pixel Build Status GoDoc Go Report Card Join the chat at https://gitter.im/pixellib/Lobby Discord Chat

A hand-crafted 2D game library in Go. Take a look into the features to see what it can do.

go get github.com/faiface/pixel

If you are using Modules (Go 1.11 or higher) and want a mutable copy of the source code:

git clone https://github.com/faiface/pixel # clone outside of $GOPATH
cd pixel
go install ./...

See requirements for the list of libraries necessary for compilation.

All significant changes are documented in CHANGELOG.md.

Tutorial

The Wiki of this repo contains an extensive tutorial covering several topics of Pixel. Here's the content of the tutorial parts so far:

The examples repository contains a few examples demonstrating Pixel's functionality.

To run an example, navigate to it's directory, then go run the main.go file. For example:

$ cd pixel-examples/platformer
$ go run main.go

Here are some screenshots from the examples!

Lights Platformer
Lights Platformer
Smoke Typewriter
Smoke Typewriter
Raycaster Gizmo
Raycaster Gizmo

Features

Here's the list of the main features in Pixel. Although Pixel is still under heavy development, there should be no major breakage in the API. This is not a 100% guarantee, though.

  • Fast 2D graphics
    • Sprites
    • Primitive shapes with immediate mode style IMDraw (circles, rectangles, lines, ...)
    • Optimized drawing with Batch
    • Text drawing with text package
  • Audio through a separate Beep library.
  • Simple and convenient API
    • Drawing a sprite to a window is as simple as sprite.Draw(window, matrix)
    • Wanna know where the center of a window is? window.Bounds().Center()
    • ...
  • Full documentation and tutorial
  • Works on Linux, macOS and Windows
  • Window creation and manipulation (resizing, fullscreen, multiple windows, ...)
  • Keyboard (key presses, text input) and mouse input without events
  • Well integrated with the Go standard library
    • Use "image" package for loading pictures
    • Use "time" package for measuring delta time and FPS
    • Use "image/color" for colors, or use Pixel's own color.Color format, which supports easy multiplication and a few more features
    • Pixel uses float64 throughout the library, compatible with "math" package
  • Geometry transformations with Matrix
    • Moving, scaling, rotating
    • Easy camera implementation
  • Off-screen drawing to Canvas or any other target (Batch, IMDraw, ...)
  • Fully garbage collected, no Close or Dispose methods
  • Full Porter-Duff composition, which enables
    • 2D lighting
    • Cutting holes into objects
    • Much more...
  • Pixel let's you draw stuff and do your job, it doesn't impose any particular style or paradigm
  • Platform and backend independent core
  • Core Target/Triangles/Picture pattern makes it easy to create new drawing targets that do arbitrarily crazy stuff (e.g. graphical effects)
  • Small codebase, ~5K lines of code, including the backend glhf package

Related repositories

Here are some packages which use Pixel:

  • TilePix Makes handling TMX files built with Tiled trivially easy to work with using Pixel.
  • spriteplus Basic SpriteSheet and Animation implementations
  • PixelUI Imgui-based GUIs for Pixel
  • pixelutils Variety of game related utilities (sprite packer, id generator, ticker, sprite loader, voronoia diagrams)

Missing features

Pixel is in development and still missing few critical features. Here're the most critical ones.

  • Audio
  • Drawing text
  • Antialiasing (filtering is supported, though)
  • Advanced window manipulation (cursor hiding, window icon, ...)
  • Better support for Hi-DPI displays
  • Mobile (and perhaps HTML5?) backend
  • More advanced graphical effects (e.g. blur) (solved with the addition of GLSL effects)
  • Tests and benchmarks
  • Vulkan support

Implementing these features will get us to the 1.0 release. Contribute, so that it's as soon as possible!

Requirements

If you're using Windows and having trouble building Pixel, please check this guide on the wiki.

PixelGL backend uses OpenGL to render graphics. Because of that, OpenGL development libraries are needed for compilation. The dependencies are same as for GLFW.

The OpenGL version used is OpenGL 3.3.

  • On macOS, you need Xcode or Command Line Tools for Xcode (xcode-select --install) for required headers and libraries.
  • On Ubuntu/Debian-like Linux distributions, you need libgl1-mesa-dev and xorg-dev packages.
  • On CentOS/Fedora-like Linux distributions, you need libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel mesa-libGL-devel libXi-devel libXxf86vm-devel packages.
  • See here for full details.

The combination of Go 1.8, macOS and latest XCode seems to be problematic as mentioned in issue #7. This issue is probably not related to Pixel. Upgrading to Go 1.8.1 fixes the issue.

Contributing

Join us in the Discord Chat!

Pixel is in, let's say, mid-stage of development. Many of the important features are here, some are missing. That's why contributions are very important and welcome! All alone, I will be able to finish the library, but it'll take a lot of time. With your help, it'll take much less. I encourage everyone to contribute, even with just an idea. Especially welcome are issues and pull requests.

However, I won't accept everything. Pixel is being developed with thought and care. Each component was designed and re-designed multiple times. Code and API quality is very important here. API is focused on simplicity and expressiveness.

When contributing, keep these goals in mind. It doesn't mean that I'll only accept perfect pull requests. It just means that I might not like your idea. Or that your pull requests could need some rewriting. That's perfectly fine, don't let it put you off. In the end, we'll just end up with a better result.

Take a look at CONTRIBUTING.md for further information.

License

MIT

pixel's People

Contributors

aerth avatar alistanis avatar andrebq avatar bcvery1 avatar bencarrr avatar cebarks avatar codelingobot avatar cpl avatar dbriemann avatar delp avatar dusk125 avatar duysqubix avatar elgopher avatar faiface avatar fgrosse avatar go-stuff avatar humpheh avatar jared-nishikawa avatar mewmew avatar miluchen avatar otraore avatar peterhellberg avatar plainsight avatar roipoussiere avatar seebs avatar snargleplax avatar thegtproject avatar tobaloidee avatar tskken avatar zergon321 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pixel's Issues

Monitor: pixelgl.PrimaryMonitor()

When switching from fullscreen mode (Monitor: pixelgl.PrimaryMonitor() in cfg) to any other window (alt-tab) (Windows 10) I get following error
When running in windowed model all works fine

_panic: reflect: slice index out of range

goroutine 1 [running, locked to thread]:
reflect.Value.Index(0x549400, 0xc04d1b4b60, 0x97, 0x0, 0x549400, 0x2, 0xc045877cf8)
C:/Go/src/reflect/value.go:871 +0x1eb
github.com/go-gl/gl/v3.3-core/gl.Ptr(0x549400, 0xc04d1b4b60, 0x549400)
C:/Users/Johan/go/src/github.com/go-gl/gl/v3.3-core/gl/conversions.go:44 +0xe4
github.com/faiface/glhf.NewTexture(0x0, 0x0, 0x0, 0x6a7040, 0x0, 0x0, 0x0)
C:/Users/Johan/go/src/github.com/faiface/glhf/texture.go:47 +0x125
github.com/faiface/glhf.NewFrame(0x0, 0x0, 0x0, 0x0)
C:/Users/Johan/go/src/github.com/faiface/glhf/frame.go:37 +0x75
github.com/faiface/pixel/pixelgl.(*GLFrame).SetBounds.func1()
C:/Users/Johan/go/src/github.com/faiface/pixel/pixelgl/glframe.go:35 +0x8b
github.com/faiface/mainthread.Call.func1()
C:/Users/Johan/go/src/github.com/faiface/mainthread/mainthread.go:64 +0x2d
github.com/faiface/mainthread.Run(0x5a14d8)
C:/Users/Johan/go/src/github.com/faiface/mainthread/mainthread.go:46 +0xf8
github.com/faiface/pixel/pixelgl.Run(0x5a14d8)
C:/Users/Johan/go/src/github.com/faiface/pixel/pixelgl/run.go:32 +0x60
main.main()
C:/Users/Johan/go/src/Quakes_1/Quakes_1.go:255 +0x34_

High CPU/GPU usage with VSync on.

Hello,

I'm not sure if this is a bug or a configuration issue somewhere. But anyway, I just found this library and I am following the tutorials provided thus far. One of them suggests to turn on VSync to slow down the update rate so that the code won't be running as fast it can. Enabling has no effect on my system it seems, it does lock the FPS but doesn't lower the CPU usage/GPU usage. 70% etc

OS: Arch Linux x64
CPU: Intel i5 2500 3.3 ghz
GPU: Nvidia GTX 1070

Using latest GLFW, pixel repo code.

How would we debug this?

Thanks!

Audio

Audio is a major missing feature in Pixel. The time has come to fix this. This issue serves as a design and implementation discussion place as well as progress reporting place.

Requirements

Here, I will summarize the most important requirements I demand from the implementation of an audio system in Pixel.

  • Playing sound and music files
  • Playing arbitrary generated stream of PCM samples
  • Support and preference of streaming, even from files
  • Ability to stop the playback at any time
  • Easily play arbitrary number of sounds simultaneously
  • Playback must be smooth, without glitches and as precise in timing as possible
  • Ability to create arbitrary stream-based audio effects in the library as well as by the user of the library (= defining 1 or 2 interfaces for this)

Design

Let's define two abstract interfaces with no specific definitions yet:

  1. Wave generator - an object of this type is capable of generating a stream of PCM waves
  2. Wave receiver - an object of this type is capable of receiving a stream of PCM waves and acting accordingly

Examples: A loaded sound file is a wave generator. A speaker is a wave receiver, since it receives the waves and plays them. An audio effect is both receiver and generator: it receives waves, modifies them and generates the modified waves.

Having defined these interfaces, here are a few example of ways the user would chain them together to create the final audio result. Objects sending to the right are generators and objects receiving from the left are receivers.

[ clap.mp3 ] -> [ volume adjustment, 0.5x ] -> [ speaker ]
[ sine wave generator ] -> [ distortion effect ] -> [ phaser effect ] -> [ speaker ]
[ music.wav ] -> [speaker ]

The "wave generator" and "wave receiver" names can and probably will change.

Implementation

This is not decided yet. Here are a few examples of possible implementation, all of which are a bit problematic.

1.

type WaveGenerator interface {
    Generate(format Format, p []byte) (n int, err error)
}

type WaveReceiver interface {
    Receive(format Format, p []byte) (n int, err error)
}

I don't like this implementation. For a stream of PCM waves, it requires the user to actively feed the speaker with new data each frame. This would be very hard to use, we would probably implement more abstractions on top of this.

2.

type WaveGenerator interface {
    Generate(format Format, p []byte) (n int, err error)
}

type WaveReceiver interface {
    Receive(WaveGenerator)
    Update()
}

The way you would use this implementation is like this:

sound := loadSound("hello.mp3") // WaveGenerator
effect.Receive(sound)
speaker.Receive(effect)

for !win.Closed() {
    speaker.Update()
}

This way, it'd be easy to create arbitrary chains of generators/receivers, however, questions and problems arise when we ask: How to play multiple sounds together? How to stop the playback? How to play two sounds one after another?

What needs to be done

First, we need to find an actual design that meets all of the requirements. Then we need to implement it.

Low level stuff

For the actual audio playback, we'll use the awesome oto package by @hajimehoshi, which supports audio playback on all major platforms.

friendly reminder: latest repo code breaks existing code

Hi again,

./Maze-generator.go:50: cannot call non-function imd.Color (type color.Color)
./Maze-generator.go:70: cannot call non-function imd.EndShape (type imdraw.EndShape)
./Maze-generator.go:74: cannot call non-function imd.Color (type color.Color)

These were easily fixed after making them a property. You probably know this :) but just a fyi

imdraw: better line triangulization

Here's an algorithm that works better for drawing thick lines.

https://github.com/egonelbre/exp/blob/master/pixel/wide-line/main.go#L70

faiface_pixel_wide-line

Still not ideal, but avoids gaps in outer corners. For solid lines the inner corners don't matter that much.

If you want round corners then in filling corner-gaps part draw a circle segment centered at a from x1 to a1 with radius.

PS: if you find a nice solution for the inner-corners let me know. I haven't yet found a nice solution for cases where you have very thick lines and very tight corners.

Need to install all dependencies by hand

Whe I run go get github.com/faiface/pixel

I have to install all dependencies by hand:
Like
go get -u github.com/go-gl/glfw/v3.2/glfw
go get github.com/go-gl/mathgl/mgl32
go get golang.org/x/image/colornames
and
go get github.com/faiface/glhf

Isn't there a way that the fist go get install all dependencies automatic?

SIGSEGV when using *pixelgl.Canvas.Texture()

I keep getting SIGSEGV:s when using the texture of a *pixelgl.Canvas.

The methods Begin(), SetPixels() and End() all result in SIGSEV.

Minimal example using Begin()

package main

import (
	"github.com/faiface/pixel"
	"github.com/faiface/pixel/pixelgl"
)

func run() {
	bounds := pixel.R(0, 0, 256, 256)
	pixelgl.NewCanvas(bounds).Texture().Begin()
}

func main() {
	pixelgl.Run(run)
}

Output

$ go run minimal-pixelgl-canvas-crash.go
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x0]

runtime stack:
runtime.throw(0x4116932, 0x2a)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/panic.go:596 +0x95
runtime.sigpanic()
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/signal_unix.go:274 +0x2db
runtime.asmcgocall(0x40000, 0xc420053f01)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_amd64.s:633 +0x70
runtime.mallocgc.func1()
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/malloc.go:690 +0x3e

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x40ca460, 0xc420053ce0, 0xc420096000)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/cgocall.go:131 +0xe2 fp=0xc420053ca0 sp=0xc420053c60
github.com/go-gl/gl/v3.3-core/gl._Cfunc_glowGenTextures(0x0, 0xc400000001, 0xc420092150)
	github.com/go-gl/gl/v3.3-core/gl/_obj/_cgo_gotypes.go:4702 +0x45 fp=0xc420053ce0 sp=0xc420053ca0
github.com/go-gl/gl/v3.3-core/gl.GenTextures(0x1, 0xc420092150)
	/Users/peter/Go/src/github.com/go-gl/gl/v3.3-core/gl/package.go:5989 +0x3f fp=0xc420053d08 sp=0xc420053ce0
github.com/faiface/glhf.NewTexture(0x100, 0x100, 0x40000, 0xc420096000, 0x40000, 0x40000, 0x0)
	/Users/peter/Go/src/github.com/faiface/glhf/texture.go:32 +0x93 fp=0xc420053d60 sp=0xc420053d08
github.com/faiface/glhf.NewFrame(0x100, 0x100, 0x4070000000000000, 0x4070000000000000)
	/Users/peter/Go/src/github.com/faiface/glhf/frame.go:37 +0x8c fp=0xc420053db8 sp=0xc420053d60
github.com/faiface/pixel/pixelgl.(*GLFrame).SetBounds.func1()
	/Users/peter/Go/src/github.com/faiface/pixel/pixelgl/glframe.go:35 +0x84 fp=0xc420053e30 sp=0xc420053db8
github.com/faiface/mainthread.Call.func1()
	/Users/peter/Go/src/github.com/faiface/mainthread/mainthread.go:64 +0x26 fp=0xc420053e70 sp=0xc420053e30
github.com/faiface/mainthread.Run(0x41180b0)
	/Users/peter/Go/src/github.com/faiface/mainthread/mainthread.go:46 +0x15f fp=0xc420053f30 sp=0xc420053e70
github.com/faiface/pixel/pixelgl.Run(0x41180b0)
	/Users/peter/Go/src/github.com/faiface/pixel/pixelgl/run.go:32 +0x5e fp=0xc420053f70 sp=0xc420053f30
main.main()
	/Users/peter/Go/src/experiments/pixel/minimal-pixelgl-canvas-crash.go:14 +0x2d fp=0xc420053f88 sp=0xc420053f70
runtime.main()
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/proc.go:185 +0x20a fp=0xc420053fe0 sp=0xc420053f88
runtime.goexit()
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc420053fe8 sp=0xc420053fe0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_amd64.s:2197 +0x1

goroutine 19 [chan receive]:
github.com/faiface/mainthread.Call(0xc420072240)
	/Users/peter/Go/src/github.com/faiface/mainthread/mainthread.go:67 +0xb3
github.com/faiface/pixel/pixelgl.(*GLFrame).SetBounds(0xc4200920a0, 0x0, 0x0, 0x4070000000000000, 0x4070000000000000)
	/Users/peter/Go/src/github.com/faiface/pixel/pixelgl/glframe.go:46 +0x111
github.com/faiface/pixel/pixelgl.NewGLFrame(0x0, 0x0, 0x4070000000000000, 0x4070000000000000, 0x0)
	/Users/peter/Go/src/github.com/faiface/pixel/pixelgl/glframe.go:21 +0x70
github.com/faiface/pixel/pixelgl.NewCanvas(0x0, 0x0, 0x4070000000000000, 0x4070000000000000, 0x0)
	/Users/peter/Go/src/github.com/faiface/pixel/pixelgl/canvas.go:35 +0x61
main.run()
	/Users/peter/Go/src/experiments/pixel/minimal-pixelgl-canvas-crash.go:10 +0x44
github.com/faiface/mainthread.Run.func1(0x41180b0, 0xc42006e180)
	/Users/peter/Go/src/github.com/faiface/mainthread/mainthread.go:39 +0x27
created by github.com/faiface/mainthread.Run
	/Users/peter/Go/src/github.com/faiface/mainthread/mainthread.go:41 +0xe5
exit status 2

Environment

$ go version
go version go1.8.1 darwin/amd64
$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 10.12.4 (16E195)
      Kernel Version: Darwin 16.5.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: Peter Hellbergs MacBook Pro
      User Name: Peter Hellberg (peter)
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 17 days 22:38

Sound API Design

@faiface I saw your posts on Reddit and recently switched from a job where I was working on Go full time to where I am now working in Scala/Ruby/Python/Java - so I'm looking for a project to work on outside the DevOps space, and this one caught my attention. I'm a long time game dev enthusiast and I experimented with sound and Go around a year ago, and I was wondering how much thought you'd put into the API design for sound in pixel. If you've already designed something, I'd love to look it over and take a stab at implementing sound for a few platforms - and if not I'd be more than happy to help design an interface.

Let me know!

-Chris

Do dis pls

  1. Rect-Vec
  • Clamp

Projection
d) Unit(angle)

Thx

Add cursor hiding

Add two *pixelgl.Window methods:

  • (*pixelgl.Window).SetCursorVisible(bool) - sets the visibility of the mouse cursor inside the window client area
  • (*pixelgl.Window).CursorVisible() bool - returns the visibility status of the mouse cursor

Minimizing Windowed/Fullscreen App Causes Panic

OS: Win 10
Go: 1.9

EDIT: This panic is more general than we had imagined, it will occur if you minimize the application in any way (clicking on the minimize icon, Alt+TAB'ing, clicking on the icon on the taskbar), regardless of the windowed/fullscreen state. Comments up until the issue name change imply this is a fullscreen-only issue, which it is not.

If you (for example) make the Platformer example fullscreen then Alt+TAB, it will panic with the following:

panic: reflect: slice index out of range

goroutine 1 [running, locked to thread]:
reflect.Value.Index(0x539120, 0xc0423ecd20, 0x97, 0x0, 0x539120, 0x2, 0xc042c09cf8)
        C:/tools/go/src/reflect/value.go:871 +0x1eb
PixelBugTest/vendor/github.com/go-gl/gl/v3.3-core/gl.Ptr(0x539120, 0xc0423ecd20, 0x539120)
        C:/Users/username/go/src/PixelBugTest/vendor/github.com/go-gl/gl/v3.3-core/gl/conversions.go:44 +0xe4
PixelBugTest/vendor/github.com/faiface/glhf.NewTexture(0x0, 0x0, 0x0, 0x691f98, 0x0, 0x0, 0x0)
        C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/glhf/texture.go:47 +0x125
PixelBugTest/vendor/github.com/faiface/glhf.NewFrame(0x0, 0x0, 0x0, 0x0)
        C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/glhf/frame.go:37 +0x75
PixelBugTest/vendor/github.com/faiface/pixel/pixelgl.(*GLFrame).SetBounds.func1()
        C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/pixel/pixelgl/glframe.go:35 +0x8b
PixelBugTest/vendor/github.com/faiface/mainthread.Call.func1()
        C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/mainthread/mainthread.go:64 +0x2d
PixelBugTest/vendor/github.com/faiface/mainthread.Run(0x58dbd0)
        C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/mainthread/mainthread.go:46 +0xf8
PixelBugTest/vendor/github.com/faiface/pixel/pixelgl.Run(0x58dbd0)
        C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/pixel/pixelgl/run.go:32 +0x60
main.main()
        C:/Users/username/go/src/PixelBugTest/vendor/github.com/faiface/pixel/examples/platformer/main.go:394 +0x34
exit status 2

The error is possibly occurring in the glhf library, and I can confirm that it also happens in my personal project.

Benchmarks

Benchmarks are incredibly useful when optimizing performance. They are also useful when we want to tell people how much we improved the performance of the library (for example: "The performance of drawing primitive shapes was improved by 80%", sounds good).

Technology

  • We'll use the standard "testing"
  • Each benchmark should be located in the same folder as the functionality it's benchmarking
  • Related benchmarks should be located together in a single appropriately named file
  • Benchmark files should have a different package than the functionality they're benchmarking (pixe -> pixel_test)

What to benchmark

Here's the list so far. Will most likely expand.

  • Pixel
    • ToRGBA
    • All Matrix operations
    • Sprite drawing to Batch
  • IMDraw
    • All IMDraw drawing operations (circle, line, etc.) separately for different number of points (i.e. don't use b.N as the number of points, but as the number of repeated drawings)
  • Text
    • Creating Atlas from several different rune sets (small, large)
    • Writing text (by small chunks, by large chunks, b.N should be the number of chunks, not their size)

Optimize design of Target/Triangles/Picture pattern

The current core pattern of Pixel has a few weak points.

  1. Triangles interface method set is not optimal. SetLen is only used to either clear the triangles, or when appending. Appending must consist of three steps: set length, slice and update, which is way too much.
  2. Triangles properties interfaces, such as TrianglesPosition and TrianglesColor are completely useless, because using them directly is insanely slow (because they operate on indices). Only fast paths with TrianglesData and so on are used in real situations.
  3. Naming is a bit unclear.

To address all of these issues, I propose to change the core interfaces as follows:

type Triangles interface {
	Len() int
	Slice(i, j int) Triangles
	Append(src Triangles)
	Copy(src Triangles) (n int)
	Clone() Triangles
}

type TrianglesDrawer interface {
	Triangles
	Draw()
}

type TrianglesPosition2D interface {
	CopyPosition2D(dst []float64, stride int) (n int)
}

type TrianglesColorRGBA interface {
	CopyColorRGBA(dst []float64, stride int) (n int)
}

type TrianglesPicture2D interface {
	CopyPicture2D(dst []float64, stride int) (n int)
}

These are changes regarding triangles, Picture interface needs to be rethought too, I need to figure it out.

failed to create Canvas, there's a bug in the shader

I've just tried to compile platform/smoke examples and saw an error
panic: failed to create Canvas, there's a bug in the shader: error compiling vertex shader: ERROR: 0:2: '' : version '130' is not supported

stacktrace

goroutine 1 [running, locked to thread]:
github.com/faiface/pixel/pixelgl.NewCanvas.func1()
	/Users/me/go/src/github.com/faiface/pixel/pixelgl/canvas.go:52 +0x138
github.com/faiface/mainthread.Call.func1()
	/Users/me/go/src/github.com/faiface/mainthread/mainthread.go:64 +0x26
github.com/faiface/mainthread.Run(0x423a320)
	/Users/me/go/src/github.com/faiface/mainthread/mainthread.go:46 +0x15f
github.com/faiface/pixel/pixelgl.Run(0x423a320)
	/Users/me/go/src/github.com/faiface/pixel/pixelgl/run.go:32 +0x5e
main.main()
	/Users/me/go/src/github.com/faiface/pixel/examples/platformer/main.go:393 +0x2d

go version
go version go1.8.3 darwin/amd64

os: macOS

what i'm doing wrong? i don't edit anything

Add text drawing

Currently, Pixel doesn't support drawing text. This needs to be changed. Implementing text drawing in Go is actually way simpler than I thought it would be.

First of all, there's an awesome package https://godoc.org/golang.org/x/image/font, which implements standard font face interface, which is well designed and very useful. Subpackages implement several font types and https://godoc.org/github.com/golang/freetype/truetype implements TrueType font loading with support of the standard font face interface. So we've got all we need.

Now, the design of text drawing in Pixel.

Text drawing should be done in a not-yet-existing "github.com/faiface/pixel/text" package. This package should export (at least) one type: Text. Creating one should be done by text.New(face), where face is a font.Face value. The *Text value returned from New will use that specific font face.

Text type should implement io.Writer interface, so drawing text to it is as simple as fmt.Sprintf(txt, "hello world"). Printing to Text draws text "to the Text object". To draw the printed text to another target (such as a window, canvas, batch, ...), simply use txt.Draw(target). Clearing needs to be supported too (txt.Clear()).

Drawing text needs to be fast. There should be no problem drawing a full screen of random text using a tiny font face at 60 FPS without a performance hit. This is something that many other libraries fail to accomplish, but it's actually not very hard. It's easily achievable by caching glyphs.

So, to recap the interface.

  • "github.com/faiface/pixel/text"
    • New(font.Face) *Text
    • type Text
      • Clear()
      • Draw(pixel.Target)
      • Write(b []byte) (n int, err error)

This is the basis for the interface. More methods will probably be added, such as WriteString, or SetDot (the position of the text line).

Custom shaders - post processing

Is there any way in current state of library to use custom shader? For example draw images on canvas and use custom shader to postprocess image?

Add text input from window

Currently, *pixelgl.Window supports checking key and mouse presses. Implementing a user-editable text is close to impossible to do correctly just using this functionality. GLFW library provides a way to correctly get a text input from the user, which depends on their keyboard settings and all that stuff.

Pixel should support this functionality too, through a simple interface. I suggest this single method.

  • (*pixelgl.Window).Typed() string - returns a string of characters the user typed on the keyboard since the last call to (*pixelgl.Window).Update

Note, that the Typed method does not and should not handle text deletion. That's easy to implement with (*pixelgl.Window).Pressed or (*pixelgl.Window).JustPressed method.

Add advanced tutorials

The tutorials in the wiki currently cover just basic topics. These tutorials need to be written:

  • Target/Triangles/Picture interface pattern (the "inside of the library")
  • Canvas and composition methods (used to create lighting, holes, etc.)
  • Hacking Triangles (e.g. creating a high-performance tilemap)
  • Creating own Target (some basic + a OpenGL target implementing an effect with custom a shader)
  • Optimizing and avoiding common performance pitfalls

Native support for glfw cursors

I see that only cursor hiding is currently supported, what do you think about adding support for the standard glfw cursors like hand and crosshair (http://www.glfw.org/docs/latest/group__shapes.html)?

I've already looked a bit on the way how it works and I can try to implement and make pull request if you're interested in a such small feature.

I'd say that it could be done by defining enum of cursor types in pixelgl/window.go and func (w *Window) SetCursorType(type CursorType).

Thanks.

Error when executing on Win10

This is what I get when executing the platformer example in Win10. No problem in Ubuntu.

panic: runtime error: index out of range

goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.2/glfw.(*Window).SetIcon(0xc0420c2080,
0x682278, 0x0, 0x0)
C:/gosrc/src/github.com/go-gl/glfw/v3.2/glfw/window.go:353 +0x5b3
github.com/faiface/pixel/pixelgl.NewWindow.func2()
C:/gosrc/src/github.com/faiface/pixel/pixelgl/window.go:140 +0x4f
github.com/faiface/mainthread.Call.func1()
C:/gosrc/src/github.com/faiface/mainthread/mainthread.go:64 +0x2d
github.com/faiface/mainthread.Run(0x597da0)
C:/gosrc/src/github.com/faiface/mainthread/mainthread.go:46 +0x166
github.com/faiface/pixel/pixelgl.Run(0x597da0)
C:/gosrc/src/github.com/faiface/pixel/pixelgl/run.go:32 +0x65
main.main()
C:/.../p/main.go:413 +0x34

Any ideas?
Thanks for sharing your library, it's very fun to play with! ^^

creating window failed: VersionUnavailable: WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable

Hello,

My understanding of this error from a quick Google is that it means my graphics card and/or its drivers are outdated. (ie. not supporting above OpenGL 3.1)

Was keen to use this but if it wont run at all on slightly older machines makes it a non-starter.

Also worth noting that the Engo engine runs fine on this machine, looking at the imports... seems it's using "github.com/go-gl/glfw/v3.1/glfw".

Any plans to support older versions of OpenGL or similar?

System:

  • Windows 10
  • Intel Graphics HD 3000

Error from running platformer example:

panic: creating window failed: VersionUnavailable: WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable

goroutine 5 [running]:
main.run()
        C:/GoProjects/src/github.com/faiface/pixel/examples/platformer/main.go:283 +0x12a0
github.com/faiface/mainthread.Run.func1(0x593040, 0xc04201a240)
        C:/GoProjects/src/github.com/faiface/mainthread/mainthread.go:39 +0x2e
created by github.com/faiface/mainthread.Run
        C:/GoProjects/src/github.com/faiface/mainthread/mainthread.go:41 +0xec

Intended way to cleanup resources associated with canvas

Hello,

I've been messing around with pixelgl canvas stuff learning enough from your lights demo to get going. Drawing to a canvas and then drawing that canvas to the main window seems like a good approach for various GUI elements to just show a portion of the GUI content at a time (in combination with a scrollbar for example) (if there's another approach you'd recommend let me know!).

I was working on some code to implement GUI element creation and noticed that there is some resource leak when I draw a sprite to a canvas that I'm not sure how to clean up, it appears to be in the glhf space, and the canvas has a function to give you the frame for example but its delete() function is not exported. I didn't dig very far into glhf yet, as I'm looking for the right approach to cleanup things created with pixelgl using pixelgl.

Here's an example of the resource leak, the framerate should be visible in your window title. I don't intend to actually create a new canvas every frame, but I am interested in what I am supposed to do to get the framerate to be stable with this code rather than now where the framerate steadily deteriorates from ~350fps to <20 in my case over the course of 30 seconds. Below is the code in question that is within a render loop.

testCanvas := pixelgl.NewCanvas(pixel.R(0, 0, 30, 30)) testCanvas.SetComposeMethod(pixel.ComposeOver) testCanvas.Clear(colornames.Antiquewhite) gs.sprite.Draw(testCanvas, pixel.IM.Moved(testCanvas.Bounds().Center()))//framerate is stable without this line testCanvas.Draw(win, pixel.IM.Moved(win.Bounds().Center()))

I would appreciate any insight here, thanks for reading.

Specifying Z-order

Currently as far as I can tell there is no way of specifying the z-order of what you are drawing. This requires ordering everything you are rendering before making draw calls (painters algorithm).

Is providing some way to specify the z-order of objects something which would be considered or is this out of scope?

Doesn't build for me

Running Go 1.8 on linux:

$ go get github.com/faiface/pixel/...
# github.com/go-gl/glfw/v3.2/glfw
In file included from ./context.go:4:0:
./glfw/include/GLFW/glfw3.h:171:21: fatal error: GL/gl.h: No such file or directory
compilation terminated.
# github.com/go-gl/gl/v3.3-core/gl
../../../gl/v3.3-core/gl/procaddr.go:52:21: fatal error: GL/glx.h: No such file or directory
compilation terminated.

pixelgl.Window bounds and position

I've noticed that Window.SetBounds() doesn't change the position currently. I'd propose to change the behaviour of SetBounds() so it does change the position of the window. Additionally I'd add a SetSize() (or Resize()) that does change the size only (the current behaviour of SetBounds()). At last I'd make it explicit for now that the Min property of the Window.bounds property isn't used (and set it to zero by default).

Proposed implementation: Schobers/pixel@2b985c01869f58213b84fa1a6d40f0390d23706d

[Question] Flipping Y-Axis

How do I go about flipping the Y-axis so that:

  • Rendering at 0 is at the top of the screen
  • Reverse Y (So positive is down and negative is up)

I'd like the code I'm writing to work with however the user has setup their own window too, so being able to set it back would be great.

Aiming to build a little integrated map editor.

ERROR: Attempt to use 'texture' as a variable

Thanks for this neat library!

I'm getting this error on master right now when trying to go run the platformer example:

panic: failed to create Canvas, there's a bug in the shader: error compiling vertex shader: ERROR: 0:6: Attempt to redeclare 'texture' as a variable
ERROR: 0:21: Attempt to use 'texture' as a variable


goroutine 1 [running, locked to thread]:
github.com/faiface/pixel/pixelgl.NewCanvas.func1()
        /Users/pi/code/go/src/github.com/faiface/pixel/pixelgl/canvas.go:52 +0x138
github.com/faiface/mainthread.Call.func1()
        /Users/pi/code/go/src/github.com/faiface/mainthread/mainthread.go:64 +0x26
github.com/faiface/mainthread.Run(0x4196cb0)
        /Users/pi/code/go/src/github.com/faiface/mainthread/mainthread.go:46 +0x15f
github.com/faiface/pixel/pixelgl.Run(0x4196cb0)
        /Users/pi/code/go/src/github.com/faiface/pixel/pixelgl/run.go:32 +0x5e
main.main()
        /Users/pi/code/workspace/go/pixel/examples/platformer/main.go:394 +0x2d
exit status 2

minimal fix PR will follow shortly.

text.Clear()

When using txt.Clear() in the for !win.Closed() {} loop and write some text afterwards no text is shown. Clear should only remove the text, not clear the whole instance? I had to replace txt.Clear() with txt := text.New(pixel.V(20, 50), atlas) in the loop to make it work as intended.

How to best draw a shape in different positions?

I'm playing around with your library and find it very accessible. The tutorials are nicely written. So, i was trying out imdraw, did issue my shape building calls and then wanted to draw my shape at different positions. I was expecting imd.SetMatrix(m) to do just that, post transform it, but found out that i have to set the matrix before i call Push. Maybe i'm missing the right way to do it, but i find it counter intuitive compared to Sprite, which i can easily draw with different transformations.

How i could see this work, without knowing too much about all of this, is that the matrix on the struct that gets set by SetMatrix would be used for anchoring and transformations and can be reset anytime, like with Sprite. Setting the matrix for the individual shape building calls would then happen via a different method. But then you would have to keep two arrays of the verts around, one of the original and one of the transformed data. To make it work like it is now, i guess, i would create a function to build my shape at the position i want it to have, which would work.

What is you intended way of drawing a shape multiple times with different transformations?

Error: SIGKILL when attempting to run on macOS

Using go 1.8 on macOS 10.12.3 with version 8.3.2 of Xcode and commandline tools.

When I run the Creating a Window example, the program is stopped by sigkill.

Running in normal mode of Gogland I get:
Process finished with exit code 137 (interrupted by signal 9: SIGKILL)

Running in debug mode of Gogland I get:

GOROOT=/usr/local/go
GOPATH=/Users/csos95/gocode
/usr/local/go/bin/go build -i -o "/private/var/folders/j8/tdt3__9j5b5g5x8pxgz3zrsc0000gn/T/Build main.go and rungo" -gcflags "-N -l" "-ldflags=-linkmode internal" /Users/csos95/gocode/src/gogs.csos95.com/csos95/GraphicsTest/main.go
# command-line-arguments
github.com/go-gl/glfw/v3.2/glfw(__TEXT/__text): unexpected GOT reloc for non-dynamic symbol _glfw
github.com/go-gl/glfw/v3.2/glfw(__TEXT/__text): unexpected GOT reloc for non-dynamic symbol _glfw
github.com/go-gl/glfw/v3.2/glfw(__TEXT/__text): unexpected GOT reloc for non-dynamic symbol _glfw
github.com/go-gl/glfw/v3.2/glfw(__TEXT/__text): unexpected GOT reloc for non-dynamic symbol _glfw
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
github.com/go-gl/glfw/v3.2/glfw(__DATA/__cfstring): unexpected reloc for dynamic symbol __CFConstantStringClassReference
/usr/local/go/pkg/tool/darwin_amd64/link: too many errors

If anymore information is needed, please let me know.

Race condition in pixelgl.NewGLTriangles

I've been playing around with integrating pixel into a game lately, and stumbled upon what looks like a race condition; a nil-pointer dereference in glpixel.GLTriangle.Len.

To identify the cause of the race condition, I added a few debug print statements in gltriangle.go:

// NewGLTriangles returns GLTriangles initialized with the data from the supplied Triangles.
//
// Only draw the Triangles using the provided Shader.
func NewGLTriangles(shader *glhf.Shader, t pixel.Triangles) *GLTriangles {
	var gt *GLTriangles
	fmt.Println("before")
	mainthread.Call(func() {
		fmt.Println("   in 1")
		gt = &GLTriangles{
			vs:     glhf.MakeVertexSlice(shader, 0, t.Len()),
			shader: shader,
		}
		fmt.Println("   in 2")
	})
	fmt.Printf("gt: %p\n", gt)
	gt.SetLen(t.Len())
	gt.Update(t)
	return gt
}

Right before the nil-pointer dereference, the output looks as follows:

before
   in 1
   in 2
gt: 0x47c4c280
before
   in 1
gt: 0x0
   in 2

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x688de23d]

goroutine 4 [running]:
github.com/faiface/pixel/pixelgl.(*GLTriangles).Len(...)
	/home/u/goget/src/github.com/faiface/pixel/pixelgl/gltriangles.go:61
github.com/faiface/pixel/pixelgl.(*GLTriangles).SetLen(0x0, 0x6)
	/home/u/goget/src/github.com/faiface/pixel/pixelgl/gltriangles.go:69 +0x1d
github.com/faiface/pixel/pixelgl.NewGLTriangles(0x47cac0c0, 0x689cc660, 0x47caa080, 0x0)
	/home/u/goget/src/github.com/faiface/pixel/pixelgl/gltriangles.go:42 +0x146
github.com/faiface/pixel/pixelgl.(*Canvas).MakeTriangles(0x47c3e280, 0x689cc660, 0x47caa080, 0x6898c801, 0x47e14150)
	/home/u/goget/src/github.com/faiface/pixel/pixelgl/canvas.go:65 +0x38
github.com/faiface/pixel/pixelgl.(*Window).MakeTriangles(0x47cb8000, 0x689cc660, 0x47caa080, 0x47e14198, 0x0)
	/home/u/goget/src/github.com/faiface/pixel/pixelgl/window.go:368 +0x34
github.com/faiface/pixel.(*Drawer).Draw(0x47c52264, 0x689cc110, 0x47cb8000)
	/home/u/goget/src/github.com/faiface/pixel/drawer.go:74 +0x1fa
github.com/faiface/pixel.(*Sprite).DrawColorMask(0x47c52240, 0x689cc110, 0x47cb8000, 0x0, 0x3ff00000, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/u/goget/src/github.com/faiface/pixel/sprite.go:87 +0xfc
github.com/faiface/pixel.(*Sprite).Draw(0x47c52240, 0x689cc110, 0x47cb8000, 0x0, 0x3ff00000, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/u/goget/src/github.com/faiface/pixel/sprite.go:61 +0x4e

Has anyone else encountered this?

GUI support!

Hey, first of all really nice game library, I like it how easy it's to work with it and the fact that is based on opengl. I'm interested to find out if this library will be GUI compatible in the near future...currently there isn't a stable gui library for go, but I do believe that this library could make a good one ;)

Clicking on icon in taskbar creates error

I have pixel on Windows 10 and go 1.9.1 64 bit. I'm new to Go and GitHub so there might be a simple solution that I missed. I was playing around and found that I could add icons to my applications, so I got a random .png and used it. It worked fine for the most part, but when I click on the application icon or minimize the window in the task-bar it immediately closes and creates an error.

My Code:

func PictureFromImage(path string) (pixel.Picture) {
    file, err := os.Open(path)
    if err != nil {
        fmt.Println()
        return nil
    }

    img, _, err := image.Decode(file)
    if err != nil {
        fmt.Println(err)
        return nil
    }

    defer file.Close() // Make sure file closes after function returns

    return pixel.PictureDataFromImage(img)
}

func run() {

    // Load window Icon
    // It is a slice because WindowConfig only takes a slice
    icons := make([]pixel.Picture, 1)
    img := PictureFromImage("icon.png")
    icons[0] = img

    cfg := pixelgl.WindowConfig{
            Title: "Window",
            Icon: icons,
            Bounds: pixel.R(0, 0, 800, 600),
            VSync: true,
    }

    window, err := pixelgl.NewWindow(cfg)
    if err != nil {
        panic(err)
    }


    for !window.Closed() {
        window.Clear(colornames.Black)

        window.Update()
    }
}

Which produces the error:
panic: reflect: slice index out of range

I don't think there was a mistake in my code, because it was mostly copied off of the tutorials (like the PictureFromImage function). I think it might be because I only gave 1 image in the slice, but the comments in the WindowConfig struct in window.go say that it's ok if I pass only 1.

Camera rotates around ZV, not given position

This is probably not the issue with pixel, and I probably need to ask it somewhere on StackOverflow, but maybe here is more proper place to ask.

I try to create some space flying simulator. To draw my rocket I use following transformations:

func (r *Rocket) Draw(win *pixelgl.Window) {
        matrix := pixel.IM.Scaled(pixel.ZV, 0.05)
        matrix = matrix.Rotated(pixel.ZV, r.angle - math.Pi / 2) // Let zero angle be pointed up
        matrix = matrix.Moved(r.pos)
        r.sprite.Draw(win, matrix)
}

It works fine, I could fly rocket around a screen.

Now I want to put my rocket into the center of the screen pointed up, to simulate view from it. I use this code:

	cam := pixel.IM.
			Moved(pixel.ZV.Sub(rocket.pos)).
			Moved(win.Bounds().Center()).
			Rotated(rocket.pos, -rocket.angle + math.Pi / 2)

	win.SetMatrix(cam)

Without rotation it works great, but when I add rotation to compensate rocket rotation, no matter where, and around what vector, for example when I turn rocket left I get this:

image

Rocket should be at the location of screen pointed by arrow, but instead is to the left and down, and when it's position is far away from zero vector it gets off the screen. World rotates not around rocket, but around it's zero vector, that is the problem. How to fix this? I tried different order of transformations with no luck. Maybe add this to camera tutorial?

Clearing part of a Batch

Not really an issue, but is it possible to clear part of a Batch so that if I remove a block from a tilemap, I wouldn't need to rebuild the whole Batch ?
I am asking that because I want to build a tilemap with transparent parts so that it is possible to superpose multiple tilemaps.

Mixing 2d and 3d

I write an OpenGL 3d renderer. It's very basic test code.

I am curious if I can use compositor to bring the OpenGL Output into your compositor to have a HUD ?

Add window icon support

Add a *pixelgl.Window method to set the icon of the window. The icon is usually displayed at the top bar of the window, or in the task bar of the desktop environment.

  • (*pixelgl.Window).SetIcon(pixel.Picture) - sets the icon of the window to the given picture

I don't think a getter is necessary.

Also, make it possible to add an icon to pixelgl.WindowConfig by adding a Icon field there. Is the (*pixelgl.Window).SetIcon actually necessary with this field?

graphics chip too old?

Hi. I'm new to Pixel, but so far I'm loving the ease-of-use and lack of boilerplate! After messing around enough with installing gcc, and other related go libraries, I got your "create window" demo to work on my main computer, an Intel NUC with Win 10 and HD Graphics 5000 (which supports OpenGL 4.3).

On my old (>10 yrs) laptop running Win 10 x64 with Mobile Intel 965 graphics (Intel Graphics Media Accelerator X3100, supports only OpenGL 2.0 on windows), I could not get it to work, however.

I got an error like WGL: The driver does not appear to support OpenGL. Sorry, I don't have more info on that because I didn't save the stacktrace or exact error message before proceeding to the next thing. Some searching led me to believe this error message meant that the driver I had did not include OpenGL drivers.

After installing an older version of the drivers the I downloaded from intel.com for this chipset, I got a different error.

panic: creating window failed: VersionUnavailable: WGL: A forward compatible OpenGL context 
requested but WGL_ARB_create_context is unavailable

goroutine 5 [running]:
main.run()
    c:/dev/code/go/src/local/pixdemo/main.go:17 +0x18b
github.com/faiface/mainthread.Run.func1(0x559cb8, 0xc0420121e0)
    c:/dev/code/go/src/github.com/faiface/mainthread/mainthread.go:39 +0x2e
created by github.com/faiface/mainthread.Run
    c:/dev/code/go/src/github.com/faiface/mainthread/mainthread.go:38 +0xec

Searching lead me back here, to issue #26 , and makes me believe that I now have OpenGL drivers, but that they're just too old to work with Pixel.

Any confirmation would be appreciated. I don't expect this "issue" to be fixed, since it is probably just the fault of my old computer.

Cross Compiling

When I try to cross compile with

GOOS=windows GOARCH=386 go build -o main.exe main.go

I get this error

../github.com/faiface/glhf/frame.go:7:2: build constraints exclude all Go files in /home/shingtaklam1324/Programming/Go/src/github.com/go-gl/gl/v3.3-core/gl

It seems to be a problem with go-gl so is there any way to bypass?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.