Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 openGL
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Thuged_Out_G




PostPosted: Tue Mar 23, 2004 5:45 pm   Post subject: openGL

how much expereince do you need with C++ do get into openGl?
is it a difficult langauge to use?

could someone possibly post some openGl code just so i can see what it looks like.

for some reason, i dont think it will be as easy as Draw.FillBox(x,y,x1,y1,clr) Surprised
Sponsor
Sponsor
Sponsor
sponsor
tinhnho




PostPosted: Tue Mar 23, 2004 6:32 pm   Post subject: (No subject)

It's hard to say that it easy or not.It's depend on peoples.here is some code for openGL:

code:

#ifdef unix               
#include <GL/gl.h>        
#include "aux.h"          
#define CALLBACK          
#else
#include<windows.h>
#include<GL/gl.h>
#include<GL/glaux.h>
#endif

GLdouble vertex[][3]={
        {0.0,0.0,0.0},
        {1.0,0.0,0.0},
        {1.0,1.0,0.0},
        {0.0,1.0,0.0},
        {0.0,0.0,1.0},
        {1.0,0.0,1.0},
        {1.0,1.0,1.0},
        {0.0,1.0,1.0}
};

int edge[][2]={
        {0,1},
        {1,2},
        {2,3},
        {0,3},
        {4,5},
        {5,6},
        {6,7},
        {7,4},
        {0,4},
        {1,5},
        {2,6},
        {3,7}
};

GLvoid CALLBACK none(void)
{
}

GLvoid CALLBACK draw(void)
{
        int i;
        static int r=0;

        glClearColor(0.0,0.0,0.0,0.0);
        glClear(GL_COLOR_BUFFER_BIT);
        glLoadIdentity();
        gluLookAt(3.0,4.0,5.0,0.0,0.0,0.0,0.0,1.0,0.0);
        glRotated((double)r,0.0,1.0,0.0);

        glColor3d(1.0,1.0,1.0);
        glBegin(GL_LINES);
        for(i=0;i<12;i++){
                glVertex3dv(vertex[edge[i][0]]);
                glVertex3dv(vertex[edge[i][1]]);
        }
        glEnd();
        glFlush();
        if(++r>=360) r=0;
}

GLvoid CALLBACK resize(GLsizei w,GLsizei h)
{
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glViewport(0,0,w,h);
        gluPerspective(30.0,1.0,1.0,10.0);
        glMatrixMode(GL_MODELVIEW);
}
       
int main(int argc, char *argv[])
{
        auxInitPosition(200,100,512,512);
        auxInitDisplayMode(AUX_RGBA);
        auxInitWindow(argv[0]);
        auxReshapeFunc(resize);
        auxIdleFunc(draw);
        auxMainLoop(none);
        return 0;
}
Catalyst




PostPosted: Tue Mar 23, 2004 6:33 pm   Post subject: (No subject)

once u get past setting up the window opengl isnt very difficult to use

some example code that draws an orange rectangle
code:

   glColor3f (1,1,0);//Red,green,blue
   glBegin (GL_QUADS);//Draw Quads
      glVertex3f (-0.5,+0.5,-1);//Each corner
      glVertex3f (-0.5,-0.5,-1);
      glVertex3f (+0.5,-0.5,-1);
      glVertex3f (+0.5,+0.5,-1);
   glEnd();


There is a lot (and i mean a lot) more stuff in ogl (e.g. Matrices,Textures,Vertex Arrays, Depth-buffers,extensions,etc)

note: posted at the same time
Thuged_Out_G




PostPosted: Tue Mar 23, 2004 7:08 pm   Post subject: (No subject)

woah....i was reading the tut on nehe.gamedev about opening a window....it was like 350 lines of code just to open a window with a black background....i think ill just stick with C++ for the time being...since i just started with it...umm, lets see...yesterday Very Happy haha
Mazer




PostPosted: Tue Mar 23, 2004 8:23 pm   Post subject: (No subject)

Try printint out the window lesson and reading it over a few times every once in a while when you're bored and you'll see that it isn't that difficult. It isn't something you have to write often when you're making a game, it's just a bit fugly the first time you see it. If you really don't like the window creation code you can check out GLUT which allows you to create a window in a few simple lines and get straight into the OpenGL right away. You'll see that OpenGL really isn't that difficult compared to turing's draw commands, it's just the way you need to use them.

EDIT: Although, having one day's experience with C++ may have some factor in this. Wink
Play around with C++ more and when you feel ready jump back into the nehe tutorials, they're quite nice.
Catalyst




PostPosted: Tue Mar 23, 2004 8:32 pm   Post subject: (No subject)

once you are ready (give it a little bit of time)
try SDL it also simplifies window creation and input
and is cross-platform Very Happy
Thuged_Out_G




PostPosted: Tue Mar 23, 2004 10:33 pm   Post subject: (No subject)

i wasnt planning on jumping right into oGL ..i just wanted to see what it was all about. and try to gain a bit of an understanding of it. but just the opening a window code, kidna blew me away haha
rizzix




PostPosted: Fri Mar 26, 2004 10:33 am   Post subject: (No subject)

Thuged_Out_G wrote:
woah....i was reading the tut on nehe.gamedev about opening a window....it was like 350 lines of code just to open a window with a black background....i think ill just stick with C++ for the time being...since i just started with it...umm, lets see...yesterday Very Happy haha


u can use the GLUT to speed things up.. this way u can concentrate only on OpenGL
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: