doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RenderBumpFlatDialog.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #include "../../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "../../sys/win32/common_resource.h"
33 
34 idCVar rbfg_DefaultWidth( "rbfg_DefaultWidth", "0", 0, "" );
35 idCVar rbfg_DefaultHeight( "rbfg_DefaultHeight", "0", 0, "" );
36 
37 static idStr RBFName;
38 
39 static bool CheckPow2(int Num)
40 {
41  while(Num)
42  {
43  if ((Num & 1) && (Num != 1))
44  {
45  return false;
46  }
47 
48  Num >>= 1;
49  }
50 
51  return true;
52 }
53 
54 extern void Com_WriteConfigToFile( const char *filename );
55 
56 static BOOL CALLBACK RBFProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
57 {
58  switch (message)
59  {
60  case WM_INITDIALOG:
61  SetDlgItemInt(hwndDlg, IDC_RBF_WIDTH, rbfg_DefaultWidth.GetInteger(), FALSE);
62  SetDlgItemInt(hwndDlg, IDC_RBF_HEIGHT, rbfg_DefaultHeight.GetInteger(), FALSE);
63  SetDlgItemText(hwndDlg, IDC_RBF_FILENAME, RBFName);
64  return TRUE;
65 
66  case WM_COMMAND:
67  switch (LOWORD(wParam))
68  {
69  case IDOK:
70  {
71  int width, height;
72 
73  width = GetDlgItemInt(hwndDlg, IDC_RBF_WIDTH, 0, FALSE);
74  height = GetDlgItemInt(hwndDlg, IDC_RBF_HEIGHT, 0, FALSE);
75 
78 
80 
81  if (!CheckPow2(width) || !CheckPow2(height))
82  {
83  return TRUE;
84  }
85 
86  DestroyWindow(hwndDlg);
87 
88  cmdSystem->BufferCommandText( CMD_EXEC_APPEND, va("renderbumpflat -size %d %d %s\n", width, height, RBFName.c_str() ) );
89  return TRUE;
90  }
91 
92  case IDCANCEL:
93  DestroyWindow(hwndDlg);
94  return TRUE;
95  }
96  }
97 
98  return FALSE;
99 }
100 
101 void DoRBFDialog(const char *FileName)
102 {
103  RBFName = FileName;
104 
105  Sys_GrabMouseCursor( false );
106 
107  DialogBox(0, MAKEINTRESOURCE(IDD_RENDERBUMPFLAT), 0, (DLGPROC)RBFProc);
108 
109  Sys_GrabMouseCursor( true );
110 }
CONST PIXELFORMATDESCRIPTOR UINT
Definition: win_qgl.cpp:47
idCVar rbfg_DefaultWidth("rbfg_DefaultWidth","0", 0,"")
#define CONFIG_FILE
Definition: Licensee.h:51
idCmdSystem * cmdSystem
Definition: CmdSystem.cpp:116
#define IDC_RBF_HEIGHT
#define BOOL
Definition: mprintf.c:71
virtual void BufferCommandText(cmdExecution_t exec, const char *text)=0
void Com_WriteConfigToFile(const char *filename)
#define IDC_RBF_FILENAME
void SetInteger(const int value)
Definition: CVarSystem.h:148
int GetInteger(void) const
Definition: CVarSystem.h:143
GLenum GLsizei width
Definition: glext.h:2846
GLenum GLsizei GLsizei height
Definition: glext.h:2856
idCVar rbfg_DefaultHeight("rbfg_DefaultHeight","0", 0,"")
Definition: Str.h:116
void DoRBFDialog(const char *FileName)
const char * c_str(void) const
Definition: Str.h:487
#define FALSE
Definition: mprintf.c:70
#define IDC_RBF_WIDTH
#define TRUE
Definition: mprintf.c:69
char * va(const char *fmt,...)
Definition: Str.cpp:1568
#define IDD_RENDERBUMPFLAT
void Sys_GrabMouseCursor(bool)
Definition: dedicated.cpp:43