Category Archives: Knowledge

Facts and information about different arguments to let you know that things exist and what is the theory about them. It requires a separate category than “Thoughts” and “Tutorials”, because it doesn’t express opinions and it’s not a set of instruction to teach you how to achieve a particular result.

The world of cryptocurrency and mining

I think that anyone has heard about cryptocurrency and bitcoin in the past, but I doubt that everybody knows the crazy world behind it. Everybody knows that bitcoin can be used instead of money to do online payments that cannot be traced. But when I talk to people, even if they work in the field of information technology, nobody seems to know the very basics of cryptocurrency, how it works, how much is a bitcoin, how you can buy it, what are altcoins, how you can convert them to money or to different altcoins, how new coins are introduced, the fact that bitcoin increased exponentially in the last year and that it will grow even more. And do you know why I know? Because I was part of those people and it is one of my best regrets :-)

Every year in informatics is characterized by huge events. Youtube was born in 2005. Facebook started the story of social networks in 2006, followed by Twitter, Instagram and Google+. But 2017 is the year of cryptocurrency. When Bitcoin was launched in 2009, the first transaction was 100 bitcoins to buy a pizza, then other coins were introduced into the system and the value of a single coin improved a lot, even though you could buy bitcoins for way less than one dollar in 2009. Just to make you understand, in this moment, 1 bitcoin is $9500. If in the past you bought 100 bitcoins for 0.30 dollars, now you would have had $950,000, about one million of dollars. Imagine when bitcoins were used mostly to make illegal transactions, mostly in the world of deep web, and imagine that those people, unlike me, knew everything about the world of bitcoins since 2009 and now they are filty rich. But jokes apart, the news that bitcoin improved exponentially is recent and it is spreading all over the world. The latest bitcoin forecasts say that bitcoin should increase even more in the future, but the predictions may diverge. Somebody says that the bubble will explode soon while other people say that, on the base of the current trend, it should reach about $50,000 in 2020. So, even if bitcoin is the heaviest coin on the market of cryptocurrency and it's reaching its maximum saturation in terms of circulating coins, it should increase even more in the future. So bitcoin and cryptocurrency in general are becoming in the understanding of people a great investment to make huge quantity of money. You don't have to do a boring job every day of your life, the only thing that you need to do is: buy $30'000 of bitcoins, wait 2-3 years, make $150'000 of bitcoins: that's it. Another thing to make profits is to exchange from one currency to another, to take advantage from the market fluctuations. In this case, you don't even need that the value improves, but you can make money through wise choices. You could sell altcoins when the value is rapdly decreasing and buy them again when the value is high again, doing what is called "trading". Now that the news is spreading along its huge promises, everybody is buying bitcoins or altcoins to make profits from fluctuations and trading. But that's not all.

Continue reading

Targeting OpenGL is not so easy, don’t get confused by the documentation

I want to create this post to clarify once and for all how the OpenGL extensions mechanism works and the correct proceedings to target OpenGL versions. I named this article in this way because OpenGL are generally bad documented (or difficult to understand) and OpenGL.org wiki makes the things worse. For example, several people got confused by this page:

https://www.opengl.org/wiki/OpenGL_Extension#Core_Extensions

Targeting OpenGL 2.1

These are useful extensions when targeting GL 2.1 hardware. Note that many of the above extensions are also available, if the hardware is still being supported. These represent non-hardware extensions introduced after 2.1, or hardware features not exposed by 2.1's API. Most 2.1 hardware that is still being supported by its maker will provide these, given recent drivers.

And this document:

https://www.opengl.org/registry/specs/ARB/map_buffer_range.txt

"New Procedures and Functions

void *MapBufferRange( enum target, intptr offset, sizeiptr length,
bitfield access );

void FlushMappedBufferRange( enum target, intptr offset, sizeiptr length );

Issues

(1) Why don't the new tokens and entry points in this extension have
"ARB" suffixes like other ARB extensions?

RESOLVED: Unlike a normal ARB extension, this is a strict subset of functionality already approved in OpenGL 3.0. This extension exists only to support that functionality on older hardware that cannot implement a full OpenGL 3.0 driver. Since there are no possible behavior changes between the ARB extension and core features, source code compatibility is improved by not using suffixes on the extension."

so the question is:

- GL_ARB_map_buffer_range is a core extension or not?

Continue reading

How the deprecated OpenGL matrix model works

Even if nowadays everybody seems to drop OpenGL methods when they are deprecated on the core profile, it doesn't mean that you don't need to use them in compatibity profile or that you don't want to know how they work. I searched on the web to find more information on how the old and deprecated OpenGL matrices are implemented and I didn't find anything (except tutorials on how to use them!). My doubt was mainly about the operations order, because I needed to make a C++ implementation of them, maintaining the same exact behavior. I used OpenGL matrices In the past without worrying about how they were implemented, I had a precise idea but now I have to be 100% sure. Even if we know how to implement operations between matrices, the row-column product doesn't have the commutative property so the internal implementation can make the difference. At the end, my question is:

- What is the matrix row-column order and how the product is implemented on OpenGL?

Tired of finding pages saying how they are useless and deprecated now, I had to check by myself the Mesa source code to find what I was searching for:

P = A * B;

P[0] = A[0] * B[0] + A[4] * B[1] + A[8] * B[2] + A[12] * B[3];
P[4] = A[0] * B[4] + A[4] * B[5] + A[8] * B[6] + A[12] * B[7];
P[8] = A[0] * B[8] + A[4] * B[9] + A[8] * B[10] + A[12] * B[11];
P[12] = A[0] * B[12] + A[4] * B[13] + A[8] * B[14] + A[12] * B[15];

P[1] = A[1] * B[0] + A[5] * B[1] + A[9] * B[2] + A[13] * B[3];
P[5] = A[1] * B[4] + A[5] * B[5] + A[9] * B[6] + A[13] * B[7];
P[9] = A[1] * B[8] + A[5] * B[9] + A[9] * B[10] + A[13] * B[11];
P[13] = A[1] * B[12] + A[5] * B[13] + A[9] * B[14] + A[13] * B[15];

P[2] = A[2] * B[0] + A[6] * B[1] + A[10] * B[2] + A[14] * B[3];
P[6] = A[2] * B[4] + A[6] * B[5] + A[10] * B[6] + A[14] * B[7];
P[10] = A[2] * B[8] + A[6] * B[9] + A[10] * B[10] + A[14] * B[11];
P[14] = A[2] * B[12] + A[6] * B[13] + A[10] * B[14] + A[14] * B[15];

P[3] = A[3] * B[0] + A[7] * B[1] + A[11] * B[2] + A[15] * B[3];
P[7] = A[3] * B[4] + A[7] * B[5] + A[11] * B[6] + A[15] * B[7];
P[11] = A[3] * B[8] + A[7] * B[9] + A[11] * B[10] + A[15] * B[11];
P[15] = A[3] * B[12] + A[7] * B[13] + A[11] * B[14] + A[15] * B[15];

where A and B are 4x4 matrices and P is the result of the product. As you can see, this snippet clarifies how rows and columns are internally ordered and how the product is implemented. In conclusion, the OpenGL methods to modify the current matrix are implemented by Mesa in this way:

Continue reading