• 9
• 10
• 9
• 10
• 10
• ### Similar Content

• Good evening everyone!

I was wondering if there is something equivalent of  GL_NV_blend_equation_advanced for AMD?
Basically I'm trying to find more compatible version of it.

Thank you!

• Hello guys,

How do I know? Why does wavefront not show for me?
I already checked I have non errors yet.

And my download (mega.nz) should it is original but I tried no success...
- Add blend source and png file here I have tried tried,.....

PS: Why is our community not active? I wait very longer. Stop to lie me!
Thanks !

• I wasn't sure if this would be the right place for a topic like this so sorry if it isn't.
I'm currently working on a project for Uni using FreeGLUT to make a simple solar system simulation. I've got to the point where I've implemented all the planets and have used a Scene Graph to link them all together. The issue I'm having with now though is basically the planets and moons orbit correctly at their own orbit speeds.
I'm not really experienced with using matrices for stuff like this so It's likely why I can't figure out how exactly to get it working. This is where I'm applying the transformation matrices, as well as pushing and popping them. This is within the Render function that every planet including the sun and moons will have and run.
if (tag != "Sun") { glRotatef(orbitAngle, orbitRotation.X, orbitRotation.Y, orbitRotation.Z); } glPushMatrix(); glTranslatef(position.X, position.Y, position.Z); glRotatef(rotationAngle, rotation.X, rotation.Y, rotation.Z); glScalef(scale.X, scale.Y, scale.Z); glDrawElements(GL_TRIANGLES, mesh->indiceCount, GL_UNSIGNED_SHORT, mesh->indices); if (tag != "Sun") { glPopMatrix(); } The "If(tag != "Sun")" parts are my attempts are getting the planets to orbit correctly though it likely isn't the way I'm meant to be doing it. So I was wondering if someone would be able to help me? As I really don't have an idea on what I would do to get it working. Using the if statement is truthfully the closest I've got to it working but there are still weird effects like the planets orbiting faster then they should depending on the number of planets actually be updated/rendered.

• Hello everyone,
I have problem with texture

• Hello everyone
For @80bserver8 nice job - I have found Google search. How did you port from Javascript WebGL to C# OpenTK.?
I have been searched Google but it shows f***ing Unity 3D. I really want know how do I understand I want start with OpenTK But I want know where is porting of Javascript and C#?

Thanks!

# OpenGL OpenGL Drawing Polygons

This topic is 4891 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am writing a small prototype clone of Space Invaders for my OpenGL class and am having trouble drawing the ship model using Polygons and Quads. I have XYZ vertexs in Ship_Verts, and I have in Ship_Edges, the set of Vertices needed to draw that particular polygon. The problem is I have to draw each polygon in the order from farthest to nearest one. Or else If i draw a polygon that is suppose to behind another then it will overlap it. I tried setting the normals,so that the polygon faces just one direction but that won't didn't help. Is that the only way i can do it, setup to draw each polygon from farthest to nearest?
[SOURCE]
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>

float Ship_Verts[16][3] = {{-1,1,-1},{-1,0,-1},{-1,0,1},{-1,1,1},{1,1,-1},{1,0,-1},{1,0,1},{1,1,1},{-0.5,0.5,1},{-0.5,0,1},{-0.5,0,1.5},{-0.5,0.5,1.5},{0.5,0.5,1},{0.5,0,1},{0.5,0,1.5},{0.5,0.5,1.5}};
int Ship_Edges[11][4] = {{3,2,1,0},{3,2,6,7},{0,4,5,1},{7,6,5,4},{0,3,7,4},{11,8,9,10},{11,10,14,15},{15,14,13,12},{9,13,14,10},{8,11,15,12},{8,12,13,9}};
int Ship_Norms[11][3] = {{-1,0,0},{0,0,1},{1,0,0},{0,0,-1},{0,1,0},{-1,0,0},{0,0,1},{1,0,0},{0,-1,0},{0,1,0},{0,0,-1}};
float Ship_Colors[11][3] = {{0,1,0},{1,0,0},{0,1,0},{0,1,1},{1,1,1},{1,1,.5},{0,0,1},{0,0,1},{0,0,1},{0,0,1},{0,0,1}};

/* A general OpenGL initialization function.  Sets all of the initial parameters. Taken from Nehe.Gamedev.net */
void InitGL(GLsizei Width, GLsizei Height)	// We call this right after our OpenGL window is created.
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);	// This Will Clear The Background Color To Black
glClearDepth(1.0);				// Enables Clearing Of The Depth Buffer
glMatrixMode(GL_PROJECTION);
glLoadIdentity();				// Reset The Projection Matrix
gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);	// Calculate The Aspect Ratio Of The Window
glMatrixMode(GL_MODELVIEW);
}

//Resize Function, taken from Nehe.Gamedev.Net
void ReSizeGLScene(GLsizei Width, GLsizei Height)
{
if (Height==0)				// Prevent A Divide By Zero If The Window Is Too Small
Height=1;

glViewport(0, 0, Width, Height);		// Reset The Current Viewport And Perspective Transformation

glMatrixMode(GL_PROJECTION);
gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
gluLookAt(10.0 , 10.0, -10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}

//Draw Ship
void draw_ship(void)
{
glColor3f(1.0, .5 , 1.0);
for(int a = 0; a < 3; a++)
{	glBegin(GL_POLYGON);
glColor3fv(&Ship_Colors[a][0]);
glNormal3iv(&Ship_Norms[a][0]);
glVertex3fv(&Ship_Verts[Ship_Edges[a][0]][0]);
glVertex3fv(&Ship_Verts[Ship_Edges[a][1]][0]);
glVertex3fv(&Ship_Verts[Ship_Edges[a][2]][0]);
glVertex3fv(&Ship_Verts[Ship_Edges[a][3]][0]);
glEnd();
}
}

void drawScene(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, .5 , 1.0);
for(int a = 0; a < 11; a++)
{	glBegin(GL_POLYGON);
glColor3fv(&Ship_Colors[a][0]);
glNormal3iv(&Ship_Norms[a][0]);
glVertex3fv(&Ship_Verts[Ship_Edges[a][0]][0]);
glVertex3fv(&Ship_Verts[Ship_Edges[a][1]][0]);
glVertex3fv(&Ship_Verts[Ship_Edges[a][2]][0]);
glVertex3fv(&Ship_Verts[Ship_Edges[a][3]][0]);
glEnd();
}
glutSwapBuffers();
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitWindowSize(500, 500);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
//glutMouseFunc(mouse);
//glutKeyboardFunc(keyboard);
glutDisplayFunc(drawScene);
//glutIdleFunc(drawScene);
glutReshapeFunc(&ReSizeGLScene);
InitGL(640, 480);
glutMainLoop();
return(0);
}
[/SOURCE]

##### Share on other sites
u need to enable depth testing

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);