Closed GoogleCodeExporter closed 9 years ago
Perhaps you should read the error message. You are calling graphics->drawImage
(quit_game, 0, 0); in the init function which is not allowed, you can only call
draw
after graphics->_beginDraw() and before graphics->_endDraw() has been called.
These
functions are called automatically in Gui::draw, so widgets that are drawn
during
Gui::draw doesn't need to bother calling _beginDraw and _endDraw.
Original comment by olof.nae...@gmail.com
on 21 Dec 2009 at 4:56
gui->logic();
graphics->_beginDraw();
gui->draw();
graphics->drawImage(background, 0, 0);
graphics->_endDraw();
SDL_Flip(screen);
I replaced the wrong code with this - it runs now but I can not see the image,
what
do I do wrong?
PS: The MouseListeners are amazing, never added mouse support that easily and
fast.
Original comment by littlega...@web.de
on 22 Dec 2009 at 9:29
Try this instead:
gui->logic();
gui->draw();
graphics->_beginDraw();
graphics->drawImage(background, 0, 0);
graphics->_endDraw();
SDL_Flip(screen);
Note that it would be better if you drew the image as part of the GUI's drawing
routine instead.
Original comment by jaxad0...@gmail.com
on 23 Dec 2009 at 2:24
How would I do that?
Original comment by littlega...@web.de
on 23 Dec 2009 at 8:24
You'd create a subclass of gcn::Widget and reimplement its virtual draw method.
Then
you'd place that widget where you want it go get drawn.
Original comment by b.lindeijer
on 23 Dec 2009 at 8:35
Well, this issue's been declared invalid, but I personally think that the
responses
so far haven't been too helpful at all. First off, Jaxad's solution isn't a real
solution, so don't try it. It's a fairly horrible hack, and isn't anything
that'll
get you anywhere.
What I would suggest is to pass your image to a new gcn::Icon, and then add
that icon
to the top widget. That is a far better practice than what you're trying to do,
and
actually attempts to use GUIChan, instead of trying to fight against it.
If that isn't clear, then what I'm saying is this. Replace this:
quit_game = gcn::Image::load("./GUI.app/Contents/Resources/close_n.png");
graphics->drawImage(quit_game, 0, 0);
with this:
quitIcon = new gcn::Icon("./GUI.app/Contents/Resources/close_n.png");
top->add(quitIcon);
You will then benefit from actually using GUIChan as intended, instead of
trying to
hack images on top of it. Oh, and as a short answer as to why your image doesn't
draw, the real answer is that it does, except that you are drawing the image
once,
then the SDL drawing polling keeps redrawing over it, and it never redraws again
throughout the life of the program.
Hope this is more helpful than the previous bits of advice.
Original comment by irar...@gmail.com
on 23 Dec 2009 at 9:42
I tried this aswell but it doesnt show up. No error occurs though and no stderr
message. Its pretty confusing. I basically want to have an image instead of
this odd
grey:
http://img526.imageshack.us/img526/3043/picture4ox.png
And when I do the stuff you said it runs well but I can not see the image. I
tried this
aswell:
background = gcn::Image::load("./GUI.app/Contents/Resources/bg.png");
background_icon = new gcn::Icon(background);
background_icon->setPosition(0, 0);
top->add(background_icon);
top->moveToBottom(background_icon);
...
Thanks for all the help!
Original comment by littlega...@web.de
on 23 Dec 2009 at 10:44
Did you try doing this?
top->setOpaque(false);
You better make sure that you have a background to substitute for the whole
program
area, though.
Original comment by irar...@gmail.com
on 23 Dec 2009 at 5:18
Ira, feel free to be more verbose or suggest other solutions, but please avoid
bashing
other people who also tried to help. It's not nice.
Original comment by b.lindeijer
on 25 Dec 2009 at 1:52
Ira, the issue has been declared invalid because this is an issue tracker, not
a forum,
and the stated issue is _not_ an issue, it is excpected behaviour.
We have an issue with images not in 32bit format, what is the format of your
image? Try
to convert it to 32bit if it's not already.
Original comment by olof.nae...@gmail.com
on 25 Dec 2009 at 3:04
It was that 32bit thing. :| Sorry for all the problems you had because of me,
it works
fine now, though. Thanks for your help.
Original comment by littlega...@web.de
on 27 Dec 2009 at 10:18
No need to apologies, the 32bit issue is in fact a bug in Guichan which we
haven't been
able to resolve yet. I'll keep this issue invalid because we already have an
issue
about the 32bit issue.
Original comment by olof.nae...@gmail.com
on 27 Dec 2009 at 2:28
Original issue reported on code.google.com by
littlega...@web.de
on 21 Dec 2009 at 2:51