Hi everyone,
I’m diving deeper into the gl world of vbos, shaders, textures, etc., and I’m getting caught on a few different problems. I’ve made simple examples out of the problems to try to clarify the process. The first problem is pretty basic: I cant get a texture with an alpha layer textured to a vbo mesh (*note i’m using ofVbo NOT ofVboMesh*).
Here’s the code, hopefully someone can tell me what I’m missing. Thanks in advance.
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ofBackground(0, 0, 0);
shader.setupShaderFromFile(GL_VERTEX_SHADER, "Billboard.vert");
shader.setupShaderFromFile(GL_FRAGMENT_SHADER, "Billboard.frag");
shader.linkProgram();
float s = 100;
mesh.addVertex(ofVec3f(-s,s,0));
mesh.addVertex(ofVec3f(s,s,0));
mesh.addVertex(ofVec3f(s,-s,0));
mesh.addVertex(ofVec3f(-s,-s,0));
vbo.setMesh(mesh, GL_STATIC_DRAW);
texture.loadImage("dot.png");
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
ofEnableAlphaBlending();
cam.begin();
shader.begin();
texture.getTextureReference().bind();
vbo.draw(GL_QUADS,0,4);
texture.getTextureReference().unbind();
shader.end();
cam.end();
texture.draw(30, 80);
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
#pragma once
#include "ofMain.h"
class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed (int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofShader shader;
ofMesh mesh;
ofVbo vbo;
ofEasyCam cam;
ofImage texture;
};