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.


Topics - Carlitox

Pages: [1]
1
I updated windows 10 and now i cannot see my game in fullscreen mode. If i keep pressed the windows button + M  on the keyboard  I see the game in fullscreen mode without the black screen.

2
Graphics / Pure black causes flickering when moving view?
« on: August 06, 2016, 06:46:20 pm »
I was using pure black to draw tiles, i had problems with flickering and discovered that some tiles were flickering and other not (pure black ones). Then i changed the color and make it clearer and solved the issue.

My position and origins are all integers. The camera movement is in integer value.

In my laptop there is no problem with this color but in my Pc the problem exists.

3
Graphics / [SOLVED] How to detect in sfml that opengl driver fails?
« on: August 03, 2016, 06:11:02 pm »
In intel g41 chipset my game is showing an error telling that "open gl cannot use vsync so i will see artifacts" I cannot access anymore to that computer so i cannot write the exact error message.

Something similar to this but not sure if is this message:

Quote
OpenGL extension SGIS_texture_edge_clamp unavailable
Artifacts may occur along texture edges
Ensure that hardware acceleration is enabled if available

I cannot use sf::RenderTextures in that computer and when i draw directily to the screen without render texture the cpu goes to 50% instead of 3%.

What can i do to detect this in my code and show the correct message for the player? By the moment the message is seen in the console.

The version of sfml is 2.3.2.


4
Graphics / Graphics Glitch depending on game view and screen size
« on: May 09, 2016, 01:23:21 am »
The glitch is  pixels not stretching proportionally. The only way i found to avoid the issue it's to use view size thar are multiple of the screen size. For example:

window.setSize(1024, 768);
view.setSize(256, 192)

In this case the window is multiple of four. Other example is:

window.setSize(800, 600);
view.setSize(200, 150)

I'm using integer values in the view position.

5
I draw my entities to a sf::RenderTextures and it caused a "vibration effect". That is solved using std::floor in my moving functions. But this affects to my collision system, I want to avoid to use render textures to draw entities but keep the map as a sf::RenderTexture.

I'm drawing my map into a sf::RenderTexture because I was having tearing problems and that solved the issue. So it seems that I'm forced to draw my entities also in the render texture The problem it's that I use 5 map layers, entities are drawn in the third ¿There is a way to render my entities without using a sf::RenderTexture? Using normal draw without the render texture doesn't show my entities, only after the last layer is drawn.

I cannot draw the entities between layers, and if I use render texture it causes the vibration effect.

PD: Forum quotes aren't working. The code draws map and entites into the buffer and display it.

void Map::draw_layer(sf::RenderTarget &target, int layer_id)
{
        if (tmx_info.num_layers >= layer_id)
        {
                sf::RenderStates states;
                states.texture = &map_layers[layer_id].texture;

                if (layer_id == 2)
                {
                        for (auto j : World::current_level->getSceneVector())
                        {
                                assert(j != nullptr);
                                texture_map.draw(*j);                  
                        }
                }

                texture_map.draw(map_layers[layer_id].entity_vertex, states);
                texture_map.display();
                sf::Sprite draw_map(texture_map.getTexture());
                target.draw(draw_map);
        }      
}
 

6
Graphics / Moving camera causes graphic glitch. My investigation.
« on: February 18, 2016, 01:35:28 am »
I use SFML-2.3.2-windows-vc14-32-bit in Visual Studio 15. It happens in my PC and in my laptop. Look to the brick joints, when I move the character the joints changes the widths. Look the picture, different sizes.



And video in movement:



 

This not happens when I resize the window manually. That could be a clue. Only making the window bigger in the resize.



Look the tile map in Tiled. It not happens only in the edges of the tile because. The joints are where it's more visible but there areanother  pixels that changes width.










It seems like a graphics glitch but maibe it's the way I set the textures and the positions. ¿Precision problem? Here you have my code where I set the Quads of each tile.

std::vector<int> map = all_map[layer_id];
        LayerObject layer;
        layer.texture.loadFromFile(spritesheet);
        layer.entity_vertex.setPrimitiveType(sf::Quads);
        layer.entity_vertex.resize(width * height * 4); // Each tile have 4 vertex
        layer.layer_id = layer_id;
        //sf::Vector2u TS(tmx_info.tile_size.x, tmx_info.tile_size.y); //TILE_SIZE
       
        sf::Vector2u TS(16, 16); //TILE_SIZE

        for (unsigned int i = 0; i < height; ++i)
        {
                for (unsigned int j = 0; j < width; ++j)
                {
                        unsigned int tile_pos = j + i*width;
                        unsigned int tile_texture_num = 0;

                        //TR = Tile Row // TC =Tile column
                        unsigned int TR = map[tile_pos] / (layer.texture.getSize().x / TS.x); //TILE_ROW
                        unsigned int TC = ((map[tile_pos]) % (static_cast<int>(layer.texture.getSize().x / TS.x))); //TILE_COLUMN

                        sf::Vertex* quad = &layer.entity_vertex[tile_pos * 4];


                        quad[0].position = sf::Vector2f( j * TS.x ,      i * TS.y);
                        quad[1].position = sf::Vector2f((j + 1) * TS.x,  i * TS.y);
                        quad[2].position = sf::Vector2f((j + 1) * TS.x, (i + 1) * TS.y);
                        quad[3].position = sf::Vector2f( j * TS.x ,     (i + 1) * TS.y);
                       
                       
                        quad[0].texCoords = sf::Vector2f( TC * TS.x ,       TR * TS.y );
                        quad[1].texCoords = sf::Vector2f((TC + 1) * TS.x ,  TR * TS.y );
                        quad[2].texCoords = sf::Vector2f((TC + 1) * TS.x , (TR + 1) * TS.y);
                        quad[3].texCoords = sf::Vector2f( TC * TS.x ,      (TR + 1) * TS.y);
                       
                }
        }

       
        map_layers.push_back(layer);


7
When there is only one key I use this function to check when one key is released:

if (GameApp::event.type == sf::Event::KeyReleased && GameApp::event.key.code == sf::Keyboard::Right)
{

}
 

But when there are two keys pressed at the same time and I release one the event it's not handled.


PD: Sorry it's solved, the code works but I was checking inside a function that it's executed only when a key it's pressed so  I wrote again the function.

8
General / Separating axis theorem: Circle and rotated square
« on: January 19, 2015, 04:02:34 pm »
In one tutorial I've found on the internet tells that I must project the center of the circle into the 3 axis, 2 axis will be from the square and one is the vector from the center of the circle to the nearest point of the square.

My problem it's that I don't know how to add the radius to the center proyection. Now the rectangle collides only with the circle center but I don't know how to collide the perimeter.

http://www.sevenson.com.au/actionscript/sat/



bool satBoxCircle(const sf::RectangleShape& object1, const sf::CircleShape& object2)
{
        sf::Vector2f Points[4];
        Points[0] = object1.getTransform().transformPoint(0.f, 0.f);
        Points[1] = object1.getTransform().transformPoint(object1.getSize().x, 0.f);
        Points[2] = object1.getTransform().transformPoint(object1.getSize().x, object1.getSize().y);
        Points[3] = object1.getTransform().transformPoint(0.f, object1.getSize().y);
        sf::Vector2f circle_center(object2.getPosition().x + object2.getRadius(), object2.getPosition().y + object2.getRadius());

        //Find nearest square vertex to the circle center
        int index = 0;
        float min_distance = distance(Points[0], circle_center);
//Proyect square
        for (int i = 0; i < 4; i++)
        {
                if (distance(Points[i], circle_center) < min_distance)
                {
                        min_distance = distance(Points[i], circle_center);
                        index = i;
                }
        }

        sf::Vector2f Axis[3] = {
                sf::Vector2f(Points[1].x - Points[0].x, Points[1].y - Points[0].y),
                sf::Vector2f(Points[1].x - Points[2].x, Points[1].y - Points[2].y),
                sf::Vector2f(Points[index].x - circle_center.x, Points[index].y - circle_center.y)
        };

        //Proyect each point into each axis and find min and max
        for (int i = 0; i < 3; i++)
        {
                float box_min = 0.f, box_max = 0.f;
                box_min = dotProduct(Points[0], Axis[i]);
                box_max = box_min;

                for (int j = 0; j<4; j++)
                {
                        float projection = dotProduct(Points[j], Axis[i]);
                        if (projection<box_min) box_min = projection;
                        if (projection>box_max) box_max = projection;
                }

                float circle_center_projection = dotProduct(circle_center, Axis[i]);
                if (!((circle_center_projection <= box_max)) && (circle_center_projection >= box_min)) return false;
        }
       
        return true;
}
 

9
Graphics / Modify a VertexArray in game
« on: January 05, 2015, 03:30:33 am »
The problem is that when a modify a vertexarray the modifications are in the bottom layer and the object that I want to refresh remains in the top layer.

This is a code of an animation, it works but if I put it in the same position of another quad it will be covered by the static object that i want to modify.



for (auto &itr1 : tiled_map_animations)
        {
                for (auto &itr2 : ids)
                {
                        if (tmx_info.maps[2][itr2]+ 4 == itr1.first)
                        {      
               
                                sf::Vertex* quad = &map_layers[2].entity_vertex[itr1.first * 4];

                                float x = itr1.second[current_anim].left;
                                float y = itr1.second[current_anim].top;

                                float w = itr1.second[current_anim].width;
                                float h = itr1.second[current_anim].height;
                                float pos_x = (itr2 % map_width) * tile_width;
                                float pos_y = (itr2 / map_width) * tile_height;

                                quad[0].texCoords = sf::Vector2f(x, y);
                                quad[1].texCoords = sf::Vector2f(x + w, y);
                                quad[2].texCoords = sf::Vector2f(x + w, y + h);
                                quad[3].texCoords = sf::Vector2f(x, y + h);

                                quad[0].position = sf::Vector2f(pos_x, pos_y);
                                quad[1].position = sf::Vector2f(pos_x + w, pos_y);
                                quad[2].position = sf::Vector2f(pos_x + w, pos_y + h);
                                quad[3].position = sf::Vector2f(pos_x, pos_y + h);

                        }
                }
        }




Pages: [1]