Saturday, July 2, 2011

Creating and Using C++ shared libraries using g++

It's been an eventful couple of months. I worked my first 90+ hour week, will be moving for a second time, and learned a heck of a lot about C++.
In this post, I will explain in simplified terms, how to create your own C++ shared Library.

It took me a couple hours to figure it out. It's not exactly straightforward, but neither is it overly complex.

I assume that you, the reader, have experience writing C++ classes and headers. 


Step 1: Create your library

Before you go and build a gigantic, powerful library, it is better to create something simple to start, then build upon it. I used a header file in addition to my c++ class file.
I'd recommend writing a simple class with just a constructor, deconstructor, and a method that outputs something like "Hello World" using cout.

Libraries do NOT contain a main() method.

Step 2: Compile your library

The following code will compile your .cpp file as a shared library. Replace the file names and library names with your own.
Be sure to name your library lib[name].so.
It needs the lib prefix and .so suffix. If you have multiple version of your library, the suffix can be .so.1, .so.1.0, .so.1.0.5, etc. as long as one with .so exists.
 g++ -Wall -shared -fPIC -o ~/libs/libmylibrary.so libmylibrary.cpp

The format goes like this: g++ [options] [library placement on filesystem] [file(s) that make up library] 

I also had a ~/libs/ folder created so I could compile and install as user. If you want system-wide access, run the command as root and use "-o /usr/local/lib/libfilename.so".


Step 3: Test your library

Now the fun part:
Create a test file (test.cpp) with just a main() method.

You will have to include the library in the file like so:
#include "libmylibrary.h"

If you are using a namespace in your library, be sure to use it or prefix any methods or constructors with it.

In your main() method, create an instance of the object, call its method(s), and delete it at the end. An example would be so:


ExampleObj * myobj = new ExampleObject();
myobj->printHelloWorld();
delete myobj;

Now the best part: Compiling your program and linking it to your library. Do so with this command:

g++ main.cpp -o ~/bin/libtest -L$HOME/libs -lmylibrary

A couple IMPORTANT things to note here:

  • ~/bin/ is a directory I created. You may have to change location or create the directory yourself
  • The -l command which links the library has omitted the "lib" prefix, so it is mylibrary instead of libmylibrary.
That last point is what really fooled me for a while. 

That's all for c++ libraries. I hope this helps.




Edit



You may have to add the following around the body of your header file.



This goes after the include statements, but before the namespace/class declarations


#ifdef __cplusplus
extern "C"
{
#endif






And after end of namespace/class declarations, but before final #endif tag:


#ifdef __cplusplus
}
#endif




This should fix some c++ specific issues you may encounter.

Saturday, April 30, 2011

Creating a more object-oriented OpenGL Window with Freeglut in C++

As per my previous post where I described how to build an OpenGL window, it was basically a c-to-c++ code transition with explainations of what different methods did.

In this post, I will be posting my code where the window preferences and display information is inside a class and only the main() method is not part of the object.

There are two parts to the following code: the cpp file and the header file. You need them in two separate files and in the same directory for things to compile properly without modifications.

Please feel free to rate and critique the code I post. Also, the method names and filenames are part of a project I'm working on, so feel free to change them. They make sense to me.

Also, I am licensing the following code under the GPL 2. Feel free to distribute and modify the source as you like.

rwindow.cpp

#include <stdlib.h>

#include <stdio.h>

#include <GL/glew.h>

#include <GL/freeglut.h>

#include <GL/gl.h>

#include "rwindow.h"

RWindow::RWindow()

{

str_window_title = "Hello World";

usi_hwindow = 250;

usi_vwindow = 250;

usi_windowx = 100;

usi_windowy = 100;

}

RWindow::RWindow(string newtitle)

{

str_window_title = newtitle;

usi_hwindow = 250;

usi_vwindow = 250;

usi_windowx = 100;

usi_windowy = 100;

}

void RWindow::SetWindowTitle(string newtitle)

{

str_window_title = newtitle;

}

string RWindow::GetWindowTitle() const

{

return str_window_title;

}

void RWindow::SetWindowHorizontal(unsigned short int newsize)

{

usi_hwindow = newsize;

}

unsigned short int RWindow::GetWindowHorizontal() const

{

return usi_hwindow;

}

void RWindow::SetWindowVertical(unsigned short int newsize)

{

usi_vwindow = newsize;

}

unsigned short int RWindow::GetWindowVertical() const

{

return usi_vwindow;

}

unsigned short int RWindow::GetWindowX() const

{

return usi_windowx;

}

void RWindow::SetWindowX(unsigned short int newsize)

{

usi_windowx = newsize;

}

unsigned short int RWindow::GetWindowY() const

{

return usi_windowy;

}

void RWindow::SetWindowY(unsigned short int newsize)

{

usi_windowy = newsize;

}

RWindow::~RWindow()

{

// remove new variables if any

// remove self

delete this; // Make sure pointer is null

}

void RWindow::display_contents()

{

/* clear all pixels */

glClear (GL_COLOR_BUFFER_BIT);

/* draw white polygon (rectangle) with corners at

* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)

*/

glColor3f (1.0, 1.0, 1.0);

glBegin(GL_POLYGON);

glVertex3f (0.25, 0.25, 0.0);

glVertex3f (0.75, 0.25, 0.0);

glVertex3f (0.75, 0.75, 0.0);

glVertex3f (0.45, 0.45, 0.0);

glEnd();

/* don't wait!

* start processing buffered OpenGL routines

*/

glFlush ();

};

void RWindow::init ()

{

/* select clearing (background) color */

glClearColor (0.0, 0.0, 0.0, 0.0);

/* initialize viewing values */

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(0.0, 1.0, 0.0, 1.0, 1.0, -1.0);

};

/*

* Declare initial window size, position, and display mode

* (single buffer and RGBA). Open window with "hello"

* in its title bar. Call initialization routines.

* Register callback function to display graphics.

* Enter main loop and process events.

*/

int main(int argc, char** argv)

{

// Code to initialize window. Normally this would be in another class

RWindow *testWindow = new RWindow();

glutInit(&argc, argv);

glutInitDisplayMode (GLUT_SINGLE | GLUT_RGBA);

glutInitWindowSize (testWindow->GetWindowHorizontal(), testWindow->GetWindowVertical());

glutInitWindowPosition (testWindow->GetWindowX(), testWindow->GetWindowY());

// .c_str() converts string to constant char*, which this function needs

glutCreateWindow (testWindow->GetWindowTitle().c_str());

testWindow->init ();

glutDisplayFunc(RWindow::display_contents);

glutMainLoop();

delete testWindow;

return 0; /* ISO C requires main to return int. */

};

rwindow.h

#ifndef R_WINDOW

#define R_WINDOW

#include <string>

using namespace std;

class RWindow

{

public:

RWindow();

RWindow(string);

virtual ~RWindow();

void SetWindowTitle(string);

string GetWindowTitle() const;

void SetWindowHorizontal(unsigned short int);

unsigned short int GetWindowHorizontal() const;

void SetWindowVertical(unsigned short int);

unsigned short int GetWindowVertical() const;

void SetWindowX(unsigned short int);

unsigned short int GetWindowX() const;

void SetWindowY(unsigned short int);

unsigned short int GetWindowY() const;

static void init();

static void display_contents();

private:

string str_window_title;

unsigned short int usi_hwindow;

unsigned short int usi_vwindow;

unsigned short int usi_windowx;

unsigned short int usi_windowy;

};

#endif

In order to compile type this:

g++ -Os rwindow.cpp -lGL -lglut -lX11 -lXext -o ~/example-window

Things you can expand on: adding shape-building methods and including them in display_contents(), random polygon generation, etc. etc.

More to come.

=-=-=-=-=
Powered by Blogilo

Thursday, April 28, 2011

Creating an OpenGL Window with Freeglut in C++

It seems everybody exudes the virtues of OpenGL's 3D capabilities. That's all fine and good, but what about 2D?

While searching for information on creating my own 2D hardware-accelerated platform, I came across this excellent website.

http://nehe.gamedev.net/

- See the opengl tutorials on the left-hand side.

And as always, the official OpenGL website is a great resource.

http://www.opengl.org/resources/libraries/

Making a window using Freeglut to accelerate it through OpenGL isn't too difficult.

I can't remember where I found the code I am using as an example, but the gist of it can be found here:

http://www.codeproject.com/KB/openGL/OpenGLWindowWithGLUT.aspx?display=Mobile

(Credit goes to whomever wrote it)

Differences include:

  • This probably won't run on a Windows box
  • We have to compile it manually (see below)

Alright. Onto the code.

First we have the headers. They are C headers, but Freeglut is a C++ friendly library so there shouldn't be any problems.

#include <stdlib.h>

#include <stdio.h>

#include <string.h>

#include <GL/glew.h>

#include <GL/freeglut.h>

#include <GL/gl.h>

We are importing two main categories of libraries: standard C libraries that handle input/output, library functions and strings as well as the OpenGL libraries.

using namespace std;

Use the standard namespace so you don't have to write out the path of the library functions. It makes reading the code a lot easier.

Now to include a method that will display a static something in the window when we get to that point.

The reason we are writing this function right after the include and namespace statements is because both C and C++ (to name two of many programming languages) cannot call a method that it does not know about at compile time. If this function was at the bottom of our file and we called it at the top, it wouldn't know that function existed yet so it would fail.

void display(void)

{

/* clear all pixels */

glClear (GL_COLOR_BUFFER_BIT);

/* draw white polygon (rectangle) with corners at

* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)

*/

glColor3f (1.0, 1.0, 1.0);

glBegin(GL_POLYGON);

glVertex3f (0.25, 0.25, 0.0);

glVertex3f (0.75, 0.25, 0.0);

glVertex3f (0.75, 0.75, 0.0);

glVertex3f (0.25, 0.75, 0.0);

glEnd();

/* don't wait!

* start processing buffered OpenGL routines

*/

glFlush ();

}

The statements are fairly self-explainatory here. glClear clears the window of previous drawings, sets a colour (white), creates a polygon (in this case, a square/rectangle), sets the points and then completes the shape, It then calls the glFlush so that all images that have been declared (have a Begin/End) get displayed.

The reason for having a flush statement is because a) it is faster to store a bunch of shapes in memory and display them after a period of time (aka a flush of the video buffer) than it is to display each and every object right after it gets created, plus b) it makes predicting and controlling frame rates a LOT easier. There are lots of reasons I'm probably not getting to, but it is important.

You could put the flush statement in the main loop after the display() method, but that would be if you want animations or are doing game design, and I recommend keeping the main loop as clean as possible. Plus it would make conditions a lot easier to write. Sometimes the flush() method is skipped because the hardware cannot keep up with the window which causes the dropping of frames to keep framerate acceptible. It will cause 'lag', but won't slow the entire program down to a crawl.

Another point to note: the glVertex3f function. Perhaps you are thinking it should be 'glVertex3d' because we are dealing with 3d graphics libraries here. This is not the case. The '3f' part of the function stands for '3 float parameter' (3f) function. As you can see, the method as 3 values that are floats and must stay as floats. (A float is a number with decimal places, smaller than a double value) If there is no number/letter suffix to the method, it probably has just one type of input parameter.

There could be a glVertex3d method, which would take doubles. Or a glVertex3i, which takes 3 integers. As you can see, the number/letter notation is a great way to know how the method gets used. Of course, you need to know the different C types as a pre-requesite to make good use of this.

void init (void)

{

/* select clearing (background) color */

glClearColor (0.0, 0.0, 0.0, 0.0);

/* initialize viewing values */

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);

}

The init method is next. It takes no parameters itself, like the display method above. All this does is set a few values for the window we'll be creating. The window we'll be drawing will need a background colour (otherwise the background of your computer will be seen through it) and some values set.

I'm not an expert in OpenGL by any means, so when I describe the glMatrixMode() method, I could be off.

There are a few different modes that OpenGL can operate in. GL_PROJECTION mode which I'm guessing is a more 2D-oriented mode, GL_MODELVIEW which does 3D, GL_TEXTURE which applies images and other texturey things to a surface (2D or 3D) therefore requires efficient I/O operations, and GL_COLOR which works on colour algorithms such as blending, transparencies and effects than actual objects.

glOrtho is part of the GL_PROJECTION Matrix Mode. It may be 2D only. The first 4 double values determine the four points of the buffer we display. Left, Right, Bottom, Top. The next two values are near and far values, glOrtho seems to deal with inversion and clipping. The OpenGL article seems to depict that it is a matrix transformation that replaces the current matrix (or what has been written to the video buffer).

Anyway, enough math for now. It may be better to experiment with changing values than to explain it with words.

The main() method, not to be mistaken for the main loop I mentioned earlier, sets up the window.

/*

* Declare initial window size, position, and display mode

* (single buffer and RGBA). Open window with "hello"

* in its title bar. Call initialization routines.

* Register callback function to display graphics.

* Enter main loop and process events.

*/

int main(int argc, char** argv)

{

glutInit(&argc, argv);

glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);

glutInitWindowSize (250, 250);

glutInitWindowPosition (100, 100);

glutCreateWindow ("hello");

init ();

glutDisplayFunc(display);

glutMainLoop();

return 0; /* ISO C requires main to return int. */

}

The header with the 'int argc, char** argv' is a C and C++ thing for command line parameters. It could probably be void, but would leave the program with little to no options if it wanted it to run a certain way.

Here's where we use glut commands. Init glut using the method parameters GLUT_SINGLE and GLUT_RGB. These are parameters: GLUT_SINGLE should set up a single buffer for the window while GLUT_RGB allows Red/Green/Blue colour values in it. GLUT_RGBA is also a possible option and I assume includes alpha transparency too.

glutWindowSize and glutWindowPosition are self explainatory. glutCreateWindow sets the window title bar text. Size and Position on your desktop. init() sets up the internals to freeglut while glutDisplayFunc() specifies the name of the method to call for displaying things using GL syntax. glutMainLoop() is that main loop I mentioned earlier and should loop through, refreshing the display so when you move the window, it doesn't get corrupted. (Don't quote me on that though).

Return statement exists as an ISO standard. Even if the program never gets to the return statement, it's required.

So that's a window example in freeglut, opengl, and c++. Copy all the code segments into a text file, save as "filename".cpp. (change filename to something else if you wish, change it in your compile statement too though.)

To compile it, you must first have installed the freeglut libraries and opengl libraries AND have a compatible video card.

But that's not all, you must also specify the libraries in the compile statment so it will include them.

g++ -Os filename.cpp -lGL -lglut -lX11 -lXext -o ~/filename

First off, "-Os" is an optimization flag. Good options are -O1, -O2, and -Os. -Os optimizes the program for small size. Can be omitted.

-lGL and -lglut are required, the -l means include library and we are including glut and opengl. (it's not -lfreeglut because freeglut is meant as a replacement for glut, an abandonded library, so requires the same import name.)

You can omit the -lX11 and -lXext, at least, it works on my machine. It still works when I include them, so maybe it's just if you write in C.

Lastly, -o means output and the next parameter is where to put it and what the program is called using a path. ~ means home directory for Unix or GNU/Linux users.

I'm fairly new to OpenGL windows, but I hope this helps other new users to start up their development-fu for hardware accelerated applications.

If learning this low-level stuff isn't for you, check out QT and KDE application libraries. They have this stuff built in already.

Thanks for stopping by and look forward to more.

=-=-=-=-=
Powered by Blogilo

Saturday, April 23, 2011

Installing Adobe Flash "Square" on a 64-bit Linux Distribution, Firefox 4

In the past month I set myself up a beautiful pure 64-bit Gentoo system on my Thinkpad X61. It's not completely ready yet, as I have yet to compile my custom kernel that should allow the wacom screen to be recognized.

Installing 64-bit Flash "Square" should be the exact same procedure on any major GNU/Linux distribution, so there shouldn't be any specific instructions. Also, this instruction set ignores the "proper" distro way of doing things.

Ubuntu has an install-flashplayer deb that does things for the user. Which is preferrable, as the way I am about to describe does not provide automatic updates. And before we continue, I should stress that Flash Square is a PREVIEW and flash is inherantly insecure due to it being a proprietary offering and ubiquitous on the web.

This method installs flash in "userspace", or in a way that does not require admin privileges. This method reduces the consequences if your computer is comprimised through flash by not being able to touch your system.

1. Download Flash Player "Square" from Adobe's web site: http://labs.adobe.com/downloads/flashplayer10_square.html

Check under the heading "64-bit Release Flash Player Downloads" and choose what should be the last option: plugin for 64-bit linux

(I shake my head at Adobe. Flash doesn't run in the kernel; they should change it to "linux-based OS" or the proper "GNU/Linux" label)

2. Extract the .tar.gz download. This can be done via command line by typing "tar -xvf [file]".

3. Make sure that the plugins folder exists. It didn't by default for my system. "mkdir -p ~/.mozilla/plugins/"

My first attempt at this failed because I created the plugins directory in .mozilla/firefox/.

4. Copy the libflashplayer.so file to the user's plugin folder. This command should work: "cp libflashplayer* ~/.mozilla/plugins/"

If you get any errors in the previous commands, you are probably in the wrong directory when typing them, you are typing the double-quotes (don't), or you aren't in the shell/command line. As well, this is for Firefox 4. Theoretically it should work for previous versions of Firefox, but I'm a little lazy to make sure.

And if you haven't checked out Mozilla's newest browser version, you really should. Startup times alone are much improved. Having a default page already cached helps, but the option to load your previously viewed tabs on last exit is convenient.

I have been doing some introductory coding in OpenGL, Freeglut and C++/QT lately. I hope to come out with some tutorials for those as well in the near future.

=-=-=-=-=
Powered by Blogilo

Friday, February 11, 2011

Gentoo Users, QT pt 2

QT 4.6 is officially out for Gentoo's portage. It needs to be unmasked, mind you. But I've now installed it and it looks damned great.

I reinstalled Gentoo over the past week, upgrading to an ext4 filesystem along with all my applications. There is a noticable speed difference with the filesystem upgrade alone, but 4.6 also is improved.

The K3B issue I was having in the last post was solved. Until it gets a newer QT port, I probably won't install it. Plus I installed Gentoo without HAL support, so I may not even be able to use my cd/dvdrom until later. I previously mentioned the drive was having issues. At some point, it got fixed, probably through an update.

While doing this re-install, I had some trouble with my Radeon X1400 mobility card.

I couldn't use desktop effects as they were full of artifacts and my screen was off-kilter. Long story short, I installed xorg-server as opposed to xorg-x11. This installs more of xorg (fonts, etc.) that not everybody needs. I also modified my custom kernel to use pci video card support as a module, which was probably the culprit. After using this new kernel and enabling desktop effects, things run faster than they did previously on my old install.

All in all, quite impressive and great job to KDE and Gentoo teams.

On a slightly related note, it's quite upsetting to see Microsoft executives infiltrate Nokia, bring down their stock, add their retarded phone OS to the mix (which barely anybody wants), possibly comprimising QT and its development (which is probably what they want anyhow) and looking the fool.

The sooner M$ is buried under their incompetance, the better. It's a shame that they act the bully because they cannot compete in the marketplace.

They already drain resources from samsung and lg off their android phones under false pretences of patent infringement.

Quite foolish, and most disappointing, coming from an IT giant. Then again, Canada's ISP giants are also looking like the retards they are. Usage based billing my ass.

They shant get away with it.

=-=-=-=-=
Powered by Blogilo

Thursday, January 20, 2011

Gentoo Users, QT

I was recently updating my gentoo system when I came across a puzzling issue. I was getting updates for QT 4.6.x as well as 4.7.x and there were conflicts all over the place. At least 12 were listed when attempting to emerge world.

I removed all QT 4.7.x packages rather foolishly to see if the conflicts would clear up, which they didn't. After looking closely at some of the packages, it seems that K3b was bringing in all these older qt updates. I removed it from my system, but the problem still persisted. That's why I'm writing this down. I had to explicitly mask the package in order for the problem to go away.

(as root)

echo "app-cdr/k3b" >> /etc/portage/package.mask

My laptop's already not allowing me to use my cdrom very well, perhaps it's dying. I can't burn or play dvd's on it. Keeps giving me HAL errors, regardless of whether it's running. Other burners don't see the drive either.

Anyway, I'll be heading up for the Global Game Jam soon. Cheers, y'all.

Thursday, December 23, 2010

Still Alive

Finished graduating my course as of this December.

During the time I've been at school, I've also been working full time, so that leaves very little left over to work on my projects. Even less since I moved in October.

Not to worry, once I get paid I will be purchasing a domain to use strictly for gaming/programming projects, whereas this blog will probably include fixes for certain issues I face, cool ideas and things that peak my interest, as well as more anti-M$ rants... most likely. I may also get a little more political in my blog.

That last paragraph implies that I will be working more on projects, which I intend to.

I may be using sourceforge to host projects, Also, they will probably fall under the GPL 3 license.

There's a lot of cool ideas I'm holding in for now. In the meantime, I must rest.

Tuesday, October 12, 2010

Quickie bug fix

I was recently having the following issue while fiddling around with expect and spawn:

send: spawn id exp6 not open
while executing
"send "$password\r""
(file "changepw" line 9)

in a script to auto-change passwords for some work I'm doing.

The reason I encountered this error is because my file I was reading from (in the changepw plain-text file), there was no newline character at the bottom.
The fix for this is to always have a clean new line in the file that needs to be read in.

I realize I haven't done much blogging recently. There should be more to come later on, once I'm more settled.

Saturday, July 24, 2010

FFROGG - FFmpeg Recursive Ogg Encoding Script

What happens when you have thousands of songs that you want encoded, but either you

a) Have a command line system where no gui app can encode them for you?

b) Want more efficient use of your processor therefore do not use a gui?

c) are not good at computing and just want to get'r done?

This is one itch I just had to scratch. Now I'm aware of great apps like handbreak and I know amarok 1.4.x used to have a script to encode songs in a playlist. However, not only am I a big fan off ffmpeg, I needed to test out my bash-fu.

The scenario is this:

Joe user has tons of music spread out all over his hard drive. Lets say he has 10 000, none of which are contained in any one folder as more OCD folks would do. (Or an organized heirarchy of folders even)

Joe decides that one day, he wants to move to a patent-free codec such as .OGG format, but not only does he not have the time to FIND all his mp3's, he's clueless about how to encode them and knows of no gui apps (except for above mentioned in this article).

Joe user visits this article and decides that he wants all his files encoded into one folder on an external hard drive (which could be his mp3 player).

All Joe has to do is ensure that ffmpeg and libvorbis/libtheora are installed correctly on his *nix system and he can go about watching TV or playing with his dog/kids/wife while the machine does all the work.

Here's How:

1) Download the script @ [ http://www.mediafire.com/?lc023alg2bsfx9x ] to your home folder

2) Make sure it's executable, use chmod +x ffrogg.sh to do so.

3) Use the command sh ffrogg.sh --input=/home/$USER/ --output=/media/externaldisk/encoded --export --recursive (as long as your --input is linked to the top folder where your music is located, it should be fine)

4) Navigate to your output folder, in Joe User's case, it's /media/externaldisk/encoded/. There should be a script called "ffrogg-encodethis-[numbers].sh".

5) At his/your convenience, run the script. Example: sh ffrogg-encodethis-1279967631.sh

Technical Aspect:

Here's the really cool technical details of the script.

THIS SCRIPT IS CURRENTLY IN ALPHA, IT DOES NOT WORK 100%!

This script at its greatest potential will dynamically produce a script using the ffmpeg and theora-vorbis backend that can be run which will encode ALL RECOGNIZED AUDIO FILES that were found when it was invoked. It can recursively find all audio files starting at the specified input directory. Since this is alpha software, below is a list of what DOES work in the current version (0.01.05 ALPHA):

sh ffrogg.sh [commands]

  • --input=[folder or file]
  • --output=[folder only]
  • --logging (this is for debugging purposes only, can specify a folder with --logging=[folder] if directory is read-only)
  • --recursive (this flag is required to go into directories to find audio files. Otherwise it just looks at contents of specified directories)
  • --export (Create the script and exit. Omitting this flag will cause the script to encode before exiting, although it gives a period to exit before starting)
  • --force (No use for it yet, as the recovery handling bit is not quite implemented. Will remove temp files if they get in your way)
  • --help (Gives a list of options, some of which will not work yet)
  • --version (displays version of program)

This script creates a few temporary files which is inefficient, but this is by no means a professional work. It's also licensed under the GPL version 2 (although I may have omitted that in the script itself).

If the --output and --logging= and --save-state= flags are given without parameters, the current folder is automatically used "." .

Running the script without parameters will cause it to exit.

I may not get around to improving it much, and I do have a graphical user interface planned which would require basically a re-write of the script into a QT application, so it may not get past Alpha. Feel free to take it on yourselves as long as you give credit in the comments at the very least, to PeonDevelopments 2010.

Thanks, and happy listening.

Since I don't usually look at comments, send them to my gmail.

peon.developments --at-- gmail --dot-- com.

=-=-=-=-=
Powered by Blogilo

Friday, July 23, 2010

Scripting in Bash: Arrays, Files and Spaces

I recently encountered some strange behaviour in my bash shell while writing a script.

My script would take the contents of a folder and store them into an array. Sounds simple enough, as it should be. But it's not.

If you type verbatim:

" declare -a ARRAY=`ls -1 -x $directory` "

You will find that every space in every filename will produce its own entry in the array.

A file called "An Introduction To Bash.txt" would be seen in the array as

An

Introduction

To

Bash.txt

which is an abomination for what I need these the filenames for. It does make sense why this behaviour appears, but if we want the entire filename per entry, we need to take the filename before it's put into the $ARRAY variable and do something with it to ensure spaces either do not exist or do not denote the start of a new array token.

The former being the easiest and resourced method, I converted all spaces to underscores (temporarily) to prove my point.

The command is now " declare -a ARRAY=`ls -1 -x $directory | sed 's/ /_/g'` " and it will output filename entries properly, albeit with underscores, no spaces.

To ensure this effect is permanent and not just for show, one would need to rename (using the 'mv' command) all the files in that directory so no spaces are in the filenames.

Bash isn't one of my stronger languages, so I may have missed a blaringly obvious detail.

Also of note: I'm still working on the freeworld project, albeit slowly after gaining employment. My 1st revision document is approximately 70-80 pages, but that's not including proper use case tables and UML/flowchart diagrams. Least of all the prototypes for necessary components.

I hope to make another entry soon enough, in the coming couple weeks.

Peon out.

=-=-=-=-=
Powered by Blogilo

Sunday, May 30, 2010

Minimalism on a Tablet

I've been experimenting with minimalist environments lately. While I'm a KDE guy all the way, I do have a tablet that even with KDE 4.4 on Slackware, it feels a little sluggish and gets ~ 2 hours of battery. I'm a bit of a perfectionist so onward I search for the perfect tablet PC configuration.

I'm no expert, but I've been using Blackbox as a window manager on a Gentoo system and have been quite pleased with the results. My average cpu while idle is 0-1% and currently my ram is sitting at 7% usage, or 76 MB out of 1 GB. (Courtesy of Conky, a great system monitor app)

Computer stats:

IBM Thinkpad X41

1.5 GHz LV Centrino (Pentium M)

1 GB DDR2 Ram (probably 533MHz or 667 MHz)

Intel GMA 910 integrated graphics chipset

ICH6 Intel Motherboard

1024x768 px screen resolution

Wacom Penabled

Functionality varies, and a minimal system isn't for everyone. I just compiled bmpanel (which looks great with transparency) for my bottom panel. Right click is the menu and after installation of a program, it must be regenerated. Some things have to be configured by hand and to use awesome programs from KDE and GNOME, both sets of libraries must be installed which amounts to ~70-90 MB for KDE and about ~33 MB for GNOME.

One program I would recommend for tablets is the GTK-based character input application, Cellwriter. I've only played with it currently, but it looks good. Once I add some script functionality to get the screen to rotate, a system tray, and a customized monitor layout, all will be good. Will update with screen shots later.

=-=-=-=-=
Powered by Blogilo

Thursday, May 27, 2010

The FreeWorld Project *

It's time for the pre-introduction (unveiling) of a project years in the making. With an intermittant design phase of 7+ years and insight as a developer and programmer, PeonDevelopments presents a strong probability of a new multiplatform Java-based FOSS application dedicated to providng the greatest 2D Role Playing Game Engine to all Gamers, Casual Players, Developers, Marketers, Businesses and Educational Institutions interested.

Our mission statement is To provide developers and non-experienced users with a modular and FLOSS role playing game engine that performs reasonably well on multiple platforms and aids in the production of dynamic and advanced battle systems for the purpose of relating a story, plot or series of meaningful actions.

As the project is not mature and currently in vapourware status, I would like to remind readers that documentation is being developed to lay groundwork for the structure of the Engine. Expect a release of such documentation in 3 months of the posting of this article at the latest.

I will be posting a road map at a later date. I wish to produce a working proof-of-concept prototype with Installer before allowing others to work on developing this project. With that in mind, I have big expectations of this project and hope it will fill a niche that currently is not being filled to the extent it could be.

Projects such as Sphere do exist but are not maintained or as powerful as I want. More updates at a later stage.

Current documentaiton progress: At 40 pages. Expect 5x that.

* Not the official release name of the project, used as a placeholder

=-=-=-=-=
Powered by Blogilo

Friday, May 21, 2010

Technical-tainment

So as I'm sitting here at the table, drinking my light-roast coffee and feeling pretty good about life, it's time to let my readers know (all 1 of them, me) about some cool techy stuff that my mind is on.

http://kernelnewbies.org/Linux_2_6_32#head-935c2274be57c1585f23d91d185888ed0b6e0567

The above link is to the changelog for kernel 2.6.32 (which I currently use) and its improvements. Notably, some great improvements have been done in virtualization as with KSM (Kernel Shared Memory), a daemon process goes through page files determining which files are the same and merges them to reduce memory usage. That in itself is great but it doesn't put anything in perspective. Until you read the following:

"The result is a dramatic decrease in memory usage in virtualization environments. In a virtualization server, Red Hat found that thanks to KSM, KVM can run as many as 52 Windows XP VMs with 1 GB of RAM each on a server with just 16 GB of RAM."

If an XP machine was to be run under minimum requirements, using 128 MB of Ram, you'd get a barely functional OS and 52 of them would use a total of 6.656 GB of Ram. I've used XP in a VirtualBox VM using 512 MB of Ram and got some decent performance out of it. (Ran SAP and Borland Together in it; not at the same time) So assuming that each user is limited to a 512 MB Windows XP Pro OS, you'd be looking at a total of 26.624 GB of Ram required if these were dedicated machines. By sharing memory and having 52 XP machines running on a bare-bones Hardware Virtualization using Red Hat, each OS would require 307 MB of Ram if it were dedicated, but as it's sharing memory, the end result would mean more Ram to use. Assuming having shared memory resulted in each OS feeling as though it had 512 MB of Ram, that's a savings of ~10 GB of Ram, or an efficiency of 166.4% (2/3rds greater) over dedicated Ram resources.

And that's just one kernel improvement. I wonder how Windows kernel is doing in comparison.

The 2.6.32 kernel also has scheduler improvements in its CFQ low-latency mode.

Some people have had issues with KDE's Akonadi, getting a "Not Registered At DBUS" message. From my limited experience in dealing with this error, it generally only happens when trying to use an external SQL database. I believe that this is an upstream issue, as Akonadi is constantly being worked on during this time and big things are expected of it. (This has been tested on a KDE 4.3.5 and 4.4.2 system) The internal database doesn't seem to have this issue; it works at least, though sometimes produces a warning message. It may take a few more releases before this bug is dealt with,

In one Fedora forum, it seems that using an external sql database works under the root user. I wouldn't recommend this route.

Others say that it's an AppArmour issue, that it is blocking akonadi. It seems odd, as I still got this issue using Gentoo which doesn't have that firewall installed. The developer team which worked on it has been layed off as well.

http://news.cnet.com/8301-13580_3-9796140-39.html?part=rss&subj=news&tag=2547-1_3-0-5

There are some issues with Gentoo's KDE Unstable 4.4.2 release, though that's to be expected.

Sometimes closing Kontact does not completely close it and attempting to run it again will have no effect. The process must be killed before it can be sucessfully launched again.

Kile (2.1 beta 2 & 3) seems to have an issue where closing the program results in an unexpected error minutes later or if the program is left open, unattended for too long. It doesn't seem to impact my work (autosave it on) and is more of an annoyance. Still, it's a great program for working in LaTeX.

Umbrello is a nice UML modeller program, but I get segfaults semi-regularly. I'm not sure why that is and I still use it. This doesn't seem restricted to the unstable KDE release, but I thought I'd point it out anyway.

Some final thoughts on KDE 4.4.2: It's faster, looks better, and has more functionality. I'm getting used to tabbed file browsing and I like where the KDE team is headed.

A special thanks to Aaron J. Seigo, a KDE guru and expert. This guy is real inspiration and I hope to do some work on KDE in the near future.

=-=-=-=-=
Powered by Blogilo

Long Weekend

In writing the title of this post, the song by Scooter comes to mind.

Well it's the weekend, for me at least. Currently jobless and bored, it'll be a great geeky weekend indeed. In fact, my joblessness has become a catalyst for getting more involved in my personal work.

School is out and I went out yesterday to congradulate my fellow graduates from college (though I, for reasons none too serious, did not graduate this at the end of this year) and wish them the best. Once school was out, my body and mind did a crash nose-dive into my bed. For about a week or two I was sleeping approximately 12 hours a day, catching up on all those late nights/all nighters spent on our Capstone Project. (2-semeter long enterprise-level software project with proper documentation and installation)

Back to the topic at hand. Once I recovered from my exhaustion, I started back into the world of programming and computing. Re-built my resume from scratch using a personal custom design (in OpenOffice.org Draw program none-the-less) and managed to hook in one possible job prospect of which I'm only now getting the full force of what I've done.

As an aside, draw programs that I really recommend for GNU/Linux users are in fact, OpenOffice.org Draw and Krita for wonderful paint/publishing works and KolourPaint for the equivalent of Window's paint.exe program. Not much experience with The Gimp, but once they implement tabs and one window (I think there's a plugin for that, photogimp or something) then I'll go for a more professional bit.

So I met one of the management team at the Calgary Open Source Software Festival (2010) as he was a speaker there. Had a little chat afterwards and got a business card. Weeks later when I got around to applying for jobs, I mentioned this past experience and added a cover letter. Well, about a week later the company and I touched bas. They are very busy, so I am quite lucky to have gotten the attention I did; And while they don't have many positions open, it's quite possible that they will have room to train me in multiple areas and the *best* part is, they may create a System Administration position later on and have me in charge of that!

Now, the mere thought of the potential here is exciting for me. As I mentioned in the interview and will mention here now,

"In 5 years I see myself as a Software Developer. In 25 years, I see myself as a Senior System Administrator."

Basically saying that while I'm quite a geek and willing to do any odd jobs including software development of which I truly enjoy, I have a career goal and in one near-coincidental meeting (assuming I actually believe in those), my entire life as a geek may have been set up perfectly. It's much too early to say for sure and anything could get in the way of this. Nothing is conclusive and I have alternate paths if this blows up. But to be taken seriously, me, a young 22-year old whippersnapper as a possible dba / system admin, this is almost unprecedented! Basically this entire series of events rubbed my ego to the hilt. =)

Best part of all: It's mainly GNU/Linux work. Right up my alley.

So what am I going to do this weekend? Catch up on System Administration tools and information. Read a book. Play around with a project of mine. Catch up on tech news feeds. Learn some more C++ and start on Python. Build a Plasmoid. Something, anything productive. And I'm going to enjoy it.

We'll see where this leads. God willing, everything will work out in the end. It always does though, even if it's not how I want it to. But even in my darkest hours, I become stronger and more knowledgable so I don't see any downside to being rejected as a Sys Admin either.

I hope everyone enjoys their weekend.

- NP

=-=-=-=-=
Powered by Blogilo

Monday, April 26, 2010

Life to CURDATE();

School's almost done and the whether is cold and blizzardy. Or, at least it was a few nights ago; That's true Canadian weather for you.

I'm currently finished writing all my assignments and have a quiz and presentation left before I am free at long last. All this free time has also meant I've been tinkering around with my computer more often than usual. Take, for instance, yesterday. While no one was around to see it, I basically spent the whole day compiling on my laptop. A lot has happened since my last post and allow me to bring you up to speed.

+ Sold my Alienware machine that I previously had Gentoo on. Sad, I miss the machine, but some hardware or driver hiccups meant that it was constantly freezing. I'm wary that the problems stemmed either from a bad hard drive or the Vista drivers it came with. Perhaps it is also indicitive of some poor Kernel drivers too, I dunno. Doubtful though. One strange issue I had is that after installing Kubuntu 8.10, it would freeze if and only if the power manager was not on performance. Well such is life. Sold it, payed for another month of insurance, and purchased a beautiful Thinkpad T60 for a fraction of the Alienware's cost.

+ T60 Specs: 2.0 GHz Core Duo, 2GB DDR2 Ram, 512 MB x1400 ATI Radeon video (128 MB dedicated), 100GB 5400 rpm hard drive, 1400x1050 resolution, keyboard light, security fingerprint reader, and a decent speaker system. Total Price? $375. It was a deal to be sure, the last one in stock. Looked brand new except for the outer lid which had some scratches on it. This runs really cool, standard at 40 degrees idle to around 50-70 when working, compiling, and of course, running flash videos. It doesn't have amd64 support unfortunately, one thing I miss. But the keyboard on this thing is where it really shines. IBM and keyboards are like bread and butter. Perhaps I'll pick up an IBM Model M in my lifetime. I remember using them way back and enjoying every minute of it.

+ Installed Gentoo on the T60. Overall, things went smoothly on the third install attempt. I have issues with perfection and things weren't up to snuff the first two times. But I'm becoming more comfortable with the Gentoo environment and more prone to try fixing problems as opposed to the 'reinstall when something goes wrong' methodology which I have yet to shake off. I installed KDE 4.3.5 and that ran wonderfully.

+ Compiled a kernel for my T60. I need to enable plug-and-play usb mouse and keyboard support as those don't work yet, as well as the radeon fb compiled into the kernel. Currently it's as a module which doesn't work. However, responsiveness since the upgrade has increased wonderfully; A pre-emptive high low-latency kernel also helps.

+ Installed KDE 4.4 series unstable on Gentoo. Had some issues, will mention them in my next post. Still loved every minute of using this faster, more streamlined system.
+ Preparing my resume for my life as a cubicle slave. Just kidding though. While I have no qualms about being a code monkey/data entry clerk/ tech documentor, it's not something my ambition will sit well with over the years. I am in fact hoping to eventually work with the government on education, but we'll see where that leads me.

+ Excited to work on my own projects and plans, make some money, pay off debts (first priority), and collect more computer toys. While I love having the fastest and greatest/latest electronic toys in my paws, I also have learned to appreciate the stability and endurance of legacy machines. Remember when towers were made of steel? IBM Keyboard Model M's are still known for their quality. Nowadays, we get cheap keyboard crap built into plastic laptops such as the Toshiba A9, with one of the most gimped keyboards I've ever used. I'm still not sure which is worse: a small backspace key, or a small shift key. Both irritate me like a papercut to the eyeball.

And so, now with a moderately set up Gentoo machine with KDE I feel I am ready to start programming full force, starting with basic plasmoids and simple GUI's in QT4. I still hope to work in Java and am very proud of a Binary Search Tree I built last year for my college. Why are people still using ArrayLists and the like?


Check out my next post for KDE-specific notes and a very frustrating error I think I've gained an understanding on.

Wednesday, March 31, 2010

5 things you should never do when selling a computer

As I've recently been in the market for a well-priced used laptop to do coding on, I've come across some amazing poorly-written ads. I'm here to share with you my experiences and to warn people following in my footsteps, which sellers might not be the best to buy from.

Here is a list of 5 things you should never do when selling a computer.


5. Advertising your computer as a 'steal', 'the bomb', 'a blast', or any other poorly worded descriptions on the quality. Remember, this is a USED laptop. Most people go into a transaction knowing it's going to be a little iffy.

4. You can find the specs ________.
When people are buying a used computer, they don't like having to hunt down specs 'cause the seller is too damn lazy to copy-paste from a review or homepage of the computer. Do you not know the capability of the machine you're trying to sell? That looks pretty bad. Granted, this doesn't always mean the product is bad, but less dedicated buyers won't pay as much attention.

3. This machine is great for doing ________.
Because we as potential buyers are always worried if we will be able to browse the internet or use a spreadsheet in this day in age. For the more savvy buyers, one boot with Puppy Linux is enough to run everything you say (with exception of 3D games, if that's advertised) on hardware that's 10 years old or more.

2. Obnoxious in-depth specs that only hardcare uesrs would understand. I mean, there's a line between really detailed and trying to confuse customers into thinking they're getting a great deal. For example, you can sell a video card and state all the cores, size of video ram, wattage, how old, manufacturer, etc. and most people will know what you mean. But start going off into how many transistors and such, basically reiterating the engineer's manual, you've just become a dick.

1. Stating Virtual Memory as a selling point.
I actually saw an ad with this once. It blew my mind. 786MB of Virtual Ram on your computer? I'm sold.
/sarcasm
When people get to the point where one variable that can easily be changed and only affects performance when multiple applications are sucking the ram out of your machine kicks in, it's obvious they are going for the suckers. Don't be one. If someone advertises Virtual Ram, stay away. More is not always better in this case.

Saturday, March 13, 2010

"Can Windows do this? " Part I

I've decided to write an ongoing blog that revolves around things I do that Windows, consequently, does not do. This may apply to OS-X as well.

Moving Files that are in Use:

As I'm listening to music in AmaroK, I tend to move the actual audio files into folders as to separate the good from the bad.
As long as the audio file is playing, I can move the physical file anywhere on disc without interrupting playback; I'm guessing the entire file is either loaded into ram or the filesystem points to references, not literal file locations.

Windows, however, will give a "File is in use" error whenever you try to move an audio file that is being played. Meaning that you can only move it after playback has ended. Now, it's no 'killer reason' to stop using Windows, but it's one thing I do that Windows doesn't support.
Needless to say, I love having the ability to move my files when I say it's okay.
Attempting to play the file after moving it will result in an error. Obviously.

Wednesday, March 10, 2010

Gentoo Series Part II : Problem and Solution

To recap what went on in my last post, I had Kubuntu 8.10 WITH 3D acceleration on it, and Gentoo with the newest Xorg (1.7) with no 3D acceleration.

I'm a little hazy on the little details of my excursion, but here's the gist of it.

Package versions of Gentoo and Kubuntu 8.10's Xorg were 1.7 and 1.5 respectively.
Kernel versions were 2.6.31 and 2.6.28 respectively

Now along with each Xorg version, there are a LOT of dependancies that go with it.
Things such as:
randrproto, dri2proto, xcb-proto, xextproto, libXau, xtrans, libxcb, libX11, libXext, etc.

and so on and so forth. These versions different from each other as well.

Here's the Kubuntu Xorg version in its entirety.

X.Org X Server 1.5.2
Release Date: 10 October 2008
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.24-15-server x86_64 Ubuntu
Current Operating System: Linux phoenix 2.6.27-16-generic #1 SMP Tue Dec 1 19:26:23 UTC 2009 x86_64
Build Date: 09 March 2009 01:06:41PM
xorg-server 2:1.5.2-2ubuntu3.1 (buildd@crested.buildd)
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Module Loader present


I spent a lot of my time compiling a kernel for Gentoo that matched the specifications on my M17 Alienware laptop. I owe a lot of thanks to the Gentoo wiki for having an entry on such a laptop.

Page: http://en.gentoo-wiki.com/wiki/Alienware_M17

The first thing I started to change was the Kernel. I started out with 2.6.31 and ended with 2.6.28.10. It took quite a few tries to compile it right. Once I had a kernel up and running smoothly, I started to focus on X.
As I had Xorg 1.7 installed, I had to first remove it. From what I remember, it didn't uninstall some of the dependencies. (Perhaps my choice of removal options in emerge). So after that, I installed Xorg 1.5.3 without too much issue. Installing it is the easy part after all =p

I believe that 1.5.3 included dependencies that were not compatible with the ATI 8.12 catalyst drivers (such as libXext, the proto libraries) but were still installed as part of the 1.5.3 package as they were 'updated' versions. Upon my journey through the vast wasteland of old forums, I found a compatibility list for Xorg 1.5.3.

Find the list here: http://bugs.gentoo.org/show_bug.cgi?id=251832

Basically this lists all of the stable xorg-related packages for the 1.5.3 release.
Then the hard part began: I had to go through each package and ensure that the version was equal or as close to as possible, the specified version.
Some packages I don't think I found (this was months if not a year after bug was created) because of recent changes to the repo structure. After getting the versions right and removing potential conflicts, I had a complete 1.5.3 Xorg built and ready.

Finally, after weeks of work I installed the Catalyst drivers and they WORKED!
However, it wasn't time to celebrate yet. If I attempted to re-install xorg 1.5.3 or did an update world, it would have overridden my work and killed my display. I spent hours afterwords blocking versions of various xorg packages for emerge.

I wasn't quite done yet either. Once up and running, I started to get the KWin slow compositing issue with window resizing, maximizing and minimizing. In the end I patched Xorg myself as xorg-1.5.3-r7 (r6 was the max revision last I checked) and installed it as a local package.
At first I started out with the slow compositing patch, but that didn't work. Then I heard about a patch known as the fedora-dont-backfill patch. I patched using that, but it still performed poorly so I basically removed all code in a method that was the potential problem. Sadly it was still laggy, but performed much better after my patch.

Turns out that the poor performance was due to a performance improvement to the Intel graphics chipset.

So after tweaking the system a bit, I got a working Xorg and Gentoo system up and running. Awesome!

Below is a list of files with descriptions that someone who wants to attempt the same process would find useful.


Fedora Backfill Patch:
http://www.mediafire.com/?nwmzy4mlmgz
Gentoo Packages I had Installed:
http://www.mediafire.com/?kjitdxxqe5y
Alienware M17 Customized 2.6.28.10 kernel:
http://www.mediafire.com/?nzoz4dyccme
Gentoo make.conf:
http://www.mediafire.com/?kyrnwvmwgjz
Gentoo package.keywords:
http://www.mediafire.com/?oyezzmyzwzj
Gentoo package.mask:
http://www.mediafire.com/?wh22nmmtzuh
Gentoo package.unmask:
http://www.mediafire.com/?j2zmydyered
KWin Resizing Patch:
http://www.mediafire.com/?dmymxmhdhzx
Gentoo rc.conf:
http://www.mediafire.com/?5nmjvmwyjmm
Local (modded) Xorg 1.5.3-r7:
http://www.mediafire.com/?2qz5dnzynwj


If you're installing Gentoo, you'll probably understand the meaning of the files.

I hope that this explaination of 3D acceleration on Gentoo's older 1.5.3 Xorg are satisfactory. Feel free to email me if you have any questions.
I may write another blog on Gentoo, part III, on some issues I found. Nothing warranting such a large blog post.

Cheers,
NuclearPeon.

Wednesday, January 20, 2010

Gentoo Series Part I : Past and Present

For the first post of my multi-part Gentoo blog series, I will be discussing the quirks I've encountered, the desired goal of my objectives, and the path to take to get there.

The purpose of the following Gentoo blog posts is to document how I went from the base command-line Gentoo system to a 3D-accelerated environment using the proprietary ATI drivers. Unfortunately, those, mixed with some quirks of my Alienware M17 machine, make for a lot of frustrations and cursing. Something hopefully those who read this blog will avoid, if you are following in these footsteps.

In retrospect, I was quite lucky for things to turn out the way they did.
It all started when I purchased this laptop a year back, in December 2008. The school-based laptops had a ton of resource-consuming Windows apps on them (Anti-virus for example) that severely degraded performance. The screens were poor, small (1200x800, so not that horrible), and they had the most gimped left-shift-key I've witnessed on a computer. Major productivity killers.
So I ordered this baby, with 1920x1200 resolution, dedicated video, but otherwise quite plain. Ever since discovering GNU/Linux in 2005 way back, when Ubuntu 6.10 was out and new, it had been my distro of choice. Well, Kubuntu to be exact, and I had not had experience in anything else but Fedora Core (not a great experience). Upon the laptop's arrival, I installed Ubuntu 8.10, the most recent at the time.

Upon first booting up into the system, I was met with the ugly 'no video driver' resolution desktop. The newest driver at the time, the Catalyst 8.12, provided excellent 3D and all was right with the world when installed. It could be run via command line installer without any additional configuration or patches.

And so I used such a system for about a year until KDE 4.3 came out. For those who have used Kubuntu 8.10, there is no official (stable) kde 4.3. Unless you use a nightly repository or compile from source, chances are you won't get it. Being a fan of the K Desktop Environment, this slowly nagged at me.

Now 3D acceleration is important to me, as it's required to play Warcraft 3, one of the few games I play on a constant basis. This is important, as a few other distributions I tried to get kde 4.3 off of, arch, gentoo, and future ubuntu versions, wouldn't give me 3D, or so I thought.
At this time, it's worth mentioning that there's an issue with either the Alienware M17 hardware, the ATI HD Radeon 3870, or the Catalyst drivers that prevent the desktop from appearing on the laptop screen. It's a strange issue, where plugging in an external monitor will show the desktop, the but the laptop lcd remains black (but lit up). It holds true on Ubuntu 9.10 with Catalyst 9.10/9.12 drivers. The HD Radeon 3870 is part of the R600 series.

So now I'm in the situation where I've been trying to migrate from a working, but old system to a new, no-3D system. It seemed like everytime I would migrate to another distribution, the lack of 3D drivers would force me back to the Kubuntu 8.10 system.

By this time, total hours spent attempting to get a newer working system with 3D has probably reached 30-40 hours (non-continuous, over a year period)
I haven't installed Gentoo by this point, only Ubuntu derivatives and Archlinux. Arch worked fine, but no 3D.

Gentoo was compiled with the core2, -pipe and -O2 optimizations. Once the base system was up and running, X and KDE quickly followed. It took about ~30 hours total including download times to get it set up and compiled with most of my programs.
Even though there was no 3D at this point, it ran deadly fast with the open-source 2D ati drivers.
Things were near-instant opening and closing. Sure, the fan was running constantly because the driver doesn't yet have proper power management, but things worked great.
It was about this time that frustration at not having 3d set in.
After installing Ubuntu 8.10 alongside Gentoo, I went in and began to check all the versions of packages that I felt would affect 3D.

This is the point where I noticed the difference in Xorg versions.
Gentoo had the newest 1.7 series, whereas Ubuntu 8.10 had 1.5.2. In a nutshell, I figured that I'd have to install the same version of packages in order to get the same setup I had in Ubuntu, which theoretically should work fine.



And so concludes the first part of the Gentoo series. This was the first step I took to getting 3D on Gentoo. And to be frank, it was the easiest part.

Stay tuned for the next part, documenting resource and configurations used in getting it setup properly.
It's loads of fun, with a bit of patching, lots of forum scrounging, and lots of compiling.

NP out.

Friday, January 8, 2010

Windows 7 Versus Vista, an end user's perspective

It has been more than 4 years since last seriously using a Windows environment to do work.
I've never been a Windows expert, but I know enough about computers to do installations and driver updates without too much trouble; A couple years back I installed Windows XP on a laptop using a slipstreamed XP cd (sadly they don't include SATA drivers) so I wasn't expecting much trouble.

Both Windows 7 and Vista are the 32-bit editions, as compatibility seems to be better as such.

On my first install attempt, my current partition setup was like this:

1 Primary Boot Partition (Linux)
1 Primary Root Partition (Linux)
1 Empty NTFS Partition to install Windows on
3 Logical Partitions for Linux mount points.


Now, there is a good reason why forums will suggest installing Windows first, then Linux on top.

The first issues I encountered were:

- Windows cannot install to the desired partition error
- Windows cannot install to an external USB error

I figure it had something to do with the number of primary partitions already set up, in addition to the logical ones. Both Vista and Windows 7 had these issues and would not install on the current configuration; they don't seem to recognize logical partitions at all.

Unsurprisingly, GNU / Linux distributions will install without any hiccup given my partitioning scheme, as I successfully installed Ubuntu 8.10 on top afterwards. But this is irrelevant for this blog topic.


So I eventually caved in and wiped my hard drive of partitions and set up all my primaries using the Windows 7 partitioner. It's installed on the 2nd primary partition and everything worked fine.
My screen resolution is 1920x1200 and I was surprised that it was autodetected and set. Generally drivers are required to get it working. However, that was as good as it got. Not only did Windows 7 feel slower than Vista (based on perception, not on actual benchmarks) as windows started to lag, tasks took longer, etc. As Windows 7 detected the video card, I expected it to detect other components of my laptop. I did not install any drivers on 7, so perhaps the slowness was due to a missing component.
The kicker came when trying to watch videos with speakers plugged into the audio jack. No sound came out through the speakers. Sound kept playing from the laptop as if nothing had been recognized. Plus the sound was quieter than when using Linux or Vista systems.

And so I judged that Windows 7 wasn't ready.

On to Vista:

Like it's newer cousin 7, it would not install when my primary partitions were already in place. I wiped 7 off and began to install Vista on the same partition 7 was previously on.

Everything was the same for installation, except when presented with the desktop, resolution was reduced, blurry, and gross.
As I had the OEM driver install cd with me (a fact that is the reason why Vista was a breeze to install; without it, it would have been exponentially more difficult to work with) and soon had all drivers working.

Now Vista at this point was still working quite slow, as most people have complained about. After using the Windows Update to get all recent updates as well as some optional ones which included optimizations (highly recommended to install for you Vista users), normal desktop usage ran like a breeze.

Warcraft 3, although quite old now, ran extremely fast on full settings. As my laptop is known as a "Gaming Laptop", a moniker I dislike personally, having 512 MB of dedicated video DDR3, it's expected to run fast.

So for the simple task of playing Warcraft 3, Vista is definitely the winner.

Of course, this is purely an end-user perspective. For all the technical jargon and points that could be made (7 is faster, blah blah blah), I prefer Vista.
And the most probable reason for my preference, is the simple fact that Vista has been out longer.
It has had more time for bug reports, updates, and real-world usage. 7 hasn't been out long enough to gain the backing that Vista now has.
And that is one reason why many companies haven't switched yet, for good reason.

Personally, the only real diff I see right now between 7 and Vista is the user interface.
And both pale in comparison to speed I can achieve with linux systems.

XP runs great with 376 MB of ram in a virtual machine with 32MB video. If I need windows apps, I've got that covered.

Lastly, I'd like to give my own personal take on what should have happened after Xp.

Since the UI is so familiar and usable for most people, what Microsoft SHOULD have done, is take the XP interface and completely rebuild Windows in order to use that interface, but with a more secure and functional system and kernel.
Naturally, UI enhancements should be included, users should be given a choice of interfaces to implement. Just like GNU/Linux users can choose Gnome, KDE, fluxbox, Enlightenment just to name a few, and have those look like Mac OS-X, Windows, or just a blank desktop (minimal), Windows too should give users more choice.

For instance, some people in China have taken Ubuntu and made it into an XP clone, pixel for pixel. Link below.

http://www.thevarguy.com/2010/01/05/ubuntu-linux-clone-looks-like-windows-xp/

Is it so hard to make Windows modular so people can build their own Windows system?

Perhaps. At least there is KDE - On - Windows for those that want functionality on their windows desktop.

http://windows.kde.org/


So many opinions, so little time.
I hope this post hasn't exasperated you readers. ( lol as if anyone reads this blog =p )

And for the record, Ubuntu and popular distributions in general install in about 20 minutes. Vista and 7 in about 30 or 40.
Windows still uses a filesystem that's 9+ years old (NTFS) and support for things like FAT, FAT16/32/64.
Honestly guys, make a better filesystem.