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

Pages: 1 2 [3] 4 5 ... 13
31
Feature requests / Batch Drawing
« on: February 27, 2012, 08:57:59 pm »
Yea, the current C++ code is:
Code: [Select]
IntroState::IntroState(Game *eGame):
IGameState(eGame)
{
    IntroSprite = sf::Sprite(*(game->textureManager.getFile("./Resources/Images/blah.png", true)));
    if(IntroSprite.GetTexture()->GetWidth() == 8)
        IntroSprite.Scale(800/8.0f, 600/8.0f);
    IntroSprite.SetPosition(sf::Vector2f(0.0f, 0.0f));

    delay = 100.0f;
    alpha = 0.0f;
    disapearing = false;
    appearing = true;
}

IntroState::~IntroState()
{

}

void IntroState::Init()
{

}

void IntroState::Cleanup(){}

void IntroState::Pause(){}
void IntroState::Resume(){}

void IntroState::HandleEvents(sf::Event &Event)
{

}

void IntroState::Update()
{
    sf::Int32 delta = game->getDelta()/100;
    if(appearing && !disapearing)
        alpha += delta * 10.0f;
    else if(!appearing && !disapearing && (alpha > 254.0f))
        delay -= delta* 10.0f;
    else if(!appearing && disapearing)
        alpha -= delta * 10.0f;

    if(alpha > 254.0f && delay > 0.0f)
    {
        disapearing = false;
        appearing = false;
    }

    else if(alpha > 254.0f && delay < 0.0f)
    {
        disapearing = true;
    }

    else if(alpha < -10.0f && delay < 0.0f)
        game->gameStateManager.PopState();

    IntroSprite.SetColor(sf::Color(255,255,255,clamp(0.0f, 255.0f,alpha) ));
}

float IntroState::clamp(float min, float max, float num)
{
    if(num > max) return max;
    if(num < min) return min;
    return num;
}

void IntroState::Draw()
{
    game->App.Draw(IntroSprite);
}


and then this to draw the time:
Code: [Select]

void Game::drawDebug()
{

     std::stringstream ss;
   ss << Game::delta << " ms" << std::endl;

   sf::Text text( ss.str() );
   text.SetPosition(5,5);
   text.SetCharacterSize(10);
   text.SetColor(sf::Color::White);
    App.Draw(text);
}


As for the C#, the map image is 54x42 (whith each tile being 16x16 so the overall size of the VertexArray is just over 800x600) and each point has 4 verteces

32
Feature requests / Batch Drawing
« on: February 27, 2012, 07:57:38 pm »
Quote from: "Laurent"
Try to compare with SFML.Graphics.Color.Black.


MapText is a System.Drawing.Bitmap tho.
I have got it working using:
Code: [Select]
if (mapText.GetPixel(x, y).ToArgb() == System.Drawing.Color.Black.ToArgb() ) {
Console.WriteLine(mapText.GetPixel (x, y));
tx = 1;
ty = 1;
}


Not ideal as I have to use an extra 2 functions just to compare but it does the job.

Anyway now that it has been ported I have noticed some tremendous gains in performance however its still very slow compared to the C++ version, dont get me wrong i know the C# version wont be as fast as teh C++ one but I was hoping better performance than this :S

The image on the left is C++ drawing an 800x600 image using a sprite.
The one on the right is the C# version drawing an 800x600 pixel map with vertex arrays

I should mention the C# version is normally at 190ms, there must have been a small spke due to the screenshot

33
Feature requests / Batch Drawing
« on: February 27, 2012, 07:36:48 pm »
Got it working, however because of the method I currently use to store the map, it isnt loading them.
Not sure if you know of anyway to get these to compare correctly?

Code: [Select]
int tx = 0;
int ty = 0;

if (mapText.GetPixel(x, y) == System.Drawing.Color.Black ) {
Console.WriteLine(mapText.GetPixel (x, y));
tx = 1;
ty = 1;
}

34
Feature requests / Batch Drawing
« on: February 27, 2012, 07:01:05 pm »
Quote from: "Laurent"
There is an examlpe here:
http://www.sfml-dev.org/forum/viewtopic.php?t=7060

If you need more specific help you can describe what you want, and I'll try to write an example for you.


That should work fine, however im trying to implement it with SFML.Net with this code:

Code: [Select]
class Map
{

SFML.Graphics.VertexArray map;
SFML.Graphics.RenderStates state;

public Map ()
{
}

public Map (string filename)
{
System.Drawing.Bitmap mapText = new System.Drawing.Bitmap ("./Resources/Maps/Level1.png");

//Console.WriteLine(mapText.Width + ":" + mapText.Height);

state = new SFML.Graphics.RenderStates (TextureManager.GetFile ("./Resources/Images/Tiles.png"));

map = new SFML.Graphics.VertexArray (SFML.Graphics.PrimitiveType.Quads, (uint)(mapText.Width * mapText.Height * 4));


for (int x = 0; x < mapText.Width; x++) {
for (int y = 0; y < mapText.Height; y++) {

int size = 16;
int width = 16;
uint current = (uint)((x + y *  mapText.Width) * 4);

// define the position of the 4 points of the current tile
map [current ].Position = new SFML.Window.Vector2f ((x + 0) * size, (y + 0) * size);
map [current + 1].Position = new SFML.Window.Vector2f ((x + 0) * size, (y + 1) * size);
map [current + 2].Position = new SFML.Window.Vector2f ((x + 1) * size, (y + 1) * size);
map [current + 3].Position = new SFML.Window.Vector2f ((x + 1) * size, (y + 0) * size);

int tx = 0;
int ty = 0;

if (mapText.GetPixel (x, y) == System.Drawing.Color.Black) {
tx = 1;
ty = 1;
} else {
tx = 0;
ty = 0;
}

map [current + 0].TexCoords = new SFML.Window.Vector2i ((tx + 0) * size, (ty + 0) * size);
map [current + 1].TexCoords = new SFML.Window.Vector2i ((tx + 0) * size, (ty + 1) * size);
map [current + 2].TexCoords = new SFML.Window.Vector2i ((tx + 1) * size, (ty + 1) * size);
map [current + 3].TexCoords = new SFML.Window.Vector2i ((tx + 1) * size, (ty + 0) * size);
}
}


}

public void Draw (SFML.Graphics.RenderWindow target)
{
target.Draw (map, state);
}
}


But I am getting these errors:
Quote

/home/richy/Projects/DotGame/DotGunner/src/Map.cs(37,45): error CS1612: Cannot modify a value type return value of `SFML.Graphics.VertexArray.this[uint]'. Consider storing the value in a temporary variable
/home/richy/Projects/DotGame/DotGunner/extlibs/linSFML/sfml net debug/sfmlnet-graphics-2.dll (Location of the symbol related to previous error)
/home/richy/Projects/DotGame/DotGunner/src/Map.cs(38,45): error CS1612: Cannot modify a value type return value of `SFML.Graphics.VertexArray.this[uint]'. Consider storing the value in a temporary variable
/home/richy/Projects/DotGame/DotGunner/extlibs/linSFML/sfml net debug/sfmlnet-graphics-2.dll (Location of the symbol related to previous error)
/home/richy/Projects/DotGame/DotGunner/src/Map.cs(39,45): error CS1612: Cannot modify a value type return value of `SFML.Graphics.VertexArray.this[uint]'. Consider storing the value in a temporary variable
/home/richy/Projects/DotGame/DotGunner/extlibs/linSFML/sfml net debug/sfmlnet-graphics-2.dll (Location of the symbol related to previous error)
/home/richy/Projects/DotGame/DotGunner/src/Map.cs(40,45): error CS1612: Cannot modify a value type return value of `SFML.Graphics.VertexArray.this[uint]'. Consider storing the value in a temporary variable
/home/richy/Projects/DotGame/DotGunner/extlibs/linSFML/sfml net debug/sfmlnet-graphics-2.dll (Location of the symbol related to previous error)
/home/richy/Projects/DotGame/DotGunner/src/Map.cs(53,45): error CS1612: Cannot modify a value type return value of `SFML.Graphics.VertexArray.this[uint]'. Consider storing the value in a temporary variable
/home/richy/Projects/DotGame/DotGunner/extlibs/linSFML/sfml net debug/sfmlnet-graphics-2.dll (Location of the symbol related to previous error)
/home/richy/Projects/DotGame/DotGunner/src/Map.cs(54,45): error CS1612: Cannot modify a value type return value of `SFML.Graphics.VertexArray.this[uint]'. Consider storing the value in a temporary variable
/home/richy/Projects/DotGame/DotGunner/extlibs/linSFML/sfml net debug/sfmlnet-graphics-2.dll (Location of the symbol related to previous error)
/home/richy/Projects/DotGame/DotGunner/src/Map.cs(55,45): error CS1612: Cannot modify a value type return value of `SFML.Graphics.VertexArray.this[uint]'. Consider storing the value in a temporary variable
/home/richy/Projects/DotGame/DotGunner/extlibs/linSFML/sfml net debug/sfmlnet-graphics-2.dll (Location of the symbol related to previous error)
/home/richy/Projects/DotGame/DotGunner/src/Map.cs(56,45): error CS1612: Cannot modify a value type return value of `SFML.Graphics.VertexArray.this[uint]'. Consider storing the value in a temporary variable
/home/richy/Projects/DotGame/DotGunner/extlibs/linSFML/sfml net debug/sfmlnet-graphics-2.dll (Location of the symbol related to previous error)


35
Feature requests / Batch Drawing
« on: February 27, 2012, 03:37:56 pm »
I see, however how would I assign the images?
Do you know if there are any tutorials on how to use a vertex array? or same code in any of the examples?

36
Feature requests / Batch Drawing
« on: February 27, 2012, 03:25:30 pm »
From what I see on the documentation, would I just use a vertex array instead of a sprite?

37
Feature requests / Batch Drawing
« on: February 27, 2012, 03:14:06 pm »
Im using the newest API but still relying on sf::Sprite, the problem is that because of driver issues or something, drawing around 2000 sprites (for the background tiles) makes it go less than a frame a second, and as im using intell graphics card I cant really use a renderTexture to draw onto and then just draw that.

38
Feature requests / Batch Drawing
« on: February 27, 2012, 01:50:17 pm »
As a way of making the drawing much faster would it be possible to use batch drawing to draw everything at once?
Not sure if this is already planned for the new graphics API but it would make things much faster.

39
DotNet / Getting SFML to work on Mono
« on: February 25, 2012, 02:45:48 pm »
Quote from: "Laurent"
Is usr/local/lib in the library loader's search paths? It's controlled by the LD_LIBRARY_PATH environment variable under Linux, no idea if it's the same on OS X.


Yea this was my bad, I had the .config files inside a folder in my project, so when they were build they werent in the same folder as the exe

40
DotNet / Getting SFML to work on Mono
« on: February 25, 2012, 11:57:10 am »
Sorry to bump this but im having the same issues with the window example.

I have tried changing the config file but still get this:

Code: [Select]
richy@Richy-Len:~/sfmlnet/examples/window$ dir
sfmlnet-audio-2.dll.config     sfmlnet-window-2.dll.config  window.csproj
sfmlnet-graphics-2.dll.config  sfmlnet-window-2.dll.mdb     window.exe
sfmlnet-window-2.dll       Window.cs    window.exe.mdb
richy@Richy-Len:~/sfmlnet/examples/window$ mono window.exe

Unhandled Exception: System.DllNotFoundException: libcsfml-window.so.2
  at (wrapper managed-to-native) SFML.Window.Window:sfWindow_Create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Window.Window..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at window.Program.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libcsfml-window.so.2
  at (wrapper managed-to-native) SFML.Window.Window:sfWindow_Create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Window.Window..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at window.Program.Main () [0x00000] in <filename unknown>:0
richy@Richy-Len:~/sfmlnet/examples/window$ mono window.exe

Unhandled Exception: System.DllNotFoundException: libcsfml-window.so.2.0
  at (wrapper managed-to-native) SFML.Window.Window:sfWindow_Create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Window.Window..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at window.Program.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libcsfml-window.so.2.0
  at (wrapper managed-to-native) SFML.Window.Window:sfWindow_Create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Window.Window..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at window.Program.Main () [0x00000] in <filename unknown>:0
richy@Richy-Len:~/sfmlnet/examples/window$ mono window.exe

Unhandled Exception: System.DllNotFoundException: libcsfml-window.so
  at (wrapper managed-to-native) SFML.Window.Window:sfWindow_Create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Window.Window..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at window.Program.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libcsfml-window.so
  at (wrapper managed-to-native) SFML.Window.Window:sfWindow_Create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Window.Window..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at window.Program.Main () [0x00000] in <filename unknown>:0
richy@Richy-Len:~/sfmlnet/examples/window$ mono window.exe

Unhandled Exception: System.DllNotFoundException: libcsfml-window.so
  at (wrapper managed-to-native) SFML.Window.Window:sfWindow_Create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Window.Window..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at window.Program.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libcsfml-window.so
  at (wrapper managed-to-native) SFML.Window.Window:sfWindow_Create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Window.Window..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at window.Program.Main () [0x00000] in <filename unknown>:0
richy@Richy-Len:~/sfmlnet/examples/window$ mono window.exe

Unhandled Exception: System.DllNotFoundException: libcsfml-window.so.2.0
  at (wrapper managed-to-native) SFML.Window.Window:sfWindow_Create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Window.Window..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at window.Program.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libcsfml-window.so.2.0
  at (wrapper managed-to-native) SFML.Window.Window:sfWindow_Create (SFML.Window.VideoMode,string,SFML.Window.Styles,SFML.Window.ContextSettings&)
  at SFML.Window.Window..ctor (VideoMode mode, System.String title, Styles style, ContextSettings settings) [0x00000] in <filename unknown>:0
  at window.Program.Main () [0x00000] in <filename unknown>:0
richy@Richy-Len:~/sfmlnet/examples/window$


I built both SFML and cSFML and these are installed in /usr/local
with my config files looking like:

Code: [Select]
<configuration>
  <dllmap dll="csfml-window-2" target="libcsfml-window.so.2.0" />
</configuration>


and my usr/local/lib has:
Code: [Select]
richy@Richy-Len:/usr/local/lib$ dir
libcsfml-audio-d.so    libcsfml-window-d.so       libsfml-network-d.so.2.0
libcsfml-audio-d.so.2    libcsfml-window-d.so.2     libsfml-network-s.a
libcsfml-audio-d.so.2.0     libcsfml-window-d.so.2.0   libsfml-network-s-d.a
libcsfml-audio.so    libcsfml-window.so       libsfml-network.so
libcsfml-audio.so.2    libcsfml-window.so.2       libsfml-network.so.2
libcsfml-audio.so.2.0    libcsfml-window.so.2.0     libsfml-network.so.2.0
libcsfml-graphics-d.so    libsfml-audio-d.so       libsfml-system-d.so
libcsfml-graphics-d.so.2    libsfml-audio-d.so.2       libsfml-system-d.so.2
libcsfml-graphics-d.so.2.0  libsfml-audio-d.so.2.0     libsfml-system-d.so.2.0
libcsfml-graphics.so    libsfml-audio-s.a       libsfml-system-s.a
libcsfml-graphics.so.2    libsfml-audio-s-d.a        libsfml-system-s-d.a
libcsfml-graphics.so.2.0    libsfml-audio.so       libsfml-system.so
libcsfml-network-d.so    libsfml-audio.so.2       libsfml-system.so.2
libcsfml-network-d.so.2     libsfml-audio.so.2.0       libsfml-system.so.2.0
libcsfml-network-d.so.2.0   libsfml-graphics-d.so      libsfml-window-d.so
libcsfml-network.so    libsfml-graphics-d.so.2    libsfml-window-d.so.2
libcsfml-network.so.2    libsfml-graphics-d.so.2.0  libsfml-window-d.so.2.0
libcsfml-network.so.2.0     libsfml-graphics-s.a       libsfml-window-s.a
libcsfml-system-d.so    libsfml-graphics-s-d.a     libsfml-window-s-d.a
libcsfml-system-d.so.2    libsfml-graphics.so        libsfml-window.so
libcsfml-system-d.so.2.0    libsfml-graphics.so.2      libsfml-window.so.2
libcsfml-system.so    libsfml-graphics.so.2.0    libsfml-window.so.2.0
libcsfml-system.so.2    libsfml-network-d.so       pkgconfig
libcsfml-system.so.2.0    libsfml-network-d.so.2     python2.7
richy@Richy-Len:/usr/local/lib$

41
C / Error building latest snapshot
« on: February 25, 2012, 05:05:12 am »
Im having to build CSFML to get the new SFML.Net working on linux but I gt this error when compiling the debug version:

Code: [Select]
[ 62%] Building CXX object src/SFML/Graphics/CMakeFiles/csfml-graphics.dir/RenderTexture.cpp.o
/home/richy/csfml/src/SFML/Graphics/RenderTexture.cpp: In function ‘sfBool sfRenderTexture_IsSmooth(const sfRenderTexture*)’:
/home/richy/csfml/src/SFML/Graphics/RenderTexture.cpp:242:5: error: no match for ‘operator==’ in ‘renderTexture->sfRenderTexture::This == 0’
/home/richy/csfml/src/SFML/Graphics/RenderTexture.cpp:242:5: note: candidates are:
/usr/local/include/SFML/System/Vector3.inl:157:13: note: template<class T> bool sf::operator==(const sf::Vector3<T>&, const sf::Vector3<T>&)
/usr/local/include/SFML/System/String.hpp:416:22: note: bool sf::operator==(const sf::String&, const sf::String&)
/usr/local/include/SFML/System/String.hpp:416:22: note:   no known conversion for argument 1 from ‘const sf::RenderTexture’ to ‘const sf::String&’
/usr/local/include/SFML/Graphics/Rect.inl:125:13: note: template<class T> bool sf::operator==(const sf::Rect<T>&, const sf::Rect<T>&)
/usr/local/include/SFML/System/Vector2.inl:150:13: note: template<class T> bool sf::operator==(const sf::Vector2<T>&, const sf::Vector2<T>&)
/usr/local/include/SFML/Graphics/Color.hpp:98:24: note: bool sf::operator==(const sf::Color&, const sf::Color&)
/usr/local/include/SFML/Graphics/Color.hpp:98:24: note:   no known conversion for argument 1 from ‘const sf::RenderTexture’ to ‘const sf::Color&’
make[2]: *** [src/SFML/Graphics/CMakeFiles/csfml-graphics.dir/RenderTexture.cpp.o] Error 1
make[1]: *** [src/SFML/Graphics/CMakeFiles/csfml-graphics.dir/all] Error 2
make: *** [all] Error 2

42
DotNet / Is it possible to get a 2.x version of the .NET bindings?
« on: February 22, 2012, 07:24:28 pm »
Quote from: "Laurent"

No, just one bug to fix and a little more testing.


Awesome :D do you think it might be ready for the weekend?

43
DotNet / Is it possible to get a 2.x version of the .NET bindings?
« on: February 22, 2012, 05:05:50 pm »
Sorry to bump this but I was just wondering if there is much left until the SFML.Net is up to date with the current SFML?

Also is this still the .Net git repo?

https://github.com/SFML/SFML.Net



Keep up the good work laurent :)

44
General / Bloom effect without rendertargets
« on: December 24, 2011, 06:29:20 pm »
If thats possible that would be great :)
However if it uses renderTextures I wont be able to use it untill SFML2.1 (or once laurent fixes the intel bug)

45
General / Bloom effect without rendertargets
« on: December 24, 2011, 02:13:25 am »
Im currently using this shader but it doesnt do much, and when i change the values it screws the image

Code: [Select]
#version 120

uniform sampler2D framebuffer;
#define glaresize 0.008 // 0.008 is good
#define power 0.5 // 0.50 is good

void main()
{
   vec4 sum = vec4(0);
   vec4 bum = vec4(0);
   vec2 texcoord = vec2(gl_TexCoord[0]);
   int j;
   int i;

   for( i= -2 ;i < 2; i++)
   {
        for (j = -1; j < 1; j++)
        {
            sum += texture2D(framebuffer, texcoord + vec2(-i, j)*glaresize) * power;
         bum += texture2D(framebuffer, texcoord + vec2(j, i)*glaresize) * power;            
        }
   }
       if (texture2D(framebuffer, texcoord).r < 2.0f)
    {
       gl_FragColor = sum*sum*sum*0.0080+bum*bum*bum*0.0080+ texture2D(framebuffer, texcoord);
    }
}

Pages: 1 2 [3] 4 5 ... 13
anything