dartgl 0.1.0 copy "dartgl: ^0.1.0" to clipboard
dartgl: ^0.1.0 copied to clipboard

outdatedDart 1 only

You can easily call native OpenGL functions from Dart. OpenGL 4.5 core profile and ARB extension interfaces are supported.

DartGL #

It is a native extension for Dart to use OpenGL in desktop applications.
On www.dartlang.org they call it "command-line or server applications". However, you can definitely create GUI application and use OpenGL too.

Support matrix #

OpenGL: 3.3-4.5 core profile
OS: Linux and Windows
Dart: any

How to install #

  • Add to pubspec.yaml
dependencis:
  dartgl: 
  • Run
pub get

How to use #

  • Add to your Dart file
import 'package:dartgl/dartgl.dart';
  • Create OpenGL context (see OpenGL Context)
  • Just use OpenGL functions and constants
  var vertexShader = glCreateShader(GL_VERTEX_SHADER);
  ...
  
  var fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
  ...
  
  program = glCreateProgram();
  glAttachShader(program, vertexShader);
  glAttachShader(program, fragmentShader);
  
  glBindAttribLocation(program, 0, "in_Position");
  glBindAttribLocation(program, 1, "in_Color");
  glBindAttribLocation(program, 2, "in_Texture");
  
  glLinkProgram(program);
  location = glGetUniformLocation(program, "in_Time");
    
  arrays = new Uint32List(1);
  glGenVertexArrays(1, arrays);
  ...
  
  while (...){

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  
    ...
    /.
}

OpenGL context #

For testing purpose, I created native extension for a tiny part of SDL 2.0 to create a window, create OpenGL context and manage window events. You can use your own way.

Examples #

In order to run basic examples from test directory, SDL should be installed.

  • Linux
sudo apt-get install libsdl2-2.0
  • Windows Download and add to PATH

To-Do #

  • Improve performance
  • Improve tests
  • MacOS X support
  • OpenGL ES
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

You can easily call native OpenGL functions from Dart. OpenGL 4.5 core profile and ARB extension interfaces are supported.

Homepage

License

unknown (license)

More

Packages that depend on dartgl