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

Drawing text causes incorrect geometry rendering

10 posts in this topic

I have been trying to add text to my application using ID3DX10Font and D3DX10CreateFont but every time I say DrawText my other geometry stops rendering correctly. I have attached images of output window with text and with text disabled. I use this code to initialize:
[source lang="cpp"]g_pFont = nullptr;

HRESULT hr = D3DX10CreateFont(g_pd3dDevice,
35, // the font height
0, // the font width
FW_BOLD, // the weight of the font
1, // number of mip levels
FALSE, // this is not an italic font
DEFAULT_CHARSET, // default character set
OUT_DEFAULT_PRECIS, // default size mapping
DEFAULT_QUALITY, // default quality mapping
DEFAULT_PITCH | FF_DONTCARE, // default pitch
L"Helvetica", // use Helvetica as the basis for this font
&g_pFont); // the output

// make sure the font was created correctly
if (FAILED(hr))
{
return hr;
}
return S_OK;[/source]

and to draw:
[source lang="cpp"]HRESULT hr = g_pFont->DrawText( NULL,
TEXT("This is a test string"),
-1,
&rc,
DT_LEFT,
D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );[/source]

Any help appreciated.
0

Share this post


Link to post
Share on other sites
It looks like the DrawText method is trashing your projection matrix, and perhaps modifying your fill mode and other stuff? How are you drawing your squares?
1

Share this post


Link to post
Share on other sites
Actually they are cubes. I update the transform matrix, set the effect file variables and then I draw the cubes. This is done in a loop.

[source lang="cpp"]D3DXMatrixTranslation( &g_World, translate.x, translate.y, translate.z );
.
.
.
g_pWorldVariable->SetMatrix( g_World );
g_pViewVariable->SetMatrix( g_View );
g_pProjectionVariable->SetMatrix( g_Projection );
.
.
.
D3D10_TECHNIQUE_DESC techDesc;
g_pTechnique->GetDesc( &techDesc );
for( UINT p = 0; p < techDesc.Passes; ++p )
{
g_pTechnique->GetPassByIndex( p )->Apply( 0 );
g_pd3dDevice->DrawIndexed( 36, 0, 0 ); // 36 vertices needed for 12 triangles in a triangle list
}[/source]
0

Share this post


Link to post
Share on other sites
The actual loop:
[source lang="cpp"]renderer.beginRender();
//text.render();

for(int i = 0; i < 10; ++i)
{
cube[i].update(t, D3DXVECTOR3(0, i * 2, i * 3), D3DXVECTOR3(0, 1, 0), D3DXVECTOR3(1, 1, 1));
mat.setWorldViewProjection(cube[i].getWorld(), cam.getView(), cam.getProjection());
cube[i].render(renderer.g_pd3dDevice, mat.getTechnique());
}

renderer.endRender();[/source]
0

Share this post


Link to post
Share on other sites
Maybe you need to set textures to NULL or to the texture used by the cube before rendering the cubes?

Cheers!
0

Share this post


Link to post
Share on other sites
But your font engine uses textures ... does that ring a bell?

Cheers!

[edit] sorry I was in a hurry, I realized just after that of course the font engine changes other states too than the textures etc. Edited by kauna
0

Share this post


Link to post
Share on other sites
The text-rendering will change every render-state known to man. Move any setup you have before your render-loop or before the text-rendering and do everything just before rendering your cubes. That includes anything you do in any init() function that you expect to remain the same since you never change it. The font will change it.
That includes setting the geometry-shader to NULL if you don't use it. Edited by Erik Rufelt
2

Share this post


Link to post
Share on other sites
Like Erik said, the drawing function changes states, so you can use the

ID3DX10Sprite::begin(D3DX10_SPRITE_SAVE_STATE);
draw text inside here
ID3DX10Sprite::end();

This will make sure your states are changed back to what they were before the draw text call. Edited by smasherprog
1

Share this post


Link to post
Share on other sites
smasherprog's idea of using D3DX10_SPRITE_SAVE_STATE worked but now it appears to ignore the z-buffer test. I used
[source lang="cpp"]ID3DX10Sprite *ppSprite;
D3DX10CreateSprite(g_pd3dDevice, 512, &ppSprite);
ppSprite->Begin(D3DX10_SPRITE_SAVE_STATE);
// text rendering
ppSprite->End();[/source]

I'm just going to reset the depth-buffer. I found a useful article here: http://hide1713.wordpress.com/2009/07/06/directx-10-drawtext-disable-depth-buffer-heres-how-to-fix-it/
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