Subversion Repositories Kolibri OS

Rev

Rev 3773 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2010 VMware, Inc.
  4.  * All Rights Reserved.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the
  8.  * "Software"), to deal in the Software without restriction, including
  9.  * without limitation the rights to use, copy, modify, merge, publish,
  10.  * distribute, sub license, and/or sell copies of the Software, and to
  11.  * permit persons to whom the Software is furnished to do so, subject to
  12.  * the following conditions:
  13.  *
  14.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16.  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  17.  * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
  18.  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  19.  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  20.  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  21.  *
  22.  * The above copyright notice and this permission notice (including the
  23.  * next paragraph) shall be included in all copies or substantial portions
  24.  * of the Software.
  25.  *
  26.  *
  27.  **************************************************************************/
  28.  
  29. #include "sw/kos_sw_winsys.h"
  30. #include "pipe/p_screen.h"
  31. #include "state_tracker/graw.h"
  32. #include "target-helpers/inline_debug_helper.h"
  33. #include "target-helpers/inline_sw_helper.h"
  34. #include <kos32sys.h>
  35. //#include <windows.h>
  36.  
  37. /*
  38. static LRESULT CALLBACK
  39. window_proc(HWND hWnd,
  40.             UINT uMsg,
  41.             WPARAM wParam,
  42.             LPARAM lParam)
  43. {
  44.    switch (uMsg) {
  45.    case WM_DESTROY:
  46.       PostQuitMessage(0);
  47.       break;
  48.  
  49.    default:
  50.       return DefWindowProc(hWnd, uMsg, wParam, lParam);
  51.    }
  52.  
  53.    return 0;
  54. }
  55. */
  56.  
  57. static struct {
  58.    void (* draw)(void);
  59. } graw;
  60.  
  61. struct pipe_screen *
  62. graw_create_window_and_screen(int x,
  63.                               int y,
  64.                               unsigned width,
  65.                               unsigned height,
  66.                               enum pipe_format format,
  67.                               void **handle)
  68. {
  69.    struct sw_winsys *winsys = NULL;
  70.    struct pipe_screen *screen = NULL;
  71.  
  72.    if (format != PIPE_FORMAT_B8G8R8X8_UNORM)
  73.       goto fail;
  74.  
  75.    winsys = kos_create_sw_winsys();
  76.    if (winsys == NULL)
  77.       goto fail;
  78.  
  79.    screen = sw_screen_create(winsys);
  80.    if (screen == NULL)
  81.       goto fail;
  82.  
  83.     return (screen);
  84.  
  85. fail:
  86.  
  87.    if (screen)
  88.       screen->destroy(screen);
  89.  
  90.    return NULL;
  91. }
  92.  
  93. void
  94. graw_set_display_func(void (* draw)(void))
  95. {
  96.    graw.draw = draw;
  97. }
  98.  
  99. void
  100. graw_main_loop(void)
  101. {
  102.    for (;;) {
  103.  
  104.       if (graw.draw) {
  105.          graw.draw();
  106.       }
  107.  
  108.       delay(1);
  109.    }
  110. }
  111.