void AbstractUniform::update(Program * program) { assert(program != nullptr); if (!program->isLinked()) { return; } if (!m_cacheDSA) // TODO: move caching to a per context caching { m_cacheDSA = true; m_directStateAccess = hasExtension(GLOW_EXT_direct_state_access); } if (m_directStateAccess) { setValueAt(program, locationFor(program)); } else { program->use(); setValueAt(locationFor(program)); } }
VideoFrameShader::VideoFrameShader() : m_vbo(QOpenGLBuffer::VertexBuffer) { auto ctx = QOpenGLContext::currentContext(); m_dma = ctx->hasExtension("GL_APPLE_client_storage") && ctx->hasExtension("GL_APPLE_texture_range"); if (m_dma) _Info("Direct memoery access(DMA) is available."); m_target = m_dma ? OGL::TargetRectangle : OGL::Target2D; m_binding = OGL::bindingTarget(m_target); m_lutInt[0].create(); m_lutInt[1].create(); m_vbo.create(); m_vbo.setUsagePattern(QOpenGLBuffer::StaticDraw); }
bool hasRG() { static int has_rg = -1; if (has_rg >= 0) return !!has_rg; qDebug("check desktop rg: %#X", gl_param_desktop[1].internal_format); if (test_gl_param(gl_param_desktop[1])) { has_rg = 1; return true; } qDebug("check es3 rg: %#X", gl_param_es3[1].internal_format); if (test_gl_param(gl_param_es3[1])) { has_rg = 1; return true; } qDebug("check GL_EXT_texture_rg"); static const char* ext[] = { "GL_EXT_texture_rg", 0}; //RED, RG, R8, RG8 if (hasExtension(ext)) { qDebug("has extension GL_EXT_texture_rg"); has_rg = 1; return true; } qDebug("check gl es>=3 rg"); if (QOpenGLContext::currentContext()) has_rg = isOpenGLES() && QOpenGLContext::currentContext()->format().majorVersion() > 2; return has_rg; }
void ALDevice::reset(const Vector<AttributePair> &attributes) { if(!hasExtension(SOFT_HRTF)) throw std::runtime_error("ALC_SOFT_HRTF not supported"); auto do_reset = [this, &attributes]() -> ALCboolean { if(attributes.empty()) { /* No explicit attributes. */ return alcResetDeviceSOFT(mDevice, nullptr); } auto attr_end = std::find_if(attributes.begin(), attributes.end(), [](const AttributePair &attr) -> bool { return std::get<0>(attr) == 0; } ); if(attr_end == attributes.end()) { /* Attribute list was not properly terminated. Copy the attribute * list and add the 0 sentinel. */ Vector<AttributePair> attrs = attributes; attrs.push_back({0, 0}); return alcResetDeviceSOFT(mDevice, &std::get<0>(attrs.front())); } return alcResetDeviceSOFT(mDevice, &std::get<0>(attributes.front())); }; if(!do_reset()) throw std::runtime_error("Device reset error"); }
AbstractTextureImplementation * AbstractTextureImplementation::get(const Texture::BindlessImplementation impl) { if (impl == Texture::BindlessImplementation::DirectStateAccessARB && hasExtension(GLextension::GL_ARB_direct_state_access)) { return TextureImplementation_DirectStateAccessARB::instance(); } else if (impl >= Texture::BindlessImplementation::DirectStateAccessEXT && hasExtension(GLextension::GL_EXT_direct_state_access)) { return TextureImplementation_DirectStateAccessEXT::instance(); } else { return TextureImplementation_Legacy::instance(); } }
AbstractVertexAttributeBindingImplementation * AbstractVertexAttributeBindingImplementation::get(const VertexArray::AttributeImplementation impl) { if (impl == VertexArray::AttributeImplementation::DirectStateAccessARB && hasExtension(GLextension::GL_ARB_direct_state_access)) { return VertexAttributeBindingImplementation_DirectStateAccessARB::instance(); } else if (impl == VertexArray::AttributeImplementation::VertexAttribBindingARB && hasExtension(GLextension::GL_ARB_vertex_attrib_binding)) { return VertexAttributeBindingImplementation_VertexAttribBindingARB::instance(); } else { return VertexAttributeBindingImplementation_Legacy::instance(); } }
/* * Returns TRUE if user left off file extension, allowing default. * Note that the name is misleading if multiple dots are allowed. * not_pgp_extension or something would be better. */ PGPBoolean noExtension( struct pgpfileBones *filebPtr, char *filename ) { #ifdef MULTIPLE_DOTS /* filename can have more than one dot */ if (hasExtension(filename, filebPtr->ASC_EXTENSION) || hasExtension(filename, filebPtr->PGP_EXTENSION) || hasExtension(filename, filebPtr->PKR_EXTENSION) || hasExtension(filename, filebPtr->SKR_EXTENSION) || hasExtension(filename, filebPtr->SIG_EXTENSION) || isTempFile(filebPtr, filename)) return FALSE; else return TRUE; #else filename = fileTail(filename); return strrchr(filename, '.') == NULL; #endif } /* no_extension */
bool ALDevice::isHRTFEnabled() const { if(!hasExtension(SOFT_HRTF)) throw std::runtime_error("ALC_SOFT_HRTF not supported"); ALCint hrtf_state = -1; alcGetIntegerv(mDevice, ALC_HRTF_SOFT, 1, &hrtf_state); if(hrtf_state == -1) throw std::runtime_error("HRTF state error"); return hrtf_state != ALC_FALSE; }
AbstractObjectNameImplementation * AbstractObjectNameImplementation::get(const Object::NameImplementation impl) { if (impl == Object::NameImplementation::DebugKHR && hasExtension(GLextension::GL_KHR_debug)) { return new ObjectNameImplementation_KHR_debug(); } else { return new ObjectNameImplementation_Legacy(); } }
AbstractProgramBinaryImplementation * AbstractProgramBinaryImplementation::get(const Program::BinaryImplementation impl) { if (impl == Program::BinaryImplementation::GetProgramBinaryARB && hasExtension(GLextension::GL_ARB_get_program_binary)) { return ProgramBinaryImplementation_GetProgramBinaryARB::instance(); } else { return ProgramBinaryImplementation_None::instance(); } }
AbstractUniformImplementation * AbstractUniformImplementation::get(const AbstractUniform::BindlessImplementation impl) { if (impl == AbstractUniform::BindlessImplementation::SeparateShaderObjectsARB && hasExtension(GLextension::GL_ARB_separate_shader_objects)) { return UniformImplementation_SeparateShaderObjectsARB::instance(); } else { return UniformImplementation_Legacy::instance(); } }
Routine *Routine::Load(string path, double scale) { Routine *p = NULL; if(hasExtension(path, ".csv")) { p = parse_csv(path.c_str(), scale); } else if(hasExtension(path, ".jocs") || hasExtension(path, ".js") || hasExtension(path, ".json")) { p = Jocs::Parse(path, scale); } FeasibilityChecker fc; if(p != NULL && !fc.check(*p)) { delete p; return NULL; } // Otherwise throw exception? return p; }
/** * lädt die driverwrapper-extensions. * * @author flosoft */ bool VideoDriverWrapper::LoadAllExtensions() { // auf VSync-Extension testen #ifdef _WIN32 if((GLOBALVARS.ext_swapcontrol = hasExtension("WGL_EXT_swap_control"))) { if( (wglSwapIntervalEXT = pto2ptf<PFNWGLSWAPINTERVALFARPROC>(loadExtension("wglSwapIntervalEXT"))) == NULL) GLOBALVARS.ext_swapcontrol = false; } #else /*if((GLOBALVARS.ext_swapcontrol = hasExtension("GLX_SGI_swap_control"))) {*/ // fix for buggy video driver... GLOBALVARS.ext_swapcontrol = true; if( (wglSwapIntervalEXT = pto2ptf<PFNWGLSWAPINTERVALFARPROC>(loadExtension("glXSwapIntervalSGI"))) == NULL) GLOBALVARS.ext_swapcontrol = false; //} #endif // auf VertexBufferObject-Extension testen if((GLOBALVARS.ext_vbo = hasExtension("GL_ARB_vertex_buffer_object"))) { #ifndef __APPLE__ if ( (glBindBufferARB = pto2ptf<PFNGLBINDBUFFERARBPROC>(loadExtension("glBindBufferARB"))) == NULL) GLOBALVARS.ext_vbo = false; else if ( (glDeleteBuffersARB = pto2ptf<PFNGLDELETEBUFFERSARBPROC>(loadExtension("glDeleteBuffersARB"))) == NULL) GLOBALVARS.ext_vbo = false; else if ( (glGenBuffersARB = pto2ptf<PFNGLGENBUFFERSARBPROC>(loadExtension("glGenBuffersARB"))) == NULL) GLOBALVARS.ext_vbo = false; else if ( (glBufferDataARB = pto2ptf<PFNGLBUFFERDATAARBPROC>(loadExtension("glBufferDataARB"))) == NULL) GLOBALVARS.ext_vbo = false; else if ( (glBufferSubDataARB = pto2ptf<PFNGLBUFFERSUBDATAARBPROC>(loadExtension("glBufferSubDataARB"))) == NULL) GLOBALVARS.ext_vbo = false; #endif // ! __APPLE__ } return true; }
GLESRenderSpec::GLESRenderSpec(GLESRenderDevice* device) { _vendor = (const char*) glGetString(GL_VENDOR); _renderer = (const char*) glGetString(GL_RENDERER); _version = (const char*) glGetString(GL_VERSION); StringVector extensions = StringUtil::tokenise((const char*) glGetString(GL_EXTENSIONS)); _extensions.insert(extensions.begin(), extensions.end()); // GLES 1.1 // http://www.khronos.org/registry/gles/ setCapable(RENDER_BLENDING); setCapable(RENDER_OCCLUSION); setCapable(RENDER_POINT_SPRITES); int value; value = 0; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); _maxTextureSize = value; // GLES 1.1 extension if (hasExtension("GL_OES_texture_npot")) { setCapable(TEXTURE_NPOT); setCapable(RT_TEXTURE_NPOT); // TODO: check again } if (hasExtension("GL_APPLE_texture_2D_limited_npot")) { setCapable(TEXTURE_NPOT); setCapable(RT_TEXTURE_NPOT); // TODO: check again setCapable(TEXTURE_NPOT_LIMITED); } if (hasExtension("GL_EXT_texture_compression_dxt1") && hasExtension("GL_EXT_texture_compression_dxt3") && hasExtension("GL_EXT_texture_compression_dxt5")) { setCapable(FORMAT_TEXTURE_DXT); } setCapable(FORMAT_TEXTURE_PVRTC, hasExtension("GL_IMG_texture_compression_pvrtc")); setCapable(FORMAT_TEXTURE_ETC1, hasExtension("GL_OES_compressed_ETC1_RGB8_texture")); // platform specific #if defined(NIT_IOS) || defined(NIT_ANDROID) setCapable(DEVICE_MAIN_MEM_SHARES_FRAME); setCapable(DEVICE_MAIN_MEM_SHARES_TEX); setCapable(DEVICE_MAIN_MEM_SHARES_GEOMETRY); #endif #if defined(NIT_ANDROID) setCapable(DEVICE_POSSIBLE_LOST); #endif // TODO: temporal if (!isCapable(TEXTURE_NPOT)) g_Render->textureNeedPOT(); if (!isCapable(RT_TEXTURE_NPOT)) g_Render->renderTargetNeedPOT(); }
void AssetList::showFolder(String folderPath) { currentFolderPath = folderPath; for(int i=0; i < assetEntries.size(); i++) { removeChild(assetEntries[i]); delete assetEntries[i]; } assetEntries.clear(); currentEntry = NULL; vector<OSFileEntry> assets = OSBasics::parseFolder(folderPath, false); Number xPos = 20; Number yPos = 20; for(int i=0; i < assets.size(); i++) { OSFileEntry entry = assets[i]; if(entry.type != OSFileEntry::TYPE_FOLDER) { if(hasExtension(entry.extension)) { AssetEntry *newEntry = new AssetEntry(entry.fullPath, entry.name, entry.extension); newEntry->selectShape->addEventListener(this, InputEvent::EVENT_MOUSEDOWN); assetEntries.push_back(newEntry); newEntry->setPosition(xPos, yPos); xPos += 120; if(xPos > 500) { xPos = 20; yPos += 100; } addChild(newEntry); } } } width = 640; if(xPos == 20) { height = yPos+20; } else { height = yPos + 120; } bgShape->setShapeSize(width, height); bgShape->rebuildTransformMatrix(); rebuildTransformMatrix(); }
Vector<String> ALDevice::enumerateHRTFNames() const { if(!hasExtension(SOFT_HRTF)) throw std::runtime_error("ALC_SOFT_HRTF not supported"); ALCint num_hrtfs = -1; alcGetIntegerv(mDevice, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &num_hrtfs); if(num_hrtfs < 0) throw std::runtime_error("HRTF specifier count error"); Vector<String> hrtfs; hrtfs.reserve(num_hrtfs); for(int i = 0;i < num_hrtfs;++i) hrtfs.emplace_back(alcGetStringiSOFT(mDevice, ALC_HRTF_SPECIFIER_SOFT, i)); return hrtfs; }
//Creates our vulkan instance and returns an error if it fails VkResult gvkInitUtils::initVulkan(VkInstance * inst) { VkApplicationInfo appinfo = {}; appinfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; appinfo.pNext = nullptr; appinfo.pApplicationName = "TODO: CHANGE THIS"; appinfo.pEngineName = "VKEngine"; appinfo.apiVersion = VK_API_VERSION_1_0; appinfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0); appinfo.engineVersion = VK_MAKE_VERSION(1, 0, 0); std::vector<const char *> enableExtensions = { VK_KHR_SURFACE_EXTENSION_NAME}; #ifdef _WIN32 enableExtensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); #elif defined(__linux__) enableExtensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); #endif VkInstanceCreateInfo instCrInfo = {}; instCrInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; instCrInfo.pApplicationInfo = &appinfo; instCrInfo.pNext = nullptr; #ifdef _DEBUG std::array<const char*, 1> enabledLayers = {"VK_LAYER_LUNARG_standard_validation" }; if (!hasLayer("VK_LAYER_LUNARG_standard_validation")) { std::cerr << "ERROR REQUIRED LAYER DOES NOT EXIST" << std::endl; return VK_ERROR_INCOMPATIBLE_DRIVER; } enableExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); instCrInfo.enabledLayerCount = enabledLayers.size(); instCrInfo.ppEnabledLayerNames = enabledLayers.data(); if (!hasExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME, "VK_LAYER_LUNARG_standard_validation")) { std::cerr << "ERROR: REQUIRED EXTENSION DOES NOT EXIST" << std::endl; return VK_ERROR_INCOMPATIBLE_DRIVER; } #else instCrInfo.enabledLayerCount = 0; instCrInfo.ppEnabledLayerNames = nullptr; #endif instCrInfo.flags = 0; instCrInfo.enabledExtensionCount = enableExtensions.size(); instCrInfo.ppEnabledExtensionNames = enableExtensions.data(); return vkCreateInstance(&instCrInfo, nullptr, inst); }
bool isPBOSupported() { // check pbo support static bool support = false; static bool pbo_checked = false; if (pbo_checked) return support; const QOpenGLContext *ctx = QOpenGLContext::currentContext(); Q_ASSERT(ctx); if (!ctx) return false; const char* exts[] = { "GL_ARB_pixel_buffer_object", "GL_EXT_pixel_buffer_object", "GL_NV_pixel_buffer_object", //OpenGL ES NULL }; support = hasExtension(exts); pbo_checked = true; return support; }
void AssetList::showFolder(String folderPath) { currentFolderPath = folderPath; clearList(); vector<OSFileEntry> assets = OSBasics::parseFolder(folderPath, false); Number xPos = 20; Number yPos = 30; for(int i=0; i < assets.size(); i++) { OSFileEntry entry = assets[i]; if(entry.type != OSFileEntry::TYPE_FOLDER) { if(hasExtension(entry.extension)) { AssetEntry *newEntry = new AssetEntry(entry.fullPath, entry.name, entry.extension, NULL); newEntry->selectShape->addEventListener(this, InputEvent::EVENT_MOUSEDOWN); newEntry->selectShape->addEventListener(this, InputEvent::EVENT_DOUBLECLICK); assetEntries.push_back(newEntry); newEntry->setPosition(xPos, yPos); xPos += 120; if(xPos > 500) { xPos = 20; yPos += 100; } addChild(newEntry); } } } setWidth(640); if(xPos == 20) { setHeight(yPos+20); } else { setHeight(yPos + 120); } rebuildTransformMatrix(); }
/* returns 0 if ok, > 0 if error */ static int getFiles(int argc, char **argv, FILE **fpin, FILE **fpout, int strip) { int out, err = 0; char *name, s[MAXLINE], t[MAXLINE]; name = getFlagName(argc, argv, OUTFLAG); out = name != NULL; if (out) strcpy(t, name); name = (char *) argv[argc - 1]; if ((argc == 0) || (*name == '-') || (out && !strcmp(t, name))) { fputs("extract: no file name given\n", stderr); err = 1; } else { strcpy(s, name); if (!hasExtension(s)) strcat(s, ASEXT); if (!out) { strcpy(t, s); killExtension(t); strcat(t, TEXEXT); } *fpin = fopen(s, "r"); if (*fpin == NULL) { fputs("extract: cannot open ", stderr); fputs(s, stderr); fputs("\n", stderr); err = 2; } else { *fpout = (strip && !out) ? stdout : fopen(t, "w"); if (*fpout == NULL) { fclose(*fpin); fputs("extract: cannot create ", stderr); fputs(t, stderr); fputs("\n", stderr); err = 3; } } } return err; }
/* if user consents to it, change the filename extension. */ char *maybeForceExtension( struct pgpfileBones *filebPtr, char *filename, char *extension ) { struct pgpenvBones *envbPtr = filebPtr->envbPtr; PGPEnv *env = envbPtr->m_env; PGPInt32 pri; PGPError err; static char newname[MAX_PATH]; if (!hasExtension(filename, extension)) { strcpy(newname, filename); forceExtension( filebPtr, newname, extension ); if (!fileExists(newname)) { fprintf(filebPtr->pgpout, LANG("\nShould '%s' be renamed to '%s' [Y/n]? "), filename, newname); if (getyesno(filebPtr, 'y', (PGPBoolean)pgpenvGetInt( env, PGPENV_BATCHMODE, &pri, &err ))) return newname; } } return NULL; }/* maybe_force_extension */
/** * Create a PsmFile object and open a database to be stored as filename. * * Requires that filename end in .psm. Will overwrite any existing * .psm file. Opens a sqlite3 database, creates necessary tables, and * sets the search ID. */ PsmFile::PsmFile(const char* filename, const ops::variables_map& options_table) : blibRunSearchID_(0), reportMatches_(options_table["report-matches"].as<int>()) { if( !hasExtension(filename, ".psm") ){ Verbosity::error("Filename '%s' does not end with .psm.", filename); } sqlite3_open(filename, &db_); if(db_ == 0) { Verbosity::error("Couldn't open .psm results file %s.", filename); } SqliteRoutine::SQL_STMT("PRAGMA synchronous=OFF", db_); SqliteRoutine::SQL_STMT("PRAGMA cache_size=750000", db_); SqliteRoutine::SQL_STMT("PRAGMA temp_store=MEMORY", db_); createTables(options_table); SqliteRoutine::SQL_STMT("BEGIN", db_); }
bool hasSSE2() const { return hasExtension(cpu_feature_names[eSSE2_Ext]); }
Buffer::Buffer(GLenum target) : Object(genBuffer()) , m_target(target) , m_directStateAccess(hasExtension(GLOW_EXT_direct_state_access)) { }
int main(int argc, char* argv[]) { std::string hdrFrames, inputFile; bool verbose = 0; #ifdef HAVE_PFS PfsInterface pfs; // Needs to store state between frames #endif try { if (!setParams(argc, argv, hdrFrames, inputFile, verbose)) return 1; // Decoder LumaDecoder decoder(inputFile.c_str(), verbose); // Frame for retrieving and storing decoded frames LumaFrame *frame; #define STRBUF_LEN 500 char str[STRBUF_LEN]; int decoded_frame_count = 0; for (int f=1; ; f++) { fprintf(stderr, "Decoding frame %d... ", f); // Get decoded frame frame = decoder.decode(); // No frame available (EOF) if (frame == NULL) break; fprintf(stderr, "done\n"); decoded_frame_count++; // Write hdr frames if( hdrFrames.size() == 0 || hasExtension( hdrFrames.c_str(), "pfs" ) ) { #ifdef HAVE_PFS if( !pfs.writeFrame(hdrFrames.c_str(), *frame) ) break; #else throw LumaException( "Compiled without pfstools support" ); #endif } else { snprintf(str, STRBUF_LEN-1, hdrFrames.c_str(), f); //sprintf(str, hdrFrames.size() == 0 ? "output_%05d.exr" : hdrFrames.c_str(), f); if (!ExrInterface::writeFrame(str, *frame)) break; } } fprintf(stderr, "\n\nDecoding finished. %d frames decoded.\n", decoded_frame_count); } catch (ParserException &e) { fprintf(stderr, "\nlumadec input error: %s\n", e.what()); return 1; } catch (LumaException &e) { fprintf(stderr, "\nlumadec decoding error: %s\n", e.what()); return 1; } catch (std::exception & e) { fprintf(stderr, "\nlumadec error: %s\n", e.what()); return 1; } return 0; }
State* State::currentState() { State* state = new State(DeferredMode); std::vector<GLenum> capabilities = { GL_BLEND, GL_COLOR_LOGIC_OP, GL_CULL_FACE, GL_DEPTH_CLAMP, GL_DEPTH_TEST, GL_DITHER, GL_FRAMEBUFFER_SRGB, GL_LINE_SMOOTH, GL_MULTISAMPLE, GL_POLYGON_OFFSET_FILL, GL_POLYGON_OFFSET_LINE, GL_POLYGON_OFFSET_POINT, GL_POLYGON_SMOOTH, GL_PROGRAM_POINT_SIZE, GL_RASTERIZER_DISCARD, GL_SAMPLE_ALPHA_TO_COVERAGE, GL_SAMPLE_ALPHA_TO_ONE, GL_SAMPLE_COVERAGE, GL_SAMPLE_MASK, GL_SCISSOR_TEST, GL_STENCIL_TEST }; if (Version::current() >= Version(3, 1)) { capabilities.push_back(GL_PRIMITIVE_RESTART); if (hasExtension(GLOW_ARB_ES3_compatibility)) { capabilities.push_back(GL_PRIMITIVE_RESTART_FIXED_INDEX); } state->primitiveRestartIndex(getInteger(GL_PRIMITIVE_RESTART_INDEX)); if (hasExtension(GLOW_ARB_sample_shading)) { capabilities.push_back(GL_SAMPLE_SHADING); } if (hasExtension(GLOW_ARB_seamless_cube_map)) { capabilities.push_back(GL_TEXTURE_CUBE_MAP_SEAMLESS); } if (hasExtension(GLOW_ARB_provoking_vertex)) { state->provokingVertex(getEnum(GL_PROVOKING_VERTEX)); } if (hasExtension(GLOW_KHR_debug)) { capabilities.push_back(GL_DEBUG_OUTPUT); capabilities.push_back(GL_DEBUG_OUTPUT_SYNCHRONOUS); } } for (GLenum capability : capabilities) { state->setEnabled(capability, glow::isEnabled(capability)); } state->blendColor(getFloats<4>(GL_BLEND_COLOR)); state->blendFuncSeparate(getEnum(GL_BLEND_SRC_RGB), getEnum(GL_BLEND_DST_RGB), getEnum(GL_BLEND_SRC_ALPHA), getEnum(GL_BLEND_DST_ALPHA)); state->clearColor(getFloats<4>(GL_COLOR_CLEAR_VALUE)); state->clearDepth(getFloat(GL_DEPTH_CLEAR_VALUE)); state->clearStencil(getInteger(GL_STENCIL_CLEAR_VALUE)); state->colorMask(getBooleans<4>(GL_COLOR_WRITEMASK)); state->cullFace(getInteger(GL_CULL_FACE_MODE)); state->depthFunc(getInteger(GL_DEPTH_FUNC)); state->depthRange(getFloats<2>(GL_DEPTH_RANGE)); state->frontFace(getEnum(GL_FRONT_FACE)); state->logicOp(getInteger(GL_LOGIC_OP_MODE)); state->pointParameter(GL_POINT_FADE_THRESHOLD_SIZE, getEnum(GL_POINT_FADE_THRESHOLD_SIZE)); state->pointParameter(GL_POINT_SPRITE_COORD_ORIGIN, getEnum(GL_POINT_SPRITE_COORD_ORIGIN)); state->pointSize(getFloat(GL_POINT_SIZE)); state->polygonMode(GL_FRONT_AND_BACK, getInteger(GL_POLYGON_MODE)); // is it right to only set GL_FRONT_AND_BACK? state->polygonOffset(getFloat(GL_POLYGON_OFFSET_FACTOR), getFloat(GL_POLYGON_OFFSET_UNITS)); state->sampleCoverage(getFloat(GL_SAMPLE_COVERAGE_VALUE), getBoolean(GL_SAMPLE_COVERAGE_INVERT)); state->scissor(getIntegers<4>(GL_SCISSOR_BOX)); state->stencilFuncSeparate(GL_FRONT, getEnum(GL_STENCIL_FUNC), getEnum(GL_STENCIL_REF), getEnum(GL_STENCIL_VALUE_MASK)); state->stencilOpSeparate(GL_FRONT, getEnum(GL_STENCIL_FAIL), getEnum(GL_STENCIL_PASS_DEPTH_FAIL), getEnum(GL_STENCIL_PASS_DEPTH_PASS)); state->stencilMaskSeparate(GL_FRONT, getEnum(GL_STENCIL_WRITEMASK)); state->stencilFuncSeparate(GL_BACK, getEnum(GL_STENCIL_BACK_FUNC), getEnum(GL_STENCIL_BACK_REF), getEnum(GL_STENCIL_BACK_VALUE_MASK)); state->stencilOpSeparate(GL_BACK, getEnum(GL_STENCIL_BACK_FAIL), getEnum(GL_STENCIL_BACK_PASS_DEPTH_FAIL), getEnum(GL_STENCIL_BACK_PASS_DEPTH_PASS)); state->stencilMaskSeparate(GL_BACK, getEnum(GL_STENCIL_BACK_WRITEMASK)); // pixel store std::vector<GLenum> pixelstoreParameters = { GL_PACK_SWAP_BYTES, GL_PACK_LSB_FIRST, GL_PACK_ROW_LENGTH, GL_PACK_IMAGE_HEIGHT, GL_PACK_SKIP_PIXELS, GL_PACK_SKIP_ROWS, GL_PACK_SKIP_IMAGES, GL_PACK_ALIGNMENT, GL_UNPACK_SWAP_BYTES, GL_UNPACK_LSB_FIRST, GL_UNPACK_ROW_LENGTH, GL_UNPACK_IMAGE_HEIGHT, GL_UNPACK_SKIP_PIXELS, GL_UNPACK_SKIP_ROWS, GL_UNPACK_SKIP_IMAGES, GL_UNPACK_ALIGNMENT }; for (GLenum param : pixelstoreParameters) { state->pixelStore(param, getInteger(param)); } return state; }
egl::Error FunctionsEGL::initialize(EGLNativeDisplayType nativeDisplay) { #define ANGLE_GET_PROC_OR_ERROR(MEMBER, NAME) \ if (!SetPtr(MEMBER, getProcAddress(#NAME))) \ { \ return egl::EglNotInitialized() << "Could not load EGL entry point " #NAME; \ } ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->bindAPIPtr, eglBindAPI); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->chooseConfigPtr, eglChooseConfig); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createContextPtr, eglCreateContext); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createPbufferSurfacePtr, eglCreatePbufferSurface); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createWindowSurfacePtr, eglCreateWindowSurface); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->destroyContextPtr, eglDestroyContext); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->destroySurfacePtr, eglDestroySurface); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getConfigAttribPtr, eglGetConfigAttrib); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getDisplayPtr, eglGetDisplay); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getErrorPtr, eglGetError); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->initializePtr, eglInitialize); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->makeCurrentPtr, eglMakeCurrent); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->queryStringPtr, eglQueryString); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->querySurfacePtr, eglQuerySurface); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->swapBuffersPtr, eglSwapBuffers); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->terminatePtr, eglTerminate); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->bindTexImagePtr, eglBindTexImage); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->releaseTexImagePtr, eglReleaseTexImage); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->swapIntervalPtr, eglSwapInterval); mEGLDisplay = mFnPtrs->getDisplayPtr(nativeDisplay); if (mEGLDisplay == EGL_NO_DISPLAY) { return egl::EglNotInitialized() << "Failed to get system egl display"; } if (mFnPtrs->initializePtr(mEGLDisplay, &majorVersion, &minorVersion) != EGL_TRUE) { return egl::Error(mFnPtrs->getErrorPtr(), "Failed to initialize system egl"); } if (majorVersion < 1 || (majorVersion == 1 && minorVersion < 4)) { return egl::EglNotInitialized() << "Unsupported EGL version (require at least 1.4)."; } if (mFnPtrs->bindAPIPtr(EGL_OPENGL_ES_API) != EGL_TRUE) { return egl::Error(mFnPtrs->getErrorPtr(), "Failed to bind API in system egl"); } const char *extensions = queryString(EGL_EXTENSIONS); if (!extensions) { return egl::Error(mFnPtrs->getErrorPtr(), "Faild to query extensions in system egl"); } angle::SplitStringAlongWhitespace(extensions, &mExtensions); if (hasExtension("EGL_KHR_image_base")) { ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createImageKHRPtr, eglCreateImageKHR); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->destroyImageKHRPtr, eglDestroyImageKHR); } if (hasExtension("EGL_KHR_fence_sync")) { ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->clientWaitSyncKHRPtr, eglClientWaitSyncKHR); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->createSyncKHRPtr, eglCreateSyncKHR); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->destroySyncKHRPtr, eglDestroySyncKHR); ANGLE_GET_PROC_OR_ERROR(&mFnPtrs->getSyncAttribKHRPtr, eglGetSyncAttribKHR); } #undef ANGLE_GET_PROC_OR_ERROR return egl::NoError(); }
bool hasAltivec() const { return hasExtension("Altivec"); }
Buffer::Buffer(GLuint id, GLenum target) : Object(id, false) , m_target(target) , m_directStateAccess(hasExtension(GLOW_EXT_direct_state_access)) { }
bool FunctionsGLX::initialize(Display *xDisplay, int screen, std::string *errorString) { terminate(); mXDisplay = xDisplay; mXScreen = screen; #if !defined(ANGLE_LINK_GLX) // Some OpenGL implementations can't handle having this library // handle closed while there's any X window still open against // which a GLXWindow was ever created. if (!sLibHandle) { sLibHandle = dlopen("libGL.so.1", RTLD_NOW); if (!sLibHandle) { *errorString = std::string("Could not dlopen libGL.so.1: ") + dlerror(); return false; } } getProc = reinterpret_cast<PFNGETPROCPROC>(dlsym(sLibHandle, "glXGetProcAddress")); if (!getProc) { getProc = reinterpret_cast<PFNGETPROCPROC>(dlsym(sLibHandle, "glXGetProcAddressARB")); } if (!getProc) { *errorString = "Could not retrieve glXGetProcAddress"; return false; } #else getProc = reinterpret_cast<PFNGETPROCPROC>(glXGetProcAddress); #endif #define GET_PROC_OR_ERROR(MEMBER, NAME) \ if (!GetProc(getProc, MEMBER, #NAME)) \ { \ *errorString = "Could not load GLX entry point " #NAME; \ return false; \ } #if !defined(ANGLE_LINK_GLX) #define GET_FNPTR_OR_ERROR(MEMBER, NAME) GET_PROC_OR_ERROR(MEMBER, NAME) #else #define GET_FNPTR_OR_ERROR(MEMBER, NAME) *MEMBER = NAME; #endif // GLX 1.0 GET_FNPTR_OR_ERROR(&mFnPtrs->createContextPtr, glXCreateContext); GET_FNPTR_OR_ERROR(&mFnPtrs->destroyContextPtr, glXDestroyContext); GET_FNPTR_OR_ERROR(&mFnPtrs->makeCurrentPtr, glXMakeCurrent); GET_FNPTR_OR_ERROR(&mFnPtrs->swapBuffersPtr, glXSwapBuffers); GET_FNPTR_OR_ERROR(&mFnPtrs->queryExtensionPtr, glXQueryExtension); GET_FNPTR_OR_ERROR(&mFnPtrs->queryVersionPtr, glXQueryVersion); GET_FNPTR_OR_ERROR(&mFnPtrs->getCurrentContextPtr, glXGetCurrentContext); GET_FNPTR_OR_ERROR(&mFnPtrs->getCurrentDrawablePtr, glXGetCurrentDrawable); GET_FNPTR_OR_ERROR(&mFnPtrs->waitXPtr, glXWaitX); GET_FNPTR_OR_ERROR(&mFnPtrs->waitGLPtr, glXWaitGL); // GLX 1.1 GET_FNPTR_OR_ERROR(&mFnPtrs->getClientStringPtr, glXGetClientString); GET_FNPTR_OR_ERROR(&mFnPtrs->queryExtensionsStringPtr, glXQueryExtensionsString); // Check we have a working GLX { int errorBase; int eventBase; if (!queryExtension(&errorBase, &eventBase)) { *errorString = "GLX is not present."; return false; } } // Check we have a supported version of GLX if (!queryVersion(&majorVersion, &minorVersion)) { *errorString = "Could not query the GLX version."; return false; } if (majorVersion != 1 || minorVersion < 3) { *errorString = "Unsupported GLX version (requires at least 1.3)."; return false; } const char *extensions = queryExtensionsString(); if (!extensions) { *errorString = "glXQueryExtensionsString returned NULL"; return false; } angle::SplitStringAlongWhitespace(extensions, &mExtensions); // GLX 1.3 GET_FNPTR_OR_ERROR(&mFnPtrs->getFBConfigsPtr, glXGetFBConfigs); GET_FNPTR_OR_ERROR(&mFnPtrs->chooseFBConfigPtr, glXChooseFBConfig); GET_FNPTR_OR_ERROR(&mFnPtrs->getFBConfigAttribPtr, glXGetFBConfigAttrib); GET_FNPTR_OR_ERROR(&mFnPtrs->getVisualFromFBConfigPtr, glXGetVisualFromFBConfig); GET_FNPTR_OR_ERROR(&mFnPtrs->createWindowPtr, glXCreateWindow); GET_FNPTR_OR_ERROR(&mFnPtrs->destroyWindowPtr, glXDestroyWindow); GET_FNPTR_OR_ERROR(&mFnPtrs->createPbufferPtr, glXCreatePbuffer); GET_FNPTR_OR_ERROR(&mFnPtrs->destroyPbufferPtr, glXDestroyPbuffer); GET_FNPTR_OR_ERROR(&mFnPtrs->queryDrawablePtr, glXQueryDrawable); // Extensions if (hasExtension("GLX_ARB_create_context")) { GET_PROC_OR_ERROR(&mFnPtrs->createContextAttribsARBPtr, glXCreateContextAttribsARB); } if (hasExtension("GLX_EXT_swap_control")) { GET_PROC_OR_ERROR(&mFnPtrs->swapIntervalEXTPtr, glXSwapIntervalEXT); } if (hasExtension("GLX_MESA_swap_control")) { GET_PROC_OR_ERROR(&mFnPtrs->swapIntervalMESAPtr, glXSwapIntervalMESA); } if (hasExtension("GLX_SGI_swap_control")) { GET_PROC_OR_ERROR(&mFnPtrs->swapIntervalSGIPtr, glXSwapIntervalSGI); } #undef GET_FNPTR_OR_ERROR #undef GET_PROC_OR_ERROR *errorString = ""; return true; }