How to modify this old pre-3.0 OpenGL code to modern OpenGL?

I’ve done the getting started section on learnopengl website. However, that means I don’t understand the old way of doing things, so I am struggling to understand some code I want to take a look at to better understand cloth simulation. In particular, I wanted to know how to create the main structure of the cloth in OpenGL. I know how to create a box right now, maybe not instinctively yet but by looking at the code I could see what is happening.

Here is the github repository to this code: https://github.com/bailus/Cloth

I am looking at the Cloth.cpp and see that it is created through the use of many triangles.cpp objects:

glBegin(mode);
    for (std::vector<Triangle>::size_type i = 0; i < triangles.size(); i++)
        triangles(i).display();
    glEnd();

The display method of triangles looks like this:

void Triangle::display() {

    for (int i = 0; i < 3; i++) {
        glTexCoord2fv(glm::value_ptr(particles(i)->texCoord));
        glNormal3fv(glm::value_ptr(particles(i)->normal));
        glVertex3fv(glm::value_ptr(particles(i)->pos));
    }
}

so my question is… what would be going on here in terms of VBOs? I can see there are texture coordinates and vertex coordinates… I don’t know about the normals. I would assume two VBOs from this, but how would I modify my display function and drawing function to support the latest opengl? Would the current object orientated structure work..? I am not sure how to go about it.

checkout – Best way to let the user modify the subscription (change number of mobile devices)

I have an online SaaS which users subscribe to. After a first trial period (one week), users can renew the service monthly. There’s no deadline to pay for the service. As soon as the user pays the monthly fee, the expiration date is extended of exactly 1 month, irrespective of when the user pay. So for example, a user may pay three times in a row on the same day to extend the current expiration date 3 months ahead.

This is a very simple model and it works very well.

Unfortunately the SaaS pricing model has another variable: the number of mobile devices per subscription.

Each month a user pays:

P x N

where P is the monthly fee for a single mobile device, and N is the number of devices the user currently have.

The free trial starts with 1 mobile device.

Now, given a fixed number of mobile devices, the user pays P x N for each month, which is fine, but how to handle changes to the number of devices?

If the change happen at the end of the current billed month, I just update N and ask the user to pay for the new amount. But a user may change the number of users during the current billed period (which is more likely).

I can’t figure out how to handle this. Till now, if a user increases the number of mobile devices, the system asks for a small sum of

M x C 

where M is the number of extra devices and C is the monthly fee for a single devices discounted for the partial month (remember we are in the middle of a billed month)

This pricing model is extremely confusing to the users which can’t figure out why they need to pay such a weird amount (the amount changes every time, depending on when the user increases the number of devices)

I’ll provide an example

Let’s say the monthly fee for a single device is $3.99 and the user has 4 devices.
Each month the user pays:

$3.99 x 4 = $15.96

Now, the user increases the number of mobile devices to 6. Which means the users added 2 extra devices to the subscription. The user does it 10 days before the current month expires.

As soon as the users does that, the system asks for the following amount of money:

$3.99 x (10/30) x 2 = 2.66 

This is because the user has to pay for 2 extra users for the current month, but only 1/3 of the current month is still available, so the user has to pay a little less (in this case only 1/3 of the full amount).

How can I present such computation in a clear way? It requires a lot of wording to explain that (as you can see on my post here)

Any other way to handle this? Giving for free the current partial month is not an option. Delaying the extra payment and attach it to the next renewal might seem confusing as well if the user doesn’t remember it. Forcing user to add devices only at renewal time might be frustrating because users may want to add devices right now.

Instead, removing devices is extremely easy: the system allows the user to decrease the number of devices at any time and for free. As a side effect, the users are incentivized to do it only at the end of the current month but this is not a big deal.

EDIT

Digging online I found that this is very common problem usually solved by proration billing. There is a fairly substantial amount of literature online.
I guess now the question is how to present the billing information to the customer in such a way it’s easy to understand

Mock page

Here’s an example of what I’m going to do.

First the user clicks on “change number of users”. The user is presented with this page

enter image description here

Then, the user select a value from the combobox (the desired new number of users). Here’s the updated page:

enter image description here

The “partial month” bit, although being correct, looks confusing. I can’t figure out a way to avoid fractions. Instead of 11/31 I could display 0.35 which is even more confusing as it’s not clear enough where the 0.35 comes from. Moreover, depending on the current month, the user may see 11/28 or 11/30 or 11/31.

I could just display a percentage (the percentage of the remaining month) but then the multiplication wouldn’t make sense (can’t multiply absolute values with percentages)

web server – Modify Cache-Control header based on condition over other header in Nginx

In a Nginx working as a proxy, I need to set the “Cache-Control” header on a response based on the size defined on their “content-length”.

For example, if the response have “150” or less, “Cache-Control” must be “max-age=60”, if not, “max-age=3600”

# curl -I 127.0.0.1/test_small.png
HTTP/1.1 200 
content-type: image/png
cache-control: max-age=60
content-length: 106
# curl -I 127.0.0.1/test_big.png
HTTP/1.1 200 
content-type: image/png
cache-control: max-age=3600
content-length: 250

android – Can I modify specific UI elements using Dynamic Feature Modules?

I have a paid and free version of my app. I want to split these two versions into Dynamic Feature Modules.

The free version shows ads and I wonder if it is possible to outsource the whole AdView tag in the XML layout to the Dynamic Feature Module?

Or, maybe, is it possible to duplicate the layout files and in the MainActivity have the logic which version is active and then change the layouts, either the layout from the free module or the layout from the paid module?

views – How to dynamically modify the text of the Global: result summary?

I’m using the Views module to displays search result. In the header of the views, I added the Global: Result summary to show result summary.

 "@total Results (@per_page per page)"  //Output: 25 Results (20 per page)

enter image description here

But depending on search result count the **Global: Result summary text should change. Meaning I want to dynamically change the text based on the search result count. For example, if total search result count is less than 10(configured Items to display)), then result summary text should be displayed like below.

 "@total Results"
  Output: 5 Results 

How can I achieve that that?

security – Can you modify the front-end source code of a mobile app?

It’s not just that people might be able to hack into your front-end app. They might be connecting directly to your server with an app that they wrote themselves.

I can get around whatever security in iOS prevents me from modifying an iPhone app, by just using Xcode to write a Mac app that connects to your server, pretends that it is a client app, and asks your server to do things that it shouldn’t do. iOS security or Android security can do nothing about it, because my code never runs on any phone.

On your server, don’t even try to detect that your front-end is your genuine, unmodified iOS or Android app. Instead examine all the data that comes from the front-end and check if the data can be trusted or not, not the application sending it.