本文整理汇总了C++中ofTexture::loadData方法的典型用法代码示例。如果您正苦于以下问题:C++ ofTexture::loadData方法的具体用法?C++ ofTexture::loadData怎么用?C++ ofTexture::loadData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofTexture
的用法示例。
在下文中一共展示了ofTexture::loadData方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
void setup()
{
if (bSetup)
return;
grayLineTex.allocate(1,3, GL_LUMINANCE_ALPHA);
unsigned char gray_line_data[3*2] = {
255,0, 255,255, 255,0
// DARK BRIGHT DARK
};
grayLineTex.loadData(gray_line_data, 1,3, GL_LUMINANCE_ALPHA);
rgbLineTex.allocate(1,7, GL_RGBA);
unsigned char rgb_line_data[7*4] = {
255,0,0,0, 255,0,0,255,
//r DARK BRIGHT
0,255,0,0, 0,255,0,255,
//g DARK BRIGHT
0,0,255,0, 0,0,255,255,
//b DARK BRIGHT
0,0,255,0
// DARK
};
rgbLineTex.loadData(rgb_line_data, 1,7, GL_RGBA);
bSetup = true;
cout << "Renderer textures initialized." << endl;
}
示例2: applyDisplaceMap
void dfDisplacementMap::applyDisplaceMap(ofxCvColorImage& sourceImage,ofTexture& destTexture,float hscale=0.3, float vscale=0.3){
//apply displacement
unsigned char * displacePixels = this->getPixels();
unsigned char * pixels = sourceImage.getPixels();
int displace,hdisplace,vdisplace;
int totalPixels=height*width*3;
unsigned char * videoDisplaced = new unsigned char[totalPixels];
for (int i = 0; i < totalPixels;i+=3){
hdisplace = (int)((displacePixels[i] - 127)*hscale); //x coord
vdisplace = (int)((displacePixels[i+2] - 127) *vscale); //y coord
if( i%(320*3)+hdisplace*3 >0 && i%(320*3)+hdisplace*3<320*3){
displace=hdisplace+vdisplace*320;
}else{
displace = 0;
}
displace*= 3;
if(i+displace>0 && i+displace<totalPixels){
videoDisplaced[i] = pixels[i+displace];
videoDisplaced[i+1] = pixels[i+displace+1];
videoDisplaced[i+2] = pixels[i+displace+2];
}
}
destTexture.loadData(videoDisplaced,width,height, GL_RGB);
delete videoDisplaced;
}
示例3: prepareBitmapTexture
//---------------------------------------------------------------------
static void prepareBitmapTexture() {
if (!bBitmapTexturePrepared) {
glesBitmappedFontTexture.allocate(16*16, 16*16, GL_LUMINANCE_ALPHA, false);
bBitmapTexturePrepared = true;
for (int i = 0; i < 256; i++) {
const unsigned char * face = bmpChar_8x13_Map[i];
for (int j = 1; j < 15; j++) {
for (int k = 0; k < 8; k++) {
if ( ((face[15-j] << k) & (128)) > 0 ) {
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*2] = 255;
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*2+1] = 255;
} else {
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*2] = 0;
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*2+1] = 0;
}
}
}
}
glesBitmappedFontTexture.loadData(myLetterPixels, 16*16, 16*16, GL_LUMINANCE_ALPHA);
}
}
示例4: 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);
}
示例5: ofLoadImage
//----------------------------------------------------------------
bool ofLoadImage(ofTexture & tex, const ofBuffer & buffer){
ofPixels pixels;
bool loaded = ofLoadImage(pixels,buffer);
if(loaded){
tex.allocate(pixels.getWidth(), pixels.getHeight(), ofGetGlInternalFormat(pixels));
tex.loadData(pixels);
}
return loaded;
}
示例6: ofLoadImage
//----------------------------------------------------------------
bool ofLoadImage(ofTexture & tex, const std::string& path, const ofImageLoadSettings &settings){
ofPixels pixels;
bool loaded = ofLoadImage(pixels, path, settings);
if(loaded){
tex.allocate(pixels.getWidth(), pixels.getHeight(), ofGetGlInternalFormat(pixels));
tex.loadData(pixels);
}
return loaded;
}
示例7: ofxCreateGaussianMapTexture
//--------------------------------------------------------------
void ofxCreateGaussianMapTexture(ofTexture& texture, int resolution, int textureTarget)
{
ofTextureData textureData;
textureData.width = resolution;
textureData.height = resolution;
textureData.glInternalFormat = GL_RGBA;
textureData.textureTarget = textureTarget;
unsigned char *data = createGaussianMap(resolution);
texture.allocate(textureData);
texture.loadData(data, resolution, resolution, GL_RGBA);
}
示例8: updateSpacePreview
void PCDecode::updateSpacePreview(int width, int height, unsigned char data[], ofTexture &texture, std::vector<PCPixel*> &foundPixels)
{
float Xdash, Ydash;
int nPixels = width * height;
for (int iPixel=0; iPixel<nPixels; iPixel++)
{
Xdash = foundPixels[iPixel]->xdash.x;
Ydash = foundPixels[iPixel]->xdash.y;
data[iPixel*3] = float(255) * Xdash;
data[iPixel*3+1] = float(255) * Ydash;
data[iPixel*3+2] = 0;
}
texture.loadData(data, width, height, GL_RGB);
}
示例9: randmap_rebuild
void testApp::randmap_rebuild(float rmin, float rmax)
{
float * parts_buf = new float[numParticles * 4];
for (int x = 0; x < parts_res; x++) {
for (int y = 0; y < parts_res; y++) {
int i = x * parts_res + y;
parts_buf[i * 3 + 0] = ofRandom(rmin, rmax);
parts_buf[i * 3 + 1] = ofRandom(rmin, rmax);
parts_buf[i * 3 + 2] = ofRandom(rmin, rmax);
parts_buf[i * 3 + 3] = ofRandom(rmin, rmax);
}
}
randtex.loadData(parts_buf, parts_res, parts_res, GL_RGBA);
delete parts_buf;
}
示例10: copy
void copy(S& src, ofTexture& tex) {
Mat mat = toCv(src);
int glType;
Mat buffer;
if(mat.depth() != CV_8U) {
copy(mat, buffer, CV_8U);
} else {
buffer = mat;
}
if(mat.channels() == 1) {
glType = GL_LUMINANCE;
} else {
glType = GL_RGB;
}
int w = buffer.cols;
int h = buffer.rows;
tex.allocate(w, h, glType);
tex.loadData(buffer.ptr(), w, h, glType);
}
示例11: prepareBitmapTexture
//---------------------------------------------------------------------
static void prepareBitmapTexture(){
if (!bBitmapTexturePrepared){
myLetterPixels.allocate(16*16, 16*16, 4); // letter size:8x14pixels, texture size:16x8letters, gl_rgba: 4bytes/1pixel
myLetterPixels.set(0);
bitmappedFontTexture.allocate(16*16, 16*16, GL_RGBA, false);
bBitmapTexturePrepared = true;
for (int i = 0; i < 256; i++) {
const unsigned char * face = bmpChar_8x13_Map[i];
for (int j = 1; j < 15; j++){
for (int k = 0; k < 8; k++){
if ( ((face[15-j] << k) & (128)) > 0 ){
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4] = 255;
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+1] = 255;
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+2] = 255;
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+3] = 255;
}else{
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4] = 0;
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+1] = 0;
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+2] = 0;
myLetterPixels[(((int)(i/16))*16*16*16+(i%16)*16 + (j-1)*16*16 + k)*4+3] = 0;
}
}
}
}
bitmappedFontTexture.loadData(myLetterPixels);
bitmappedFontTexture.setTextureMinMagFilter(GL_LINEAR,GL_NEAREST);
charMesh.setMode(OF_PRIMITIVE_TRIANGLES);
}
}
示例12: setup
//--------------------------------------------------------------
void testApp::setup(){
// ofSetFrameRate(60);
ofBackground(0, 0, 0);
glDisable(GL_DEPTH_TEST);
float w = 720; //ofGetWidth();
float h = 720; //ofGetHeight();
// renderFbo.allocate(ofGetWidth() * 0.75, ofGetHeight() * 0.75, GL_RGBA32F);
renderFbo.allocate(w, h, GL_RGBA32F);
renderFbo.getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
// renderFbo.getTextureReference().setTextureWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER);
parts_res = (int)sqrt((float)numParticles);
numParticles = parts_res * parts_res;
float * parts_buf = new float[numParticles * 4];
for (int x = 0; x < parts_res; x++) {
for (int y = 0; y < parts_res; y++) {
int i = x * parts_res + y;
parts_buf[i * 4 + 0] = ofRandom(0.0, w-1);
parts_buf[i * 4 + 1] = ofRandom(0.0, h-1);
parts_buf[i * 4 + 2] = ofRandom(0.0, part_life);
parts_buf[i * 4 + 3] = 0.0;
/* pos is now an index into the postion map fbo */
pos[i][0] = x;
pos[i][1] = y;
pos[i][2] = 0;
}
}
parts_vbo.setVertexData((ofVec3f *)&pos[0], numParticles, GL_STATIC_DRAW);
randtex.allocate(parts_res, parts_res, GL_RGBA32F);
randtex.setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
randtex.loadData(parts_buf, parts_res, parts_res, GL_RGBA);
partsFbo.allocate(parts_res, parts_res, GL_RGBA32F);
partsFbo.src->getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
partsFbo.dst->getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
partsFbo.src->getTextureReference().loadData(parts_buf, parts_res, parts_res, GL_RGBA);
partsFbo.dst->getTextureReference().loadData(parts_buf, parts_res, parts_res, GL_RGBA);
// partsFbo.src->getTextureReference().setTextureWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER);
// partsFbo.dst->getTextureReference().setTextureWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER);
delete[] parts_buf;
colorFbo.allocate(parts_res, parts_res, GL_RGBA32F);
colorFbo.src->getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
colorFbo.dst->getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
// colorFbo.src->getTextureReference().setTextureWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER);
// colorFbo.dst->getTextureReference().setTextureWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER);
colorShader.load("", "color.frag");
velFbo.allocate(parts_res, parts_res, GL_RGBA32F);
velFbo.src->getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
velFbo.dst->getTextureReference().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);
// velFbo.src->getTextureReference().setTextureWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER);
// velFbo.dst->getTextureReference().setTextureWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER);
velshader.load("", "velocity.frag");
partshader.load("particle.vert", "");
posshader.load("", "position.frag");
debugShader.load("", "debug.frag");
debugFbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA32F);
w = h = renderFbo.getHeight();//720;//ofGetHeight();
dja.setup(w, h, 200);
dja.logmaxd = 5.0;
dja.setZoom(zoom);
dja.setParam(0.5 * PI, 0.5 * PI, -0.5 * PI, -0.5 * PI);
dja.update();
randmap_rebuild(-1.0, 1.0);
needDraw = true;
blur = new ofxBlur();
// blur->setup(ofGetWidth(), ofGetHeight());
blur->setup(renderFbo.getWidth(), renderFbo.getHeight());
blur->setScale(blur_scale);
// printf("setup: blur dim %.0f %.0f\n", blur.getTextureReference().getWidth(), blur.getTextureReference().getHeight());
cf.setup(renderFbo.getWidth(), renderFbo.getHeight());
cf.setScale(0.5);
cf.build(dja.getTextureReference());
// cf.setScale(curl_scale);
//at some stage set inital vels cause atm it looks not so good when it starts
velFbo.src->begin();
ofClear(ofFloatColor(0.0, 0.0, -1.0, 1.0));
velFbo.src->end();
width_offset = (int)((renderFbo.getWidth() - dja.getWidth()) / 2.0);
//.........这里部分代码省略.........
示例13: setup
//--------------------------------------------------------------
void testApp::setup(){
ofBackground(0);
ofSetFrameRate(30);
ofEnableAlphaBlending();
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glEnable(GL_DEPTH_TEST);
glPointSize(1.0);
drawFBO = false;
autoRotate = true;
drawEQ = false;
//not really needed
// glEnable(GL_ALPHA_TEST);
// glAlphaFunc(GL_GREATER, 0.10f);
//generate the mesh points
buildSphereMesh(rad, res, vm);
cout << "nverts: " << vm.getNumVertices() << endl;
cout << "arb: " << ofGetUsingArbTex() << ", norm: " << ofGetUsingNormalizedTexCoords() << endl;
//load the texture shader
shader.load("tex.vert", "tex.frag");
//fft init
fftSmoothed = new float[8192];
memset(fftSmoothed, 0x00, sizeof(float) * 8192);
//map the frequencies to bark bands
float freq_spc = FREQ_MAX / (float)SPECTRAL_BANDS;
for (int i = 0; i < SPECTRAL_BANDS; i++) {
int bidx = bark(i * freq_spc);
barkmap[i] = bidx;
}
//load the position updating frag shader
pos_shader.load("", "position.frag");
//for the sphere we set this to the resolution which = #of verts along each axis
fbo_res = res;
//init the fbo's with blank data
vector<ofVec3f> fbo_init_data;
fbo_init_data.assign(fbo_res * fbo_res, ofVec3f(0.0, 0.0, 0.0));
posbuf.allocate(fbo_res, fbo_res, GL_RGB32F);
posbuf.src->getTextureReference().loadData((float *)&fbo_init_data[0], fbo_res, fbo_res, GL_RGB);
posbuf.dst->getTextureReference().loadData((float *)&fbo_init_data[0], fbo_res, fbo_res, GL_RGB);
//reuse fbo_init_data for no real reason, it just needs to be blank
eq_tex.allocate(fbo_res, 1, GL_RGB32F_ARB);
eq_tex.loadData((float *)&fbo_init_data[0], fbo_res, 1, GL_RGB);
axis_loc = fbo_res;
angincr = 180.0/(float)fbo_res;
player.loadSound("jhfd.mp3");
player.play(); //go
}
示例14: update
//--------------------------------------------------------------
void testApp::update(){
/* get the spectral data */
float * val = ofSoundGetSpectrum(nBandsToGet);
for (int i = 0; i < nBandsToGet; i++){
// let the smoothed calue sink to zero:
fftSmoothed[i] *= 0.96f;
// take the max, either the smoothed or the incoming:
if (fftSmoothed[i] < val[i])
fftSmoothed[i] = val[i];
if (fftSmoothed[i] > fftmax) {
fftmax = fftSmoothed[i];
}
}
/* update our bark map'd frequency bins */
memset(bins, 0x00, sizeof(bins));
for (int i = 0; i < SPECTRAL_BANDS; i++) {
int idx = barkmap[i];
bins[idx] += fftSmoothed[i] * 20;
}
/* put the eq vals into a path to turn them into a curve */
int line_len = fbo_res;
float ppseg = line_len /(float)(BARK_MAX+1);
eq_path.clear();
eq_path.curveTo(0, -bins[0]);
for (int i = 0; i < BARK_MAX; i++) {
// bins[i] = max(5.0f, bins[i]); //set a lower bound on the bin val
eq_path.curveTo(i * ppseg, -bins[i]);
}
// eq_path.curveTo(BARK_MAX * ppseg, -bins[0]);
// eq_path.curveTo(BARK_MAX * ppseg, -bins[0]);
//smooth this out a little at the end so the eq texture wraps, 25 = BARK_MAX
eq_path.curveTo(25 * ppseg, -(bins[0] + bins[24] + bins[23] + bins[22])/4.0f);
eq_path.curveTo(26 * ppseg, -bins[0]);
eq_path.curveTo(26 * ppseg, -bins[0]);
ofMesh eq_m = eq_path.getTessellation();
//load up the eq curve into a texture
eq_tex.loadData((float *)eq_m.getVerticesPointer(), fbo_res, 1, GL_RGB);
//update where on the axis we will apply the latest eq data
axis_loc--;
if (axis_loc < 0)
axis_loc = fbo_res;
//use fbo to work out displacement coeffcients
posbuf.dst->begin();
ofClear(0);
pos_shader.begin();
pos_shader.setUniformTexture("u_prevDisp", posbuf.src->getTextureReference(), 0);
pos_shader.setUniformTexture("u_newDisp", eq_tex, 1); //pass the new displacement data
pos_shader.setUniform1f("u_axisloc", axis_loc);
pos_shader.setUniform1f("u_decayRate", posdecayrate);
ofSetColor(255, 255, 255, 255);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex3f(0, 0, 0);
glTexCoord2f(fbo_res, 0); glVertex3f(fbo_res, 0, 0);
glTexCoord2f(fbo_res, fbo_res); glVertex3f(fbo_res, fbo_res, 0);
glTexCoord2f(0, fbo_res); glVertex3f(0, fbo_res, 0);
glEnd();
pos_shader.end();
posbuf.dst->end();
posbuf.swap();
}