Posts Tagged ‘Code Snippet’
Posts that have small parts from a bigger code.
Unity: How to playback fullscreen videos using the GL class
Posted by Dimitri | Filed under Programming
This Unity programming tutorial explains how to use the immediate mode rendering available at the GL class for the playback of video files. There is already another post here on 41 Post that shows how to do the same thing using GUITexture component. However, in this tutorial, a quad is going to be rendered and the video will be played at its texture.
Not only the steps required for achieving fullscreen video playback are going to be explained, but how to properly scale the video based on the screen dimensions is also featured in this post. Warning: this tutorial works only with Unity Pro because the free version doesn’t support video decoding. This post has been created and tested in Unity version 3.4. At the end of the post, a Unity project featuring all the code explained here is available for download both in C# and JavaScript.
Android: Fixing the API 12 Demos project errors
Posted by Dimitri | Filed under Programming
This post shows how to fix some of the most common errors when creating a project with the API 12 (Android 3.1) demos in the Eclipse IDE. The API samples comes bundled with the Android SDK and are a set of Activities that exemplifies how to do almost anything in Android. Following the instructions described at the official documentation to create a new Eclipse project with the API demos 12 code will cause a lot of errors.
Android: Disabling anti-aliasing for pixel art
Posted by Dimitri | Filed under Programming
Android is great when it comes to displaying scaled pictures in applications and games since it tries to interpolate the pixels, making the resulting image look as good as possible. That works for almost every case, however, what about pixel art? This behavior isn’t good for that because, after scaling it, the resulting image will be “smoothed out”, invalidating the handcrafted pixel placement.
There are two options in this case: use an image with the correct size and never scale it, or try to disable anything that could be aliasing the image. This post is going to describe how to do the latter. As usual, an example project is available for download at the end of the post. (more…)
Android: Transparent or Translucent View Background
Posted by Dimitri | Filed under Programming
This Android post is going to explain how to change the background color of a View, to make it completely or partially transparent. It may seen a little strange at first, but sometimes it makes sense to create a translucent or transparent background, like when coding an application with multiple viewports, such as a graphic editing tool, for example. Luckily, Android has already some built-in features that aids the programmer in achieving total or partial transparency at any required level.
So, to create a fully transparent background, all that’s needed is to add the following line to the Manifest file: (more…)
Android: take a picture without displaying a preview
Posted by Dimitri | Filed under Programming
Accessing hardware functionality when programming for an Android device is generally quite straightforward. The same can be said about writing an Activity that takes a picture, but Android requires a preview of what the camera will capture to be displayed prior to capturing an image. This post explains how to “cheat” this requirement imposed by the OS, and how to write an application that takes a picture and displays it.
An Eclipse project with all the code explained here is available for download at the end of the post.
Before going into the Activity code, the interface layout (the main.xml file) must be edited to add a Surface View and an Image View to the interface. To add an element, just drag and drop it from the list inside your layout, like this: (more…)