Ejemplo n.º 1
0
bool ofFbo::checkGLSupport() {
#ifndef TARGET_OPENGLES
	if(CheckExtension("GL_EXT_framebuffer_object")){
		ofLog(OF_LOG_VERBOSE,"FBO supported");
	}else{
		ofLog(OF_LOG_ERROR, "FBO not supported by this graphics card");
		return false;
	}
	glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &_maxColorAttachments);
	glGetIntegerv(GL_MAX_DRAW_BUFFERS, &_maxDrawBuffers);
	glGetIntegerv(GL_MAX_SAMPLES, &_maxSamples);

	ofLog(OF_LOG_NOTICE, string("ofFbo::checkGLSupport()\n") +
		  "maxColorAttachments: " + ofToString(_maxColorAttachments) + "\n" +
		  "maxDrawBuffers: " + ofToString(_maxDrawBuffers) + "\n" +
		  "maxSamples: " + ofToString(_maxSamples)
		  );
#else

	if(CheckExtension("GL_OES_framebuffer_object")){
		ofLog(OF_LOG_VERBOSE,"FBO supported");
	}else{
		ofLog(OF_LOG_ERROR, "FBO not supported by this graphics card");
		return false;
	}
	string extensions = (char*)glGetString(GL_EXTENSIONS);
	ofLog(OF_LOG_VERBOSE,extensions);
#endif

	return true;
}
Ejemplo n.º 2
0
bool ofFbo::checkGLSupport() {
#ifndef TARGET_OPENGLES
	if(CheckExtension("GL_EXT_framebuffer_object")){
		ofLogVerbose("ofFbo") << "FBO supported";
	}else{
        ofLogError("ofFbo") << "FBO not supported by this graphics card";
		return false;
	}
	glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &_maxColorAttachments);
	glGetIntegerv(GL_MAX_DRAW_BUFFERS, &_maxDrawBuffers);
	glGetIntegerv(GL_MAX_SAMPLES, &_maxSamples);

	ofLogVerbose("ofFbo") << "checkGLSupport()"
                          << "maxColorAttachments: " << _maxColorAttachments
                          << "maxDrawBuffers: " << _maxDrawBuffers
                          << "maxSamples: " << _maxSamples;
#else

	if(CheckExtension("GL_OES_framebuffer_object")){
		ofLogVerbose("ofFbo") << "FBO supported";
	}else{
		ofLogError("ofFbo") << "FBO not supported by this graphics card";
		return false;
	}
	string extensions = (char*)glGetString(GL_EXTENSIONS);
	ofLogVerbose("ofFbo") << extensions;
#endif

	return true;
}
void ParticleInstancingRenderer::Initialize() {

    // Initialize can be called at any time - don't actually initialize
    // more than once.
    if (is_initialized)
        return;

    is_initialized = true;
    extensions_supported = false;

    // check for the extensions that are required
    GLboolean shader4_supported = CheckExtension("GL_EXT_gpu_shader4");
    if (shader4_supported)
        debug2 << "ParticleInstancingRenderer: Extension GL_EXT_gpu_shader4 supported" << endl;
    else
        debug2 << "ParticleInstancingRenderer: Extension GL_EXT_gpu_shader4 not supported" << endl;

	
    GLboolean tbo_supported = CheckExtension("GL_EXT_texture_buffer_object");
    if (tbo_supported)
        debug2 << "ParticleInstancingRenderer: Extension GL_EXT_texture_buffer_object supported" << endl;
    else
        debug2 << "ParticleInstancingRenderer: Extension GL_EXT_texture_buffer_object not supported" << endl;


    extensions_supported = (shader4_supported && tbo_supported);
	if (extensions_supported) {
	    debug1 << "ParticleInstancingRenderer: Necessary extensions supported, "
               << "using the new Molecule plot implementation." << endl;
	}
	else
    {
	    debug1 << "ParticleInstancingRenderer: Necessary extensions not supported, "
               << "using the old Molecule plot implementation." << endl;
	}

    // don't do any more if the extensions aren't supported
    if (!extensions_supported)
        return;



    // 
    GLint max_texture_buffer_size;
    glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE_EXT, &max_texture_buffer_size);
    debug1 << "maximal texture buffer size " << FormatBytes(max_texture_buffer_size) << endl;

    size_t instances_position_radius = size_t(max_texture_buffer_size) / (4*sizeof(float));
    size_t instances_color  = size_t(max_texture_buffer_size) / (4*sizeof(unsigned char));
    instanced_batch_size = std::min(instances_position_radius, instances_color);


    debug1 << "ParticleInstancingRenderer: Max number of instances " 
           << instanced_batch_size << " = "
           << instanced_batch_size / 1000000.0f << " million" << endl;

    GenerateAndBuildTBO();
    BuildSphereGeometryVBOs();
    BuildShaders();
}
Ejemplo n.º 4
0
bool ccFBOUtils::CheckShadersAvailability()
{
    bool bARBShadingLanguage       = CheckExtension("GL_ARB_shading_language_100");
    bool bARBShaderObjects         = CheckExtension("GL_ARB_shader_objects");
    bool bARBVertexShader          = CheckExtension("GL_ARB_vertex_shader");
    bool bARBFragmentShader        = CheckExtension("GL_ARB_fragment_shader");

    bool bShadersSupported = bARBShadingLanguage &&
                             bARBShaderObjects &&
                             bARBVertexShader &&
                             bARBFragmentShader;

    return bShadersSupported;
}
Ejemplo n.º 5
0
DWORD CPrecacheManager::OnLoadFile(DWORD size, void *data)
{
	VERIFY_MESSAGE_SIZE(size, sizeof(LOADFILEEXTPARAMS));
	
	LOADFILEEXTPARAMS *lfep = (LOADFILEEXTPARAMS *)data;

	CHashString hszFileResource( lfep->fileName );

	if( CheckExtension( lfep->fileName ) )
	{
		RESOURCEMAP::iterator itr = m_ResourceMap.find( hszFileResource.GetUniqueID() );
		if( itr == m_ResourceMap.end() )
		{
			// A new resource, add the entry to the map
			RESOURCEINFO tmpInfo;
			tmpInfo.m_bLoaded = true;
			tmpInfo.m_iRefCount = 1;
			m_ResourceMap[hszFileResource.GetUniqueID()] = tmpInfo;

			// Add the new resource to the current Precache file if it exists
			if( m_PrecacheStack.size() != 0 )
			{
				m_PrecacheStack.front()->AddResource( &hszFileResource );
			}
		}
	}
	
	return MSG_HANDLED_PROCEED;
}
Ejemplo n.º 6
0
void AnimManager_loadAll( AnimManager *am ) {
    if( am ) {
        struct dirent *entry = NULL;

        DIR *anim_dir = opendir( AnimDirectory );

        while( ( entry = readdir( anim_dir ) ) ) {
            const char *file = entry->d_name;

            if( CheckExtension( file, "json" ) ) {
                str32 anim_name;

                // remove '.json. extension from name
                int filename_n = strlen( file );
                strncpy( anim_name, file, filename_n - 5 );
                anim_name[filename_n-5] = 0;

                // find anim that match the name
                Anim *a = AnimManager_gets( am, anim_name );

                if( a ) {
                    str64 anim_path;
                    strcpy( anim_path, AnimDirectory );
                    strcat( anim_path, file );
                    Anim_loadFromFile( a, anim_path );
                }
            }
        }
    }
}
Ejemplo n.º 7
0
static int
VMwareXineramaIsActive(ClientPtr client)
{
    xXineramaIsActiveReply	rep;
    ExtensionEntry *ext;
    ScrnInfoPtr pScrn;
    VMWAREPtr pVMWARE;

    REQUEST_SIZE_MATCH(xXineramaIsActiveReq);

    if (!(ext = CheckExtension(PANORAMIX_PROTOCOL_NAME))) {
       return BadMatch;
    }
    pScrn = ext->extPrivate;
    pVMWARE = VMWAREPTR(pScrn);

    rep.type = X_Reply;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;
    rep.state = pVMWARE->xinerama;
    if(client->swapped) {
	register int n;
	_swaps(&rep.sequenceNumber, n);
	_swapl(&rep.length, n);
	_swapl(&rep.state, n);
    }
    WriteToClient(client, sizeof(xXineramaIsActiveReply), (char *) &rep);
    return client->noClientException;
}
Ejemplo n.º 8
0
void
VMwareXinerama_ExtInit(ScrnInfoPtr pScrn)
{
   ExtensionEntry *myext;
   VMWAREPtr pVMWARE = VMWAREPTR(pScrn);

#ifdef PANORAMIX
   if(!noPanoramiXExtension) {
      xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                 "Built-in Xinerama active, not initializing VMware Xinerama\n");
      pVMWARE->xinerama = FALSE;
      return;
   }
#endif

   if (!(myext = CheckExtension(PANORAMIX_PROTOCOL_NAME))) {
      if (!(myext = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
                                 VMwareXineramaDispatch,
                                 SVMwareXineramaDispatch,
                                 VMwareXineramaResetProc,
                                 StandardMinorOpcode))) {
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                    "Failed to add VMware Xinerama extension.\n");
         return;
      }

      pVMWARE->xinerama = TRUE;

      myext->extPrivate = pScrn;

      xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                 "Initialized VMware Xinerama extension.\n");
   }
}
Ejemplo n.º 9
0
void ShowHelp(const wchar_t *fullfilename,const wchar_t *topic, bool CmdLine)
{
	if (CmdLine || CheckExtension(fullfilename))
	{
		const wchar_t *Topic=topic;

		if (NULL == Topic)
			Topic=GetMsg(MDefaultTopic);

		Info.ShowHelp(fullfilename,Topic,FHELP_CUSTOMFILE);
	}
}
Ejemplo n.º 10
0
/* wrapper for CheckOpenglVersion and CheckExtension, also used by macros
 */
GLboolean CheckVersionExtension(const char *name)
{
	if (name && name[0] && name[0]>='0' && name[0]<='9') { /* GL version query */
		int major,minor;

		if (sscanf( name, "%d.%d", &major, &minor ) != 2)
				return GL_FALSE;
	
		return (CheckOpenglVersion(major,minor));
	} else {
		return (CheckExtension(name));
	}
}
Ejemplo n.º 11
0
static int
VMwareXineramaQueryScreens(ClientPtr client)
{
    xXineramaQueryScreensReply	rep;
    ExtensionEntry *ext;
    ScrnInfoPtr pScrn;
    VMWAREPtr pVMWARE;

    REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);

    if (!(ext = CheckExtension(PANORAMIX_PROTOCOL_NAME))) {
       return BadMatch;
    }
    pScrn = ext->extPrivate;
    pVMWARE = VMWAREPTR(pScrn);

    rep.type = X_Reply;
    rep.sequenceNumber = client->sequence;
    rep.number = pVMWARE->xinerama ? pVMWARE->xineramaNumOutputs : 0;
    rep.length = rep.number * sz_XineramaScreenInfo >> 2;
    if(client->swapped) {
       register int n;
       _swaps(&rep.sequenceNumber, n);
       _swapl(&rep.length, n);
       _swapl(&rep.number, n);
    }
    WriteToClient(client, sizeof(xXineramaQueryScreensReply), (char *)&rep);

    if(pVMWARE->xinerama) {
       xXineramaScreenInfo scratch;
       int i;

       for(i = 0; i < pVMWARE->xineramaNumOutputs; i++) {
	  scratch.x_org  = pVMWARE->xineramaState[i].x_org;
	  scratch.y_org  = pVMWARE->xineramaState[i].y_org;
	  scratch.width  = pVMWARE->xineramaState[i].width;
	  scratch.height = pVMWARE->xineramaState[i].height;
	  if(client->swapped) {
	     register int n;
	     _swaps(&scratch.x_org, n);
	     _swaps(&scratch.y_org, n);
	     _swaps(&scratch.width, n);
	     _swaps(&scratch.height, n);
	  }
	  WriteToClient(client, sz_XineramaScreenInfo, (char *)&scratch);
       }
    }

    return client->noClientException;
}
Ejemplo n.º 12
0
// Open an Archive.
CArchive* CArchive::Open( const VFS_String& strAbsoluteFileName )
{
	// Try to open the Archive.
	CArchive* pArchive = new CArchive( CheckExtension( strAbsoluteFileName ) );

	// Invalid Archive?
	if( !pArchive->IsValid() )
	{
		delete pArchive;
		return NULL;
	}

	return pArchive;
}
Ejemplo n.º 13
0
bool ShowHelp(const wchar_t *fullfilename,const wchar_t *topic, bool CmdLine, bool ShowError)
{
	if (fullfilename && (CmdLine || CheckExtension(fullfilename)))
	{
		const wchar_t *Topic=topic;

		if (NULL == Topic)
			Topic=GetMsg(MDefaultTopic);

		return Info.ShowHelp(fullfilename,Topic,FHELP_CUSTOMFILE|(ShowError?0:FHELP_NOSHOWERROR))?true:false;
	}

	return false;
}
Ejemplo n.º 14
0
void	WiredCodec::FeelExtension(list<t_LibInfo> Info)
{
  list<t_LibInfo>::const_iterator	iterLibInfo;
  
  for (iterLibInfo = Info.begin(); iterLibInfo != Info.end(); iterLibInfo++)
    {
      if ((*iterLibInfo).CodecMask & DECODE)
	if (!_DecodeExtList.empty())
	  {
	    if (CheckExtension((*iterLibInfo).Extension, _DecodeExtList))
	      _DecodeExtList.push_back((*iterLibInfo).Extension);
	  }
	else
	  _DecodeExtList.push_back((*iterLibInfo).Extension);
      if ((*iterLibInfo).CodecMask & ENCODE)
	if (!_EncodeExtList.empty())
	  {
	    if (CheckExtension((*iterLibInfo).Extension, _EncodeExtList))
	      _EncodeExtList.push_back((*iterLibInfo).Extension);
	  }
	else
	  _EncodeExtList.push_back((*iterLibInfo).Extension);
    }
}
Ejemplo n.º 15
0
// это HLF-файл?
// первая строка hlf всегда начинается с ".Language="
BOOL IsHlf(void)
{
	BOOL ret=FALSE;
	struct EditorInfo ei={sizeof(EditorInfo)};
	Info.EditorControl(-1,ECTL_GETINFO,0,&ei);
	bool CheckedHlf=true;

	if (Opt.CheckMaskFile)
	{
		wchar_t *FileName=GetEditorFileName();
		if (FileName)
		{
			if (!CheckExtension(FileName))
				CheckedHlf=false;
			delete[] FileName;
		}
	}

	if (CheckedHlf)
	{
		memset(&esp,-1,sizeof(esp));
		egs.StringNumber=-1;
		intptr_t total=(ei.TotalLines<3)?ei.TotalLines:3;

		if (total>2)
		{
			for (esp.CurLine=0; esp.CurLine<total; esp.CurLine++)
			{
				Info.EditorControl(-1,ECTL_SETPOSITION,0,&esp);
				Info.EditorControl(-1,ECTL_GETSTRING,0,&egs);

				if (!FSF.LStrnicmp(L".Language=",egs.StringText,10))
				{
					// доп.проверка
					if (FindTopic(true,false))
						ret=TRUE;
					break;
				}
			}

			RestorePosition(&ei);
		}
	}

	return ret;
}
Ejemplo n.º 16
0
static int
VMwareXineramaGetScreenSize(ClientPtr client)
{
    REQUEST(xPanoramiXGetScreenSizeReq);
    WindowPtr				pWin;
    xPanoramiXGetScreenSizeReply	rep;
    register int			n;
    ExtensionEntry *ext;
    ScrnInfoPtr pScrn;
    VMWAREPtr pVMWARE;
    int rc;


    REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
    rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
    if (rc != Success)
	return rc;

    if (!(ext = CheckExtension(PANORAMIX_PROTOCOL_NAME))) {
       return BadMatch;
    }
    pScrn = ext->extPrivate;
    pVMWARE = VMWAREPTR(pScrn);

    rep.type = X_Reply;
    rep.length = 0;
    rep.sequenceNumber = client->sequence;
    rep.width  = pVMWARE->xineramaState[stuff->screen].width;
    rep.height  = pVMWARE->xineramaState[stuff->screen].height;
    rep.window = stuff->window;
    rep.screen = stuff->screen;
    if(client->swapped) {
       _swaps(&rep.sequenceNumber, n);
       _swapl(&rep.length, n);
       _swapl(&rep.width, n);
       _swapl(&rep.height, n);
       _swapl(&rep.window, n);
       _swapl(&rep.screen, n);
    }
    WriteToClient(client, sizeof(xPanoramiXGetScreenSizeReply), (char *)&rep);
    return client->noClientException;
}
Ejemplo n.º 17
0
intptr_t WINAPI ProcessEditorInputW(const ProcessEditorInputInfo *InputInfo)
{
	LPWSTR FileName=NULL;
	BOOL Result=FALSE;

	if (Opt.ProcessEditorInput)
	{
		if (InputInfo->Rec.EventType==KEY_EVENT && InputInfo->Rec.Event.KeyEvent.bKeyDown && inputrecord_compare(InputInfo->Rec,Opt.RecKey))
		{
			Info.EditorControl(-1,ECTL_GETINFO,0,&ei);
			size_t FileNameSize=Info.EditorControl(-1,ECTL_GETFILENAME,0,0);

			if (FileNameSize)
			{
				FileName=new wchar_t[FileNameSize];

				if (FileName)
				{
					Info.EditorControl(-1,ECTL_GETFILENAME,FileNameSize,FileName);
				}
			}

			if (CheckExtension(FileName))
			{
				ShowCurrentHelpTopic();
				Result=TRUE;
			}
		}
	}

	if (FileName)
	{
		delete[] FileName;
	}

	return Result;
}
Ejemplo n.º 18
0
intptr_t WINAPI ProcessEditorInputW(const ProcessEditorInputInfo *InputInfo)
{
	BOOL Result=FALSE;

	if (Opt.ProcessEditorInput)
	{
		if (InputInfo->Rec.EventType==KEY_EVENT && InputInfo->Rec.Event.KeyEvent.bKeyDown && inputrecord_compare(InputInfo->Rec,Opt.RecKey))
		{
			Info.EditorControl(-1,ECTL_GETINFO,0,&ei);
			wchar_t *FileName=GetEditorFileName();

			if (IsHlf() || (Opt.CheckMaskFile && CheckExtension(FileName)))
			{
				if (ShowCurrentHelpTopic())
					Result=TRUE;
			}

			if (FileName)
				delete[] FileName;
		}
	}

	return Result;
}
Ejemplo n.º 19
0
/*************************************************************************
 InitializeExtensions()

 Sets up all of the extensions needed. Returns false if a required
 extension isn't supported.
*************************************************************************/
bool InitializeExtensions()
{
  if (CheckExtension("GL_ARB_multitexture"))
  {
    pglMultiTexCoord2f = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2f");
	  pglActiveTexture = (PFNGLCLIENTACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTexture");
    pglClientActiveTexture = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glClientActiveTexture");
  }
  else
  {
    MessageBox(g_hwnd, "This program requires multitexturing, which is not supported by your hardware", "ERROR", MB_OK);
    return false;
  }

  if (CheckExtension("GL_EXT_point_parameters"))
  {
    pglPointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXTPROC) wglGetProcAddress("glPointParameterfvEXT");
  }

  if (CheckExtension("WGL_EXT_swap_control"))
  {
    pwglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT");
  }

  if (!CheckExtension("GL_EXT_bgra"))
  {
    MessageBox(g_hwnd, "This program requires the BGRA pixel storage format, which is not supported by your hardware", "ERROR", MB_OK);
    return false;
  }

  g_useTextureCompression = CheckExtension("GL_ARB_texture_compression");
  g_useEdgeClamp = CheckExtension("GL_EXT_texture_edge_clamp");
  g_useSGISMipmapGeneration = CheckExtension("GL_SGIS_generate_mipmap");

  return true;
} // end InitializeExtensions()
Ejemplo n.º 20
0
// Check the File Existence.
VFS_BOOL CArchive::Exists( const VFS_String& strAbsoluteFileName )
{
	return VFS_EXISTS( CheckExtension( strAbsoluteFileName ) );
}
Ejemplo n.º 21
0
bool ccFBOUtils::CheckVAAvailability()
{
	return CheckExtension("GL_ARB_vertex_array_object");
}
Ejemplo n.º 22
0
glbsp_ret_e GlbspCheckInfo(nodebuildinfo_t *info,
    volatile nodebuildcomms_t *comms)
{
  cur_comms = comms;
  SetErrorMsg("(Unknown Problem)");

  info->same_filenames = FALSE;
  info->missing_output = FALSE;

  if (!info->input_file || info->input_file[0] == 0)
  {
    SetErrorMsg("Missing input filename !");
    return GLBSP_E_BadArgs;
  }

  if (CheckExtension(info->input_file, "gwa"))
  {
    SetErrorMsg("Input file cannot be GWA (contains nothing to build)");
    return GLBSP_E_BadArgs;
  }

  if (!info->output_file || info->output_file[0] == 0)
  {
    GlbspFree(info->output_file);
    info->output_file = GlbspStrDup(ReplaceExtension(
          info->input_file, "gwa"));

    info->gwa_mode = TRUE;
    info->missing_output = TRUE;
  }
  else  /* has output filename */
  {
    if (CheckExtension(info->output_file, "gwa"))
      info->gwa_mode = TRUE;
  }

  if (UtilStrCaseCmp(info->input_file, info->output_file) == 0)
  {
    info->load_all = TRUE;
    info->same_filenames = TRUE;
  }

  if (info->no_prune && info->pack_sides)
  {
    info->pack_sides = FALSE;
    SetErrorMsg("-noprune and -packsides cannot be used together");
    return GLBSP_E_BadInfoFixed;
  }

  if (info->gwa_mode && info->force_normal)
  {
    info->force_normal = FALSE;
    SetErrorMsg("-forcenormal used, but GWA files don't have normal nodes");
    return GLBSP_E_BadInfoFixed;
  }
 
  if (info->no_normal && info->force_normal)
  {
    info->force_normal = FALSE;
    SetErrorMsg("-forcenormal and -nonormal cannot be used together");
    return GLBSP_E_BadInfoFixed;
  }
 
  if (info->factor <= 0 || info->factor > 32)
  {
    info->factor = DEFAULT_FACTOR;
    SetErrorMsg("Bad factor value !");
    return GLBSP_E_BadInfoFixed;
  }

  if (info->spec_version <= 0 || info->spec_version > 5)
  {
    info->spec_version = 2;
    SetErrorMsg("Bad GL-Nodes version number !");
    return GLBSP_E_BadInfoFixed;
  }
  else if (info->spec_version == 4)
  {
    info->spec_version = 5;
    SetErrorMsg("V4 GL-Nodes is not supported");
    return GLBSP_E_BadInfoFixed;
  }

  if (info->block_limit < 1000 || info->block_limit > 64000)
  {
    info->block_limit = DEFAULT_BLOCK_LIMIT;
    SetErrorMsg("Bad blocklimit value !");
    return GLBSP_E_BadInfoFixed;
  }

  return GLBSP_E_OK;
}
Ejemplo n.º 23
0
glbsp_ret_e GlbspParseArgs(nodebuildinfo_t *info, 
    volatile nodebuildcomms_t *comms,
    const char ** argv, int argc)
{
  const char *opt_str;
  int num_files = 0;
  int got_output = FALSE;

  cur_comms = comms;
  SetErrorMsg("(Unknown Problem)");

  while (argc > 0)
  {
    if (argv[0][0] != '-')
    {
      // --- ORDINARY FILENAME ---

      if (got_output)
      {
        SetErrorMsg("Input filenames must precede the -o option");
        cur_comms = NULL;
        return GLBSP_E_BadArgs;
      }

      if (CheckExtension(argv[0], "gwa"))
      {
        SetErrorMsg("Input file cannot be GWA (contains nothing to build)");
        cur_comms = NULL;
        return GLBSP_E_BadArgs;
      }

      if (num_files >= 1)
      {
        AddExtraFile(info, GlbspStrDup(argv[0]));
      }
      else
      {
        GlbspFree(info->input_file);
        info->input_file = GlbspStrDup(argv[0]);
      }

      num_files++;

      argv++; argc--;
      continue;
    }

    // --- AN OPTION ---

    opt_str = &argv[0][1];

    // handle GNU style options beginning with '--'
    if (opt_str[0] == '-')
      opt_str++;

    if (UtilStrCaseCmp(opt_str, "o") == 0)
    {
      if (got_output)
      {
        SetErrorMsg("The -o option cannot be used more than once");
        cur_comms = NULL;
        return GLBSP_E_BadArgs;
      }

      if (num_files >= 2)
      {
        SetErrorMsg("Cannot use -o with multiple input files.");
        cur_comms = NULL;
        return GLBSP_E_BadArgs;
      }

      if (argc < 2 || argv[1][0] == '-')
      {
        SetErrorMsg("Missing filename for the -o option");
        cur_comms = NULL;
        return GLBSP_E_BadArgs;
      }

      GlbspFree(info->output_file);
      info->output_file = GlbspStrDup(argv[1]);

      got_output = TRUE;

      argv += 2; argc -= 2;
      continue;
    }

    if (UtilStrCaseCmp(opt_str, "factor") == 0 ||
        UtilStrCaseCmp(opt_str, "c") == 0)
    {
      if (argc < 2)
      {
        SetErrorMsg("Missing factor value");
        cur_comms = NULL;
        return GLBSP_E_BadArgs;
      }

      info->factor = (int) strtol(argv[1], NULL, 10);

      argv += 2; argc -= 2;
      continue;
    }

    if (tolower(opt_str[0]) == 'v' && isdigit(opt_str[1]))
    {
      info->spec_version = (opt_str[1] - '0');

      argv++; argc--;
      continue;
    }

    if (UtilStrCaseCmp(opt_str, "maxblock") == 0 ||
        UtilStrCaseCmp(opt_str, "b") == 0)
    {
      if (argc < 2)
      {
        SetErrorMsg("Missing maxblock value");
        cur_comms = NULL;
        return GLBSP_E_BadArgs;
      }

      info->block_limit = (int) strtol(argv[1], NULL, 10);

      argv += 2; argc -= 2;
      continue;
    }

    HANDLE_BOOLEAN2("q",  "quiet",      quiet)
    HANDLE_BOOLEAN2("f",  "fast",       fast)
    HANDLE_BOOLEAN2("w",  "warn",       mini_warnings)
    HANDLE_BOOLEAN2("p",  "pack",       pack_sides)
    HANDLE_BOOLEAN2("n",  "normal",     force_normal)
    HANDLE_BOOLEAN2("xr", "noreject",   no_reject)
    HANDLE_BOOLEAN2("xp", "noprog",     no_progress)

    HANDLE_BOOLEAN2("m",  "mergevert",   merge_vert)
    HANDLE_BOOLEAN2("u",  "prunesec",    prune_sect)
    HANDLE_BOOLEAN2("y",  "windowfx",    window_fx)
    HANDLE_BOOLEAN2("s",  "skipselfref", skip_self_ref)
    HANDLE_BOOLEAN2("xu", "noprune",     no_prune)
    HANDLE_BOOLEAN2("xn", "nonormal",    no_normal)

    // to err is human...
    HANDLE_BOOLEAN("noprogress",  no_progress)
    HANDLE_BOOLEAN("packsides",   pack_sides)
    HANDLE_BOOLEAN("prunesect",   prune_sect)

    // ignore these options for backwards compatibility
    if (UtilStrCaseCmp(opt_str, "fresh") == 0 ||
        UtilStrCaseCmp(opt_str, "keepdummy") == 0 ||
        UtilStrCaseCmp(opt_str, "keepsec") == 0 ||
        UtilStrCaseCmp(opt_str, "keepsect") == 0)
    {
      argv++; argc--;
      continue;
    }

    // backwards compatibility
    HANDLE_BOOLEAN("forcegwa",    gwa_mode)
    HANDLE_BOOLEAN("forcenormal", force_normal)
    HANDLE_BOOLEAN("loadall",     load_all)

    // The -hexen option is only kept for backwards compatibility
    HANDLE_BOOLEAN("hexen", force_hexen)

    SetErrorMsg("Unknown option: %s", argv[0]);

    cur_comms = NULL;
    return GLBSP_E_BadArgs;
  }

  cur_comms = NULL;
  return GLBSP_E_OK;
}
Ejemplo n.º 24
0
static void CheckParms( void )
/****************************/
{
    char        *defext;

    CheckExtension( CmdLineParms.InFileName, "rc" );
    CheckPass2Only();

    /* was an EXE file name given */
    if( CmdLineParms.InExeFileName[0] == '\0' ) {
        if (CmdLineParms.NoResFile) {
            strncpy( CmdLineParms.InExeFileName, CmdLineParms.InFileName, _MAX_PATH );
        } else {
            MakeFileName( CmdLineParms.InFileName,
                             CmdLineParms.InExeFileName, "exe" );
        }
    } else {
        CheckExtension( CmdLineParms.InExeFileName, "exe" );
    }

    /* was an output RES file name given */
    if( CmdLineParms.PreprocessOnly ) {
        defext = "lst";
    } else {
        defext = "res";
    }
    if( CmdLineParms.OutResFileName[0] == '\0' ) {
        MakeFileName( CmdLineParms.InFileName,
                      CmdLineParms.OutResFileName, defext );
    } else {
        CheckExtension( CmdLineParms.OutResFileName, defext );
    }

    /* was an output EXE file name given */
    if( CmdLineParms.OutExeFileName[0] == '\0' ) {
        strncpy( CmdLineParms.OutExeFileName, CmdLineParms.InExeFileName, _MAX_PATH );
    } else {
        CheckExtension( CmdLineParms.OutExeFileName, "exe" );
    }

    /* check for the existance of the input files */
    if (! (CmdLineParms.Pass2Only && CmdLineParms.NoResFile) ) {
        if( access( CmdLineParms.InFileName, F_OK ) != 0 ) {
            RcFatalError( ERR_CANT_FIND_FILE, CmdLineParms.InFileName );
        }
    }
    if( !CmdLineParms.Pass1Only && !CmdLineParms.PreprocessOnly ) {
        if( access( CmdLineParms.InExeFileName, F_OK ) != 0 ) {
            RcFatalError( ERR_CANT_FIND_FILE, CmdLineParms.InExeFileName );
        }
    }

    if( CmdLineParms.GenAutoDep && CmdLineParms.MSResFormat ) {
        RcFatalError( ERR_OPT_NOT_VALID_TOGETHER, "-ad", "-zm" );
    }
    if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
        switch( CmdLineParms.MBCharSupport ) {
        case DB_SIMPLIFIED_CHINESE:
            strcpy( CmdLineParms.CodePageFile, "936.uni" );
            break;
        case DB_TRADITIONAL_CHINESE:
            strcpy( CmdLineParms.CodePageFile, "950.uni" );
            break;
        case DB_KANJI:
            strcpy( CmdLineParms.CodePageFile, "kanji.uni" );
            break;
        case DB_WANSUNG_KOREAN:
            strcpy( CmdLineParms.CodePageFile, "949.uni" );
            break;
        }
    }
    if( CmdLineParms.PreprocessOnly && CmdLineParms.NoPreprocess ) {
        RcFatalError( ERR_OPT_NOT_VALID_TOGETHER, "-o", "-zn" );
    }

} /* CheckParms */
Ejemplo n.º 25
0
void gl_LoadExtensions()
{
	InitContext();
	CollectExtensions();

	const char *version = Args->CheckValue("-glversion");
	const char *glversion = (const char*)glGetString(GL_VERSION);

	if (version == NULL)
	{
		version = glversion;
	}
	else
	{
		double v1 = strtod(version, NULL);
		double v2 = strtod(glversion, NULL);
		if (v2 < v1) version = glversion;
		else Printf("Emulating OpenGL v %s\n", version);
	}

	float gl_version = (float)strtod(version, NULL) + 0.01f;

	// Don't even start if it's lower than 2.0 or no framebuffers are available (The framebuffer extension is needed for glGenerateMipmapsEXT!)
	if ((gl_version < 2.0f || !CheckExtension("GL_EXT_framebuffer_object")) && gl_version < 3.0f)
	{
		I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 2.0 with framebuffer support is required to run " GAMENAME ".\n");
	}

	// add 0.01 to account for roundoff errors making the number a tad smaller than the actual version
	gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL) + 0.01f;

	gl.vendorstring = (char*)glGetString(GL_VENDOR);

	// first test for optional features
	if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION;
	if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags |= RFL_TEXTURE_COMPRESSION_S3TC;

	if ((gl_version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) && !Args->CheckParm("-nosampler"))
	{
		gl.flags |= RFL_SAMPLER_OBJECTS;
	}
	
	// The minimum requirement for the modern render path are GL 3.0 + uniform buffers. Also exclude the Linux Mesa driver at GL 3.0 because it errors out on shader compilation.
	if (gl_version < 3.0f || (gl_version < 3.1f && (!CheckExtension("GL_ARB_uniform_buffer_object") || strstr(gl.vendorstring, "X.Org") != nullptr)))
	{
		gl.legacyMode = true;
		gl.lightmethod = LM_LEGACY;
		gl.buffermethod = BM_LEGACY;
		gl.glslversion = 0;
		gl.flags |= RFL_NO_CLIP_PLANES;
	}
	else
	{
		gl.legacyMode = false;
		gl.lightmethod = LM_DEFERRED;
		gl.buffermethod = BM_DEFERRED;
		if (gl_version < 4.f)
		{
#ifdef _WIN32
			if (strstr(gl.vendorstring, "ATI Tech"))
			{
				gl.flags |= RFL_NO_CLIP_PLANES;	// gl_ClipDistance is horribly broken on ATI GL3 drivers for Windows.
			}
#endif
		}
		else if (gl_version < 4.5f)
		{
			// don't use GL 4.x features when running a GL 3.x context.
			if (CheckExtension("GL_ARB_buffer_storage"))
			{
				// work around a problem with older AMD drivers: Their implementation of shader storage buffer objects is piss-poor and does not match uniform buffers even closely.
				// Recent drivers, GL 4.4 don't have this problem, these can easily be recognized by also supporting the GL_ARB_buffer_storage extension.
				if (CheckExtension("GL_ARB_shader_storage_buffer_object"))
				{
					// Shader storage buffer objects are broken on current Intel drivers.
					if (strstr(gl.vendorstring, "Intel") == NULL)
					{
						gl.flags |= RFL_SHADER_STORAGE_BUFFER;
					}
				}
				gl.flags |= RFL_BUFFER_STORAGE;
				gl.lightmethod = LM_DIRECT;
				gl.buffermethod = BM_PERSISTENT;
			}
		}
		else
		{
			// Assume that everything works without problems on GL 4.5 drivers where these things are core features.
			gl.flags |= RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE;
			gl.lightmethod =	LM_DIRECT;
			gl.buffermethod = BM_PERSISTENT;
		}

		if (gl_version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER;
		if (gl_version >= 4.3f || CheckExtension("GL_KHR_debug")) gl.flags |= RFL_DEBUG;

		const char *lm = Args->CheckValue("-lightmethod");
		if (lm != NULL)
		{
			if (!stricmp(lm, "deferred") && gl.lightmethod == LM_DIRECT) gl.lightmethod = LM_DEFERRED;
		}

		lm = Args->CheckValue("-buffermethod");
		if (lm != NULL)
		{
			if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED;
		}
	}

	int v;
	
	if (!gl.legacyMode && !(gl.flags & RFL_SHADER_STORAGE_BUFFER))
	{
		glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v);
		gl.maxuniforms = v;
		glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v);
		gl.maxuniformblock = v;
		glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v);
		gl.uniformblockalignment = v;
	}
	else
	{
		gl.maxuniforms = 0;
		gl.maxuniformblock = 0;
		gl.uniformblockalignment = 0;
	}
	

	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl.max_texturesize);
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

	if (gl.legacyMode)
	{
		// fudge a bit with the framebuffer stuff to avoid redundancies in the main code. Some of the older cards do not have the ARB stuff but the calls are nearly identical.
		FUDGE_FUNC(glGenerateMipmap, EXT);
		FUDGE_FUNC(glGenFramebuffers, EXT);
		FUDGE_FUNC(glBindFramebuffer, EXT);
		FUDGE_FUNC(glDeleteFramebuffers, EXT);
		FUDGE_FUNC(glFramebufferTexture2D, EXT);
		FUDGE_FUNC(glGenerateMipmap, EXT);
		FUDGE_FUNC(glGenFramebuffers, EXT);
		FUDGE_FUNC(glBindFramebuffer, EXT);
		FUDGE_FUNC(glDeleteFramebuffers, EXT);
		FUDGE_FUNC(glFramebufferTexture2D, EXT);
		FUDGE_FUNC(glFramebufferRenderbuffer, EXT);
		FUDGE_FUNC(glGenRenderbuffers, EXT);
		FUDGE_FUNC(glDeleteRenderbuffers, EXT);
		FUDGE_FUNC(glRenderbufferStorage, EXT);
		FUDGE_FUNC(glBindRenderbuffer, EXT);
		FUDGE_FUNC(glCheckFramebufferStatus, EXT);
		gl_PatchMenu();
	}
}
Ejemplo n.º 26
0
//--------------------------------------------------------------
// Name:			CGL_APP::Init - public
// Description:		Initiate an OpenGL application
// Arguments:		-iX, iY: the upperleft position of the window
//					-iWidth, iHeight: the dimensions of the window
//					-iBPP: the pixel depth of the window (usually 16 or 32)
//					-szTitle: the title to appear in the window's titlebar
//					-icon: a resource ID for a program application icon (defaults to NULL)
//					-menu: a resource ID for a menu (defaults to NULL)
// Return Value:	A boolean variable: -true: successful window initiation
//										-false: unsuccessful window initiation
//--------------------------------------------------------------
bool CGL_APP::Init( int iX, int iY, int iWidth, int iHeight, int iBPP, 
					const char* szTitle, WORD icon, WORD menu )
{
	WNDCLASS winclass;				//The windows class structure
	unsigned int uiPixelFormat;		//Hold the correct match for the pixel format

	//initiate the program log
	g_log.Init( "program log.html" );

	if( m_timer.Init( ) )
		g_log.Write( LOG_PLAINTEXT, "Performance timer has been initialized" );
	else
		g_log.Write( LOG_PLAINTEXT, "Multimedia timer has been initialized" );

	//record the dimensions in the class's members
	m_iWidth = iWidth;
	m_iHeight= iHeight;
	m_iBPP   = iBPP;

	//customize the window's parameters
	m_hInstance			  = GetModuleHandle( NULL );				//get the window's instance
	winclass.style		  = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;		//redraw the window on resize
	winclass.lpfnWndProc  = WindowProc;								//handle the WINPROC messages
	winclass.cbClsExtra	  = 0;										//no extra win data
	winclass.cbWndExtra	  = 0;										//no extra win data
	winclass.hInstance	  = m_hInstance;							//get the window's instance
	winclass.hIcon		  = LoadIcon( NULL, MAKEINTRESOURCE( icon ) );//load an icon
	winclass.hCursor	  = LoadCursor( NULL, IDC_ARROW );			//load the mouse pointer
	winclass.lpszMenuName = MAKEINTRESOURCE( menu );				//load the menu
	winclass.hbrBackground= ( HBRUSH )GetStockObject( BLACK_BRUSH );//no background required for OpenGL stuff
	winclass.lpszClassName= APP_CLASSNAME;							//set the class name

	//register the window class
	if( !RegisterClass(&winclass ) )
	{
		g_log.Write( LOG_FAILURE, "WINDOW FAILURE: could not register class" );
		return false;		
	}
	//ruh-roh, something screwed up
	else
		g_log.Write( LOG_SUCCESS, "WINDOW SUCCESS: class registered" );

	//create the window
	if( !( m_hWnd=CreateWindowEx( WS_EX_CLIENTEDGE,			//the extended style for the window
							      APP_CLASSNAME,			//the class name
							      szTitle,					//the window's title
							      WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_VISIBLE,
							      iX, iY,					//the window's position
							      m_iWidth,					//calculate the window's width
							      m_iHeight,				//calculate the window's height
							      NULL,						//no parent window
							      NULL,						//no menu needed
							      m_hInstance,				//the window's instance
							      NULL ) ) )				//nothing to pass to WM_CREATE
	{
		//the window could not be created
		Shutdown( );				
		g_log.Write( LOG_FAILURE, "WINDOW ERROR: window could not be created" );
		return false;			
	}

	//get the pixel format's description
	static PIXELFORMATDESCRIPTOR pfd=
	{
		sizeof( PIXELFORMATDESCRIPTOR ),	//Get the size of the structure
		1,									//Version number
		PFD_DRAW_TO_WINDOW |				//Format must support Windows
		PFD_SUPPORT_OPENGL |				//Format must support OpenGL
		PFD_DOUBLEBUFFER,					//Must support Double Buffering
		PFD_TYPE_RGBA,						//Request a RGBA (red,green,blue,alpha) format
		m_iBPP,								//Select the bits per pixel
		0, 0, 0, 0, 0, 0,					//Color bits ignored
		0,									//No alpha buffer
		0,									//shift bit ignored
		0,									//No accumulation buffer (advanced)
		0, 0, 0, 0,							//Accumulation bits ignored
		32,									//16 bit Z-Buffer (Depth Buffer)  
		0,									//No Stencil Buffer (advanced)
		0,									//No Auxiliary Buffer (advanced)
		PFD_MAIN_PLANE,						//The main drawing layer
		0,									//Reserved area
		0, 0, 0								//Layer masks ignored
	};
	
	//get a handle to the device context
	if( !( m_hDC= GetDC( m_hWnd ) ) )
	{
		//no device context for us
		Shutdown( );
		MessageBox( m_hWnd, "Could not create a OpenGL device context", "RENDERER ERROR", MB_OK | MB_ICONSTOP );
		return false;								
	}

	//find a compatible pixel format
	if(!(uiPixelFormat= ChoosePixelFormat(m_hDC, &pfd)))
	{
		//no suitable pixel format
		Shutdown( );
		MessageBox( m_hWnd, "Could not find a suitable pixel format", "RENDERER ERROR", MB_OK | MB_ICONSTOP );
		return false;
	}

	//set the previously found pixel format
	if( !SetPixelFormat( m_hDC, uiPixelFormat, &pfd ) )
	{
		//could not set the pixel format
		Shutdown( );
		MessageBox( m_hWnd, "Could not set pixel format", "RENDERER ERROR", MB_OK | MB_ICONSTOP );
		return false;
	}
	
	//get a handle to the application's rendering context
	if( !( m_hRC= wglCreateContext( m_hDC ) ) )
	{
		//could not get OpenGL support
		Shutdown( );
		MessageBox( m_hWnd, "Could not create the OpenGL rendering context", "RENDERER ERROR", MB_OK | MB_ICONSTOP );
		return false;		
	}

	//set the device and rendering context to our window (activating OpenGL)
	if( !wglMakeCurrent( m_hDC, m_hRC ) )
	{
		//could not activate OpenGL
		Shutdown( );
		MessageBox( m_hWnd, "Could not activate the OpenGL rendering context", "RENDERER ERROR", MB_OK | MB_ICONSTOP );
		return false;
	}

	glShadeModel( GL_SMOOTH );							//Enable smooth shading (so you can't see the individual polygons of a primitive, best shown when drawing a sphere)
	glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
	glClearDepth( 1.0 );									//Depth buffer setup
	glDepthFunc( GL_LEQUAL );								//The type of depth testing to do (LEQUAL==less than or equal to)
	glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );	//The nicest perspective look

	ShowWindow( m_hWnd, SW_SHOW );						//Show the window
	SetForegroundWindow( m_hWnd );						//Give the window a high priority
	SetFocus( m_hWnd );									//Sets the keyboard's focus to the window

	//setup the program's perspective view
	ResizeScene( m_iWidth, m_iHeight );

	m_szSupportedGLExtensions= ( char* )glGetString( GL_EXTENSIONS );

	if( CheckExtension( "GL_ARB_multitexture" ) )
	{
		glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &m_iNumTextureUnits);
		if(m_iNumTextureUnits > 1)
			m_bCanMultitexture= true;
		else
			m_bCanMultitexture= false;
	}
	else
		m_bCanMultitexture= false;

	glActiveTextureARB		= ( PFNGLACTIVETEXTUREARBPROC )	     wglGetProcAddress( "glActiveTextureARB" );
	glClientActiveTextureARB= ( PFNGLCLIENTACTIVETEXTUREARBPROC )wglGetProcAddress( "glClientActiveTextureARB" );
	glMultiTexCoord2fARB	= ( PFNGLMULTITEXCOORD2FARBPROC )	 wglGetProcAddress( "glMultiTexCoord2fARB" );
	glMultiTexCoord2dARB	= ( PFNGLMULTITEXCOORD2DARBPROC )	 wglGetProcAddress( "glMultiTexCoord2dARB" );

	g_log.Write( LOG_RENDERER, "Multitexturing has been initiated, and your video card supports %d texture units", m_iNumTextureUnits );

	if( CheckExtension( "GL_EXT_compiled_vertex_array" ) )
		m_bCanCVA= true;
	else
		m_bCanCVA= false;

	CheckExtension( "GL_CLAMP_TO_EDGE" );

	//configure the volumetric fog system
	if( CheckExtension( "GL_EXT_fog_coord" ) )
		glFogCoordfEXT= ( PFNGLFOGCOORDFEXTPROC )wglGetProcAddress( "glFogCoordfEXT" );

	glLockArraysEXT  = ( PFNGLLOCKARRAYSEXTPROC )  wglGetProcAddress( "glLockArraysEXT" );
	glUnlockArraysEXT= ( PFNGLUNLOCKARRAYSEXTPROC )wglGetProcAddress( "glUnlockArraysEXT" );

	m_bActive= APP_ACTIVE;
	g_log.Write( LOG_SUCCESS, "WINDOW SUCCESS: A %dx%dx%d window has been created", m_iWidth, m_iHeight, m_iBPP);
	return true;
}
Ejemplo n.º 27
0
bool GetNextImage()
{
	HANDLE			Search;
	WIN32_FIND_DATA	FindData;
	int				i = 0, j, Total = 0, FileNamePos = -1;
	TCHAR			*Ext, *CurName;

	Search = FindFirstFile(L"*.*", &FindData);
	CurName = wcsrchr(CurFileName, '\\');
	if (CurName == NULL) {
		CurName = CurFileName;
	}
	else {
		CurName++;  // Skip the '\'
	}

	do {
		if (!_wcsicmp(FindData.cFileName, L".") || !_wcsicmp(FindData.cFileName, L".."))
			continue;
		Ext = GetExtension(FindData.cFileName);
		if (Ext == NULL)
			continue;
		for (j = 0; ExtList[j] != NULL; j++) {
			if (CheckExtension(FindData.cFileName, ExtList[j])) {
				if (!_wcsicmp(FindData.cFileName, CurName))
					FileNamePos = Total;
				Total++;
				break;
			}
		}
	} while (FindNextFile(Search, &FindData));

	FindClose(Search);
	Search = FindFirstFile(L"*.*", &FindData);

	if (Total == 0 || FileNamePos == -1)
		return false;

	if (FileNamePos == Total-1)
		FileNamePos = -1;

	do {
		if (!_wcsicmp(FindData.cFileName, L".") || !_wcsicmp(FindData.cFileName, L".."))
			continue;
		Ext = GetExtension(FindData.cFileName);
		if (Ext == NULL)
			continue;
		for (j = 0; ExtList[j] != NULL; j++) {
			if (CheckExtension(FindData.cFileName, ExtList[j])) {
				if (FileNamePos == i-1) {
					wcscpy(OpenFileName, FindData.cFileName);
					i++;
					break;
				}
				i++;
				break;
			}
		}
	} while (FindNextFile(Search, &FindData));


	FindClose(Search);
	return true;
}
Ejemplo n.º 28
0
bool ccFBOUtils::CheckFBOAvailability()
{
    return CheckExtension("GL_EXT_framebuffer_object");
}
Ejemplo n.º 29
0
/* Rectangle, left, right(not inclusive), top, bottom(not inclusive). */
OpenGL_Blitter::OpenGL_Blitter(int scanlines, ShaderType pixshader, const int screen_w, const int screen_h, int *rs, int *gs, int *bs, int *as) : gl_screen_w(screen_w), gl_screen_h(screen_h)
{
 try
 {
 const char *extensions;
 const char *vendor;
 const char *renderer;
 const char *version;
 uint32 version_h;

 MaxTextureSize = 0;
 SupportNPOT = false;
 SupportARBSync = false;
 PixelFormat = 0;
 PixelType = 0;

 for(unsigned i = 0; i < 4; i++)
  textures[i] = 0;

 rgb_mask = 0;

 using_scanlines = 0;
 last_w = 0;
 last_h = 0;

 OSDLastWidth = 0;
 OSDLastHeight = 0;

 shader = NULL;

 DummyBlack = NULL;
 DummyBlackSize = 0;


 #define LFG(x) if(!(p_##x = (x##_Func) SDL_GL_GetProcAddress(#x))) { throw MDFN_Error(0, _("Error getting proc address for: %s\n"), #x); }
 #define LFGN(x) p_##x = (x##_Func) SDL_GL_GetProcAddress(#x)

 LFG(glGetError);
 LFG(glBindTexture);
 LFGN(glColorTableEXT);
 LFG(glTexImage2D);
 LFG(glBegin);
 LFG(glVertex2f);
 LFG(glTexCoord2f);
 LFG(glEnd);
 LFG(glEnable);
 LFG(glBlendFunc);
 LFG(glGetString);
 LFG(glViewport);
 LFG(glGenTextures);
 LFG(glDeleteTextures);
 LFG(glTexParameteri);
 LFG(glClearColor);
 LFG(glLoadIdentity);
 LFG(glClear);
 LFG(glMatrixMode);
 LFG(glDisable);
 LFG(glPixelStorei);
 LFG(glTexSubImage2D);
 LFG(glFinish);
 LFG(glOrtho);
 LFG(glPixelTransferf);
 LFG(glColorMask);
 LFG(glTexEnvf);
 LFG(glGetIntegerv);
 LFG(glTexGend);
 LFG(glRasterPos2i);
 LFG(glDrawPixels);
 LFG(glPixelZoom);
 LFG(glAccum);
 LFG(glClearAccum);
 LFG(glGetTexLevelParameteriv);
 LFG(glPushMatrix);
 LFG(glPopMatrix);
 LFG(glRotated);
 LFG(glScalef);
 LFG(glReadPixels);

 vendor = (const char *)p_glGetString(GL_VENDOR);
 renderer = (const char *)p_glGetString(GL_RENDERER);
 version = (const char *)p_glGetString(GL_VERSION);

 {
  int major = 0, minor = 0;
  trio_sscanf(version, "%d.%d", &major, &minor);
  if(minor < 0) minor = 0;
  if(minor > 255) minor = 255;

  version_h = (major << 8) | minor;
  //printf("%08x\n", version_h);
 }

 MDFN_printf(_("OpenGL Implementation: %s %s %s\n"), vendor, renderer, version);

 extensions = (const char*)p_glGetString(GL_EXTENSIONS);

 MDFN_printf(_("Checking extensions:\n"));
 MDFN_indent(1);

 SupportNPOT = FALSE;
 SupportARBSync = false;

 if(CheckExtension(extensions, "GL_ARB_texture_non_power_of_two"))
 {
  MDFN_printf(_("GL_ARB_texture_non_power_of_two found.\n"));
  SupportNPOT = TRUE;
 }

 if(CheckExtension(extensions, "GL_ARB_sync"))
 {
  MDFN_printf(_("GL_ARB_sync found.\n"));
  LFG(glFenceSync);
  LFG(glIsSync);
  LFG(glDeleteSync);
  LFG(glClientWaitSync);
  LFG(glWaitSync);
  LFG(glGetInteger64v);
  LFG(glGetSynciv);
  SupportARBSync = true;
 }

 MDFN_indent(-1);

 // x,y specify LOWER left corner of the viewport.
 p_glViewport(0, 0, gl_screen_w, gl_screen_h);

 p_glGenTextures(4, &textures[0]);
 p_glGenTextures(1, &rgb_mask);
 using_scanlines = 0;

 shader = NULL;

 if(pixshader != SHADER_NONE)
 {
  LFG(glCreateShaderObjectARB);
  LFG(glShaderSourceARB);
  LFG(glCompileShaderARB);
  LFG(glCreateProgramObjectARB);
  LFG(glAttachObjectARB);
  LFG(glLinkProgramARB);
  LFG(glUseProgramObjectARB);
  LFG(glUniform1fARB);
  LFG(glUniform2fARB);
  LFG(glUniform3fARB);
  LFG(glUniform1iARB);
  LFG(glUniform2iARB);
  LFG(glUniform3iARB);
  LFG(glUniformMatrix2fvARB);
  LFG(glActiveTextureARB);
  LFG(glGetInfoLogARB);
  LFG(glGetUniformLocationARB);
  LFG(glDeleteObjectARB);
  LFG(glDetachObjectARB);

  LFG(glGetObjectParameterivARB);

  shader = new OpenGL_Blitter_Shader(this, pixshader);
  SupportNPOT = 0; 	 // Our pixel shaders don't work right with NPOT textures(for them to do so would probably necessitate rewriting them to use texelFetch)
  p_glActiveTextureARB(GL_TEXTURE0_ARB);
 }

 // printf here because pixel shader code will set SupportNPOT to 0

 if(SupportNPOT)
  MDFN_printf(_("Using non-power-of-2 sized textures.\n"));
 else
  MDFN_printf(_("Using power-of-2 sized textures.\n"));

 if(scanlines)
 {
  int slcount;

  using_scanlines = scanlines;

  p_glBindTexture(GL_TEXTURE_2D, textures[1]);
  p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
  p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);

  uint8 *buf=(uint8*)malloc(64 * (256 * 2) * 4);

  slcount = 0;
  for(int y=0;y<(256 * 2);y++)
  {
   for(int x=0;x<64;x++)
   {
    int sl_alpha;

    if(slcount)
     sl_alpha = 0xFF - (0xFF * abs(scanlines) / 100);
    else
     sl_alpha = 0xFF;

    buf[y*64*4+x*4]=0;
    buf[y*64*4+x*4+1]=0;
    buf[y*64*4+x*4+2]=0;
    buf[y*64*4+x*4+3] = sl_alpha;
    //buf[y*256+x]=(y&1)?0x00:0xFF;
   }
   slcount ^= 1;
  }
  p_glPixelStorei(GL_UNPACK_ROW_LENGTH, 64);
  p_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 64, 256 * 2, 0, GL_RGBA,GL_UNSIGNED_BYTE,buf);
  free(buf);
 }
 p_glBindTexture(GL_TEXTURE_2D, textures[3]);
 p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
 p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
 p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
 p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);


 p_glBindTexture(GL_TEXTURE_2D, textures[0]);
     
 p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
 p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
 //p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 0x812F);
 //p_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 0x812F);

 p_glBindTexture(GL_TEXTURE_2D, textures[2]);

 p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP);
 p_glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP);

 p_glEnable(GL_TEXTURE_2D);
 p_glClearColor(0.0f, 0.0f, 0.0f, 0.0f);	// Background color to black.
 p_glMatrixMode(GL_MODELVIEW);

 p_glLoadIdentity();
 p_glFinish();

 p_glDisable(GL_TEXTURE_1D);
 p_glDisable(GL_FOG);
 p_glDisable(GL_LIGHTING);
 p_glDisable(GL_LOGIC_OP);
 p_glDisable(GL_DITHER);
 p_glDisable(GL_COLOR_MATERIAL);
 p_glDisable(GL_NORMALIZE);
 p_glDisable(GL_SCISSOR_TEST);
 p_glDisable(GL_STENCIL_TEST);
 p_glDisable(GL_ALPHA_TEST);
 p_glDisable(GL_DEPTH_TEST);

 p_glPixelTransferf(GL_RED_BIAS, 0);
 p_glPixelTransferf(GL_GREEN_BIAS, 0);
 p_glPixelTransferf(GL_BLUE_BIAS, 0);
 p_glPixelTransferf(GL_ALPHA_BIAS, 0);

 p_glPixelTransferf(GL_RED_SCALE, 1);
 p_glPixelTransferf(GL_GREEN_SCALE, 1);
 p_glPixelTransferf(GL_BLUE_SCALE, 1);
 p_glPixelTransferf(GL_ALPHA_SCALE, 1);

 p_glPixelTransferf(GL_MAP_COLOR, GL_FALSE);

 p_glOrtho(0, gl_screen_w, gl_screen_h, 0, -1.0, 1.0);

 last_w = 0;
 last_h = 0;

 OSDLastWidth = OSDLastHeight = 0;


 MDFN_printf(_("Checking maximum texture size...\n"));
 MDFN_indent(1);
 p_glBindTexture(GL_TEXTURE_2D, textures[0]);
 // Assume maximum texture width is the same as maximum texture height to greatly simplify things
 MaxTextureSize = 32768;
 
 while(MaxTextureSize)
 {
  GLint width_test = 0;

  p_glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA, MaxTextureSize, MaxTextureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
  p_glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width_test);

  if((unsigned int)width_test == MaxTextureSize)
   break;

  MaxTextureSize >>= 1;
 }
 MDFN_printf(_("Apparently it is at least: %d x %d\n"), MaxTextureSize, MaxTextureSize);

 if(MaxTextureSize < 256)
 {
  MDFN_printf(_("Warning:  Maximum texture size is reported as being less than 256, but we can't handle that.\n"));
  MaxTextureSize = 256;
 }

 DummyBlack = NULL;
 DummyBlackSize = 0;

 MDFN_indent(-1);

 if(!CheckAlternateFormat(version_h))
 {
  #ifdef LSB_FIRST
  *rs = 0;
  *gs = 8;
  *bs = 16;
  *as = 24;
  #else
  *rs = 24;
  *gs = 16;
  *bs = 8;
  *as = 0;
  #endif
  PixelFormat = GL_RGBA;
  PixelType = GL_UNSIGNED_BYTE;
  MDFN_printf(_("Using GL_RGBA, GL_UNSIGNED_BYTE for texture source data.\n"));
 }
 else
 {
  *as = 24;
  *rs = 16;
  *gs = 8;
  *bs = 0;
  PixelFormat = GL_BGRA;
  PixelType = GL_UNSIGNED_INT_8_8_8_8_REV;
  MDFN_printf(_("Using GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV for texture source data.\n"));
 }
 }
 catch(...)
 {
  Cleanup();
  throw;
 }
}
Ejemplo n.º 30
0
//	This is responsible for binding our qgl function pointers to the
// appropriate GL stuff.
void QGL_Init() {
	common->Printf( "...initializing QGL\n" );

#define GLF_0( r, n )             qgl ## n = gl ## n;
#define GLF_V0( n )               qgl ## n = gl ## n;
#define GLF_1( r, n, t1, p1 )     qgl ## n = gl ## n;
#define GLF_V1( n, t1, p1 )       qgl ## n = gl ## n;
#define GLF_V2( n, t1, p1, t2, p2 )   qgl ## n = gl ## n;
#define GLF_3( r, n, t1, p1, t2, p2, t3, p3 ) qgl ## n = gl ## n;
#define GLF_V3( n, t1, p1, t2, p2, t3, p3 )   qgl ## n = gl ## n;
#define GLF_V4( n, t1, p1, t2, p2, t3, p3, t4, p4 )   qgl ## n = gl ## n;
#define GLF_V5( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5 )   qgl ## n = gl ## n;
#define GLF_V6( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6 )   qgl ## n = gl ## n;
#define GLF_V7( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7 )   qgl ## n = gl ## n;
#define GLF_V8( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8 )   qgl ## n = gl ## n;
#define GLF_V9( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8, t9, p9 )   qgl ## n = gl ## n;
#define GLF_V10( n, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8, t9, p9, t10, p10 )    qgl ## n = gl ## n;
#include "qgl_functions.h"
#undef GLF_0
#undef GLF_V0
#undef GLF_1
#undef GLF_V1
#undef GLF_V2
#undef GLF_3
#undef GLF_V3
#undef GLF_V4
#undef GLF_V5
#undef GLF_V6
#undef GLF_V7
#undef GLF_V8
#undef GLF_V9
#undef GLF_V10

	qglActiveTextureARB = NULL;
	qglClientActiveTextureARB = NULL;
	qglMultiTexCoord2fARB = NULL;

	qglLockArraysEXT = NULL;
	qglUnlockArraysEXT = NULL;

	qglPointParameterfEXT = NULL;
	qglPointParameterfvEXT = NULL;

	qglPNTrianglesiATI = NULL;
	qglPNTrianglesfATI = NULL;

#ifdef _WIN32
	qwglSwapIntervalEXT = NULL;
#else
	qglXSwapIntervalSGI = NULL;
#endif

	common->Printf( "Initializing OpenGL extensions\n" );

	// GL_S3_s3tc
	glConfig.textureCompression = TC_NONE;
	if ( CheckExtension( "GL_EXT_texture_compression_s3tc" ) ) {
		if ( r_ext_compressed_textures->integer ) {
			glConfig.textureCompression = TC_EXT_COMP_S3TC;
			common->Printf( "...using GL_EXT_texture_compression_s3tc\n" );
		} else {
			glConfig.textureCompression = TC_NONE;
			common->Printf( "...ignoring GL_EXT_texture_compression_s3tc\n" );
		}
	} else if ( CheckExtension( "GL_S3_s3tc" ) ) {
		if ( r_ext_compressed_textures->integer ) {
			glConfig.textureCompression = TC_S3TC;
			common->Printf( "...using GL_S3_s3tc\n" );
		} else {
			glConfig.textureCompression = TC_NONE;
			common->Printf( "...ignoring GL_S3_s3tc\n" );
		}
	} else {
		common->Printf( "...GL_S3_s3tc not found\n" );
	}

	// GL_ARB_multitexture
	if ( CheckExtension( "GL_ARB_multitexture" ) ) {
		if ( r_ext_multitexture->integer ) {
			qglMultiTexCoord2fARB = ( void ( APIENTRY* )( GLenum target, GLfloat s, GLfloat t ) )GLimp_GetProcAddress( "glMultiTexCoord2fARB" );
			qglActiveTextureARB = ( void ( APIENTRY* )( GLenum target ) )GLimp_GetProcAddress( "glActiveTextureARB" );
			qglClientActiveTextureARB = ( void ( APIENTRY* )( GLenum target ) )GLimp_GetProcAddress( "glClientActiveTextureARB" );

			if ( qglActiveTextureARB ) {
				qglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.maxActiveTextures );

				if ( glConfig.maxActiveTextures > 1 ) {
					common->Printf( "...using GL_ARB_multitexture\n" );
				} else {
					qglMultiTexCoord2fARB = NULL;
					qglActiveTextureARB = NULL;
					qglClientActiveTextureARB = NULL;
					common->Printf( "...not using GL_ARB_multitexture, < 2 texture units\n" );
				}
			}
		} else {
			common->Printf( "...ignoring GL_ARB_multitexture\n" );
		}
	} else {
		common->Printf( "...GL_ARB_multitexture not found\n" );
	}

	// GL_EXT_texture_env_add
	glConfig.textureEnvAddAvailable = false;
	if ( CheckExtension( "GL_EXT_texture_env_add" ) ) {
		if ( r_ext_texture_env_add->integer ) {
			glConfig.textureEnvAddAvailable = true;
			common->Printf( "...using GL_EXT_texture_env_add\n" );
		} else {
			glConfig.textureEnvAddAvailable = false;
			common->Printf( "...ignoring GL_EXT_texture_env_add\n" );
		}
	} else {
		common->Printf( "...GL_EXT_texture_env_add not found\n" );
	}

#ifdef _WIN32
	// WGL_EXT_swap_control
	if ( CheckExtension( "WGL_EXT_swap_control" ) ) {
		if ( r_ext_gamma_control->integer ) {
			qwglSwapIntervalEXT = ( BOOL ( WINAPI* )( int ) )GLimp_GetProcAddress( "wglSwapIntervalEXT" );
			if ( qwglSwapIntervalEXT ) {
				common->Printf( "...using WGL_EXT_swap_control\n" );
				r_swapInterval->modified = true;	// force a set next frame
			} else {
				common->Printf( "...WGL_EXT_swap_control not found\n" );
			}
		} else {
			common->Printf( "...ignoring WGL_EXT_swap_control\n" );
		}
	} else {
		common->Printf( "...WGL_EXT_swap_control not found\n" );
	}
#else
	// GLX_SGI_swap_control
	if ( CheckSystemExtension( "GLX_SGI_swap_control" ) ) {
		qglXSwapIntervalSGI = ( int ( * )( int interval ) )GLimp_GetProcAddress( "glXSwapIntervalSGI" );
		common->Printf( "...using GLX_SGI_swap_control\n" );
	} else {
		common->Printf( "... GLX_SGI_swap_control not found\n" );
	}
#endif

	// GL_EXT_compiled_vertex_array
	if ( CheckExtension( "GL_EXT_compiled_vertex_array" ) ) {
		if ( r_ext_compiled_vertex_array->integer ) {
			common->Printf( "...using GL_EXT_compiled_vertex_array\n" );
			qglLockArraysEXT = ( void ( APIENTRY* )( int, int ) )GLimp_GetProcAddress( "glLockArraysEXT" );
			qglUnlockArraysEXT = ( void ( APIENTRY* )() )GLimp_GetProcAddress( "glUnlockArraysEXT" );
			if ( !qglLockArraysEXT || !qglUnlockArraysEXT ) {
				common->FatalError( "bad getprocaddress" );
			}
		} else {
			common->Printf( "...ignoring GL_EXT_compiled_vertex_array\n" );
		}
	} else {
		common->Printf( "...GL_EXT_compiled_vertex_array not found\n" );
	}

	if ( CheckExtension( "GL_EXT_point_parameters" ) ) {
		if ( r_ext_point_parameters->integer ) {
			common->Printf( "...using GL_EXT_point_parameters\n" );
			qglPointParameterfEXT = ( void ( APIENTRY* )( GLenum, GLfloat ) )GLimp_GetProcAddress( "glPointParameterfEXT" );
			qglPointParameterfvEXT = ( void ( APIENTRY* )( GLenum, const GLfloat* ) )GLimp_GetProcAddress( "glPointParameterfvEXT" );
			if ( !qglPointParameterfEXT || !qglPointParameterfvEXT ) {
				common->FatalError( "bad getprocaddress" );
			}
		} else {
			common->Printf( "...ignoring GL_EXT_point_parameters\n" );
		}
	} else {
		common->Printf( "...GL_EXT_point_parameters not found\n" );
	}

	// GL_NV_fog_distance
	glConfig.NVFogAvailable = false;
	glConfig.NVFogMode = 0;
	if ( CheckExtension( "GL_NV_fog_distance" ) ) {
		if ( r_ext_NV_fog_dist->integer ) {
			glConfig.NVFogAvailable = true;
			common->Printf( "...using GL_NV_fog_distance\n" );
		} else {
			common->Printf( "...ignoring GL_NV_fog_distance\n" );
		}
	} else {
		common->Printf( "...GL_NV_fog_distance not found\n" );
	}

	// GL_EXT_texture_filter_anisotropic
	if ( CheckExtension( "GL_EXT_texture_filter_anisotropic" ) ) {
		if ( r_ext_texture_filter_anisotropic->integer ) {
			glConfig.anisotropicAvailable = true;
			common->Printf( "...using GL_EXT_texture_filter_anisotropic\n" );
		} else {
			common->Printf( "...ignoring GL_EXT_texture_filter_anisotropic\n" );
		}
	} else {
		common->Printf( "... GL_EXT_texture_filter_anisotropic not found\n" );
	}

	// GL_ATI_pn_triangles - ATI PN-Triangles
	if ( CheckExtension( "GL_ATI_pn_triangles" ) ) {
		if ( r_ext_ATI_pntriangles->integer ) {
			common->Printf( "...using GL_ATI_pn_triangles\n" );

			qglPNTrianglesiATI = ( PFNGLPNTRIANGLESIATIPROC )GLimp_GetProcAddress( "glPNTrianglesiATI" );
			qglPNTrianglesfATI = ( PFNGLPNTRIANGLESFATIPROC )GLimp_GetProcAddress( "glPNTrianglesfATI" );

			if ( !qglPNTrianglesiATI || !qglPNTrianglesfATI ) {
				common->FatalError( "bad getprocaddress 0" );
			}
		} else {
			common->Printf( "...ignoring GL_ATI_pn_triangles\n" );
		}
	} else {
		common->Printf( "...GL_ATI_pn_triangles not found\n" );
	}

	// check logging
	QGL_EnableLogging( !!r_logFile->integer );
}