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

Pages: [1]
1
DotNet / Re: Odd behavior using backbuffer on OSX
« on: July 12, 2016, 03:02:27 am »
Thanks so much, that was it. I had no idea I had to do that first... I'm glad it was something this simple to fix.

What do you think was causing this code to work on Windows but not on Mac?

2
DotNet / Odd behavior using backbuffer on OSX
« on: July 08, 2016, 07:37:10 pm »
Hey guys, I've recently started trying to get my game (which is developed using C# and SFML.NET) to run on Macs. I've followed this guide and gotten it to the point where it compiles and displays things onscreen, but the game is a flickery glitchy mess, which sprites and tiles rapidly appearing and disappearing, etc.

After some investigation trying to create a minimal example, I found that this code (which doesn't use a backbuffer) renders perfectly:

Code: [Select]
using SFML.Graphics;
using SFML.Window;
using SFML.System;

namespace TestSFML {
class MainClass {
public static void Main(string[] args) {
// initialize window
RenderWindow window = new RenderWindow(new VideoMode(640, 480, 32), "SFML Test", Styles.Close);
window.SetVerticalSyncEnabled(true);
window.Clear(Color.Black);
window.Display();

double sqrX = 20, sqrY = 20;

// game loop
while (window.IsOpen) {
window.DispatchEvents();

sqrX += 0.5;
sqrY += 0.5;

window.Clear();
Color rectangleColor = new Color(255, 0, 0);
RectangleShape r = new RectangleShape {
Size = new Vector2f(200, 200),
Position = new Vector2f((float)sqrX, (float)sqrY),
FillColor = rectangleColor,
OutlineColor = rectangleColor,
OutlineThickness = 1
};
window.Draw(r);

window.Display();
}

window.Close();
}
}
}

...but this code (which uses a backbuffer RenderTexture) is unresponsive and glitchy:

Code: [Select]
using SFML.Graphics;
using SFML.Window;
using SFML.System;

namespace TestSFML {
class MainClass {
public static void Main(string[] args) {
// initialize window
RenderWindow window = new RenderWindow(new VideoMode(640, 480, 32), "SFML Test", Styles.Close);
window.SetVerticalSyncEnabled(true);
window.Clear(Color.Black);
window.Display();

// create backbuffer image and sprite
RenderTexture backbuffer = new RenderTexture(640, 480);
Sprite bufferSprite = new Sprite {
Texture = backbuffer.Texture,
TextureRect = new IntRect(0, 480, 640, -480)
};
backbuffer.Clear();

double sqrX = 20, sqrY = 20;

// game loop
while (window.IsOpen) {
window.DispatchEvents();

sqrX += 0.5;
sqrY += 0.5;

backbuffer.Clear();
Color rectangleColor = new Color(255, 0, 0);
RectangleShape r = new RectangleShape {
Size = new Vector2f(200, 200),
Position = new Vector2f((float)sqrX, (float)sqrY),
FillColor = rectangleColor,
OutlineColor = rectangleColor,
OutlineThickness = 1
};
backbuffer.Draw(r);

window.Draw(bufferSprite);
window.Display();
}

backbuffer.Dispose();
bufferSprite.Dispose();
window.Close();
}
}
}

(Both programs are just rendering a red square which moves down and to the right every frame, with VSync on.)

Does anyone know why this could be happening? I'm not getting this issue with the second example on Windows.

I'm using CSFML 2.3.0 and SFML 2.3.2, with SFML.Net 2.2 (so the latest versions of everything). In addition, this is running on a Mac Mini with an Intel HD Graphics 4000 graphics card.

Thanks for your time, guys!
Sri

EDIT: Just tried using SFML 2.3.0 instead (to match CSFML's version number), nothing changed.

3
Graphics / Re: Stuttering / slowdown in windowed mode
« on: May 25, 2012, 12:06:56 am »
I just tried the test code on a computer running Ubuntu Linux 11.04, graphics card GeForce 9400 -- no stuttering or slowdown with any configuration setting (vsync, frame limiting, neither, or both.) Actually, here's a straight up dump of the specs, since I can do that easily on here. I'll post something similar for the PC I made the original post on when I get back home in a bit. I'd really like to solve this issue if possible, I don't want to have to force fullscreen on players (and testing my game in windowed mode is also more convenient for me anyway.)

EDIT: I should probably also mention that, on the Windows PC at least, this is something that seems to happen with every SFML program I open (including e.g. the demos) not just the ones I write. Also, the stutter occurs at a rate of approximately once per second, if that helps.

4
Graphics / Re: Stuttering / slowdown in windowed mode
« on: May 24, 2012, 05:07:41 pm »
If you mean just polling for events in a loop like so:

        sf::Event ev;
        while (game.pollEvent(ev))      {
            if (ev.type == sf::Event::Closed) game.close();
        }

...then no, it doesn't I'm afraid.

5
Graphics / Stuttering / slowdown in windowed mode
« on: May 24, 2012, 06:53:40 am »
Hi,

I've been having a problem with erratic framerate and stutter/slowdown in SFML. This problem has happened both in previous versions of SFML as well as the current release candidate of SFML-2, which I just switched to after hearing some timing issues were fixed. Weirdly enough, this only seems to happen in windowed mode -- everything works fine in fullscreen (no stutter at all.) Enabling VSync, frame limiting to 60fps, or both doesn't help the stuttering, and even without any limiting at all the program still slows down (e.g. it'll be running at 500fps for a small bit then slow down to 100 or lower, then speed up again, etc.)

Here's a small test case (I first encountered this problem when working on a relatively large-scale game project:)

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

int SCR_WIDTH = 640;
int SCR_HEIGHT = 480;
bool FULLSCREEN = false;
bool VSYNC = true;
bool LIMIT_FRAMERATE = false;
int FRAMERATE = 60;

int main()      {
        unsigned long style = ((FULLSCREEN == true) ? sf::Style::Fullscreen : sf::Style::Close);
        sf::RenderWindow game(sf::VideoMode(SCR_WIDTH,SCR_HEIGHT,32), "Test", style);

        game.setVerticalSyncEnabled(VSYNC);
        if (LIMIT_FRAMERATE) game.setFramerateLimit(FRAMERATE);

        sf::Clock frameClock;

        sf::Image redSquareImg;
        redSquareImg.create(128, 128, sf::Color(sf::Color::Red));
        sf::Texture redSquareTex;
        redSquareTex.loadFromImage(redSquareImg);
        sf::Sprite redSquare;
        redSquare.setTexture(redSquareTex);
        int squareX = 20, squareY = 20;

        while (game.isOpen())   {
                frameClock.restart();

                game.clear();

                redSquare.setPosition(squareX, squareY);
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) squareX -= 2;
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) squareX += 2;
                game.draw(redSquare);

                game.display();
                int ft =  1000 / frameClock.getElapsedTime().asMilliseconds();

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) game.close();
                std::cout << ft << std::endl;
        }
}

Running Windows 7, graphics card is NVIDIA GeForce GTX 260. Any help would be greatly appreciated.

Thanks,
Sri

Pages: [1]
anything