コード例 #1
0
ファイル: OGLRender.cpp プロジェクト: jgreth/mupen64plus-rpi
bool OGLRender::RenderFillRect(uint32 dwColor, float depth)
{
    float a = (dwColor>>24)/255.0f;
    float r = ((dwColor>>16)&0xFF)/255.0f;
    float g = ((dwColor>>8)&0xFF)/255.0f;
    float b = (dwColor&0xFF)/255.0f;
    glViewportWrapper(0, windowSetting.statusBarHeightToUse, windowSetting.uDisplayWidth, windowSetting.uDisplayHeight);
    OPENGL_CHECK_ERRORS;

    GLboolean cullface = glIsEnabled(GL_CULL_FACE);
    glDisable(GL_CULL_FACE);
    OPENGL_CHECK_ERRORS;

#if SDL_VIDEO_OPENGL

    glBegin(GL_TRIANGLE_FAN);
    glColor4f(r,g,b,a);
    glVertex4f(m_fillRectVtx[0].x, m_fillRectVtx[1].y, depth, 1);
    glVertex4f(m_fillRectVtx[1].x, m_fillRectVtx[1].y, depth, 1);
    glVertex4f(m_fillRectVtx[1].x, m_fillRectVtx[0].y, depth, 1);
    glVertex4f(m_fillRectVtx[0].x, m_fillRectVtx[0].y, depth, 1);
    glEnd();
    OPENGL_CHECK_ERRORS;

#elif SDL_VIDEO_OPENGL_ES2

    GLfloat colour[] = {
            r,g,b,a,
            r,g,b,a,
            r,g,b,a,
            r,g,b,a};

    float w = windowSetting.uDisplayWidth / 2.0f, h = windowSetting.uDisplayHeight / 2.0f, inv = 1.0f;

    GLfloat vertices[] = {
            -inv + m_fillRectVtx[0].x / w, inv - m_fillRectVtx[1].y / h, depth, 1,
            -inv + m_fillRectVtx[1].x / w, inv - m_fillRectVtx[1].y / h, depth, 1,
            -inv + m_fillRectVtx[1].x / w, inv - m_fillRectVtx[0].y / h, depth, 1,
            -inv + m_fillRectVtx[0].x / w, inv - m_fillRectVtx[0].y / h, depth, 1
    };

    glVertexAttribPointer(VS_COLOR, 4, GL_FLOAT,GL_FALSE, 0, &colour );
    glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,0,&vertices);
    glDisableVertexAttribArray(VS_TEXCOORD0);
    OPENGL_CHECK_ERRORS;
    glDrawArrays(GL_TRIANGLE_FAN,0,4);
    OPENGL_CHECK_ERRORS;

    //Restore old pointers
    glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
    glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0]));
    glEnableVertexAttribArray(VS_TEXCOORD0);

#endif

    if( cullface ) glEnable(GL_CULL_FACE);
    OPENGL_CHECK_ERRORS;

    return true;
}
コード例 #2
0
ファイル: Keyframe.cpp プロジェクト: mejanly/Sharkify
void Keyframe::setKeyframes(SharkBone *bone, glm::vec3 dir, float angle) {
   MatStack.pushMatrix();
   MatStack.rotate(angle, dir); 
   
   glm::mat4 curr = MatStack.getMatrix();
   /* set bone matrix here
      
      make funcs for get head/tail vec4
      move the rest of this to sharkmesh?
      Put the matrix stack in sharkmesh...but send it here
         push from this func, pop from sharkmesh?
         need to be able to push the current bone...not just bones
            in order
    */
   glm::vec4 head = curr * glm::vec4(bone->headPoint - glm::vec3(0, 0, 0), 1);
   glm::vec4 tail = curr * glm::vec4(bone->tailPoint - glm::vec3(0, 0, 0), 1);

   safe_glUniformMatrix4fv(h_uModelMatrix, glm::value_ptr(MatStack.modelViewMatrix));
   
   glVertex4f(head.x, head.y, head.z, head.w);
   glVertex4f(tail.x, tail.y, tail.z, tail.w);
   
   vector<SharkBone *>::iterator ic;
   vector<SharkBone *> bones = bone->gBones();

   MatStack.popMatrix();
   
   for(ic = bones.begin(); ic != bones.end(); ic++) {
      setKeyframes((*ic), dir, angle); 
   }
}
コード例 #3
0
DWORD ShaderPlugin::ProcessOpenGL(ProcessOpenGLStruct *pGL) {
    
    m_shader.BindShader();
    
    for (auto& p : m_parameters) {
        m_extensions.glUniform1fARB(p.UniformLocation, p.GetScaledValue());
    }
    
    if (!m_HostSupportsSetTime)
    {
        update_time(&m_time, m_startTime);
    }
    
    m_extensions.glUniform1fARB(m_timeLocation, m_time);
    m_extensions.glUniform3fvARB(m_resolutionLocation, 3, m_resolution);
        
	glBegin(GL_QUADS);
    //m_extensions.glMultiTexCoord2f(GL_TEXTURE0, 0, 0);
	glVertex4f(-1, -1, 0, 1);
    //m_extensions.glMultiTexCoord2f(GL_TEXTURE0, 0, m_resolution[1]);
	glVertex4f(-1, 1, 0, 1);
    //m_extensions.glMultiTexCoord2f(GL_TEXTURE0, m_resolution[0], m_resolution[1]);
	glVertex4f(1, 1, 0, 1);
    //m_extensions.glMultiTexCoord2f(GL_TEXTURE0, m_resolution[0], 0);
	glVertex4f(1, -1, 0, 1);
	glEnd();
  
    m_shader.UnbindShader();
    
    return FF_SUCCESS;
}
コード例 #4
0
ファイル: OGLRender.cpp プロジェクト: IcooN/OpenEmu
bool OGLRender::RenderFillRect(uint32 dwColor, float depth)
{
    float a = (dwColor>>24)/255.0f;
    float r = ((dwColor>>16)&0xFF)/255.0f;
    float g = ((dwColor>>8)&0xFF)/255.0f;
    float b = (dwColor&0xFF)/255.0f;
    glViewportWrapper(0, windowSetting.statusBarHeightToUse, windowSetting.uDisplayWidth, windowSetting.uDisplayHeight);
    OPENGL_CHECK_ERRORS;

    GLboolean cullface = glIsEnabled(GL_CULL_FACE);
    glDisable(GL_CULL_FACE);
    OPENGL_CHECK_ERRORS;

    glBegin(GL_TRIANGLE_FAN);
    glColor4f(r,g,b,a);
    glVertex4f(m_fillRectVtx[0].x, m_fillRectVtx[1].y, depth, 1);
    glVertex4f(m_fillRectVtx[1].x, m_fillRectVtx[1].y, depth, 1);
    glVertex4f(m_fillRectVtx[1].x, m_fillRectVtx[0].y, depth, 1);
    glVertex4f(m_fillRectVtx[0].x, m_fillRectVtx[0].y, depth, 1);
    glEnd();
    OPENGL_CHECK_ERRORS;

    if( cullface ) glEnable(GL_CULL_FACE);
    OPENGL_CHECK_ERRORS;

    return true;
}
コード例 #5
0
ファイル: scene.cpp プロジェクト: vfrenkel/cg_opengl
void InfinitePlaneMesh::render() {
  glBegin(GL_QUADS);
  glVertex4f(1, 0, 1, 0.00001);
  glVertex4f(-1, 0, 1, 0.00001);
  glVertex4f(-1, 0, -1, 0.00001);
  glVertex4f(1, 0, -1, 0.00001);
  glEnd();
}
コード例 #6
0
void SHADOW_MODEL::DrawInfiniteShadowVolume(VECTOR3D lightPosition, bool drawCaps)
{
	glBegin(GL_QUADS);
	{
		for(unsigned int i=0; i<numTriangles; ++i)
		{
			//if this face does not face the light, continue
			if(!isFacingLight[i])
				continue;

			//Loop through edges on this face
			for(int j=0; j<3; ++j)
			{
				//Draw the shadow volume "edge" if this is a silhouette edge
				if(isSilhouetteEdge[i*3+j])
				{
					VECTOR3D vertex1=vertices[indices[i*3+j]].position;
					VECTOR3D vertex2=vertices[indices[i*3+(j+1)%3]].position;

					glVertex3fv(vertex2);
					glVertex3fv(vertex1);
					glVertex4f(	vertex1.x-lightPosition.x,
								vertex1.y-lightPosition.y,
								vertex1.z-lightPosition.z, 0.0f);
					glVertex4f(	vertex2.x-lightPosition.x,
								vertex2.y-lightPosition.y,
								vertex2.z-lightPosition.z, 0.0f);
				}
			}
		}
	}
	glEnd();

	//Draw caps if required
	if(drawCaps)
	{
		glBegin(GL_TRIANGLES);
		{
			for(unsigned int i=0; i<numTriangles; ++i)
			{
				for(int j=0; j<3; ++j)
				{
					VECTOR3D vertex=vertices[indices[i*3+j]].position;
					
					if(isFacingLight[i])
						glVertex3fv(vertex);
					else
						glVertex4f(	vertex.x-lightPosition.x,
									vertex.y-lightPosition.y,
									vertex.z-lightPosition.z, 0.0f);
				}
			}
		}
		glEnd();
	}
}
コード例 #7
0
ファイル: Face.cpp プロジェクト: Dipakkumar07/school
void Face::draw(int renderMode)
{
	glBegin(renderMode);
	glVertex4f(facepoint0->x, facepoint0->y, facepoint0->z, facepoint0->w);
	glVertex4f(facepoint1->x, facepoint1->y, facepoint1->z, facepoint1->w);
	glVertex4f(facepoint2->x, facepoint2->y, facepoint2->z, facepoint2->w);
	glVertex4f(facepoint3->x, facepoint3->y, facepoint3->z, facepoint3->w);

	glEnd();
}
コード例 #8
0
ファイル: util.cpp プロジェクト: Umarahmad87/Pacman
void DrawCircle(float sx, float sy, float radius, float*color) {

	glColor3fv(color); // set the circle color
	InitCircleVertices(radius);
	glBegin(GL_TRIANGLE_FAN);
	glVertex4f(sx, sy, 0, 1);
	for (int i = 0; i < nvertices; ++i)
		glVertex4f(sx + vertices[i][0], sy + vertices[i][1], 0, 1);
	//			glVertex4f(sx + mx - 1, sy + my - 1, 0, 1);
	glEnd();
}
コード例 #9
0
ファイル: PsychGLGlue.c プロジェクト: BR-Innes/Psychtoolbox-3
void PsychGLVertex4f(PsychWindowRecordType *windowRecord, float x, float y, float z, float w)
{
    // Classic OpenGL? Use glEnd() and be done:
    if (PsychIsGLClassic(windowRecord)) {
        glVertex4f(x,y,z,w);
        return;
    }

    // Make sure we don't overflow our internal static vertex array bufer:
    if (gl_buffer_index > PSYCH_MAX_IMMSIM_VERTEX_COMPONENTS - 12) {
        printf("PTB-ERROR: Overflow of internal immediate mode rendering buffer! Limit of %i components reached.\n", PSYCH_MAX_IMMSIM_VERTEX_COMPONENTS);
        printf("PTB-ERROR: You must reduce the workload, or your stimulus image will be damaged. Likely culprit is Screen('Fill/FrameOval') with too high level of detail!\n\n");
        return;
    }

    // Store (x,y,z,w) vertex pos first:
    gl_buffer[gl_buffer_index++] = x;
    gl_buffer[gl_buffer_index++] = y;
    gl_buffer[gl_buffer_index++] = z;
    gl_buffer[gl_buffer_index++] = w;

    // Then current color (r,g,b,a):
    gl_buffer[gl_buffer_index++] = (float) currentColor[0];
    gl_buffer[gl_buffer_index++] = (float) currentColor[1];
    gl_buffer[gl_buffer_index++] = (float) currentColor[2];
    gl_buffer[gl_buffer_index++] = (float) currentColor[3];
    
    // Then current texture coordinates (s,t,u,v):
    gl_buffer[gl_buffer_index++] = currentTexCoord[0];
    gl_buffer[gl_buffer_index++] = currentTexCoord[1];
    gl_buffer[gl_buffer_index++] = currentTexCoord[2];
    gl_buffer[gl_buffer_index++] = currentTexCoord[3];

    return;
}
コード例 #10
0
ファイル: glx_beginend.c プロジェクト: glproxy/glproxy
static bool
test_without_glproxy(void)
{
    glBegin(GL_TRIANGLES);
    {
        /* Hit a base entrypoint that won't call gl_version() */
        glVertex4f(0, 0, 0, 0);

        /* Hit an entrypoint that will call probably call gl_version() */
        glMultiTexCoord3f(GL_TEXTURE0, 0.0, 0.0, 0.0);

        /* Hit an entrypoint that will probably call
         * glproxy_conservative_has_extension();
         */
        if (has_argb2101010) {
            glTexCoordP3ui(GL_UNSIGNED_INT_2_10_10_10_REV, 0);
        }
    }
    glEnd();

    /* We can't make any assertions about error presence this time
     * around. This test is just trying to catch segfaults.
     */
    return true;
}
コード例 #11
0
void glVertex4fv( const F32 * pv )
{
    AssertFatal( (beginEndMode >= 0), "glVertex3fv(): called outside glBegin/glEnd");
    glVertex4f( pv[0], pv[1], pv[2], pv[3] );
    int glError;
    glError = TEST_FOR_OPENGL_ERRORS
}
コード例 #12
0
void glVertex2i( GLint x, GLint y)
{
    AssertFatal( (beginEndMode >= 0), "glVertex2i(): called outside glBegin/glEnd");
    glVertex4f( GLfloat(x), GLfloat(y), 0.0f, 1.0f );
    int glError;
    glError = TEST_FOR_OPENGL_ERRORS
}
コード例 #13
0
void glVertex3f( GLfloat x, GLfloat y, GLfloat z )
{
    AssertFatal( (beginEndMode >= 0), "glVertex3f(): called outside glBegin/glEnd");
    glVertex4f( x, y, z, 1.0f );
    int glError;
    glError = TEST_FOR_OPENGL_ERRORS
}
コード例 #14
0
/*
 *  Display the scene
 */
void display()
{
   //  Clear the image
   glClear(GL_COLOR_BUFFER_BIT);
   //  Reset previous transforms
   glLoadIdentity();
   //  Set view angle
   glRotated(ph,1,0,0);
   glRotated(th,0,1,0);
   //  Draw 1 pixel points - Randomly generated colors
   glColor3ub( rand()%255, rand()%255, rand()%255 );
   glPointSize(1);
   glBegin(GL_LINE_STRIP);
   
   int i;
   /*  Coordinates  */
   double x = 1;
   double y = 1;
   double z = 1;
   /*  Time step  */
   double dt = 0.001;
   
   for (i=0;i<50000;i++)
   {
      double dx = s*(y-x);
      double dy = x*(r-z)-y;
      double dz = x*y - b*z;
      x += dt*dx;
      y += dt*dy;
      z += dt*dz;
      glVertex4f(x*0.03,y*0.03,z*0.03,w);
   }
   glEnd();
   //  Draw axes in white
   glColor3f(1,1,1);
   glBegin(GL_LINES);
   glVertex3d(0,0,0);
   glVertex3d(1,0,0);
   glVertex3d(0,0,0);
   glVertex3d(0,1,0);
   glVertex3d(0,0,0);
   glVertex3d(0,0,1);
   glEnd();
   //  Label axes
   glRasterPos3d(1,0,0);
   Print("X");
   glRasterPos3d(0,1,0);
   Print("Y");
   glRasterPos3d(0,0,1);
   Print("Z");
   //  Display parameters
   glWindowPos2i(5,5);
   Print("View Angle=%d,%d; s = %f; b = %f; r = %f",th,ph,s,b,r);
   //  Sanity check
   ErrCheck("display");
   //  Flush and swap
   glFlush();
   glutSwapBuffers();
}
コード例 #15
0
void
GenerateShadowVolume(const Occluder * pOcc, const float olight[4])
{
    unsigned int edgeOrder[2];
    unsigned int i, numEdges = pOcc->handle->edges->len;

    for (i = 0; i < numEdges; i++) {
        winged_edge *we = &g_array_index(pOcc->handle->edges, winged_edge, i);

        float f0 = sqdDist(pOcc->handle->planes, we->w[0], olight);
        float f1;
        if (we->w[1] >= 0)
            f1 = sqdDist(pOcc->handle->planes, we->w[1], olight);
        else {
            if (we->w[1] == TOP_EDGE && f0 < 0)
                continue;
            f1 = -f0;
        }

        if (f0 >= 0 && f1 < 0) {
            edgeOrder[0] = we->e[1];
            edgeOrder[1] = we->e[0];
        } else if (f1 >= 0 && f0 < 0) {
            edgeOrder[0] = we->e[0];
            edgeOrder[1] = we->e[1];
        } else {
            continue;
        }

        {
            position *pn0 = &g_array_index(pOcc->handle->points, position, edgeOrder[0]);
            position *pn1 = &g_array_index(pOcc->handle->points, position, edgeOrder[1]);

            /* local segment */
            glVertex3f(pn0->x, pn0->y, pn0->z);
            glVertex3f(pn1->x, pn1->y, pn1->z);
            /* segment projected to infinity (NB. w == 0) */
            glVertex4f(pn1->x * olight[3] - olight[0],
                       pn1->y * olight[3] - olight[1], pn1->z * olight[3] - olight[2], 0.f);

            glVertex4f(pn0->x * olight[3] - olight[0],
                       pn0->y * olight[3] - olight[1], pn0->z * olight[3] - olight[2], 0.f);
        }
    }
}
コード例 #16
0
void RenderFunction(void)
{
  glClear(GL_COLOR_BUFFER_BIT);

  glPointSize(20.0);
  glBegin(GL_POINTS);
  // primul varf
  glColor4f( 1.0f, 0.0f, 0.0f, 1.0f);
  glVertex4f(-0.8f, -0.8f, 0.0f, 1.0f);
  // al doilea varf
  glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
  glVertex4f(0.0f,  0.8f, 0.0f, 1.0f);
  // al treilea varf
  glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
  glVertex4f(0.8f, -0.8f, 0.0f, 1.0f);
  glEnd( );
  glFlush ( );
}
コード例 #17
0
ファイル: geometry.cpp プロジェクト: Shaggy-Rogers/pj64
FX_ENTRY void FX_CALL
grDrawPoint( const void *pt )
{
  float *x = (float*)pt + xy_off/sizeof(float);
  float *y = (float*)pt + xy_off/sizeof(float) + 1;
  float *z = (float*)pt + z_off/sizeof(float);
  float *q = (float*)pt + q_off/sizeof(float);
  unsigned char *pargb = (unsigned char*)pt + pargb_off;
  float *s0 = (float*)pt + st0_off/sizeof(float);
  float *t0 = (float*)pt + st0_off/sizeof(float) + 1;
  float *s1 = (float*)pt + st1_off/sizeof(float);
  float *t1 = (float*)pt + st1_off/sizeof(float) + 1;
  float *fog = (float*)pt + fog_ext_off/sizeof(float);
  LOG("grDrawPoint()\r\n");

  if(nvidia_viewport_hack && !render_to_texture)
  {
    glViewport(0, viewport_offset, viewport_width, viewport_height);
    nvidia_viewport_hack = 0;
  }

  reloadTexture();

  if(need_to_compile) compile_shader();

  glBegin(GL_POINTS);

  if (nbTextureUnits > 2)
  {
    if (st0_en)
      glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *s0 / *q / (float)tex1_width,
      ytex(0, *t0 / *q / (float)tex1_height));
    if (st1_en)
      glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *s1 / *q / (float)tex0_width,
      ytex(1, *t1 / *q / (float)tex0_height));
  }
  else
  {
    if (st0_en)
      glTexCoord2f(*s0 / *q / (float)tex0_width,
      ytex(0, *t0 / *q / (float)tex0_height));
  }
  if (pargb_en)
    glColor4f(pargb[2]/255.0f, pargb[1]/255.0f, pargb[0]/255.0f, pargb[3]/255.0f);
  if (fog_enabled && fog_coord_support)
  {
    if(!fog_ext_en || fog_enabled != 2)
      glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f);
    else
      glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f);
  }
  glVertex4f((*x - (float)widtho) / (float)(width/2) / *q,
    -(*y - (float)heighto) / (float)(height/2) / *q, ZCALC(*z ,*q), 1.0f / *q);

  glEnd();
}
コード例 #18
0
ファイル: FGLPoint.cpp プロジェクト: FKint/FTetris
void FGLPoint::InternDraw(bool standalone){
	if(standalone){
		glBegin(GL_POINTS);
	}

	glVertex4f(this->GetX(), this->GetY(), this->GetZ(), this->GetW());
	if(standalone){
		glEnd();
	}
}
コード例 #19
0
ファイル: renderer.cpp プロジェクト: samidare/engine
    /** 描画
     */
    void CRenderer::Render()
    {
        wglMakeCurrent(m_hdc, m_hglrc);
        glClearColor(0.0f, 0.5f, 1.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT);

	    glBegin(GL_TRIANGLE_STRIP);

        glColor4f(0xE0, 0xE0, 0x60, 0xff);  // 適当な黄色

        glVertex4f(-0.5f, -0.5f, 0.0f, 1.0f);
        glVertex4f(-0.5f, 0.5f, 0.0f, 1.0f);
        glVertex4f( 0.5f, -0.5f, 0.0f, 1.0f);
        glVertex4f( 0.5f, 0.3f, 0.0f, 1.0f);
        glEnd();

        glFlush();
        SwapBuffers(m_hdc);
        wglMakeCurrent(NULL, NULL);
    }
コード例 #20
0
ファイル: Mesh.cpp プロジェクト: Nazul/MSC-CG_OpenGL
void CMesh::Draw(MATRIX4D &M) {
  for (unsigned long i = 0; i < m_Indices.size(); i += 3) {
    for (unsigned long j = 0; j < 3; j++) {
      VECTOR4D &C = m_Vertices[m_Indices[i + j]].Color;
      VECTOR4D &Tex = m_Vertices[m_Indices[i + j]].TexCoord;
      VECTOR4D V = M * m_Vertices[m_Indices[i + j]].Position;
      glColor4f(C.r, C.g, C.b, C.a);
      glTexCoord2f(Tex.x, Tex.y);
      glVertex4f(V.x, V.y, V.z, V.w);
    }
  }
}
コード例 #21
0
ファイル: spheremap.c プロジェクト: xtmacbook/SGI
void 
draw_special_sphere(int tess)
{
    float r = 1.0, r1, r2, z1, z2;
    float theta, phi;
    int nlon = tess, nlat = tess;
    int i, j;

    glBegin(GL_TRIANGLE_FAN);
    theta = M_PI * 1.0 / nlat;
    r2 = r * sin(theta);
    z2 = r * cos(theta);
    glNormal3f(0.0, 0.0, 1.0);
    glVertex4f(0.0, 0.0, r * r, r);
    for (j = 0, phi = 0.0; j <= nlon; j++, phi = 2 * M_PI * j / nlon) {
	glNormal3f(r2 * cos(phi), r2 * sin(phi), z2);
	glVertex4f(r2 * cos(phi) * z2, r2 * sin(phi) * z2, z2 * z2, z2);	/* top */
    }
    glEnd();

    for (i = 2; i < nlat; i++) {
	theta = M_PI * i / nlat;
	r1 = r * sin(M_PI * (i - 1) / nlat);
	z1 = r * cos(M_PI * (i - 1) / nlat);
	r2 = r * sin(theta);
	z2 = r * cos(theta);

	if (fabs(z1) < 0.01 || fabs(z2) < 0.01)
	    break;

	glBegin(GL_QUAD_STRIP);
	for (j = 0, phi = 0; j <= nlat; j++, phi = 2 * M_PI * j / nlon) {
	    glNormal3f(r1 * cos(phi), r1 * sin(phi), z1);
	    glVertex4f(r1 * cos(phi) * z1, r1 * sin(phi) * z1, z1 * z1, z1);
	    glNormal3f(r2 * cos(phi), r2 * sin(phi), z2);
	    glVertex4f(r2 * cos(phi) * z2, r2 * sin(phi) * z2, z2 * z2, z2);
	}
	glEnd();
    }
}
コード例 #22
0
ファイル: stitcher.cpp プロジェクト: bosstweed11/school
/*TODO: add bottom and top face triangles*/
void draw_cube_brute()
{

  draw_triangle(vertices_cube_brute, 4,5,1,BLUE);
  draw_triangle(vertices_cube_brute, 0,4,1,BLUE);
  draw_triangle(vertices_cube_brute, 5,6,2,CYAN);
  draw_triangle(vertices_cube_brute, 1,5,2,CYAN);
  draw_triangle(vertices_cube_brute, 3,2,6,YELLOW);
  draw_triangle(vertices_cube_brute, 7,3,6,YELLOW);
  draw_triangle(vertices_cube_brute, 0,3,7,MAGENTA);
  draw_triangle(vertices_cube_brute, 4,0,7,MAGENTA);
  draw_triangle(vertices_cube_brute, 1,2,3,WHITE);
  draw_triangle(vertices_cube_brute, 7,6,5,WHITE);
  
  
  //manually calculate the normals for the cube
  if(draw_norms){
  		glBegin(GL_LINES);
  		{
  			glVertex4f(1,1,-1,1);
  			glVertex4f(1+1/sqrt(3),1+1/sqrt(3),-1-1/sqrt(3),1);
  			glVertex4f(1,-1,-1,1);
  			glVertex4f(1+1/sqrt(3),-1-1/sqrt(3),-1-1/sqrt(3),1);
  			glVertex4d(1,-1,1,1);
  			glVertex4f(1+1/sqrt(3),-1-1/sqrt(3),1+1/sqrt(3),1);
  			glVertex4d(-1,-1,1,1);
  			glVertex4f(-1-1/sqrt(3),-1-1/sqrt(3),1+1/sqrt(3),1);
  			glVertex4d(-1,1,1,1);
  			glVertex4f(-1-1/sqrt(3),1+1/sqrt(3),1+1/sqrt(3),1);
  			glVertex4d(-1,1,-1,1);
  			glVertex4f(-1-1/sqrt(3),1+1/sqrt(3),-1-1/sqrt(3),1);
  			glVertex4d(-1,-1,-1,1);
  			glVertex4f(-1-1/sqrt(3),-1-1/sqrt(3),-1-1/sqrt(3),1);
  			glVertex4d(1,1,1,1);
  			glVertex4f(1+1/sqrt(3),1+1/sqrt(3),1+1/sqrt(3),1);
  		}
  		glEnd();

  }
}
コード例 #23
0
ファイル: Floor.cpp プロジェクト: beamery/legacy-stool
void Floor::draw(MatrixStack &mViewStack) {
	// save previous modelview matrix
	mViewStack.push();

	// Draw axes
	// y coord offset by 0.01 to stop the lines from fighting each other
	glLineWidth(3.0f);
	glBegin(GL_LINES);
	// x
	glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
	glVertex4f(60.0f, 0.01f, 60.0f, 1.0f);
	glVertex4f(120.0f, 0.01f, 60.0f, 1.0f);
	// y
	glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
	glVertex4f(60.0f, 0.0f, 60.0f, 1.0f);
	glVertex4f(60.0f, 60.0f, 60.0f, 1.0f);
	// z
	glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
	glVertex4f(60.0f, 0.01f, 60.0f, 1.0f);
	glVertex4f(60.0f, 0.01f, 120.0f, 1.0f);
	glEnd();


	// Draw floor grid
	glLineWidth(1.0f);
	for (int i = 0; i < GRID_SIZE - 1; i++) {
		glBegin(GL_LINE_LOOP);
		glColor4f(0.6f, 0.6f, 0.6f, 1.0f);
		for (int j = 0; j < GRID_SIZE - 1; j++) {
			glVertex4f(grid[i][j].x, 0.0f, grid[i][j].z, 1.0f);
			glVertex4f(grid[i+1][j].x, 0.0f, grid[i+1][j].z, 1.0f);
			glVertex4f(grid[i+1][j+1].x, 0.0f, grid[i+1][j+1].z, 1.0f);
			glVertex4f(grid[i][j+1].x, 0.0f, grid[i][j+1].z, 1.0f);
		}
		glEnd();
	}
	// restore previous modelview matrix
	mViewStack.pop();
}
コード例 #24
0
ファイル: wes_begin.c プロジェクト: Solexid/gl-wes-v2
GLvoid
glVertex3f(GLfloat x, GLfloat y, GLfloat z)
{
    if (vt_possize > 3){
        glVertex4f(x, y, z, 1.0);
    } else {
        vt_possize = 3;
        vt_current->x = x;
        vt_current->y = y;
        vt_current->z = z;
        vt_vbuffer[vt_count++] = vt_current[0];
    }
}
コード例 #25
0
ファイル: main.cpp プロジェクト: hksonngan/gpgpu
void recursion( float startX,
				float startY,
				float startZ,
				float startW)
{
	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,0,streamoutBufffer[0]);

	glBeginTransformFeedback(GL_POINTS);
	glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, outputQuery);
	glPointSize(1);
	glBegin(GL_POINTS);
	glVertex4f(startX, startY, startZ, startW);
	glEnd();
	glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);

	glEndTransformFeedback();

	GLint outPointCount = 0;
	GLint succ = 0;

	while(!succ)
		glGetQueryObjectiv(outputQuery, GL_QUERY_RESULT_AVAILABLE, &succ);
	glGetQueryObjectiv(outputQuery, GL_QUERY_RESULT, &outPointCount);
	//std::cout << "points written: " << outPointCount << std::endl;
	succ = 0;

	glEnableClientState(GL_VERTEX_ARRAY);
	int bb = 0;
	while(outPointCount > 0)
	{
		glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER,0,streamoutBufffer[(bb+1)%2]);
		glBeginTransformFeedback(GL_POINTS);

		glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, outputQuery);

		glBindBufferARB(GL_ARRAY_BUFFER_ARB, streamoutBufffer[bb]);
		glVertexPointer(4,GL_FLOAT,0,NULL);
		glDrawArrays(GL_POINTS, 0, outPointCount);

		glEndTransformFeedback();

		glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
		while(!succ)
			glGetQueryObjectiv(outputQuery, GL_QUERY_RESULT_AVAILABLE, &succ);
		glGetQueryObjectiv(outputQuery, GL_QUERY_RESULT, &outPointCount);
		succ = 0;

		bb = (bb + 1) % 2;
	}
	glDisableClientState(GL_VERTEX_ARRAY);
}
コード例 #26
0
// draw the pool ball!
void PoolBall::render(glm::dmat4 &parent_model)
{
	glm::dmat4 model = parent_model * glm::translate(glm::dmat4(1.0), glm::dvec3(x, diameter/2, z)) * rotation * glm::scale(glm::dmat4(1.0), glm::dvec3(diameter/2));

	mesh.render(tex, model);

#if 0
	glUseProgram(0); glErrorCheck();
	
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glMultMatrixd(&view[0][0]);
	glMultMatrixd(&parent_model[0][0]);
	glMatrixMode(GL_PROJECTION);
	//glLoadIdentity();
extern double wide_view[];	
	//gluLookAt(eye[0], eye[1], eye[2], wide_view[3], wide_view[4], wide_view[5], 0, 1, 0);
	glLoadMatrixd(&perspective[0][0]);
	
	glEnable(GL_DEPTH_TEST);
	glBegin(GL_LINES);
#if 0
	glVertex4f(x, 0, z, 1.0f);
	glVertex4f(light_position[0], light_position[1], light_position[2], 1.0f);
#endif
	
#if 0
	for (int i = 0; i < vertices.size(); ++i)
	{
		glVertex3f(vertices[i][0], vertices[i][1], vertices[i][2]);
		glVertex3f(vertices[i][0] + normals[i][0], vertices[i][1] + normals[i][1], vertices[i][2] + normals[i][2]);
	}
#endif
	glEnd(); glErrorCheck();
#endif
	
	glDisable(GL_TEXTURE_2D);
}
コード例 #27
0
static void
setup_legacy_const_attribute (CoglContext *ctx,
                              CoglPipeline *pipeline,
                              CoglAttribute *attribute)
{
#ifdef COGL_PIPELINE_PROGEND_GLSL
  if (attribute->name_state->name_id == COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY)
    {
      if (ctx->driver != COGL_DRIVER_GLES1)
        setup_generic_const_attribute (ctx, pipeline, attribute);
    }
  else
#endif
    {
      float vector[4] = { 0, 0, 0, 1 };
      float *boxed = attribute->d.constant.boxed.v.float_value;
      int n_components = attribute->d.constant.boxed.size;
      int i;

      for (i = 0; i < n_components; i++)
        vector[i] = boxed[i];

      switch (attribute->name_state->name_id)
        {
        case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
          GE (ctx, glColor4f (vector[0], vector[1], vector[2], vector[3]));
          break;
        case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
          GE (ctx, glNormal3f (vector[0], vector[1], vector[2]));
          break;
        case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
          {
            int layer_number = attribute->name_state->layer_number;
            CoglPipelineLayer *layer =
              _cogl_pipeline_get_layer (pipeline, layer_number);
            int unit = _cogl_pipeline_layer_get_unit_index (layer);

            GE (ctx, glClientActiveTexture (GL_TEXTURE0 + unit));

            GE (ctx, glMultiTexCoord4f (vector[0], vector[1], vector[2], vector[3]));
            break;
          }
        case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
          GE (ctx, glVertex4f (vector[0], vector[1], vector[2], vector[3]));
          break;
        default:
          g_warn_if_reached ();
        }
    }
}
コード例 #28
0
ファイル: draw_routines.cpp プロジェクト: jinghuage/pcaster
static void vert(float theta, float phi)
{
  float r = 0.75f;
  float x, y, z, nx, ny, nz;

  nx = sin(DTOR * theta) * cos(DTOR * phi);
  ny = sin(DTOR * phi);
  nz = cos(DTOR * theta) * cos(DTOR * phi);
  glNormal3f(nx, ny, nz);

  x = r * sin(DTOR * theta) * cos(DTOR * phi);
  y = r * sin(DTOR * phi);
  z = r * cos(DTOR * theta) * cos(DTOR * phi);
  glVertex4f(x, y, z, 1.0);
}
コード例 #29
0
ファイル: Mesh.cpp プロジェクト: Kalabaza/Graficas
void CMesh::Draw(const MATRIX4D &M)
{
    for (unsigned int i = 0; i < m_Indexes.size(); i += 3)
    {
        for (int j = 0; j < 3; ++j)
        {
            auto &C = m_Vertexes[m_Indexes[i + j]].Color;
            glColor4f(C.r, C.g, C.b, C.a);
            auto &T = m_Vertexes[m_Indexes[i + j]].TexCoord;
            glTexCoord2f(T.x, T.y);
            VECTOR4D V = M * m_Vertexes[m_Indexes[i + j]].Position;
            glVertex4f(V.x, V.y, V.z, V.w);
        }
    }
}
コード例 #30
0
static void renderSlices( const SliceClipper& sliceClipper )
{
    int numberOfSlices = static_cast<int>( 3.6 / sliceClipper.sliceDistance );

    for( int s = 0; s < numberOfSlices; ++s )
    {
        glBegin( GL_POLYGON );
        for( int i = 0; i < 6; ++i )
        {
            eq::Vector3f pos =
                    sliceClipper.getPosition( i, numberOfSlices-1-s );

            glVertex4f( pos.x(), pos.y(), pos.z(), 1.0 );
        }
        glEnd();
    }
}