# busyme

Members

43

124 Neutral

• Rank
Member
1. ## When does an algorithm turn alive?

When you know your self and understand, then you can develop such AI. Otherwise it just fruitless, it may emulate but never be it no matter how automated it is. So you first you must understand yourself, your inner working, and your "I am" identity then you can talk about this. Other wise like someone here said this "REDUNDANT"!
2. ## WEIRD RENDERS

thank you, I don't know what gotten over me :/
3. ## WEIRD RENDERS

thank you thank you. How would you make box move up and left at same time? My code on movement is this: void move() { //object variables D3DXMATRIX matObj, matScale, matRotate, matTranslate; //Translate the object away from the origin if(KEYDOWN(buffer, DIK_LEFT)) D3DXMatrixTranslation(&matTranslate, position.x-= 5, position.y, position.z); else if (KEYDOWN(buffer, DIK_UP)) D3DXMatrixTranslation(&matTranslate, position.x, position.y+= 5, position.z); else if (KEYDOWN(buffer, DIK_DOWN)) D3DXMatrixTranslation(&matTranslate, position.x, position.y-= 5, position.z); else if (KEYDOWN(buffer, DIK_RIGHT)) D3DXMatrixTranslation(&matTranslate, position.x+= 5, position.y, position.z); D3DXMatrixMultiply(&matObj, &matTranslate, &matRotate); }
4. ## WEIRD RENDERS

Oh thank you so much, now why when you don't clear the Z buffer it does this? Does it simply overwrite infinitely?
5. ## WEIRD RENDERS

Here the picture using imageshack.us [url=http://imageshack.us][img=http://img525.imageshack.us/img525/5397/35qt.png][/url] I am also trying to post image yet it's not showing it in forum. Why? Why is it doing this, notice these are just 3D solid shapes.
6. ## WEIRD RENDERS

OK, so I set up the depth buffer, and it doing rendering really weird whats happening? http://rapidshare.de/files/9825926/3.bmp.html bool initDirect3D(HWND hwnd) { if( NULL == ( pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) return false; D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_COPY; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = SCREEN_HEIGHT; d3dpp.BackBufferWidth = SCREEN_WIDTH; d3dpp.hDeviceWindow = hwnd; if( FAILED( pD3D-&gt;CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice ) ) ) return false; pd3dDevice-&gt;SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(255, 255, 255)); pd3dDevice-&gt;SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); pd3dDevice-&gt;SetRenderState(D3DRS_LIGHTING, FALSE); return true; } whats wrong with my code with depth buffer?
7. ## WEIRD RENDERS

ok I got it Thank you.. Now for the depth buffer how would you turn it on??? [source="cpp"] #include "DXinit.h" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { HRESULT hr; position.x = 0.0f; position.y = 0.0f; position.z = 0.0f; forward.x = 0.0f; forward.y = -164.0f; forward.z = 0.0f; // call our function to init and create our window if (!initWindow(hInstance)) { MessageBox(NULL, "Unable to create window", "ERROR", MB_OK); return false; } if (!initDirect3D(wndHandle)) { MessageBox(NULL, "Unable to init Direct3D", "ERROR", MB_OK); return false; } if (!createCube()) { MessageBox(NULL, "Cube could not be created", "ERROR", MB_OK); return false; } if(!createFloor()) { MessageBox(NULL, "Floor could not be created", "ERROR", MB_OK); return false; } // Create the DirectInput object. hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&g_lpDI, NULL); if FAILED(hr) return FALSE; // Retrieve a pointer to an IDirectInputDevice8 interface hr = g_lpDI->CreateDevice(GUID_SysKeyboard, &g_lpDIDevice, NULL); hr = g_lpDIDevice->SetDataFormat(&c_dfDIKeyboard); if FAILED(hr) { return FALSE; } // Set the cooperative level hr = g_lpDIDevice->SetCooperativeLevel(wndHandle, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE); if FAILED(hr) { return FALSE; } // Get access to the input device. hr = g_lpDIDevice->Acquire(); if FAILED(hr) { return FALSE; } createCamera(1.0f, 1500.0f); // near clip plane, far clip plane moveCamera(D3DXVECTOR3(0.0f, 0.0f, -450.0f)); pointCamera(D3DXVECTOR3(0.0f, 0.0f, 0.0f)); // Main message loop: // Enter the message loop MSG msg; ZeroMemory( &msg, sizeof(msg) ); while( msg.message!=WM_QUIT ) { // check for messages if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } // this is called when no messages are pending else { hr = g_lpDIDevice->GetDeviceState(sizeof(buffer),(LPVOID)&buffer); move(); render(); //renderFloor(); } } if (g_lpDI) { if (g_lpDIDevice) { // Always unacquire device before calling Release(). g_lpDIDevice->Unacquire(); g_lpDIDevice->Release(); g_lpDIDevice = NULL; } g_lpDI->Release(); g_lpDI = NULL; } // release and shutdown Direct3D shutdownDirect3D(); return (int) msg.wParam; } bool initWindow(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = "DirectXExample"; wcex.hIconSm = 0; RegisterClassEx(&wcex); wndHandle = CreateWindow("DirectXExample", "DirectXExample", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL); if (!wndHandle) return false; ShowWindow(wndHandle, SW_SHOW); UpdateWindow(wndHandle); return true; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hWnd, message, wParam, lParam); } bool createFloor(void) { //Initialize three vertices for rendering a triangle CUSTOMVERTEX g_Floor[] = { // 3 { -100.0f, 100.0f, 100.0f, D3DCOLOR_ARGB(0,15,5,255)}, { 100.0f, 100.0f, 100.0f, D3DCOLOR_ARGB(0,15,5,255)}, { -100.0f, 100.0f, -100.0f, D3DCOLOR_ARGB(0,15,5,255)}, { 100.0f, 100.0f, -100.0f, D3DCOLOR_ARGB(0,15,5,255)}, }; // Create the vertex buffer. // Create the vertex buffer. HRESULT hr; hr = pd3dDevice->CreateVertexBuffer(sizeof(g_Floor) * sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &vertexBuffer2, NULL ); if FAILED (hr) return false; // prepare to copy the vertices into the vertex buffer VOID* pFloor; // lock the vertex buffer hr = vertexBuffer2->Lock(0, sizeof(g_Floor), (void**)&pFloor, 0); // check to make sure the vertex buffer can be locked if FAILED (hr) return false; // copy the vertices into the buffer memcpy( pFloor, g_Floor, sizeof(g_Floor) ); // unlock the vertex buffer vertexBuffer2->Unlock(); return true; } bool createCube(void) { // Initialize three vertices for rendering a triangle CUSTOMVERTEX g_Vertices[] = { // 1 { -64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { -64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, // 2 { -64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { -64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, // 3 { -64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { -64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, // 4 { -64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { -64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, // 5 { 64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, // 6 {-64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, {-64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, {-64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, {-64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, }; // Create the vertex buffer. HRESULT hr; hr = pd3dDevice->CreateVertexBuffer(sizeof(g_Vertices) * sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &vertexBuffer, NULL ); if FAILED (hr) return false; // prepare to copy the vertices into the vertex buffer VOID* pVertices; // lock the vertex buffer hr = vertexBuffer->Lock(0, sizeof(g_Vertices), (void**)&pVertices, 0); // check to make sure the vertex buffer can be locked if FAILED (hr) return false; // copy the vertices into the buffer memcpy( pVertices, g_Vertices, sizeof(g_Vertices) ); // unlock the vertex buffer vertexBuffer->Unlock(); return true; } bool initDirect3D(HWND hwnd) { if( NULL == ( pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) return false; D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = SCREEN_HEIGHT; d3dpp.BackBufferWidth = SCREEN_WIDTH; d3dpp.hDeviceWindow = hwnd; if( FAILED( pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice ) ) ) return false; pd3dDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(255, 255, 255)); pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); return true; } void shutdownDirect3D(void) { if( pd3dDevice != NULL) { pd3dDevice->Release(); pd3dDevice = NULL; } if( pD3D != NULL) { pD3D->Release(); pD3D = NULL; } } /************************************************************************* * createCamera * creates a virtual camera *************************************************************************/ void createCamera(float nearClip, float farClip) { //Here we specify the field of view, aspect ration and near and far clipping planes. D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4, 640/480, nearClip, farClip); pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj); } /************************************************************************* * moveCamera * moves the camera to a position specified by the vector passed as a * parameter *************************************************************************/ void moveCamera(D3DXVECTOR3 vec) { cameraPosition = vec; } /************************************************************************* * pointCamera * points the camera a location specified by the passed vector *************************************************************************/ void pointCamera(D3DXVECTOR3 vec) { cameraLook = vec; D3DXMatrixLookAtLH(&matView, &cameraPosition, //Camera Position &cameraLook, //Look At Position &D3DXVECTOR3(0.0f, 1.0f, 0.0f)); //Up Direction pd3dDevice->SetTransform(D3DTS_VIEW, &matView); } void render() { // Clear the backbuffer to a black color pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255,255,255), 1.0f, 0 ); pd3dDevice->BeginScene(); pd3dDevice->SetStreamSource( 0, vertexBuffer, 0, sizeof(CUSTOMVERTEX) ); pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); //object variables D3DXMATRIX matObj, matScale, matRotate, matTranslate; D3DXMatrixTranslation(&matTranslate, position.x, position.y, position.z); // set the rotation D3DXMatrixRotationY (&matRotate, D3DXToRadian(45)); // set the scaling ///D3DXMatrixScaling(&matScale, 1.0f, 1.0f, 1.0f); // multiple the scaling and rotation matrices to create the meshMat matrix D3DXMatrixMultiply(&matObj, &matTranslate, &matRotate); // transform the object in world space pd3dDevice->SetTransform(D3DTS_WORLD, &matObj); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 4, 2 ); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 8, 2 ); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 12, 2 ); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 16, 2 ); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 20, 2 ); pd3dDevice->SetStreamSource( 0, vertexBuffer2, 0, sizeof(CUSTOMVERTEX) ); D3DXMatrixTranslation(&matTranslate, forward.x, forward.y, forward.z); // set the rotation D3DXMatrixRotationY (&matRotate, D3DXToRadian(45)); // set the scaling ///D3DXMatrixScaling(&matScale, 1.0f, 1.0f, 1.0f); // multiple the scaling and rotation matrices to create the meshMat matrix D3DXMatrixMultiply(&matObj, &matTranslate, &matRotate); // transform the object in world space pd3dDevice->SetTransform(D3DTS_WORLD, &matObj); pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); pd3dDevice->EndScene(); // Present the backbuffer contents to the display pd3dDevice->Present( NULL, NULL, NULL, NULL ); } void move() { //object variables D3DXMATRIX matObj, matScale, matRotate, matTranslate; //Translate the object away from the origin if(KEYDOWN(buffer, DIK_LEFT)) D3DXMatrixTranslation(&matTranslate, position.x-= 5, position.y, position.z); else if (KEYDOWN(buffer, DIK_UP)) D3DXMatrixTranslation(&matTranslate, position.x, position.y+= 5, position.z); else if (KEYDOWN(buffer, DIK_DOWN)) D3DXMatrixTranslation(&matTranslate, position.x, position.y-= 5, position.z); else if (KEYDOWN(buffer, DIK_RIGHT)) D3DXMatrixTranslation(&matTranslate, position.x+= 5, position.y, position.z); D3DXMatrixMultiply(&matObj, &matTranslate, &matRotate); } anything wrong with my code?
8. ## WEIRD RENDERS

source tags man I forgot I havn't been on this site for a while. [TAG] This one?? [/TAG] Thats what I thought, so how you would you set up depth buffer? Merry Christmas + Happy New Year
9. ## WEIRD RENDERS

I am curious Why does it do this? I rendered a cube and a floor, first a cube then are floor. http://rapidshare.de/files/9789162/1.bmp.html http://rapidshare.de/files/9789207/2.bmp.html here is my code --------------------------------------------------------------------------- #include "DXinit.h" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { HRESULT hr; position.x = 0.0f; position.y = 0.0f; position.z = 0.0f; forward.x = 0.0f; forward.y = -164.0f; forward.z = 0.0f; // call our function to init and create our window if (!initWindow(hInstance)) { MessageBox(NULL, "Unable to create window", "ERROR", MB_OK); return false; } if (!initDirect3D(wndHandle)) { MessageBox(NULL, "Unable to init Direct3D", "ERROR", MB_OK); return false; } if (!createCube()) { MessageBox(NULL, "Cube could not be created", "ERROR", MB_OK); return false; } if(!createFloor()) { MessageBox(NULL, "Floor could not be created", "ERROR", MB_OK); return false; } // Create the DirectInput object. hr = DirectInput8Create(hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&g_lpDI, NULL); if FAILED(hr) return FALSE; // Retrieve a pointer to an IDirectInputDevice8 interface hr = g_lpDI-&gt;CreateDevice(GUID_SysKeyboard, &g_lpDIDevice, NULL); hr = g_lpDIDevice-&gt;SetDataFormat(&c_dfDIKeyboard); if FAILED(hr) { return FALSE; } // Set the cooperative level hr = g_lpDIDevice-&gt;SetCooperativeLevel(wndHandle, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE); if FAILED(hr) { return FALSE; } // Get access to the input device. hr = g_lpDIDevice-&gt;Acquire(); if FAILED(hr) { return FALSE; } createCamera(1.0f, 1500.0f); // near clip plane, far clip plane moveCamera(D3DXVECTOR3(0.0f, 0.0f, -450.0f)); pointCamera(D3DXVECTOR3(0.0f, 0.0f, 0.0f)); // Main message loop: // Enter the message loop MSG msg; ZeroMemory( &msg, sizeof(msg) ); while( msg.message!=WM_QUIT ) { // check for messages if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } // this is called when no messages are pending else { hr = g_lpDIDevice-&gt;GetDeviceState(sizeof(buffer),(LPVOID)&buffer); move(); render(); //renderFloor(); } } if (g_lpDI) { if (g_lpDIDevice) { // Always unacquire device before calling Release(). g_lpDIDevice-&gt;Unacquire(); g_lpDIDevice-&gt;Release(); g_lpDIDevice = NULL; } g_lpDI-&gt;Release(); g_lpDI = NULL; } // release and shutdown Direct3D shutdownDirect3D(); return (int) msg.wParam; } bool initWindow(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = "DirectXExample"; wcex.hIconSm = 0; RegisterClassEx(&wcex); wndHandle = CreateWindow("DirectXExample", "DirectXExample", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL); if (!wndHandle) return false; ShowWindow(wndHandle, SW_SHOW); UpdateWindow(wndHandle); return true; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hWnd, message, wParam, lParam); } bool createFloor(void) { //Initialize three vertices for rendering a triangle CUSTOMVERTEX g_Floor[] = { // 3 { -100.0f, 100.0f, 100.0f, D3DCOLOR_ARGB(0,15,5,255)}, { 100.0f, 100.0f, 100.0f, D3DCOLOR_ARGB(0,15,5,255)}, { -100.0f, 100.0f, -100.0f, D3DCOLOR_ARGB(0,15,5,255)}, { 100.0f, 100.0f, -100.0f, D3DCOLOR_ARGB(0,15,5,255)}, }; // Create the vertex buffer. // Create the vertex buffer. HRESULT hr; hr = pd3dDevice-&gt;CreateVertexBuffer(sizeof(g_Floor) * sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &vertexBuffer2, NULL ); if FAILED (hr) return false; // prepare to copy the vertices into the vertex buffer VOID* pFloor; // lock the vertex buffer hr = vertexBuffer2-&gt;Lock(0, sizeof(g_Floor), (void**)&pFloor, 0); // check to make sure the vertex buffer can be locked if FAILED (hr) return false; // copy the vertices into the buffer memcpy( pFloor, g_Floor, sizeof(g_Floor) ); // unlock the vertex buffer vertexBuffer2-&gt;Unlock(); return true; } bool createCube(void) { // Initialize three vertices for rendering a triangle CUSTOMVERTEX g_Vertices[] = { // 1 { -64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { -64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, // 2 { -64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { -64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, // 3 { -64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { -64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, // 4 { -64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { -64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, // 5 { 64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, { 64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, // 6 {-64.0f, 64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, {-64.0f, -64.0f, -64.0f, D3DCOLOR_ARGB(0,100,100,100)}, {-64.0f, 64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, {-64.0f, -64.0f, 64.0f, D3DCOLOR_ARGB(0,100,100,100)}, }; // Create the vertex buffer. HRESULT hr; hr = pd3dDevice-&gt;CreateVertexBuffer(sizeof(g_Vertices) * sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &vertexBuffer, NULL ); if FAILED (hr) return false; // prepare to copy the vertices into the vertex buffer VOID* pVertices; // lock the vertex buffer hr = vertexBuffer-&gt;Lock(0, sizeof(g_Vertices), (void**)&pVertices, 0); // check to make sure the vertex buffer can be locked if FAILED (hr) return false; // copy the vertices into the buffer memcpy( pVertices, g_Vertices, sizeof(g_Vertices) ); // unlock the vertex buffer vertexBuffer-&gt;Unlock(); return true; } bool initDirect3D(HWND hwnd) { if( NULL == ( pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) return false; D3DPRESENT_PARAMETERS d3dpp; ZeroMemory( &d3dpp, sizeof(d3dpp) ); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = SCREEN_HEIGHT; d3dpp.BackBufferWidth = SCREEN_WIDTH; d3dpp.hDeviceWindow = hwnd; if( FAILED( pD3D-&gt;CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice ) ) ) return false; pd3dDevice-&gt;SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(255, 255, 255)); pd3dDevice-&gt;SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); pd3dDevice-&gt;SetRenderState(D3DRS_LIGHTING, FALSE); return true; } void shutdownDirect3D(void) { if( pd3dDevice != NULL) { pd3dDevice-&gt;Release(); pd3dDevice = NULL; } if( pD3D != NULL) { pD3D-&gt;Release(); pD3D = NULL; } } /************************************************************************* * createCamera * creates a virtual camera *************************************************************************/ void createCamera(float nearClip, float farClip) { //Here we specify the field of view, aspect ration and near and far clipping planes. D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4, 640/480, nearClip, farClip); pd3dDevice-&gt;SetTransform(D3DTS_PROJECTION, &matProj); } /************************************************************************* * moveCamera * moves the camera to a position specified by the vector passed as a * parameter *************************************************************************/ void moveCamera(D3DXVECTOR3 vec) { cameraPosition = vec; } /************************************************************************* * pointCamera * points the camera a location specified by the passed vector *************************************************************************/ void pointCamera(D3DXVECTOR3 vec) { cameraLook = vec; D3DXMatrixLookAtLH(&matView, &cameraPosition, //Camera Position &cameraLook, //Look At Position &D3DXVECTOR3(0.0f, 1.0f, 0.0f)); //Up Direction pd3dDevice-&gt;SetTransform(D3DTS_VIEW, &matView); } void render() { // Clear the backbuffer to a black color pd3dDevice-&gt;Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255,255,255), 1.0f, 0 ); pd3dDevice-&gt;BeginScene(); pd3dDevice-&gt;SetStreamSource( 0, vertexBuffer, 0, sizeof(CUSTOMVERTEX) ); pd3dDevice-&gt;SetFVF( D3DFVF_CUSTOMVERTEX ); //object variables D3DXMATRIX matObj, matScale, matRotate, matTranslate; D3DXMatrixTranslation(&matTranslate, position.x, position.y, position.z); // set the rotation D3DXMatrixRotationY (&matRotate, D3DXToRadian(45)); // set the scaling ///D3DXMatrixScaling(&matScale, 1.0f, 1.0f, 1.0f); // multiple the scaling and rotation matrices to create the meshMat matrix D3DXMatrixMultiply(&matObj, &matTranslate, &matRotate); // transform the object in world space pd3dDevice-&gt;SetTransform(D3DTS_WORLD, &matObj); pd3dDevice-&gt;DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); pd3dDevice-&gt;DrawPrimitive( D3DPT_TRIANGLESTRIP, 4, 2 ); pd3dDevice-&gt;DrawPrimitive( D3DPT_TRIANGLESTRIP, 8, 2 ); pd3dDevice-&gt;DrawPrimitive( D3DPT_TRIANGLESTRIP, 12, 2 ); pd3dDevice-&gt;DrawPrimitive( D3DPT_TRIANGLESTRIP, 16, 2 ); pd3dDevice-&gt;DrawPrimitive( D3DPT_TRIANGLESTRIP, 20, 2 ); pd3dDevice-&gt;SetStreamSource( 0, vertexBuffer2, 0, sizeof(CUSTOMVERTEX) ); D3DXMatrixTranslation(&matTranslate, forward.x, forward.y, forward.z); // set the rotation D3DXMatrixRotationY (&matRotate, D3DXToRadian(45)); // set the scaling ///D3DXMatrixScaling(&matScale, 1.0f, 1.0f, 1.0f); // multiple the scaling and rotation matrices to create the meshMat matrix D3DXMatrixMultiply(&matObj, &matTranslate, &matRotate); // transform the object in world space pd3dDevice-&gt;SetTransform(D3DTS_WORLD, &matObj); pd3dDevice-&gt;DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 ); pd3dDevice-&gt;EndScene(); // Present the backbuffer contents to the display pd3dDevice-&gt;Present( NULL, NULL, NULL, NULL ); } void move() { //object variables D3DXMATRIX matObj, matScale, matRotate, matTranslate; //Translate the object away from the origin if(KEYDOWN(buffer, DIK_LEFT)) D3DXMatrixTranslation(&matTranslate, position.x-= 5, position.y, position.z); else if (KEYDOWN(buffer, DIK_UP)) D3DXMatrixTranslation(&matTranslate, position.x, position.y+= 5, position.z); else if (KEYDOWN(buffer, DIK_DOWN)) D3DXMatrixTranslation(&matTranslate, position.x, position.y-= 5, position.z); else if (KEYDOWN(buffer, DIK_RIGHT)) D3DXMatrixTranslation(&matTranslate, position.x+= 5, position.y, position.z); D3DXMatrixMultiply(&matObj, &matTranslate, &matRotate); } ------------------------------------------------------------------------------- Why is it doing this, why the last thing being rendered is always on top of the last even though they intersect each other? [Edited by - busyme on December 25, 2005 5:55:15 PM]
10. ## alpha sprites still wont work

i tried png, and this is 32 bit Alpha channel bmp saved as A8R8G8B8
11. ## alpha sprites still wont work

my initDirect3D looks like this.. [SOURCE] bool initDirect3D(void) { pD3D = NULL; pd3dDevice = NULL; if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION))) { lastResult = E_FAIL; return false; } D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = 480; d3dpp.BackBufferWidth = 640; d3dpp.hDeviceWindow = wndHandle; if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, wndHandle, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice))) { lastResult = E_FAIL; return false; } return true; } [/SOURCE][/source] where should I the ALPHABLENDENABLE or where should I ID3DXSprite functions?
12. ## alpha sprites still wont work

maybe ID3DXSprite library will help so i included ID3DXSprite spDraw; then i included spDraw->Begin(D3DXSPRITE_ALPHABLEND); the thing is that i can't compile the Begin function what am i missing here
13. ## alpha sprites still wont work

how do I post my code in seperate window? I just don't understand, thank you for your feedback and help but it's still not working. I will include my code here... CPP [SOURCE] #include <windows.h> #include <d3d9.h> #include <d3dx9.h> #include <string> HRESULT lastResult; LPDIRECT3D9 pD3D; LPDIRECT3DDEVICE9 pd3dDevice; IDirect3DSurface9* bkgrd; IDirect3DSurface9* sprite; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); bool initDirect3D(void); bool initSprites(void); void render(void); IDirect3DSurface9* getSurfaceFromBitmap(std::string filename); IDirect3DSurface9* getSpriteFromBitmap(std::string filename); #define SPRITE_WIDTH 64 #define SPRITE_HEIGHT 23 #define SCRN_WIDTH 640 #define SCRN_HEIGHT 480 #define MAX_SPRITES 10 struct { RECT srcRect; //position int posX; int posY; int moveX; int moveY; int numFrames; int curFrame; }spriteStruct[MAX_SPRITES]; HINSTANCE hInst; HWND wndHandle; bool initWindow(HINSTANCE hInstance); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { if(!initWindow(hInstance)) return false; if(!initDirect3D()) return false; if(!initSprites()) return false; bkgrd = getSurfaceFromBitmap("./bkgrd.bmp"); sprite = getSpriteFromBitmap("./fishes.bmp"); MSG msg; ZeroMemory(&msg, sizeof(msg)); while(msg.message!=WM_QUIT) { if(PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { render(); } } if(pd3dDevice != NULL) { pd3dDevice->Release(); pd3dDevice = NULL; } if(pD3D != NULL) { pD3D->Release(); pD3D = NULL; } return (int) msg.wParam; } bool initWindow(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style =CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc =(WNDPROC)WndProc; wcex.cbClsExtra =0; wcex.cbWndExtra =0; wcex.hInstance =hInstance; wcex.hIcon =0; wcex.hCursor =LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground =(HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName =NULL; wcex.lpszClassName ="DirectXExample"; wcex.hIconSm =0; RegisterClassEx(&wcex); wndHandle = CreateWindow( "DirectXExample", "DirectXExample", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, SCRN_WIDTH, SCRN_HEIGHT, NULL, NULL, hInstance, NULL); if(!wndHandle) return false; ShowWindow(wndHandle, SW_SHOW); UpdateWindow(wndHandle); return true; } bool initDirect3D(void) { pD3D = NULL; pd3dDevice = NULL; if(NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION))) { lastResult = E_FAIL; return false; } D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; d3dpp.BackBufferCount = 1; d3dpp.BackBufferHeight = 480; d3dpp.BackBufferWidth = 640; d3dpp.hDeviceWindow = wndHandle; if(FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, wndHandle, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice))) { lastResult = E_FAIL; return false; } return true; } bool initSprites(void) { for(int i = 0; i < MAX_SPRITES; i++) { spriteStruct[i].srcRect.top = 0; spriteStruct[i].srcRect.left = i * SPRITE_WIDTH; spriteStruct[i].srcRect.right = spriteStruct[i].srcRect.left + SPRITE_WIDTH; spriteStruct[i].srcRect.bottom = SPRITE_HEIGHT; spriteStruct[i].posX = rand()% SCRN_WIDTH - SPRITE_WIDTH; spriteStruct[i].posY = rand()% SCRN_HEIGHT - SPRITE_HEIGHT; spriteStruct[i].curFrame = 0; spriteStruct[i].numFrames = 4; spriteStruct[i].moveX = 1; spriteStruct[i].moveY = 0; } return true; } IDirect3DSurface9* getSurfaceFromBitmap(std::string filename) { HRESULT hResult; IDirect3DSurface9* surface = NULL; D3DXIMAGE_INFO imageInfo; hResult = D3DXGetImageInfoFromFile(filename.c_str(), &imageInfo); if (FAILED(hResult)) return NULL; hResult = pd3dDevice->CreateOffscreenPlainSurface(imageInfo.Width, imageInfo.Height, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL); if(FAILED(hResult)) return NULL; hResult = D3DXLoadSurfaceFromFile(surface, NULL, NULL, filename.c_str(), NULL, D3DX_DEFAULT, 0, NULL); if(FAILED(hResult)) return NULL; return surface; } IDirect3DSurface9* getSpriteFromBitmap(std::string filename) { HRESULT hResult; IDirect3DSurface9* surface = NULL; D3DXIMAGE_INFO imageInfo; hResult = D3DXGetImageInfoFromFile(filename.c_str(), &imageInfo); if(FAILED(hResult)) return NULL; hResult = pd3dDevice->CreateOffscreenPlainSurface(imageInfo.Width, imageInfo.Height, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL); if(FAILED(hResult)) return NULL; hResult = D3DXLoadSurfaceFromFile(surface, NULL, NULL, filename.c_str(), NULL, D3DX_DEFAULT, 0, NULL); if(FAILED(hResult)) return NULL; return surface; } void render(void) { IDirect3DSurface9* backbuffer = NULL; if(NULL == pd3dDevice) return; pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0); pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer); pd3dDevice->StretchRect(bkgrd, NULL, backbuffer, NULL, D3DTEXF_NONE); for(int i = 0; i < 10; i++) { if(spriteStruct[i].curFrame < spriteStruct[i].numFrames-1) spriteStruct[i].curFrame++; else spriteStruct[i].curFrame = 0; spriteStruct[i].srcRect.left = spriteStruct[i].curFrame * SPRITE_WIDTH; spriteStruct[i].srcRect.right = spriteStruct[i].srcRect.left + SPRITE_WIDTH; RECT destRect; destRect.left = spriteStruct[i].posX; destRect.top = spriteStruct[i].posY; destRect.bottom = destRect.top + SPRITE_HEIGHT; destRect.right = destRect.left + SPRITE_WIDTH; spriteStruct[i].posX += spriteStruct[i].moveX; if(spriteStruct[i].posX > SCRN_WIDTH - SPRITE_WIDTH) { spriteStruct[i].moveX *= -1; } else if(spriteStruct[i].posX < 0) { spriteStruct[i].moveX *= -1; } spriteStruct[i].posY += spriteStruct[i].moveY; if(spriteStruct[i].posY > SCRN_HEIGHT - SPRITE_HEIGHT) { spriteStruct[i].moveY *= -1; } else if(spriteStruct[i].posY < 0) { spriteStruct[i].moveY *= -1; } pd3dDevice->StretchRect(sprite, &spriteStruct[i].srcRect, backbuffer, &destRect, D3DTEXF_NONE); } pd3dDevice->Present(NULL, NULL, NULL, NULL); } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hWnd, message, wParam, lParam); } [/SOURCE][/source][/source] THATS it, notice that i removed the ALPHATESTENABLE because they don't work, I tried in initDirect3D and it won't let me compile. If I put it in other functions it will let me compile but it doesn't do anything. [Edited by - busyme on August 30, 2005 1:03:42 AM]
14. ## alpha sprites still wont work

now that i tried what you asked, it still doesn't work. Compiler accepts them anywhere but in initDirect3D function, just weird! it doesn't work with setTextureStageState also for an info this is 2D image. just plain image of a fish and i want the background to be INVISIBLE!!!! how do you accomplish such a feat?
15. ## alpha sprites still wont work

what am I doing wrong here?