473,221 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

Erros of Porting to OpenGL 1.2 for Managed C++ in VC++.NET (2002)

Hi all,
I tried to use Managed C++ coding of VC++.NET (2002)and
OpenGL version 1.2 to draw a hexagon shape of benzene.
My OpenGLdrawBenzene.cpp is the following:
// This is the main project file for VC++ application
project
// generated using an Application Wizard.

#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <GL/glut.h> // OpenGL Graphics Utility
Library
#using <mscorlib.dll>
#include <tchar.h>

using namespace System;

// These variables set the dimensions of the
rectanglar region we wish to view.
const double Xmin = 0.0, Xmax = 3.0;
const double Ymin = 0.0, Ymax = 3.0;

// Clear the rendering window
glClear(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT);

// Set drawing color to white
glColor3f( 1.0, 1.0, 1.0 );
// Draw six points on xy plane with z=0.0
glBegin(GL_POINTS);
glVertex3f( 0.0, 0.0, 0.0 );
glVertex3f( 0.9, 1.0, 0.0 );
glVertex3f( 1.9, 1.0, 0.0 );
glVertex3f( 2.8, 0.0, 0.0 );
glVertex3f( 1.9,-1.0, 0.0 );
glVertex3f( 0.9,-1.0, 0.0 );
glEnd();
// Flush the pipeline. (Not usually necessary.)
glFlush();
}
// Initialize OpenGL's rendering modes
void initRendering()
{
// Called when the window is resized
// w, h - width and height of the window in
pixels.
void resizeWindow(int w, int h)
{
double scale, center;
double windowXmin, windowXmax, windowYmin,
windowYmax;

// Define the portion of the window used for OpenGL
rendering.
glViewport( 0, 0, w, h ); // View port uses
whole
window

// Set up the projection view matrix: orthographic
projection
// Determine the min and max values for x and y
that
should appear in the window.
// The complication is that the aspect ratio of the
window may not match the
// aspect ratio of the scene we want
to view.
w = (w==0) ? 1 : w;
h = (h==0) ? 1 : h;
if ( (Xmax-Xmin)/w < (Ymax-Ymin)/h ) {
scale = ((Ymax-Ymin)/h)/((Xmax-Xmin)/w);
center = (Xmax+Xmin)/2;
windowXmin = center - (center-Xmin)*scale;
windowXmax = center + (Xmax-center)*scale;
windowYmin = Ymin;
windowYmax = Ymax;
}
else {
scale = ((Xmax-Xmin)/w)/((Ymax-Ymin)/h);
center = (Ymax+Ymin)/2;
windowYmin = center - (center-Ymin)*scale;
windowYmax = center + (Ymax-center)*scale;
windowXmin = Xmin;
windowXmax = Xmax;
}

// Now that we know the max & min values for x & y
that should be visible in the window,
// we set up the orthographic
projection.
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( windowXmin, windowXmax, windowYmin,
windowYmax, -1, 1 );

}
// This is the entry point for this application
int _tmain(int argc, char** argv)
{
// TODO: Please replace the sample code below with
your own.
Console::WriteLine(S"OpenGLdrawBenzene");

///////////int main( int argc, char** argv )

glutInit(&argc,argv);

// The image is not animated so single buffering is
OK.
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB |
GLUT_DEPTH );

// Window position (from top corner), and size
(width
and hieght)
glutInitWindowPosition( 20, 60 );
glutInitWindowSize( 360, 360 );
glutCreateWindow( "SimpleDraw - Press space bar to
toggle images" );

// Initialize OpenGL as we like it..
initRendering();

// Set up callback functions for key presses
glutKeyboardFunc( myKeyboardFunc );
// Handles
"normal" ascii symbols
// glutSpecialFunc( mySpecialKeyFunc ); //
Handles
"special" keyboard keys

// Set up the callback function for resizing
windows
glutReshapeFunc( resizeWindow );

// Call this for background processing
// glutIdleFunc( myIdleFunction );

// call this whenever window needs redrawing
glutDisplayFunc( drawScene );

fprintf(stdout, "Press space bar to toggle images;
escape button to quit.\n");

// Start the main loop. glutMainLoop never
returns.
glutMainLoop( );
return 0;
}
///////////////////////////////////////
When I built it, I got many errors:
------ Build started: Project: OpenGLdrawBenzene,
Configuration: Debug Win32 ------

Compiling...
OpenGLdrawBenzene.cpp
OpenGLdrawBenzene.cpp(18) : error C2501: 'glClear' :
missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(18) : error C2365: 'glClear' :
redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1162) : see
declaration of 'glClear'
OpenGLdrawBenzene.cpp(21) : error C2501: 'glColor3f' :
missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(21) : error C2365: 'glColor3f' :
redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1173) : see
declaration of 'glColor3f'
OpenGLdrawBenzene.cpp(21) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(23) : error C2501: 'glBegin' :
missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(23) : error C2365: 'glBegin' :
redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1156) : see
declaration of 'glBegin'
OpenGLdrawBenzene.cpp(24) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(24) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(24) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(25) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(25) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(25) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(26) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(26) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(26) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(27) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(27) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(27) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(28) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(28) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(28) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(29) : error C2501: 'glVertex3f'
: missing storage-class or type specifiers
OpenGLdrawBenzene.cpp(29) : error C2365: 'glVertex3f'
: redefinition; previous definition was a 'function'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1472) : see
declaration of 'glVertex3f'
OpenGLdrawBenzene.cpp(29) : error C2078: too many
initializers
OpenGLdrawBenzene.cpp(30) : error C2556: 'int
glEnd(void)' : overloaded function differs only by
return type from 'void glEnd(void)'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1226) : see
declaration of 'glEnd'
OpenGLdrawBenzene.cpp(30) : error C2373: 'glEnd' :
redefinition; different type modifiers
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1226) : see
declaration of 'glEnd'
OpenGLdrawBenzene.cpp(32) : error C2556: 'int
glFlush(void)' : overloaded function differs only by
return type from 'void glFlush(void)'
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1242) : see
declaration of 'glFlush'
OpenGLdrawBenzene.cpp(32) : error C2373: 'glFlush' :
redefinition; different type modifiers
C:\Program Files\Microsoft Visual Studio
..NET\Vc7\PlatformSDK\Include\gl\GL.h(1242) : see
declaration of 'glFlush'
OpenGLdrawBenzene.cpp(33) : error C2059: syntax error
: '}'
OpenGLdrawBenzene.cpp(33) : error C2143: syntax error
: missing ';' before '}'
OpenGLdrawBenzene.cpp(33) : error C2059: syntax error
: '}'
OpenGLdrawBenzene.cpp(36) : error C2143: syntax error
: missing ';' before '{'
OpenGLdrawBenzene.cpp(36) : error C2447: '{' : missing
function header (old-style formal list?)
OpenGLdrawBenzene.cpp(119) : fatal error C1004:
unexpected end of file found

Build log was saved at "file://c:\Documents and
Settings\default\My
Documents\Programming\OpenGLdrawBenzene\Debug\Buil dLog.htm"
OpenGLdrawBenzene - 35 error(s), 0 warning(s)

---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped
///////////////////////////////////////////////
Please kindly tell me what caused the first error in
Line 18 of this .cpp

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

and how to cure it. If you can help me more in
solving the rest of the errors, I will be greatly
appreciated.

Thanks in advance,
Scott Chang
Nov 16 '05 #1
0 3610

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael Sgier | last post by:
Hello i'm trying to port a windows program to linux with Kdevelop 1.question: unsigned char *LoadBitmapFile(char *filename, BITMAPINFOHEADER *bitmapInfoHeader); ...
1
by: Robin Charisse | last post by:
Hi, I have a VC++6 project that uses msxml to parse XML documents. I have been asked to port this to a .NET project but from the research I've done so far it looks as though the only way to do...
10
by: Bad_Kid | last post by:
which is better for what?
0
by: Scott Chang | last post by:
Hi all, Is any article or document for porting to OpenGL for Microsoft Visual C++.NET (2002)? Please advise. Thanks in advance, Scott Chang
1
by: Scott Chang | last post by:
Hi All I tried to use the attached OpenGL code to draw a Star-shaped figure on my Microsoft Visual C++ .NET 2002-Windows XP Pro PC. When I did 'Build' in Debug Mode, I got an error C2065:...
3
by: John Vannoy | last post by:
I have created a small OpenGL app in VC.NET and so far so good. But when I try to create a GLUquadric object with gluNewQuadric, I get a runtime error: An unhandled exception of type...
11
by: Peter Oliphant | last post by:
Is there any plan to support templates with managed code in the (near) future? For instance, VS.NET 2005... : )
14
by: Jessica Weiner | last post by:
I am writing an application in C# which need to plot graphs and simple shapes (polygons, circles, squares etc). Which library is better for this purpose and why? Thanks.
6
by: =?Utf-8?B?RGlwZXNoX1NoYXJtYQ==?= | last post by:
Hi all, I am porting an code written in VC++ to VC.Net to make it manage. But in Managed VC we dont use "const" keyboard at all. but my code is using it very frequently, so is their any...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.