glutDisplayFunc(); warning
in C
I get this warning in my OpenGl projects with my new compiler. I can fix the warning by putting void inside the OnDraw function call, but I am wondering if it is the wright thing to do. Is it?
Build started: Project: C, Configuration: Debug Win32
C.c
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(34): warning C4113: 'void (__cdecl *)()' differs in parameter lists from 'void (__cdecl *)(void)'
C.vcxproj -> C:\Users\Smjprogrammer\documents\visual studio 2013\Projects\C\Debug\C.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Build started: Project: C, Configuration: Debug Win32
C.c
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(34): warning C4113: 'void (__cdecl *)()' differs in parameter lists from 'void (__cdecl *)(void)'
C.vcxproj -> C:\Users\Smjprogrammer\documents\visual studio 2013\Projects\C\Debug\C.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
#include <glut.h>
void OnDraw()
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0);// Top Red.
glVertex3f(0, 10, 0);
glColor3f(0, 1, 0);// Bottom Left Green.
glVertex3f(-10, -10, 0);
glColor3f(0, 0, 1);// Bottom Right Blue.
glVertex3f(10, -10, 0);
glEnd();
glutSwapBuffers();
}
void OnReshape(int w, int h)
{
glViewport(0, 25, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-12, 12, -12, 16, -1, 1);
glMatrixMode(GL_MODELVIEW);
}
int main(int a, char **b)
{
glutInit(&a, b);
glutInitDisplayMode(GLUT_DEPTH | GLUT_RGBA | GLUT_DOUBLE);
glutInitWindowSize(256, 256);
glutCreateWindow("RGB Triangle");
glutDisplayFunc(OnDraw);
glutReshapeFunc(OnReshape);
glutMainLoop();
}// RGB Triangle.
Comments
Also if I am not mistaken there is a better way to program this with the new OpenGL standard. Is that standard included with this compiler?
Build started: Project: C, Configuration: Debug Win32
C.c
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(6): error C2061: syntax error : identifier 'Cube'
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(6): error C2059: syntax error : ';'
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(7): error C2449: found '{' at file scope (missing function header?)
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(36): error C2059: syntax error : '}'
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(79): error C2065: 'display' : undeclared identifier
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(79): warning C4047: 'function' : 'void (__cdecl *)(void)' differs in levels of indirection from 'int'
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(79): warning C4024: 'glutDisplayFunc' : different types for formal and actual parameter 1
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Build started: Project: C, Configuration: Debug Win32
C.c
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(4): error C2061: syntax error : identifier 'Moon'
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(4): error C2059: syntax error : ';'
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(5): error C2449: found '{' at file scope (missing function header?)
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(21): error C2059: syntax error : '}'
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(25): error C2061: syntax error : identifier 'Orbiter'
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(25): error C2059: syntax error : ';'
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(26): error C2449: found '{' at file scope (missing function header?)
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(40): error C2059: syntax error : '}'
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(51): warning C4013: 'getPosition' undefined; assuming extern returning int
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(53): error C2065: 'moon' : undeclared identifier
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(53): error C2224: left of '.draw' must have struct/union type
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(60): warning C4013: 'advance' undefined; assuming extern returning int
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(80): error C2065: 'moon' : undeclared identifier
c:\users\smjprogrammer\documents\visual studio 2013\projects\c\c\c.c(80): error C2224: left of '.create' must have struct/union type
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Line 24: [icode]static struct Moon moon;[/icode]
line 54: [icode]drawMoon(&moon);[/icode]
line 81: [icode]createMoon(&moon);[/icode].
And make similar changes to class Orbiter.
To to convert class method draw() to C format you need to make this change:
As I said several days ago converting that c++ code to C is possible, but will be tedious and time consuming. If you are not already well familiar with both languages you will have lot of difficulty. You can't just blindly make class methods global functions, you also have to think about and make some changes to the internals of how the methods go about doing things.
I'm not about to make all those changes for you or hold your hand while you do it. If you do not have the skills to make the changes on your own then you should think about not attempting to convert the c++ to C.
Go ahead and join DaniWeb -- ProgrammingForums.org is owned by DaniWeb.