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

Pages: [1]
1
Graphics / BGRA buffer to sf::Texture
« on: June 18, 2013, 03:38:04 pm »
I have a buffer (char*) in BGRA that i need to create a sf::Texture of.
I have a sprite that uses sprite.setTexture(renderedTexture) that gets the texture from this:

sf::Texture texture;

Awesomium::BitmapSurface* bitmap = (Awesomium::BitmapSurface*)m_views[name]->surface();

texture.create(bitmap->width(), bitmap->height());

sf::Uint8* rgba = new sf::Uint8[bitmap->width() * bitmap->height() * 4];

for(int i = 0; i < bitmap->width() * bitmap->height(); i++)
{
        rgba[(i * 4)]     = bitmap->buffer()[(i * 4) + 2];
        rgba[(i * 4) + 1] = bitmap->buffer()[(i * 4) + 1];
        rgba[(i * 4) + 2] = bitmap->buffer()[(i * 4)];
        rgba[(i * 4) + 3] = bitmap->buffer()[(i * 4) + 3];
}

texture.update(rgba);

return texture;

The texture seems to render in the correct size, but all white.

EDIT: I didn't store the texture properly so it was invalidated.

2
Graphics / 640x480 in 800x600 window
« on: February 26, 2011, 02:00:15 pm »
Quote from: "Laurent"
The view shouldn't know anything about the window it will be displayed in. Just setup with the size that want to view (640x480). Same for the center, this is the center of the world area that you want to display, this has nothing to do with the size of the target window.


Thanks a lot Laurent! I really appreciate that you're taking time to help us.
That's worth a Flattr ;)

3
Graphics / 640x480 in 800x600 window
« on: February 26, 2011, 01:14:33 pm »
Hi. I want to show a 640x480 screen in a larger window. The window can be 800x600 or larger. I know that sf::View is good for this.

But how should i do it (for a 800x600 window)?
Code: [Select]
sf::View view;
view.setCenter(400, 300);
view.setHalfSize(400, 300);
view.Zoom(2.0f);


or

Code: [Select]
sf::View view;
view.setCenter(400, 300);
view.setHalfSize(320, 240);

or something else?

Thanks in advance.

4
Network / TCP Listening server doesn't get whats sent to it
« on: August 27, 2009, 07:14:07 pm »
Oh.. :P but why are no data sent?

5
Network / TCP Listening server doesn't get whats sent to it
« on: August 27, 2009, 08:01:54 am »
Hi, i'm having some problems. I have a client with a TCP Socket that connects to a server and sends some data to it. But the server doesn't respond.

Code: [Select]
if(sock == listener)
{
sf::IPAddress addr;
sf::SocketTCP client;
listener.Accept(client, &addr);

cout << "Client connected (" << addr << ") ID:" << i << endl;

//Add the connecting client to the selector
selector.Add(client);
}
else
{
//Not the listener, it's a client sendind something. Hooray!
sf::Packet packet;

if(sock.Receive(packet) == sf::Socket::Done)
{
std::string msg;
packet >> msg;

cout << "Incoming data: '" << msg << "'" << endl;
}
else
{
//Something is messed up..
cout << "Client (ID:" << i << ") disconnected" << endl;
selector.Remove(sock); //So long!
}
}


It notices when a client connects, or disconnects. But it never prints out incoming packets.

This is code from the client that sends data to the server:
Code: [Select]
if(socket.Send(data.c_str(), sizeof(data.c_str()) != sf::Socket::Done)
{
cout << "Unable to send packet" << endl;
return false;
}
else
{
cout << "Sent packet: '" << data << "' (" << sizeof(data.c_str()) << " Bytes)" << endl;
return true;
}


"data" is an std::string. I have tested with a char[], but no difference. Something that disturbs me a bit as well, is that sixeof(data.c_str()) seems to always return 4.

Any reason why the server don't get the data, or why the client wouldn't send it?

6
General / Scripting module for SFML
« on: August 13, 2009, 10:36:18 am »
I must say tha ChaiScript seems like it would be very easy to implement, and i do like the syntax. And as i have the Boost library avilable, it's no problem for me. I dont know if i even need to write a custom scripting module for sfml, as ChaiScript basically has what i planned to write. :)

7
Graphics / PostFX for computors without support for it
« on: August 12, 2009, 03:48:57 pm »
Quote from: "Laurent"
At least you should directly work on the array of pixels, and re-uploading them once per frame with sf::Image::LoadFromPixels.


Does LoadFromPixels want a miltidimensional array, or a "single"? And what type does it expect the pixel values to be?

8
General / Scripting module for SFML
« on: August 12, 2009, 03:20:50 pm »
It looks like it's easy to embed. But i'll get mad at it as it is a c/javascript-like syntax.. without semicolons. And i agree with Laurent when it comes to the boost part.

And i can't manage to find any reference of the "standard library", if there even are one. No, i did not download anything. Just clicked around the website.

9
Graphics / PostFX for computors without support for it
« on: August 11, 2009, 10:45:07 am »
Quote
Yep. Especially if you target old configurations.


Not old really. Just for systems which doesn't support advanced shaders. Like my laptop, dualcore cpu, 2gb ram, weak/integrated gfx-card and such.

10
Graphics / PostFX for computors without support for it
« on: August 11, 2009, 10:33:18 am »
Quote
Definitely.

Definitely.. too slow?

11
General / Scripting module for SFML
« on: August 11, 2009, 09:54:50 am »
I know it's not the most necessary module to write, but i just want to write a simple wrapper. This will be used for a custom PostFX system (if i can get it fast enough).  :wink:

12
General / Scripting module for SFML
« on: August 11, 2009, 03:08:58 am »
I have some plans of writing a simple scripting module for SFML.
I need one myself fo a project, so i thougt that i just as well could share it.

I have a question for you though..
Which scripting language would you like to see in the module?

Lua - Easy to use, fast and relativly good features.
GameMonkey - C-like syntax, and quite small. (Small is good)
Python - Nice syntax, a bit "huge" though.
Pawn - C-like syntax. Fast. Has to be compiled though.
Squirrel - Syntax similiar to Lua and Python. Good features.
Suggest - If you have any suggestions about a language, please let me know!  :wink:

13
Graphics / PostFX for computors without support for it
« on: August 11, 2009, 02:52:15 am »
Hi there.

I'm sitting on a fairly new Laptop (yes i know, crappy gfx-card) but it at least support PixelShader 2.0. But i guess the total lack of any VertexShader support and HW T & L is the problem.

Is it possible to run PostFX on gfx-cards like mine?

I have my small plans on implementing my own, using some lightweight scripting language such as GameMonkey. This could use GetPixel() to get the color and give me the new color. The problem i have is that there are no SetPixel() (afaik).

Laurent, take this as a feature request maybe? :wink:

Would this bee way too slow? It may mean that every pixel of the screen has to be read and written every frame.

Thanks in advance for your answers.  :)

Pages: [1]
anything