Simflex Image Gallery - Full Free Flex Image Gallery

Comment


I am releasing my source code for a full fledged Flex 3 image gallery along with a PHP based Minimal Image file manager page with upload, delete and automatic thumbnail generation features. I had made this while learning Flex, but it is very usable in many projects.

To see it in action, download, extract and put the bin-debug folder under your web server. There is a folder called "Admin" inside "bin-debug" folder which has the PHP part responsible image upload, XML file generation and auto thumbnail code. To manage the images, use filelist.php in admin folder. Tested with JPG and PNG images.

Download Source code - 8.78 MB (along with sample images)
Please drop me a line if you are using this anywhere.

3d Tunnel OpenGL Source code - iPhone OpenGL ES compatible !

Comment



I am releasing source code of the iPhone OpenGL ES compatible Never-Ending Tunnel Source Code. The code is done using SDL on Windows only. But the OpenGL elements use only Triangle strips and all OpenGL ES compatible functions and porting to iPhone is a cakewalk.

I have searched on the web and never found a ES compatible version which is easily portable, so here we go enjoy. I have intentionally left a small glitch in Texture Coordinate generation, which actually looks pretty according to me. If you need I can help you to fix is easily.


Some important notes :-
  • No Models present - The Tunnel is a torus which is completely procedurally generated.. so the torus properties can be changed easily.

  • The Texture generation part is platform dependent. The files RTexture.h and RTexture.cpp is almost completely copy-paste reusable :D

  • DO NOT REMOVE - #define QUAKEBOY_IS_AWESOME (!)

Download Source code (along with SDL Library and Binaries included - 1.36 MB)

Andre Michelle's Tile based Scrolling ported to AS 3

Comment
Update:- I have found something that has to be added to the existing code. The SWF embedded here runs only @ around 60 FPS on a Safari or Firefox on a Mac. I will work on a more consistent render loop code adding some timer calculation elements soon.


I have ported the Tile based scrolling in Flash code by Andre Michelle to use Actionscript 3.0
Main challenge I faced was the tearing issue which was removed after I used Timer Event and updateAfterEvent() method. Thanks to 8bitRocket site for the tip.




I am getting a blazing 160 FPS in browser.. OMG Flash rocks ! If anyone wants me to provide comments and documentation for the code. I will happily do it on request.

Click here to get the full source code.

P.S. If its slow, its because you might be having the static noise swf playing below (scroll page down). View on the post page by click the title to ensure it plays smoothly.

Creating Static TV Noise in Flash using AS3

Comment
Creating Fast and Smooth Static TV Noise in Flash using AS3 was a simpler task than I expected it. First attempt was using for loops to set every pixel and was not very fast. A Simple browse through the API docs for BitmapData class gave me the 'noise' method

bgdata.noise(Math.random() * 1000, 0, 255, 7, true);
did the trick :)

Complete code below

package {
import flash.display.Sprite;
import flash.events.Event;
import flash.display.Graphics;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Point;
public class StaticNoise extends Sprite {
const ww = 480;
const hh = 272;
var bgdata:BitmapData = new BitmapData(ww, hh, false, 0xffffff);
var bg:Bitmap = new Bitmap(bgdata);
var zeroPt:Point = new Point(0,0);
public function StaticNoise() {
addChild(bg);
addEventListener(Event.ENTER_FRAME, drawBaby);
}
function drawBaby(e:Event) {
bgdata.lock();
bgdata.noise(Math.random() * 1000, 0, 255, 7, true);
bgdata.unlock();
}
}
}


You can modify,use this code where ever you want, without giving credits. But please just let me know in the comments if it helped you.

Android keyCodes list

Comment
a - z
29 - 54

"0" - "9"
7 - 16

BACK BUTTON - 4
MENU BUTTON - 82

UP, DOWN, LEFT, RIGHT
19, 20, 21, 22

SELECT (MIDDLE) BUTTON - 23

SPACE - 62
SHIFT - 59
ENTER - 66
BACKSPACE - 67

How to take Screenshot in Android Emulator with Eclipse

Comment

I used to use PrintScreen > MSPAINT > Ctrl+V combination to capture screen of Android Emulator. Recently discovered that we can get a neat screen shot inside Eclipse using the Devices View.

If the Devices panel is not visible, on the menu bar click Window > Show View > Other. In the newly opened dialog box, under Android category, select Devices.

Now on the Devices panel, Click the button as shown in the Image and your screenshot is ready.

tags:- android screen capture, android screenshot, android emulator screenshot.

How to load a texture in Android OpenGL ES

2 comments
Here is how you can easily load a texture from any image format - PNG, BMP, JPG etc.. in OpenGL ES in Android.

**Before you begin the code, you need to import your images into your project's /res/drawable/ folder. Just right click the project in eclipse and select import to do that.**

//First setup the integer array to hold texture numbers which OpenGL generates
int texture[] = new int[1];

//Generate and bind to the texture (gl is my GL10 object)
gl.glGenTextures(1, texture, 0);
gl.glBindTexture(GL10.GL_TEXTURE_2D, texture[0]);

//Setup the texture co-ordinates
float texCoords[] = {
0.0f, 0.0f,
1.0f, 0.0f,.......};
FloatBuffer texcoords = FloatBuffer.wrap(texCoords);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texcoords);
Bitmap wood = BitmapFactory.decodeResource(this.getContext().getResources(), R.drawable.myimagefilenamewithoutextension);

//Setup optional texture parameters
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);

//Set the texture image
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, wood, 0);

//Enable texture related flags (Important)
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

Hope that helped you.. please let me know any problems

Turning on Depth Buffer makes everything disappear !

Comment
I finally got to use textures on Android using OpenGL ES, and I found that its turn I started using the Depth buffer for some proper rendering. The moment I uncommented

gl.glEnable(GL10.GL_DEPTH_BUFFER);

The object disappeared and became invisible. Not even a pixel of the object was visible. Then a colleague of mine gave me a hint about clearing buffers !

Uffff ! I corrected the line
"gl.glClear(GL10.GL_COLOR_BUFFER_BIT);"
--to--
"gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);"

and everything was fine again !

Using M_PI gives error even after including math.h ?

Comment
If you look at the math.h header file, the PI math constant M_PI and other values will be defined at the end of the file and just above that there will be a conditional #define pre-processor statement.

Solution :- Just type in #define _USE_MATH_DEFINES after before including math.h

#define _USE_MATH_DEFINES
#include <math.h>