Yeah With intro Jucer , create an openGLApplication and define JUCE_OPENGL3. Then open a Visual Studio 13 project and replace the MainComponent.cpp with this:
/*
==============================================================================
This file was auto-generated!
==============================================================================
*/
#ifndef MAINCOMPONENT_H_INCLUDED
#define MAINCOMPONENT_H_INCLUDED
#include "../JuceLibraryCode/JuceHeader.h"
#include <memory>
float points[] = {
0.0f, 0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
-0.5f, -0.5f, 0.0f
};
const char* vertex_shader =
"#version 150\n"
"in vec3 vp;"
"void main () {"
" gl_Position = vec4 (vp, 1.0);"
"}";
const char* fragment_shader =
"#version 150\n"
"out vec4 frag_colour;"
"void main () {"
" frag_colour = vec4 (0.5, 0.0, 0.5, 1.0);"
"}";
//==============================================================================
/*
This component lives inside our window, and this is where you should put all
your controls and content.
*/
class MainContentComponent : public OpenGLAppComponent
{
public:
//==============================================================================
MainContentComponent()
{
setSize (800, 600);
openGLContext.setOpenGLVersionRequired(OpenGLContext::openGL3_2);
}
~MainContentComponent()
{
shutdownOpenGL();
}
void initialise() override
{
//load shaders
program = std::make_shared<OpenGLShaderProgram>(openGLContext);
program->addVertexShader(vertex_shader);
program->addFragmentShader(fragment_shader);
program->link();
positionA = std::make_shared<OpenGLShaderProgram::Attribute>(*program,"vp");
// create vertex buffer
openGLContext.extensions.glGenBuffers (1, &vbo);
openGLContext.extensions.glBindBuffer (GL_ARRAY_BUFFER, vbo);
openGLContext.extensions.glBufferData (GL_ARRAY_BUFFER, 9 * sizeof (float), points, GL_STATIC_DRAW);
openGLContext.extensions.glBindBuffer(GL_ARRAY_BUFFER, 0);
// create vao object
glGenVertexArrays (1, &vao);
glBindVertexArray (vao);
openGLContext.extensions.glEnableVertexAttribArray (0);
openGLContext.extensions.glBindBuffer (GL_ARRAY_BUFFER, vbo);
openGLContext.extensions.glVertexAttribPointer (0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
openGLContext.extensions.glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
void shutdown() override
{
openGLContext.extensions.glDeleteBuffers(1, &vbo);
glDeleteVertexArrays(1, &vao);
}
void render() override
{
OpenGLHelpers::clear (Colours::black);
glBindVertexArray(vao);
program->use();
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
}
void paint (Graphics& g) override
{
// You can add your component specific drawing code here!
// This will draw over the top of the openGL background.
}
void resized() override
{
// This is called when the MainContentComponent is resized.
// If you add any child components, this is where you should
// update their positions.
}
private:
//==============================================================================
// private member variables
GLuint vao;
GLuint vbo;
std::shared_ptr<OpenGLShaderProgram> program;
std::shared_ptr<OpenGLShaderProgram::Attribute> positionA;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
};
// (This function is called by the app startup code to create our main component)
Component* createMainContentComponent() { return new MainContentComponent(); }
#endif // MAINCOMPONENT_H_INCLUDED
this code works on MAC OSX no problems but wont even complie on windows.