Reputation: 10147
I have an Invalid Image Format error which crops up from opengl. I'm not sure if it's because I'm using precompiled headers, or if I'm just not initializing OpenGL properly. As far as I know, I am not using C++/CLI (I chose to create an empty project in VC++ Express 2010). I'm running Windows7 (x64), and my error code is 0xc000007b
.
Is this common with OpenGL? I'm also using Glew, with Freeglut.
The weird thing is that I haven't tried at all to render an image or anything; I simply am trying to get a window to appear.
The Code
#include "stdafx.h"
#include "triangle.h"
#include "matrix3f.h"
static GLfloat move;
static GLfloat spin;
void init() {
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glShadeModel(GL_FLAT);
glPopMatrix();
glutSwapBuffers();
}
void draw_window() {
int height = 500;
double width = 1.9 * (double)height;
glutInitWindowSize((int)width, height);
glutInitWindowPosition(0, 0);
glutCreateWindow("opengl_03");
}
void spin_display() {
spin += 2.0;
if (spin > 360.0)
spin -= 360.0;
glutPostRedisplay();
}
void move_display() {
move += 1.0;
if (move > 10)
move -= 10;
glutPostRedisplay();
}
void keyboard(unsigned char button, int state, int x) {
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitContextVersion(3, 1);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
init();
draw_window();
//system("pause");
return 0;
}
What would also be interesting to know is how I have a bad image format from this. I've checked to make sure that my release is debug in the IDE, as well.
Question
My main question is to know exactly what I am doing wrong, if possible.
Update
I tried moving glew32.dll
to SysWOW64
, and unfortunately that did not work. I also tried the suggestion which involved moving my draw_window
function to the top of main, and that did not work either.
Upvotes: 2
Views: 895
Reputation: 10147
Problem solved.
Do not put freeglut.dll
into your SysWOW64
folder; rather, add it to your System32
folder.
At least, try the System32
folder first.
Upvotes: 2
Reputation: 283763
You might try using GLee instead of GLEW. Both perform the same function (looking up function pointers for OpenGL extension functions) but GLee focuses on ease of use, while GLEW is more powerful.
With GLee, you should get the latest version from subversion as the last released version is quite out of date. But all you need to do is include glee.h
and add glee.c
to your project. No DLLs needed. And GLee also loads extensions as you need them, it doesn't bog down your startup code trying to load thousands of extensions the way GLEW does.
Upvotes: 0
Reputation: 474076
You cannot call any OpenGL functions until after you have called glutCreateWindow
to create the OpenGL window. So take the contents of draw_window
and put them in main
before the call to init
.
Upvotes: 0