Jump to content
  • Advertisement
Sign in to follow this  
ekrax

basic opengl app

This topic is 5049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, i've been using opengl for a little while, and mostly using a template similar to the NeHe one in the tutorials. however i find that the NeHe template is a lot larger than some of the other tutorials out on the net, and i don't like having the copy-paste code without knowing what it does. i've found quite a few opengl template / example apps that are fairly small, but i'm still not sure how cut down they are. does anyone have a link to a opengl template / tutorial that has the most cut down code possible (ie the most basic code possible to get an opengl window working (doesnt have to be fullscreen)) ... i want to use a basic version so i can add more options and functionality to it myself so i actually know what each instruction does. thanks in advance for any links / help.

Share this post


Link to post
Share on other sites
Advertisement
I'd recommend NeHe's "Simple" basecode, or the entire "NeHe SDK". It's about as basic as you'll get with win32 code.

However, I really do like the OOP code, it feels so...natural.

Look on the main page and you should find it.

Share this post


Link to post
Share on other sites

// From OpenGL Lighthouse 3D
#include <gl/glut.h>
#include<gl/gl.h>

void renderScene(void) {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);
glEnd();
glFlush();
}

void main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("3D Tech- GLUT Tutorial");
glutDisplayFunc(renderScene);
glutMainLoop();
}



Here.
But you need GLUT, a cross-platform window wrapper for OpenGL. It's nice for lightweight OpenGL application, but for video games, I still recommend SDL.

Share this post


Link to post
Share on other sites
I'll throw my $0.02 in and second the recommendation for SDL. I have a win32 template for OpenGL I've been using for quite some time, until recently, when I needed a template that would port easily to the Mac OS X. SDL did the trick pretty much flawlessly, with a template that was less than half the size. SDL is designed to be simple to understand.

The book Focus on SDL is a good place to start. Or you could go here or here. Or just download the SDL sdk here and work through the documentation.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Everytime you see something you don't understand look it up in the SDK docs

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!