[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

OpenGL



Hej!

Her i juleferien er jeg gået i gang med bogen "Programming Linux Games".
Bogen bruger for det meste SDL og de programmer, hvor der bliver brugt SDL fungere også perfekt og der kommer ingen compiler fejl.
Der et eksempel hvor der bliver brugt OpenGL og den kode kan jeg ikke kompile.
Jeg kører RH 8.0.
Programmet ser sådan ud:


/* Example of OpenGL rendering through SDL. */

#include <SDL/SDL.h>
#include <GL/gl.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    /* Initialize SDL as usual. */
    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
	printf("Error: %s\n", SDL_GetError());
	return 1;
    }

atexit(SDL_Quit);

    /* Enable OpenGL double buffering. */
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    /* Set the color depth (16-bit 565). */
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);

    /* Create a 640x480, 16 bit window with support for
       OpenGL rendering. Unfortunately we won't know
       whether this is hardware accelerated. */
    if (SDL_SetVideoMode(640, 480, 16, SDL_OPENGL) == NULL) {
	printf("Error: %s\n", SDL_GetError());
	return 1;
    }

    /* Set a window title. */
    SDL_WM_SetCaption("OpenGL with SDL!", "OpenGL");

    /* We can now use any OpenGL rendering commands. */
    glViewport(80, 0, 480, 480);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 100.0);
    glClearColor(0, 0, 0, 0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_TRIANGLES);
    glColor3f(1.0, 0, 0);
    glVertex3f(0.0, 1.0, -2.0);
    glColor3f(0, 1.0, 0);
    glVertex3f(1.0, -1.0, -2.0);
    glColor3f(0, 0, 1.0);
    glVertex3f(-1.0, -1.0, -2.0);
    glEnd();
    glFlush();

    /* Display the back buffer to the screen. */
    SDL_GL_SwapBuffers();

    /* Wait a few seconds. */
    SDL_Delay(5000);

    return 0;
}


Når jeg compiler programmet med komandoen: gcc opengl-sdl.c `sdl-config --cflags --libs` -I/usr/include/GL

får jeg fejlen:

/tmp/ccnCv2Lh.o: In function `main':
/tmp/ccnCv2Lh.o(.text+0xfb): undefined reference to `glViewport'
/tmp/ccnCv2Lh.o(.text+0x10b): undefined reference to `glMatrixMode'
/tmp/ccnCv2Lh.o(.text+0x113): undefined reference to `glLoadIdentity'
/tmp/ccnCv2Lh.o(.text+0x142): undefined reference to `glFrustum'
/tmp/ccnCv2Lh.o(.text+0x152): undefined reference to `glClearColor'
/tmp/ccnCv2Lh.o(.text+0x162): undefined reference to `glMatrixMode'
/tmp/ccnCv2Lh.o(.text+0x16a): undefined reference to `glLoadIdentity'
/tmp/ccnCv2Lh.o(.text+0x177): undefined reference to `glClear'
/tmp/ccnCv2Lh.o(.text+0x184): undefined reference to `glBegin'
/tmp/ccnCv2Lh.o(.text+0x198): undefined reference to `glColor3f'
/tmp/ccnCv2Lh.o(.text+0x1af): undefined reference to `glVertex3f'
/tmp/ccnCv2Lh.o(.text+0x1c3): undefined reference to `glColor3f'
/tmp/ccnCv2Lh.o(.text+0x1dd): undefined reference to `glVertex3f'
/tmp/ccnCv2Lh.o(.text+0x1f1): undefined reference to `glColor3f'
/tmp/ccnCv2Lh.o(.text+0x20b): undefined reference to `glVertex3f'
/tmp/ccnCv2Lh.o(.text+0x213): undefined reference to `glEnd'
/tmp/ccnCv2Lh.o(.text+0x218): undefined reference to `glFlush'
collect2: ld returned 1 exit status


jeg har tjekket at jeg har gl.h filen den ligger i mappen /usr/include/GL/


Når jeg prøver med komandoen: gcc opengl-sdl.c -I/usr/include/SDL -D_REENTRANT,/usr/include/GL/ -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread

får jeg næsten den samme fejl:

<command line>:1:11: advarsel: ISO C requires whitespace after the macro name
/tmp/ccMMfVuu.o: In function `main':
/tmp/ccMMfVuu.o(.text+0xfb): undefined reference to `glViewport'
/tmp/ccMMfVuu.o(.text+0x10b): undefined reference to `glMatrixMode'
/tmp/ccMMfVuu.o(.text+0x113): undefined reference to `glLoadIdentity'
/tmp/ccMMfVuu.o(.text+0x142): undefined reference to `glFrustum'
/tmp/ccMMfVuu.o(.text+0x152): undefined reference to `glClearColor'
/tmp/ccMMfVuu.o(.text+0x162): undefined reference to `glMatrixMode'
/tmp/ccMMfVuu.o(.text+0x16a): undefined reference to `glLoadIdentity'
/tmp/ccMMfVuu.o(.text+0x177): undefined reference to `glClear'
/tmp/ccMMfVuu.o(.text+0x184): undefined reference to `glBegin'
/tmp/ccMMfVuu.o(.text+0x198): undefined reference to `glColor3f'
/tmp/ccMMfVuu.o(.text+0x1af): undefined reference to `glVertex3f'
/tmp/ccMMfVuu.o(.text+0x1c3): undefined reference to `glColor3f'
/tmp/ccMMfVuu.o(.text+0x1dd): undefined reference to `glVertex3f'
/tmp/ccMMfVuu.o(.text+0x1f1): undefined reference to `glColor3f'
/tmp/ccMMfVuu.o(.text+0x20b): undefined reference to `glVertex3f'
/tmp/ccMMfVuu.o(.text+0x213): undefined reference to `glEnd'
/tmp/ccMMfVuu.o(.text+0x218): undefined reference to `glFlush'
collect2: ld returned 1 exit status


Hvad skal jeg gøre??? På forhånd tak og godt nytår

MVH Niels



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *