LINUX programming

Moderators: ITA
Number of threads: 1347
Number of posts: 2935

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Edit Report
graphics programing in linux Posted by ravi on 24 Jun 2000 at 1:38 PM
my hobby is programing graphics in c language. i am fully familiar with c in dos mode. recently i started to work on linux and i like it. but i could not run any "graphics program in linux"<br>
with or without using graphics.h. other than using ascii characters on screen mode..<br>
could you please brief up how graphics programing in c for linux is done.


Edit Report
Re: graphics programing in linux Posted by Sergey on 29 Sept 2000 at 9:10 PM
: my hobby is programing graphics in c language. i am fully familiar with c in dos mode. recently i started to work on linux and i like it. but i could not run any "graphics program in linux"<br>
: with or without using graphics.h. other than using ascii characters on screen mode..<br>
: could you please brief up how graphics programing in c for linux is done.<br>
: <br>
<br>
If you like to play with graphics I would suggest you to<br>
start with OpenGL. It is real fun to program and there are plenty of<br>
examples out there for free. But first you have to figure out whether you <br>
have Mesa lib or not. Check in /usr/lib/ there must be Mesa-x.x where x.x is<br>
a version. <br>
here is files you may want to get from net:<br>
Mesa-demos-3.0-2.i386.rpm<br>
Mesa-devel-3.0-2.i386.rpm<br>
Mesa-glut-3.0-2.i386.rpm<br>
Mesa-glut-devel-3.0-2.i386.rpm<br>
--------------------------------------<br>
For you to start here is a small example: <br>
Save it as x.c or x.cpp where x is name you like and than compile by the following command:<br>
For x.c use<br>
cc x.c -lglut -lMesaGLU -lMesaGL -L/usr/X11/lib -L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt &#8211;lXi<br>
<br>
For x.cpp use<br>
g++ x.cpp -lglut -lMesaGLU -lMesaGL -L/usr/X11/lib -L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi<br>
<br>
Later you have to decide which X lib you have to use during compilation but now I show you most common lib. <br>
<br>
<br>
----------------------------------------------<br>
<br>
<br>
/*<br>
* Copyright (c) 1993-1997, Silicon Graphics, Inc.<br>
* ALL RIGHTS RESERVED <br>
* Permission to use, copy, modify, and distribute this software for <br>
* any purpose and without fee is hereby granted, provided that the above<br>
* copyright notice appear in all copies and that both the copyright notice<br>
* and this permission notice appear in supporting documentation, and that <br>
* the name of Silicon Graphics, Inc. not be used in advertising<br>
* or publicity pertaining to distribution of the software without specific,<br>
* written prior permission. <br>
*<br>
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"<br>
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,<br>
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR<br>
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON<br>
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,<br>
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY<br>
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,<br>
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF<br>
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN<br>
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON<br>
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE<br>
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.<br>
* <br>
* US Government Users Restricted Rights <br>
* Use, duplication, or disclosure by the Government is subject to<br>
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph<br>
* (c)(1)(ii) of the Rights in Technical Data and Computer Software<br>
* clause at DFARS 252.227-7013 and/or in similar or successor<br>
* clauses in the FAR or the DOD or NASA FAR Supplement.<br>
* Unpublished-- rights reserved under the copyright laws of the<br>
* United States. Contractor/manufacturer is Silicon Graphics,<br>
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.<br>
*<br>
* OpenGL(R) is a registered trademark of Silicon Graphics, Inc.<br>
*/<br>
<br>
/*<br>
* cube.c<br>
* This program demonstrates a single modeling transformation,<br>
* glScalef() and a single viewing transformation, gluLookAt().<br>
* A wireframe cube is rendered.<br>
*/<br>
#include <GL/glut.h><br>
#include <stdlib.h><br>
<br>
void init(void) <br>
{<br>
glClearColor (0.0, 0.0, 0.0, 0.0);<br>
glShadeModel (GL_FLAT);<br>
}<br>
<br>
void display(void)<br>
{<br>
glClear (GL_COLOR_BUFFER_BIT);<br>
glColor3f (1.0, 1.0, 1.0);<br>
glLoadIdentity (); /* clear the matrix */<br>
/* viewing transformation */<br>
gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);<br>
glScalef (1.0, 2.0, 1.0); /* modeling transformation */ <br>
glutWireCube (1.0);<br>
glFlush ();<br>
}<br>
<br>
void reshape (int w, int h)<br>
{<br>
glViewport (0, 0, (GLsizei) w, (GLsizei) h); <br>
glMatrixMode (GL_PROJECTION);<br>
glLoadIdentity ();<br>
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);<br>
glMatrixMode (GL_MODELVIEW);<br>
}<br>
<br>
/* ARGSUSED1 */<br>
void keyboard(unsigned char key, int x, int y)<br>
{<br>
switch (key) {<br>
case 27:<br>
exit(0);<br>
break;<br>
}<br>
}<br>
<br>
int main(int argc, char** argv)<br>
{<br>
glutInit(&argc, argv);<br>
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);<br>
glutInitWindowSize (500, 500); <br>
glutInitWindowPosition (100, 100);<br>
glutCreateWindow (argv[0]);<br>
init ();<br>
glutDisplayFunc(display); <br>
glutReshapeFunc(reshape);<br>
glutKeyboardFunc(keyboard);<br>
glutMainLoop();<br>
return 0;<br>
}<br>
---------------------------------------------<br>
<br>
Have fun!<br>
PS: if you wish e-mail me and I will post you those libs.<br>






 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.