zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Fog.cpp
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <zeni_graphics.h>
19 
20 #ifndef DISABLE_DX9
21 #include <d3dx9.h>
22 #endif
23 
24 #ifndef DISABLE_GL
25 #if defined(REQUIRE_GL_ES)
26 #include <GLES/gl.h>
27 #else
28 #include <GL/glew.h>
29 #endif
30 #endif
31 
32 namespace Zeni {
33 
34  Fog::Fog(const Color &color_,
35  const float &density_,
36  const FOG_TYPE &type_,
37  const float &start_,
38  const float &end_)
39  : type(type_),
40  color(color_),
41  density(density_),
42  start(start_),
43  end(end_)
44  {
45  }
46 
47 #ifndef DISABLE_GL_FIXED
48  void Fog::set(Video_GL_Fixed &) const {
49  const int mode = type == FOG_EXP ? GL_EXP
50  : type == FOG_EXP2 ? GL_EXP2
51  : GL_LINEAR;
52 
53  glFogi(GL_FOG_MODE, mode);
54 
55  if(type == FOG_LINEAR) {
58  }
59  else
61 
62  glFogfv(GL_FOG_COLOR, reinterpret_cast<const GLfloat *>(&color));
64  }
65 #endif
66 
67 #ifndef DISABLE_GL_SHADER
68  void Fog::set(Video_GL_Shader &vgl) const {
70  set(reinterpret_cast<Video_GL_Fixed &>(vgl));
71  }
72 #endif
73 
74 #ifndef DISABLE_DX9
75  void Fog::set(Video_DX9 &screen) const {
76  const DWORD mode = type == FOG_EXP ? D3DFOG_EXP
78  : D3DFOG_LINEAR;
79 
80  screen.get_d3d_device()->SetRenderState(D3DRS_FOGTABLEMODE, mode);
81 
82  if(type == FOG_LINEAR) {
83  screen.get_d3d_device()->SetRenderState(D3DRS_FOGSTART, *(DWORD *)(&start));
84  screen.get_d3d_device()->SetRenderState(D3DRS_FOGEND, *(DWORD *)(&end));
85  }
86  else
87  screen.get_d3d_device()->SetRenderState(D3DRS_FOGDENSITY, *(DWORD *)(&density));
88 
89  screen.get_d3d_device()->SetRenderState(D3DRS_FOGCOLOR, color.get_argb());
90  }
91 #endif
92 
93 }
#define glHint
Definition: gl_mangle.h:918
#define GL_NICEST
Definition: gl2.h:229
#define GL_FOG_COLOR
Definition: glew_head.h:366
The Direct3D9 Rendering System.
Definition: Video_DX9.h:62
LPDIRECT3DDEVICE9 & get_d3d_device()
See DirectX Documentation for details.
Definition: Video_DX9.hxx:48
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: gl2ext.h:845
GLuint color
Definition: glew.h:7185
GLuint start
Definition: glew.h:1239
#define glFogfv
Definition: gl_mangle.h:509
void set(Video_GL_Fixed &screen) const
Definition: Fog.cpp:48
FOG_TYPE
Definition: Fog.h:45
The OpenGL Rendering System.
#define glFogf
Definition: gl_mangle.h:507
#define GL_FOG_HINT
Definition: glew_head.h:421
The OpenGL Rendering System.
Fog(const Color &color_=ZENI_DEFAULT_FOG_COLOR, const float &density_=ZENI_DEFAULT_FOG_DENSITY, const FOG_TYPE &type_=ZENI_DEFAULT_FOG_TYPE, const float &start_=ZENI_DEFAULT_FOG_START, const float &end_=ZENI_DEFAULT_FOG_END)
Definition: Fog.cpp:34
float density
used when (FOGTYPE == FOG_EXP || FOGTYPE == FOG_EXP2)
Definition: Fog.h:68
#define GL_FOG_START
Definition: glew_head.h:363
#define GL_LINEAR
Definition: gl2.h:308
#define GL_EXP
Definition: glew_head.h:312
#define GL_FOG_DENSITY
Definition: glew_head.h:362
typedef DWORD(WINAPI *XInputGetState_t)(DWORD dwUserIndex
GLuint GLuint end
Definition: glew.h:1239
#define GL_FOG_MODE
Definition: glew_head.h:365
#define glFogi
Definition: gl_mangle.h:510
GLenum mode
Definition: glew.h:2394
#define GL_FOG_END
Definition: glew_head.h:364
Color.
Definition: Color.h:41
#define GL_EXP2
Definition: glew_head.h:314