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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MenosGrandes

Pages: [1]
1
Graphics / Re: SFML updateTexture error
« on: November 02, 2015, 08:42:07 pm »
Point (0,0,0) is in the center of the view space. The Triangle in TGA is correctly drawn, but when I'm rewriting the data to the SFML the texture flip out..


2
Graphics / Re: SFML updateTexture error
« on: November 02, 2015, 08:07:56 pm »
Dispise the colors, why the triangle is upside down?

3
Graphics / SFML updateTexture error
« on: November 02, 2015, 07:11:07 pm »
Im on Windows 8.1 with MinGw32 4.8.1-4 using SFML 2.1. Because all precompiled versions don't work, but it's not the point.

I have
    m_pixels = new Colour[width*height];
 
where Colour have     
 unsigned char r,g,b,a;
Now I'm trying to rewrite all pixels from m_pixels to   
 sf::Uint8 * pixels = new sf::Uint8[img_size.x*img_size.y*4];
 
using
void RenderTarget::rewritePixelForTexture(d_type::Bubyte* pixels)
{
    for (d_type::Bint i=0; i<m_size.x*m_size.y ; i++)
    {
        d_type::Bint k=i*4;
        pixels[k+3]=m_pixels[i].a;
        pixels[k+2]=m_pixels[i].r;
        pixels[k+1]=m_pixels[i].g;
        pixels[k]  =m_pixels[i].b;

    }

}

Whole main.cpp :
sf::RenderWindow window(sf::VideoMode(img_size.x, img_size.y), "RENDERER!");

    sf::Texture texture;
    if (!texture.create(img_size.x, img_size.y))
    {
        std::cout<<"ERROR WITH TEXTURE\n";
    }

    sf::Sprite sprite(texture);

    sf::Uint8 * pixels = new sf::Uint8[img_size.x*img_size.y*4];
    sf::Clock FPSClock;
    std::stringstream ss;
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }


        file->rewritePixelForTexture(pixels);
        texture.update(pixels);

        window.clear();
        window.draw(sprite);

        window.display();

        ss<<getFPS(FPSClock.restart());

       window.setTitle(ss.str());
       ss.str("");


    }
And now to the core. This program supose to be softwere renderer, so NOT USING OPENGL\DIRECTX to render objects. I'm using the SFML only for window. And I have class to draw to file, simple TGA


void RenderTarget::drawToFile(std::string m_filename)
{
    //Error checking
    if (m_size.x <= 0 || m_size.y <= 0)
    {
        std::cout << "Image size is not set properly\n";
        return;
    }

    std::ofstream o(m_filename.c_str(), std::ios::out | std::ios::binary);

    //Write the header
    o.put(0);
    o.put(0);
    o.put(2);                         /* uncompressed RGB */
    o.put(0);
    o.put(0);
    o.put(0);
    o.put(0);
    o.put(0);
    o.put(0);
    o.put(0);           /* X origin */
    o.put(0);
    o.put(0);           /* y origin */
    o.put((m_size.x  & 0x00FF));
    o.put((m_size.x & 0xFF00) / 256);
    o.put((m_size.y  & 0x00FF));
    o.put((m_size.y  & 0xFF00) / 256);
    o.put(32);                        /* 24 bit bitmap */
    o.put(0);

    //Write the pixel data
    for (d_type::Bint i=0; i<getSizePixels() ; i++)
    {
        o.put(m_pixels[i].b);
        o.put(m_pixels[i].g);
        o.put(m_pixels[i].r);
        o.put(m_pixels[i].a);
    }

    //close the file
    o.close();
}
And this is the resault. The triangle is in position:
Vector3Bf(0,0,0),Vector3Bf(0.5f,0.5f,0),Vector3Bf(0.5f,0,0)
But the file and the Texture/Sprite are different.

And my question is simple.. WHY?....
https://imgur.com/a/lb8L5

4
General / SFGUI ScrolledWindow problem
« on: August 01, 2015, 03:38:43 pm »
Hi I have little problem..
When I'm adding elements to ScrolledWindow I have error.

I have class that is container for elements :
   

class RuleAxiomGUI
{
public :
    sfg::Entry::Ptr entryAxiom,entryRule;
    sfg::Label::Ptr labelRule,labelAxiom,labelProbabilityOfAxiom;
    sfg::Adjustment::Ptr probabilityOfAxiom;

    void Add(std::string labelA,std::string labelR,int number,sfg::Box::Ptr box);
    void ProbabilityChange();

};
 
And a method in GUI class that adding elements to sfg::Box::Ptr :

void GUI::AddRule()
{
static int counter=0;
counter++;
SharedRuleAxiomGUI ra(new RuleAxiomGUI());
ra->Add("Axiom","Rule",counter,m_boxAddFractalsViewport);

}
 

I'm creating simple ScrolledView like in tutorial on git so :


/* Create the ScrolledWindow.*/
        auto scrolledwindow2 = sfg::ScrolledWindow::Create();

/* Set the ScrolledWindow to always show the horizontal scrollbar and only show the vertical scrollbar when needed.*/
        scrolledwindow2->SetScrollbarPolicy(  sfg::ScrolledWindow::VERTICAL_AUTOMATIC );
/*Box for viewport*/
    m_boxAddFractalsViewport = sfg::Box::Create( sfg::Box::Orientation::VERTICAL, 5.0f );

/*Add the ScrolledWindow box to the ScrolledWindow and create a new viewport automatically.*/
        scrolledwindow2->AddWithViewport( m_boxAddFractalsViewport );
/* Always remember to set the minimum size of a ScrolledWindow.*/

        scrolledwindow2->SetRequisition( sf::Vector2f( 200.f, 600.f ) );

...

    m_boxAddFractals->Pack(scrolledwindow2,false,true);

 

In debug error occures when I want to add 4-th RuleAxiom and I have this :
#0 0xb7d3ca46   sfg::Container::HandleEvent(sf::Event const&) () (/usr/local/lib/libsfgui.so:??)
#1 0xb7de17b4   sfg::Viewport::HandleEvent(sf::Event const&) () (/usr/local/lib/libsfgui.so:??)
#2 0xb7d3ca52   sfg::Container::HandleEvent(sf::Event const&) () (/usr/local/lib/libsfgui.so:??)
#3 0xb7d3ca52   sfg::Container::HandleEvent(sf::Event const&) () (/usr/local/lib/libsfgui.so:??)
#4 0xb7d3ca52   sfg::Container::HandleEvent(sf::Event const&) () (/usr/local/lib/libsfgui.so:??)
#5 0xb7d3ca52   sfg::Container::HandleEvent(sf::Event const&) () (/usr/local/lib/libsfgui.so:??)
#6 0xb7d3e6d6   sfg::Desktop::HandleEvent(sf::Event const&) () (/usr/local/lib/libsfgui.so:??)
#7 0x804d101    main() (main.cpp:45)
 
main.cpp:45 is:
            gui->desktop.HandleEvent( event );

Is it bug or what?...

Its also on SFGUI forum :
http://sfgui.sfml-dev.de/forum/post2420.html#p2420

5
Graphics / Re: L-System drawer
« on: July 08, 2015, 06:01:36 pm »
I'm so dumb... thank you;)

6
Graphics / Re: L-System drawer
« on: July 07, 2015, 10:03:52 pm »
I have something like this:

float currentRotation=0;
float rotate=90;

sf::Vector2f currentPosition(0,0);

        m_vertices.setPrimitiveType(sf::LinesStrip);
        m_vertices.resize(initializer.length());
       // sf::Vertex* quad2 = &m_vertices[0];
        //m_vertices[0].position = currentPosition;

for(int i=0;i<initializer.length();i++)
{


    char sign=initializer[i];
    switch(sign)
    {
        case '+' :
            //std::cout<<" + ";
/* Rotate left*/
currentRotation+=rotate;

            break;
        case '-' :
            /* Rotate right*/
           // std::cout<<" - ";
currentRotation-=rotate;
            break;
        case 'F' :
           // std::cout<<" F ";
currentPosition.x+=1;
currentPosition.y+=1;
m_vertices[i].position = sf::Vector2f((currentPosition.x), (currentPosition.y));
//std::cout<<quad[i].position.x<<" "<<quad[i].position.y<<"\n";
            break;

    }

}
 

and I dont know how to calulate the rotation..

7
Graphics / L-System drawer
« on: July 07, 2015, 07:13:33 pm »
Hallo I have problem with drawing a L-System.
I have created a class that implementing base L-System, but I don't know how to draw it.
I have tried using sf::VertexArray with sf::LineStrip and sf::RectangleShape. In VertexArray I don't know how to rotate next line.

Any sugesstions?

Pages: [1]