• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Conny14156

How do I pass D3d11Device into a parameter correct?[SOLVE]!

8 posts in this topic

Hi, This maybe is a stupid question but, I have a function like this Object::InitBuffer(ID3D11Device* D3d11Device) And I need to pass the D3d11Device, But when I do it like Object Test; Test.InitBuffer(D3d11Device); "nothing" happend, more like I see nothing >.<. I think it has something to do with that am just passing "value" and not the "whole" "object" so my program sets the setting onto another D3d11Device. But when I tried something like Test.InitBuffer(*D3d11Device); or Test.InitBuffer(&D3d11Device); I get errors :/ So my simple question is. Is the first passing parameter the correct way to do it? if not is there another way I should do it? if so what would that be? if the first parameter is correct than its something wrong with my function but I tried to do it "normal" (By having the function inside the same cpp file) than It worked as it suppose to be.

0

Share this post


Link to post
Share on other sites

You're supposed to add the pointer address of the Direct3D11 device.

 

So simply, first initialize your device, 

 


 

ID3D11Device* d3ddev = NULL;   // the pointer to the device class

 

 

in this case, in the parameter you write,

 


 

&d3ddev

 

 

hope this helps.

Edited by regonaros
1

Share this post


Link to post
Share on other sites

Seems like I miss phrased my question kinda bad >.<

 

I already have all my device and DeviceContext initialized, but When I try to pass the device with &, than I get a error like this

cannot convert parameter 1 from 'ID3D11Device **' to 'ID3D11Device *' 

0

Share this post


Link to post
Share on other sites
Here the parts that gives me the error ;(
If you need any other piece of code just tell me :3




void DrawObject()
{
Test.InitBuffer(&D3d11Device);
Test.SetBuffer(&D3d11DevCon);
Test.DrawObject(&D3d11DevCon);
}

// ^ That code is in a seperate cpp file compared to the code below


bool Object::InitBuffer(ID3D11Device* D3d11Device)
{
	
	Vertex* Vertices;

	Vertices = new Vertex[Model.VertexCount];
	Vertex v[] =
	{
		Vertex( 0.0f, 0.5f, 0.5f ),
		Vertex( 0.5f, -0.5f, 0.5f ),
		Vertex(-0.5f, -0.5f, 0.5f ),
	};

	//Create the vertex buffer Describer and describ it
	D3D11_BUFFER_DESC vertexBufferDesc;
	ZeroMemory( &vertexBufferDesc, sizeof(vertexBufferDesc) );

	vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
	vertexBufferDesc.ByteWidth = sizeof( Vertex ) * 3;
	//vertexBufferDesc.ByteWidth = sizeof( Vertex ) * Model.VertexCount;
	vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
	vertexBufferDesc.CPUAccessFlags = 0;
	vertexBufferDesc.MiscFlags = 0;

	D3D11_SUBRESOURCE_DATA vertexBufferData; 

	ZeroMemory( &vertexBufferData, sizeof(vertexBufferData) );
	vertexBufferData.pSysMem = v;
	D3d11Device->CreateBuffer( &vertexBufferDesc, &vertexBufferData, &Buffer.VertexBuffer);
	
	
	return true;
}
bool Object::SetBuffer(ID3D11DeviceContext* D3d11DevCon)
{
	//Set the vertex buffer
	UINT stride = sizeof( Vertex );
	UINT offset = 0;
	D3d11DevCon->IASetVertexBuffers( 0, 1, &Buffer.VertexBuffer, &stride, &offset );
	D3d11DevCon->IASetIndexBuffer(Buffer.IndexBuffer,DXGI_FORMAT_R32_UINT,0);
	return true;
}
bool Object::DrawObject(ID3D11DeviceContext* D3d11DevCon)
{
	D3d11DevCon->DrawIndexed(3,0,0);
	return true;
}
0

Share this post


Link to post
Share on other sites

I need to see this code

 

//--------------------------------------------------------------------------------------
// Global Variables
//--------------------------------------------------------------------------------------
HINSTANCE               g_hInst = NULL;
HWND                    g_hWnd = NULL;
D3D_DRIVER_TYPE         g_driverType = D3D_DRIVER_TYPE_NULL;
D3D_FEATURE_LEVEL       g_featureLevel = D3D_FEATURE_LEVEL_11_0;
ID3D11Device*           g_pd3dDevice = NULL;
ID3D11DeviceContext*    g_pImmediateContext = NULL;
IDXGISwapChain*         g_pSwapChain = NULL;
ID3D11RenderTargetView* g_pRenderTargetView = NULL;
0

Share this post


Link to post
Share on other sites
Edit:
FUUU


#include <d3d11.h>
#include <D3DX11.h>
#include <D3DX10.h>
#include <DxErr.h>
#include <xnamath.h>

#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "D3DX11.lib")
#pragma comment(lib, "D3DX10.lib")
#pragma comment(lib, "DXErr.lib")


#include "ObjectH.h"
#include "WindowsHandlerH.h"

IDXGISwapChain* SwapChain;
ID3D11Device* D3d11Device;
ID3D11DeviceContext* D3d11DevCon;
ID3D11RenderTargetView* RenderTargetView;
ID3D11DepthStencilView* DepthStencilView;
ID3D11Texture2D* DepthStencilBuffer;


D3DXCOLOR bgColour(0.0f,0.0f,0.0f,0.0f);

ID3D11VertexShader* VS;
ID3D11PixelShader* PS;
ID3D10Blob* VSBuffer;
ID3D10Blob* PSBuffer;
ID3D11InputLayout* InputLayout;

D3D11_INPUT_ELEMENT_DESC Layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
UINT LayoutElement = ARRAYSIZE(Layout );
Object Test;

This one? Edited by Conny14156
0

Share this post


Link to post
Share on other sites

I think the problem is you need to put the Draw Object function underneath the init buffer function. try that.

0

Share this post


Link to post
Share on other sites

I GOT IT TO WORK!

The problem was I used 

D3d11devCon->DrawIndexed INSTEAD of just simply ->Draw

 

I had forgot that I havent set up any Index buffer yet and only setted up a normal vertex buffer >.>. >.< 

so stupid of me.

and I would't realize this stupid misstake if u didnt tell me to rearrange the order of my object function, that was when I notice I had used DrawIndex instead of draw >.<

THANKS MAN! can finnaly keep moving on >.<

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0