Jump to content
  • Advertisement

Pero83

Member
  • Content Count

    20
  • Joined

  • Last visited

Community Reputation

102 Neutral

About Pero83

  • Rank
    Member
  1. Pero83

    Wavefront Obj format

    I'm new myself, and was recently also going into OBJ import. In used Maya to triangulate mesh, but you can do that in almost any app nowdays, so it would probably be best to triangulate and then import, i find it easier to work that way.
  2. Ok tnx a lot, i think i understand it now!
  3. Hey all. Got a little problems with understand one thing around constructors. In Frank Luna's Book, author has this class D3Dapp: D3Dapp::D3Dapp(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD verProc) Then he has child class: HelloDirect3D::HelloDirect3D(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD VerProc):D3Dapp(hInstance, winCaption, devType, VerProc) And finally, he creates object of child class: HelloDirect3D mApp(hInstance, "X", D3DDEVTYPE_HAL, D3DCREATE_HARDWARE_VERTEXPROCESSING); Now, i'm having a little problems understand what exactly is going on around here. If i start with object; i create object from HelloDirect3D child class, and give those 4 parameters. But i did not state parameters for parent class ? So when i use hInstance or "X" in object as argument......does it assign them to child class, or parent class, or what? I thought parent's constructor always gets "calculated" first, only then childs. So i'm having problems understand, to wich constructor does those parameters goes? Or, was it, when i created subclass of D3Dapp, and and first declared arguments for childs constructor...those same arguments translated to the parent class with HelloDirect3D::HelloDirect3D(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType2, DWORD VerProc):D3Dapp(hInstance, winCaption, devType2, VerProc) Tnx!
  4. Pero83

    c++ extern command

    Yes, but why would you basicly say that two times?
  5. Pero83

    c++ extern command

    well, that is what is confusing the hell out of me. I'll try to make more simple example. I have: - A.h - B.h - B.cpp B.h has : extern D3DApp* gd3dApp; Do note the EXTERN keyword. Now, B.cpp has D3DApp* gd3dApp = 0; No extern keyword. This, i think, i understand. In B.h, you declare an external variable, wich means, that it is define / initialized somewhere farther in the code or in other file. But what gave me a problem, is that A.h already has the " extern D3DApp* gd3dApp", wich B.h also has. Not definition, but (Extern) declaration. B.h then includes this A.h, and as such, you call extern two times on same variables within same file (while definition is in third file - B.cpp). So if understand Kobo correctly, you don't need to call extern command in B.h, because it includes A.h, wich already did that (as in, it already used extern command on that variable)? And B.cpp actually then defines this varible? tnx all for help btw.
  6. Pero83

    c++ extern command

    even if you include file that already used extern command on the same variable? Looks to me like you would use extern command two times on the same variable, since you already include the first file?
  7. Pero83

    c++ extern command

    Hey all! I was starting to learn Frank Luna's dx9 shader approach book, and i have some problems to understand few things. For example, the extern command. Like this: extern D3DApp* gd3dApp; Now, In first chapters, you have basicly 3 files. - d3dUtil.h - d3dApp.h - d3dApp. now, d3dUtil.h has following lines: // Globals for convenient access. extern D3DApp* gd3dApp; extern IDirect3DDevice9* gd3dDevice; d3dapp.h includes this d3dUtil.h file, yet, it also, at the end, use same command: // Globals for convenient access. extern D3DApp* gd3dApp; extern IDirect3DDevice9* gd3dDevice; And then you have d3dApp.cpp, wich has this code h D3DApp* gd3dApp = 0; IDirect3DDevice9* gd3dDevice = 0; And this is what confuses me. Ok so, has i understand, he is trying to make global variable D3DApp*; and iirc, when you use extern command; there is no memory saved for this variable, as you say, that it is defined externally from that file. Now, if that is the case. If d3dapp.h includes d3dUtil.h.....why do BOTH of them have same command, extern D3DApp* gd3dApp; would the one in d3dUtil file suffice, since we included that file into d3dapp.h anyway? Tnx
  8. Pero83

    Array size and variables

    Hm, ok, i think i found a problem. Looks like problem wasn't in dynamic arrays at all, but rather when i lock index and vertex buffers; it seems i use wrong values for those. So anyhow, tnx all! --edite-- wow, i actually can import my models from maya now. This so awesome.
  9. Pero83

    Array size and variables

    Hm, ok tnx guys. I'm posting here entire code, and do note, i'm a noob, so i'm probably doing many thigns wrong. Also, just for info, i'm getting vSize and fSize from the txt file, where i "converter" obj file. I also tried to check the values with message box, and they are correct. So, for the moment, i put 36 as the fSize and vSize.(because if i use regular, static arrays with the size 36, it works) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // DX 6 - working with meshes ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Defines #define CUSTOMFVF D3DFVF_XYZ // Includes #include <fstream> #include <string> #include <sstream> #include <iostream> #include <Windows.h> #include <d3d9.h> #include <d3dx9.h> // Pragmas #pragma comment (lib, "d3d9.lib") #pragma comment (lib, "d3dx9.lib") // Defines #define SCREEN_WIDTH 1680 #define SCREEN_HEIGHT 1050 const int c = 120; using namespace std; // Structs struct CustomVertex { float x,y,z; //float nx, ny, nz; //float u,v; }; // Functions bool init_window(HINSTANCE hInstance); LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); void init_d3d(HWND hWnd); void setup_VMIB(void); void render_frame(void); void clean_d3d(void); void setMesh(string filename, CustomVertex* vertex); int getVertexCount(string filename); int getFaceCount(string filename); // Variables HINSTANCE hInstance; HWND hWnd; // D3D variables LPDIRECT3D9 d3d; LPDIRECT3DDEVICE9 d3ddev; LPD3DXMESH mesh; D3DXMATRIX matProj, matView; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Win Main ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow) { if(!init_window(hInstance)) return 0; MSG msg; ZeroMemory(&msg, sizeof(msg)); init_d3d(hWnd); setup_VMIB(); while(true) { while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (msg.message == WM_QUIT) break; render_frame(); } clean_d3d(); return msg.wParam; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Init Window ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool init_window(HINSTANCE hInstance) { WNDCLASSEX wc; ZeroMemory(&wc, sizeof(wc)); wc.cbSize = sizeof(wc); wc.hInstance = hInstance; wc.lpszClassName = "OBJ import Class"; wc.lpfnWndProc = WindowProc; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.style = CS_HREDRAW|CS_VREDRAW; RegisterClassEx(&wc); hWnd = CreateWindowEx(NULL, "OBJ import Class", "OBJ import Window", WS_EX_TOPMOST|WS_POPUP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL); if (!hWnd) return false; ShowWindow(hWnd, SW_SHOW); return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Window Proc ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY|WM_KEYDOWN: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, message, wParam, lParam); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // init D3D ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void init_d3d(HWND hWnd) { 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 = SCREEN_WIDTH; d3dpp.BackBufferHeight = SCREEN_HEIGHT; d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3d->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE); d3ddev->SetRenderState(D3DRS_LIGHTING, FALSE); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //setup Vertex Buffer / Index Buffer ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void setup_VMIB(void) { int vSize = getVertexCount("cube.txt"); //const int a = 36; int fSize = getFaceCount("cube.txt"); //CustomVertex vertices[a]; /*ostringstream os; os<<vSize; string Content = os.str(); MessageBoxA(NULL, Content.c_str(), "43", MB_OK);*/ CustomVertex* vertices; short* indices; vertices = new CustomVertex[36]; indices = new short[36]; D3DXCreateMeshFVF(fSize, vSize, D3DXMESH_DYNAMIC| D3DXMESH_WRITEONLY, CUSTOMFVF, d3ddev, &mesh); setMesh("cube.txt", vertices); //set index array for (int i=0; i<(vSize); i++) { indices = i; } // prepare to copy the vertices into the vertex buffer VOID* pVertices; // lock the vertex buffer mesh->LockVertexBuffer(D3DLOCK_DISCARD, &pVertices); // copy the vertices into the buffer memcpy( pVertices, vertices, sizeof(vertices) ); // unlock the vertex buffer mesh->UnlockVertexBuffer(); // prepare to copy the indexes into the index buffer VOID* IndexPtr; // Lock the index buffer mesh->LockIndexBuffer( 0, &IndexPtr ); // Copy the indexes into the buffer memcpy( IndexPtr, indices, sizeof(indices)*sizeof(WORD) ); // unlock the buffer mesh->UnlockIndexBuffer(); delete [] vertices; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // render_frame ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void render_frame(void) { d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 55, 155), 1.0f, 0); d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 55, 155), 1.0f, 0); d3ddev->BeginScene(); d3ddev->SetFVF(CUSTOMFVF); static float indexY = 0.0f; //ever increasing float value for Y axes indexY +=0.15f; D3DXMATRIX matRotY; D3DXMatrixRotationY(&matRotY, indexY); d3ddev->SetTransform(D3DTS_WORLD, &matRotY); D3DXMatrixPerspectiveFovLH(&matProj, D3DXToRadian(45), (float)SCREEN_WIDTH/(float)SCREEN_HEIGHT, 1.0f, 1000.0f); d3ddev->SetTransform(D3DTS_PROJECTION, &matProj); D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3(10.0f, 10.0f, 10.0f), &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(0, 1.0f, 0)); d3ddev->SetTransform(D3DTS_VIEW, &matView); mesh->DrawSubset(0); d3ddev->EndScene(); d3ddev->Present(NULL,NULL, NULL, NULL); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // clean_D3D ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void clean_d3d(void) { mesh->Release(); d3ddev->Release(); d3d->Release(); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Set Mesh /* Reads txt file, extract info about mesh and stores it into array */ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void setMesh(string filename, CustomVertex* vertex) { int i = 0; ifstream fin; char input; string s; fin.open("cube.txt"); //fin.get(input); while(!fin.eof()) { fin.get(input); if(input == 'v') { //fin>>(float)vertex.x >>(float)vertex.y >>(float)vertex.z >>(float)vertex.u >>(float)vertex.v >>(float)vertex.nx >>(float)vertex.ny >>(float)vertex.nz; fin>>(float)vertex.x >>(float)vertex.y >>(float)vertex.z; /*ostringstream os; os<<vertex.x; string Content = os.str(); MessageBoxA(NULL, Content.c_str(), "43", MB_OK);*/ i++; } while(input != '\n') { fin.get(input); } } fin.close(); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Get Number of Vertices ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int getVertexCount(string filename) { ifstream fin; char input; int vCount; string s; fin.open("cube.txt"); fin.get(input); while(!fin.eof()) { if(input == 'a') { fin>>s; if(s == "Vertex_Count") { fin>>(int)vCount; } } } fin.close(); return vCount; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Get Number of Vertices ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int getFaceCount(string filename) { ifstream fin; char input; int vCount; string s; fin.open("cube.txt"); fin.get(input); while(!fin.eof()) { if(input == 'a') { fin>>s; if(s == "Face_Count") { fin>>(int)vCount; } } } fin.close(); return vCount; }
  10. Pero83

    Array size and variables

    Tnx! Hm, your link isn't working. Hm, more code. Ok, lets say for index array, i'll give example of code that gave me problem. If i do this: short indices[36]; for (int i=0; i<(fSize*3); i++) { indices = i; } , it works fine. But now, if i do this: short* indices; indices = new short[36]; for (int i=0; i<(fSize*3); i++) { indices = i; } It does work, but instead of whole cube (like in first example), i only see one triangle (face). Shouldn't these provide identical results?
  11. Pero83

    Array size and variables

    oh yeah, sorry, it was a typo when i copied here. XD
  12. Pero83

    Array size and variables

    Tnx! Well, i did try to use 'new', but problem was, that although it doesn't give me any error, it simply refuses to display mesh (like it didn't store values in array correctly). I idid a like this: CustomVertex* vertices; vertices = new CustomVertex[fSize*3]; Maybe i did something wrong there.... b. sounds like solution that should work, but not sure if it's really ok, since it may not be the most optimized way. Tnx!
  13. Well, i get to this problem a lot, and while dynamic arrays sometimes solves the problem, it doesn't in this case. I'm making app, that should read obj and render it, so to speak. So, i have function "readVertexCount", which reads file (say, obj), and return number of vertices. Now, in my other function, where i create vertex buffer, i create array, and need to tell the size. So, i call this "readVertexCount" function, and it gives me number of vertices (int). I'm trying to use this as array size: int vSize = getVertexCount("cube.txt"); CustomVertex vertices[vSize]; but, as you probably guessed, i get error, saying, that array cannot have variable size. Ok so i understand why this happens, but i don't know how to "fix" it. So, why i basicly want to do, is have a function that returns number of vertices, and then use this in creating an array for vertex buffer. And i don't want to use dynamic arrays Any ideas?
  14. I'm trying to use D3DXCreateMeshFVF to create a simple mesh, and while it does render, i get error on exiting. So, in general too, i'm just looking for some tips, how to know in future, what exactly is causing a problem. First, my code: ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // DX 6 - working with meshes ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Defines #define CUSTOMFVF (D3DFVF_XYZ|D3DFVF_DIFFUSE) // Includes #include <fstream> #include <string> #include <iostream> #include <Windows.h> #include <d3d9.h> #include <d3dx9.h> // Pragmas #pragma comment (lib, "d3d9.lib") #pragma comment (lib, "d3dx9.lib") // Defines #define SCREEN_WIDTH 1680 #define SCREEN_HEIGHT 1050 using namespace std; // Functions bool init_window(HINSTANCE hInstance); LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); void init_d3d(HWND hWnd); void setup_VMIB(void); void render_frame(void); void clean_d3d(void); // Variables HINSTANCE hInstance; HWND hWnd; // D3D variables LPDIRECT3D9 d3d; LPDIRECT3DDEVICE9 d3ddev; LPD3DXMESH mesh; D3DXMATRIX matProj, matView; // Structs struct CustomVertex { float x,y,z; DWORD color; }; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Win Main ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow) { if(!init_window(hInstance)) return 0; MSG msg; ZeroMemory(&msg, sizeof(msg)); init_d3d(hWnd); D3DXCreateMeshFVF(12, 8, D3DXMESH_VB_DYNAMIC, CUSTOMFVF, d3ddev, &mesh); setup_VMIB(); while(true) { while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (msg.message == WM_QUIT) break; render_frame(); } clean_d3d(); return msg.wParam; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Init Window ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool init_window(HINSTANCE hInstance) { WNDCLASSEX wc; ZeroMemory(&wc, sizeof(wc)); wc.cbSize = sizeof(wc); wc.hInstance = hInstance; wc.lpszClassName = "OBJ import Class"; wc.lpfnWndProc = WindowProc; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.style = CS_HREDRAW|CS_VREDRAW; RegisterClassEx(&wc); hWnd = CreateWindowEx(NULL, "OBJ import Class", "OBJ import Window", WS_EX_TOPMOST|WS_POPUP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL); if (!hWnd) return false; ShowWindow(hWnd, SW_SHOW); return true; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Window Proc ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY|WM_KEYDOWN: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, message, wParam, lParam); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // init D3D ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void init_d3d(HWND hWnd) { 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 = SCREEN_WIDTH; d3dpp.BackBufferHeight = SCREEN_HEIGHT; d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; d3d->CreateDevice (D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE); d3ddev->SetRenderState(D3DRS_LIGHTING, FALSE); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //setup Vertex Buffer / Index Buffer ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void setup_VMIB(void) { // vertices for the vertex buffer CustomVertex g_Vertices[ ] = { // X Y Z U V {-1.0f,-1.0f,-1.0f, D3DCOLOR_ARGB(0,0,255,255)}, // 0 {-1.0f, 1.0f,-1.0f, D3DCOLOR_ARGB(0,0,255,255)}, // 1 {1.0f, 1.0f,-1.0f, D3DCOLOR_ARGB(0,0,255,255)}, // 2 { 1.0f,-1.0f,-1.0f, D3DCOLOR_ARGB(0,0,255,255)}, // 3 {-1.0f,-1.0f, 1.0f, D3DCOLOR_ARGB(0,0,255,255)}, // 4 {1.0f,-1.0f, 1.0f, D3DCOLOR_ARGB(0,0,255,255)}, // 5 { 1.0f, 1.0f, 1.0f, D3DCOLOR_ARGB(0,0,255,255)}, // 6 {-1.0f, 1.0f, 1.0f, D3DCOLOR_ARGB(0,0,255,255)} // 7 }; // index buffer data WORD IndexData[ ] = { 0,1,2, 2,3,0, 4,5,6, 6,7,4, 0,3,5, 5,4,0, 3,2,6, 6,5,3, 2,1,7, 7,6,2, 1,0,4, 4,7,1 }; // prepare to copy the vertices into the vertex buffer VOID* pVertices; // lock the vertex buffer mesh->LockVertexBuffer(D3DLOCK_DISCARD, &pVertices); // copy the vertices into the buffer memcpy( pVertices, g_Vertices, sizeof(g_Vertices) ); // unlock the vertex buffer mesh->UnlockVertexBuffer(); // prepare to copy the indexes into the index buffer VOID* IndexPtr; // Lock the index buffer mesh->LockIndexBuffer( 0, &IndexPtr ); // Copy the indexes into the buffer memcpy( IndexPtr, IndexData, sizeof(IndexData)*sizeof(WORD) ); // unlock the buffer mesh->UnlockIndexBuffer(); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // render_frame ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void render_frame(void) { d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 55, 155), 1.0f, 0); d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 55, 155), 1.0f, 0); d3ddev->BeginScene(); d3ddev->SetFVF(CUSTOMFVF); D3DXMatrixPerspectiveFovLH(&matProj, D3DXToRadian(45), (float)SCREEN_WIDTH/(float)SCREEN_HEIGHT, 1.0f, 1000.0f); d3ddev->SetTransform(D3DTS_PROJECTION, &matProj); D3DXMatrixLookAtLH(&matView, &D3DXVECTOR3(20.0f, 20.0f, 20.0f), &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(0, 1.0f, 0)); d3ddev->SetTransform(D3DTS_VIEW, &matView); mesh->DrawSubset(0); d3ddev->EndScene(); d3ddev->Present(NULL,NULL, NULL, NULL); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // clean_D3D ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void clean_d3d(void) { mesh->Release(); d3ddev->Release(); d3d->Release(); } And here's what output window provides: Direct3D9: (ERROR) :************************************************************ Direct3D9: (ERROR) :ASSERTION FAILED! File s:\gfx_aug09\windows\directx\dxg\inactive\d3d9\d3d\fw\lhbatchfilter.cpp Line 3466: pArgs->Flags.Discard Direct3D9: (ERROR) :************************************************************ Direct3D9: (ERROR) :************************************************************ Direct3D9: (ERROR) :ASSERTION FAILED! File s:\gfx_aug09\windows\directx\dxg\inactive\d3d9\d3d\fw\lhbatchfilter.cpp Line 3466: pArgs->Flags.Discard Direct3D9: (ERROR) :************************************************************ Direct3D9: (ERROR) :************************************************************ Direct3D9: (ERROR) :ASSERTION FAILED! File s:\gfx_aug09\windows\directx\dxg\inactive\d3d9\d3d\fw\lhbatchfilter.cpp Line 3466: pArgs->Flags.Discard Direct3D9: (ERROR) :************************************************************ Direct3D9: (WARN) :Ignoring redundant SetRenderState - 7 Direct3D9: (WARN) :Indexbuffer created with POOL_DEFAULT but WRITEONLY not set. Performance penalty could be severe. Direct3D9: (WARN) :Vertexbuffer created with POOL_DEFAULT but WRITEONLY not set. Performance penalty could be severe. Direct3D9: (INFO) :DDI threading stopped Direct3D9: (WARN) :INVALID FREE! cookie=3f800000, ptr = 00dddd00 Direct3D9: (WARN) :00dddd00: lAllocID=150 dwSize=0000ffff, lpAddr=6901a22b Critical error detected c0000374 Windows has triggered a breakpoint in DX_5_Meshes.exe. This may be due to a corruption of the heap, which indicates a bug in DX_5_Meshes.exe or any of the DLLs it has loaded. This may also be due to the user pressing F12 while DX_5_Meshes.exe has focus. The output window may have more diagnostic information. First-chance exception at 0x777ee653 in DX_5_Meshes.exe: 0xC0000374: A heap has been corrupted. Unhandled exception at 0x777ee653 in DX_5_Meshes.exe: 0xC0000374: A heap has been corrupted. HEAP[DX_5_Meshes.exe]: Heap block at 00DDDC58 modified at 00DDDCE4 past requested size of 84 Windows has triggered a breakpoint in DX_5_Meshes.exe. This may be due to a corruption of the heap, which indicates a bug in DX_5_Meshes.exe or any of the DLLs it has loaded. This may also be due to the user pressing F12 while DX_5_Meshes.exe has focus. The output window may have more diagnostic information. HEAP[DX_5_Meshes.exe]: Invalid address specified to RtlFreeHeap( 00DD0000, 00DDDC60 ) Windows has triggered a breakpoint in DX_5_Meshes.exe. This may be due to a corruption of the heap, which indicates a bug in DX_5_Meshes.exe or any of the DLLs it has loaded. This may also be due to the user pressing F12 while DX_5_Meshes.exe has focus. The output window may have more diagnostic information. The thread 'Win32 Thread' (0xb34) has exited with code 0 (0x0). 'DX_5_Meshes.exe': Unloaded 'C:\Windows\SysWOW64\nvd3dum.dll' Direct3D9: :====> ENTER: DLLMAIN(68ffd9a0): Process Detach 00000494, tid=000017bc Direct3D9: (INFO) :MemFini! Direct3D9: (ERROR) :Memory Address: 00dddd1c lAllocID=150 dwSize=0000ffff, ReturnAddr=6901a22b (pid=00000494) Direct3D9: (ERROR) :Total Memory Unfreed From Current Process = 65535 bytes Direct3D9: :====> EXIT: DLLMAIN(68ffd9a0): Process Detach 00000494 The program '[1172] DX_5_Meshes.exe: Native' has exited with code 0 (0x0). So, any idea what can be wrong? And how can i "read" this message to understand it? From what i see, perhabs i maybe forgot to free some resources. And what is the: Direct3D9: (ERROR) :ASSERTION FAILED! File s:\gfx_aug09\windows\directx\dxg\inactive\d3d9\d3d\fw\lhbatchfilter.cpp Line 3466: pArgs->Flags.Discard error? Tnx for any help!
  15. Ah, so in other words, if i have cube with 24 normals, i need to have 24 vertices (x,y,z position values) aswell? But that kinda sounds very unoptimized. Is there no way to optimize, similar to how OBJ does, so that gpu doesn't have duplicated vertecies and therefor reduce vertex number a lot?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!