LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-26-2011, 12:28 PM   #1
prayas.suneja
LQ Newbie
 
Registered: Feb 2011
Location: shimla
Distribution: opensuse 11.1
Posts: 2

Rep: Reputation: 0
Question my opengl program gives a blank output screen after compilation...


i compiled this code and got no error.....but the output screen is blank.


the code is as follows:
-------------------------------------------------------------------------
# include <GL/glut.h>
# include <iostream>
# include <cstdio>
using namespace std;

void init(int w,int h)
{
glClearColor(0,0.5,0.5,0.0);
glMatrixMode(GL_PROJECTION);
glViewport(0,0,w,h);
}

void dispfcn()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2i(50,50);
glVertex2i(100,50);
glVertex2i(75,100);
glEnd();
glFlush();
}

int main(int argc,char**argv)
{
int w,h;
w=h=400;
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowPosition(100,100);
glutInitWindowSize(w,h);
glutCreateWindow("triangle");
init(w,h);
glutDisplayFunc(dispfcn);
glutMainLoop();
return 0;
}
-------------------------------------------------------------------------

i compiled the program as follows:
g++ first.cpp -o first -lglut
 
Old 02-26-2011, 02:12 PM   #2
adamk75
Senior Member
 
Registered: May 2006
Posts: 3,091

Rep: Reputation: 399Reputation: 399Reputation: 399Reputation: 399
I get just a gray window here, on two separate machines with different drivers. Where did you get the code? Do you know what it is supposed to produce?

Adam
 
Old 02-26-2011, 05:32 PM   #3
prayas.suneja
LQ Newbie
 
Registered: Feb 2011
Location: shimla
Distribution: opensuse 11.1
Posts: 2

Original Poster
Rep: Reputation: 0
i wrote this code...
it is a simple program to draw a triangle.....

i made this program with the help of some programs available on the internet(which worked perfectly fine in my distro) and the program i ran in visual c++(in my college lab),this is a hybrid...i guess there is some logical error or incorrect usage of function that's why blank screen is coming......
its working fine in the main where we can change the background display....but the 'dispfunc' is not displaying the triangle....
 
Old 02-26-2011, 05:58 PM   #4
adamk75
Senior Member
 
Registered: May 2006
Posts: 3,091

Rep: Reputation: 399Reputation: 399Reputation: 399Reputation: 399
I'd suggest that this isn't the best forum for troubleshooting OpenGL programming errors. This forum will probably get you better results:

http://www.opengl.org/discussion_boards/

Adam
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Blank Screen after Kernel Compilation with High Memory Enabled jonegold Slackware 3 01-09-2007 11:57 PM
Compilation problem with fltk + opengl crisostomo_enrico Linux - Software 0 07-18-2006 06:49 AM
Compiled OpenGL programs produce blank screens norfenstein Programming 3 12-04-2004 02:37 PM
blank screen on opengl xscreensavers n_hendrick Linux - Newbie 1 01-16-2004 03:55 PM
When closing my graphics program & entering the application again the screen is blank armesk Programming 7 08-29-2003 01:16 PM


All times are GMT -5. The time now is 12:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration