User forums > General (but related to Code::Blocks)
Strange Behaviour
Cybrid:
Well , I have this class created to do some basic OpenGL setup tasks, <GL/gl.h> and <GL/glu.h> are included in "glInit.h". Strangely I receive error: 'GLfloat' undeclared (first use this function) from compiler when trying to build.
I've already added -lopengl32 -lglu32 -gdi32 -user32 -kernel32 to "other option" in the linker tab of my project.
This is the code:
--- Code: (cpp) ---#include "glInit.h"
#pragma once
bool glInit::setupGL()
{
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
return true;
}
void glInit::changeSize(GLsizei width, GLsizei height)
{
GLfloat aspectRatio;
if(height==0){height=1;}
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
aspectRatio = (GLfloat)width / (GLfoat)height; //ERROR IS HERE
if(width<=height)
{
glOrtho(-100.0, 100.0, -100 / aspectRatio, 100.0 / aspectRatio, 1.0, -1.0);
}
else
{
glOrtho (-100.0 * aspectRatio, 100.0 * aspectRatio, -100.0, 100.0, 1.0, -1.0);
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
--- End code ---
Michael:
Hello,
Did you tried to add <GL/gl.h> and <GL/glu.h> directly? Does it works?
Just a question. Where should GLfloat be defined?
Best wishes,
Michael
Cybrid:
Yes, I've tried to add the headers directly and it didn't work. Responding to your question (I may be wrong) GLfloat is defined in gl.h .
Cybrid:
Any other Idea of what can be?. Maybe a C::B bug?
mandrav:
--- Quote from: Cybrid on February 15, 2006, 10:22:46 am ---Any other Idea of what can be?. Maybe a C::B bug?
--- End quote ---
Post the full build log (enable it first in global compiler options and then rebuild).
Navigation
[0] Message Index
[#] Next page
Go to full version