Monday, December 7, 2009

OpenGL Installation and Testing

In this tutorial I will show how to install and running OpenGL on your windows machine. Here I will show how to setup OpenGL on visual Studio 2008. If you are using visual studio 2005 take a look here.

OpenGL at visual studio 2005.


If you are using visual c++ 6.0 take a look here

OpenGL at visual c++ 6.0

First of all you need to collect OpenGL library from here

GLut Library

Download the latest stable version (3.7.6 currently!). Download the bin.zip file.
Unzip it. Here you get a library file, a header file and a dll file.

Put the .lib (library) file on your visual studio library folder. If you install visual studio on it's default location it will be C:\Program Files\Microsoft Visual Studio 9.0\VC\lib

At the same manner put the .h (header) in the include folder of your visual studio. It will be fine if you create a floder named 'GL' in the include folder and put the header file there. So the location like C:\Program Files\Microsoft Visual Studio 9.0\VC\include\GL

Put the .dll file on system32. Like C:\Windows\System32

Now you are ready for coding. Open your visual studio 2009. Go to the File->New->Project section. A new window comes select visual c++ -> General -> Empty Project.

Now go to the Solution Explorer. Right click on the project, select properties. From the Configuration tab select all configurations. Select Configuration properties -> Linker -> Input. Now on the left section copy "opengl32.lib glut32.lib glu32.lib" at additional dependencies. That's all.

Now Download the code

Reference and Additional Download:

1. This tutorial is prepared with help of this site.

Eooks Download Links

2. OpenGL SuperBible
3. OpenGL Programming Guide
4. OpenGL Graphics Through Application
5. Fundamentals of Computer Graphics
6. OpenGL Game Programming
7. OpenGL Game Programming -- Book Code
8. OpenGL API specification

Important Web Links

nehe.gamedev.net
lighthouse3d.com

I will try to post later how to install and configure OpenGL on Linux based platform.



Friday, October 2, 2009

আমরা কোথায় যাচ্ছি

"পৃথিবী বদলে গেছে, যা দেখি অবাক লাগে
ঢাকা শহর এমন হবে, ভেবেছ কি কখনো আগে"

উপরের এই দুটি গানের চরনের মত শুধু ঢাকা নয় সারা দুনিয়াই বদলে গেছে।এই যা একটা ভুল করলাম, পৃথিবী বদলাই নাই বদলে গেছি আমরা।গত কয়েক বছরের দিকে তাকালে কি দেখা য়ায - বন্যা,খরা,ভূমিকম্প অথবা সুনামির মত নুতন কোন মহা বিপর্যয়।আচ্ছা বলুন তো মানুষ যখন খুব রেগে যায় তখন কি করে।বিনাশের নেশা মাথায় চেপে বসে।প্রকৃতিরও এখন বিনাশের নেশা চেপে বসেছে।আমার মনে হয় যে মহা বিপর্যয় আমাদের দিকে এগিয়ে আসছে তা রোধ করা আমাদের পক্ষে সম্ভব নয়।তা হলে কি আমরা মুখে আঙ্গুল দিয়ে চুসবো।না,প্রকৃ্তিকে বাঁচাতে হবে।

-----------------
পরে আবার লিখব

Thursday, August 20, 2009

Internet Address: IPV4

The Internet is a global network which connects several hundreds and thousands of local networks. In this tutorial I will discuss about internet addressing in IPV4. There are two address methods IPV4 and IPV6. IPV4 is 32 bits (4 bytes) long and IPV6 is 128 bits long. So by using IPV4 you can have at most 2^32 or four billions public IP address. A public IP address is accessible from any part of the network. Well private IP address is accessible from the local network, where it resides. The IPV4 addressing has two different formats to represent IP address.

  1. Class full IP address
  2. Class less IP address (CIDR)


Class full IP address:

In class full addressing the IP address is partitioned in different sections with different block size. They are

  • Class 'A'
  • Class 'B'
  • Class 'C'
  • Class 'D'
  • Class 'E'

Actually class 'A','B' and 'C' are well-known to all. The first three classes are unicast address. Class 'D' is multicast and class 'E' is reserved for future use. Every class has associated IP address range.

-------------------------------------------------------------------------------------------------
Class | Start with | IP address range | Number of Blocks | Total Addresses |
-------------------------------------------------------------------------------------------------
A | 0 | 0.0.0.0. to 127.255.255.255 | 128* | 2147483648* |

-------------------------------------------------------------------------------------------------

B | 10 | 128.0.0.0 to 191.255.255.255 | 16384** | 1073741824** |

-------------------------------------------------------------------------------------------------

C | 110 | 192.0.0.0 to 223.255.255.255 | 2097152*** | 536870912*** |

-------------------------------------------------------------------------------------------------

D | 1110 | 224.0.0.0 to 239.255.255.255 | 1 | 268435456 |

-------------------------------------------------------------------------------------------------

E | 1111 | 240.0.0.0 to 255.255.255.255 | 1 | 268435456 |

-------------------------------------------------------------------------------------------------

*Actually the class 'A' has 125 blocks to use in the global internet. Three blocks are used for different purpose. The block with the starting address 10.0.0.0 to 10.255.255.255 is used for private network. That is this block of address are used in home network and the host with the private network address are not accessible from the outside of the network.

The block with the address of 127.0.0.0 to 127.255.255.255 is used as loopback address. That is to test an application on the same machine. The datagrams are not gone out the host when using loopback address. It will come back at the same machine. If you run a server on your machine and at the browser type 'http: //127.x.y.z' (x, y, z are any number from 0~255), it will show you the server default page.

The block with the address 0.0.0.0 to 0.255.255.255 is used for two different purposes. If all zero it is used as 'The host on this network'. When a host does not know its IP address it will send a datagram using the address 0.0.0.0 in its network. If DHCP or other method is established it will work with the datagram and lease a IP address to the host for specific amount of time.

**Sixteen blocks of the class 'B' address are reserved for private addressing. The blocks with the address 172.16.0.0 to 172.31.255.255 are user for this purpose.

***Two hundred fifty-six blocks are used for private addresses. The ranges are 192.168.0.0 to 192.168.255.255

Thursday, August 13, 2009

Bridge, Router, Switch, Hub and Gateway

Bridge, Router, Switch, Hub and Gateway


The Internet is an interconnection of hundreds and thousands of networks. At the bottom of this is the LAN (Local Area Network). Some computers are connected with each other to form a LAN. There are several methods to connect computers in a LAN. Ring, bus, start etc. are some of the popular form. In this tutorial I will describe some of the important concept regarding to interconnect networks (possible LAN segments).


Bridge:

A bridge is used to connect LAN segments. It works on physical layer and used to relay MAC address. The purpose of the bridge can be explained by the following example:

Suppose you have 12 computers to connect with each other. You can make a LAN segments using your computers. On a LAN the computers shares the same collection domain and the bandwidth is divided equally to all the computers. So when a computer sends a packet to another computer then if another computer tries to send at the same time collision will occur. To solve this problem, we can use Bridge. We use a bridge in our LAN to partition it into two LAN segments. Now the collision domain is partitioned into two and bandwidth increase by two. So by using multiple bridges we can increase bandwidth as well as decrease collision domain.

Bridge is IP transparent. This means that, when a host wants to send a packet to another host in the LAN segment, it will send the packet (datagram) directly to the destination host.


Another feature of bridge is that- when a host emits a packet with the broadcast address as destination bridge will forward it to the LAN segment. But router will block it (limited broadcast address will be blocked).

Router:

Router is used to connect different networks. It works on the network layer. Every router has two interfaces associated with it, an input interface and an output interface. When a datagram is received by an input interface of a router, it will see its forwarding table to which output interface it will forward.

Router is visible to IP. That is, any host wants to send datagram can't send it directly to the destination host. The datagram first sends to the router and router will responsible to route it to the correct destination host.


Switch:

Switch is also used to connect different LAN segments. Unlike bridge it has solved the problem of collision domain and bandwidth efficiently. A switch with 'N' LAN segments has 'N' different dedicated link with it. So it is possible to connect the entire host separately with the switch. The switch has the property – self learning. It has switching table which is updated automatically without and human initialization. Switch has also the advantages to connect different LAN with different link capacity. That is, if we have three LAN segments with link capacity of 10Mbps, 100Mbps and 1Gbps. We can connect them with a switch.

The self learning property has some problems too. Basically in wireless network where the wireless station (host) moves from one network to another network.


Hub:

Hub is a device which is also used to connect LAN segments. But the purpose of Hub is to re-generate (re-create) each and every bit and broadcast it to the network. The collision domain in Hub is very huge. Hub has no self learning capacity and it can't connect different LAN with different link capacity. Like switch it is auto configured without human initialization.


Gateway:

Gateway works on the upper layer on TCP/IP protocol suite. Such as, mail gateway in SMTP. It supports address mapping from one network to another, and may also provide transformation of the data between the environments to support end-to-end application connectivity.

A gateway can be said to be opaque to IP. That is, a host cannot send an IP datagram through a gateway; it can only send it to a gateway. The higher-level protocol information carried by the datagrams is then passed on by the gateway using whatever networking architecture is used on the other side of the gateway.

*** Will update periodically


Monday, July 27, 2009

DNS: How it Works

We know every thing which we access in the internet has a public ip address. That is suppose when you want to access a web site(www.gmail.com), you type it on your address bar of your browser and you find the pages. But host name is not used in the internet. Because host name may be variable of size, so storage is difficult. For this reason, we use ip based system. In this system, every host in the global internet has an ip(public or private) address. So some mechanism is needed to translate host name to it's corresponding ip address. DNS does the work.

DNS-Domain Name Service is a client-server based software approach to solve the host name to ip address translation. But DNS does more than ip translating, which I will describe in another lesson.

In the early time of the internet every computer stores a host file on it's hard disk which contains simply the mapping of host name to ip address. But when huge information have to store this system failed. So a centralized process is needed to solve the problem.

There are some (around 13) root DNS server around the world. Every root DNS server contains info in a hierarchical manner.

-> At the top level the root
-> The top level domain(.com,.org,.bd,.in etc)
-> Authoritative domain (gmail)

By this manner info is stored.

So the question is how the DNS is resolved?

Step 1: When you type the hostname(www.google.com) on your browser and hits ENTER then a DNS request message is send on the local DNS server.

Step 2: If the local DNS server has the ip address of the hostname, it will forward the ip address as a DNS response message to you. So it acts like a cash between your machine and real DNS server.

Step 3: If the local DNS server has no record regarding on the host name what you specified it calls one of the root DNS server to solve it. So the local DNS sever knows the (ip) address of the root DNS server.

Step 4: The root DNS server looks the request and sees the it has the top level domain .com. The root DNS server knows the address the .com.

Step 5: The .com finds the authoritative domain (google) and now actually we know the ip address of www.google.com.

Step 6: The ip address is backpass and at a time it will come to the local DNS server. The local DNS server stores a copy of it and forwards it to you.

Step 7: Now you see the web page www.google.com. All the works are done in fraction of seconds.

Look at the picture for better understanding

Saturday, July 25, 2009

Computer Network Term: Hub and Switch

Hub
Hub is a transparent device. If you have several computers and which you want to connect you can use a hub. There are many versions of hub. They may be 4 ports as well as much more ports then 4. Basically hub has some inherent problems. First of all, if you connect 10 computers with hub then if a packet comes from internet to your hub it will just re-generate the bits of the packet and send it to all (10 computers). So it has large traffic domain. Hub does not contains any mechanism of forwarding or hub table on it.

Switch
Switch is a device which can solve much of the problems of the hub. It has different traffic domain. The most important issue regarding switch that it makes a dedicated path between switch and the connecting computer. And at the same time you can use different bandwidth wires (standard ethernet, fast ethernet, gigabyte ethernet) with switch.

Friday, April 24, 2009

ATmega32 Tutorial in C - Part I

Recently I have worked with ATmega32. I am using avr-gcc library(C program) to program ATmega32. When I first start to work I can't find good source or link to learn. So I have taken decision to write something about it.

First off all you need some softwares and hardwares to start.

1. C compiler(AVRGCC)
2. AVR Studio
3. Proteus --- For circuit simulation

Proteus is not necessary. But if you want to check your design before making the hardware you can use this tool to simulate your circuit before burning.

4. ATmega32/ATmega32L
5. Some Leds(unipolar,bipolar)
6. Resistors(470 ohms)
7. Breadboard
8. Switch(Toggle switch)

So after collecting all of them it is now time to start work. At first you have to know details about ATmega32/L. So collect the data sheet of it and read first four or five pages. That's enough for now.



First of all some description of the ATmega32 IC. ATmega32 is a 40 pin package. It has 32KB of programmable memory. That is you can load a hex file maximum of 32 KB on your IC. For both hobbies and professional this is enough. It has four ports for input and output. Namely PORTA,PORTB,PORTC and PORTD. Every port has 8 pins for I/O. All the ports are capable of both input and output. That is you can use a port for both input and output.

Software Installation:

1. Install avr-gcc
2. Install avr studio

After installing the softwares, open avr studio. Select new project, select avr-gcc as your compiler, select avr simulator and the appropriate version of ATmega(for this tutorial it is ATmega32). That's all.

It's the end of the first tutorial. In the next tutorial we dive into programming part.

Download Link:


AVR-GCC Compiler

AVR Studio 4

All the next tutorial will be found at the following link
ATmega32 Tutorial

Friday, January 2, 2009

নুতন বছর - পুরানো কথা

দেখতে দেখতে একটি বছর কেটে গেল। আমি অনেকটা নিজেকে ব্লগ লেখা থেকে বিরত রেখেছি। আসলে আমার কোন কাজ বেশি দিন করতে ভাল লাগে না। তো ২০০৮ সালে আমার জন্য তেমন মহিমার না হলেও বাংলাদেশের জন্য ছিল অনেক important. নির্বাচন,সরকার পরিবর্তন ইত্যাদি অনেকের মত আমার কাছেও important.

---- চলবে

Saturday, September 27, 2008

অন্ধকার

আলোকের পথে তোমাদের যাত্রা বিলম্বিত হোক
নিকষ কালো অন্ধকার তোমাদের চারপাশ থেকে গ্রাস করুক।
অমাবস্যার রাতে ঝিঁঝিঁ পোকার ডাকে তোমাদের গা ছমছম করে উঠুক
আলোকের পথে তোমাদের যাত্রা বিলম্বিত হোক।

বিবর্তনের পথে পথে অন্ধকারের ছোপ-ছোপ দাগ লেগে থাকুক।
শীতল চাঁদর গায়ে তোমাকে হাঁটতে হবে বার্ধ্যকের দাড়ে

Saturday, August 9, 2008

An introduction to USB

In 1994, an alliance of four industrial partners (Compaq, Intel, Microsoft, and NEC) started specifying the USB protocol. The original goal of the protocol was to connect the PC to the telephone and to provide I/O interfaces that were easy to expand and reconfigure. In January 1996, the first version of the USB specification was released, and a subsequent revision (version 1.1) was released in September 1998. The specification allowed 127 devices to be connected together at the same time, with the total communication bandwidth limited to 12 Mbps. Later on, three more members (Hewlett-Packard, Lucent, and Philips) joined the alliance. In April 2000, version 2.0 of the USB specification, which supports transfer rates up to 480 Mbps, was released. Today, USB plays a key role in high-speed (video, imaging, storage) and full-speed (audio, broadband, microphone) data-transfer applications. It also connects a variety of low-speed devices (keyboards, mice, game peripherals, virtual reality peripherals) to the PC.

The USB protocol is strictly hierarchical. In any USB system there is only a single host, and the USB interface to the host computer is referred to as the host controller. There are two standards for host controllers -- the Open Host Controller Interface (OHCI, by Compaq) and the Universal Host Controller Interface (UHCI, by Intel). Both standards provide the same capabilities and work with all USB devices; the hardware implementation of a UHCI is simpler, but requires a more complex device driver (and thus puts more load onto the CPU).

The USB physical interconnect is a tiered star topology, with up to seven tiers. A hub is at the center of each star, and the USB host is considered the root hub. Each wired segment is a point-to-point connection between a hub and USB device; the latter can be either another hub that provides additional attachment points to the system, or a device of some sort that provides functional capabilities. The host uses a master/subordinate protocol to communicate with the USB devices. This approach solves the problem of packet collision but also prevents the attached devices from establishing direct communication with each other.

All the data transfers are initiated by the host controller. Data directed from the host to a device is called downstream or out transfer; data directed from a device to the host is called upstream or in transfer. Data transfer occurs between the host and a particular endpoint on the USB device, and the data link between the host and the endpoint is called a pipe. A given USB device may have many endpoints, and the number of data pipes between the host and the device is the same as the number of endpoints on the device. A pipe may be uni-directional or bi-directional, and the data flow in one pipe is independent of the data flow in any other pipes.

Communication on the USB network can use any one of four different data transfer types:

* Control transfers: These are short data packets for device control and configuration, particularly at attach time.
* Bulk transfers: These are data packets in relatively large quantities. Devices like scanners or SCSI adapters use this transfer type.
* Interrupt transfers: These are data packets that are polled periodically. The host controller will automatically post an interrupt at a specified interval.
* Isochronous transfers: These are data streams in real time with higher requirements for bandwidth than for reliability. Audio and video devices generally use this transfer type.

Like a serial port, each USB port on a computer is assigned a unique identification number (port ID) by the USB controller. When a USB device is attached to a USB port, this unique port ID is assigned to the device and the device descriptor is read by the USB controller The device descriptor includes information that applies globally to the device, as well as information on the configuration of the device. A configuration defines the functionality and I/O behavior of a USB device. A USB device may have one or more configurations, which are described by their corresponding configuration descriptors. Each configuration has one or more interfaces, which can be considered as a physical communication channel; each interface has zero or more endpoints, which can be either data providers or data consumers, or both. Interfaces are described by interface descriptors, and endpoints are described by end-point descriptors. Furthermore, a USB device might also have string descriptors to provide additional information such as vendor name, device name, or serial numbers.

Post Source


http://www.ibm.com/developerworks/linux/library/j-usb.html