TwitterFacebook

Working with GLFW library under Fedora.

Today I will try to use GLFW library.

GLFW is a C library that lets you using an OpenGL context and window, display modes and inputs like keyboard, mouse, joystick and time.

GLFW supports Windows, Mac OS X and Unix, Linux and FreeBSD and any operating systems with the X Window System.

Also you can read more about this library here.

First install the library using root account.

# yum install libglfw-devel.i386

Now let’s see the source code.

First I includes all librarys I need.

/* 
 * File:   main.cpp
 * Author: free-tutorials.org
 *
 * Created on May 15, 2013, 2:54 PM
 */

#include <cstdlib>
// my c++ include headers 
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glfw.h>
using namespace std;

In the main function I start to see if the library is working.

int main() {
if( !glfwInit() )
{
    fprintf( stderr, "Failed to initialize GLFW Init \n" );
    return -1;
}

The next step is to set some settings, see:

// 4x antialiasing because I use NVIDIA FX5500
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); 

… and also testing the desktop settings.

// get infos about desktop 
GLFWvidmode desktop;
glfwGetDesktopMode( &#038;desktop );

The settings it’s show on console with cout function.

// show infos about your desktop
cout << "Width : " << desktop.Width << "\n";
cout << "Height : " << desktop.Height << "\n";
cout << "RedBits : " << desktop.RedBits << "\n";
cout << "GreenBits : " << desktop.GreenBits << "\n";
cout << "BlueBits : " << desktop.BlueBits << "\n";

Now I make the window context using fullscreen option.

if ( !glfwOpenWindow(
    desktop.Width,
    desktop.Height,
    desktop.RedBits,
    desktop.GreenBits,
    desktop.BlueBits,
    32,          // alpha bits
    32,         // depth bits
    0,          // stencil bits
    GLFW_FULLSCREEN
) ) {
    // error if failed 
}

I set the title of the window.

glfwSetWindowTitle( "opengl-shader test" );

I enable the keys.

glfwEnable( GLFW_STICKY_KEYS );

do{
    // draw something sexy 
 
    // Swap buffers need it 
    glfwSwapBuffers();
 
}

The next source code it’s close the window.

// When ESC key was pressed or the window was closed
while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &#038;&#038;
glfwGetWindowParam( GLFW_OPENED ) );

}

Testing with time command to see how fast working.

$ time ./opengl-shader 
Width : 1280
Height : 1024
RedBits : 8
GreenBits : 8
BlueBits : 8

real	0m2.358s
user	0m0.341s
sys	0m1.240s

The netbeans IDE make the package in this path.

$cd /opengl-shader/dist/Debug/GNU-Linux-x86/package

I make RPM package for Fedora distro.

# rpm -ivh opengl-shader-1.0-1.i386.rpm 
Preparing...                ########################################### [100%]
   1:opengl-shader          ########################################### [100%]

I test my example and working well.

NASA migrates from Windows to Linux

According to article wrote by Lawrence Latif , N.A.S.A. will replace the Windows XP with Linux :

THE INTERNATIONAL SPACE STATION (ISS) will remove Microsoft Windows from its onboard laptops and run Linux exclusively.

The main reason can be :

…NASA has been using Linux on its missions for some time, including on its Mars Curosity rover, suggesting that the delay in shifting over to Linux on ISS was more to do with porting legacy applications from Windows.
Read more about this

The new AIDE version 2.0 released.

AIDE Android
New

  • Support building native apps with C/C++
  • Quick preview of Xml layout designs
  • Swipe between open files and between tool windows
  • Editor tabs for open files (optional)
  • Line numbers in the editor
  • Git create, merge, delete branch
  • Create Git repository for new project

Improved:

  • Auto import for nested classes (OnClickListener)
  • Code completion in Xml layout files
  • App template includes the Android support library
  • Holo look and feel

The new Blender 3D version 2.67 released.

The Blender Foundation and online developer community is proud to present Blender 2.67. New in this release is the Freestyle render engine for non-photorealistic rendering, which can generate 2D line drawings in various styles.

You can download the new Blender 3D from here.

Using grep and many commands under Android OS .

The BusyBox combines tiny versions of many common UNIX utilities into a single executable.

You can find this command under android os.

Using busybox is simple. The first argument is taken by busybox and it’s applet executable.

For example if you want run dmesg with grep command then use this:

$ dmesg | busybox grep 'mac'

All applets include:


        [, [[, acpid, addgroup, adduser, adjtimex, ar, arp, arping, ash,
        awk, basename, beep, blkid, brctl, bunzip2, bzcat, bzip2, cal, cat,
        catv, chat, chattr, chgrp, chmod, chown, chpasswd, chpst, chroot,
        chrt, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab,
        cryptpw, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod,
        devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname,
        dos2unix, dpkg, du, dumpkmap, dumpleases, echo, ed, egrep, eject,
        env, envdir, envuidgid, expand, expr, fakeidentd, false, fbset,
        fbsplash, fdflush, fdformat, fdisk, fgrep, find, findfs, flash_lock,
        flash_unlock, fold, free, freeramdisk, fsck, fsck.minix, fsync,
        ftpd, ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip, hd,
        hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock, id,
        ifconfig, ifdown, ifenslave, ifplugd, ifup, inetd, init, inotifyd,
        insmod, install, ionice, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink,
        iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5, klogd,
        last, length, less, linux32, linux64, linuxrc, ln, loadfont,
        loadkmap, logger, login, logname, logread, losetup, lpd, lpq, lpr,
        ls, lsattr, lsmod, lzmacat, lzop, lzopcat, makemime, man, md5sum,
        mdev, mesg, microcom, mkdir, mkdosfs, mkfifo, mkfs.minix, mkfs.vfat,
        mknod, mkpasswd, mkswap, mktemp, modprobe, more, mount, mountpoint,
        mt, mv, nameif, nc, netstat, nice, nmeter, nohup, nslookup, od,
        openvt, passwd, patch, pgrep, pidof, ping, ping6, pipe_progress,
        pivot_root, pkill, popmaildir, printenv, printf, ps, pscan, pwd,
        raidautorun, rdate, rdev, readlink, readprofile, realpath,
        reformime, renice, reset, resize, rm, rmdir, rmmod, route, rpm,
        rpm2cpio, rtcwake, run-parts, runlevel, runsv, runsvdir, rx, script,
        scriptreplay, sed, sendmail, seq, setarch, setconsole, setfont,
        setkeycodes, setlogcons, setsid, setuidgid, sh, sha1sum, sha256sum,
        sha512sum, showkey, slattach, sleep, softlimit, sort, split,
        start-stop-daemon, stat, strings, stty, su, sulogin, sum, sv,
        svlogd, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac,
        tail, tar, taskset, tcpsvd, tee, telnet, telnetd, test, tftp, tftpd,
        time, timeout, top, touch, tr, traceroute, true, tty, ttysize,
        udhcpc, udhcpd, udpsvd, umount, uname, uncompress, unexpand, uniq,
        unix2dos, unlzma, unlzop, unzip, uptime, usleep, uudecode, uuencode,
        vconfig, vi, vlock, volname, watch, watchdog, wc, wget, which, who,
        whoami, xargs, yes, zcat, zcip

You can read more about this here.