Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [RESOLVED] Issue with Render States after non texture draw  (Read 2826 times)

0 Members and 1 Guest are viewing this topic.

snoopdloop

  • Newbie
  • *
  • Posts: 2
    • View Profile
[RESOLVED] Issue with Render States after non texture draw
« 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]
« Last Edit: February 12, 2013, 11:17:11 pm by snoopdloop »

krzat

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: Issue with Render States after non texture draw
« Reply #1 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);
SFML.Utils - useful extensions for SFML.Net

snoopdloop

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Issue with Render States after non texture draw
« Reply #2 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.

 

anything