Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Meduusa

Pages: [1]
1
Am I doing this right

first I create a window like
Code: [Select]
hWnd = CreateWindowEx(NULL, L"WindowClass", L"test",
                          WS_OVERLAPPED, 0, 0, 1024, 768,
                          NULL, NULL, hInstance, NULL);

Then I create device like
Code: [Select]
    d3d = Direct3DCreate9(D3D_SDK_VERSION);

    D3DPRESENT_PARAMETERS d3dpp;

    ZeroMemory(&d3dpp, sizeof(d3dpp));
    d3dpp.Windowed = true;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.hDeviceWindow = hWnd;
    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
    d3dpp.BackBufferWidth = 1024;
    d3dpp.BackBufferHeight = 768;

    d3d->CreateDevice(D3DADAPTER_DEFAULT,
                      D3DDEVTYPE_HAL,
                      hWnd,
                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                      &d3dpp,
                      &d3ddev);

And i have
Code: [Select]
D3DXMATRIX matRotateY;

static float index = 0.0f; index+=0.05f;
D3DXMatrixRotationY(&matRotateY, index);
d3ddev->SetTransform(D3DTS_WORLD, &matRotateY);

D3DXMATRIX matView;
D3DXMatrixLookAtLH(&matView,
                       &D3DXVECTOR3 (0.0f, 0.0f, 10.0f),
                       &D3DXVECTOR3 (0.0f, 0.0f, 0.0f),
                       &D3DXVECTOR3 (0.0f, 1.0f, 0.0f));
d3ddev->SetTransform(D3DTS_VIEW, &matView);

D3DXMATRIX matProjection;
D3DXMatrixPerspectiveFovLH(&matProjection,
                               D3DXToRadian(45),
                               589824.0f,                            //is this right?
                               1.0f,
                               100.0f);
d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection);

How do I add black lines since they dont come automatically?

2
Mayby I can explain myselve a litte better. If I design a program to use a 1280x720 resolution (aspec ratio 16:9) but I give user an opportunity to run a program in 1024x768 (aspect ratio 4:3). I still want to forse users to use 16:9 aspect ratio in 1024x768 mode and i can do that by adding borders to tom and bottomm but how do I add them?

3
I dont understand source code of those examples since they are c# and vb and i would prefere c++ or c sample

but looking at those they wont still add black lines to top and bottom if I would scale window

4
How can I achieve letterboxing in directx so that my graphics wont get stretched with differet aspect ratios?

5
General chat / Re: The futer of 256 :(
« on: June 02, 2008 »
Whats wrong with dosbox i know it dosent run all the intros at the moment but its getting better and better all the time.
Personally I use a qemu with MSDOS-6.22 and Win98 installed and Ive been able to run most dos demos Ive tried and it dosent take even much resources about 14mb whitout virtual disk.

6
Ahh sorry for my previous post apparantly I have to modify value of position not center I dont really understand why center doesnt work but I got it working by modifying position. :)

BIG thanks to everybody who helped me throught this I wont forget you.

7
Yep I got i working
Code: [Select]

for(int x=0; x<5; x++)  // 5 times 5 is 25
{
for(int y=0; y<5; y++)
{
lockedarea[x+y * offset / 4] = 0x00000000;  // if I do this shouldnt this produce a square but instead it produces a line that is 25
}
}

But now Im noticed that Im having trouble with Z-Buffering. I use this code to draw tiles
Code: [Select]
D3DXVECTOR3 center(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 position(50.0f, 50.0f, 1.0f);
d3dspt->Draw(Texture1, NULL, &center, &position, D3DCOLOR_ARGB(alph, 255, 255, 255));

when i set Z value of position to anything non 0 my tile dosent apper

I have enabled and cleared Z-Buffer by
Code: [Select]
d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE); //this one is in init function
d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); // and this one in rendering function

Might the problem be that Im trying to draw a sprite interface (d3dspt) and not to the d3ddev? Can I enable Z-Buffering to sprite interface or is there a way to overcome this problem?

8
Yeah I almost solved this one.

Heres the code

Code: [Select]

D3DXCreateTextureFromFileEx(d3ddev,    // the device pointer
                                L"image.png",    // the new file name
                                D3DX_DEFAULT,    // default width
                                D3DX_DEFAULT,    // default height
                                D3DX_DEFAULT,    // no mip mapping
                                NULL,
                                D3DFMT_A8R8G8B8,    // 32-bit pixels with alpha
                                D3DPOOL_MANAGED,    // typical memory handling
                                D3DX_DEFAULT,    // no filtering
                                D3DX_DEFAULT,    // no mip filtering
                                D3DCOLOR_XRGB(255, 0, 255),    // the hot-pink color key
                                NULL,    // no image info struct
                                NULL,    // not using 256 colors
                                &Texture);    // load to sprite

RECT area;
D3DLOCKED_RECT LockedRect;

SetRect(&area, 40, 40, 45, 45);    // area is 5 x 5
Texture->LockRect(0, &LockedRect, &area, 0); // lock target area

DWORD *lockedarea = (DWORD *)LockedRect.pBits;

for(int i=0; i<25; i++)  // 5 times 5 is 25
{
lockedarea[i] = 0x00000000;  // if I do this shouldnt this produce a square but instead it produces a line that is 25
                                                       // (pixels?) long
}

Texture->UnlockRect(0);

Some other interesting issues when I try
Code: [Select]
lockedarea[i] = 0xFFFF00FF; it produses a hot-pink line but if pink is a color-key shouldnt it be then transparent but well I can just set alpha color to 0 and dont bother whit this.

But still why this produces a line instead of square whats wrong? My SetRect() is wrong or LockRect() or maybe Im drawing it wrong?

9
Big thanks rain_storm I will try to this out.

First I allocate memory for texture and load it

Code: [Select]
LPDIRECT3DTEXTURE9 sprite;    // the pointer to the sprite

D3DXCreateTextureFromFileEx(d3ddev,    // the device pointer
                                L"Panel2.png",    // file name to load texture from
                                D3DX_DEFAULT,    // default width
                                D3DX_DEFAULT,    // default height
                                D3DX_DEFAULT,    // no mip mapping
                                NULL,    // regular usage
                                D3DFMT_A8R8G8B8,    // 32-bit pixels with alpha
                                D3DPOOL_MANAGED,    // typical memory handling
                                D3DX_DEFAULT,    // no filtering
                                D3DX_DEFAULT,    // no mip filtering
                                D3DCOLOR_XRGB(255, 0, 255),    // the hot-pink color key
                                NULL,    // no image info struct
                                NULL,    // not using 256 colors
&sprite);    // load to sprite

2. Im not sure if Im doing this next step right

Code: [Select]
        RECT area;
D3DLOCKED_RECT area2;

SetRect(&area, 10, 10, 30, 30);  // I define area to be 20 x 20 big area from sprite
sprite->LockRect(0, &area2, &area, D3DLOCK_DISCARD); // and then I lock it

How can I access that area
can i now use sprite as a pointer and plot thing to it like

Code: [Select]
for (int i = 0; i < 30 * 30; i++)
{
    &sprite[i] = D3DCOLOR_XRGB(255, 0, 255);  // this dosent work
}

10
Works in here NV8800GTS vista home premium

11
BIG thanks to every one who ansewered I will continue working on this.

But how can i turn part of tile to transparent to see other tile under it? Can I somehow access pixels in texture and set some of them to alpha or set them match color key which will make them transparent? Or can I create 2D array copy correct data to it and then load it as a texture?

12
In ASD - Metamorphosis demo http://www.pouet.net/prod.php?which=50127 when the lines are drawn and ants run inside of lines how can this line drawing be achievend in directx? Im trying to make a scroller demo like Metamorphosis and I thing tiles is a way to go. Lets say I have a tile1 of size 512x512 under tile2 and tile2 of size 200x200 exactly in center over tile1. How can I draw a vertical line throught tile2 and see tile1 throught it?

Im very sorry for my bad english.

Pages: [1]