BasicEntry.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 1.0 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 OpenFX Development Team
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019 You may contact the OpenFX development team via elecronic mail
00020 at core@openfx.org, or visit our website at http://openfx.org for
00021 further information and support details.
00022 -- */
00023 
00024 /* TEMPLATE.C  example image post-processing external DLL                  */
00025 
00026 /* The user interface for these effects is similar to the Shaders interface.*/
00027 /* A DialogBox is presented to the user in which any standard Windows       */
00028 /* control may be placed. Each control should correspond to a parameter of  */
00029 /* the effect. When the user dismisses the DialogBox the parameters are     */
00030 /* written as text to a character string that can be of any length. The     */
00031 /* text string is stored in the STG file and is passed back to the Dialog   */
00032 /* box function when the parameters need to be edited                       */
00033 /* DLL will contain a Function that implements the effect and this function */
00034 /* reads the parameters using sscanf() and then acts upon them.             */
00035 /* Several example PostProcessors are provided along with this template     */
00036 /* that show how to use the information passed in the XIMAGE data structure */
00037 
00038 #include <stdlib.h>
00039 #include <stdio.h>
00040 #include <float.h>
00041 #include <math.h>
00042 #include <windows.h>
00043 
00044 #include "struct.h"           /* general structures    */
00045 #include "..\common\postprocess\ximage.h"
00046 #include "local.h"
00047 
00048 #include "template.h" /* Dialog ID's etc.   */
00049 
00050 #if __X__MIPS__
00051 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00052 #endif
00053 
00054 static HINSTANCE hDLLinstance=NULL; /* use to pick up resources from DLL   */
00055 static long version;
00056 
00057 /************************** Local Utility Functions ***********************/
00058 
00059 #include "utils.h"
00060 
00061 /************************** DLL entry point ********************************/
00062 
00063 #if __WATCOMC__
00064 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00065 #elif __BC__
00066 BOOL WINAPI DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00067 #else
00068 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00069 #endif
00070   switch (dwReason) {
00071     case DLL_PROCESS_ATTACH:
00072 #if __X__MIPS__
00073       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00074 #endif
00075       hDLLinstance = hDLL;  /* handle to DLL file */
00076       break;
00077     case DLL_PROCESS_DETACH:
00078 #if __X__MIPS__
00079       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00080 #endif
00081       break;
00082   }
00083 return (int)TRUE;
00084 }
00085 
00086 #if __SC__
00087 #pragma startaddress(DllMain)
00088 #endif
00089 
00090 /*******************************************************************\
00091 |                Code that executes the process                     |
00092 \*******************************************************************/
00093 
00094 long _RenderImageProcess(char *PrmList, XIMAGE *lpXimage){
00095 /* read the parameters from the character string in which they are stored */
00096 // sscanf(PrmList,"  ",version     );
00097 
00098  return 1;
00099 }
00100 
00101 /*************** Functions used to set up      ***************/
00102 
00103 /* Dialog box callback  */
00104 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00105 
00106 /* Function called from Animator to provide the user interface Dialog    */
00107 char * _SetExternalParameters(
00108   char *Op,                 /* string for the parameters                  */
00109   HWND hWnd,                /* parent window                              */
00110   long ruler,               /* ruler scale value to facilitate scaling    */
00111   char *name,               /* name of DLL file with the effect           */
00112   X__MEMORY_MANAGER *lpEVI /* pointer to structure with memory functions */
00113                                     ){
00114  /* output name and buffer should be as long as necessary to hold full string */
00115  char buffer[256]; /* make long enough to store all parameters as text */
00116  if(Op != NULL){   /* parameters exist so read them off the list  */
00117    sscanf(Op,"%s %ld",buffer,&version); /* first parameter is always the NAME */
00118  }
00119  /*   Do the user interface as required to set up the effect, may use a     */
00120  /*   dialog box etc. Return old string if effect is cancelled (no change)  */
00121  if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG_TEMPLATE),hWnd,
00122               (DLGPROC)DlgProc) == FALSE)return Op;
00123  /* Free space occupied by old parameter string */
00124  if(Op != NULL)CALL_FREE(Op);  /* free the old string */
00125  /* print the parameters into the buffer */
00126  sprintf(buffer,"%s %ld",name,version); /* always print the NAME first  */
00127  /* Prepare the output buffer to take copy of parameter list */
00128  if((Op=(char *)CALL_MALLOC(strlen(buffer)+1)) == NULL){
00129   MessageBox (GetFocus(),"External effect: Out of memory","Error",
00130                 MB_OK|MB_TASKMODAL|MB_ICONSTOP);
00131    return NULL;
00132  }
00133  /* Copy the parameter string to the output buffer */
00134  strcpy(Op,buffer);
00135  return Op;
00136 }
00137 
00138 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00139  char str[32];
00140  switch( msg ) {
00141    case WM_INITDIALOG:
00142      CentreDialogOnScreen(hwnd);
00143      return TRUE;
00144    case WM_COMMAND:
00145      switch(LOWORD(wparam)){
00146         case IDCANCEL:
00147           EndDialog(hwnd,FALSE);
00148           return(TRUE);
00149         case IDOK:
00150           EndDialog(hwnd,TRUE);
00151           return(TRUE);
00152         default:
00153           break;
00154       }
00155       break;
00156     default: break;
00157  }
00158  return FALSE;
00159 }
00160 

Generated on Sun Apr 27 14:20:12 2014 for OpenFX by  doxygen 1.5.6