Esempio n. 1
0
int LoadGLFunctions() {
    /*if(!(glCreateShader = (PFNGLCREATESHADERPROC) SDL_GL_GetProcAddress("glCreateShader"))) return 10;
    if(!(glShaderSource = (PFNGLSHADERSOURCEPROC) SDL_GL_GetProcAddress("glShaderSource"))) return 20;
    if(!(glCompileShader = (PFNGLCOMPILESHADERPROC) SDL_GL_GetProcAddress("glCompileShader"))) return 30;
    if(!(glGetShaderiv = (PFNGLGETSHADERIVPROC) SDL_GL_GetProcAddress("glGetShaderiv"))) return 40;
    if(!(glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) SDL_GL_GetProcAddress("glGetShaderInfoLog"))) return 50;
    if(!(glCreateProgram = (PFNGLCREATEPROGRAMPROC) SDL_GL_GetProcAddress("glCreateProgram"))) return 60;
    if(!(glAttachShader = (PFNGLATTACHSHADERPROC) SDL_GL_GetProcAddress("glAttachShader"))) return 70;
    if(!(glLinkProgram = (PFNGLLINKPROGRAMPROC) SDL_GL_GetProcAddress("glLinkProgram"))) return 80;
    if(!(glGetProgramiv = (PFNGLGETPROGRAMIVPROC) SDL_GL_GetProcAddress("glGetProgramiv"))) return 90;
    if(!(glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) SDL_GL_GetProcAddress("glGetProgramInfoLog"))) return 100;
    if(!(glDetachShader = (PFNGLDETACHSHADERPROC) SDL_GL_GetProcAddress("glDetachShader"))) return 108;
    if(!(glDeleteShader = (PFNGLDELETESHADERPROC) SDL_GL_GetProcAddress("glDeleteShader"))) return 110;
    if(!(glGenBuffers = (PFNGLGENBUFFERSPROC) SDL_GL_GetProcAddress("glGenBuffers"))) return 120;
    if(!(glBindBuffer = (PFNGLBINDBUFFERPROC) SDL_GL_GetProcAddress("glBindBuffer"))) return 130;
    if(!(glBufferData = (PFNGLBUFFERDATAPROC) SDL_GL_GetProcAddress("glBufferData"))) return 140;
    if(!(glBufferSubData = (PFNGLBUFFERSUBDATAPROC) SDL_GL_GetProcAddress("glBufferSubData"))) return 141;
    if(!(glUseProgram = (PFNGLUSEPROGRAMPROC) SDL_GL_GetProcAddress("glUseProgram"))) return 150;
    if(!(glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) SDL_GL_GetProcAddress("glEnableVertexAttribArray"))) return 160;
    if(!(glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) SDL_GL_GetProcAddress("glVertexAttribPointer"))) return 170;
    if(!(glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) SDL_GL_GetProcAddress("glDisableVertexAttribArray"))) return 180;
    if(!(glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) SDL_GL_GetProcAddress("glGetUniformLocation"))) return 190;
    if(!(glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) SDL_GL_GetProcAddress("glGetAttribLocation"))) return 192;
    if(!(glActiveTexture = (PFNGLACTIVETEXTUREPROC) SDL_GL_GetProcAddress("glActiveTexture"))) return 200;
    if(!(glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) SDL_GL_GetProcAddress("glUniformMatrix4fv"))) return 210;
    if(!(glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) SDL_GL_GetProcAddress("glDeleteBuffers"))) return 220;
    if(!(glDeleteProgram = (PFNGLDELETEPROGRAMPROC) SDL_GL_GetProcAddress("glDeleteProgram"))) return 230;*/
    if(!(glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) SDL_GL_GetProcAddress("glGenVertexArrays"))) return 240;
    if(!(glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) SDL_GL_GetProcAddress("glBindVertexArray"))) return 241;
    if(!(glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) SDL_GL_GetProcAddress("glDeleteVertexArrays"))) return 242;
    return 0;
}
Esempio n. 2
0
//------------------------------------------------------------------------------------
// Инициализация работы с VBO
//------------------------------------------------------------------------------------
bool vw_Internal_InitializationVBO()
{
	// Get Pointers To The GL Functions
#ifdef USE_GLES
	glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) SDL_GL_GetProcAddress("glGenBuffers");
	glBindBufferARB = (PFNGLBINDBUFFERARBPROC) SDL_GL_GetProcAddress("glBindBuffer");
	glBufferDataARB = (PFNGLBUFFERDATAARBPROC) SDL_GL_GetProcAddress("glBufferData");
	glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) SDL_GL_GetProcAddress("glDeleteBuffers");
	glIsBufferARB = (PFNGLISBUFFERARBPROC) SDL_GL_GetProcAddress("glIsBuffer");
#else
	glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) SDL_GL_GetProcAddress("glGenBuffersARB");
	glBindBufferARB = (PFNGLBINDBUFFERARBPROC) SDL_GL_GetProcAddress("glBindBufferARB");
	glBufferDataARB = (PFNGLBUFFERDATAARBPROC) SDL_GL_GetProcAddress("glBufferDataARB");
	glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) SDL_GL_GetProcAddress("glDeleteBuffersARB");
	glIsBufferARB = (PFNGLISBUFFERARBPROC) SDL_GL_GetProcAddress("glIsBufferARB");
#endif

	if (glGenBuffersARB == NULL || glBindBufferARB == NULL || glBufferDataARB == NULL ||
		glDeleteBuffersARB == NULL || glIsBufferARB == NULL)
	{
		glGenBuffersARB 	= NULL;
		glBindBufferARB 	= NULL;
		glBufferDataARB 	= NULL;
		glDeleteBuffersARB 	= NULL;
		glIsBufferARB 		= NULL;

		return false;
	}

	return true;
}
Esempio n. 3
0
void InitGLExtensions()
{
#ifdef __EMSCRIPTEN__
    return;
#endif
	const char* p = (const char*)glGetString( GL_EXTENSIONS );
	std::string extname;
	while( *p )
	{
		char c = *p++;
		if( c != ' ' )
			extname += c;
		else
		{
	//		printf("'%s'\n", extname.c_str() );
			if( !g_Config.nomultitexture &&
				(extname == "GL_ARB_multitexture" ||
				 extname == "GL_EXT_multitexture" ) )
			{
#ifdef WIN32
				g_glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)
					SDL_GL_GetProcAddress( "glActiveTextureARB" );

				g_glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)
					SDL_GL_GetProcAddress( "glMultiTexCoord2fARB" );
#else
				g_glActiveTextureARB = (GL_ActiveTextureARB_Func)
					SDL_GL_GetProcAddress( "glActiveTextureARB" );

				g_glMultiTexCoord2fARB = (GL_MultiTexCoord2fARB_Func)
					SDL_GL_GetProcAddress( "glMultiTexCoord2fARB" );
#endif
				if( g_glActiveTextureARB && g_glMultiTexCoord2fARB )
				{

					GLint numunits;
					glGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &numunits );
					g_NumTextureUnits = numunits;

					g_GLMultitexture = true;

//					printf( "got %s (%d textureunits)\n", extname.c_str(), g_NumTextureUnits );
				}
			}
			else if( extname == "GL_ARB_texture_env_add" )
			{
				g_ARB_texture_env_add = true;
//				printf( "got texture_env_add\n" );
			}

			extname.erase();
		}
	}
}
void init_glframebufferext() 
{
	glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) SDL_GL_GetProcAddress("glGenFramebuffersEXT");
	glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) SDL_GL_GetProcAddress("glBindFramebufferEXT");
	glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) SDL_GL_GetProcAddress("glGenRenderbuffersEXT");
	glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) SDL_GL_GetProcAddress("glBindRenderbufferEXT");
	glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) SDL_GL_GetProcAddress("glRenderbufferStorageEXT");
	glGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) SDL_GL_GetProcAddress("glGetRenderbufferParameterivEXT");
	glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) SDL_GL_GetProcAddress("glFramebufferTexture2DEXT");
	glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) SDL_GL_GetProcAddress("glFramebufferRenderbufferEXT");
	glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) SDL_GL_GetProcAddress("glCheckFramebufferStatusEXT");
	glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) SDL_GL_GetProcAddress("glGenerateMipmapEXT");
}
Esempio n. 5
0
static void
init_group(const struct fv_gl_group *group)
{
        int minor_gl_version = fv_gl.minor_version;
        const char *suffix;
        struct fv_buffer buffer;
        void *func;
        int gl_version;
        int i;

        if (minor_gl_version >= 10)
                minor_gl_version = 9;
        gl_version = fv_gl.major_version * 10 + minor_gl_version;

        if (group->minimum_gl_version >= 0 &&
            gl_version >= group->minimum_gl_version)
                suffix = "";
        else if (group->extension &&
                 SDL_GL_ExtensionSupported(group->extension))
                suffix = group->extension_suffix;
        else
                return;

        fv_buffer_init(&buffer);

        for (i = 0; group->funcs[i].name; i++) {
                fv_buffer_set_length(&buffer, 0);
                fv_buffer_append_string(&buffer, group->funcs[i].name);
                fv_buffer_append_string(&buffer, suffix);
                func = SDL_GL_GetProcAddress((char *) buffer.data);
                *(void **) ((char *) &fv_gl + group->funcs[i].offset) = func;
        }

        fv_buffer_destroy(&buffer);
}
Esempio n. 6
0
void *GetGLFunc(const char *proc)
{
	void *func = SDL_GL_GetProcAddress(proc);
	if (!func)
		func = hwSym(proc, GLUhandle);
	return func;
}
Esempio n. 7
0
int wzGetSwapInterval()
{
	if (swapInterval >= 0)
	{
		return swapInterval;
	}

	typedef void (* PFNGLXQUERYDRAWABLEPROC)(Display *, GLXDrawable, int, unsigned int *);
	typedef int (* PFNGLXGETSWAPINTERVALMESAPROC)(void);
	typedef int (* PFNGLXSWAPINTERVALSGIPROC)(int);
	PFNGLXQUERYDRAWABLEPROC glXQueryDrawable;
	PFNGLXGETSWAPINTERVALMESAPROC glXGetSwapIntervalMESA;
	PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI;

#if GLX_VERSION_1_2
	// Hack-ish, but better than not supporting GLX_SWAP_INTERVAL_EXT?
	GLXDrawable drawable = glXGetCurrentDrawable();
	Display *display =  glXGetCurrentDisplay();
	glXQueryDrawable = (PFNGLXQUERYDRAWABLEPROC) SDL_GL_GetProcAddress("glXQueryDrawable");

	if (glXQueryDrawable && drawable)
	{
		unsigned interval;
		glXQueryDrawable(display, drawable, GLX_SWAP_INTERVAL_EXT, &interval);
		swapInterval = interval;
		return swapInterval;
	}
#endif

	glXGetSwapIntervalMESA = (PFNGLXGETSWAPINTERVALMESAPROC) SDL_GL_GetProcAddress("glXGetSwapIntervalMESA");
	if (glXGetSwapIntervalMESA)
	{
		swapInterval = glXGetSwapIntervalMESA();
		return swapInterval;
	}

	glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC) SDL_GL_GetProcAddress("glXSwapIntervalSGI");
	if (glXSwapIntervalSGI)
	{
		swapInterval = 1;
	}
	else
	{
		swapInterval = 0;
	}
	return swapInterval;
}
Esempio n. 8
0
static void
VID_InitGL(void)
{
    gl_vendor = (const char *)glGetString(GL_VENDOR);
    gl_renderer = (const char *)glGetString(GL_RENDERER);
    gl_version = (const char *)glGetString(GL_VERSION);
    gl_extensions = (const char *)glGetString(GL_EXTENSIONS);

    printf("GL_VENDOR: %s\n", gl_vendor);
    printf("GL_RENDERER: %s\n", gl_renderer);
    printf("GL_VERSION: %s\n", gl_version);
    printf("GL_EXTENSIONS: %s\n", gl_extensions);

    gl_mtexable = false;
    if (!COM_CheckParm("-nomtex") && VID_GL_CheckExtn("GL_ARB_multitexture")) {
	qglMultiTexCoord2fARB = SDL_GL_GetProcAddress("glMultiTexCoord2fARB");
	qglActiveTextureARB = SDL_GL_GetProcAddress("glActiveTextureARB");

	glGetIntegerv(GL_MAX_TEXTURE_UNITS, &gl_num_texture_units);
	if (gl_num_texture_units >= 2 &&
	    qglMultiTexCoord2fARB && qglActiveTextureARB)
	    gl_mtexable = true;
	Con_Printf("ARB multitexture extension enabled\n"
		   "-> %i texture units available\n",
		   gl_num_texture_units);
    }

    glClearColor(0.5, 0.5, 0.5, 0);
    glCullFace(GL_FRONT);
    glEnable(GL_TEXTURE_2D);

    glEnable(GL_ALPHA_TEST);
    glAlphaFunc(GL_GREATER, 0.666);

    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    glShadeModel(GL_FLAT);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
Esempio n. 9
0
void *load_opengl_command(const char *cmd) {
    void *r = SDL_GL_GetProcAddress(cmd);
    if (r == NULL) {
        SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Failed to load %s command.", cmd);
    }

    return r;
}
Esempio n. 10
0
/**
**  Initialize OpenGL extensions
*/
static void InitOpenGLExtensions()
{
	// ARB_texture_compression
	if (IsExtensionSupported("GL_ARB_texture_compression"))
	{
		glCompressedTexImage3DARB =
			(PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)SDL_GL_GetProcAddress("glCompressedTexImage3DARB");
		glCompressedTexImage2DARB =
			(PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)SDL_GL_GetProcAddress("glCompressedTexImage2DARB");
		glCompressedTexImage1DARB =
			(PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)SDL_GL_GetProcAddress("glCompressedTexImage1DARB");
		glCompressedTexSubImage3DARB =
			(PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)SDL_GL_GetProcAddress("glCompressedTexSubImage3DARB");
		glCompressedTexSubImage2DARB =
			(PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)SDL_GL_GetProcAddress("glCompressedTexSubImage2DARB");
		glCompressedTexSubImage1DARB =
			(PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)SDL_GL_GetProcAddress("glCompressedTexSubImage1DARB");
		glGetCompressedTexImageARB =
			(PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)SDL_GL_GetProcAddress("glGetCompressedTexImageARB");

		if (glCompressedTexImage3DARB && glCompressedTexImage2DARB &&
			glCompressedTexImage1DARB && glCompressedTexSubImage3DARB &&
			glCompressedTexSubImage2DARB && glCompressedTexSubImage1DARB &&
			glGetCompressedTexImageARB)
		{
			GLTextureCompressionSupported = true;
		}
		else
		{
			GLTextureCompressionSupported = false;
		}
	}
}
Esempio n. 11
0
/* general OpenGL initialization function */
void Graphics::initGL( GLvoid ) {
  /* Enable Texture Mapping */
  rsmEnable( GL_TEXTURE_2D );
  
  /* Enable smooth shading */
  glShadeModel( GL_SMOOTH );
  
  // which one to use?
  // default is good
  //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

  /* Set the background black */
  glClearColor( 0.0f, 0.0f, 0.0f, 0.5f );

  /* Depth buffer setup */
  glClearDepth( 1.0f );
  if( stencilBufferUsed ) glClearStencil(0); // Clear The Stencil Buffer To 0

  /* Enables Depth Testing */
  rsmEnable( GL_DEPTH_TEST );

  /* The Type Of Depth Test To Do */
  glDepthFunc( GL_LEQUAL );

  /* Really Nice Perspective Calculations */
  // glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );

  glColorMaterial ( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ) ;
  rsmEnable( GL_COLOR_MATERIAL );

  /* initialize opengl extensions */
  if( Constants::multitexture ) {
    //	  fprintf(stderr, "BEFORE: glSDLActiveTextureARB=%u\n", glSDLActiveTextureARB);
    glSDLActiveTextureARB = 
      (PFNGLACTIVETEXTUREARBPROC)SDL_GL_GetProcAddress ("glActiveTextureARB");
    //	  fprintf(stderr, "AFTER: glSDLActiveTextureARB=%u\n", glSDLActiveTextureARB);
    glSDLMultiTexCoord2fARB = 
      (PFNGLMULTITEXCOORD2FARBPROC)SDL_GL_GetProcAddress ("glMultiTexCoord2fARB");
    glSDLMultiTexCoord2iARB = 
      (PFNGLMULTITEXCOORD2IARBPROC)SDL_GL_GetProcAddress ("glMultiTexCoord2iARB");
  }

  return;
}
Esempio n. 12
0
static bool bindEXTFunction( void *&fnAddress, const char *name )
{
   void* addr = (void*)SDL_GL_GetProcAddress(name);
   if( !addr )
      Con::errorf(ConsoleLogEntry::General, " Missing OpenGL extension '%s'", name);
   else
      fnAddress = addr;
   return (addr != NULL);
}
void setup_gl_extensions() {

	glActiveTextureARB_ptr = (GL_ACTIVETEXTUREARB_FUNC)
		SDL_GL_GetProcAddress("glActiveTextureARB");

	glClientActiveTextureARB_ptr = (GL_CLIENTACTIVETEXTUREARB_FUNC)
		SDL_GL_GetProcAddress("glClientActiveTextureARB");
        
	if (glActiveTextureARB_ptr == 0 || glClientActiveTextureARB_ptr == 0) {
		has_multitex = 0;
	} else {
		has_multitex = 1;
	}

	glCompressedTexImage2DARB_ptr = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) 
		SDL_GL_GetProcAddress("glCompressedTexImage2DARB");
	if (!glCompressedTexImage2DARB_ptr) fprintf(stderr, "uh oh!\n");
}
Esempio n. 14
0
void ogl_extensions_init()
{
	const auto version_str = reinterpret_cast<const char *>(glGetString(GL_VERSION));
	if (!version_str) {
		con_puts(CON_URGENT, "DXX-Rebirth: no valid OpenGL context when querying GL extensions!");
		return;
	}
	const auto version = parse_version_str(version_str);
	const auto extension_str = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));

#if DXX_USE_OGLES
#define DXX_OGL_STRING  " ES"
#else
#define DXX_OGL_STRING  ""
#endif
	con_printf(CON_VERBOSE, "DXX-Rebirth: OpenGL" DXX_OGL_STRING ": version %ld.%ld (%s)", version[0], version[1], version_str);
#undef DXX_OGL_STRING

	/* GL_EXT_texture_filter_anisotropic */
	if (is_supported(extension_str, version, "GL_EXT_texture_filter_anisotropic", -1, -1, -1, -1)) {
		glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &ogl_maxanisotropy);
		con_printf(CON_VERBOSE, "DXX-Rebirth: OpenGL: GL_EXT_texture_filter_anisotropic available, max anisotropy: %f", ogl_maxanisotropy);
	} else {
		ogl_maxanisotropy=0.0f;
		con_puts(CON_VERBOSE, "DXX-Rebirth: OpenGL: GL_EXT_texture_filter_anisotropic not available");
	}

	/* GL_ARB_sync */
	if (is_supported(extension_str, version, "GL_ARB_sync", 3, 2, 3, 0)) {
		glFenceSyncFunc = reinterpret_cast<PFNGLFENCESYNCPROC>(SDL_GL_GetProcAddress("glFenceSync"));
		glDeleteSyncFunc = reinterpret_cast<PFNGLDELETESYNCPROC>(SDL_GL_GetProcAddress("glDeleteSync"));
		glClientWaitSyncFunc = reinterpret_cast<PFNGLCLIENTWAITSYNCPROC>(SDL_GL_GetProcAddress("glClientWaitSync"));

	}
	const char *s;
	if (glFenceSyncFunc && glDeleteSyncFunc && glClientWaitSyncFunc) {
		ogl_have_ARB_sync=true;
		s = "DXX-Rebirth: OpenGL: GL_ARB_sync available";
	} else {
		s = "DXX-Rebirth: OpenGL: GL_ARB_sync not available";
	}
	con_puts(CON_VERBOSE, s);
}
Esempio n. 15
0
static bool lookup_glsym(const char *funcname, void **func)
{
    *func = SDL_GL_GetProcAddress(funcname);
    if (*func == NULL)
    {
		LOG(ERROR) << "Failed to find OpenGL symbol '" << funcname << "'";
        return false;
    }
    return true;
}
Esempio n. 16
0
static void *LOVEGetProcAddress(const char *name)
{
#ifdef LOVE_ANDROID
	void *proc = dlsym(RTLD_DEFAULT, name);
	if (proc)
		return proc;
#endif

	return SDL_GL_GetProcAddress(name);
}
Esempio n. 17
0
/* Must be done after creating a rendering context */
void init_glexts(sdl_data* sd)
{
    static int already_done = 0;

    if(already_done == 0) {
        int i;
        int op;
        sdl_fun* fun_tab = sd->fun_tab;
        char** str_tab = sd->str_tab;

        already_done = 1;

        for (i = 0; (op = ext_fns[i].op) != 0; i++) {
            if (fun_tab[op] == undefined_extension) {
                void* ext_ptr = SDL_GL_GetProcAddress(ext_fns[i].name);
                str_tab[op] = ext_fns[i].name;
                if (ext_ptr) {
                    /* fprintf(stderr, "Success %s \r\n", ext_fns[i].name);*/
                    * (void **) (ext_fns[i].ext_fun) = ext_ptr;
                    fun_tab[op] = ext_fns[i].fun;
                } else {
                    char arbname[256];
                    char* tmp;
                    strcpy(arbname, ext_fns[i].name);
                    tmp = arbname + strlen(arbname);
                    strncpy(tmp, "ARB", 4);
                    ext_ptr = SDL_GL_GetProcAddress(arbname);
                    if (ext_ptr) {
                        /* fprintf(stderr, "Success %s \r\n", ext_fns[i].name); */
                        * (void **) (ext_fns[i].ext_fun) = ext_ptr;
                        fun_tab[op] = ext_fns[i].fun;
                    } else {
                        /*	       fprintf(stderr, "Failed %s \r\n", ext_fns[i].name); */
                        fun_tab[op] = undefined_extension;
                    }
                }
            } else {
                fprintf(stderr, "Exiting FP EXTENSION array mismatch in initialization %d %d %s\r\n",
                        i, ext_fns[i].op, ext_fns[i].name);
            }
        }
    }
}
Esempio n. 18
0
EXPORT void * CALL VidExt_GL_GetProcAddress(const char* Proc)
{
    /* call video extension override if necessary */
    if (l_VideoExtensionActive)
        return (*l_ExternalVideoFuncTable.VidExtFuncGLGetProc)(Proc);

    if (!SDL_WasInit(SDL_INIT_VIDEO))
        return NULL;

    return SDL_GL_GetProcAddress(Proc);
}
Esempio n. 19
0
Texture::Texture()
{
	width = 0;
	height = 0;

	#ifndef USE_GLEW
		if(glGenerateMipmapEXT == NULL) //get the extension
			glGenerateMipmapEXT = (glGenerateMipmapEXT_func) SDL_GL_GetProcAddress("glGenerateMipmapEXT");
	#endif

}
Esempio n. 20
0
static void parseExtensionsCore(PFNGLGETINTEGERVPROC GetIntegerv, BoostSet<std::string> &out)
{
	PFNGLGETSTRINGIPROC GetStringi =
		(PFNGLGETSTRINGIPROC) SDL_GL_GetProcAddress("glGetStringi");

	GLint extCount = 0;
	GetIntegerv(GL_NUM_EXTENSIONS, &extCount);

	for (GLint i = 0; i < extCount; ++i)
		out.insert((const char*) GetStringi(GL_EXTENSIONS, i));
}
Esempio n. 21
0
PFNPROC
glGetProcAddress(const char *f)
{
	union {
		PFNPROC fptr;
		void    *ptr;
	} conv;

	conv.ptr = SDL_GL_GetProcAddress(f);
	return(conv.fptr);
}
Esempio n. 22
0
void *GetGLFunc(const char *proc)
{
	if (strncmp(proc, "glu", 3) == 0)
	{
		if (GLUhandle)
			return hwSym(proc, GLUhandle);
		else
			return NULL;
	}
	return SDL_GL_GetProcAddress(proc);
}
Esempio n. 23
0
int wzGetSwapInterval()
{
	typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC)(void);
	PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT;

	wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC) SDL_GL_GetProcAddress("wglGetSwapIntervalEXT");
	if (wglGetSwapIntervalEXT)
	{
		return wglGetSwapIntervalEXT();
	}
	return 0;
}
Esempio n. 24
0
//------------------------------------------------------------------------------------
// Инициализация работы с VAO
//------------------------------------------------------------------------------------
bool vw_Internal_InitializationVAO()
{
	// Get Pointers To The GL Functions
	glGenVertexArraysARB = (PFNGLGENVERTEXARRAYSPROC) SDL_GL_GetProcAddress("glGenVertexArrays");
	glBindVertexArrayARB = (PFNGLBINDVERTEXARRAYPROC) SDL_GL_GetProcAddress("glBindVertexArray");
	glDeleteVertexArraysARB = (PFNGLDELETEVERTEXARRAYSPROC) SDL_GL_GetProcAddress("glDeleteVertexArrays");
	glIsVertexArrayARB = (PFNGLISVERTEXARRAYPROC) SDL_GL_GetProcAddress("glIsVertexArray");

	if (glGenVertexArraysARB == NULL || glBindVertexArrayARB == NULL ||
		glDeleteVertexArraysARB == NULL || glIsVertexArrayARB == NULL)
	{
		glGenVertexArraysARB 	= NULL;
		glBindVertexArrayARB 	= NULL;
		glDeleteVertexArraysARB = NULL;
		glIsVertexArrayARB 		= NULL;

		return false;
	}

	return true;
}
Esempio n. 25
0
void *
get_funcaddr(const char *p)
{
    void *f = SDL_GL_GetProcAddress(p);
    if (f) {
        return f;
    } else {
        printf("Unable to get function pointer for %s\n", p);
        quit(1);
    }
    return NULL;
}
Esempio n. 26
0
void *opengl_proc(const char *name)
{
#ifdef __linux__
    void *p = glXGetProcAddressARB((const GLubyte *) name);
#else
    void *p = SDL_GL_GetProcAddress(name);
#endif

    if (p == NULL)
        error("OpenGL procedure '%s' not found", name);

    return p;
}
Esempio n. 27
0
File: beagle.c Progetto: dzz/ctt2
static void requestVsyncMode(unsigned int mode)
{    
#ifdef _WIN32
    typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALPROC)( int );
    PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = 0;
    wglSwapIntervalEXT = 
        (PFNWGLSWAPINTERVALPROC)SDL_GL_GetProcAddress( "wglSwapIntervalEXT" );
    wglSwapIntervalEXT(mode);
#endif
#ifdef __linux__
    log_message(CTT2_RT_CORE, LOG_LEVEL_WARNING, "linux unimplemented vsync()");
#endif
}
Esempio n. 28
0
static void check_opengl_sync_capabilities(void)
{
    fs_log("checking OpenGL capabilities\n");
    const char *ext = (const char *) glGetString(GL_EXTENSIONS);
    if (ext) {
        if (strstr(ext, "GL_NV_fence") != NULL) {
            g_has_nv_fence = 1;
            fs_log("GL_NV_fence extension found \n");
#if defined(WITH_GLEW)
#elif defined(WITH_GLAD)
#else
            glGenFencesNV = SDL_GL_GetProcAddress("glGenFencesNV");
            glSetFenceNV = SDL_GL_GetProcAddress("glSetFenceNV");
            glTestFenceNV = SDL_GL_GetProcAddress("glTestFenceNV");
#endif
        }
        if (strstr(ext, "GL_APPLE_fence") != NULL) {
            g_has_apple_fence = 1;
            fs_log("GL_APPLE_fence extension found\n");
#if defined(WITH_GLEW)
#elif defined(WITH_GLAD)
#else
            glGenFencesAPPLE = SDL_GL_GetProcAddress("glGenFencesAPPLE");
            glSetFenceAPPLE = SDL_GL_GetProcAddress("glSetFenceAPPLE");
            glTestFenceAPPLE = SDL_GL_GetProcAddress("glTestFenceAPPLE");
#endif
        }
        if (strstr(ext, "GL_ARB_sync") != NULL) {
            fs_log("GL_ARB_sync extension found\n");
#if defined(WITH_GLEW)
#elif defined(WITH_GLAD)
#else
            glFenceSync = SDL_GL_GetProcAddress("glFenceSync");
            glWaitSync = SDL_GL_GetProcAddress("glWaitSync");
            glClientWaitSync = SDL_GL_GetProcAddress("glClientWaitSync");
#endif
            if (glFenceSync && glClientWaitSync) {
                g_has_arb_sync = 1;
            } else {
                fs_log("error looking up functions\n");
            }
        }
    }
}
Esempio n. 29
0
void InitFBO(void)
{
//#ifndef _WINDOWS // glx is for X11.
// Use SDL for wrapper. 20130128
    if(AG_UsingSDL(NULL)) {
       glVertexPointerEXT = (PFNGLVERTEXPOINTEREXTPROC)SDL_GL_GetProcAddress("glVertexPointerEXT");
       if(glVertexPointerEXT == NULL) bGL_EXT_VERTEX_ARRAY = FALSE;
       glDrawArraysEXT = (PFNGLDRAWARRAYSEXTPROC)SDL_GL_GetProcAddress("glDrawArraysEXT");
       if(glDrawArraysEXT == NULL) bGL_EXT_VERTEX_ARRAY = FALSE;
       glTexCoordPointerEXT = (PFNGLTEXCOORDPOINTEREXTPROC)SDL_GL_GetProcAddress("glTexCoordPointerEXT");
       if(glTexCoordPointerEXT == NULL) bGL_EXT_VERTEX_ARRAY = FALSE;
       glBindBuffer = (PFNGLBINDBUFFERPROC)SDL_GL_GetProcAddress("glBindBuffer");
       if(glBindBuffer == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
       glBufferData = (PFNGLBUFFERDATAPROC)SDL_GL_GetProcAddress("glBufferData");
       if(glBufferData == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
       glGenBuffers = (PFNGLGENBUFFERSPROC)SDL_GL_GetProcAddress("glGenBuffers");
       if(glGenBuffers == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
       glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)SDL_GL_GetProcAddress("glDeleteBuffers");
       if(glDeleteBuffers == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
    } else { // glx, wgl
#ifndef _WINDOWS
       glVertexPointerEXT = (PFNGLVERTEXPOINTEREXTPROC)glXGetProcAddress((const GLubyte *)"glVertexPointerEXT");
       if(glVertexPointerEXT == NULL) bGL_EXT_VERTEX_ARRAY = FALSE;
       glDrawArraysEXT = (PFNGLDRAWARRAYSEXTPROC)glXGetProcAddress((const GLubyte *)"glDrawArraysEXT");
       if(glDrawArraysEXT == NULL) bGL_EXT_VERTEX_ARRAY = FALSE;
       glTexCoordPointerEXT = (PFNGLTEXCOORDPOINTEREXTPROC)glXGetProcAddress((const GLubyte *)"glTexCoordPointerEXT");
       if(glTexCoordPointerEXT == NULL) bGL_EXT_VERTEX_ARRAY = FALSE;
       glBindBuffer = (PFNGLBINDBUFFERPROC)glXGetProcAddress((const GLubyte *)"glBindBuffer");
       if(glBindBuffer == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
       glBufferData = (PFNGLBUFFERDATAPROC)glXGetProcAddress((const GLubyte *)"glBufferData");
       if(glBufferData == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
       glGenBuffers = (PFNGLGENBUFFERSPROC)glXGetProcAddress((const GLubyte *)"glGenBuffers");
       if(glGenBuffers == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
       glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)glXGetProcAddress((const GLubyte *)"glDeleteBuffers");
       if(glDeleteBuffers == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
#else
       glVertexPointerEXT = (PFNGLVERTEXPOINTEREXTPROC)wglGetProcAddress("glVertexPointerEXT");
       if(glVertexPointerEXT == NULL) bGL_EXT_VERTEX_ARRAY = FALSE;
       glDrawArraysEXT = (PFNGLDRAWARRAYSEXTPROC)wglGetProcAddress("glDrawArraysEXT");
       if(glDrawArraysEXT == NULL) bGL_EXT_VERTEX_ARRAY = FALSE;
       glTexCoordPointerEXT = (PFNGLTEXCOORDPOINTEREXTPROC)wglGetProcAddress("glTexCoordPointerEXT");
       if(glTexCoordPointerEXT == NULL) bGL_EXT_VERTEX_ARRAY = FALSE;
       glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer");
       if(glBindBuffer == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
       glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData");
       if(glBufferData == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
       glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers");
       if(glGenBuffers == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
       glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers");
       if(glDeleteBuffers == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = FALSE;
#endif // _WINDOWS    
    }
   
}
Esempio n. 30
0
bool QGL_Init(const char *libName)
{
#if !USE_SDL
	if (!(libGL.Load(libName)))
	{
		appWPrintf("QGL_Init: LoadLibrary(%s) failed\n", libName);
		return false;
	}
#endif

	for (int i = 0; i < NUM_GLFUNCS; i++)
	{
#if !USE_SDL
		if (!libGL.GetProc(GLNames[i], &GlFunc(lib, i)))
#else
		dummyFunc_t func = (dummyFunc_t) (SDL_GL_GetProcAddress(GLNames[i]));
		GlFunc(lib, i) = func;
		if (!func)
#endif
		{
			// free library
#if !USE_SDL
			libGL.Free();
#endif
			appWPrintf("QGL_Init: inconsistent OpenGL library %s: function %s is not found\n", libName, GLNames[i]);
			return false;
		}
	}
#if _WIN32 && !USE_SDL
	// detect minidriver OpenGL version
	if (!gl_driver->IsDefault())			// compare with opengl32.dll
		appPrintf("...minidriver detected\n");
	else
	{
		// replace some wgl function with equivalent GDI ones
		lib.ChoosePixelFormat   = ChoosePixelFormat;
		lib.DescribePixelFormat = DescribePixelFormat;
		// lib.GetPixelFormat   = GetPixelFormat;
		lib.SetPixelFormat      = SetPixelFormat;
		lib.SwapBuffers         = SwapBuffers;
	}
#endif

	GL = lib;

	// allow init-time logging
//	QGL_EnableLogging(gl_logFile->integer != 0);

	return true;
}