Categories
Articles Programming

How to Permanently Delete Your Gmail Account

While many would argue that Gmail is the best email platform there is, there are those who disagree. Whether it’s the promotional emails, the different labels and tags, or you’re worried about your security, Gmail might not be the best email option for you.

Luckily, there’s a simple way to delete your account, but since you’re most likely using Google services on other platforms (like Youtube or Google search), it’s best to double check that the rest of your information won’t be deleted too.

(If you want to delete all of your Google accounts, rest assured, you can do that, too. However, this article is geared towards those that simply want to delete their Gmail account.)

Before permanently deleting your Gmail account, there are a few things to consider and checkoff:

  1. If your Gmail account is associated with any social media accounts, you won’t be able to recover or reset your social media account information. This includes Facebook, Youtube, iTunes, Instagram, etc. Before you delete your account, create an alternative email account to switch everything to.
  2. If you receive any email subscriptions that you want to continue reading, you will have to change your account information there, too.
  3. Any contacts or information stored on with Gmail will be lost. It’s a good idea to download your data and file it somewhere else.
  4. Deleting your Gmail account will not free up your username. So, if you ever want a new Gmail account, you will need a complete new username.
  5. Deleting your Gmail account does not delete your Google account, so you will still be able to access Drive and other Google features, if you still want to.

Now that you’re all ready, here’s how to delete your Gmail account. (You can complete the same steps on your phone.)

How to Delete Your Gmail Account

Step 1 – Sign into your account

Sign into your Google Account by using myaccount.google.com and click Sign in. Enter your Gmail details and click Sign in.

Step 2 – Go to your account setting

On the Accounts page, find Data & personalization. This is usually towards the left-hand side of the page, along with other settings.

Step 3 – Choose Delete Products

  1. Next you’ll need to select Delete a service or your account.
  2. Google gives you two options, to delete a Google service or your entire Google account. If you only want to get rid of Gmail click on Delete a service, if you want to delete your account click on Delete your account.
  3. You will be prompted to re-enter your password and sign in.

Step 4 – Delete Your Gmail Account

  1. Before you proceed, you will receive a final warning on what deleting your account entails.
  2. If you are ready to continue, click on Delete Account.

Step 5 – Open up your new account

There will be a message instructing you to open an email that was sent to your new primary email address. At the bottom of the memo, click the “OK, Got it” button.

Click ➨➨➨ slot yang gampang menang

Step 6 – Confirm your status

You will receive a confirmation email. Check the details and click on the confirmation link. A page will open asking if you want to confirm that you want to delete your Gmail account.

Enter your password and click “Confirm.” Finally, you will receive a confirmation message that your account has been deleted.

It takes some time and a bunch of pages to click through, but deleting your Gmail account isn’t difficult at all.

Categories
Articles Programming Tutorials

9 Easy Ways to Hide Your IP Address in 2022 (Some Are Free)

There are lots of reasons to hide your IP address, from getting discounts on plane tickets to accessing content that’s not available in your region. It allows you to unlock different countries’ Netflix libraries and use platforms like Hulu and BBC iPlayer, which are blocked in many parts of the world.

It’s also a great way to protect your privacy and keep your personal information from falling into the hands of advertisers, hackers, and other third parties.

The best way to hide your IP address is to use a VPN. My all-time favorite is VPN, as it’s the fastest service and has over 3,000 servers in 90 different countries, giving you 300,000+ IP addresses to choose from. It also offers a 30-day money-back guarantee so you can try it risk-free!

Quick Guide: How to Hide Your IP Address With a VPN

  1. Choose a VPN – ideally VPN, which is super fast and secure – and install it on your device.
  2. Pick a server in the country where you want to connect.
  3. Your IP is now hidden. Start browsing and streaming anonymously!

What Is an IP Address?

An or IP (Internet Protocol) address is a unique string of numbers and decimals used to identify every device that connects to the internet. Each device that’s connected to a computer network has its own, unique IP address. But if you have multiple devices connected through one WiFi router, their IP addresses are the same.

When you visit a website, your device sends out a request to the website’s server using the website’s IP address. The request comes back with the information you requested using your own IP address.

There are two types of IP addresses. IPv4 (Internet Protocol version 4) addresses consist of four two- or three-digit numbers separated by periods (123.45.67.89, for example). IPv6 (Internet Protocol version 6) addresses are much longer and include both letters and numbers separated by colons.

IPv6 is being deployed because the number of available IPv4 addresses is running out. It also has more efficient routing and data flow than IPv4, and improved security. But most of the world still uses IPv4, and switching to IPv6 isn’t an easy process.

If you do want to change to IPv6, your ISP, router, and operating system all have to be compatible with it. Unfortunately, most internet service providers don’t support IPv6 yet.

If you want to see your own IP address right now, you can easily do so with our IP checking tool. I used it to check my IP address with and without a VPN:

Your IP address isn’t randomly assigned. A nonprofit organization called the Internet Assigned Numbers Authority creates IP addresses and gives them to the world’s five regional internet registries (RIRs), which then give IP addresses to internet service providers in their region.

This means that your IP address can be used to identify your location.

Since your computer and other devices need an IP address to access information online, there’s no way to avoid using an IP address altogether. The only way to hide your real IP address is to mask it with a different one.

Why Hide My IP Address?

Handing out your real IP address to every website you visit can threaten your privacy and anonymity online.

This is because your IP address can easily be used to figure out your location – sometimes with a scary level of accuracy. Hiding your IP address keeps this from happening. It’s especially important if you’re going to torrent or do any other activity that falls in a legal gray area.

But even if you’re just browsing, revealing your location has consequences. Websites and third-party advertisers can use this data to target you with specific content, in order to profit from your online activity.

For example, airlines and travel companies change their prices based on the location of your IP address. You might be shocked by how much plane ticket prices can vary because of this.

Another reason to hide your IP address is to bypass the restrictions of websites, service providers, government agencies, workplaces, and even schools. One common example is Netflix, which uses your IP address to determine the content you’re able to watch.

If you don’t hide your IP address, you’ll only be able to see the Netflix library for your actual location. But if you want to get around regional restrictions and access content from all over the world, hiding your IP address will do the trick.

Get a New IP Address Now

9 Ways to Hide Your IP Address

1. Use a VPN – The Fastest, Easiest, and Safest Option

This is the best and most reliable way to hide your IP address. All you have to do is pick one of the top VPN services, download it, and then choose which country you want to connect through. The VPN will assign you a virtual IP address associated with that country, effectively hiding your real location.

One of the biggest advantages of using a VPN is fast connection speed. Unlike with other methods, you won’t have to worry about super slow browsing, streaming, or downloading.

This is particularly important if you want to stream content on Netflix or other platforms. These sites are very good at detecting when users are trying to bypass their restrictions, and won’t hesitate to block you. But the best VPNs can easily get around even the strictest geoblocks.

VPNs are also the safest way to torrent. In addition to hiding your IP address and protecting your identity, some VPN providers offer dedicated torrenting and P2P profiles.

VPNs are incredibly safe in general, as long as you choose a reputable service that uses advanced encryption and security profiles, such as VPN. This keeps your real IP address from being leaked.

The best VPNs on the market require you to pay a subscription fee, but they’re absolutely worth it. Although there are some decent free VPNs available, they are very limited and will usually give you a slow connection and only a small amount of bandwidth and data transfer. Some free VPNs can even put you at risk of data theft, malware attacks, and other security threats.

In my opinion, investing in a premium VPN like the ones listed below is essential; a few extra bucks per month is a small price to pay when it comes to protecting your privacy. My recommended VPNs offer money-back guarantees, so you can test out their service risk-free.

The Best VPNs to Hide Your IP Address

1. VPN

VPN has thousands of servers around the world and boasts incredible speeds. When we tested VPN, we found that it’s especially good at accessing platforms that don’t support VPNs, which means you can use it to watch content on Netflix, Hulu, BBC iPlayer, and more.

VPN also supports P2P connections on all servers, making torrenting a breeze. Its advanced security features include TrustedServer technology, DNS leak protection, and more. You can try VPN risk-free before you decide. It offers a 30-day money-back guarantee, so you can ask for a refund if you’re not happy with it.

2. CyberGhost

CyberGhost is an incredibly stable and secure service, with over 7,670 servers around the world. It’s super easy to set up, allowing you to connect in a matter of seconds. Our speed tests show that it’s not as fast as VPN, but its speeds are sufficient to stream in HD.

It’s also very affordable, but lower prices don’t mean less security; it has advanced encryption, zero logging, leak-proof apps, and an extra kill switch. One thing that sets CyberGhost apart is its 45-day money-back guarantee, which is much longer than most competitors’ offers.

January 2022 Deal: CyberGhost is currently offering 84% off its most popular plan! Take advantage of this offer now and save more on your CyberGhost subscription.

2. Proxy – Slow and Not Safe for Torrenting

Proxies are commonly used to access geoblocked content. Let’s say you want to view something that’s only available in a certain country. Your computer sends a request to the website to view it, but the proxy intercepts the request and resends it using an IP address from that country. When the proxy server gains access, it sends it back to you — et voilà.

There are several downsides to proxies: they’re super slow and not very secure, as they don’t encrypt your traffic like VPNs do. They also don’t work well for torrenting, since they won’t hide all your activity from your ISP. And many popular sites, like Hulu, can easily tell when you’re using a proxy and block your access.

3. Tor – Mask Your IP for Free (Not for Streaming or Torrenting)

If you want to stay completely anonymous online without paying a cent, Tor is a solid solution. It consists of a large network of volunteer-operated servers around the world. When you use Tor, your traffic is routed through several of these servers and encrypted various times, making it nearly impossible for anyone to trace it back to your IP address.

However, all of that encryption and decryption makes Tor incredibly slow, so it’s not useful for streaming or downloading – and its developers advise against using it to torrent. If you just want to browse, you can use Tor Browser or download the Firefox extension. However, for the highest possible level of privacy, I recommend using Tor in combination with a VPN.

4. Public WiFi – A Risky Last Resort

Your IP address is assigned to you by your internet service provider, so if you connect to the internet through a different network, you’ll be assigned a new one. If you need to quickly and temporarily change your IP address, you can go to a café or other spot with public WiFi. Since it’s a shared connection, your activity can’t be traced back to you.

That said, public WiFi makes you vulnerable to hackers, malware, and all kinds of other security threats. I always suggest using a VPN when connected to public WiFi anyway. Plus, public WiFi won’t help you bypass geoblocks – so it’s more of a quick fix than a long-term solution.

5. Use Your Mobile Network – A Temporary Solution

If you don’t have easy access to a public WiFi connection – or prefer not to subject yourself to all of the risks it involves – you can also temporarily change your IP address by using data on your mobile device instead of WiFi.

The main downside of this method is that it can get expensive, especially if you want to stream or download a lot of content. Again, it’s far from a permanent solution, and I only recommend it if you think your regular IP address has been compromised. If that’s the case, using your mobile network is an easy way to immediately get a new IP address.

6. Unplug Your Modem – Reset Your IP Address

This may sound silly, but sometimes unplugging your modem for a while can actually change your IP address. When you disconnect from your ISP, the link with your current IP address is deleted – but only if your ISP uses dynamic IP addresses (which is likely).

Leave the modem unplugged for as long as you can stand, as this increases the chance that your IP address will be changed. When you plug it back in, you should receive a brand new one. However, this isn’t the most reliable method, so it shouldn’t be your first choice.

7. Renew Your IP address – Follow These Steps

I mentioned above that your main IP address is publicly visible, but if you’re using WiFi or an ethernet cable, you also have a private IP address. This method only works for replacing the private one, not the public one.

If you want to get a new private IP address, all you have to do is enter some commands on your computer.

On MacOS:

  1. From the Apple menu, open System Preferences.
  2. Open Network settings.
  3. Click on the network you’re using.
  4. Click “Advanced…”.
  5. Choose the TCP/IP tab.
  6. Click “Renew DHCP Lease.”

On Windows:

  1. Search for Command Prompt.
  2. Right click on it, then select “Run as administrator.”
  3. Type in ipconfig /release.
  4. Type in ipconfig /renew.

After following these steps, your device should have a new private IP address.

8. Use a NAT Firewall – Hide Your Private IP Address

Like the previous method, this option only applies to your private IP address. A NAT (Network Address Translation) firewall lets different devices keep their private IP addresses hidden by using the same public IP address. In other words, multiple devices that are connected to the same router can share a public IP address.

The main benefit of NAT is that it protects you from receiving unrequested communications from unknown internet users, which may be malicious. But it doesn’t hide your device’s public IP address, which is what matters most when it comes to online privacy. As I said before, the best way to do that is with a VPN.

9. Get Your ISP to Change It for You – Ask Nicely

Since your internet service provider assigns your IP address, you can simply ask them to change it. You’ll need to contact them directly and provide your account information. This is a fairly straightforward way to change your IP address, but it won’t solve any problems related to geoblocks or security, like a VPN would.

Don’t forget that if your ISP uses dynamic IP addresses, it will change again at some point in the future. If you want it to stay the same, you can ask for a static IP address – but this usually costs extra and requires additional effort.

How to Check Your IP Address

Once you’ve used a VPN or another method to hide your IP address, it’s important to check that it’s working. You should do this right after hiding it, and then periodically for as long as you need it to stay hidden. This will help you detect any errors that could compromise your privacy.

Our IP checking tool is the simplest way to ensure that your IP address is completely hidden. It will automatically display your IP address and the geolocation associated with it.

If your IP address has been hidden correctly, our tool will display the IP address and location of the VPN or proxy server you’re connected to. If not, it will display your own IP address and physical location – letting you know that something has gone wrong.

FAQ

What else can a VPN do?

In addition to hiding your IP address, the best VPNs allow you to access geoblocked content from all over the world. It can also get you past online restrictions put in place by service providers game slot gacor terbaru 2022, government agencies, or other entities. Finally, it’s the best way to hide your identity and internet activity if you want to maximize your privacy and keep your data safe.

To learn more about what a VPN can do, read our beginner’s guide to VPNs.

How can I see my IP address?

The easiest way to see your IP address is by using our IP checking tool. All you have to do is click the link in the previous sentence, and you’ll see your IP address, browser, country, and city at the top of the page.

Can my IP address reveal my identity?

Technically, your IP address alone cannot reveal your identity. However, when combined with other easily accessible information like usernames, browsing activity, and the physical location associated with it, people can use your IP address to figure out who you are. This is why if you value your privacy, you should use a trustworthy VPN, like VPN, to hide your IP address.

Why would I need to hide my IP address?

There are lots of reasons why you might need to hide your IP address, but the most common ones are to bypass geoblocks to access online content (such as streaming sites like Netflix) and to protect your privacy online. Beyond that, if you’re traveling to a country with strict internet censorship (like China), a VPN is vital in order to stay connected and safe.

How can I hide my IP address for free?

There are a few ways to avoid paying to hide your IP address. You could use the Tor network, which is totally free – but also infamous for slow connection speeds. Or you could use a free VPN, but I don’t recommend this for security reasons.

Instead, I suggest downloading a premium VPN like VPN. If you’re not happy with it, you have 30 days to ask for your money back.

What is IP masking?

IP masking is just another term for hiding your IP address. Essentially, it means that you’re covering up your actual IP address with a different one from another server somewhere else in the world. This is the only way to use the internet without revealing your IP address.

The best way to mask your IP address is with a VPN, which makes it impossible for anyone to identify your location or identity based on your online activity.

Can I use a free VPN to hide my IP address?

Yes, there are some free VPNs that will allow you to hide your IP address. However, I don’t recommend using these services, as their lack of advanced security can make you incredibly vulnerable online.

If you really don’t want to pay, use a premium VPN’s money-back guarantee to try the service for a month, then cancel for a full refund. CyberGhost’s 45-day guarantee period is one of the longest on the market.

Is it illegal to hide my IP address?

No, it’s not illegal to hide your IP address – or to use a VPN to do so. Even in countries like China, where VPNs are strictly regulated, it’s not technically against the law to use one. Although some people may think that hiding your IP address is a sign that you’re doing something shady online, there are plenty of legitimate and totally legal reasons for it.

Is an IP address permanent?

Most IP addresses are dynamic, which means they’re not permanent. Some IP addresses are static, meaning they never change, but it takes extra effort and money to request a static IP address.

It’s important to remember that even if you have a static IP address, it does not move with you; if you switch to a different internet connection, you’ll have a different IP address.

Is there a way to hide my IP address from my ISP?

No, there is no way to hide your IP address from your internet service provider. Even when you use a VPN, your IP address is still being used to communicate with the VPN server. However, a VPN keeps your ISP from seeing what you’re doing online, while hiding your IP address from the apps and websites you’re using – so no one can see the whole picture.

What’s the difference between IPv4 and IPv6?

IPv4 and IPv6 are two different types of IP addresses. IPv4 addresses are more common and less complex, consisting of a string of numbers and periods. IPv6 addresses are much longer, and include both letters and numbers separated by colons. IPv6 is currently being deployed to provide more IP addresses and to resolve some issues associated with IPv4.

Categories
Programming

Different Types of Pointers in C

Introduction

If you are aiming at a career in programming, pointers are a must-know. Pointers allow programmers to refer to (and manipulate) data in computer memory that is not stored in the current location.

A pointer is an abstraction of a physical address in memory. A pointer variable holds the address or location of another variable.

Different Types of Pointers in C

C is among the most popular and widely used general-purpose programming language. It is probably the oldest programming language that is still in use. Moreover, C climbed to the number one position in the TIOBE index in 2021 suppressing every other major programming language such as Java, Python, and Java.

Created in 1972, C has held a prominent place in the programming community. It has influenced many major programming languages. Though modern programming languages have many advanced features, many of them come from C. One of these important features of the C language is pointers. In this article before Slot Gacor 2021, we will focus on the type of pointers in C but first will discuss pointers briefly.

Pointers in C Programming

A pointer in the C programming language is defined as a variable that stores the address of another variable. By address, it means the direct memory location of the variable.

A pointer is declared just like any other variable in C. The only difference is that a pointer name has an asterisk (*) in front of it. Observe the following.

“`
int *pt1;
float *pt2;
double *pt3;
“`
Note: It is mandatory to assign an asterisk symbol.

Working with a pointer is simple. First, we define a pointer variable, then we assign a value to it, and finally access the value using an asterisk (*) symbol or address without the asterisk (*) symbol.

Type of pointers in C

C has eight types of pointers. Each varies in terms of value and behavior. Let’s discuss each of them one by one with the help of examples.

Null pointer

The null pointer is the simplest and one of the commonly used pointers in C. As the name of the pointer implies, the pointer having a Null value is known as a Null pointer.

Basically, a Null pointer has 0 as its value. Such pointers are useful when we do not want to assign any address to a variable. Observe the following C code.

“`
#include <stdlib.h>
#include <stdio.h>

int main(){
// creating a NULL pointer
int *pt1 = NULL;
}
“`

Dangling pointer

Memory allocation is not permanent. Sooner or later it is deleted. So if the memory, to which a pointer is pointing, is deleted, then that pointer is called a dangling pointer.

“`
#include <stdlib.h>
#include <stdio.h>
int main()
{
int *pt1 = (int *)malloc(sizeof(int));

free(pt1); // this will turn the pointer *pt1 into a dangling pointer
}
“`

Void pointer

Pointers, usually, have a data type associated with them. But if we want to define a pointer without any data type, we can do it by creating a void pointer.

A void pointer, as the name suggests, is a pointer created using the void keyword.

“`
#include <stdlib.h>
#include <stdio.h>
int main()
{
// void pointer
void *pt1 = NULL;
}
“`

Wild pointer

In C, it is also possible to create pointers without initializing. Such pointers are called wild pointers.

“`
#include <stdlib.h>
#include <stdio.h>
int main()
{
// wild pointer
void *pt1;
}
Note: If a wild pointer is given a value afterward, then it is no longer a wild pointer.

Complex pointers

A complex pointer is defined in a complex manner. Observe the following pointer.

“`
int *(*p[]) () );
“`
It is not like the pointers we discussed in this article. It is a complex pointer and to understand it, we need to decipher it properly. Let’s decipher it step by step.

First, start from the innermost part. It can be parentheses that have an identifier.
(*p[]) – p is an identifier here and square brackets indicate it is an array. Moreover, it has an asterisk (*) symbol in front of it. This means it is a pointer. So, we can say “p is an array of pointers”.

Note: [] and () should be given more priority than *.

Now, let’s find another () or [] near the innermost part.
(*p[]) () – Another () implies “p is an array of pointers to a function”.

After () and [], look for another *.
*(*p[]) () ) – With another * in front of the parenthesis implies “p is an array of pointers to a function returning pointers”.

When identifiers, (), [], and * are finished, look for the data type.
int *(*p[]) () ) – int implies “p is an array of pointers to a function returning pointers of int data type”.

Near, Far, and Huge pointers

Near pointer stores 16-bit addresses while far and huge pointers are capable of storing 32-bit addresses. While the near pointer can access memory only with a 16-bit segment of the machine, the other two can access outside the memory. The difference between far and huge pointers is that the segment can be modified in huge pointers but it is not possible in far pointers.

Summary

  • Pointers in C are used to store addresses of other variables.
  • A pointer is created using an asterisk symbol.
  • There are eight types of pointers in C.
  • A pointer with a NULL value is called a Null pointer.
  • A pointer pointing towards an address that is deleted is called a dangling pointer.
  • A pointer with a void data type is called a void pointer.
  • A pointer defined without initialization is called a wild pointer.
  • A pointer with a complex value is called a complex pointer.
  • Apart from these, there are three more pointers – near, far, and huge.
Categories
Programming

PyOpenGL Tutorial – Creating Graphics in Python

In this tutorial, we will be going through what is PyOpenGL? moving on we will be creating our first PyOpenGL program. Not only that you will also be guided to extend your skills using PyOpenGL for further use.

About PyOpenGL

The pyopengl library is an implementation of OpenGL for Python. It includes bindings to the GLUT library and is able to support multiple windowing systems, including X11, Windows, and Mac OS X.

Installation:

PyOpenGL is quite easy to install, Below are some of the methods that you can select according to your device’s Operating System.

Windows, Linux, and Mac:

Assuming that Python is already installed on your machine if it is not then you can walk through this Python installation guide. You can install PyOpenGL using Pip which is a Python package manager.

Open your Command Prompt and use the command

pip install PyOpenGL

Just to know We have another optimized version PyOpenGL library named “PyOpenGL-accelerate” which uses different Cython accelerator modules to speed up the process.

Use the following command to install “PyOpenGL-accelerate”.

pip install PyOpenGL-accelerate

To manually download PyOpenGL. Check out this site Situs Slot Gacor Terbaru. Just make sure to download the bit version according to the Operating System.

To avoid any unnecessary errors we also need NumPy and PIL(Python Imaging Library) because PyOpenGL programs sometimes need to work with arrays and image data.

# for Numpy
Pip install numpy
# for PIL
Pip install PIL

Getting Started:

We are going to start with the basic concepts and then move on to the complex program, in which we will animate a primitive shape.

PyOpenGL is a Python binding for OpenGL that is used to render 2D and 3D graphics. PyOpenGL is cross-platform which means it can be used on Popular OS like Windows, Mac
Linux, etc.

For this tutorial, we are going to use “glfw with PyOpenGL”. GLFW is a simple crossplatform API for PyOpenGL which is going to help us in creating the main windows, in which the graphics will be rendered

Note: use the command “pip install glfw” to install glfw on your machine.

Drawing a Triangle:

STEP 1:

import glfw
from OpenGL.GL import
import numpy as np
First, we are going to make some imports that include glfw, NumPy, and OpenGL.GL. Here “
* ” means import everything. The reason why we need NumPy in PyOpenGL because it cannot work with simple Python lists. So these lists need to be converted into NumPy arrays with a specific datatype.

Step 2:

glfw.init()
# creating a window with 800 width and 600 height
window = glfw.create_window(800,600,”PyOpenGL Triangle”, None, None)
glfw.set_window_pos(window,400,200)
glfw.make_context_current(window)

Every Painter needs a canvas to draw his/her painting similarly we need to create a window on which we are going to render 2D or 3D graphics.

● glfw.init() is used for initialization. Without initialization, we cannot access its functions.
● “glfw.create_window()” function is utilized in creating a window. This function takes in multiple arguments like “width, height, and Name of the window”.

All of the above are descriptive, no need for more explanation.

● “glfw.set_window_pos()” is used to set the position of a specific window of the device’s screen. This method requires three arguments “window name, x-axis, y-axis”.
● “glfw.make_context_current()” takes the window augment for current context.

Step3:

Here we created the vertices of our triangle in the form of a list and then convert it into a NumPy array.

vertices = [-0.5, -0.5, 0.0,
0.5, -0.5,0.0,
0.0, 0.5, 0.0]
v = np.array(vertices,dtype=np.float32)
Each of these three points in the list corresponds to the x,y,z location on a plane.

Left vertex = -0.5 , -0.5 ,0.0 (x,y,z)
Right vertex = 0.5 , -0.5, 0.0 (x,y,z)
Top vertex = 0.0, 0.5, 0.0 (x,y,z)

As our triangle is 2d, so the z-axis is 0.

Have a look at this pictorial representation of a triangle on the canvas. The center point of
the triangle is (0,0).

triangle

Next, we converted this list into a NumPy array using the numpy.array() function.

Step 4 :

glEnableClientState(GL_VERTEX_ARRAY)
glVertexPointer(3, GL_FLOAT,0,v)
# setting color for background
glClearColor(0,0,0,0
glEnableClientState() is used to enable client-side capabilities.

We have set the background color using glClearColor(0,0,0,0). Which takes in R,G,B,A as an argument.

Step 5:

while not glfw.window_should_close(window):

glfw.poll_events()
glClear(GL_COLOR_BUFFER_BIT)

glDrawArrays(GL_TRIANGLES,0,3)
glfw.swap_buffers(window)

glfw.terminate()
Next, we have created a loop that will execute until the window we created is not closed.

● glfw.poll_events() is used to check for events applied to windows.
● glClear() is going to clean the screen every time the loop runs, to ensure that there is nothing on the screen before we render graphics.
● And finally, the glDrawArrays() that is going to draw triangles.

Syntax:

glDrawArray(Mode, first, count)
Here count is the number of indices to be rendered. In our case, it is 3.

Full Code:

import glfw
from OpenGL.GL import *
import numpy as np

# initializing glfw
glfw.init()

# creating a window with 800 width and 600 height
window = glfw.create_window(800,600,”PyOpenGL Triangle”, None, None)
glfw.set_window_pos(window,400,200)
glfw.make_context_current(window)

vertices = [-0.5, -0.5, 0.0,
0.5, -0.5,0.0,
0.0, 0.5, 0.0]

v = np.array(vertices,dtype=np.float32)

# for drawing a colorless triangle
glEnableClientState(GL_VERTEX_ARRAY)
glVertexPointer(3, GL_FLOAT,0,v)

# setting color for background
glClearColor(0,0,0,0)

while not glfw.window_should_close(window):

glfw.poll_events()
glClear(GL_COLOR_BUFFER_BIT)

glDrawArrays(GL_TRIANGLES,0,3)
glfw.swap_buffers(window)

glfw.terminate()
Triangle using PyOpenGL

Adding Colors and Animation:

WE have simply added a list of Colors, converted it into a NumPy array. And then we enable the client-side using the glEnableClientState().

Next, we added an extra function glrotatef() inside the while loop for animation.

Syntax:

glrotatef(angle,x ,y ,z)

import glfw
from OpenGL.GL import *
import numpy as np

glfw.init()

window = glfw.create_window(800,600,”PyOpenGL Triangle”, None, None)
glfw.set_window_pos(window,400,200)
glfw.make_context_current(window)

vertices = [-0.5, -0.5, 0.0,
0.5, -0.5,0.0,
0.0, 0.5, 0.0]

#list of colors
colors = [1.0, 0, 0,
0, 1.0, 0,
0, 0, 1.0 ]

v = np.array(vertices,dtype=np.float32)
c = np.array(colors, dtype=np.float32)

# for drawing a colorless triangle
glEnableClientState(GL_VERTEX_ARRAY)
glVertexPointer(3, GL_FLOAT,0,v)

glEnableClientState(GL_COLOR_ARRAY)
glColorPointer(3, GL_FLOAT,0,c)

# setting color for the background

glClearColor(1,1,1,0)

while not glfw.window_should_close(window):

# the function below will keep calling until the window is not
closed

glfw.poll_events()
glClear(GL_COLOR_BUFFER_BIT)

# adding animation
glRotatef(0.1,0,1,0)
glDrawArrays(GL_TRIANGLES,0,3)
glfw.swap_buffers(window)

glfw.terminate()

Conclusion:

Till now we have covered creating a simple triangle using PyOpenGL. Next, we added another feature to the program which is going to add color and animate the triangle to rotate on the y-axis.

This tutorial is going to end here but not Your journey with PyOpenGL, I have found some amazing resources where you can expand your knowledge and explore PyOpenGL in-depth. Check these links below 👇.

Create an animated 3D cube in PyOpenGL.
Official Documentation