Im trying to compile the juce opengl demo in my own app but getting a few errors. I want to create a header file containing only the gl demo as below.
[code]
#ifndef GLCOMPONENT_H
#define GLCOMPONENT_H
#ifdef _WIN32
#include <windows.h>
#elif ! defined (LINUX)
#include <Carbon.h>
#include <Movies.h>
#endif
//#include “…/jucedemo_headers.h”
#if JUCE_OPENGL
#ifdef _WIN32
#include <gl/gl.h>
#include <gl/glu.h>
#ifdef _MSC_VER
#pragma comment(lib, “OpenGL32.Lib”)
#pragma comment(lib, “GlU32.Lib”)
#endif
#elif defined (LINUX)
#include <GL/gl.h>
#include <GL/glut.h>
#undef KeyPress
#else
#include <agl/agl.h>
#include <glut/glut.h>
#endif
#ifndef GL_BGRA_EXT
#define GL_BGRA_EXT 0x80e1
#endif
//==============================================================================
class DemoOpenGLCanvas : public OpenGLComponent,
public Timer
{
float rotation, delta;
Image* image;
public:
DemoOpenGLCanvas()
{
rotation = 0.0f;
delta = 1.0f;
Image* im = ImageFileFormat::loadFrom (BinaryData::juce_png, BinaryData::juce_pngSize);
image = new Image (Image::RGB, 512, 512, true);
Graphics g (*image);
g.fillAll (Colours::white);
g.drawImage (im, 0, 0, 512, 512, 0, 0, im->getWidth(), im->getHeight());
delete im;
startTimer (20);
}
~DemoOpenGLCanvas()
{
delete image;
}
// when the component creates a new internal context, this is called, and
// we'll use the opportunity to create the textures needed.
void newOpenGLContextCreated()
{
// (no need to call makeCurrentContextActive(), as that will have
// been done for us before the method call).
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth (1.0);
glDepthFunc (GL_LESS);
glEnable (GL_DEPTH_TEST);
glEnable (GL_TEXTURE_2D);
glEnable (GL_BLEND);
glShadeModel (GL_SMOOTH);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
int stride, pixStride;
const void* pixels = image->lockPixelDataReadOnly (0, 0, image->getWidth(), image->getHeight(), stride, pixStride);
glTexImage2D (GL_TEXTURE_2D, 0, 4, image->getWidth(), image->getHeight(),
0, GL_RGB,
GL_UNSIGNED_BYTE, pixels);
image->releasePixelDataReadOnly (pixels);
glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
glHint (GL_POINT_SMOOTH_HINT, GL_NICEST);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
void mouseDrag (const MouseEvent& e)
{
delta = e.getDistanceFromDragStartX() / 100.0f;
repaint();
}
void renderOpenGL()
{
glClearColor (0.8f, 0.0f, 0.4f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho (0.0, getWidth(), 0.0, getHeight(), 0, 1);
glColor4f (1.0f, 1.0f, 1.0f, fabsf (sinf (rotation / 100.0f)));
glBegin(GL_QUADS);
glTexCoord2i (0, 0); glVertex2f (50.0f, getHeight() - 50.0f);
glTexCoord2i (1, 0); glVertex2f (getWidth() - 50.0f, getHeight() - 50.0f);
glTexCoord2i (1, 1); glVertex2f (getWidth() - 50.0f, 50.0f);
glTexCoord2i (0, 1); glVertex2f (50.0f, 50.0f);
glEnd();
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glClear (GL_DEPTH_BUFFER_BIT);
gluPerspective (45.0f,
getWidth() / (GLfloat) getHeight(),
0.1f,
100.0f);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
glTranslatef (0.0f, 0.0f, -5.0f);
glRotatef (rotation, 0.5f, 1.0f, 0.0f);
glBegin (GL_QUADS);
glColor3f (0.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glColor3f (1.0f, 0.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glColor3f (0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
glColor3f (1.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glColor3f (0.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glColor3f (1.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glEnd();
glPopMatrix();
}
void timerCallback()
{
rotation += delta;
repaint();
}
};
#endif
#endif[/code]
This is straight out of the Juce Demo and I can compile that no problems, however the above code gives me the following errors, all of them related to winnt.h
1>C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(894) : error C2988: unrecognizable template declaration/definition
1>C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(894) : error C2059: syntax error : '('
1>C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(894) : error C2090: function returns array
1>C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(894) : error C2988: unrecognizable template declaration/definition
1>C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(894) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(1454) : error C2143: syntax error : missing ';' before '*'
1>C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(2938) : error C2143: syntax error : missing ';' before 'identifier'
1>C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(2938) : warning C4091: 'typedef ' : ignored on left of '_FLOATING_SAVE_AREA' when no variable is declared
1>C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(2938) : fatal error C1075: end of file found before the left brace '{' at 'C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include\winnt.h(22)' was matched
I’ve tried lots of things but can’t seem to track down what the problem is, I want to keep the glcomponent as a seperate header file how can I do this