SFML community forums

Bindings - other languages => DotNet => Topic started by: snoopdloop on February 11, 2013, 09:28:45 pm

Title: [RESOLVED] Issue with Render States after non texture draw
Post by: snoopdloop on February 11, 2013, 09:28:45 pm
I have run into the following issue when attempting to draw vertex arrays of non and textured rendered states.  The following code works with no issues.

                        m_CacheSize = 0;
                       
                        m_RenderState.Texture = tex;
                       
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(0, 0), new Vector2f(0, 0));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(300, 0), new Vector2f(300, 0));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(300, 300), new Vector2f(300, 300));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(0, 300), new Vector2f(0, 300));
                       
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(300, 0), new Vector2f(0, 0));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(600, 0), new Vector2f(300, 0));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(600, 300), new Vector2f(300, 300));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(300, 300), new Vector2f(0, 300));
                       
                        window.Draw(m_VertexCache, PrimitiveType.Quads, m_RenderState);
 

When i put a filled rectangle prior in the vertex array, the alpha mode is ignored when drawing the second textured image.  code as follows

                        m_CacheSize = 0;
                       
                        // Set up for rectangle
                        m_RenderState.Texture = null;
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(300, 300), new Color(255,0,0,255));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(600, 300), new Color(255,0,0,255));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(600, 600), new Color(0,0,0,255));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(300, 600), new Color(0,0,0,255));
                       
                        window.Draw(m_VertexCache, PrimitiveType.Quads, m_RenderState);

                        m_CacheSize = 0;
                       
                        m_RenderState.Texture = tex;
                       
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(0, 0), new Vector2f(0, 0));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(300, 0), new Vector2f(300, 0));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(300, 300), new Vector2f(300, 300));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(0, 300), new Vector2f(0, 300));
                       
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(300, 0), new Vector2f(0, 0));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(600, 0), new Vector2f(300, 0));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(600, 300), new Vector2f(300, 300));
                        m_VertexCache[m_CacheSize++] = new Vertex(new Vector2f(300, 300), new Vector2f(0, 300));
                       
                        window.Draw(m_VertexCache, PrimitiveType.Quads, m_RenderState)

 

Any suggestions or possible known issues there are?  I have also included the source of this project as an attachment, you will need to make sure the libraries are in the same directory as the bin.

Im running on a windows 7 machine in 64 bit with an 6400 nvidia card.

Thanks

[attachment deleted by admin]
Title: Re: Issue with Render States after non texture draw
Post by: krzat on February 12, 2013, 07:53:05 pm
In IssueTextures you are setting vertices for gradient, but you are drawing whole array. Try:
window.Draw(m_VertexCache, 0,4, PrimitiveType.Quads, m_RenderState);
Title: Re: Issue with Render States after non texture draw
Post by: snoopdloop on February 12, 2013, 11:12:37 pm
ahh ha, that was the issue, i needed to only include the vertices for that primitive being that it does not use a texture to render the state.

Thanks krzat.