Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Sh@dow

Member Since 02 Sep 2009
Offline Last Active Oct 16 2014 09:18 AM

Topics I've Started

How object coordinates are tracked in game engines?

10 October 2014 - 10:54 AM

Hi all,
 
My question is more about the general game engine design concept rather than particular case.
 
There are many objects in the scene and for some of them the coordinates must be known
after they are rotated and translated. They are necessary to track collisions for instance.
 
The problem is that graphics libraries hide theese coordinates inside after transformation. For instance in OpenGL after we perform glTranslate/glRotate functions the current matrix holds all transformations but vertexes are multiplied to it internally when we pass vertexes into OpenGL.
 
It is interesting to me how the object coordinates tracked in the game engine?
 
There are several ways to do that. 
 
The first one is to use glTranslate/glRotate for positioning objects and transformating the vertexes additionally in the engine code. The disadvantage of this approach is that two the same transformations are done.
 
Another way is not to use glTranslate/glRotate but do all the transformations manually and pass to the OpengGL library already transformed vertexes.
 
Are there any other ways?

[DX8] GetDeviceState for joystick

02 August 2011 - 04:12 PM

Hi everyone,
I'm using DirectInput to read joystick state. Especially i need button states. Here is the code.

BOOL CALLBACK
enumCallback(const DIDEVICEINSTANCE* instance, VOID* context)
{
    HRESULT result;
    result = di->CreateDevice(instance->guidInstance, &joystick, NULL);
    if (FAILED(result)) { 
        return DIENUM_STOP;
    }
    return DIENUM_CONTINUE;
}

bool EnumerateDevices()
{
if (FAILED(result = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, 
                               	IID_IDirectInput8, (VOID**)&di, NULL))) 
	{
		return false;
	}
	if (FAILED(result = di->EnumDevices(DI8DEVCLASS_GAMECTRL, enumCallback,
                                NULL, DIEDFL_ATTACHEDONLY))) {
    return false;
	}
}

//////////////////MAIN CODE////////////////////
if (joystick == NULL) {
    OutputDebugString(L"JOYSTIC NOT FOUND\n");
    return false;
}

DIDEVCAPS capabilities;

if (FAILED(result = joystick->SetDataFormat(&c_dfDIJoystick))) 
{
	OutputDebugString(L"ERROR\n");
    return;
}

if (FAILED(result = joystick->SetCooperativeLevel(dlg_handle, DISCL_NONEXCLUSIVE |
                                              DISCL_BACKGROUND))) 
{
	OutputDebugString(L"ERROR\n");
    return;
}
capabilities.dwSize = sizeof(DIDEVCAPS);
if (FAILED(result = joystick->GetCapabilities(&capabilities))) 
{
	OutputDebugString(L"ERROR\n");
    return;
}
// this structure holds the data for the property changes
DIPROPRANGE joy_axis_range;
// first set x axis tp -1024 to 1024
joy_axis_range.lMin = -1024;
joy_axis_range.lMax = 1024;

joy_axis_range.diph.dwSize   	= sizeof(DIPROPRANGE);
joy_axis_range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
joy_axis_range.diph.dwObj  = DIJOFS_X;
joy_axis_range.diph.dwHow = DIPH_BYOFFSET;
joystick->SetProperty(DIPROP_RANGE,&joy_axis_range.diph);

// now y-axis
joy_axis_range.lMin = -1024;
joy_axis_range.lMax = 1024;
joy_axis_range.diph.dwSize   	= sizeof(DIPROPRANGE);
joy_axis_range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
joy_axis_range.diph.dwObj        = DIJOFS_Y;
joy_axis_range.diph.dwHow        = DIPH_BYOFFSET;
joystick->SetProperty(DIPROP_RANGE,&joy_axis_range.diph);
    
if (joystick == NULL) {
   	OutputDebugString(L"Joystic not found\n");
    }
	result = joystick->Acquire();
	if (FAILED(result = joystick->GetDeviceState(sizeof(DIJOYSTATE), &js))) {
        OutputDebugString(L"The device should have been acquired during the Poll()\n");
		return; 
    }

    joystick->Unacquire();
	joystick->Release();

In EnumDevice i see that the joystic is found. In GetCapabilities function i see the correct parameters of the joystick. When I say Poll the result is DI_NOEFFECT. Sho i removed Poll method. Acquire returns no errors. But after i say GetDeviceState the rgbButtons are zeros even if i press buttons.
The program is dialog based. In CooperativeLevel i pass the handle of the dialog. Where is the problem? Why buttons are not readed?
Thanks,

Create 2D model in 3ds max

12 July 2011 - 10:07 AM

Hi all,

I'm developing a simple game (2D) and i need to draw a model.
Is it possible to draw a model on a plane in 3ds max using primitives(circle,oval) and export vertex coordinates to a file? How could i do this?
I see that 3ds max works only in 3D.
Thanks,

Lesson 43: How texture is rendered

17 June 2011 - 05:27 AM

In Lesson 43 to render a texture from free type font we are saying:

glBegin(GL_QUADS);
	glTexCoord2d(0,0); glVertex2d(0,bitmap.rows);
	glTexCoord2d(0,y); glVertex2d(0,0);

	glTexCoord2d(x,y); glVertex2d(bitmap.width,0);
	glTexCoord2d(x,0); glVertex2d(bitmap.width,bitmap.rows);

I can't understand what does this code do? We are drawing here two quads: first has all x = 0; What does this supposed to mean?
Thanks.

Several Graphics in single window

19 March 2011 - 02:34 PM

Hi, everyone
I need to plot different types of graphics in one window. I'm using C++ language on Win platform.
My problem is that i can't correctly imagine a whole program architecture.
I have several objects each one draws the specific types of graph(signal, 2d matrix). These objects expect device context as a parameter. But if i have only one window that means i have only one device context. As i understand the device context could not be divided into areas to draw separately into them. I can draw into the whole device context at one time. That's a problem to me because i can't redraw graphics independently.Imagine we have two graphics. When new data comes for graph1 i want to redraw it (not the entire window area and other graph2) so i can't do that.Or maybe i can?:D Is there any way to redraw only part of the window.Some kind of incremental drawing?

PARTNERS