4 #include <Evas_Engine_Direct3D.h>
8 static HINSTANCE instance;
11 static LRESULT CALLBACK
12 MainWndProc(HWND hwnd,
31 hdc = BeginPaint (window, &ps);
32 evas_damage_rectangle_add(evas,
33 ps.rcPaint.left, ps.rcPaint.top,
34 ps.rcPaint.right - ps.rcPaint.left,
35 ps.rcPaint.bottom - ps.rcPaint.top);
36 EndPaint(window, &ps);
41 PRECT rect = (PRECT)lParam;
43 evas_output_viewport_set(evas, 0, 0,
44 rect->right - rect->left,
45 rect->bottom - rect->top);
46 evas_output_size_set(evas,
47 rect->right - rect->left,
48 rect->bottom - rect->top);
49 win_w = rect->right - rect->left;
50 win_h = rect->bottom - rect->top;
54 evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
55 evas_event_feed_mouse_down(evas, 3, EVAS_BUTTON_NONE, 0, NULL);
58 evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
59 evas_event_feed_mouse_down(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
62 evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
63 evas_event_feed_mouse_up(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
66 evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
67 evas_event_feed_mouse_up(evas, 3, EVAS_BUTTON_NONE, 0, NULL);
70 if (!evas_pointer_inside_get(evas)) evas_event_feed_mouse_in(evas, 0, NULL);
71 evas_event_feed_mouse_move(evas, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, NULL);
74 evas_event_feed_mouse_out(evas, 0, NULL);
76 /* FIXME : can't find an event when the mouse is entering */
83 if ((key == VK_SHIFT) ||
86 evas_key_modifier_on(evas, "Shift");
87 if ((key == VK_CONTROL) ||
88 (key == VK_LCONTROL) ||
90 evas_key_modifier_on(evas, "Control");
91 if ((key == VK_MENU) ||
94 evas_key_modifier_on(evas, "Alt");
95 if ((key == VK_LWIN) ||
97 evas_key_modifier_on(evas, "Super");
99 if (key == VK_CAPITAL)
101 if (evas_key_lock_is_set(evas_key_lock_get(evas), "Caps_Lock"))
102 evas_key_lock_off(evas, "Caps_Lock");
104 evas_key_lock_on(evas, "Caps_Lock");
106 if (key == VK_NUMLOCK)
108 if (evas_key_lock_is_set(evas_key_lock_get(evas), "Num_Lock"))
109 evas_key_lock_off(evas, "Num_Lock");
111 evas_key_lock_on(evas, "Num_Lock");
113 if (key == VK_SCROLL)
115 if (evas_key_lock_is_set(evas_key_lock_get(evas), "Scroll_Lock"))
116 evas_key_lock_off(evas, "Scroll_Lock");
118 evas_key_lock_on(evas, "Scroll_Lock");
120 if (key == VK_ESCAPE)
121 evas_event_feed_key_down(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
122 if (key == VK_RETURN)
123 evas_event_feed_key_down(evas, "Return", "Return", NULL, NULL, 0, NULL);
125 evas_event_feed_key_down(evas, "Left", "Left", NULL, NULL, 0, NULL);
127 evas_event_feed_key_down(evas, "Right", "Right", NULL, NULL, 0, NULL);
129 evas_event_feed_key_down(evas, "Q", "Q", NULL, NULL, 0, NULL);
131 evas_event_feed_key_down(evas, "q", "q", NULL, NULL, 0, NULL);
138 key = LOWORD(wParam);
140 if ((key == VK_SHIFT) ||
141 (key == VK_LSHIFT) ||
143 evas_key_modifier_off(evas, "Shift");
144 if ((key == VK_CONTROL) ||
145 (key == VK_LCONTROL) ||
146 (key == VK_RCONTROL))
147 evas_key_modifier_off(evas, "Control");
148 if ((key == VK_MENU) ||
151 evas_key_modifier_off(evas, "Alt");
152 if ((key == VK_LWIN) ||
154 evas_key_modifier_off(evas, "Super");
155 if (key == VK_ESCAPE)
156 evas_event_feed_key_up(evas, "Escape", "Escape", NULL, NULL, 0, NULL);
157 if (key == VK_RETURN)
158 evas_event_feed_key_up(evas, "Return", "Return", NULL, NULL, 0, NULL);
160 evas_event_feed_key_up(evas, "Left", "Left", NULL, NULL, 0, NULL);
162 evas_event_feed_key_up(evas, "Right", "Right", NULL, NULL, 0, NULL);
164 evas_event_feed_key_up(evas, "Q", "Q", NULL, NULL, 0, NULL);
166 evas_event_feed_key_up(evas, "q", "q", NULL, NULL, 0, NULL);
170 return DefWindowProc(hwnd, uMsg, wParam, lParam);
175 engine_direct3d_args(const char *engine, int width, int height)
181 Evas_Engine_Info_Direct3D *einfo;
186 instance = GetModuleHandle(NULL);
187 if (!instance) return EINA_FALSE;
190 wc.lpfnWndProc = MainWndProc;
193 wc.hInstance = instance;
194 wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
195 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
196 wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
197 wc.lpszMenuName = NULL;
198 wc.lpszClassName = "Evas_Direct3D_Test";
200 if(!RegisterClass(&wc))
206 rect.bottom = height;
207 AdjustWindowRect (&rect, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, FALSE);
209 window = CreateWindowEx(0,
210 "Evas_Direct3D_Test",
211 "Evas_Direct3D_Test",
212 WS_OVERLAPPEDWINDOW | WS_SIZEBOX,
213 CW_USEDEFAULT, CW_USEDEFAULT,
214 rect.right - rect.left, rect.bottom - rect.top,
215 NULL, NULL, instance, NULL);
217 goto unregister_class;
219 /* make the window non resizable */
220 style = GetWindowLong(window, GWL_STYLE);
221 style &= ~WS_THICKFRAME;
222 if (!SetWindowLong(window, GWL_STYLE, style))
223 goto unregister_class;
229 depth = GetDeviceCaps(dc, BITSPIXEL);
232 evas_output_method_set(evas, evas_render_method_lookup("direct3d"));
233 einfo = (Evas_Engine_Info_Direct3D *)evas_engine_info_get(evas);
236 fprintf(stderr, "Evas does not support the Direct3D Engine\n");
240 einfo->info.window = window;
241 einfo->info.depth = depth;
242 einfo->info.rotation = 0;
243 if (!evas_engine_info_set(evas, (Evas_Engine_Info *)einfo))
245 printf("Evas can not setup the informations of the Direct3D Engine\n");
249 /* the second parameter is ignored, as it's the first call of ShowWindow */
250 ShowWindow(window, SW_SHOWDEFAULT);
251 UpdateWindow(window);
256 DestroyWindow(window);
258 UnregisterClass("Evas_Direct3D_Test", instance);
260 FreeLibrary(instance);
266 engine_direct3d_loop(void)
272 if (!PeekMessage (&msg, window, 0, 0, PM_NOREMOVE))
275 res = GetMessage (&msg, NULL, 0, 0);
276 TranslateMessage (&msg);
277 DispatchMessage (&msg);
283 engine_direct3d_shutdown(void)
285 DestroyWindow(window);
286 UnregisterClass("Evas_Direct3D_Test", instance);
287 FreeLibrary(instance);