Sorry for asking so many questions, its just that i am so into this now
a days and i encounter a few problems a day. usually they are pretty
simple problems as you can see, but thanks anyway.
okay so i have the following code....
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <stdlib.h>
#include <iostream>
#include <windows.h>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <Math.h>
#define PI 3.1415926535898
float zoom = 12.0f;
double angle;
double a=0.0,b=0.0;
void init(void)
{
//glShadeModel(GL_SMOOTH);
//glClearColor (0.0f,0.0f,0.0f,0.5f);
GLfloat mat_specular[]={1.0,1.0,0.0,1.0};
GLfloat light_position[]={3.0,4.0,100.0,0.0};
glClearColor (0.1,0.1,0.1,0.0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
//glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseMaterial);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialf(GL_FRONT, GL_SHININESS, 1000.0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glColorMaterial(GL_FRONT, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
}
void glRotatef(
GLfloat angle,
GLfloat x,
GLfloat y,
GLfloat z
);
void drawString (const char *s) //How do display text
{
unsigned int i;
for (i = 0; i < strlen (s); i++)
glutBitmapCharacter (GLUT_BITMAP_HELVETICA_18, s[i]);
};
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
//glTranslatef(0,0,-zoom);
glTranslatef(-2,-2,-zoom);
glColor4f(0.2,0.2,1.0,0.0);
glutSolidSphere(1.0,200,16);
glTranslatef(3,4,-zoom);
glColor3f(0.7,0.7,0.0);
glutSolidSphere(1.0,200,16);
glTranslatef(3,4,-zoom);
glColor3f(1.0,0.0,0.0);
glutSolidSphere(1.0,200,16);
glTranslatef(5,9,-20);
glColor3f(1.0,0.6,0.0);
glutSolidSphere(10.0,200,16);
glColor4f(1.0,0.0,0.0,1.0); //LINE HERE
glLineWidth(5.0);
glBegin(GL_LINES);
glVertex3f(-10000,0,10);
glVertex3f(100000,0,10);
glutPostRedisplay();
glEnd();
glTranslatef(a,b,-zoom);
glColor3f(1.0,0.2,0.0);
glutSolidSphere(1.0,200,16);
a-=0.3;
b-=0.3;
glutFullScreen( );
glPopMatrix();
glFlush();
glLoadIdentity();
glutSwapBuffers();
glutPostRedisplay();
}
void reshape( int w, int h)
{
glViewport(0,0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
{
glOrtho(-1.5,1.5,-1.5*(GLfloat)h/(GLfloat)w,
1.5*(GLfloat)h/(GLfloat)w, -10.0,10.0);
}
else
{
glOrtho(-1.5*(GLfloat)w/(GLfloat)h,
1.5*(GLfloat)w/(GLfloat)h, -1.5,1.5,-10.0,10.0);
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45,(float)w/h,0.1,100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
/*glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45,(float)w/h,0.1,100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();*/
}
void Keyboard(unsigned char key, int x, int y)
{
switch(key)
{
case 27:
exit(0);
break;
default:
break;
}
}
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(1275,955);
glutInitWindowPosition(0,0);
glutCreateWindow("Asteroids");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(Keyboard);
glutMainLoop();
return 0;
}
and the problem is, where i am drawing a VERY LONG straight line. for
some reason its black and i can't figure it out. i can tell there's a
line there, cause its not the same black that the background is, but
its kind of black. Why is that happening if im setting the color to red?
|
|
0
|
|
|
|
Reply
|
lubanfamily (53)
|
8/29/2005 1:49:29 AM |
|
bballmitch wrote:
> Sorry for asking so many questions, its just that i am so into this now
> a days and i encounter a few problems a day. usually they are pretty
> simple problems as you can see, but thanks anyway.
Lighting affects lines just as much as other primitives, so turn lighting off
if you want a pure red line:
glDisable(GL_LIGHTING);
glColor4f(1.0,0.0,0.0,1.0); //LINE HERE
glLineWidth(5.0);
glBegin(GL_LINES);
glVertex3f(-10000,0,10);
glVertex3f(100000,0,10);
glutPostRedisplay();
glEnd();
glEnable(GL_LIGHTING);
Also, glutFullScreen() should only be called onced durring your GL initialization.
Mike
> okay so i have the following code....
>
> #include <GL/gl.h>
> #include <GL/glu.h>
> #include <GL/glut.h>
> #include <stdlib.h>
> #include <iostream>
> #include <windows.h>
> #include <cstdio>
> #include <cstdlib>
> #include <string.h>
> #include <stdio.h>
> #include <stdarg.h>
> #include <Math.h>
>
> #define PI 3.1415926535898
>
> float zoom = 12.0f;
> double angle;
> double a=0.0,b=0.0;
>
> void init(void)
> {
> //glShadeModel(GL_SMOOTH);
> //glClearColor (0.0f,0.0f,0.0f,0.5f);
> GLfloat mat_specular[]={1.0,1.0,0.0,1.0};
> GLfloat light_position[]={3.0,4.0,100.0,0.0};
> glClearColor (0.1,0.1,0.1,0.0);
> glShadeModel(GL_SMOOTH);
> glEnable(GL_DEPTH_TEST);
> //glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseMaterial);
> glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
> glMaterialf(GL_FRONT, GL_SHININESS, 1000.0);
> glLightfv(GL_LIGHT0, GL_POSITION, light_position);
> glEnable(GL_LIGHTING);
> glEnable(GL_LIGHT0);
> glColorMaterial(GL_FRONT, GL_DIFFUSE);
> glEnable(GL_COLOR_MATERIAL);
> }
>
> void glRotatef(
> GLfloat angle,
> GLfloat x,
> GLfloat y,
> GLfloat z
> );
>
> void drawString (const char *s) //How do display text
> {
> unsigned int i;
> for (i = 0; i < strlen (s); i++)
> glutBitmapCharacter (GLUT_BITMAP_HELVETICA_18, s[i]);
>
> };
>
>
> void display(void)
> {
> glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
> glPushMatrix();
> //glTranslatef(0,0,-zoom);
>
> glTranslatef(-2,-2,-zoom);
> glColor4f(0.2,0.2,1.0,0.0);
> glutSolidSphere(1.0,200,16);
> glTranslatef(3,4,-zoom);
> glColor3f(0.7,0.7,0.0);
> glutSolidSphere(1.0,200,16);
> glTranslatef(3,4,-zoom);
> glColor3f(1.0,0.0,0.0);
> glutSolidSphere(1.0,200,16);
> glTranslatef(5,9,-20);
> glColor3f(1.0,0.6,0.0);
> glutSolidSphere(10.0,200,16);
>
> glColor4f(1.0,0.0,0.0,1.0); //LINE HERE
> glLineWidth(5.0);
> glBegin(GL_LINES);
> glVertex3f(-10000,0,10);
> glVertex3f(100000,0,10);
> glutPostRedisplay();
glutPostRedisplay() in the middle of a drawing operation? Or maybe that's just
for debugging? Still, GL won't like that.
> glEnd();
>
> glTranslatef(a,b,-zoom);
> glColor3f(1.0,0.2,0.0);
> glutSolidSphere(1.0,200,16);
> a-=0.3;
> b-=0.3;
>
> glutFullScreen( );
>
> glPopMatrix();
> glFlush();
> glLoadIdentity();
> glutSwapBuffers();
> glutPostRedisplay();
> }
>
>
> void reshape( int w, int h)
> {
> glViewport(0,0, (GLsizei) w, (GLsizei) h);
> glMatrixMode(GL_PROJECTION);
> glLoadIdentity();
> if(w<=h)
> {
> glOrtho(-1.5,1.5,-1.5*(GLfloat)h/(GLfloat)w,
> 1.5*(GLfloat)h/(GLfloat)w, -10.0,10.0);
> }
> else
> {
> glOrtho(-1.5*(GLfloat)w/(GLfloat)h,
> 1.5*(GLfloat)w/(GLfloat)h, -1.5,1.5,-10.0,10.0);
> }
> glMatrixMode(GL_MODELVIEW);
> glLoadIdentity();
> glMatrixMode(GL_PROJECTION);
> glLoadIdentity();
> gluPerspective(45,(float)w/h,0.1,100);
> glMatrixMode(GL_MODELVIEW);
> glLoadIdentity();
> /*glMatrixMode(GL_PROJECTION);
> glLoadIdentity();
> gluPerspective(45,(float)w/h,0.1,100);
> glMatrixMode(GL_MODELVIEW);
> glLoadIdentity();*/
> }
>
> void Keyboard(unsigned char key, int x, int y)
> {
> switch(key)
> {
> case 27:
> exit(0);
> break;
> default:
> break;
> }
> }
>
> int main(int argc, char** argv)
> {
> glutInit(&argc,argv);
> glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
> glutInitWindowSize(1275,955);
>
> glutInitWindowPosition(0,0);
> glutCreateWindow("Asteroids");
> init();
>
> glutDisplayFunc(display);
> glutReshapeFunc(reshape);
> glutKeyboardFunc(Keyboard);
>
> glutMainLoop();
> return 0;
> }
>
> and the problem is, where i am drawing a VERY LONG straight line. for
> some reason its black and i can't figure it out. i can tell there's a
> line there, cause its not the same black that the background is, but
> its kind of black. Why is that happening if im setting the color to red?
|
|
0
|
|
|
|
Reply
|
Mike
|
8/29/2005 2:19:03 AM
|
|
thanks for tips. and it worked.
|
|
0
|
|
|
|
Reply
|
bballmitch
|
8/29/2005 2:25:32 AM
|
|
|
2 Replies
80 Views
(page loaded in 0.059 seconds)
Similiar Articles: Image Processing- Length of a line - comp.soft-sys.matlab ...The black darker lines are what i am interested in. Now each of the lines has a thickness of a few pixels. How do i come up with the length a single pixel line which can ... Screen Flickers on Edge , with Black background. Why? - comp ...The most ugly thing of all is that there appears on the edges (usually where the scrollbar is) a little black and white lines (1-2 cm). The same thing happens when i try ... How to turn off lines in filled contour plot? - comp.soft-sys ...I can't figure out how to turn off the black lines on a filled contour plot. Can anyone explain how to do this? (The documentation in contour, conto... Change plot grid line colour - comp.soft-sys.matlab... Xcolor',[0.5 0.5 0.5]); set(gca,'Ycolor',[0.5 0.5 0.5]); % Note the the X and Y ticks will be the same color as the grid lines, if you still want the tick marks black ... Is it possible to remove black line on face in pictures? - comp ...Is it possible to remove the black line (mask? or blacked-out) face I sometimes see on photographs (jpeg, or gif) online? 2) What is it [the blac... Multiple line plots, two y axes - comp.soft-sys.matlabI am trying to plot a total of four lines onto a single line graph. All of the lines ... I want them to just be the standard black, but I can't see what function has set them ... Antialiasing with transparent background - comp.graphics.api ...I was able to have a better result with setting the line widther of 1 pixel if the transparency is used. This work fine for black lines, the result is very similar with ... Changing the color of lines - comp.graphics.apps.gimp... when shaded - comp.cad.solidworks If I change the color to say dark magenta, the edge lines (in shaded with edges) appear magenta but the faces are all now still black but ... polar plotting two lines - comp.soft-sys.matlab... display all of the data in my arrays on one polar plot with part of the line being black ... polar plotting two lines - comp.soft-sys.matlab I have two sets of data that are ... one line plot with different colors - comp.soft-sys.matlab ...For example, I want to plot only the negative values in red and the postitve values in black. To plot the data points in different colors is easy, but the line between ... Black Phone Chat LinesBlack phone chat lines are a amusing way of meeting and chatting with other black singles who are on the look out for fun, friendship or a bit more. Black lines in fingernails ยท Skin Conditions discussions | Body ...Hi! Recently, I noticed black lines in fingernails. What caused black lines in fingernails? Do you know something about that? I am worried. Thanks! 7/18/2012 8:55:39 PM
|