Cylinder in OpenGL ES 2.0

For my current project, CPU Information I wanted to create a 3D representation for a Battery to indicate the remaining charge of it to the user in a visually appealing way.

Initially I used a 3D battery model but after playing around with it some time, I decided to build the Battery model in code instead. All that was required for it was to find a algo I could easily adjust for my program.

After searching for a few hours ( yes hours ) I came to realize that there was no good example for OpenGL ES 2.0 and I had to write my own.

It seems that there are plenty of examples for OpenGL 1.x or examples in many other different shapes and forms but none that I could find which simply creates a GL_TRAINGLE_STRIP – buffer and passing it to OpenGL ES 2.x.

Algolite

The algorithm will create a cylinder in one buffer by first creating the top circle, then the cylinder and finally the bottom circle. The OpenGL Drawing mode is GL_TRIANGLE_STRIP.

You only have to provide radius, height, and number of segments to create the cylinder. Once the floating point buffer with the vertices is created we have to convert it to OpenGL digestible FloatBuffer and the pass the information to OpenGL for rendering … Done.

Decomplexify

The passing of the data to OpenGL is cookie-cutter OpenGL code which you can find easily. I do not want to complexify this sample here by cookie cutting.


    // Creating a cylinder object to be rendered in OpenGL
    Object3DData createCylinder ( float radius, float height, int segments, float yOffset, float clr[] ) {
        float buffer[]  = createCylinderBuffer ( radius, height, segments );
        FloatBuffer vertices = makeFloatBuffer ( buffer, buffer.length );

        Object3DData     obj = new Object3DData( vertices );
        obj.setDrawMode ( GLES20.GL_TRIANGLE_STRIP );
        obj.setColor    ( clr[0], clr[1], clr[2], clr[3] );
        obj.setPosition ( 0.0f, yOffset, 0.0f );
        return obj;
    }

    // GL_TRIANGLE_STRIP -=> Standing cylinder
    float[] createCylinderBuffer ( float radius, float height, int segments )  {
        int iBuffSize = segments * 3 * 3 + (int)( ((float)segments/3.0f+1.0f )) * 3 * 2 + 6;
        float buffer[] = new float[ iBuffSize ];
        int t, idx = 0;
        float increment = (float)( 360.0f / (float)( segments - 1 ) );

        //create the top
        int iZeroCounter = 2;
        float hh = height / 2.0f;
        for ( t=0; t<segments; t++ )  {
            float angle = (float)( Math.PI/180.0f * t * increment );
            float cos = (float) ( radius * Math.cos ( angle ) );
            float sin = (float) ( radius * Math.sin ( angle ) );

            if ( iZeroCounter++ >= 2 )  {
                buffer[idx++] = 0.0f;
                buffer[idx++] = +hh;
                buffer[idx++] = 0.0f;
                iZeroCounter  = 0;
            }
            buffer[idx++] = cos;
            buffer[idx++] = +hh;
            buffer[idx++] = sin;
        }

        // create the cylinder
        for ( t=0; t<segments+2; t++ )  {
            float angle = (float)( Math.PI/180.0f * t * increment );
            float cos = (float) ( radius * Math.cos ( angle ) );
            float sin = (float)-( radius * Math.sin ( angle ) );

            buffer[idx++] = cos;
            buffer[idx++] = hh;
            buffer[idx++] = sin;
            hh *= -1.0f;
        }

        hh = height / 2.0f;
        for ( t=0; t<segments; t++ )  {
            float angle = (float)( Math.PI/180.0f * t * increment );
            float cos = (float)-( radius * Math.cos ( angle ) );
            float sin = (float) ( radius * Math.sin ( angle ) );

            if ( iZeroCounter++ >= 2 )  {
                buffer[idx++] = 0.0f;
                buffer[idx++] = -hh;
                buffer[idx++] = 0.0f;
                iZeroCounter = 0;
            }
            buffer[idx++] = cos;
            buffer[idx++] = -hh;
            buffer[idx++] = sin;
        }
        return buffer;
    }

    public static FloatBuffer makeFloatBuffer ( float[] arr, int iSize )  {
        if ( iSize == 0 )
             iSize = arr.length;
        ByteBuffer bb = ByteBuffer.allocateDirect ( iSize * 4 ); // Size of Float is 4 bytes
        bb.order ( ByteOrder.nativeOrder( ) );
        FloatBuffer fb = bb.asFloatBuffer ( );
        fb.put ( arr );
        fb.position ( 0 );
        return fb;
    }

Promising results

Here is the result in all its glory after stacking a few cylinders on top of each other, coloring them and give the battery a heart beat. Yeah, I think you can’t enough Special effect this one.

Please feel free to install CPU Information onto your Android device and try it out in action.
Get it on Google Play

Android SEO app

If you have a blog, a web-page, or any other kind of online-content which you want to expose online and grow your customer base or readership, you will have to do SEO.

Search Engine Optimization is the methodology to increase your sites visibility in the search engines, such as Google or Bing. Increasing your position in the search results by just one or two positions could mean the difference between earning money or closing your doors ( virtually ) forever.

SEO as a Sport

There are a ton of resources available online and offline to learn all about SEO. Most of those however are pointed to some sales funnel or describe some kind of oversimplified rules and tools.

The thing I have learned about SEO is that there is no certain way of doing SEO which will always work. Instead, you should see it as an art rather than a science project.
 
If you play it like a game and you keep at it for a long time you will certainly see more or less results.
 
Where to start on your journey and how to go about your initial steps in ranking better will be overwhelming. There is google trends, keyword suggestion tools like this , Alexa site ranking, Backlink checker, and tools which help you to discover more about your sites appeal on the internet than you could ever ask for.

Black-hat-techniques

I mentioned above that there is no sure fire way to improve your ranking. This is of course in regard to SEO. You can always count on search engine ranking you higher for better content. If your site has the highest authority about any subject, you will get ranked accordingly. This is the number one ingredient to your sites success. SEO is the second most important thing you can do to rank your site well with search engines.

There are however some ways to get punished if you go about it the wrong way. Black-hat-SEO is one of the easiest ways to get your site ignored by the search engines. Stay away from any of those if you want your site to be visible to any human being.

For example, if you pay someone to build a huge amount of backlinks ( other web pages pointing to your web page ), then you have great chances to get your page ranking dropped by Google to a place in hell, which in Google land is a rank of 1.000.000.000 +.

Do the right thing

However there are White hat ways to improve your rankings. Such as adding good and meaningful contents on a regular basis or building the best blog, web-site or whatever it is you want to rank
 
This of course required hard work and takes in general a long time.
 
Another approved of way to get more visitors is of course through paid advertising, especially if you use Goggles AdWords.
 
Using a keyword planning tool to make certain your site is ranked for the right keyword is another way to increase your ranking. As a matter of fact, keywords are so important to you ranking that you will have to dive in and really learn as much as you can about them.

 

What to do

The question for most people then boils down to what-to-do, when-to-do-it, and how-to-do-it. Especially as a beginner this can be challenging as you don’t know the rules and tools yet and you don’t want to get yourself into hot water.
 
Enter “Free SEO Tool”, the Android app which provides you with a shorthand way is playing with SEO tools from all around.

It offers a collection of tools in one convenient spot. The resulting report for your website spans 25 pages and will also explain reach of the analyzed sections in the report. You can also export the report as a PDF version and share the results with others.
 
Give this app a try and see how you can improve on you online present to increase your visibility. The report is huge but easy to read and understand. The required changes on your site should become obvious, and best of all, its free to boot.

Get it on Google Play

Get it on Google Play

Throwing money at google

Here, take these $26.​60 google to find me some nice people to install my app.
... but why would you do that ? Google already rakes in billions of dollars in revenue … Well let me tell you why.

I have been running a few AdWord campaigns in the past and I wanted to run a new ad campaign for my latest app :
CPU Information

CPU Information

As I just started out with this campaign and as I am not a huge corporation but a small indy-developer, I started with $20,- and thought to myself I want to get up a bit on the high side and then reduce my bid target to stretch the money throughout a 24 hour time period. So I started to target at $0.15 per conversion.

Chill time

Off I went onto doing different things. Then about an hour later I checked back and I had spend $26.60 already on this campaign. so 30% over budget and way earlier than expected. However this is not the reason I told you that I threw money at Google, the real head scratcher came when I wanted to correlate the approximately 200 conversions to my play store account.

Interestingly The play store hourly installs did not budge at all. So it is almost as if another app profited from my investment :(. I have no idea how this may have happened as I would have expected to see at least the bump of an additional 200 installs during that time period. Also My AdMob account showed the same unmoved result, as if nothing had happened and the 200 conversions did not reach my app at all.

I have shifted my approach now and reduced my bids down to $0.05 to stretch the installs out. Next thing to do is to go and dig a little bit deeper into stats from Firebase, the Play store, AdMob, and AdWord.

I want to find out what happened to my supposed conversions and the approx 42k views of my app. If you have an idea of what could be going on, please share and let me know.

AdWord where …

After some more digging I found one issue with the campaign which was location. Originally I wanted to only target the US and Canada. I set this up but I must have forgotten to click on the [Save] button before starting the campaign.
Thus my ads were distributed worldwide and a good chunk of the installs went to the southern hemi-sphere, to countries like Libya, Algeria, Iraq, India to name a few.

While this explains why the money was exhausted as fast as it was at the target bid prices, as well as why my AdMob revenue did not jump up. After all the cost-per-click in these regions is usually way below
what you will get in the northern hemi-sphere, I.e.  Europe or northern America. 
So from a regional targeting you get more per click however at the same time it is also way more expensive to get traffic to your app.

App Store stats …

I am still investigating as to why my app-store does not reflect the additional 200 installs.

And finally this mystery has been solved as well. It took The play store around 6hours to get the hourly stats to reflect the actual installs which came from this one-time boo-boo of mine.

What have we ( I ) learned

  • Be careful when starting a new ad campaign. Going forward I will set the max allowance to a small enough amount so that in case something does ot work out as expected, I can re-adjust before go all in.
  • Look at the stats of all available sites, like AdMob, AdWord, Google Play, and Firebase
  • Be patient. I have had some interesting correlation dissonance happened to me in the past. Especially the google play store stats are somewhat funky.

Android Oreo’s CPU stats

I have been using Android phones for a long time now and have never really considered switching to an iOS device. I think that ever since Android version 4.x ( 3.0 was terrible ) the hardware and software selection was better than those offered by Apple. From there on, Android waas getting better by the release it seemed … or was it ?

Google has however started to remove features from the OS over the past few years which is starting to limit the apps which can be written for these devices.

The storage API is one example which started to slowly diminish over time and is getting to the point where you can no longer access external storage in a concise and manageable way.

With Oreo, google has again removed some functionality which was very useful. This time Google made it impossible to monitor, and report on the CPUs utilization of its cores or the overall CPU utilization.

New motto ???

All of /proc/stat has been disabled for non-System apps, as a side-channel. More information, with an official response from Google here: https://issuetracker.google.com/issues/37140047

While there is an API available to retrieve similar information, it is only available for kiosk-like devices and not enabled in a stock mobile device. Starting from API level 24:

HardwarePropertiesManager propertiesManager = (HardwarePropertiesManager)context.getSystemService(Context.HARDWARE_PROPERTIES_SERVICE);
CpuUsageInfo[] cpuUsages = propertiesManager.getCpuUsages();

But only system apps have access to this API, because only system apps can have android.permission.DEVICE_POWER permission, which is needed here.

So the developer, and the users are left out in the dark on what’s zapping the Phones battery, and you will never know when the cores got to 100% proactively but only when your phone slows down.

Please let me know if you have Oreo ( and above ) and you know of an app which does display the CPU stats for you.

Shader Editor app

Android and iOS smart phones support the OpenGL ES 3D library.

The latest version for OpenGL Stand currently at 3.2 which was released in August 2015. Most phones on the market however support OpenGL 3.0 since Android 4.3 or iOS 7.

Those is versions we released in or around 2013 such by now was five years ago.

The OpenGL API had changed a lot between 1.x and 2.0 in that it introduced vertex and fragment shader languages as part of the spec. Prior to this, the OpenGL library stopped a set of will defined API calls to handle most aspects of the OpenGL Städte engine.

OpenGL shaders

As stated above, the shader language became past of the OpenGL Standard with version 2.0 and onwards. What it provides is more flexibility in programming the GPU tender pipelines. Instead of trying on a fixed, hardcore pipeline you can go ahead and code your own shader program.

This flexibility comes at the expense of some additional complexity alas this can greatly be migrated through the usage of or defined coffee snippets or libraries which sit Stop OpenGL.

The shader language is leaning heavily on c-style and is functional in nature. As the code is compiled, linked and will then be loaded into the GPU and run with a limited set of instructions, this language is limited in certain aspects and I would really recommend to find online courses or read a book if you want to truly understand the inner working of OpenGL.

 

OpenGL ES

The ES Stand for embedded systems, and is an indication that it has some limitations to the desktop version. Alright although those limitations are really not as big as one would think.

What is more is that WebGL is basically identical to OpenGL ES and many of the shaders you will find running in the browse will also run in your phone.

For example, the web page Http:www.shadertoy.com has a lot of very interesting looking shader samples which you can adapt easily to run on your phone.

But how ?

Shader editor

The shadertoy app can help you play around with some really cool looking shader examples. When you first download the app you will only see a limited set of available samples. Burger you can easily edit and save new shader samples on your device with this app.

The editor is using a just in time compilation of the code on a semi transparent editor window. This allows you to easily explore you shaders and view the results in real-time.

The way that this tool used the OpenGL libraries is to use a fixed vertex shader code base and have all the code executing in the fragment shader. Which is to say that the whole logic is about coloring the fragments ( parts of a pixel ) to achieve those stunning effects.

If you like to experiment and OpenGL is something you have always wanted to play around with, then Shader Editor is a small app you can not afford to miss.


Get it on Google Play

Get it on Google Play

D-Tube, video cryptonite

D-Tube is a distributed video platform based on Steem . Say what ???
Okay I can see the proverbial question marks popping off of your head. No worries, I am hear to help.

Lets  go through this one fancy term at a time.

Steem, Steemit, Steem-Dollars, Steem-Power


We all know Bitcoin or we have heard of it. That magical unicorn currency which created billionaires over night. And while a lot of what has happened in the past few months was mostly negative, such as the collapse of bitconnect, the underlying technology is sound and offers many new opportunities in the tech sector.

As bitcoin has eased off last years heights of over $19000,-US per bitcoin, it currently stands at around $3200,-US per bitcoin, the whole blockchain technology front is in search of providing value beyond the selling of dreams of digital currency backed by … well I leave that up to you to figure out …

Steem is a crypto currency which is in contrast to bitcoin is based off the. Here is a good rundown of what steem is. This article goes into steem vs steem-dollar vs steem-power.
Overall, steem solves a major problem in digital content creation. You can consider Steemit as similar to Reddit, where users can create and publish their content online and get rewarded for it. However, there is one major difference. it also rewards its users using cryptocurrency!

Oh and it is uncensored, decentralized and safe .. in theory.

D-Tube, the YouTube alternative

D-Tube was started by Adrian M  as an alternative to other digital content platforms such as YouTube. The whole concept is build around the steem cryptocurrency and as a creator you will be rewarded with Steem instead of US Dollars.

There is a lot to learn about Steem and D-Tube in the beginning but once you created your account with steemit you can go ahead and create contents and publish it on D-Tube without the fear that your video may be removed by a corporate working slave with a set agenda.

What’s more is that Steem will reward you for any kind of contents you create and publish on the Steemit platform. For example I am publishing this WordPress blog post on the Internet and also on Steemit to increase visibility, and potentially earn a few cents of Steem ( Dollars and Power ).

D-Tube app

​​ 
The D-Tube app can be used to view videos in a very similar fashion as you would watch YouTube videos. However the functionality at this point in time is not much further advanced as creating a shortcut to the d.tube mobile friendly web page on your home screen. Both solutions allow you to get very similar functionality as YouTube’s video client.

From a technological point of view I think that both YouTube, and D-Tube are neck-to-neck and you will have no issues finding your way around the app.


Video Quality

Now I am not talking about the resolution, bitrate etc here. What I mean with quality is the contents of the video provided on the platform.

While it is true that you can earn money on D-TUbe, the ability to do so heavily depends on the Whale’s on Steem. In reality what you will realize is that while there is no censorship on steemit, there is an indirect censorship driven by the people with the most money ( Steem-Power ).

If you make a video which one of those whale-people likes, you stand to earn a lot of money. On the other hand, if you like to create contents about knitting or Java, there will be very little you can earn.

But on the positive side, just like YouTube, you can create your audience over time and if you are truly good at what you do and you do provide real value to — the community –, then you can grow your income as well over time and eventually become one of those whales yourself.

App vs web-page-shortcut

Android App
Android App
If you are thinking about installing the app or simply creating a web-page-shortcut, then either one will do the trick at this time. I am confident that over time there will be more advantages in choosing the app.

For not my recommendation though has to be to go to your mobile browser, navigate to https://d.tube, then find your settings and “Add to Homescreen”.
Web Page Shortcut
Web Page Shortcut


Creator vs Consumer

The answer is Yes ( or 42, depending on your leaning ). You have to check this out and decide for yourself if you like it. I found myself fascinated with the whole concept and given the proper circumstances, I can see this platform grow by leaps and bounds over the coming years.

YouTube killer … not quite yet. But if YouTube continues to disregard the smaller contributors and build more negative sentiment I have no doubt that a platform like D-Tube will give the multi billion $ behemoth a run for its money ( and future ).

Overall app rating : 3 stars out of 5.
Overall technology rating : 5 stars out of 5.
Overall honesty rating : 5 stars out of 5

Get it on Google Play

JAMFOX earbits

A few weeks ago, my trusted BT headphones broke. I had them for about a 1.5 years and I was very happy with them.

They were comfortable and quality was great and they were omni-present to the point where I forgot I was wearing them around my neck.

 
I charged them up once in the morning and when I returned from work they could still give me company until bedtime. Obviously not un-interrupted.

Then one day the left side speaker gave out. It was the cable. In my younger days I would have fixed it with my soldering iron but as you grow older you tend to value your time more and so I decided to get a pair of new bluetooth headsets. 

JAMFOX Earbits

Wireless headphones have shrunk down to the point where they have been renamed to earbuds. Well JAMFOX thought earbits may be more along the lines of their marketing strategy and indeed those speakers are tiny bits of Bluetooth technology.

You get two bluetooth devices which connect to your phone. You can also use them individually. For example, you could loan one to your friend and keep the other one connected to your phone.

A fun experiment is to connect them to different phones and listen to both at the same time. Absolutely the best solution for people with multiple personality disorder.

In my case I was more the normal user and wanted to listen to music most of the time, talk on my phone, and also have the ability to use only one side to have the second ear available for my colleagues at work while I am in the kitchen eating lunch. 

Setup and usage.

In order to pair the set to your phone you have to only pair the JAMFOX-L and ignore JAMFOX-R. That is you do not need to pair the right side with your phone. The Left earbit will connect to the right earbit and thus allow you to listen to stereo.

The bits both come with built in microphones and allow you to do a normal phone call. They behave as you would expect, which means they will stop playing your music or video when a call is coming in.

Another great thing about those little gems are the touch sensors sitting on top of each earbit. They are used to pause / play, as well as increase and decrease the volume through double-tapping the left of the right bit.

Troubleshooting

I used them the first 4 weeks without any issues and eventually I gotten myself into the situation where I could only listen to the left earbit OR the right one but not to BOTH at the same time.

Searching online did only reveal a set of instructions which did not work for me but eventually I figured out how I could get stereo back:

I could fix it by

  1. unpairing from my Android device ( Nexus 6 )
  2. pairing it with another phone ( Remember to only pair JAMFOX-L, and ignore the right channel ). Stereo came right on.
  3. I then unpaired it with the second phone and could
  4. finally get stereo back on my Nexus after re-pairing JAMFOX-L

I hope this helps people with similar problems.

Conclusion

Those are great earbuds / earbits / headphones to have and they are well worth the investment. The battery pack will allow you to basically survive the whole day without the need to plug in.

The sound quality is the only thing which could be better however this is mostly due to the size of the speaker and I would not expect them to of the same quality as a full sized headset.

Please share your experience with them if you have the same set of earbits.

Get your background going

Setting the background of your phone is something that most people do only once in a while. I have had periods where I used the same background image for years.

Lately however I grew tired of my static background and wanted to get something with more pep.

Welcome to 3D Parallax Background.

If you don’t know what parallax stand for, according to Wikipedia, it is :

Parallax (from Ancient Greek παράλλαξις (parallaxis), meaning ‘alternation’) is a displacement or difference in the apparent position of an object viewed along two different lines of sight,

In other words, your brain can utilize the parallax from the information from both of your eyes to detect depth.

Another obvious effect is that objects closer to your eyes will move more than objects farther away. Having a multi layered image, where the background layer moves less than the foreground layer will trick us into seeing depth where there is none.

3D Parallax Background is using this effect and does so with great results. Once you have the mechanics in place, the most important thing to do is to create some stunningly beautiful collages to use.

You can choose between more than 250 different background themes in a selection menu which in itself is animated so that you can easily see the 3D effect before you actually download the whole theme and install it as your background.

 

Themes range from nature to movies to space to abstract and anime, to name but a few. I really like this app and use it currently as my background with changing themes.

I love beaches and beer which is great because there is a ready made background for me, as well as the cars and space and … well you get the drift.

The usability is also well thought through and you have many options available in the settings to tune the background to your liking. Actually the only thing I found missing was an editor to build your own theme and utilize it or publish it for every one else to use.

Overall, this app rocks, and I would recommend you take a closer look at it if you are in the market for a new background.

If you want to check it out, then hush over to the play store and install it from here

Get it on Google Play

Device Info the Iron Man way

Your Android phone is an incredible piece of technology. It has the ability to not only make phone calls but you can also take pictures and videos, play 3D accelerated games, find your location using the GPS satellite system, you have a gyroscope, compass, accelerator and much much more.

All of this hardware comes in nearly unlimited variations put together into a singular, unique device. The Samsung S5 and a Pixel XL smartphones for example both have the same types of hardware available but have vastly different hardware chips for those tasks.

If you want to know your phone, you have to know your phones innards and software versions. There are plenty of device info apps on the app store. However there is one app in particular which makes it fun and exciting to look up all of these pieces of information.

CPU Information

This app has a Virtual Reality inspired interface to view your device information. The interface can be adjust the color scheme and a few other details which makes this a great app to go together with your devices protective cover.

The dashboard graphics are stunningly beautiful and playful. Aside from the center control which acts as a menu you can also see the polar clock on the top left corner. The sound effects are very well done and play seamlessly with the animation.

CPU Information is under active development and new widgets will come on a constant basis. If you install it today you will be able to see the progress over time and take full advantage of all new widgets and features before you have to pay for them.

So to sum it all up, if there is one app you want to use to view your devices information, it is this app. CPU Information offers all the information plus one of the most unique interfaces on the app-store.

Intro Video

You can take a quick peek at the application in action in this short demo video below. But please note that the app may hav added new features by the time you view this video.



Get it on the Play store now.

Get it on Google Play