Oh I am a big turnip!
Ok heres the code:
/* Using the standard output for fprintf */
#include <stdio.h>
#include <stdlib.h>
/* Use glew.h instead of gl.h to get all the GL prototypes declared */
#include <glew.h>
/* Using the GLUT library for the base windowing setup */
#include <glut.h>
/* ADD GLOBAL VARIABLES HERE LATER */
int init_resources(void)
{
/* FILLED IN LATER */
return 1;
}
void onDisplay()
{
/* FILLED IN LATER */
}
void free_resources()
{
/* FILLED IN LATER */
}
int main(int argc, char* argv[])
{
/* Glut-related initialising functions */
glutInit(&argc, argv);
glutInitContextVersion(2,0);
glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutCreateWindow("My First Triangle");
/* Extension wrangler initialising */
GLenum glew_status = glewInit();
if (glew_status != GLEW_OK)
{
fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status));
return EXIT_FAILURE;
}
/* When all init functions run without errors,
the program can initialise the resources */
if (1 == init_resources())
{
/* We can display it if everything goes OK */
glutDisplayFunc(onDisplay);
glutMainLoop();
}
/* If the program exits in the usual way,
free resources and exit with a success */
free_resources();
return EXIT_SUCCESS;
}
and here are the errors: http://imgur.com/H2R00O9
(isnt there a way to just COPY AND PASTE the darn text from the build messages screen????????)
I installed glut as like the readme.txt file said:
* Put the .dll in system32 directory
* put the .h file in "CodeBlocks\MinGW\include" and "CodeBlocks\MinGW\include\GL"
* put the .lib "CodeBlocks\MinGW\lib"
Restarted program and the code, and it gives those errors...
Ok heres the build log:
-------------- Build: Debug in GL_PROJ (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -o bin\Debug\GL_PROJ.exe obj\Debug\main.o -lopengl32 -lglu32 -lgdi32 "..\..\..\..\..\..\Program Files (x86)\CodeBlocks\MinGW\lib\glut32.lib"
obj\Debug\main.o: In function `glutInit_ATEXIT_HACK':
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../include/glut.h:486: undefined reference to `__glutInitWithExit'
obj\Debug\main.o: In function `glutCreateWindow_ATEXIT_HACK':
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../include/glut.h:503: undefined reference to `__glutCreateWindowWithExit'
obj\Debug\main.o: In function `glutCreateMenu_ATEXIT_HACK':
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../include/glut.h:549: undefined reference to `__glutCreateMenuWithExit'
obj\Debug\main.o: In function `main':
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:31: undefined reference to `glutInitContextVersion'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:32: undefined reference to `glutInitDisplayMode'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:33: undefined reference to `glutInitWindowSize'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:37: undefined reference to `_imp__glewInit@0'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:40: undefined reference to `_imp__glewGetErrorString@4'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:49: undefined reference to `glutDisplayFunc'
C:/Users/Beasty/Desktop/CODE BLOCKS/Tutorials/GL_PROJ/main.c:50: undefined reference to `glutMainLoop'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
10 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Ok so i downloaded and installed freeglut, no problem, it ran the default code with the spinny red objects, great stuff.... then when trying to use the other code, it wouldnt work:
(this is the very first example code from here: http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Introduction)
/* Using the standard output for fprintf */
#include <stdio.h>
#include <stdlib.h>
/* Use glew.h instead of gl.h to get all the GL prototypes declared */
#include <glew.h>
/* Using the GLUT library for the base windowing setup */
#include <glut.h>
/* ADD GLOBAL VARIABLES HERE LATER */
int init_resources(void)
{
/* FILLED IN LATER */
return 1;
}
void onDisplay()
{
/* FILLED IN LATER */
}
void free_resources()
{
/* FILLED IN LATER */
}
int main(int argc, char* argv[])
{
/* Glut-related initialising functions */
glutInit(&argc, argv);
glutInitContextVersion(2,0);
glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutCreateWindow("My First Triangle");
/* Extension wrangler initialising */
GLenum glew_status = glewInit();
if (glew_status != GLEW_OK)
{
fprintf(stderr, "Error: %s\n", glewGetErrorString(glew_status));
return EXIT_FAILURE;
}
/* When all init functions run without errors,
the program can initialise the resources */
if (1 == init_resources())
{
/* We can display it if everything goes OK */
glutDisplayFunc(onDisplay);
glutMainLoop();
}
/* If the program exits in the usual way,
free resources and exit with a success */
free_resources();
return EXIT_SUCCESS;
}
It gives an error:
mingw32-g++.exe -Wall -g -I"C:\Program Files (x86)\CodeBlocks\MinGW\include" -c "C:\Users\Beasty\Desktop\CODE BLOCKS\Tutorials\Yoolloooo\main.cpp" -o obj\Debug\main.o
C:\Users\Beasty\Desktop\CODE BLOCKS\Tutorials\Yoolloooo\main.cpp: In function 'int main(int, char**)':
C:\Users\Beasty\Desktop\CODE BLOCKS\Tutorials\Yoolloooo\main.cpp:30:29: error: 'glutInitContextVersion' was not declared in this scope
What's this mean and how can it be fixed?
I also now have another query in relation to this website:
http://en.wikibooks.org/wiki/OpenGL_Programming#The_basics_arc
From an example page i found a link to the source code for the examples and decided to download it. I was sure that if ever anything was ever even remotely possible to fluke and work, it would be with fully working examples which had been set up by an expert that I could just open and run.
FYI, the download link page is here: https://gitorious.org/wikibooks-opengl/modern-tutorials/source/90bf72991caf34ea6cdbed044a9616b7bbdf2d0f:
Unfortunately (as expected), they did not work, none of them, from the simplest code to the more complex stuff, compile errors everywhere (usually starting with "___IMP___" for some reason), Here's the build log for tut01_intro\triangle.cpp:
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x1c): undefined reference to `_imp____glutInitWithExit@12'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x3e): undefined reference to `_imp____glutCreateWindowWithExit@8'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x60): undefined reference to `_imp____glutCreateMenuWithExit@8'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0xb1): undefined reference to `_imp____glewCreateShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0xd5): undefined reference to `_imp____glewShaderSource'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0xfe): undefined reference to `_imp____glewCompileShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x110): undefined reference to `_imp____glewGetShaderiv'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x16a): undefined reference to `_imp____glewCreateShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x18e): undefined reference to `_imp____glewShaderSource'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x1b7): undefined reference to `_imp____glewCompileShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x1c9): undefined reference to `_imp____glewGetShaderiv'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x223): undefined reference to `_imp____glewCreateProgram'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x238): undefined reference to `_imp____glewAttachShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x253): undefined reference to `_imp____glewAttachShader'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x26e): undefined reference to `_imp____glewLinkProgram'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x282): undefined reference to `_imp____glewGetProgramiv'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x2e2): undefined reference to `_imp____glewGetAttribLocation'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x3d0): undefined reference to `glClearColor@16'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x3df): undefined reference to `glClear@4'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x3e7): undefined reference to `_imp____glewUseProgram'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x3fb): undefined reference to `_imp____glewEnableVertexAttribArray'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x424): undefined reference to `_imp____glewVertexAttribPointer'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x476): undefined reference to `glDrawArrays@12'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x47e): undefined reference to `_imp____glewDisableVertexAttribArray'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x492): undefined reference to `_imp__glutSwapBuffers@0'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x4c9): undefined reference to `_imp____glewDeleteProgram'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x519): undefined reference to `_imp__glutInitContextVersion@8'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x52a): undefined reference to `_imp__glutInitDisplayMode@4'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x543): undefined reference to `_imp__glutInitWindowSize@8'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x55c): undefined reference to `_imp__glewInit@0'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x572): undefined reference to `_imp__glewGetErrorString@4'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x5b4): undefined reference to `_imp__glutDisplayFunc@4'
...\tut01_intro\triangle.o:triangle.cpp:(.text+0x5be): undefined reference to `_imp__glutMainLoop@0'
glut (freeglut is installed), glew is installed, GLM is installed now as well. What else needs to be installed?
For the record I have not edited the code at all. I literally just opened codeblocks, opened the .cpp file and ran it. No adjustments.
Can anyone confirm that any of the code from the above site works at all? I'm starting to think its actually not me now...
If anyone can make any of this code run, please advise what else is needed to be installed in codeblocks...