Tuesday 11 December 2007

DirectX Demo Project

Here is my DirectX demo project for Games Programming course at Abertay.

It makes use of:
- A point light and a directional light
- Shadows (planar)
- Animated meshes



And it's the url:
http://www.youtube.com/watch?v=xI8r653mX4U

Now I'm going to start to study for my Maths exam :)

Sunday 9 December 2007

How to print text in directx

First, you need to create a RECT object to set the area on screen, ID3DXFont object, and a D3DCOLOR object:

RECT lineRect;
ID3DXFont * pDefaultFont;
D3DCOLOR defaultFontColor;


This is how to initialise them:

A rectangle which has a height of 50px, on top of screen:
lineRect.left = 0;
lineRect.top = 0;
lineRect.right = 1024;
lineRect.bottom = 50;


How to create a font
D3DXCreateFont(Device, 30/*fontHeight*/,
0, FW_BOLD, 0, FALSE,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
TEXT("Calibri"), &pDefaultFont );


I'm not going to deal with the details of D3DXCreateFont method, but you can find the reference here:
http://msdn2.microsoft.com/en-us/library/bb172773.aspx

How to set the color:
defaultFontColor = D3DCOLOR_ARGB(255, 255, 255, 255);

Now you can write your text:
pDefaultFont->DrawTextA(NULL, "My Text Here", -1, &lineRect, DT_RIGHT, defaultFontColor);

Sometimes I strongly miss the VB6 times:
Print "my text here"
But of course, they're "incomparable" in terms of speed :)

Thursday 15 November 2007

from the 'Scratchware Manifesto'

It's a very-must-read for all the game developers, and also a must-read for other developers. So, please read it in its entirety.

What are the characteristics of vampires? Well, they’re immortal. Strangely enough, a corporation can live forever, too. Morgan Bank, Ford Motors, and General Electric - they can go on and on and on. Another characteristic of vampires? They live by sucking blood. You know the feeling you get when you boot up a new game and it crashes five times in the first 15 minutes? That’s your blood being sucked. The corporation exists for one reason only (and don’t let them tell you otherwise) - to make as much money as it possibly can. It’s like we’re cattle, kept alive for the greedy bloodsuckers to get as much profit as they can out of us. (They treat the Earth the same way, too - ever seen a clear-cut forest? Corporate vampires in action!) Vampires are notoriously hard to kill, and so are corporations. Exxon spilled oil all over Alaska - but it’s still going. Union Carbide killed thousands in Bhopal, India, but it’s still trucking. You can try and sue a corporation, but they have millions of dollars and thousands of lawyers to make sure their evil undead masters remain in control. Bridgestone/Firestone made a bunch of shitty tires, which killed a whole bunch of people in their SUVs. They might get in some trouble, but you can be sure that the corporation will go on. (An interesting fact: many of the faulty tires were made in the Decatur Illinois plant, where the regular workers were on strike. The tires were made by ‘replacement workers’, also known as scabs. Vampires and scabs? Some coincidence.) Vampires also have nests; usually the basement of some dusty castle. The vampires who run America have a nest, too, but theirs is called Wall Street. Vampires have a dark charisma; corporations spend billions on advertising.

Monday 12 November 2007

The upcoming game 'Spore'

No doubt, a new hit-title is on the way. Will Wright, the designer of The Sims and Sim City, has been started the development of a new game.

Check out Spore on wiki

Wednesday 24 October 2007

Retrieve your windows product key

I lost the paper that I'd written my product keys on. Maybe it's still somewhere at my room in Izmir, but my mother couldn't find it unsurprisingly.

But an angel appeared for help! This program is what it says in its name:
Magical Jelly Bean Keyfinder

"Stupid is who does stupid"
Forrest Gump's mother

Tuesday 23 October 2007

Article: "What is software design?"

This is one of the best articles I've ever read about the function of software engineering, and software design. A recommended reading for all butties around this software thing.

My favourite paragraph:
Also consider how the process of software development is changing. Once upon a time we had the waterfall process. Now we talk of spiral development and rapid prototyping. While such techniques are often justified with terms like "risk abatement" and "shortened product delivery times", they are really just excuses to start coding earlier in the life cycle. This is good. This allows the build/test cycle to start validating and refining the design earlier. It also means that it is more likely that the software designers that developed the top level design are still around to do the detailed design.

And the link to the article:
"What is software design?", Jack W. Reeves, ©C++ Journal - 1992

Saturday 13 October 2007

Dundee, 2007

After a couple of months, It's time to give an update to this blog.

The nontrivial things:
- I'm graduated, and titled as a software engineer, at last. Yahoo!
- I've started studying the course MSc Computer Games Technology, at University of Abertay Dundee. With my friends Kaya and Umut. Indeed, Umut is doing Smart Systems.

This means I'll tend to post CGT-related stuff, here.

Just to keep the rituel in the first post, this is my new working desk @The Hub, Dundee, Scotland:

Kimden Other


I just remembered why I'm using blogspot. Because it was ten times faster than wordpress. My other blog, which is in Turkish and is hosted on wordpress, is too damn painy to update. Thanks to those bulky AJAX stuff.

Thursday 5 April 2007

PHP Data Access Layer Generator


I've written a program that generates php scripts, using given sql queries. A set of data access functions is generated by the program, including connection methods and protection for sql injection.


Tuesday 13 March 2007

Robert Heinlein

"a human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. specialization is for insects."

Monday 22 January 2007

pthread on slackware on vmware on windows xp

Yesterday, I had to write a multithreaded application using posix threads on linux, for one of my friends.
We had thought that we could do it by installing slackware linux on a vmware virtual machine running on windows xp. brillant idea, huh?
For early 4 hours, everything was ok. We drawn up state diagrams and wrote trivial code parts to use later.
After that, we set up threading and thread syncronisation using mutexes. Then the nightmare started. Results were inconsistent. Sometimes things went well, and sometimes deadlocks occured.
We could not obviate managing of the conditional variables (pthreads mutexes), and worked different solutions, algorithms for about 4 hours. It was suspicious that Sleep(int) method worked seconds-based, not miliseconds-based as expected on a linux. and bigger values like sleep(1000) did not cause a sleep.
We renounced at late of the evening.
The day after, we requested one of our friends to try the same source on his native linux (pardus).
And a dramatic notice! It had given the expected(correct) results.
-
We think it is vmware. But already so many multithreaded applications work on it. Is it posix threads library version on slackware? We don't know yet.

Conditional("Debug")

There's a pretty cool feature in C#(or MSIL compiler?). On a method, you can put a conditional attribute, and calls to that method are only compiled on debug mode. This gives a perfect way to trace how are things going on.

public class Test{
[Conditional("Debug")]
public void Method()
{
// ....
}
}


Today, I've found a bug in my code, associated with this.
[Conditional("DEBUG")]

I had written the string in capital letters. But in runtime or compile-time, there's not an error about it. It simply and silently "doesn't work."

It took an hour to realize this. It would be great if they used an enum, for examle:
[Conditional(ConditionalModes.Debug)]

or different attribute types for each mode:
[DebugConditional]

This is not a big thing of course, but these kind of design decisions are important.
I always prefer compile time errors -where possible- :)

Thursday 18 January 2007

SqlDataReader

Just like DbCommand objects, using DataReader objects is a pain.
Everytime the same routine: check value, cast, set.
I've automated this with RTTI, too:

public class DbDataReaderReviver
{
public object ActivateObject(DbDataReader reader, Type typeOfObject)
{
object myObj = System.Activator.CreateInstance(typeOfObject);
FieldInfo[] objFields = typeOfObject.GetFields(BindingFlags.SetField);
string fieldName;
object fieldValue;
foreach (FieldInfo finfo in objFields)
{
fieldName = finfo.Name;
fieldValue = reader[fieldName];
if (fieldValue == null) continue;
finfo.SetValue(myObj, fieldValue);
}
return myObj;
}
}

sqlcommand

I'm very tired of adding parameters to sqlcommand (or oracledommand, or -best- dbcommand) objects.

I have written a smart code with RTTI, that fills the parameters of dbcommand objects using an "object instance". First it searches for the member fields of the object, then populates the dbcommand object with these name-value pairs.

I didn't tested this code, but I know this approach works well.


public class DbCommandBuilder
{
/// summary
/// Populates a DbCommand object with the public fields of
/// the given object as parameters.
/// summary
/// param name="command" DbCommand reference to fill
/// param name="obj" Object to get fields of
public void BuildCommand(DbCommand command, object obj)
{
Type type = obj.GetType();
FieldInfo[] finfos = type.GetFields(BindingFlags.Public);
string fieldName;
object fieldValue;
foreach (FieldInfo fin in finfos)
{
fieldName = fin.Name;
fieldValue = fin.GetValue(obj);
command.Parameters.Add(fieldName);
command.Parameters[fieldName].Value = fieldValue;
}
}
}

my desk


This is where I work at home.
I love my desk.
Posted by Picasa

fresh start

Or better, from now on I will start a seperate blog in English.

In fact, I don't like writing in English so much, writing in Turkish is much more joy for me.

Apologizes to good-english-knowers for my non-perfect English. I hope somebody corrects me when I make mistake.

wordpress

Aslına bakarsanız blogspot'ta günlük tutmayı düşünmüştüm. Ama bir hesap açıp biraz kurcaladıktan sonra (yavaşlığını bir yana bırakırsak) wordpress'ten buraya taşınmanın attan inip eşeğe binmek olacağını farkettim.

Export import bile yapmaktan aciz :(

Velhasıl-ı kelam:
http://gorkem.wordpress.com