Code Monkey home page Code Monkey logo

gdx-swiper's Introduction

gdx-swiper

An example of a "Fruit Ninja" style swipe in LibGDX.

The tutorial can be seen here:
https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Finger-Swipe

Note that, since writing this, I have been developing a more efficient and more robust line rendering system. By using a shader, we only need one triangle strip per line. Alternatively, triangles can be used to batch multiple lines.

The shader also allows us to create the anti-aliasing and stroke based on the line width (so its completely scalable). We do this by giving one edge of vertices a texcoord of 1.0, and the other edge a texcoord of -1.0. Then, in the fragment shader, we use abs() to ensure that the gradient goes from 0.0 (outer edges) to 1.0 (center of line).

The smoothing would be calculated a little like this:

//the mirrored gradient in the range 0.0 to 1.0
float aa = 1.0 - abs(vTexCoord.y);

//the exact smooth amount
vec4 color = vColor; //vertex color
color.a *= smoothstep(0.0, smooth/thickness, aa);
gl_FragColor = color;

The technique can also be used to draw general lines, such as a circular progress bar:
http://www.java-gaming.org/topics/circular-health-bar/29791/msg/274139/view.html#msg274139

I hope to continue working on my line rendering system, to provide features like end cap style, proper line joins, and so forth. Lots of useful information on OpenGL line rendering here:
http://artgrammer.blogspot.ca/search/label/vase%20renderer

gdx-swiper's People

Contributors

mattdesl avatar

Watchers

 avatar  avatar

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.