PDA

View Full Version : Window and Research



havok13888
07-05-2009, 11:41 AM
Hey

I'm a total newbie and I had two questions.

1) I created a window for windows using c++ and I created a 3d object using opengl. How do I get my win32 window to display the 3d object created in opengl. Do I call the functions that I call in the main for the opengl program in winmain of the win32 code.

2) Where can I get to read research articles about various topics on graphics and their implementation, algorithms, optimizations etc.
Topics like HDR or volumetric lighting etc.

Thanks

ZbuffeR
07-05-2009, 12:23 PM
1) ... yes ? ... in fact I do not understand your question. Maybe you mean GLUT instead of OpenGL somewhere ?

2) a good start is the NVidia SDK :
http://developer.download.nvidia.com/SDK/10.5/opengl/samples.html
a good number of samples are not nvidia-specific.
It seem weaker on the ATI side, but I found this :
http://ati.amd.com/developer/sdk/RadeonSDK/Html/Info/Prog3D.html

havok13888
07-05-2009, 11:34 PM
I am using glut right now. When I compile and run any of my Opengl code, I get the 3d object running in a window but there is always a dos console running in the background. Any suggestions as to how I can have the console not appear each time I run any of my OpenGl code. It's not a big thing but I guess it adds to the presentation.


Thanks a lot for the links

ZbuffeR
07-05-2009, 11:40 PM
It is not glut that provides the "dos console". It is how you set up your project compile options.

IE. with VC++ :
http://www.lighthouse3d.com/opengl/glut/
Read the paragraph starting with "Setting up in Visual C/C++ 6.0".

awhig
07-06-2009, 12:01 AM
Thought glut is fine and easy to use for display, there is another way of doing (if interested). you can use openGL with MFC. Though its pain staking to set up.you need wgl functions.
For reference, go to MSDN and look out for opengl.

But as a beginner, glut is the best.

dletozeun
07-06-2009, 04:44 AM
to remove console, type



/ENTRY:main /SUBSYSTEM:WINDOWS


in project properties / linker command line.

IIRC, it is because your main function is called "main" and not "WinMain" but I think it is not the only reason.

havok13888
07-06-2009, 07:35 AM
I did follow the instructions and well now nothing shows up. I just did two things

Set entry point to main and sub system to Windows subsystem

I am using VC++ 2008 express

Here is the code i used.


#include<iostream>
#include<stdlib.h>

#ifdef __APPLE__
#include<OpenGL/OpenGL.h>
#include<GLUT/glut.h>
#else
#include<GL/glut.h>
#endif

using namespace std;

void handleKeypress(unsigned char key, int x, int y)
{
switch (key)
{
case 27:
exit(0);
}
}

void initRendering()
{
glEnable(GL_DEPTH_TEST);
}

void handleResize(int w, int h)
{
glViewport(0, 0, w, h);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(90.0, double(w)/double(h), 1.0, 200.0);

}

void drawScene ()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glBegin(GL_QUADS);

glVertex3f(-0.7f, -1.5f, -5.0f);
glVertex3f(0.7f, -1.5f, -5.0f);
glVertex3f(0.4f, -0.5f, -5.0f);
glVertex3f(-0.4f, -0.5f, -5.0f);

glEnd();

glBegin(GL_TRIANGLES);

// Pentagon
glVertex3f(0.5f, 0.5f, -5.0f);
glVertex3f(1.5f, 0.5f, -5.0f);
glVertex3f(0.5f, 1.0f, -5.0f);

glVertex3f(0.5f, 1.0f, -5.0f);
glVertex3f(1.5f, 0.5f, -5.0f);
glVertex3f(1.5f, 1.0f, -5.0f);

glVertex3f(0.5f, 1.0f, -5.0f);
glVertex3f(1.5f, 1.0f, -5.0f);
glVertex3f(1.0f, 1.5f, -5.0f);

// Triangle
glVertex3f(-0.5f, 0.5f, -5.0f);
glVertex3f(-1.0f, 1.5f, -5.0f);
glVertex3f(-1.5f, 0.5f, -5.0f);

glEnd();
glFlush();
glutSwapBuffers();
}

int main (int argc, char** argv)
{
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(800, 600);

glutCreateWindow("Basic Shapes");
initRendering();

glutDisplayFunc(drawScene);
glutKeyboardFunc(handleKeypress);
glutReshapeFunc(handleResize);

glutMainLoop();
return 0;
}







Is there anything else that I need to avoid the console from appearing.


Edit:
So I did everything again and now every time I compile the program, the .exe file crashes with an error, the .exe has stopped working.

I'm using Vista so is this a Vista problem.

dletozeun
07-06-2009, 11:37 AM
Oops, I made a mistake, actually it is:



/SUBSYSTEM:windows /ENTRY:mainCRTStartup

havok13888
07-07-2009, 10:09 AM
Sweet thanks it works perfectly now. Thanks a lot