• 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
Tim Lawton

Drawing text in DirectX11

0 posts in this topic

Hey there,

I've recently attempted to draw text to my screen in DirectX 11, I have no errors, but I think its the way Im ordering the way things are drawn in my Render function, could an experienced programmer take a look for me and tell me what Im doing wrong?

The outcome it supose to be a 2d bitmap in the top left, a 3d cube spinning in the middle with lighting, and another 2d bitmap in the top right, holding txt, but the surface is alphablended out.

thanks

Graphics::Init
[CODE]
bool Graphics::Init(int screenWidth, int screenHeight, HWND hwnd)
{
bool result;
D3DXMATRIX baseViewMatrix;
//-----------------
// D3D
//-----------------
//Create the Direct3D Object
d3d = new D3D;
if(!d3d)
{
return false;
}
//Initialize the Direct3D Object
result = d3d->Init(screenWidth, screenHeight, VSYNC_ENABLED, hwnd,
FULL_SCREEN, SCREEN_DEPTH, SCREEN_NEAR);
if(!result)
{
MessageBox(hwnd, "Could not initalize Direct3D", "Error", MB_OK);
return false;
}
//-----------------
// CAMERA
//-----------------
// Create the camera object.
camera = new Camera;
if(!camera)
{
return false;
}
//Initialize a base view matrix with the camera for 2D User interface rendering
camera->SetPosition(0.0f, 0.0f, -10.0f);
camera->Render();
camera->GetViewMatrix(baseViewMatrix);

//-----------------
// MODEL (3D)
//-----------------
// Create the model object.
model = new Model;
if(!model)
{
return false;
}
// Initialize the model object.
result = model->Init(d3d->GetDevice(), "Shapes/Cube.txt", "Textures/seafloor.bmp");
if(!result)
{
MessageBox(hwnd, "Could not initialize the model object.", "Error", MB_OK);
return false;
}
//-----------------
// COLORSHADER
//-----------------
// Create the color shader object.
colorshader = new Colorshader;
if(!colorshader)
{
return false;
}
// Initialize the color shader object.
result = colorshader->Init(d3d->GetDevice(), hwnd);
if(!result)
{
MessageBox(hwnd, "Could not initialize the color shader object.", "Error!", MB_OK);
return false;
}
//-----------------
// TEXTURESHADER
//-----------------
//Create the texture shader object
textureshader = new Textureshader;
if(!textureshader)
{
return false;
}
//Initialize the textureshader object
result = textureshader->Init(d3d->GetDevice(), hwnd);
if(!result)
{
MessageBox(hwnd, "Could not load the texutre shader object", "Error!", MB_OK);
return false;
}
//-----------------
// BITMAP (2D)
//-----------------
//Create the bitmap object.
bitmap = new Bitmap;
if(!bitmap)
{
return false;
}
// Initialize the bitmap object.
result = bitmap->Init(d3d->GetDevice(), screenWidth, screenHeight, "Textures/seamlessMetal.jpg", 256, 256);
if(!result)
{
MessageBox(hwnd, "Could not initialize the bitmap object.", "Error", MB_OK);
return false;
}
//-----------------
// LIGHTSHADER
//-----------------
//Create the light shader object
lightshader = new Lightshader;
if(!lightshader)
{
return false;
}
//Initialize the light shader object
result = lightshader->Init(d3d->GetDevice(), hwnd);
if(!result)
{
MessageBox(hwnd, "Could not initialize the light shader object.", "Error!", MB_OK);
return false;
}
//-----------------
// LIGHT
//-----------------
//Create the light object
light = new Light;
if(!light)
{
return false;
}
//Initialize the light object
light->SetAmbientColor(0.15f, 0.15f, 0.15f, 1.0f);
light->SetDiffuseColor(1.0f, 1.0f, 1.0f, 1.0f);
light->SetDirection(0.0f, 0.0f, 1.0f);
light->SetSpecularColor(1.0f, 1.0f, 1.0f, 1.0f);
light->SetSpecularPower(32.0f);
//-----------------
// TEXT
//-----------------
//Create text object
text = new Text;
if(!text)
{
return false;
}
//Initialize the text object
result = text->Init(d3d->GetDevice(), d3d->GetDeviceContext(), hwnd, screenWidth, screenHeight, baseViewMatrix);
if(!result)
{
MessageBox(hwnd, "Could not initialize the text object", "Error!", MB_OK);
return false;
}
return true;
}
[/CODE]




Graphics::Render
[CODE]
bool Graphics::Render(float rotation)
{
//-----------------
// VARIABLES
//-----------------
D3DXMATRIX worldMatrix, viewMatrix, projectionMatrix, orthoMatrix;
bool result;
//-----------------
// BEGIN SCENE
//-----------------
//Clear the buffers to a black screen
d3d->BeginScene(0.0f, 0.0f, 0.0f, 1.0f); //RGBA
//-----------------
// LIGHTING
//-----------------
// Render the model using the light shader.
result = lightshader->Render(d3d->GetDeviceContext(), model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
model->GetTexture(), light->GetDirection(), light->GetAmbientColor(), light->GetDiffuseColor(), camera->GetPosition(),
light->GetSpecularColor(), light->GetSpecularPower());
if(!result)
{
return false;
}
//-----------------
// CAMERA
//-----------------

//Generate the view matrix based on the camera's position
camera->Render();
//Get the world, view, and projection matrices from the camera and d3d objects.
camera->GetViewMatrix(viewMatrix);
d3d->GetWorldMatrix(worldMatrix);
d3d->GetProjectionMatrix(projectionMatrix); //Draw 3D
d3d->GetOrthoMatrix(orthoMatrix); //Draw 2D

//-----------------
// 2D RENDERING
//-----------------
//Turn off the ZBuffer to start 2d rendering
d3d->TurnZBufferOff();
//Turn on alpha blending to start 2d rendering
d3d->TurnAlphaBlendingOn();
//FONT
//Render the text strings
result = text->Render(d3d->GetDeviceContext(), worldMatrix, orthoMatrix);
if(!result)
{
return false;
}
//turn off alpha blending after rendering the text
d3d->TurnAlphaBlendingOff();

//RENDER 2D BITMAP
//Put the bitmap vertex and index buffers on the graphics pipeline to prepare
result = bitmap->Render(d3d->GetDeviceContext(), 1, 1);
if(!result)
{
return false;
}

//RENDER 2D TEXTURE
//Render the bitmap with the texture shader
result = textureshader->Render(d3d->GetDeviceContext(), bitmap->GetIndexCount(), worldMatrix, viewMatrix, orthoMatrix, bitmap->GetTexture());
if(!result)
{
return false;
}
//Turn zBuffer back on for 3D rendering
d3d->TurnZBufferOn();

//-----------------
// ANIMATION
//-----------------
//Rotate
D3DXMatrixRotationY(&worldMatrix, rotation);
//-----------------
// 3D RENDERING
//-----------------
//Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing.
model->Render(d3d->GetDeviceContext());
//-----------------
// 3D TEXTURE
//-----------------
//Render the model using the texture
result = textureshader->Render(d3d->GetDeviceContext(), model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
model->GetTexture());
if(!result)
{
return false;
}
// Render the model using the color shader.
result = colorshader->Render(d3d->GetDeviceContext(), model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix);
if(!result)
{
return false;
}

//-----------------
// END DRAW/SCENE
//-----------------
//Present the rendered scene of teh screen
d3d->EndScene();
return true;
}
[/CODE] Edited by Xuchilbara
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