Navigation |
This project is totally deprecated since 1999.
What is gdck?gdck held for Gtk Demo Contruction Kit. This application helps coders and graphists working together easier and synchronise their jobs. The goal is to provide a graphical interface to create a demo. gdck was coded in C++ and works with Gtk library. It works on Windows and Unix OS if gtk is install. You don't need any other libraries. Often, coders are not dezigner and dezigner cannot work on C++ sources to do transition and linking differents effects together. To create a demo, today, dezigner must explain what he imagines to the coder and hope the coder will arrive to translate dezigner imagination into reality. This situation require lot of time, coders and deigner must meet often to discute and show the current state of the demo. gdck tries to decrease these interactions.How does gdck work?For the graphistgdck is a single window application. This window have 2 main part: The black middle part and the script part in the bottom. The black part is the realtime rendering of the demo and shows you what will you see during the demo. You can move and scale effects on this part. The script part shows the differents effects and how these effects will start and end. There are also few buttons on the top of the window. You can load/save/clear a script. The interface is very light because all features are available using shortcut keys. A script is a group of effect. Each effect is a single and "simple" graphical render. For example, There's an effect called Background that display a picture on the screen. Another effect called 3dPlayer display a single 3d object on the screen. You can superpose effect like "layers" and all effects will be rendered for the top to the bottom. For the coder gdck is a tool that help all coders to have the same organisation and know that is his effect works alone, the effect will work on gdck. An effect is a C++ class with virtual method that must be implemented by the coder. The interface is very easy to understand and when you manage it, you can add new effect easily.For the groupWhen you want to make a demo, you start to code the specific effects for your demo. When all effects are coded, you link them to gdck and give gdck to your graphist or dezigner. Then, he could put effect together and, in realtime, modify all effects to be smooth and synchronize with the music. Transition are very easy to do in this way. When the script is over, you can build the packed data file automatically. The demo will contain the gdck script player, the packed file data and that's all. The packing format is a melting pot private format that give you the certitude that datas will never reuse by other groups.How to start?It's perhaps hard to begin on gdck because the interface isn't very userfriendly. I'll do a little tutorial explain how to make your first script! To begin, launch gdck :/ First thing we do is to add an effect on the script part. As you can see, the script is like a table. In the horiontal axe, you have the time and in the vertical axe, you have layers. In the rendering process, effects are display from top to bottom layer. There are 2 fondamental modes on the script. The first one is the "move mode". It's the default mode when you start gdck. This mode allows you to move and scale the script with the mouse. Let's push the left button and scroll the mouse. It's like if you drag a paper. With the right mouse button down and horizontal mouse move, you scale the script. It's useful when you want a global view of the script or to see a detail in a part of the script. The second mode is the "new mode". You have to pass in this mode, just press the 'N' key. This mode allows you to add new effect, in this case left button doesn't have the same behavior than in the "move mode". When holding down the left mouse button you set the begin of the effect. Move your mouse on the right and release the button. You insert your first effect!!! As you can see, when moving your mouse on the effect on the left, center or right part of the effect, the cursor change. You can resize the left or right part of the effect (start time or end time of the effect). You can drag the effect on his line by clicking on it (when the cursor is like a cross) and move your mouse. Release the button when the effect is on the good position. You can return in "move mode" by pressing 'M' key. As you can see, the effect name is Nothing. All new effects are Nothing. This means that the effect do... nothing. Now, you have to change the effect unless if you want a nothing demo :). To do that, just left click on the effect. The properties window should pop up. The "Common properties" part contains 3 buttons. You can use the arrows buttons if you want to move up or down this effect to next layers. StartTime? and EndTime? is the start and the end of the effect in milliseconds. The list contains all effects available in gdck, choose the Background effect. The second part contains specific data for the effect. Now you have choose the background effect, you have to put a picture filename. You can close the properties window and put the current time on the effect. To do that, scroll the top scroll bar until the black vertical line on script part are on the effect. You should see the picture. Now you can scroll and resize the picture on the black part of the main window. Just push the left button and drag the pic to move it and use the right mouse button to scale the picture. How do add a new effect on gdck? If you want to add a new effect, you have to implement a virtual class called CEffect?. gdck was coded in C++ but you don't really have to know the C++ concept to create an effect. I made some preprocessor macro which hide the C++ parts. What you need is to implement some predefined functions. The best way to start is to see an empty example The CEffect? class contains variables initialized by gdck that you have to use. For example, Destination is a pointer to the destination buffer that your effect have to fill. Width and Height give you the size of the buffer. Could I see an example? Ok, because this documentation is quite short and not very easy to understand, I'll show you an example of an effect that I use in gdck. It's a very useful effect and very simple one. Its mission is to clear the screen :)// Includes #include <stdlib.h> #include <math.h> #include <string.h>First we include standard library needed by the effect. #include "mlib.h"This include provides you mlib functions. This library is a set of "cool" functions helping you to debug, use files and picture easily. For more informations about mlib, take a look here: ace.planet-d.net/mlib #include "mtpfx.hpp"This include contains the generic CEffect? class. Look on this file if you want to see all variables and functions you have to use or implements. // Declarations START_CLASS (ClearScreen?)START_CLASS is a macro that put a C++ init class block. It avoids you to put some unuseful code and increase lisibility of your file. This solution is a good way if one day, I want to add or remove some features on the generic class. ClearScreen? is the name of your effect. You have to change it because 2 effects can't of the same name. pixel Color;In this part, you have to put all your effects variables. You can't init them here, so you have to do it on a special function. For this example, Color is the color that we use to clear the screen. pixel is a gdck type for representing a pixel :). It's an ARGB format with 8 bits per components. void Default ()
{
Color = 0;
VarArray?.Add (&Color, "Color");
}
This function is called when your effect is create. You have to initialise all your variables with a default value. Here, we put the default color to black (0). The next line tell gdck that he have to put the Color variable available for the user. The user will be able to change the value of this variable. The first parameter is a pointer on the variable and the second one is the name of the variable the user will see.
void Play ()
{
if (Color == 0)
{
if (Width == Scanline &&
XMin? == 0 && XMax? == Scanline - 1)
{
memset (Destination + YMin? * Scanline, 0, Scanline * (YMax? - YMin? + 1) * sizeof(pixel));
}
else
{
for (int y = YMin?; y <= YMax?; y++)
{
memset (&(Destination[y * Scanline + XMin?]), 0, (XMax? - XMin? + 1) * sizeof (pixel));
}
}
}
else
{
for (int y = YMin?; y <= YMax?; y++)
{
for (int x = XMin?; x <= XMax?; x++)
{
Destination[y * Scanline + x] = Color;
}
}
}
}
This function is the most important one. gdck will call it each frame for the rendering. It's here that you have to put your code that will render your effect. There are lot of predefined variables that you have to use to render the effect correctly. As you can see, the function try to see if we can use a memset or not depending of few parameters. The goal is to use the most optimised function if possible. If you want to have more informations about predefined variable, let's go here
END_CLASS (ClearScreen?)This macro marks the end of you effect. It puts some C++ code and is not important for you. There are some other predefined functions but we doesn't need them for this example. How does CEffect? look like? I'll explain in this part what the CEffect? class have and explain all the methods you have to manage. class CEffect? { pixel *Source; // Source bufferThis is the source buffer that contains the "screen" before your effect. You can use it for special effect for example if you want to do a blur effect, you read on the source buffer. pixel *Destination; // Destination buffer (could be the same as source buffer)This buffer have the same size as the Source buffer and used for drawing your effect. Effects always read on the Source buffer and write on the Destination buffer. You have to be carefull because Source and Destination could be the same buffer. In this version of gdck, it is always the case (Source = Destination). int Width;It contains the Width of the buffer. For a 320*200 effect, Width = 320. int Height;This is the height of the buffer. int Scanline;It's the scanline of the buffer. Width and Scanline have very often different value so if you want to put a value on the buffer at (x,y) coordonate, do this: Destination[y*Scanline+x] = value; int XMin?, YMin?, XMax?, YMax?;This values define a clipping box. It means that you must not fill all the Destination buffer but only pixel that are on this clipping box. If the Width=320, Height=200 and all the buffer have to be filled, Xmin and YMin? will be 0, XMax? will be 319 and YMax? 199. float Pourcentage;This value give you a relative time scale. At the beginning of the effect, Pourcentage will be 0.0 and at the end it will be 1.0. Each frame, this value will change and give you the relative time. If your effect do a fade from black to white, you can use Pourcentage to know which value you have to put for the fade for the current frame. In this case, the fade color will be Pourcentage * 256.0. CVarArray? VarArray?;This is a class that you don't really need to know. it contains all variables that the user will be modified for your effect. It can be a color, a string, a number. The Add method is the only one really useful. If you want the user can modify the color of your effect. Create a pixel Color variable that contain the color you will use and this variable on the array like this: VarArray?.Add (&Color, "my color"); virtual void Default ();You have to put this function on your effect to initalize your value if the default state. In a class, when you instanciate a variable you can't put the default value on the same line like this (int val=0). so you have to instanciate it first (int val;) and initialize it in this function (val=0;). virtual void Init ();This function contains all the code you need to initialize your effect. For example, load pictures, precalculate your data. virtual void Example ();This function have the same goal as Default but put some example value instead than default value. To understand the difference, if you have an effect that display a picture. Default will put the picture file name to "". the user will have to put the picture he wants. Put if the user wants to see an example of this effect, he'll press the example button and this will call Example function. Your function will for example "mypic.tga" for the picture file name. Like that, the user will see, in one click, the effect. virtual void Play ();This is the main part of your effect. It'will render the effect on the Destination buffer. Put here all your code the effect need for one frame rendering. It's often a double "for" loop on y and x. Don't forget to use the clipping window. virtual void Clear ();This function is called for freeing your effect. If you allocate some array, free them here. };That's all! You don't have to write all these functions if you effect doesn't need it. They have a default behavior. If you effect doesn't allocate buffer, you don't need the Clear function. If your effect doesn't need initialisation, don't write the Init function. A very important thing you have to know about predefined variables is that all the values of these variables can changed on the next frame. For example, Width can be 320 when Pourcentage is 0.0 and be 10 when Pourcentage will be 0.5. It's up to the user to put a spline on the Width value. Scanline is the exception. It will never changed during all the effect. |