本文整理汇总了C++中ofImage::getTextureReference方法的典型用法代码示例。如果您正苦于以下问题:C++ ofImage::getTextureReference方法的具体用法?C++ ofImage::getTextureReference怎么用?C++ ofImage::getTextureReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofImage
的用法示例。
在下文中一共展示了ofImage::getTextureReference方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeMasked
void testApp::makeMasked(ofImage mask, ofImage toBeMasked){
// if you want blurrier outlines, try smaller numbers, fewer cycles than blurring.
// mask.resize(40,30);
mask.resize(80,60);
mask.resize(WIDTH,HEIGHT);
makeMe.setFromPixels(toBeMasked.getPixels(),WIDTH,HEIGHT,OF_IMAGE_COLOR);
//then draw a quad for the top layer using our composite shader to set the alpha
maskShader.begin();
//our shader uses two textures, the top layer and the alpha
//we can load two textures into a shader using the multi texture coordinate extensions
glActiveTexture(GL_TEXTURE0_ARB);
makeMe.getTextureReference().bind();
glActiveTexture(GL_TEXTURE1_ARB);
mask.getTextureReference().bind();
//draw a quad the size of the frame
glBegin(GL_QUADS);
glMultiTexCoord2d(GL_TEXTURE0_ARB, 0, 0);
glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, 0);
glVertex2f( 0, 0);
glMultiTexCoord2d(GL_TEXTURE0_ARB, WIDTH, 0);
glMultiTexCoord2d(GL_TEXTURE1_ARB, WIDTH, 0);
glVertex2f( ofGetWidth(), 0);
glMultiTexCoord2d(GL_TEXTURE0_ARB, WIDTH, HEIGHT);
glMultiTexCoord2d(GL_TEXTURE1_ARB, WIDTH, HEIGHT);
glVertex2f( ofGetWidth(), ofGetHeight());
glMultiTexCoord2d(GL_TEXTURE0_ARB, 0, HEIGHT);
glMultiTexCoord2d(GL_TEXTURE1_ARB, 0, HEIGHT);
glVertex2f( 0, ofGetHeight());
glEnd();
//deactive and clean up
glActiveTexture(GL_TEXTURE1_ARB);
mask.getTextureReference().unbind();
//mask.unbind();
glActiveTexture(GL_TEXTURE0_ARB);
makeMe.getTextureReference().unbind();
maskShader.end();
}
示例2: setTexture
void testApp::setTexture(char* name, ofxShader& shader, ofImage& img, int location) {
ofTextureData texData = img.getTextureReference().getTextureData();
glActiveTexture(GL_TEXTURE0 + location);
glEnable(texData.textureTarget);
glBindTexture(texData.textureTarget, texData.textureID);
glDisable(texData.textureTarget);
shader.setUniform(name, location);
}
示例3: glGetUniformLocation
void ofxShader::setSampler2d(string name, ofImage& img, int textureLocation) {
if(bLoaded) {
GLint uniformLocation = glGetUniformLocation((GLuint) shader, name.c_str());
glUniform1i(uniformLocation, textureLocation);
glActiveTexture(GL_TEXTURE0 + textureLocation);
img.getTextureReference().bind();
}
}
示例4: draw
//----------------------------------------------------------
void ofGLRenderer::draw(ofImage & image, float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh){
if(image.isUsingTexture()){
ofTexture& tex = image.getTextureReference();
if(tex.bAllocated()) {
tex.drawSubsection(x,y,z,w,h,sx,sy,sw,sh);
} else {
ofLogWarning() << "ofGLRenderer::draw(): texture is not allocated";
}
}
}
示例5: draw
//----------------------------------------------------------
void ofGLRenderer::draw(const ofImage & image, float x, float y, float z, float w, float h, float sx, float sy, float sw, float sh) const{
if(image.isUsingTexture()){
const ofTexture& tex = image.getTextureReference();
if(tex.bAllocated()) {
tex.drawSubsection(x,y,z,w,h,sx,sy,sw,sh);
} else {
ofLogWarning("ofGLRenderer") << "drawing an unallocated texture";
}
}
}
示例6: draw
void ofxQuad::draw(ofImage image,int sx,int sy,int sw,int sh,int num){
// ofSetColor(255, 255, 255);
if(moveall == 1){
if(quadMesh.getNumVertices() < 4){
quadMesh.draw();
}
}
ofTexture bb;
bb = image.getTextureReference();
ofPushMatrix();
// find transformation matrix
findHomography(src, dst, matrix);
//finally lets multiply our matrix
glMultMatrixf(matrix);
bb.drawSubsection(0,0,w,h,sx,sy,sw,sh);
if(debug){
if(active){
ofSetColor(redColour, 255, 0,255);
}
else{
ofSetColor(255, 255, 255,255);
}
// ofDrawBitmapString(ofToString(num), sw,sy);
ofRect(0,0,w,h);
// verdana30.drawString(ofToString(num), sx,sh+sh);
ofSetColor(0, 0, 0);
}
ofPopMatrix();
if(debug){
ofPushStyle();
ofSetColor(255, 255, 255);
ofSetLineWidth(4);
ofLine(0, ofGetMouseY(), ofGetWidth(), ofGetMouseY());
ofLine(ofGetMouseX(), 0, ofGetMouseX(), ofGetHeight());
ofPopStyle();
}
}
示例7: update
// ---------------------------------------------------------------------------------------
//
void update()
{
float time = ofGetElapsedTimef();
ocl.begin();
cl::ImageGL cl_destImage;
ofxCL::convert( destImage.getTextureReference(), cl_destImage );
ofxCL::Kernel::Ref noiseKernel = noiseProgram.getKernel( methodNames.at(methodIndex) );
noiseKernel->global( destImage.getWidth(), destImage.getHeight() );
float t = time * 0.1f;
// ofParameters do not seem to get passed on correctly. Todo: avoid this workaround.
float tmpLacunarity = Lacunarity;
float tmpIncrement = Increment;
float tmpOctaves = Octaves;
float tmpAmplitude = Amplitude;
ofVec2f bias(0,0);
if( AutoMove )
{
bias.x = ofSignedNoise( t, t * -0.30f ) * AutoMoveMagnitude;
bias.y = ofSignedNoise( -t, t * 0.33f ) * AutoMoveMagnitude;
}
float tmpScale = Scale * ScaleMultiplier;
if( methodIndex == 0 )
{
noiseKernel->call( cl_destImage, bias, ofVec2f(tmpScale,tmpScale), tmpAmplitude );
}
else
{
noiseKernel->call( cl_destImage, bias, ofVec2f(tmpScale,tmpScale), tmpLacunarity, tmpIncrement, tmpOctaves, tmpAmplitude );
}
ocl.end();
}
示例8: draw
//----------------------------------------------------------
void ofGLRenderer::draw(ofImage & image, float x, float y, float z, float w, float h){
if(image.isUsingTexture()){
image.getTextureReference().draw(x,y,z,w,h);
}
}
示例9: draw
//--------------------------------------------------------------
void testApp::draw() {
if(doRender) {
ofEnableAlphaBlending();
glEnable(GL_DEPTH_TEST);
glPushMatrix();
glTranslatef(width/2, 0, -width / 3); // center scene
static float rot = 0;
glRotatef(rot, 0, 1, 0); // rotate scene
rot += rotSpeed; // slowly increase rotation (to get a good 3D view)
if(forceTimer) {
float translateMax = forceTimer;
glTranslatef(ofRandom(-translateMax, translateMax), ofRandom(-translateMax, translateMax), ofRandom(-translateMax, translateMax));
forceTimer--;
}
glDisable(GL_LIGHTING);
glBegin(GL_QUADS);
// draw right wall
glColor3f(.9, 0.9, 0.9); glVertex3f(width/2, height+1, width/2);
glColor3f(1, 1, 1); glVertex3f(width/2, -height, width/2);
glColor3f(0.95, 0.95, 0.95); glVertex3f(width/2, -height, -width/2);
glColor3f(.85, 0.85, 0.85); glVertex3f(width/2, height+1, -width/2);
// back wall
glColor3f(.9, 0.9, 0.9); glVertex3f(width/2, height+1, -width/2);
glColor3f(1, 1, 1); glVertex3f(width/2, -height, -width/2);
glColor3f(0.95, 0.95, 0.95); glVertex3f(-width/2, -height, -width/2);
glColor3f(.85, 0.85, 0.85); glVertex3f(-width/2, height+1, -width/2);
// left wall
glColor3f(.9, 0.9, 0.9); glVertex3f(-width/2, height+1, -width/2);
glColor3f(1, 1, 1); glVertex3f(-width/2, -height, -width/2);
glColor3f(0.95, 0.95, 0.95); glVertex3f(-width/2, -height, width/2);
glColor3f(.85, 0.85, 0.85); glVertex3f(-width/2, height+1, width/2);
// front wall
glColor3f(0.95, 0.95, 0.95); glVertex3f(width/2, -height, width/2);
glColor3f(.85, 0.85, 0.85); glVertex3f(width/2, height+1, width/2);
glColor3f(.9, 0.9, 0.9); glVertex3f(-width/2, height+1, width/2);
glColor3f(1, 1, 1); glVertex3f(-width/2, -height, width/2);
// floor
glColor3f(.8, 0.8, 0.8);
glVertex3f(width/2, height+1, width/2);
glVertex3f(width/2, height+1, -width/2);
glVertex3f(-width/2, height+1, -width/2);
glVertex3f(-width/2, height+1, width/2);
glEnd();
// glEnable(GL_LIGHTING);
// draw springs
glColor4f(0.5, 0.5, 0.5, 0.5);
for(int i=0; i<physics.numberOfSprings(); i++) {
ofxMSASpring *spring = (ofxMSASpring *) physics.getSpring(i);
ofxMSAParticle *a = spring->getOneEnd();
ofxMSAParticle *b = spring->getTheOtherEnd();
ofPoint vec = b->getPosition() - a->getPosition();
float dist = msaLength(vec);
float angle = acos( vec.z / dist ) * RAD_TO_DEG;
if(vec.z <= 0 ) angle = -angle;
float rx = -vec.y * vec.z;
float ry = vec.x * vec.z;
glPushMatrix();
glTranslatef(a->getX(), a->getY(), a->getZ());
glRotatef(angle, rx, ry, 0.0);
float size = ofMap(spring->strength, SPRING_MIN_STRENGTH, SPRING_MAX_STRENGTH, SPRING_MIN_WIDTH, SPRING_MAX_WIDTH);
glScalef(size, size, dist);
glTranslatef(0, 0, 0.5);
glutSolidCube(1);
glPopMatrix();
}
// draw particles
glAlphaFunc(GL_GREATER, 0.5);
ofEnableNormalizedTexCoords();
ballImage.getTextureReference().bind();
for(int i=0; i<physics.numberOfParticles(); i++) {
ofxMSAParticle *p = physics.getParticle(i);
if(p->isFixed()) glColor4f(1, 0, 0, 1);
else glColor4f(1, 1, 1, 1);
glEnable(GL_ALPHA_TEST);
// draw ball
glPushMatrix();
glTranslatef(p->getX(), p->getY(), p->getZ());
glRotatef(180-rot, 0, 1, 0);
// glutSolidSphere(p->getRadius(), 2, 2);
//.........这里部分代码省略.........
示例10: setup
//--------------------------------------------------------------
void testApp::setup(){
img.loadImage("fill.png");
ktex.setTexture(img.getTextureReference());
}
示例11: draw
//--------------------------------------------------------------
void testApp::draw(){
glPushMatrix();
glTranslatef(ofGetWidth()/2, 0, 0);
glRotatef(currentRot, 0, 1, 0);
ofSetColor(255);
glEnable(GL_DEPTH_TEST);
glPointSize(pointSize);
if(useTexture) image.getTextureReference().bind(); // new in OF006
if(useSprite) {
glEnable(GL_POINT_SPRITE);
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
}
switch(drawMode) {
case kModeVA:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, pos);
glColorPointer(4, GL_FLOAT, 0, col);
glDrawArrays(GL_POINTS, 0, numParticles);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
break;
case kModeVBO:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo[0]);
glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, numParticles * 3 * sizeof(float), pos);
glVertexPointer(3, GL_FLOAT, 0, 0);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo[1]);
glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, numParticles * 4 * sizeof(float), col);
glColorPointer(4, GL_FLOAT, 0, 0);
glDrawArrays(GL_POINTS, 0, numParticles);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
break;
case kModeNormal:
default:
glBegin(GL_POINTS);
for(int i=0; i<numParticles; i++) {
glColor4f(col[i][0], col[i][1], col[i][2], col[i][3]);
glVertex3f(pos[i][0], pos[i][1], pos[i][2]);
}
glEnd();
}
if(useTexture) image.getTextureReference().unbind(); // new in OF006
if(useSprite) {
glDisable(GL_POINT_SPRITE);
}
glDisable(GL_DEPTH_TEST);
glPopMatrix();
// black rectangle for text
ofSetColor(0);
ofRect(0, 0, 200, 200);
ofSetColor(255);
ofDrawBitmapString("FPS: " + ofToString(ofGetFrameRate(), 2) + "\n" +
"numParticles: " + ofToString(numParticles) + "\n" +
"immediate mode (1): " + (drawMode == kModeNormal ? "X" : "") + "\n" +
"useVA (2): " + (drawMode == kModeVA ? "X" : "") + "\n" +
"useVBO (3): " + (drawMode == kModeVBO ? "X" : "") + "\n" +
"useTexture (t): " + (useTexture ? "X" : "") + "\n" +
"useSprite (s): " + (useSprite ? "X" : "") + "\n" +
"vsync (v): " + (vsync ? "X" : "") + "\n" +
"pointSize []: " + ofToString(pointSize)
, 20, 20);
}