]> git.vomp.tv Git - vompclient.git/blob - osdwinpixel.cc
Windows fixes
[vompclient.git] / osdwinpixel.cc
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20 #include "defines.h"
21
22 #ifndef GRADIENT_DRAWING
23
24 #include "osdwinpixel.h"
25 #include "videowin.h"
26 #include "surfacewin.h"
27
28
29 #include "message.h"
30 #include "command.h"
31
32
33
34 //This is stuff for rendering the OSD
35
36 OsdWinPixel::OsdWinPixel()
37 {
38
39
40   
41 }
42
43 OsdWinPixel::~OsdWinPixel()
44 {
45   if (initted) 
46   {
47                 shutdown();
48   }
49 }
50
51 int OsdWinPixel::getFD()
52 {
53   if (!initted) return 0;
54   return fdOsd;
55 }
56
57 Surface * OsdWinPixel::createNewSurface(){
58         return (Surface*)new SurfaceWin();
59 }
60
61 int OsdWinPixel::init()
62 {
63   if (initted) return 0;
64
65   if (!createDirect3D9Objects()) return 0;
66   GdiplusStartup(&gdiptoken, &gdipstartup, NULL);
67
68   VideoWin* video = (VideoWin*)Video::getInstance();
69   //Now we will create the Screen
70   screen = new SurfaceWin(Surface::SCREEN);
71   screen->create(video->getScreenWidth(), video->getScreenHeight());
72   screen->display();
73   initted = true; // must set this here or create surface won't work
74
75   startRenderLoop();
76
77   return 1;
78 }
79
80
81 int OsdWinPixel::shutdown()
82 {
83   if (!initted) return 0;
84   initted = false;
85   stopRenderLoop();
86   shutdownDirect3D9Objects();
87  
88   Gdiplus::GdiplusShutdown(gdiptoken);
89
90   return 1;
91 }
92
93 void OsdWinPixel::screenShot(const char* fileName)
94 {
95   screen->screenShot(fileName);
96 }
97
98 LPDIRECT3DTEXTURE9 OsdWinPixel::getNextOsdTexture()
99 {
100         return ((SurfaceWin*)screen)->getD3dtexture();
101 }
102
103 void OsdWinPixel::lostDestroyObjects()
104 {
105         ((SurfaceWin*)screen)->ReleaseSurface();
106 }
107
108 void OsdWinPixel::lostRecreateObjects()
109 {
110         Video *video = Video::getInstance();
111         screen->create(video->getScreenWidth(), video->getScreenHeight());
112         screen->display();
113 }
114
115 void OsdWinPixel::getTextureCoordinates(FLOAT*x, FLOAT*y)
116 {
117         Video* video = Video::getInstance();
118         FLOAT texx = ((float)video->getScreenWidth()) / 1024.f;
119         FLOAT texy = ((float)video->getScreenHeight()) / 1024.f;
120         *x = texx;
121         *y = texy;
122
123 }
124 #endif