• A Cow Based Economics Lession

    Reposted from Sam Aminisam

    SOCIALISM You have 2 cows. You give one to your neighbor.

    COMMUNISM You have 2 cows. The State takes both and gives you some milk.

    FASCISM You have 2 cows. The State takes both and sells you some milk.

    NAZISM You have 2 cows. The State takes both and shoots you.

    BUREAUCRATISM You have 2 cows. The State takes both, shoots one, milks the other, and then throws the milk away.

    TRADITIONAL CAPITALISM You have two cows. You sell one and buy a bull. Your herd multiplies, and the economy grows. You sell them and retire on the income.

    ROYAL BANK OF SCOTLAND (VENTURE) CAPITALISM You have two cows. You sell three of them to your publicly listed company, using letters of credit opened by your brother-in-law at the bank, then execute a debt/equity swap with an associated general offer so that you get all four cows back, with a tax exemption for five cows. The milk rights of the six cows are transferred via an intermediary to a Cayman Island Company secretly owned by the majority shareholder who sells the rights to all seven cows back to your listed company. The annual report says the company owns eight cows, with an option on one more. You sell one cow to buy a new president of the United States , leaving you with nine cows. No balance sheet provided with the release. The public then buys your bull.

    » Continue reading

  • Why I prefer Android over iOS

    There are a lot of discussions around which mobile devices are the best and a lot of reasoning why either side is better, Google’s Android or Apple’s iOS. Personally I really prefer Android, continue reading to learn why.

    The one argument that I will not discuss here is the price of different devices, iPhone is much more expensive compared to Android devices with the same specifications and I for one want value for my money.

    So what do you prefer? The customization and selection of Android devices or the straight forward iOS devices?

    HTC One X and iPhone 5 side by side (Source: TechnoBuffalo)

    Design & usability

    One of the common myths about Android is that it is ugly and hard to use. In the beginning of Android, this was completely correct. iOS that was introduced in 2007 looked much better and was more of a complete product than the HTC Dream when it came in 2008. So what has changed since then?

    Android have focused much more on design and feel the later years as a response to the critique, this led to Android introducing design principles for Android applications and even publishing it all on their developer site: Android Design. This has led to the applications, the base Android user interface and the manufacturer skins looking a lot better and following the same design principles.

    » Continue reading

  • Setting up a Git client with SSH keys

    As a developer, version control systems are one of the daily routines. Surprisingly there are a lot of people who does not know how to use them even though there are a lot of good tutorials out there. Today we are adding a new one, trying to explain the setup process as simple as possible. For now, we will stick to using Git with Windows and a GUI.

    Start off by downloading the following files:

    The installation proccess

    To be sure, I'll go through every program to make sure that everything gets set up correctly.

    Installing Plink and puTTYgen

    These programs have no installer, so simply place them in a directory that is not in your way, as you will at least need the Plink for later. The newer installations of TortoiseGit does not require these as they are included in the installer, so this is just mentioned to be sure.

    Installing msysgit

    A very straight forward install, select "Use Git Bash only" when asked for adjusting your PATH environment and make sure that you set the line endings to "Checkout Windows-style, commit Unix-style line endings" if someone in your team uses Linux. I would never recommend using the other ones, unless you are specifically told to do so or if you are running your Git server on a Windows machine. If you want to add the Windows Explorer integration, go ahead, but it is really not needed as we are using TortoiseGit for this instead.

    » Continue reading

  • A little JavaScript progress bar with JQuery

    As it has been a lot of heavyweight programming lately (as well as the code that I have shared here) I wanted to lighten the mood and do a little JavaScript with JQuery again. This is a very simple progress bar that can be used pretty much anywhere. It looks something like this:

    0%


    Hover over the progress bar to animate it.

    The code:

    <div id="pbar_outerdiv" style="width: 300px; height: 20px; border: 1px solid grey; z-index: 1; position: relative; border-radius: 5px; -moz-border-radius: 5px;">
    <div id="pbar_innerdiv" style="background-color: lightblue; z-index: 2; height: 100%; width: 0%;"></div>
    <div id="pbar_innertext" style="z-index: 3; position: absolute; top: 0; left: 0; width: 100%; height: 100%; color: black; font-weight: bold; text-align: center;">0%</div>
    </div>
    
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script type="text/javascript">
    var timer = 0;
    var perc = 0;
    
    function updateProgress(percentage) {
        $('#pbar_innerdiv').css("width", percentage + "%");
        $('#pbar_innertext').text(percentage + "%");
    }
    
    function animateUpdate() {
        perc++;
        updateProgress(perc);
        if(perc < 100) {
            timer = setTimeout(animateUpdate, 50);
        }
    }
    
    $(document).ready(function() {
        $('#pbar_outerdiv').mouseenter(function() {
            clearTimeout(timer);
            perc = 0;
            animateUpdate();
    	});
    });
    </script>

  • Android OpenGL Texture Manager

    At the moment, I am working on a little project for Android. It is going to be a 2D tank war game using the accelerometer in the device for controlling the tank. When doing this I made a little texture manager class so that I can refer to the resource ID instead of the index of the GL Texture, making it a lot easier to use textures in OpenGL. Keep in mind that that code does not check for resources that are not loaded, you might want to add that or ensure that the required resources are loaded.

    Using this is very simple. Here is an example:

    // When initializing
    TextureHandler h = new TextureHandler(ctx, gl);
    h.addTexture(R.drawable.image1);
    h.addTexture(R.drawable.image2);
    h.addTexture(R.drawable.image3);
    h.loadTextures();
    
    
    // In the draw loop
    h.setTexture(R.drawable.image2);
    

    The Code:

    import java.util.ArrayList;
    import javax.microedition.khronos.opengles.GL10;
    
    import android.content.Context;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.opengl.GLUtils;
    
    public class TextureHandler {
        private Context context = null;
        private GL10 gl = null;
        private ArrayList<Integer> textureResources = null;
    	
        private int[] textures = null;
    	
        public TextureHandler(Context context, GL10 gl) {
            this.context = context;
            this.gl = gl;
            textureResources = new ArrayList<Integer>();
        }
    	
        public void addTexture(int resourceID) {
            textureResources.add(resourceID);
        }
    	
        public void loadTextures() {
            textures = new int[textureResources.size()];
    		
            gl.glGenTextures(textureResources.size(), textures, 0);
    		
            for(int i = 0; i < textures.length; i++) {
                Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), textureResources.get(i));	
    			
                gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[i]);
    			
                gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
                gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
    			
                GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
                bmp.recycle();
            }
        }
    	
        public boolean setTexture(int resourceID) {
            for(int i = 0; i < textureResources.size(); i++) {
                if(resourceID == textureResources.get(i)) {		
                    gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[i]);
                    return true;
                }
            }
            return false;
        }
    }
    

  • OpenGL 4.0 wrapper using GLEW and GLFW

    So after my post yesterday about the GLSL shader loader, I thought that it might be redundant without the actual wrapper so here we go! GLWrapper.hpp

    #ifndef GLWRAPPER_HPP
    #define GLWRAPPER_HPP
    
    #define GLFW_DLL 
    #include "GL/glew.h"
    #include "GL/glfw.h"
    
    class GLWrapper {
    private :
        int width;
        int height;
        char *title;
        double fps;
        void (*renderer)();
        bool running;
    
    public :
        GLWrapper(int width, int height, char *title);
        ~GLWrapper();
    
        void setFPS(double fps) {
            this->fps = fps;
        }
        void setRenderer(void (*f)());
        void glMainLoop();
    };
    
    #endif

    » Continue reading

subscribe via RSS