00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <stdlib.h>
00021 #include <stdio.h>
00022 #include <float.h>
00023 #include <math.h>
00024 #include <windows.h>
00025
00026 #include <gl/gl.h>
00027 #include <gl/glu.h>
00028
00029
00030 #include <fcntl.h>
00031 #define __gl2_main_
00032 #include "..\gl2.h"
00033 #define PADDR(functype,funcname) (funcname = (functype) wglGetProcAddress( #funcname ))
00035
00036 #include "struct.h"
00037 #include "..\common\postprocess\ximage.h"
00038 #include "local.h"
00039
00040 #include "filter.h"
00041
00042 #if __X__MIPS__
00043 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00044 #endif
00045
00046 static HINSTANCE hDLLinstance=NULL;
00047
00048
00049
00050 #include "utils.h"
00051
00052 #include "paint.c"
00053
00054
00055
00056 #if __WATCOMC__
00057 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00058 #elif __BC__
00059 BOOL WINAPI DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00060 #else
00061 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00062 #endif
00063 switch (dwReason) {
00064 case DLL_PROCESS_ATTACH:
00065 #if __X__MIPS__
00066 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00067 #endif
00068
00069 hDLLinstance = hDLL;
00070 break;
00071 case DLL_PROCESS_DETACH:
00072 #if __X__MIPS__
00073 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00074 #endif
00075
00076 break;
00077 }
00078 return (int)TRUE;
00079 }
00080
00081 #if __SC__
00082 #pragma startaddress(DllMain)
00083 #endif
00084
00085
00086
00087
00088
00089 long _RenderImageProcess(char *PrmList, XIMAGE *lpXimage){
00090 int i,j;
00091 double rs,gs,bs;
00092 char dummy[255];
00093 fullscreenbuffer *S;
00094
00095 sscanf(PrmList,"%s %f %f %f",dummy,&rs,&gs,&bs);
00096
00097 S=lpXimage->Screen;
00098 for(j=0;j<lpXimage->Ymax;j++)
00099 for(i=0;i<lpXimage->Xmax;i++){
00100
00101 S->R = min(255,(unsigned char)((double)S->R * rs));
00102 S->G = min(255,(unsigned char)((double)S->G * gs));
00103 S->B = min(255,(unsigned char)((double)S->B * bs));
00104 S++;
00105 }
00106 return 1;
00107 }
00108
00109
00110
00111 long _RenderGLexternal(char *PrmList, XIMAGE *lpXimage){
00112 GLfloat rs,gs,bs;
00113 char dummy[255];
00114 gl2Initialize();
00115 sscanf(PrmList,"%s %f %f %f",dummy,&rs,&gs,&bs);
00116
00117
00118 glMatrixMode(GL_PROJECTION);
00119 glLoadIdentity();
00120 glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
00121 glMatrixMode( GL_MODELVIEW );
00122 glLoadIdentity();
00123 glViewport( 0, 0, lpXimage->Xmax,lpXimage->Ymax);
00124 glEnable(GL_BLEND);
00125 glDisable(GL_DEPTH_TEST);
00126 glDepthMask(GL_FALSE);
00127 glBlendColor(rs,gs,bs,1.0);
00128
00129 glBlendFunc(GL_ONE_MINUS_CONSTANT_COLOR,GL_CONSTANT_COLOR);
00130 glColor4f(0.0,0.0,0.0,1.0);
00131 glBegin(GL_QUADS);
00132 glVertex3f(0.0,0.0,-1.0);
00133 glVertex3f(1.0,0.0,-1.0);
00134 glVertex3f(1.0,1.0,-1.0);
00135 glVertex3f(0.0,1.0,-1.0);
00136 glEnd();
00137 glEnable(GL_DEPTH_TEST);
00138 glDepthMask(GL_TRUE);
00139 glDisable(GL_BLEND);
00140 return 1;
00141 }
00142
00143
00144
00145
00146
00147 double red_scale=1.0,green_scale=1.0,blue_scale=1.0;
00148
00149
00150 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00151
00152 char * _SetExternalParameters(
00153 char *Op,
00154 HWND hWnd,
00155 long ruler,
00156 char *name,
00157 X__MEMORY_MANAGER *lpEVI
00158 ){
00159
00160 char buffer[256];
00161 if(Op != NULL){
00162 sscanf(Op,"%s %f %f %f",buffer,&red_scale,&green_scale,&blue_scale);
00163 }
00164
00165
00166 if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG_FILTER),hWnd,
00167 (DLGPROC)DlgProc) == FALSE)return Op;
00168
00169 if(Op != NULL)CALL_FREE(Op);
00170
00171 sprintf(buffer,"%s %f %f %f",name,red_scale,green_scale,blue_scale);
00172
00173 if((Op=(char *)CALL_MALLOC(strlen(buffer)+1)) == NULL){
00174 MessageBox (GetFocus(),"External effect: Out of memory","Error",
00175 MB_OK|MB_TASKMODAL|MB_ICONSTOP);
00176 return NULL;
00177 }
00178
00179 strcpy(Op,buffer);
00180 return Op;
00181 }
00182
00183 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00184 char str[32];
00185 switch( msg ) {
00186 case WM_INITDIALOG:
00187
00188 sprintf(str,"%.2f",red_scale);
00189 SetDlgItemText(hwnd,DLG_FILTER_RED,str);
00190 sprintf(str,"%.2f",green_scale);
00191 SetDlgItemText(hwnd,DLG_FILTER_GREEN,str);
00192 sprintf(str,"%.2f",blue_scale);
00193 SetDlgItemText(hwnd,DLG_FILTER_BLUE,str);
00194 CentreDialogOnScreen(hwnd);
00195 return TRUE;
00196 case WM_PAINT:
00197 PaintBackground(hwnd);
00198 break;
00199 case WM_COMMAND:
00200 switch(LOWORD(wparam)){
00201 case IDCANCEL:
00202 EndDialog(hwnd,FALSE);
00203 return(TRUE);
00204 case IDOK:
00205 if(GetDlgItemText(hwnd,DLG_FILTER_RED,str,12) != 0)
00206 sscanf(str,"%f",&red_scale);
00207 if(GetDlgItemText(hwnd,DLG_FILTER_GREEN,str,12) != 0)
00208 sscanf(str,"%f",&green_scale);
00209 if(GetDlgItemText(hwnd,DLG_FILTER_BLUE,str,12) != 0)
00210 sscanf(str,"%f",&blue_scale);
00211 EndDialog(hwnd,TRUE);
00212 return(TRUE);
00213 default:
00214 break;
00215 }
00216 break;
00217 default: break;
00218 }
00219 return FALSE;
00220 }
00221