Kiekos
Member
|
Drawing problem after dividing code into states
Hello there!
I divided my app into states as it is shown in the tutorials and a strange problem occured. When I try to load an image and draw it on the screen in the Intro or Menu state - it is drawn as a black rectangle.
Code:
Image image;
image.Import( "name.png" );
image.draw( Rect_C (0, 0, 1, 0.5f) );
Funny thing is that when I draw it in the Game state - it works fine and draws the image.
If it's drawn in the Menu state, it's a black rectangle, then I go to the Game state, come back to the Menu state and guess what - a black rectangle again.
Common sense says that it's some graphics initialisation related problem but after going into Game state and coming back to Menu state it shouldn't de-initialise or whatever.
Any ideas?
Regards,
Kiekos
|
|
05-20-2013 02:04 PM |
|
AndrewBGS
Member
|
RE: Drawing problem after dividing code into states
Just an idea, didn't test it.
I often had similar problems due the ORDER of drawing components. I kept thinking after some change the temp item icon isn't drawn, but the only issue was that I was drawing the GUI AFTER drawing the icon, so the icon was covered. Order matters.
So it's just an idea, but see if you're not overlapping with other drawing parts.
|
|
05-20-2013 02:09 PM |
|
Kiekos
Member
|
RE: Drawing problem after dividing code into states
Well, I've tried that but the only thing drawn in my Intro state is:
Code:
void DrawIntro()
{
D.clear(WHITE);
D.text (0, 0.5f, "Some random text");
image.draw( Rect_C(0,0,1,0.5f) );
}
I set background to white to see the black rectangle. Text is drawn but the image is not.
(This post was last modified: 05-20-2013 02:17 PM by Kiekos.)
|
|
05-20-2013 02:16 PM |
|
Seba
Member
|
RE: Drawing problem after dividing code into states
Code that i use to draw intro:
Quote:/******************************************************************************/
#include "stdafx.h"
#include "Main.h"
/******************************************************************************/
Image intro;
Image logo;
Bool InitIntro()
{
intro.load("Gfx/intro.gfx");
logo.load("Gfx/logo+alpha.gfx");
return true;
}
void ShutIntro()
{
intro.del();
logo.del();
}
/******************************************************************************/
Bool UpdateIntro()
{
if(StateActive->time()>6 || Kb.bp(KB_ESC))
StateMenu.set(1.0);
return true;
}
void DrawIntro()
{
D.clear(BLACK);
if(StateActive->time()>3)
intro.draw(Rect(-D.w(),-D.h(),D.w(),D.h()));
else
logo.draw(Rect(-D.w(),-D.h(),D.w(),D.h()));
}
/******************************************************************************/
State StateIntro(UpdateIntro,DrawIntro,InitIntro,ShutIntro);
/******************************************************************************/
|
|
05-20-2013 05:24 PM |
|
Rubeus
Member
|
RE: Drawing problem after dividing code into states
Is this EE1? This won't work in 2.0, so it will be harder for people to help you. You may want to upgrade.
|
|
05-20-2013 08:12 PM |
|
Kiekos
Member
|
RE: Drawing problem after dividing code into states
@Seba, thank you for the code! I converted .png to .gfx and just loaded it instead of importing it.
Damn, so simple >.<
|
|
05-20-2013 08:27 PM |
|
Esenthel
Administrator
|
RE: Drawing problem after dividing code into states
You can do Image.Import just specify IMAGE_2D as the image mode (IMAGE_SOFT is default for PNG's)
|
|
05-23-2013 02:14 PM |
|