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

Pages: 1 [2] 3 4 ... 15
16
SFML projects / Re: The 8-Bit Encounter - My Open-World 2D Game Demo
« on: October 03, 2014, 11:48:13 pm »
Yeah, the LPC sprites have a consistent style across a wide array of themes, so they are a great choice for prototyping.
I used that sprite as well, it has high quality sprites.

17
SFML projects / Re: The Wanderer - Lost in time
« on: September 30, 2014, 12:22:16 am »
Depends what you define as demo, but the answer is yes.
I meant a playable binary version of the game (i.e. in the state you have already showcased in your YouTube videos).
Oh the date should be before January 1st but i cannot promise, it is not a deadline we have to meet, it is deadline we would like to meet.
The showcase lacked one thing i am currently working hard to get right "Battle/Combat".

18
SFML projects / Re: The Wanderer - Lost in time
« on: September 29, 2014, 11:20:17 pm »
Just wondering, are you planning on releasing a demo for that game?
Quote from: BaneTrapper
When we are done with ACT I, as i stated it will be free of charge, since it is demo to show what is to come!
Depends what you define as demo, but the answer is yes. We decided initially to split full game intro multiple Acts, and introduce mechanics slowly. And most importantly to see how we work together as a team, so far so good.
The Act I which is the start of story will be showcase of whats to come, free to download & play, available platforms are still unknown. Later Acts will introduce new mechanics, and complete the story.
At least that is the plan for now, cannot tell what the future holds.

19
SFML projects / Re: The Wanderer - Lost in time
« on: September 29, 2014, 05:52:33 pm »
Update 3- It has bean over a month, how the time flies i cannot believe.
Note that video quality is poor, my machine is very weak so i cannot record not even close to 30 fps 800x600 resolution.
https://www.youtube.com/watch?v=XbgK8qwpi5c

We are again recruiting members for various roles:
http://www.gamedev.net/classifieds/item/3534-looking-for-members-2d-top-down-rpg/

We are done with Story for ACT I, just finishing touches, now its time to implement it all!
When we are done with ACT I, as i stated it will be free of charge, since it is demo to show what is to come!

Although the progress was slow last few months, it was because i was working with engine, and i was supper ambitious with what i wanted to achieve, i settled for less, and am ready to get back to old progress tracks.

20
Good to know that you fixed it  :)

I'm not sure I understand what you found as the problem. Is it because you were using pointers to elements in a vector and they were moving when allocating more size?
The issue was with the sf::Sprite::m_texture member (const Texture* m_texture;)
When using vectors push_back() function the m_texture is copied properly.
But when vector resize() occurs(Manually, or when it reaches maximum size) all m_texture go invalid, i don't know why, and currently don't care i fixed it!

I suspected issue was texture because i was only getting last texture created drawn.

21
I no longer require such feature, tho having it would be improvement to performance.

22
SOLVED!

sf::Texture texture = renderTexture.getTexture();
doesn't copy the texture?

If i fail even then, i will probably quit sfml, it is probably not for for me.
This is a terrible attitude to have. I have many other words to describe it but I will refrain from doing so.
I think you misunderstood me i expressed poorly, the text is important and i have more then i stated at first, drawing it with sf::Text uses too much performance to do. I was unable to achieve that, so i would have to resolve to different library or method.
The issue was quite a whacky one, i stated i do not use sprites, i was unaware the sf::Sprite member "m_texture" was a const.

Fixed the issue.

The issue was not with the sf::Texture or sf::RenderTexture. It was the sf::Sprite all the time.
The reason is, as i was adding more elements to the vector, the vector reached maximum size and had to reallocate, issue comes from sf::Sprite member (const Texture* m_texture; ).
Fixed the issue with, setting size for vector before adding any elements. Or setting sf::Sprite texture before drawing.


 :-[, unsure if i was supposed to know this.
Two lines are commented out in main which fix issue.
Code: [Select]
class Dialog
{
public:
Dialog();
Dialog(const Dialog & d);
void MakeText(sf::Font & font);

sf::Texture tex;
sf::Sprite spr;
};
Dialog::Dialog(){ std::cout << "defC" << std::endl; }
Dialog::Dialog(const Dialog & d)
{
tex = d.tex;
spr = d.spr;
std::cout << "d:" << d.spr.getTexture() << std::endl;
std::cout << "s:" << spr.getTexture() << std::endl;
}

void Dialog::MakeText(sf::Font & font)
{
std::cout << "mTXT" << std::endl;
sf::Text txt;
int posX = 0, posY = 0;

txt.setCharacterSize(32);
txt.setColor(sf::Color::White);
txt.setFont(font);
txt.setString("Hello");
txt.setPosition(0, 0);

sf::RenderTexture renTex;
renTex.create(100, 100);
renTex.draw(txt);
renTex.display();

tex = renTex.getTexture();

spr.setTexture(tex, true);
spr.setPosition(1, 1);
}

int main()
{
sf::View view;
view.setViewport(sf::FloatRect(0, 0, 1, 1));

sf::RenderWindow win;
sf::VideoMode vidMod(800,600,32);
win.create(vidMod, "hello", sf::Style::Default);
win.setFramerateLimit(100);
win.setView(view);

sf::Font arial;
arial.loadFromFile("arial.ttf");


std::vector<Dialog> listDialog;
//listDialog.reserve(4);
for (unsigned int i = 0; i < 4; i++)
{
listDialog.push_back(Dialog());
listDialog.back().MakeText(arial);
}

sf::Sprite tmpSpr1, tmpSpr2, tmpSpr3;
sf::Texture tex;
tex.loadFromFile("link.png");

tmpSpr1.setTexture(tex);
tmpSpr1.setPosition(101, 0);

tmpSpr2 = tmpSpr1;
tmpSpr2.setPosition(101, 50);

tmpSpr3 = tmpSpr2;
tmpSpr3.setPosition(101, 100);

bool done = false;
while(done == false)
{
win.clear();

sf::Event event;
while(win.pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
done = true;
break;
default:
break;
}
}

for (unsigned int i = 0; i < listDialog.size(); i++)
{
//listDialog[i].spr.setTexture(listDialog[i].tex, true);
listDialog[i].spr.setPosition(0, i*101);
win.draw(listDialog[i].spr);
}
win.draw(tmpSpr1);
win.draw(tmpSpr2);
win.draw(tmpSpr3);
win.display();
}

return 0;
};

23
I'm not sure about that. getTexture() returns an actual sf::Texture, and copying an sf::Texture does a very real copy (in fact, it looks like it copies it from GPU to CPU back to GPU...which you probably don't want to do too often).  After looking at the SFML source to confirm this (I was bored), I don't think there is a heavier or deeper way to perform that copy operation.
getTexture() return const reference to its texture. The issue is i don't know how to copy it.
Doing
Code: [Select]
sf::Texture tex;
sf::RenderTexture renTex;

tex = renTex.getTexture();
Performs assignment operation as it should.
There is this constructor for Texture tho
Code: [Select]
Texture(const Texture& copy);
When i used it with getTexture().
The texture was still null after renderTexture deconstructor got called. Beats me why... i don't know whats going on anymore, i made quite few posts, read all documentation... I hit brick wall, i will attempt to reintroduce the problem again and solve it in different way.
If i fail even then, i will probably quit sfml, it is probably not for for me.

24
Copying (moving) a RenderTexture to a Texture is not enough?
Not sure I understand what you need/want that cannot already be done..
Moving renderTexture to texture, is that possible? i tested, and failed to accomplish that.
Example please.

Would be nice to explain why you want such a feature.
It looks like the "feature already exists" i just failed to see it.

what do you mean by 'swapping ownership'?
and i think sf::Texture would be the drawing itself, not a paper where you draw.
I mean that i cannot extract the texture from sf::RenderWindow to sf::Texture.
The sf::RenderTexture has to have the texture pointer in GPU, texture has none and is in "invalid" state by default afaik.
Setting sf::Texture texture to sf::RenderTexture texture (meaning now they share it)
Then sf::RenderTexture texture to nothing. Meaning we swapped ownership of texture from sf::RenderTexture to sf::Texture without having to copy the texture around.

25
Hello.
Id like to request a possibility of sf::RenderTexture swapping ownership of its texture with sf::Texture.
Reasons being,
Code: [Select]
std::cout << sizeof(sf::RenderTexture) << std::endl;//488
std::cout << sizeof(sf::Texture) << std::endl;//32
My thought are that RenderTexture was supposed to be used as a drawing board and sf::Texture would be the paper that you actually draw on.

Related to topics:
http://en.sfml-dev.org/forums/index.php?topic=16178.0
http://en.sfml-dev.org/forums/index.php?topic=16174.0
Is it possible to expect such a feature?

26
Hi, the render texture is destructed at the end of Dialog::MakeText, so that is normal if the texture is all white.
I suspected so, thank you on confirming it.
How do i make a copy of renderTexture renText(actual texture) to sf::Texture tex?
The reason being, renderTexture is a heavy object compared to Texture.
I tried
Code: [Select]
tex = renTex.getTexture();

27
Graphics / (Not bug)Bug with sfmlRenderTexture or i am doing it wrong
« on: August 25, 2014, 11:22:00 pm »
Hello.
In short what i want to do: I want to draw sf::Text once and save it as texture, then use texture to speed up drawing.

In short what i achieve: I draw text and save it as texture, all but last texture are white. I suspect the renderTexture deconstructor releases its texture and thus i am getting all white when using it.
But i have no clue what em i doing wrong.
Magic happens in Dialog::MakeText(...);
EDIT::Also the creating renderTexture does not fail.

Code: [Select]
class Dialog
{
public:
Dialog(std::string & str, int linkedObjectVecID = -1, int posX = -1, int posY = -1);
Dialog& operator=(Dialog & d);
Dialog(const Dialog & d);
void MakeText(sf::Font & font);

sf::Text txt;
sf::Texture tex;
sf::Sprite spr;
int linkedObjectVecID;
int posX, posY;
std::string str;
};

Dialog::Dialog(std::string & Str, int LinkedObjectVecID, int PosX, int PosY)
{
linkedObjectVecID = LinkedObjectVecID;
posX = PosX;
posY = PosY;
str = Str;
}

Dialog& Dialog::operator = (Dialog & d)
{
txt = d.txt;
tex = d.tex;
spr = d.spr;
linkedObjectVecID = d.linkedObjectVecID;
posX = d.posX;
posY = d.posY;
str = d.str;
return *this;
}
Dialog::Dialog(const Dialog & d)
{
txt = d.txt;
tex = d.tex;
spr = d.spr;
linkedObjectVecID = d.linkedObjectVecID;
posX = d.posX;
posY = d.posY;
str = d.str;
}

void Dialog::MakeText(sf::Font & font)
{
txt.setCharacterSize(32);
txt.setColor(sf::Color::White);
txt.setFont(font);
txt.setString(str);
txt.setPosition(-txt.getLocalBounds().left, -txt.getLocalBounds().top);
std::cout << "MakeText str:" << str << std::endl;

sf::RenderTexture renTex;
if (renTex.create(txt.getLocalBounds().width + txt.getLocalBounds().left * 2, txt.getLocalBounds().height + txt.getLocalBounds().top * 2) == false)
std::cout << "Dialog::MakeText Creating texture failed:" << std::endl;
renTex.draw(txt);
renTex.display();
//tex.create(renTex.getSize().x, renTex.getSize().y);
tex = renTex.getTexture();

spr.setTexture(tex);
//Set position on position
spr.setPosition(posX - (txt.getLocalBounds().width / 2), posY - txt.getLocalBounds().height - (txt.getLocalBounds().top * 2));
}

int main()
{
sf::View view;
view.setViewport(sf::FloatRect(0, 0, 1, 1));

sf::RenderWindow win;
sf::VideoMode vidMod(800,600,32);
win.create(vidMod, "hello", sf::Style::Default);
win.setFramerateLimit(100);
win.setView(view);

sf::Font arial;
arial.loadFromFile("arial.ttf");

std::vector<Dialog> listDialog;
listDialog.push_back(Dialog(std::string("Greeting traveler."), -1, 300, 300));
listDialog.back().MakeText(arial);
listDialog.push_back(Dialog(std::string("Two trees."), -1, 300, 100));
listDialog.back().MakeText(arial);
listDialog.push_back(Dialog(std::string("Derp"), -1, 300, 500));
listDialog.back().MakeText(arial);

bool done = false;
while(done == false)
{
win.clear();

sf::Event event;
while(win.pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
done = true;
break;
default:
break;
}
}

for (Dialog & d : listDialog)
win.draw(d.spr);

win.display();
}

return 0;
};

28
Graphics / Re: Drawing a click and drag rectangle?
« on: August 25, 2014, 03:18:21 pm »
Here is a example of how i did it, but if you don't make your own damn copy and rewrite it all... I will me bad  >:(
Code: [Select]
void SetRectangle(sf::Vector2f & startPos, sf::Vector2f & mousePos, sf::RectangleShape & rec)
{
if (mousePos.x < startPos.x && mousePos.y < startPos.y)//Mouse is left up of start, use mouse for x and y
{
rec.setPosition(mousePos.x, mousePos.y);
rec.setSize(sf::Vector2f(startPos.x - mousePos.x, startPos.y - mousePos.y));
}
else if (mousePos.x < startPos.x)//Rectagle is left down of start pos
{
rec.setPosition(mousePos.x, startPos.y);
rec.setSize(sf::Vector2f(startPos.x - mousePos.x, mousePos.y - startPos.y));
}
else if (mousePos.y < startPos.y)//Rectagle is right up of start pos
{
rec.setPosition(startPos.x, mousePos.y);
rec.setSize(sf::Vector2f(mousePos.x - startPos.x, startPos.y - mousePos.y));
}
else//Rectangle is right down, default state
{
rec.setPosition(startPos.x, startPos.y);
rec.setSize(sf::Vector2f(mousePos.x - startPos.x, mousePos.y - startPos.y));
}
}

int main()
{
sf::View view;
view.reset(sf::FloatRect(0, 0, float(800), float(600)));
view.setViewport(sf::FloatRect(0, 0, 1.f, 1.f));


sf::RenderWindow win;
sf::VideoMode vidMod(800, 600, 32);
win.create(vidMod, "test", sf::Style::Default);
win.setFramerateLimit(100);
win.setView(view);

sf::RectangleShape rec;
rec.setFillColor(sf::Color::White);
sf::Vector2f startPos;
sf::Vector2f mousePos;
bool isDrawRectangle = false;

bool done = false;
while (done == false)
{
win.clear();

sf::Event event;
while (win.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
done = true;
break;
case sf::Event::MouseButtonPressed:
switch (event.mouseButton.button)
{
case sf::Mouse::Button::Left:
isDrawRectangle = true;
startPos = mousePos;
break;
default:
break;
}
break;
case sf::Event::MouseButtonReleased:
switch (event.mouseButton.button)
{
case sf::Mouse::Button::Left:
isDrawRectangle = false;
break;
default:
break;
}
break;
case sf::Event::MouseMoved:
mousePos.x = event.mouseMove.x;
mousePos.y = event.mouseMove.y;
break;
default:
break;
}
}

SetRectangle(startPos, mousePos, rec);
if (isDrawRectangle)
win.draw(rec);

win.display();
}

return 0;
}

29
Okay, redesign....
Code: [Select]
//In class tex=sf::Texture, spr=sf::Sprite
sf::RenderTexture renTex;
renTex.create(txt.getLocalBounds().width + txt.getLocalBounds().left * 2, txt.getLocalBounds().height + txt.getLocalBounds().top * 2);
renTex.draw(txt);
renTex.display();
tex.create(renTex.getSize().x, renTex.getSize().y);
tex = renTex.getTexture();
//This line here
tex = renTex.getTexture();
For some reason the "tex" texture is fully white when i use it later down the line, but when i extracted this code in minimal example, and sf::RenderTexture renTex; didn't deconstruct the tex texture is correct.

Can i copy the renderTexture texture intro the "tex" Texture somehow? Or just make the renderTexture's texture the "tex" Texture? so i directly draw intro it, and don't have to copy.
Because
Code: [Select]
tex = renTex.getTexture();
Doesn't really make a new copy of the texture as far as i see.

30
Graphics / sf::NonCopyable, can you tell me what in my class causes it.
« on: August 25, 2014, 01:16:41 pm »
I suppose something like sf::RenderTexture is NoNCopyable. I will just make it a pointer and transfer ownership when operator= called, but i got no clue what is NoNCopyable. Can you help me and point it out?

The error:
Code: [Select]
1>------ Build started: Project: TheRPG, Configuration: Release Win32 ------
1>  Chat.cpp
1>Chat.cpp(27): warning C4244: 'argument' : conversion from 'float' to 'unsigned int', possible loss of data
1>Chat.cpp(65): warning C4018: '>=' : signed/unsigned mismatch
1>C:\C++\Libs\SFML VS2013\include\SFML/Graphics/RenderTarget.hpp(419): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
1>          C:\C++\Libs\SFML VS2013\include\SFML/System/NonCopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
1>          C:\C++\Libs\SFML VS2013\include\SFML/System/NonCopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1>          This diagnostic occurred in the compiler generated function 'sf::RenderTarget::RenderTarget(const sf::RenderTarget &)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

//Removing this line of code makes it go away, and compile as it should
void DialogHolder::AddDialog(Dialog & d)
{
listDialog.push_back(d);//This line here
}
Code: [Select]
//HPP
class Dialog
{
public:
Dialog(int linkedObjectVecID = -1, int posX = -1, int posY = -1);
Dialog(std::string & str, sf::Font & font, int linkedObjectVecID = -1, int posX = -1, int posY = -1);
void MakeText(std::string & str, sf::Font & font);
void Loop();

sf::Text txt;
sf::RenderTexture renTex;
sf::Sprite spr;

int linkedObjectVecID;
int posX, posY;
};

class DialogHolder
{
public:
DialogHolder(Font & ObjFont);

void AddDialog(Dialog & d);
void RemoveDialog(int vecID);
void Loop();
void Draw(sf::RenderWindow & renWin);

std::vector<Dialog> listDialog;
private:
Font & objFont;
};

//CPP
Dialog::Dialog(int LinkedObjectVecID, int PosX, int PosY)
{
linkedObjectVecID = LinkedObjectVecID;
posX = PosX;
posY = PosY;
}

Dialog::Dialog(std::string & str, sf::Font & font,int LinkedObjectVecID, int PosX, int PosY)
{
linkedObjectVecID = LinkedObjectVecID;
posX = PosX;
posY = PosY;
MakeText(str, font);
}
void Dialog::MakeText(std::string & str, sf::Font & font)
{
txt.setCharacterSize(32);
txt.setColor(sf::Color::White);
txt.setFont(font);
txt.setString(str);
txt.setPosition(-txt.getLocalBounds().left, -txt.getLocalBounds().top);

renTex.create(txt.getLocalBounds().width + txt.getLocalBounds().left * 2, txt.getLocalBounds().height + txt.getLocalBounds().top * 2);
renTex.draw(txt);
renTex.display();

spr.setTexture(renTex.getTexture(), true);
if (linkedObjectVecID != -1)
{//Set position on unit
Object & o = glob::objFunc.objObjectH->listObject[linkedObjectVecID];
spr.setPosition(o.pos.x + (o.size.x/2) - (txt.getLocalBounds().width / 2), o.pos.y - txt.getLocalBounds().height - (txt.getLocalBounds().top*2));
}
else
{//Set position on position
spr.setPosition(posX - (txt.getLocalBounds().width / 2), posY - txt.getLocalBounds().height - (txt.getLocalBounds().top * 2));
}
}

void Dialog::Loop()
{
if (linkedObjectVecID != -1)
{//Set position on unit
Object & o = glob::objFunc.objObjectH->listObject[linkedObjectVecID];
spr.setPosition(o.pos.x + (o.size.x / 2) - (txt.getLocalBounds().width / 2), o.pos.y - txt.getLocalBounds().height - (txt.getLocalBounds().top * 2));
}
}


DialogHolder::DialogHolder(Font & ObjFont)
: objFont(ObjFont)
{

}

void DialogHolder::AddDialog(Dialog & d)
{
listDialog.push_back(d);
}
void DialogHolder::RemoveDialog(int vecID)
{
if (vecID < 0 || vecID >= listDialog.size())
return;

//listDialog.erase(listDialog.begin() + vecID);
}


void DialogHolder::Loop()
{
for (Dialog & d : listDialog)
d.Loop();
}

void DialogHolder::Draw(sf::RenderWindow & renWin)
{
for (Dialog & d : listDialog)
renWin.draw(d.spr);
}


Pages: 1 [2] 3 4 ... 15
anything