How to use glRenderer and draw a triangle with OpenGL(Beginner)

Hi there,
My question is simple how to use ofGLRenderer in my sketch ?
All i want is to draw a triangle with OpenGL.

#pragma once

#include "ofMain.h"

class ofApp : 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 mouseEntered(int x, int y);
	void mouseExited(int x, int y);
	void windowResized(int w, int h);
	void dragEvent(ofDragInfo dragInfo);
	void gotMessage(ofMessage msg);

	ofGLRenderer glr;
	
};

ofApp.cpp

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){

}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){
glr.drawTriangle(0, 0, 0, 1, 1, 1, 2, 2, 2);
}

I get (VS2015)
C2280 ‘ofApp::ofApp(void)’: attempting to reference a deleted function
Can I get some explanations to it ? How to call properly ofGLRenderer function , as drawTriangle() ? Where I can find documentation about using OF with OpenGL ?

Thanks !!!

OF automatically references renderer behind the scenes, so you can call OF’s draw functions directly.

ofDrawTriangle( 0, 0, 0, 1, 1, 1, 2, 2, 2);

Check out the grahicsExample project that comes with OF (examples/graphics/)

Also, OF will always default to drawing with openGL.

1 Like