All Blog Entries

All blog entries, ordered from most recent. Entry count: 1198.

Warning! Some information on this page is older than 6 years now. I keep it for reference, but it probably doesn't reflect my current knowledge and beliefs.

Pages: > 1 ... 60 61 62 63 64 ... 150 >

# What is C++/CLI ?

Fri
25
Sep 2009

Today I've started learning C++/CLI. It's a Microsoft technology that allows to write managed code for .NET platform in C++. But I can see it's not just a Microsoft idea to introduce custom language extensions. It's a massive piece of technology and even some C++ gurus were involved in its development, like Herb Sutter and Stanley Lippman. It's also approved as ECMA-372 standard.

So what exactly is C++/CLI? It's yet another language for .NET, just like C# or VB.NET, but it has the unique feature of being compatible with native C++ and being able to freely mix managed and unmanaged code.

For many people it may trigger some bad connotations with ugly syntax like __gc, __interface, __property etc., but that's not true. Syntax like this existed in Managed Extensions for C++, but C++/CLI is its new, improved version introduced in Visual Studio 2005.

Here is a screenshot from my first experiment, where I've created a property grid control from .NET next to a native Direct3D9 device initialized inside a panel control.

Just look at how old good native code can be mixed with managed one:

#include <d3dx9.h>
namespace ManagedCpp02 {
  using namespace System::Windows::Forms;

...

public:
  Form1()
  {
    PropertyGrid^ propertyGrid1 = gcnew PropertyGrid();
    ...
    IDirect3D9 *d3d = Direct3DCreate9(D3D_SDK_VERSION);
    System::Diagnostics::Debug::Assert(d3d != nullptr);

Microsoft wasn't afraid to introduce new keywords and operators to the language. These designed to operate on managed code work next to the native ones, so you can define and use native and managed classes next to each other just like this:

class NativeClass { };

// Allocate from unmanaged heap - memory must be freed.
NativeClass *nPtr = new NativeClass();
delete nPtr;

ref class ManagedClass { };

// Allocate from managed heap - garbage collected.
ManagedClass ^mPtr = gcnew ManagedClass();

Comments | #c++ #.net #visual studio Share

# Learning PhysX

Fri
18
Sep 2009

Yesterday I've started learning NVIDIA PhysX. It's the first time I use a physics engine at home, but it seems quite easy for me. I like the PhysX library as it has pretty, object-oriented API.

Is using a physics engine really an advanced topic? Now I don't think so. Sure there are some scary looking terms like "inertia tensor" or "angular damping", but all you need for the start is to know a bit about vectors, matrices, quaternions and some school-level physics like the concept of mass, velocity and force.

PhysX is very powerful. It can simulate soft bodies, cloth, force fields, fluids and much more. But the foundation is just rigid body physics plus character controller. In fact it is so simple and powerful at the same time that I now think every beginner game programmer should learn this. Physics in games is not only to simulate boxes and ragdolls of killed enemies. Using such physics engine is many times easier than implementing algorithms for normal collision detection, sliding along walls, walking on the height field, checking if an object entered a trigger or casting rays. PhysX offers it all!

So how to start learning PhysX if you are interested in this subject? All you need to do is to go to the NVIDIA PhysX website, download and install the PhysX SDK. It includes all necessary files like headers, libraries, DLL-s, documentation and tutorials. I learn from the included tutorials in DOC format which can be found in the TrainingPrograms\Docs\ subdirectory.

Here is a small screenshots from my today experiments:

Comments | #libraries #physics Share

# About Graphics in Modern Games

Tue
15
Sep 2009

There are always some "trendy" styles that differentiate professional creations from amateur ones. CollegeHumor made a parody of professional-looking trailer for fictional movie Minesweeper [en] and LIMO cabaret did the same with movie Leszek Balcerowicz - Nieznana historia [pl].

What about games? Today people I'm following on Tweeter posted interesting links about graphics in modern games. First, this comic says much. Dark, brown and gray colors are common in today's games, especially in some genres like action games (opposite to colourful fantasy RPG and arcade games, like Trine). Here is also a funny picture. Second, Kayamon posted on his blog quite serious note about how render target size can be reduced by using only two channels to describe pixel colors. His experiment gave quite good results with screenshots from Gears of War :)

Comments | #video #humor #rendering #web Share

# Coding Texture Preview

Sun
13
Sep 2009

Today is the 256's day of the year, so it's the Programmers' Day. Thus I wish all the best, especially a good code and no bugs to all of you who code for fun or/and profit (hopefully "and" :)

I've recently started new home project called "BlueWay". There's noting special about it - just another time I start everyting from scratch :) But this time I have deferred shading, cascaded shadow mapping, new scene management (based on k-d tree), new component-based object system and asynchronous resource manager (resources are loaded in the background on separate thread). I'm not sure whether I can call D3DXCompileShaderFromFile from separate thread without D3DCREATE_MULTITHREADED, but it seems to work OK :)

What I want to show today is a code for previewing textures. When coding some complex effects, it's often handy to look at intermediate results in render-target textures. Of course we have famous PIX and NVIDIA PerfHUD, but I believe that such custom code for real-time in-game texture preview is useful anyway. I wanted to make it general and flexible and here is the way I do it.

 

 

 

Comments | #rendering #directx Share

# New DirectX SDK and Total Commander

Thu
10
Sep 2009

There are two new software releases that are important to me. I know about them from Twitter (yet another good reason to join microblogging activity :)

First one is DirectX SDK August 2009. Updates relate mostly to DirectX 11, but hey, there was no new SDK version for a long time!

(I've just discovered there are changes in the error handling system that are not backward compatible. To compile my code I had to change #include <dxerr9.h> to <dxerr.h>, link with file dxerr.lib instead of dxerr9.lib and rename function calls DXGetErrorString9 and DXGetErrorDescription9 to DXGetErrorString and DXGetErrorDescription.)

Second new release is Total Commander 7.5 FINAL. I can't see any revolutionary changes (despite the new, Vista-like behavior of the current directory bar), but that's a good news as Total Commander is already great.

Comments | #directx #software Share

# Dualism of Data Types

Thu
03
Sep 2009

In 3D games programming we use structure type called "vector", like D3DXVECTOR3, but we can remember from school that there are two separate geometrical objects: point and vector. Although both contain just 3 real numbers, there actually is a difference between them. Point represents a position in the space of some coordinate system (it's absolute - we can imagine it as a dot), while vector represents a translation by some distance and direction (it's relative - we can image it as an arrow). If we had separate types for points and vectors, we should define their operators this way:

POINT + POINT doesn't exist
POINT - POINT = VECTOR (difference between points)

POINT + VECTOR = POINT (translated point)
POINT - VECTOR = POINT (point translated by inverted vector)

VECTOR + VECTOR = VECTOR (sum)
VECTOR - VECTOR = VECTOR (difference)

VECTOR * float = VECTOR (scaling length)
VECTOR / float = VECTOR (scaling length)

In my opinion it's good to express this difference by naming variables "position" (when we mean absolute position of an object) and "translation" (when we mean transformation of the object position), "size" (when we mean persisting size of the object) and "scale" (when we mean transforming object scale by some amount), "orientation" (when we mean how the object is currently rotated) and "rotation" (when we mean a transformation that is going to modify its orientation).

Although we never make such distinction by defining two separate data types for vectors or matrices, it happens sometimes in the analogical situation with date-time types. For example there is the DateTime structure in C# that represents an instant in time and the TimeSpan structure that represents a time interval.

Similar problem exists when we talk about any indices or pointers, especially if we want to use unsigned integers. Index or pointer cannot be negative and special "invalid" value can be defined as 0xffffffff as well as -1. I like to use unsigned type, e.g. because I can just check if (index < elemCount) instead of if (index >= 0 && index < elemCount). But what if we need a type to describe a relative offset? Obviously it should be signed because it can be negative. That's why C++ has types size_t (unsigned) and ptrdiff_t (signed). But things get complicated when we think about what type should the fseek function expect, as it can get either absolute (SEEK_SET) or relative position (SEEK_CUR, SEEK_END).

So all in all I think maybe we don't have to always define two separate types in our code, but we should always remember about this distinction when writing code.

Comments | #c++ Share

# My Theory of Communication

Mon
31
Aug 2009

Today is the Blog Day. I'm not going to link the blogday.org website or apply their advices about recommending other blogs, but instead I want to present my little theory explaining what's the place of blogging and tweeting among other forms of communication.

I think that communication and knowledge sharing can be seen as a spectrum, where each form has its place between two extremes - first is writing/reading a book and the second is a casual real-life chat. I hope this diagram explains everything:

Theory of Communication

So if you only like to read books and you disregard communication via the Internet and casual chatting or the opposite - you are used to only write and read short messages to your friends and you never read books or write long letters - then think for a while whether your way of communication is really better than others or maybe your beliefs make you losing some of the opporunities from this full spectrum that you may enjoy...

Comments | #philosophy #web Share

# Calculating Linear and Quadratic Equation Coefficients

Sun
30
Aug 2009

Some time ago I've written about formulas to calculate coefficients of linear and quadratic equation [pl] when having 2 or 3 given points (x,y). Yesterday I suddenly noticed that my code needs to do it every frame so I need functions to calculate these coefficients. Below you can find the code of my functions. They are templates, so they work with many types including float, double, as well as vectors of any dimmension and other types which have addition, subtraction and assignment operators, as well as multiplication and divistion by float scalar.

 

 

 

Comments | #rendering #math #algorithms Share

Pages: > 1 ... 60 61 62 63 64 ... 150 >

[Download] [Dropbox] [pub] [Mirror] [Privacy policy]
Copyright © 2004-2026