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

Pages: [1]
1
General / Is there any way to use shaders on opengl es 1.4?
« on: October 15, 2017, 12:06:13 am »
I don't want to remake my game in directx, so, i want to know if there's any hope to get shaders working on the opengl es version i currently have.

2
General / Re: Crash after too many objects in screen
« on: October 12, 2017, 01:16:32 pm »
I found what's happening!

Code: [Select]
int8_t i;

for (const auto& x : objects)
{
objects[i].update();
objects[i].draw(m_window);
i++;
}

i = 0;

I declared a signed int8_t variable, which explains why the object limit was being 127!!!
So, i changed it to a unsigned short, and now i can have 65535 objects in screen.

Thanks for the help guys!

3
General / Re: Crash after too many objects in screen
« on: October 12, 2017, 01:01:47 pm »
I ran the debugger, and after the crash, this appear in the debugger
Code: [Select]
Program received signal SIGSEGV, Segmentation fault.
At Core.cpp:73

Core.cpp:73 is the  objects.update();

4
General / Re: Crash after too many objects in screen
« on: October 12, 2017, 12:42:19 pm »
Do you mean that's happening stack overflow?
Then, how i can fix it? Because the game crashes after the first object when i do this:
Code: [Select]
std::vector<GameObject*> objects;

if (sf::Keyboard::isKeyPressed(sf::Keyboard::B))
{
    GameObject* obj = new GameObject(sortOfATex);
    objects.push_back(obj);
    delete obj;
}

int8_t i;

for (const auto& x : objects)
{
objects[i]->update();
objects[i]->draw(m_window);
i++;
}

i = 0;


5
General / Crash after too many objects in screen
« on: October 12, 2017, 02:45:58 am »
My game crashes after my objects vector's size gets higher than 127.

This is my code

--- Main loop function
Code: [Select]
// Set the FPS limit of the window
m_window.setFramerateLimit(60);

// Activate the window
m_window.setActive(true);

// Disable lighting
glDisable(GL_LIGHTING);

// Configure the viewport (the same size as the window)
glViewport(0, 0, m_window.getSize().x, m_window.getSize().y);

// Enable OpenGL
glEnable(GL_TEXTURE_2D);

// Load all scenes
SceneTest sc_0;
scenes.push_back(&sc_0);

sf::Texture sortOfATex;
sortOfATex.loadFromFile("data/uglie.gif");

// Main game loop
while (m_window.isOpen())
{
// Event
sf::Event event;

while (m_window.pollEvent(event))
{
// Close the game when the [X] button is clicked
if (event.type == sf::Event::Closed)
m_window.close();
}

// Clear the buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Run the scene
scenes[currentScene]->run(m_window);

if (sf::Keyboard::isKeyPressed(sf::Keyboard::B))
{
GameObject obj(sortOfATex);
objects.push_back(obj);
}

int8_t i;

for (const auto& x : objects)
{
objects[i].update();
objects[i].draw(m_window);
i++;
}

i = 0;

// Display the things on the window
m_window.display();

}
--- GameObject
Source file
Code: [Select]
#include "GameObject.hpp"

GameObject::GameObject(sf::Texture& text)
    : spr(text)
{}

GameObject::~GameObject() {}

void GameObject::update()
{
    spr.move(1, 0);
}

void GameObject::draw(sf::RenderWindow& w)
{
    w.draw(this->spr);
}
Header
Code: [Select]
#ifndef GAMEOBJECT_HPP
#define GAMEOBJECT_HPP
#include <SFML/Graphics.hpp>

class GameObject
{
    public:
        GameObject(sf::Texture& text);
        virtual ~GameObject();
        virtual void    update();
        virtual void    draw(sf::RenderWindow& w);
    private:
        sf::Sprite      spr;
};

#endif // GAMEOBJECT_HPP

Thanks for reading.

Pages: [1]
anything