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 - JollyGent

Pages: [1]
1
Graphics / Re: texture.update() problem
« on: May 27, 2015, 02:34:08 pm »
Thank you for the reply.

Now we know the problem, I'm going to post the bigger picture.

First of all, how my program works is that in the MainGameState's constructor, Map->load() function is called, which look like this.

void Map::load(std::string filename){

   // this->texture->loadFromFile("resources/" + filename);

    std::ifstream openMap("resources/" + filename);

    std::getline(openMap,this->tileset);

    this->tile_width = 64; // there are no methods of converting string to integer in 32 bitMinGW, so let's just fix it to 64 bits.
    this->tile_length = 64;
    this->width = 20;
    this->length = 12;


    this->tile->loadFromFile("resources/tiles.png");

    this->data = new int[this->width * this->length];

    for(int y = 0;y < this->length;y++){
        for(int x =0;x < this->width;x++){
            char temp;
            openMap >> this->data[x + y * this->width] >> temp;
          //  std::cout << this->data[x+y*this->width];
          //  manage.add("stone",stone);
        }
    }

    openMap.close();

    sf::Image tile1,tile2,tile3,tile4,tile5;

    tile1.create(64,64);
    tile2.create(64,64);
    tile3.create(64,64);
    tile4.create(64,64);
    tile5.create(64,64);

    tile1.copy(*this->tile,0,0,sf::IntRect(0,0,this->tile_width,tile_width)); // stone
    tile2.copy(*this->tile,0,0,sf::IntRect(64,0,this->tile_width,tile_width)); // dark stone
    tile3.copy(*this->tile,0,0,sf::IntRect(0,64,this->tile_width,tile_width));
    tile4.copy(*this->tile,0,0,sf::IntRect(64,64,this->tile_width,tile_width));
    tile5.copy(*this->tile,0,0,sf::IntRect(128,0,this->tile_width,tile_width));



    for(int y = 0;y<this->length;y++){ //runs through all of the data[] and assigns each to a texture.
        for(int x =0;x < this->width;x++){

            switch(this->data[x+y*this->width]){

            case 1:

              /*  this->texture->loadFromImage(tile1);
                this->tiles->setTexture(*this->texture);
                this->tiles->setPosition(x*64,y*64);
                manage.add("tile2",tiles);*/


                this->texture->loadFromImage(tile1);


                break;

            case 2:

               /* this->texture->loadFromImage(tile2);
                this->tiles->setTexture(*this->texture);
                this->tiles->setPosition(x*64,y*64);
                manage.add("tile2",tiles); */



                this->texture->update(tile2,x*64,y*64);

                break;

            case 3:

                /*this->texture->loadFromImage(tile3);
                this->tiles->setTexture(*this->texture);
                this->tiles->setPosition(x*64,y*64);
                manage.add("tile3",tiles); */


                this->texture->update(tile3,x*64,y*64);


                break;

            case 4:

                /*this->texture->loadFromImage(tile4);
                this->tiles->setTexture(*this->texture);
                this->tiles->setPosition(x*64,y*64);
                manage.add("tile4",tiles);*/


                this->texture->update(tile4,x*64,y*64);


                break;

            case 5:

                /*this->texture->loadFromImage(tile5);
                this->tiles->setTexture(*this->texture);
                this->tiles->setPosition(x*64,y*64);
                manage.add("tile5",tiles);*/


                this->texture->update(tile5,x*64,y*64);

                break;
            default:

                break;


            }
        }
    }



    this->setTexture(*this->texture);

}



 

the reason I use copy is that the "tiles.png" is the tileset, and each tile is supposed to represent the different parts of the tile.

Surely, if the problem is that the file is loaded over and over, it wouldn't happen in this case where the map is rendered only once?

2
Graphics / texture.update() problem
« on: May 27, 2015, 01:56:17 pm »
I am making a mini zombie survival game in SFML, and what I'm trying to do at the moment is to render the map. However, when I try to use the line:

this->texture->update(tile1,x*64,y*64);


it crashes, and at first I thought it is because the image size is too big or something, or I made a derp in the development process, so I created a minimal code, and please note, I made sure the
"Stones.png"
is 64x64.


#include<iostream>
#include<SFML/Graphics.hpp>
#include<SFML/Window.hpp>

int main(){

    sf::Image image;
    sf::RenderWindow window(sf::VideoMode(800,600),"minimal code");
    sf::Texture texture;
    sf::Event event;

    while(window.isOpen()){

        while(window.pollEvent(event)){

            if(event.type == sf::Event::Closed){
                window.close();
            }

        }


        image.create(64,64);
        image.loadFromFile("Stones.png");
        texture.update(image,64,64);


    }


}

 


now that the context of the minimal code is given, I should also tell you that

 texture.update(image,64,64);
is what causes the problem.



here is the png, just so you can do a quick test.

3
SFML projects / Re: space shooter
« on: April 11, 2015, 01:04:48 am »
Tbh it feels like I achieved nothing but I feel so proud like I set a foundation towards my aspirations! too bad GCSEs and laziness are holding me down on 100% concentration on development :P

4
SFML projects / space shooter
« on: April 07, 2015, 10:56:41 pm »


little game I have developed.

http://www.mediafire.com/download/xggge5cn9e2smd8/SpaceShooter.7z

^ that is the coding. I am still clumsy with SFML, but I am proud I managed to finish a project from scratch.

5
Graphics / Re: Basic rendering crashing
« on: January 18, 2015, 01:20:14 am »
I have checked and I am sure that I am using the correct versions and compilers.

Since the window.draw(shape) is what's causing the problem, I wondered if it's the driver that is causing the problem, so I tried to open a random steam game and here was the result:



I have checked the device manager and:



Apparently I need to disable a graphics driver in order for my actual driver to work, however as you can see from the device manager I only have one graphics driver(Intel graphics HD) available. Maybe it's due to the fact that this hard drive is not mine but my friend's, so I deleted his AMD catalyst graphics driver, but that doesn't seem to cut it.

It seems like it's the driver. In which case, I don't think there is a resolve to. :(

6
Graphics / Re: Basic rendering crashing
« on: January 17, 2015, 04:15:10 pm »
I didn't have any 2.1 files in first place so I don't think I can have 2.1 DLLS I kept deleting and re-downloading over and over again D:

7
Graphics / Re: Basic rendering crashing
« on: January 17, 2015, 03:17:39 pm »


this is how I linked it. Perhaps this is what's causing the problem?

As soon as I add

window.draw(shape);

it crashes. I know where the problem is coming from, I just have no idea how to fix it

8
Graphics / Re: Basic rendering crashing
« on: January 15, 2015, 12:12:34 am »
If you look at the image in the OP that is all I'm getting in the debugger

D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderTarget.cpp: No such file or directory.
#1  0x00404c18 in sf::RenderTarget::applyBlendMode (this=0x28fce8, mode=...) at D:\sfml-release\_Sources\SFML\src\SFML\Graphics\RenderTarget.cpp:445

Apparently RenderTarget doesn't exist?!

9
Graphics / Re: Basic rendering crashing
« on: January 14, 2015, 11:55:22 pm »

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}


 

That's literally all I need to do. To render. The example code in the tutorial alone is enough to cause problem. The graphic driver I updated, re-downloaded, tried everything. I guess this just doesn't work for me haha  :P

10
Graphics / Re: Basic rendering crashing
« on: January 14, 2015, 11:08:17 pm »
Checking for existence: C:\Users\family\Desktop\C++ programming studies\January 2015\Hello World!\bin\Debug\Hello World!.exe
Executing: "C:\Program Files (x86)\CodeBlocks/cb_console_runner.exe" "C:\Users\family\Desktop\C++ programming studies\January 2015\Hello World!\bin\Debug\Hello World!.exe"  (in C:\Users\family\Desktop\C++ programming studies\January 2015\Hello World!\.)

I just got this hard drive from my friend because my old hard drive broke. It seems that the program builds perfectly fine and runs fine, but it keeps crashing. If I remove code and just try to create a window, the window opens up fine. It's just when I try to render the graphics.

11
Graphics / Basic rendering crashing
« on: January 13, 2015, 11:41:40 pm »


I have followed all the tutorial and I have linked to every dependant files like the tutorial asked me to just like opengl32 and etc, and the creating the window works, but when I try to render a basic shape similar to the one in the tutorial my window crashes with no error, and this seems strange because nobody else seems to be having the same problem or if they do, they don't have the same complaints on debugging mode(shown above).
What could be the problem? I thoroughly apologise if this is a stupid question

Oh, also, my first post :D nice to meet you all

Pages: [1]