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

Text disappearing? (D3DXFONT)

8 posts in this topic

Hi,

When I start my 3D engine and load scene etc., I output text on the Window to show progres.

- scene file loaded
- d3d device initialized
etc.

Before I enabled the debug version of D3D (instead of retail) version, everything worked fine. Now in debug, I get notes about 'present' cannot we between beginscene and endscene. I've read that this might have to do that my graphic card supports it (retail mode) but some others might not.
I figured, let's solve it so it works always.

Can anyone give me some pointers on what I might be doing wrong?
(by the way, my print function counts the line number in the object, goes one up after each call)

Here's the sample code:
[source lang="cpp"]_d3d.mD3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), NULL, 0);

// compiling those 4 lines and the 4 lines below, gives as result:
// green background color, first line of text not shown, 2nd line (code below) shown on black //background

_d3d.mD3ddev->BeginScene();
_d3d.mD3dFont.Print((char*)console_initdi);
_d3d.mD3ddev->EndScene();
_d3d.mD3ddev->Present(NULL, NULL, NULL, NULL);


// do other stuff


// only compiling these 4 lines of code, shows text correctly
_d3d.mD3ddev->BeginScene();
_d3d.mD3dFont.Print((char*)console_loadscn);
_d3d.mD3ddev->EndScene();
_d3d.mD3ddev->Present(NULL, NULL, NULL, NULL);
[/source] Edited by cozzie
0

Share this post


Link to post
Share on other sites
You don't have to (or better said - you shouldn't) call BeginScene, EndScene and Present for every single draw call, but only once per render target. If you render only to the default backbuffer, you just call BeginScene at the beginning, then do all drawing (including text), then at the end call EndScene followed by Present.

[source lang="cpp"]
_d3d.mD3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), NULL, 0);
_d3d.mD3ddev->BeginScene();
_d3d.mD3dFont.Print((char*)console_initdi);

// do other stuff

_d3d.mD3dFont.Print((char*)console_loadscn);
_d3d.mD3ddev->EndScene();
_d3d.mD3ddev->Present(NULL, NULL, NULL, NULL);

[/source]
0

Share this post


Link to post
Share on other sites
Hi, thanks for the reply.
I'll try that, but I wonder if it will solve my problem, because what I'm trying to do is give a progress update on things being loaded, meaning I want to 'present'/draw each line as soon as a stap has finished. In your example/ reply I believe all text is rendered in the end, when I exectute 'present'? (or am I overseeing something).
0

Share this post


Link to post
Share on other sites
As suggested, you should only call Present once per frame. I don't believe you will need to have "load progress" updates faster than once per frame, but if you do, I suggest piping them to OutputDebugStream, a log file or a special console window instead of to the screen.
0

Share this post


Link to post
Share on other sites
[quote name='cozzie' timestamp='1353916682' post='5004139']
In your example/ reply I believe all text is rendered in the end, when I exectute 'present'? (or am I overseeing something).
[/quote]
Yes, that's correct, when you call present, the content of backbuffer is swapped with frontbuffer and thus displayed on the screen.

The code you posted is executed in your main loop (every frame) or is it just "linear" code, something like:
- print something on the screen
- do something
- add some other text on the screen
- do something
- add some other text on the screen
- end

If the later, then I'm afraid it won't be so easy. In DirectX you normally do your drawing every frame (for example 60 times per second), even if nothing changed on the screen. If you want to display some text, like a console (dos window), you could add the text to some buffer (for example std::vector<string> where each entry is one line or one message) whenever you want to add a new line on the screen, and display this whole vector every frame. Edited by Tom KQT
0

Share this post


Link to post
Share on other sites
What I'm trying to do here is 'one time' execution, not for each frame.
The order is:
1. initialize direct3d
=> print a line of text in window/ fullscreen with LPD3DXFONT
(including making it visible)
2. initialize directinput
=> print a line of text in window/ fullscreen with LPD3DXFONT
(including making it visible)
3. load scene file
etc. etc.

So it's not something which I do for each frame (it's the initialisation phase, before rendering the scene frame by frame). With frame by frame rendering, I have no issues with printing text in each frame.
0

Share this post


Link to post
Share on other sites
Hi Tom,
It's the latter, inital startup of my engine, not during scene rendering frame by frame.

With the reactions I now think I would have two options.
One being:
1. clear buffers, begin scene, print text, end scene, present
2. don't clear buffers, begin scene, print text, end scene, present
3. etc..
that way I keep the 'normal frame rendering' in place, without clearing the frontbuffer.


Two being:
1 - clear buffers. begin scene
2 - print text to frontbuffer directly
3 - print text to frontbuffer directly
... etc.
x - end scene


One I didn't get working up till now, two I don't know if this is possible.
0

Share this post


Link to post
Share on other sites
If you don't render your scene each frame, you'll have problems everytime the window or its part needs to be redrawn. That means for example:
- in windowed mode when you move the window partly behind the edge of the screen
- in windowed mode when another window is displayed over your application window
- in windowed mode when you minimize the window
- in fullscreen mode when you alt-tab away

In this cases the part of the window (or the whole window) will be white until you swap buffers by calling present again.
Normally you call present frequently so you don't notice it, or you call present also as a reaction to the WM_PAINT windows message which tells you that the window needs to be redrawn. Neither is possible in your case.

[quote name='cozzie' timestamp='1353972471' post='5004349']
2 - print text to frontbuffer directly
[/quote]
I don't think you can do this in DirectX, but I never even thought about it so who knows :)
0

Share this post


Link to post
Share on other sites
Thanks.
I think I'll go for a simple 'buffer'/ string array then, during the initialization process.
Just draw the new succeeded step in loading, including the earlier ones, and then render all lines at once
(and delete the array after last progress update).
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