• 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
thestien

Drawing lines that wont show as coloured

4 posts in this topic

Hi guys only me [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Another simple program causing me headache. it is supposed to draw coloured lines but they only apprear black. ill try to only include relavent code.

[code]
int GameInit()
{

HRESULT r = 0;

g_pD3D = Direct3DCreate9( D3D_SDK_VERSION);

if( g_pD3D == NULL)
{
SetError( " Could not create IDIRECT3D9 object");
return E_FAIL;
}

r = InitDirect3DDevice( g_hWndMain, 640, 480, TRUE, D3DFMT_A8R8G8B8, g_pD3D, &g_pDevice);

if( FAILED( r))
{
SetError( "Init of the device failed");
return E_FAIL;
}

g_Camera.Reset();


CreateViewport();
SetProjectionMatrix();

g_pDevice->Clear( 0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 0, 0, 0),10.f, 0);
r = g_pDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &g_pBackSurface);

if( FAILED( r))
{
SetError( "Couldnt get backbuffer");
return E_FAIL;
}


srand( GetTickCount());
InitTiming();

for( int i = 0; i < g_NumPoints; i++)
{
g_Lines[i].SetProps( 0,0,0,D3DCOLOR_XRGB(rand()%255,rand()%255,rand()%255),
(float)(rand()%10)-rand()%10,
(float)(rand()%10)-rand()%10,
(float)(rand()%10)-rand()%10,
D3DCOLOR_XRGB(rand()%255, rand()%255, rand()%255));
}

return S_OK;
}
[/code]

this should setup 300 lines of random colour all starting at the origin and extending out randomly.
g_NumPoints = 300;

[code]
int Render()
{
//Pause(1000);


HRESULT r = 0;
g_pDevice->Clear( 0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 255, 50, 50, 50),10.f, 0);

if(!g_pDevice)
{
SetError( "cannot render because there is no device");
return E_FAIL;
}



g_pDevice->BeginScene();

D3DXMATRIX RotationX, RotationY, WorldMatrix;
D3DXMatrixRotationY( &RotationY, timeGetTime()/200.0f);
D3DXMatrixRotationX( &RotationX, timeGetTime()/800.0f);
D3DXMatrixMultiply( &WorldMatrix, &RotationX, &RotationY);

/*
static D3DLIGHT9 Light;
ZeroMemory( &Light, sizeof(D3DLIGHT9));
Light.Type = D3DLIGHT_POINT;
Light.Diffuse.r = 1.0f;
Light.Diffuse.g = 1.0f;
Light.Diffuse.b = 1.0f;
Light.Position = D3DXVECTOR3( 0, 0, -10);
Light.Range = 10.0f;


g_pDevice->SetLight( 0, &Light);
g_pDevice->LightEnable( 0, TRUE);
g_pDevice->SetRenderState( D3DRS_LIGHTING, TRUE );


D3DMATERIAL9 Material;
ZeroMemory( &Material, sizeof(D3DMATERIAL9));
Material.Diffuse.r = 0.0f;
Material.Diffuse.g = 0.5f;
Material.Diffuse.b = 0.0f;
Material.Diffuse.a = 1.0f;
Material.Ambient.r = 1.0f;
Material.Ambient.b = 0.0f;
Material.Ambient.g = 0.0f;
Material.Ambient.a = 1.0f;

g_pDevice->SetMaterial( &Material);
*/
g_pDevice->SetFVF( ZENVERTEX_TYPE);
g_pDevice->SetTransform( D3DTS_WORLD, &WorldMatrix);

for( int i = 0; i < g_NumPoints; i++)
{
g_Lines[i].Render();
}

g_pDevice->EndScene();

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



static float z = 0;
static BOOL bForward = FALSE;
if(bForward == TRUE)
{
z += 0.1f;
if(z > 0.0f)
{
z = 0.0f;
bForward=FALSE;
}
}
else
{
z -= 0.1f;
if(z < -50.0f)
{
z = -50.0f;
bForward = TRUE;
}
}
g_Camera.SetPosition(0,0,z);
g_Camera.Update();

return S_OK;

}
[/code]

now this is supposed to draw those lines to the screen i have no idea whats wrong with it i have tried messing about with light and material which is commented out but i have had no luck with it :(

[code]
HRESULT CZenLine::Render()
{
HRESULT r = 0;
LPDIRECT3DVERTEXBUFFER9 pVB = 0;

r = g_pDevice->CreateVertexBuffer( sizeof( CZenVertex) * 2, D3DUSAGE_WRITEONLY,
ZENVERTEX_TYPE, D3DPOOL_DEFAULT, &pVB, NULL);
if (FAILED(r))
{
SetError("ZenLine Dont Work");
return E_FAIL;
}

BYTE* pData = 0;

r = pVB->Lock( 0, 0, (void**)&pData, 0);
if( FAILED(r))
{
pVB->Release();
return E_FAIL;
}
CopyMemory( pData, (void*)&m_StartPoint, sizeof( CZenVertex));
CopyMemory( pData + sizeof(CZenVertex), (void*)&m_EndPoint, sizeof( CZenVertex));

pVB->Unlock();

g_pDevice->SetStreamSource( 0, pVB, 0, sizeof( CZenVertex));
g_pDevice->DrawPrimitive( D3DPT_LINELIST, 0, 1);
pVB->Release();
return S_OK;
}
[/code]

this is the render function for the lines.
and finally

[code]
#define ZENVERTEX_TYPE ( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_SPECULAR |D3DFVF_TEX1)

class CZenVertex
{
public:
CZenVertex();
CZenVertex( float x, float y, float z, float nx, float ny, float nz, D3DCOLOR DiffuseColor,
D3DCOLOR SpecularColor, float tu, float tv);
~CZenVertex();

public:
void Set( float x, float y, float z, float nx, float ny, float nz, D3DCOLOR DiffuseColor,
D3DCOLOR SpecularColor, float tu, float tv);

protected:

public:
D3DVECTOR m_Position;
D3DVECTOR m_Normal;
D3DCOLOR m_DiffuseColor;
D3DCOLOR m_SpecularColor;
float m_tu, m_tv;

protected:
};
[/code]

this is the vertex info.


sorry i have posted so much code but hopefully you can help me figure out what the problem is as i have had the same problem with this happening with a similar program drawing points.

thanks in advance, your help is appreciated [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
0

Share this post


Link to post
Share on other sites
Hi guys should i move this thread to the dx xna forum? i was worried about posting it there as im a begginer.
i thought this would be the best place because its a noob friendly forum my lack of understanding wont offend anyone who would potentially help me but on the downside more people who deal with dx would get to see this if i moved it.

anyway i think i like this forum better you guys are cool :)
0

Share this post


Link to post
Share on other sites
What if you add in a call to:
g_pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
somewhere before rendering your lines?

EDIT: If that fixes it, it's because lighting is on by default, but you're not setting up any lights or materials in your scene.

Also, what does the SetProps() function look like? Are you sure the parameters are in the correct order?
0

Share this post


Link to post
Share on other sites
Hi Thanks for the reply Evil Steve

im at work so im itching to get home to change the code and see if it works :)

here is the setprops function
[code]
void CZenLine::SetProps( float x1, float y1, float z1, D3DCOLOR StartColor,
float x2, float y2, float z2, D3DCOLOR EndColor)
{
m_StartPoint.m_Position.x = x1;
m_StartPoint.m_Position.y = y1;
m_StartPoint.m_Position.z = z1;
m_StartPoint.m_DiffuseColor = StartColor;
m_EndPoint.m_Position.x = x2;
m_EndPoint.m_Position.y = y2;
m_EndPoint.m_Position.z = z2;
m_EndPoint.m_DiffuseColor = EndColor;
}
[/code]

thanks again for your help :)
0

Share this post


Link to post
Share on other sites
Evil Steve i do declare you a genius.

for the second time you have fixed my programme with a single line of text.

thanks again for the help its much appriciated. [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
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