本文整理汇总了C++中ofTexture::getTextureData方法的典型用法代码示例。如果您正苦于以下问题:C++ ofTexture::getTextureData方法的具体用法?C++ ofTexture::getTextureData怎么用?C++ ofTexture::getTextureData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofTexture
的用法示例。
在下文中一共展示了ofTexture::getTextureData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send
//----------
bool Sender::send(const ofTexture & texture, bool flipY) {
try {
if (!this->isInitialized()) {
throw("Not initialised");
}
//check if the sender matches the settings of the texture
if (this->width != texture.getWidth() || this->height != texture.getHeight()) {
this->width = texture.getWidth();
this->height = texture.getHeight();
//update the sender to match local settings
char mutableName[256];
strcpy_s(mutableName, channelName.size() + 1, channelName.c_str());
if (!this->spoutSender->UpdateSender(mutableName, this->width, this->height)) {
throw("Can't update sender");
}
this->channelName = string(mutableName);
}
//send texture and retain any fbo bound for drawing
GLint drawFboId = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId);
this->spoutSender->SendTexture(texture.getTextureData().textureID, texture.getTextureData().textureTarget, this->width, this->height, flipY, drawFboId);
return true;
}
catch (const char * e) {
ofLogError("ofxSpout::Sender::send") << e;
return false;
}
}
示例2: mapTexCoords
//----------------------------------------------------------
void of3dPrimitive::mapTexCoordsFromTexture( ofTexture& inTexture ) {
bool bNormalized = true;
#ifndef TARGET_OPENGLES
bNormalized = (inTexture.getTextureData().textureTarget!=GL_TEXTURE_RECTANGLE_ARB);
#endif
ofTextureData& tdata = inTexture.getTextureData();
if(bNormalized)
mapTexCoords( 0, 0, tdata.tex_t, tdata.tex_u );
else
mapTexCoords(0, 0, inTexture.getWidth(), inTexture.getHeight());
ofVec4f tcoords = getTexCoords();
mapTexCoords(tcoords.x, tcoords.y, tcoords.z, tcoords.w);
}
示例3: initFromTexture
void OpenCLImage::initFromTexture(ofTexture &tex,
cl_mem_flags memFlags,
int mipLevel)
{
ofLog(OF_LOG_VERBOSE, "OpenCLImage::initFromTexture");
init(tex.getWidth(), tex.getHeight(), 1);
cl_int err;
if(clMemObject) clReleaseMemObject(clMemObject);
clMemObject = clCreateFromGLTexture2D(pOpenCL->getContext(), memFlags, tex.getTextureData().textureTarget, mipLevel, tex.getTextureData().textureID, &err);
assert(err != CL_INVALID_CONTEXT);
assert(err != CL_INVALID_VALUE);
// assert(err != CL_INVALID_MIPLEVEL);
assert(err != CL_INVALID_GL_OBJECT);
assert(err != CL_INVALID_IMAGE_FORMAT_DESCRIPTOR);
assert(err != CL_OUT_OF_HOST_MEMORY);
assert(err == CL_SUCCESS);
assert(clMemObject);
texture = &tex;
hasCorrespondingGLObject = true;
}
示例4: ofDrawBitmapCharacterStart
//---------------------------------------------------------------------
void ofDrawBitmapCharacterStart(int stringLength) {
verts.clear();
coords.clear();
verts.assign(12 * (stringLength+1), 0);
coords.assign(12 * (stringLength+1), 0);
if(!bBitmapTexturePrepared) {
prepareBitmapTexture();
}
glesBitmappedFontTexture.bind();
#ifndef TARGET_OPENGLES
// this temporarily enables alpha testing,
// which discards pixels unless their alpha is 1.0f
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_EQUAL, 1.0f);
#endif
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glTexParameterf(glesBitmappedFontTexture.getTextureData().textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
vC = 0;
}
示例5: copy
void copy(S& src, ofTexture& tex) {
imitate(tex, src);
int w = tex.getWidth(), h = tex.getHeight();
int glType = tex.getTextureData().glTypeInternal;
Mat mat = toCv(src);
tex.loadData(mat.ptr(), w, h, glType);
}
示例6: setUniformTexture
void ofxShader::setUniformTexture(const char* name, ofTexture& tex, int textureLocation) {
if(bLoaded) {
ofTextureData texData = tex.getTextureData();
glActiveTexture(GL_TEXTURE0 + textureLocation);
glEnable(texData.textureTarget);
glBindTexture(texData.textureTarget, texData.textureID);
glDisable(texData.textureTarget);
setUniform1i(name, textureLocation);
glActiveTexture(GL_TEXTURE0);
}
}
示例7: initFromOFTexture
void GLTexture::initFromOFTexture(ofTexture &texture)
{
tex[0] = texture.getTextureData().textureID;
type = texture.texData.glType;
texTarget = texture.texData.textureTarget; //texTarget GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB,
texInternalFormat = texture.texData.glTypeInternal; //GL_RGBA, GL_RGBA16F_ARB, GL_RGBA32F_ARB;
minFilter = GL_LINEAR; //GL_NEAREST, GL_LINEAR
magFilter = GL_LINEAR; //GL_NEAREST, GL_LINEAR
width = texture.getWidth();
height = texture.getHeight();
}
示例8: loadTexture
GLuint ofxImGui::loadTexture(ofTexture& texture, string imagePath)
{
bool isUsingArb = ofGetUsingArbTex();
if (isUsingArb)
{
ofDisableArbTex();
}
ofLoadImage(texture, imagePath);
if (isUsingArb)
{
ofEnableArbTex();
}
return texture.getTextureData().textureID;
}
示例9: setUniformTexture
//--------------------------------------------------------------
void ofShader::setUniformTexture(const string & name, const ofTexture& tex, int textureLocation) const{
if(bLoaded) {
ofTextureData texData = tex.getTextureData();
glActiveTexture(GL_TEXTURE0 + textureLocation);
if (!ofIsGLProgrammableRenderer()){
glEnable(texData.textureTarget);
glBindTexture(texData.textureTarget, texData.textureID);
glDisable(texData.textureTarget);
} else {
glBindTexture(texData.textureTarget, texData.textureID);
}
setUniform1i(name, textureLocation);
glActiveTexture(GL_TEXTURE0);
}
}
示例10: toPixels
// get pixels from a fbo or texture // untested
void ftUtil::toPixels(ofTexture& _tex, ofPixels& _pixels) {
ofTextureData& texData = _tex.getTextureData();
int format = texData.glInternalFormat;
int readFormat, numChannels;
switch(format){
case GL_R8: readFormat = GL_RED, numChannels = 1; break; // or is it GL_R
case GL_RG8: readFormat = GL_RG, numChannels = 2; break;
case GL_RGB8: readFormat = GL_RGB, numChannels = 3; break;
case GL_RGBA8: readFormat = GL_RGBA, numChannels = 4; break;
default:
ofLogWarning("ftUtil") << "toPixels: " << "can only read char texturs to ofPixels";
return;
}
if (_pixels.getWidth() != texData.width || _pixels.getHeight() != texData.height || _pixels.getNumChannels() != numChannels) {
_pixels.allocate(texData.width, texData.height, numChannels);
}
ofSetPixelStoreiAlignment(GL_PACK_ALIGNMENT, texData.width, 1, numChannels);
glBindTexture(texData.textureTarget, texData.textureID);
glGetTexImage(texData.textureTarget, 0, readFormat, GL_UNSIGNED_BYTE, _pixels.getData());
glBindTexture(texData.textureTarget, 0);
}
示例11: receive
//----------
bool Receiver::receive(ofTexture & texture) {
try {
//check if we're initialised
if (!this->isInitialized()) {
throw("Not initialized");
}
//prepare the channel name, allow it to be changed if different channels are available
char mutableName[256];
unsigned int mutableWidth, mutableHeight;
strcpy_s(mutableName, this->channelName.size() + 1, this->channelName.c_str());
//check if the texture is allocated correctly, if not, allocate it
if (texture.getWidth() != this->width || texture.getHeight() != this->height) {
int format = texture.isAllocated() ? texture.getTextureData().glInternalFormat : this->defaultFormat;
texture.allocate(width, height, format);
}
//pull data into the texture (keep any existing fbo attachments)
GLint drawFboId = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId);
if (!this->spoutReceiver->ReceiveTexture(mutableName, mutableWidth, mutableHeight, texture.getTextureData().textureID, texture.getTextureData().textureTarget, false, drawFboId)) {
throw("Can't receive texture");
}
//update our local settings incase anything changed
this->channelName = mutableName;
this->width = mutableWidth;
this->height = mutableHeight;
return true;
}
catch (const char * e) {
ofLogError("ofxSpout::Receiver::receive") << e;
return false;
}
}
示例12: flipSurface
void CubeMap::flipSurface(ofTexture & surf)
{
unsigned char* data = surf.getTextureData();
int w = surf.getRowBytes();
int h = surf.getHeight();
char r,g,b,a=0;
// for(int i = 0 ; i < w*h*100; i++)
// data[i] = 10;
int pixInc = surf.getPixelInc();
for(int j = 0; j < h; j++)
{
for(int i = 0; i < 256; i++)
{
int index =pixInc*i+j*w;
int nIndex = (j+1)*w-(i)*pixInc;
r = data[index];
g = data[index+1];
b = data[index+2];
a = data[index+3];
data[index] = data[nIndex];
data[index+1] = data[nIndex+1];
data[index+2] = data[nIndex+2];
data[index+3] = data[nIndex+3];
data[nIndex] = r;
data[nIndex+1] = g;
data[nIndex+2] = b;
data[nIndex+3] = a;
}
}
}
示例13: allocate
void ofxPBO::allocate(ofTexture & tex, int numPBOs){
pboIds.resize(numPBOs);
glGenBuffersARB(numPBOs, &pboIds[0]);
int numChannels=1;
switch(tex.getTextureData().glTypeInternal){
case GL_LUMINANCE:
numChannels = 1;
break;
case GL_RGB:
numChannels = 3;
break;
case GL_RGBA:
numChannels = 4;
break;
}
dataSize = tex.getWidth()*tex.getHeight()*numChannels;
for(int i=0;i<(int)pboIds.size();i++){
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboIds[i]);
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, dataSize, 0, GL_STREAM_DRAW_ARB);
}
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
texture = tex;
}
示例14: setCustomUniformTexture
void ofMaterial::setCustomUniformTexture(const std::string & name, const ofTexture & value, int textureLocation){
uniformstex[name] = {value.getTextureData().textureTarget, int(value.getTextureData().textureID), textureLocation};
}
示例15: setupCapture
CubeMap::CubeMap( GLsizei texWidth,
GLsizei texHeight,
const ofTexture &pos_x,
const ofTexture &pos_y,
const ofTexture &pos_z,
const ofTexture &neg_x,
const ofTexture &neg_y,
const ofTexture &neg_z )
{
mWidth = texWidth;
mHeight = texHeight;
setupCapture();
// glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
//create a texture object
glGenTextures(1, &textureObject);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, textureObject);
//assign the images to positions
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pos_x.getTextureData());
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, neg_x.getTextureData());
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pos_y.getTextureData());
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, neg_y.getTextureData());
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pos_z.getTextureData());
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, neg_z.getTextureData());
//set filtering modes for scaling up and down
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}