Added down state
-Added mouse down state -Commented out useless function -Added temporary default value to ovr_id -Added temporary images go_dn and go_dn_id -Removed debug spacing increase and decrease key press code (causes crashes by design and was useless)
This commit is contained in:
35
main.cpp
35
main.cpp
@@ -38,10 +38,13 @@ static int sep = 125;
|
|||||||
static int spacing = 25;
|
static int spacing = 25;
|
||||||
static G3D::TextureRef go = NULL;
|
static G3D::TextureRef go = NULL;
|
||||||
static G3D::TextureRef go_ovr = NULL;
|
static G3D::TextureRef go_ovr = NULL;
|
||||||
|
static G3D::TextureRef go_dn = NULL;
|
||||||
static float mousex = 0;
|
static float mousex = 0;
|
||||||
static float mousey = 0;
|
static float mousey = 0;
|
||||||
static int go_id = 0;
|
static int go_id = 0;
|
||||||
static int go_ovr_id;
|
static int go_ovr_id = 0;
|
||||||
|
static int go_dn_id = 0;
|
||||||
|
static bool mouseButton1Down = false;
|
||||||
/**
|
/**
|
||||||
This simple demo applet uses the debug mode as the regular
|
This simple demo applet uses the debug mode as the regular
|
||||||
rendering mode so you can fly around the scene.
|
rendering mode so you can fly around the scene.
|
||||||
@@ -250,10 +253,10 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void readMouseGUIInput()
|
//void readMouseGUIInput()
|
||||||
{
|
//{
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|
||||||
void Demo::onUserInput(UserInput* ui) {
|
void Demo::onUserInput(UserInput* ui) {
|
||||||
if (ui->keyPressed(SDLK_ESCAPE)) {
|
if (ui->keyPressed(SDLK_ESCAPE)) {
|
||||||
@@ -265,20 +268,6 @@ void Demo::onUserInput(UserInput* ui) {
|
|||||||
{
|
{
|
||||||
app->debugController.setActive(true);
|
app->debugController.setActive(true);
|
||||||
}
|
}
|
||||||
if(ui->keyPressed(SDLK_KP_PLUS))
|
|
||||||
{
|
|
||||||
spacing++;
|
|
||||||
messageTime = System::time();
|
|
||||||
message = "Spacing set to " + Convert(spacing);
|
|
||||||
}
|
|
||||||
if(ui->keyPressed(SDLK_KP_MINUS))
|
|
||||||
{
|
|
||||||
spacing--;
|
|
||||||
messageTime = System::time();
|
|
||||||
message = "Spacing set to " + Convert(spacing);
|
|
||||||
|
|
||||||
OnError(3423);
|
|
||||||
}
|
|
||||||
else if(ui->keyReleased(SDL_RIGHT_MOUSE_KEY))
|
else if(ui->keyReleased(SDL_RIGHT_MOUSE_KEY))
|
||||||
{
|
{
|
||||||
app->debugController.setActive(false);
|
app->debugController.setActive(false);
|
||||||
@@ -321,6 +310,7 @@ void Demo::onUserInput(UserInput* ui) {
|
|||||||
}
|
}
|
||||||
mousex = ui->getMouseX();
|
mousex = ui->getMouseX();
|
||||||
mousey = ui->getMouseY();
|
mousey = ui->getMouseY();
|
||||||
|
mouseButton1Down = ui->keyDown(SDL_LEFT_MOUSE_KEY);
|
||||||
//readMouseGUIInput();
|
//readMouseGUIInput();
|
||||||
// Add other key handling here
|
// Add other key handling here
|
||||||
}
|
}
|
||||||
@@ -525,7 +515,12 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
if(mouseInArea(10,25,70,85))
|
if(mouseInArea(10,25,70,85))
|
||||||
glBindTexture( GL_TEXTURE_2D, go_ovr_id);
|
{
|
||||||
|
if(mouseButton1Down)
|
||||||
|
glBindTexture( GL_TEXTURE_2D, go_dn_id);
|
||||||
|
else
|
||||||
|
glBindTexture( GL_TEXTURE_2D, go_ovr_id);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
glBindTexture( GL_TEXTURE_2D, go_id);
|
glBindTexture( GL_TEXTURE_2D, go_id);
|
||||||
|
|
||||||
@@ -559,7 +554,9 @@ void App::main() {
|
|||||||
// Load objects here
|
// Load objects here
|
||||||
go = Texture::fromFile(GetFileInPath("/content/images/Run.png"));
|
go = Texture::fromFile(GetFileInPath("/content/images/Run.png"));
|
||||||
go_ovr = Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png"));
|
go_ovr = Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png"));
|
||||||
|
go_dn = Texture::fromFile(GetFileInPath("/content/images/Run_dn.png"));
|
||||||
go_id = go->getOpenGLID();
|
go_id = go->getOpenGLID();
|
||||||
|
go_dn_id = go_dn->getOpenGLID();
|
||||||
go_ovr_id = go_ovr->getOpenGLID();
|
go_ovr_id = go_ovr->getOpenGLID();
|
||||||
fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
|
fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
|
||||||
fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
|
fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
|
||||||
|
|||||||
Reference in New Issue
Block a user