• 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

Losing triangles between VertexShader and OutputMerger

3 posts in this topic

I have successfully created a window and cleared the screen, but I am having trouble taking the next step and drawing a triangle. When I run in the Visual Studio 2012 graphics debugger and view the rendering pipeline, it appears that the triangle is fine in the Input Assembler and Vertex Shader, but by the OutputMerger window it is gone.


I am running with Native symbols and the DirectX SDK, but I'm not getting any errors or warnings. I flattened out my code into one contiguous segment, posted below. The effect fx file is included as well.


Any ideas what may be going wrong?


edit: I forgot to mention that I resize the window to make it re-render many times, and triangles never appear. It is not a matter of culling triangles.


Device device;
SwapChain swapChain;
RenderTargetView renderTargetView;
Effect effect;
//This is the window's Hwnd
Control control = Control.FromHandle(Hwnd);

//BEGIN: Init
SlimDX.DXGI.SwapChainDescription swapDesc = new SlimDX.DXGI.SwapChainDescription
    BufferCount = 1,
    Flags = SlimDX.DXGI.SwapChainFlags.AllowModeSwitch,
    IsWindowed = true,
    ModeDescription = new SlimDX.DXGI.ModeDescription(0, 0,
            new SlimDX.Rational(60, 1), SlimDX.DXGI.Format.R8G8B8A8_UNorm),
    OutputHandle = Hwnd,
    SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
    SwapEffect = SlimDX.DXGI.SwapEffect.Discard,
    Usage = SlimDX.DXGI.Usage.RenderTargetOutput

SlimDX.Result res = Device.CreateWithSwapChain(DriverType.Hardware, 
                                                out device, 
                                                out swapChain);
using (var resource = Resource.FromSwapChain<SlimDX.Direct3D11.Texture2D>(swapChain, 0))
    renderTargetView = new RenderTargetView(device, resource);
var viewport = new SlimDX.Direct3D11.Viewport(0, 0, 
                            control.ClientRectangle.Width, control.ClientRectangle.Height);

file_stream = System.Reflection.Assembly.
byte[] buffer;
buffer = new byte[file_stream.Length];
file_stream.Read(buffer, 0, buffer.Length);

SlimDX.DataStream ds = new SlimDX.DataStream(buffer.Length, true, true);
ds.Write(buffer, 0, buffer.Length);
ds.Position = 0;
ShaderBytecode bc = new ShaderBytecode(ds);
bc = ShaderBytecode.Compile(buffer, "fx_5_0");

effect = new SlimDX.Direct3D11.Effect(device, bc);

//BEGIN: All the following is called on render

//color is set elsewhere to random values. Trippy, but just for debugging
SlimDX.Color4 slimColor = new SlimDX.Color4(color.ToArgb());
device.ImmediateContext.ClearRenderTargetView(renderTargetView, slimColor);

List<Vector3> vert;
//Set to random for debugging purposes. Random values are between 0-1
vert.Add(new Vector3((float)_rand.NextDouble(), 
vert.Add(new Vector3((float)_rand.NextDouble(), 
vert.Add(new Vector3((float)_rand.NextDouble(), 
//simplified for now to Matrix.Identity
Vector4 foregroundColor;//this is set elsewhere

EffectTechnique tech = effect.GetTechniqueByName("RenderUber");
EffectPass pass = tech.GetPassByIndex(0);
_renderer.Signature = effect.GetTechniqueByName("RenderUber").GetPassByIndex									(0).Description.Signature;

DataStream stream = new DataStream(vert.Count * Marshal.SizeOf(Vector3), true, true);
stream.Position = 0;
var vertexBuffer = new SlimDX.Direct3D11.Buffer(device, 
                                                _vertices.Count * Marshal.SizeOf(Vector3), 

var elements = new[] { new InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32_Float, 0)};
var sig = effect.GetTechniqueByIndex(0).GetPassByIndex(0).Description.Signature;
var layout = new InputLayout(device, sig, elements);

context.InputAssembler.InputLayout = layout;
context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, Marshal.SizeOf(Vector3), 0));
context.Draw(vertexCount, 0); //vertexCount is 3 here

_swapChain.Present(0, SlimDX.DXGI.PresentFlags.None);

// File: EffectSimple.fx
// save with encoding: Western European (Windows)- Codepage 1252

//Global variables-------------------------------------------------------------

float4x4 WorldViewProj;
float4 ForeColor;

//Input Output Structures------------------------------------------------------
struct VS_INPUT
	float3 Position   : POSITION;   // vertex position 

struct VS_OUTPUT
	float4 Position   : SV_POSITION;   // vertex position 

struct PS_OUTPUT
	float4 RGBColor : SV_TARGET0;  // Pixel color	

//Vertex Shaders---------------------------------------------------------------

	VS_OUTPUT Output;
	Output.Position = mul(float4(In.Position,1), WorldViewProj);
	return Output;

//Pixel Shaders----------------------------------------------------------------

	PS_OUTPUT Output;
	Output.RGBColor = ForeColor;
	return Output;


technique11 RenderUber
	pass P
		SetVertexShader( CompileShader( vs_4_0, RenderSceneVS() ) );
		SetPixelShader ( CompileShader( ps_4_0, RenderScene2D() ) );
Edited by rtclawson

Share this post

Link to post
Share on other sites

Are you sure culling isn't an issue? It seems very likely to me that since you're randomizing your vertices, that they will often be facing away from the camera and as such will get backface culled. I don't see you setting a rasterizer state anywhere, so I have to assume you're using the defaults, which do indeed cull backfaces.


Share this post

Link to post
Share on other sites

Unfortunately, culling was not the issue. This is what I used to make sure that culling was not the problem.


RasterizerStateDescription description = new RasterizerStateDescription


CullMode = CullMode.None,

FillMode = SlimDX.Direct3D11.FillMode.Solid,


RasterizerState rs = RasterizerState.FromDescription(_device, description);

_device.ImmediateContext.Rasterizer.State = rs;


Any other ideas?


Share this post

Link to post
Share on other sites

I found the issue. The code I posted I had pulled from various parts of my framework. As it turns out, in my framework, I was creating a new RenderTargetView every frame. Sheesh...


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