Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

D_JildQuantum

This will probably be ignored but...

This topic is 5563 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, having figured out how to store several things in one buffer, i ran into another problem. Ir just starts up and says this:
This program has performed an illeagle operation and will be shut down

3DFIREFLY caused an invalid page fault in
module KERNEL32.DLL at 0197:bff7a388.
Here is where i believe the error is coming form, though im not sure:
bool InitD3D(HWND g_hWnd)
{ 
    //D3D Initialization    

	///////////////////////////

	//BARE MINIMUM!////////////

	///////////////////////////


	g_pDirect3D=Direct3DCreate8(D3D_SDK_VERSION); 
        if(g_pDirect3D==NULL) 
                return(false); 
		
		D3DDISPLAYMODE DisplayMode; 
        if(g_bFullscreen==false) 
        { 
                g_hr=g_pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &DisplayMode); 
                if(FAILED(g_hr)) 
                        return(false); 
        } 
        else 
        { 
                DisplayMode.Width=      WINDOW_WIDTH; 
                DisplayMode.Height=     WINDOW_HEIGHT; 
                DisplayMode.RefreshRate=0; 
                DisplayMode.Format=     D3DFMT_R5G6B5; 
        } 
        
		D3DPRESENT_PARAMETERS   PresentParameters; 
        memset(&PresentParameters, 0, sizeof(D3DPRESENT_PARAMETERS)); 
        if(g_bFullscreen==false) 
        { 
                PresentParameters.Windowed = true; 
        } 
        else if(g_bFullscreen==true) 
        { 
                PresentParameters.Windowed = false; 
        } 
        PresentParameters.SwapEffect	   = D3DSWAPEFFECT_DISCARD;
		PresentParameters.BackBufferWidth = 640;
		PresentParameters.BackBufferHeight = 480;
		PresentParameters.BackBufferFormat = D3DFMT_X8R8G8B8; 

		PresentParameters.BackBufferCount  = 1;
		PresentParameters.hDeviceWindow    = g_hWnd;
		PresentParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
		PresentParameters.EnableAutoDepthStencil = true;
		PresentParameters.AutoDepthStencilFormat = D3DFMT_D16;
		PresentParameters.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
		
        g_hr=g_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, 
                                  D3DCREATE_SOFTWARE_VERTEXPROCESSING, 
                                  &PresentParameters, &g_pDevice); 
        if(FAILED(g_hr)) 
        { 
                return(false); 
        } 
		///////////////////////

		//END BARE MINIMUM!////

		///////////////////////

		
		///////////////////////

		//Matrix Setup/////////

		///////////////////////

		//ProjectionMatrix

		D3DXMATRIX MatrixProjection;
		ZeroMemory(&MatrixProjection, sizeof(MatrixProjection));
		D3DXMatrixPerspectiveFovLH(&MatrixProjection, D3DX_PI/6, WINDOW_WIDTH/WINDOW_HEIGHT, 1.0, 100.0);
		g_pDevice->SetTransform(D3DTS_PROJECTION, &(D3DMATRIX)MatrixProjection);
		//View Matrix

		ZeroMemory(&MatrixView, sizeof(MatrixView));
		D3DXMatrixLookAtLH(&MatrixView, &D3DXVECTOR3(-1.5f, 1.7f, -10.0f),
										&D3DXVECTOR3(1.0f, 0.0f, 0.0f),
										&D3DXVECTOR3(0.0f, 1.0f, 0.0f));
		g_pDevice->SetTransform(D3DTS_VIEW, &MatrixView);
		//World Matrix

		D3DXMATRIX MatrixWorld;
		D3DXMatrixTranslation(&MatrixWorld, 3.0f, 0.0f, 2.0f);
		g_pDevice->SetTransform(D3DTS_WORLD, &MatrixWorld);
		///////////////////////

		//END MATRIX STUFF/////

		///////////////////////


		///////////////////////

		//Vertex Buffers... Need to Figure out how to Use one vertex buffer for all objects!

		///////////////////////

		//Quad Buffer

		g_hr=g_pDevice->CreateVertexBuffer(sizeof(CQVQuad), 0, D3DFVF_CQuantumVertex, D3DPOOL_DEFAULT,
                                         &g_pQuantumVertexBuffer);
		if(FAILED(g_hr))
			return false;
		BYTE* pVerticeLock=0;
		g_hr=g_pQuantumVertexBuffer->Lock(0, sizeof(CQVQuad), &pVerticeLock, 0);
		if(FAILED(g_hr))
			return(false);
		//Quad

		CopyMemory(pVerticeLock, &CQVQuad, sizeof(CQVQuad));
		pVerticeLock+=sizeof(CQVQuad);
		//Triangle

		CopyMemory(pVerticeLock, &CQVTriangle, sizeof(CQVTriangle));
		pVerticeLock+=sizeof(CQVTriangle);
		//Terrain

		CopyMemory(pVerticeLock, &CQVTerrain, sizeof(CQVTerrain));
		pVerticeLock+=sizeof(CQVTerrain);
		//SkyBoxEast

		CopyMemory(pVerticeLock, &CQVSkyBoxEast, sizeof(CQVSkyBoxEast));
		//SetRender States

		g_pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
		g_pDevice->SetRenderState( D3DRS_LIGHTING, false);
		///////////////////////

		//DInput Initialization

		///////////////////////

		return(true);
}//End InitD3D() 



 ////////////////////////////////////////////////////////////////////////////////

//DrawScene()																	//

//Purpose: Render the scene to the back buffer and then copy it to the monitor	//

 ////////////////////////////////////////////////////////////////////////////////

void DrawScene()
{
	//Clear

	g_pDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255), 1.0f, 0 );
	if(g_pDevice->BeginScene() == D3D_OK)
	{
	//Quad

	g_pDevice->SetTexture(0, g_pPyramidTexture);
	g_pDevice->SetStreamSource(0,g_pQuantumVertexBuffer,sizeof(CQuantumVertex));
	g_pDevice->SetVertexShader(D3DFVF_CQuantumVertex);
	g_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, CQVQuad, sizeof(CQuantumVertex));
	//Triangles

	g_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 4, CQVTriangle, sizeof(CQuantumVertex));
	//Terrain

	g_pDevice->SetTexture(0, g_pDessertTexture);
	g_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, CQVTerrain, sizeof(CQuantumVertex));
	//SkyBox East

	g_pDevice->SetTexture(0, g_pLavaTexture);
	g_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, CQVSkyBoxEast, sizeof(CQuantumVertex));
	g_pDevice->EndScene();
	}
	//Present

	g_pDevice->Present(NULL, NULL, NULL, NULL);
}

Thats just my initialization and Draw functions, and if you want any other segments, just ask. This post is gunna get one of three reactions form the public: Either A)everyone is going to suddenly go through a metamorphasis and stop treating me like im some retard, B)Ignore me or C)Call me a lazy retard and tell me never to show my face here again Quantum

Share this post


Link to post
Share on other sites
Advertisement
Run it through the debugger, and find out WHICH line it''s crapping out on. What this''ll be, is a null or invalid pointer being dereferenced. (Possibly the "this" pointer; any access of a non-static class member within a member function causes a pointer dereference.) Tell us which line it''s having a problem with, and we can help you better.

Oh, and what''s the deal with the a,b,c thing? Perhaps there''s some history here I''m not aware of (I am too lazy, at the moment, to look at your post history) but in my experience, people who get preemptively defensive here usually get less help.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
Its just that i have kept having problems and the last few posts people see to be ignoring me more than in the beginning... But thanks, ill try out your idea

Quantum

Share this post


Link to post
Share on other sites
Ok, im getting more familiar with the debugger, and hopefully the reason people were getting sick of me was because i dont use the debugger... Everyone as my witness, i took a few tutorials so you dont have to groan whenever you see my name! And btw, i found out which line was failing:

//In my InitTextures function (unexpected) It comes up with the acces violation


g_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
g_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

//BEWARE, FAULTY CODE AHEAD

if(FAILED(D3DXCreateTextureFromFile(g_pDevice, "C:\\Name\\PROGRAMMINGPROJECTS\\3DFirefly\\Media\\Graphics\\pyratext.jpg", &g_pPyramidTexture)))//THIS ONE RIGHT HERE!

//BEWARE FAULTY CODE BEHIND

return(false);
if(FAILED(D3DXCreateTextureFromFile(g_pDevice, "C:\\Name\\PROGRAMMINGPROJECTS\\3DFirefly\\Media\\Graphics\\sandtext.jpg",&g_pDessertTexture)))
return(false);
if(FAILED(D3DXCreateTextureFromFile(g_pDevice, "C:\\Name\\PROGRAMMINGPROJECTS\\3DFirefly\\Media\\Graphics\\grasstext.jpg",&g_pForestTexture)))
return(false);
if(FAILED(D3DXCreateTextureFromFile(g_pDevice, "C:\\Name\\PROGRAMMINGPROJECTS\\3DFirefly\\Media\\Graphics\\lavatext.jpg",&g_pLavaTexture)))
return(false);
return(true);
}


Thanks Sneftel. Tell me what you think the problem is. Oh, and the Debugger Error says: "Unhandled Exception in 3DFirefly.exe (KERNEL32.DLL): 0xC0000005: Access Violation
Hope you can help =/

Quantum

Share this post


Link to post
Share on other sites
There is a potential problem with this line...


g_hr=g_pDevice->CreateVertexBuffer(sizeof(CQVQuad), 0, D3DFVF_CQuantumVertex, D3DPOOL_DEFAULT, &g_pQuantumVertexBuffer);


The first parameter, sizeof(CQVQuad) , is possibly incorrect. This is telling Direct3D to create a vertex buffer of sizeof(CQVQuad) bytes...

...and then you go on and try to fill it with a quad, a triangle, terrain and skybox. This will cause a problem as you have not created a large enough vertex buffer.

Regards,
Sharky

---
< Sharky''s Coding Corner >
---

Share this post


Link to post
Share on other sites
Gah, I shoulda caught that in the other thread.

And D_JildQuantum the more you protray an image that no one wants to help you regardless of wether it is true or not is only going to hinder your getting help as people tend to not want to help negative thinkers.

Just take everything everyone says into consideration, dont expect answers within a half hour, and read up on anything people suggest you should read up on.

// Full Sail Student with a passion for games
// This post in no way indicates my being awake when writing it

Share this post


Link to post
Share on other sites
Ok thanks sharky. dclyde: the only reason i feel like everyone hates me is because i think im on the brink of depression... i feel like im always unorganised in my code, and everything i learn or do is going nowhere.

Quantum

Share this post


Link to post
Share on other sites
ok i changed it to this:


g_hr=g_pQuantumVertexBuffer->Lock(0, sizeof(CQVQuad)+sizeof(CQVTriangle)+sizeof(CQVTerrain)+sizeof(CQVSkyBoxEast), &pVerticeLock, 0);


Right? then it adds all of the sizeofs of them together? or should i just multiply it by 50 to be safe or sumthin?

Quantum

Share this post


Link to post
Share on other sites
Yay! I plugged in the values into CreateDevice, but then it still wouldnt work, so i plugged it onto the lock and it worked ^_^ *is going to be Optomistic from now on*


Quantum

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!