Mercurial > hg > Game > Cerium
annotate Renderer/Engine/viewerPS3.cc @ 1319:31455d34e502 draft
collada file reader minor changes.
author | Taiki TAIRA <e095767@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 18 Dec 2011 09:39:14 +0900 |
parents | da1cec21f0c9 |
children |
rev | line source |
---|---|
981
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
1 #include "viewerPS3.h" |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
2 #include "fb.h" |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
3 #include "types.h" |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
4 #include "ps3fb/cp_vt.h" |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
5 #include "ps3fb/cp_fb.h" |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
6 #include <stdio.h> |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
7 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
8 #define default_sdl_flag SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
9 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
10 ViewerPS3::ViewerPS3() {} |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
11 ViewerPS3::~ViewerPS3() {} |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
12 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
13 #if defined(__linux__) |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
14 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
15 #define DEVICE_NAME "/dev/fb0" |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
16 #define DIV_BYTE 8 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
17 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
18 ScreenInfo |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
19 ViewerPS3::get_fbdev_addr() |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
20 { |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
21 ScreenInfo info; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
22 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
23 cp_vt_open_graphics(&vt); |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
24 cp_fb_open(&fb); |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
25 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
26 info.xres = fb.w; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
27 info.yres = fb.h; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
28 info.vbpp = 32; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
29 info.fbptr[0] = (uint32_t *)fb.draw_addr[ 0 ]; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
30 info.fbptr[1] = (uint32_t *)fb.draw_addr[ 1 ]; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
31 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
32 return info; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
33 } |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
34 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
35 #else /* !defined(__linux__) */ |
988 | 36 ScreenInfo |
37 ViewerPS3::get_fbdev_addr(void) { | |
981
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
38 ScreenInfo tmp = {0,0,0,0}; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
39 return tmp; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
40 } |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
41 #endif /* defined(__linux__) */ |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
42 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
43 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
44 Uint32 * |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
45 ViewerPS3::video_init(TaskManager *manager, int bpp, int width, int height) |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
46 { |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
47 // Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
48 Uint32 sdl_flag = default_sdl_flag ; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
49 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
50 if (SDL_Init(sdl_flag) < 0) { |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
51 fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError()); |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
52 exit(1); |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
53 } |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
54 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
55 screen_info = get_fbdev_addr(); |
984 | 56 |
981
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
57 uint32_t *pixels = screen_info.fbptr[frame_ndx]; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
58 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
59 if (pixels == 0) { |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
60 fprintf(stderr, "Cannot get frame buffer!\n"); |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
61 pixels = (new Uint32[width*height*32/8]); |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
62 } |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
63 this->width = screen_info.xres; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
64 this->height = screen_info.yres; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
65 this->bpp = screen_info.vbpp; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
66 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
67 return pixels; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
68 } |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
69 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
70 void |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
71 ViewerPS3::clean_pixels() |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
72 { |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
73 } |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
74 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
75 void |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
76 ViewerPS3::clear_screen() |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
77 { |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
78 } |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
79 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
80 uint32_t * |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
81 ViewerPS3::flip_screen(uint32_t *old) |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
82 { |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
83 // At the vsync, the previous frame is finished sending to the CRT |
985 | 84 // cp_fb_wait_vsync( &fb ); |
981
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
85 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
86 // Send the frame just drawn to the CRT by the next vblank |
988 | 87 #ifdef __linux__ |
981
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
88 cp_fb_flip( &fb, frame_ndx ); |
988 | 89 #endif |
981
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
90 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
91 frame_ndx = frame_ndx ^ 0x01; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
92 return (uint32_t*)fb.draw_addr[ frame_ndx ]; |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
93 } |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
94 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
95 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
96 void |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
97 ViewerPS3::free_device() |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
98 { |
988 | 99 #ifdef __linux__ |
981
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
100 cp_vt_close(&vt); |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
101 cp_fb_close(&fb); |
988 | 102 #endif |
981
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
103 } |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
104 |
fdb36a9c5030
add double buffering frame device
root@henri.cr.ie.u-ryukyu.ac.jp
parents:
diff
changeset
|
105 /* end */ |