Exemplo n.º 1
0
Arquivo: main.cpp Projeto: Raf22/Snow
int main() {

    Window window;
    Camera camera(window.GetAspectRatio(), glm::vec3(2.0, 2.0, 1.0));
    Mesh* sphereMesh = CreateMesh("sphere.obj", "sphere");
    Shader defaultShader("Shaders/defaultShader.vert", "Shaders/defaultShader.frag", "defaultShader");
    SetupMesh(sphereMesh, defaultShader);
    do {
        window.Clear();

        DrawMesh(*sphereMesh, camera, defaultShader);
        camera.front = sphereMesh->position;
        sphereMesh->rotY -= 0.016;
        {
            if (glfwGetKey(window.GetWindowInstance(), GLFW_KEY_W) == GLFW_PRESS) {
                sphereMesh->position.x -= 0.16;
            }
            else if (glfwGetKey(window.GetWindowInstance(), GLFW_KEY_S) == GLFW_PRESS) {
                sphereMesh->position.x += 0.16;
            }
            if (glfwGetKey(window.GetWindowInstance(), GLFW_KEY_A) == GLFW_PRESS) {
                sphereMesh->position.z += 0.16;
            }
            else if (glfwGetKey(window.GetWindowInstance(), GLFW_KEY_D) == GLFW_PRESS) {
                sphereMesh->position.z -= 0.16;
            }
        }
        window.Update();
    } while (!window.Closed() && glfwGetKey(window.GetWindowInstance(), GLFW_KEY_ESCAPE) != GLFW_PRESS);
    delete sphereMesh;
}
Exemplo n.º 2
0
void View::Refresh( void ) {
  Window *win = static_cast<Window *>( windows.Tail() );

  Flood( Color(CF_COLOR_WHITE) );
  while ( win ) {
    if ( !win->Closed() ) {
      win->Blit( this, Rect( 0, 0, win->Width(), win->Height() ),
                 win->LeftEdge(), win->TopEdge() );
    }
    win = static_cast<Window *>( win->Prev() );
  }

  // now update the display
  Update();
}
Exemplo n.º 3
0
GUI_Status View::HandleEvents( void ) {
  SDL_Event event;
  GUI_Status rc = FetchEvent( event );

  if ( (rc != GUI_ERROR) && (rc != GUI_QUIT) && (rc != GUI_NONE) ) {
    Window *win = static_cast<Window *>( windows.Head() );
    if ( win ) {
      rc = win->HandleEvent( event );
      if ( rc == GUI_CLOSE ) win = CloseWindow( win );
    }

    // collect destroyed windows
    while ( (win = static_cast<Window *>(windows.Tail())) && win->Closed() ) {
      win->Remove();
      delete win;
    }
  }
  return rc;
}
Exemplo n.º 4
0
void View::Refresh( const Rect &refresh ) {
  Window *window = static_cast<Window *>( windows.Tail() );
  Rect v( refresh );
  v.Clip( *this );

  FillRect( v, Color(CF_COLOR_WHITE) );
  while ( window ) {
    if ( !window->Closed() ) {
      // clip the window to the refresh area
      Rect win = *window;
      Rect src( 0, 0, window->Width(), window->Height() );
      win.ClipBlit( src, v );
      if ( win.Width() && win.Height() )
        window->Blit( this, src, win.LeftEdge(), win.TopEdge() );
    }
    window = static_cast<Window *>( window->Prev() );
  }
  Update( v );
}
Exemplo n.º 5
0
void View::CloseAllWindows( void ) {
  for ( Window *w = static_cast<Window *>(windows.Head());
        w && !w->Closed(); w = static_cast<Window *>(w->Next()) )
    w->Close();
  Refresh();
}
Exemplo n.º 6
0
JNIEXPORT jboolean JNICALL Java_sp_app_Window_native_1Closed
(JNIEnv *env, jclass cls, jlong handler) {
	Window* window = getHandle<Window>(handler);
	return window->Closed();
}