private static void OnRenderFrame() { //Calculate time elapsed since last frame watch.Stop(); float deltaTime = (float)watch.ElapsedTicks / System.Diagnostics.Stopwatch.Frequency; watch.Restart(); //Adjust angle based on time passed angle += deltaTime; //Set up OpenGL viewport and clear colour and depth bits Gl.Viewport(0, 0, width, height); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); //Use shader program program.Use(); //For each cube in cubes list, then for each squares in each of these cubes, bind elements, colours and vertices, then finally draw the cube foreach (Cube c in cubes) { foreach (Square s in c.squares) { drawSquare(s, 0); } } Glut.glutSwapBuffers(); }
// --- Callbacks --- #region Display() private static void Display() { int i; Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); for (i = 0; i < numberStars; i++) { stars[i].X += stars[i].VX; if (stars[i].X < Glut.glutGet(Glut.GLUT_WINDOW_WIDTH)) { Gl.glBegin(Gl.GL_LINE_STRIP); Gl.glColor3ub(0, 0, 0); Gl.glVertex2i((int)(stars[i].X - stars[i].VX * 4), (int)stars[i].Y); Gl.glColor3ub(255, 255, 255); Gl.glVertex2i((int)stars[i].X, (int)stars[i].Y); Gl.glEnd(); } else { stars[i].X = 0; } } Glut.glutSwapBuffers(); }
private static void OnRenderFrame() { // calculate how much time has elapsed since the last frame watch.Stop(); float deltaTime = (float)watch.ElapsedTicks / System.Diagnostics.Stopwatch.Frequency; watch.Restart(); Matrix4 modelMatrix = CreateModelMatrix(time_); time_ += deltaTime; effect_.update(deltaTime, Neutrino._math.vec3_(modelMatrix[3].x, modelMatrix[3].y, modelMatrix[3].z), null); // set up the OpenGL viewport and clear both the color and depth bits Gl.Viewport(0, 0, width, height); //Gl.ClearColor(0.5F, 0.5F, 0.5F, 0.0F); Gl.ClearColor(0.4F, 0.4F, 0.4F, 0.0F); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Matrix4 projMatrix = Matrix4.CreateOrthographic(width, height, 1F, 10000F); //.CreatePerspectiveFieldOfView(60F * (float)Math.PI / 180F, (float)width / height, 1F, 10000F); Matrix4 viewMatrix = Matrix4.LookAt(new Vector3(0, 0, 1000), Vector3.Zero, Vector3.Up); effect_.render(ref projMatrix, ref viewMatrix, ref modelMatrix); Glut.glutSwapBuffers(); }
static void display() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glLoadIdentity(); setCamera(); material(Estrutura.tipo_material.slate); desenhaSolo(); //desenhaEixos(); desenhaLabirinto(); /*glPushMatrix(); * glScalef(0.005,0.005,0.005); * modelo.homer.SetSequence(0); * mdlviewer_display(modelo.homer); * glPopMatrix();*/ if (estado.picking >= 0) { desenhaInformacao(Glut.glutGet(Glut.GLUT_WINDOW_WIDTH), Glut.glutGet(Glut.GLUT_WINDOW_HEIGHT)); menuNos(); } if (estado.eixoTranslaccao < 0 && estado.eixoTranslaccao != -4) { // desenha plano de translacção Console.Write("Translate... " + estado.eixoTranslaccao + "\n"); desenhaPlanoDrag(estado.eixoTranslaccao); } Glut.glutPostRedisplay(); Gl.glFlush(); Glut.glutSwapBuffers(); }
private static void OnRenderFrame() { // set up the OpenGL viewport and clear both the color and depth bits Gl.Viewport(0, 0, width, height); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // use our shader program Gl.UseProgram(program); // transform the triangle program["model_matrix"].SetValue(Matrix4.CreateTranslation(new Vector3(-1.5f, 0, 0))); // bind the vertex attribute arrays for the triangle (the hard way) uint vertexPositionIndex = (uint)Gl.GetAttribLocation(program.ProgramID, "vertexPosition"); Gl.EnableVertexAttribArray(vertexPositionIndex); Gl.BindBuffer(triangle); Gl.VertexAttribPointer(vertexPositionIndex, triangle.Size, triangle.PointerType, true, 12, IntPtr.Zero); Gl.BindBuffer(triangleElements); // draw the triangle Gl.DrawElements(BeginMode.Triangles, triangleElements.Count, DrawElementsType.UnsignedInt, IntPtr.Zero); // transform the square program["model_matrix"].SetValue(Matrix4.CreateTranslation(new Vector3(1.5f, 0, 0))); // bind the vertex attribute arrays for the square (the easy way) Gl.BindBufferToShaderAttribute(square, program, "vertexPosition"); Gl.BindBuffer(squareElements); // draw the square Gl.DrawElements(BeginMode.Quads, squareElements.Count, DrawElementsType.UnsignedInt, IntPtr.Zero); Glut.glutSwapBuffers(); }
// --- Callbacks --- #region Display() /// <summary> /// Called to draw the client area. /// </summary> private static void Display() { // clear the color and depth buffers Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // draw the world grid Gl.glPushMatrix(); // position the grid Gl.glTranslatef(-10.0f, 0.0f, 10.0f); // draw the grid Gl.glLineWidth(1.0f); Gl.glColor3f(0.2f, 1.0f, 0.2f); RenderGrid(); Gl.glPopMatrix(); // draw the car Gl.glPushMatrix(); // translate to (x, 0, z) world coordinate Gl.glTranslatef(objectPositionX, 0.0f, objectPositionZ); Gl.glLineWidth(2.0f); // draw the object RenderObject(); Gl.glPopMatrix(); Gl.glFlush(); Glut.glutSwapBuffers(); }
private static void onRenderFrame() { watch.Stop(); float delat = (float)watch.ElapsedMilliseconds / System.Diagnostics.Stopwatch.Frequency; watch.Restart(); angle += delat * 10000; Gl.Viewport(pos_x, pos_y, width, height); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); SHprogram.Use(); SHprogram["model_matrix"].SetValue(Matrix4.CreateRotationY(angle) * Matrix4.CreateTranslation(new Vector3(-1.5f, 0, 0))); uint vertexPos = (uint)Gl.GetAttribLocation(SHprogram.ProgramID, "vertexPos"); Gl.EnableVertexAttribArray(vertexPos); Gl.BindBuffer(triangle); Gl.VertexAttribPointer(vertexPos, triangle.Size, triangle.PointerType, true, 12, IntPtr.Zero); Gl.BindBufferToShaderAttribute(triangle_col, SHprogram, "vertexCol"); Gl.BindBuffer(triangle_el); Gl.DrawElements(BeginMode.Triangles, triangle_el.Count, DrawElementsType.UnsignedInt, IntPtr.Zero); Glut.glutSwapBuffers(); }
private static void OnRenderFrame() { Gl.Viewport(0, 0, width, height); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Glut.glutSwapBuffers(); }
// --- Callbacks --- #region Display() private static void Display() { Node point; Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); point = points; while (point != null) { Gl.glPushMatrix(); Gl.glColor3ub(point.R, point.G, point.B); Gl.glTranslatef(point.X, point.Y, 0.0f); Glut.glutSolidCone(width > height ? width : height, 1.0, 32, 1); if (drawPoints) { Gl.glDepthFunc(Gl.GL_ALWAYS); Gl.glColor3ub(255, 255, 255); Gl.glBegin(Gl.GL_POINTS); Gl.glVertex2i(0, 0); Gl.glEnd(); Gl.glDepthFunc(Gl.GL_LEQUAL); } Gl.glPopMatrix(); point = point.Next; } Glut.glutSwapBuffers(); }
static void OnDisplay() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glLoadIdentity(); Glu.gluLookAt(eye_x, eye_y, eye_z, 0, -10, 0, 1, 0, 0); Gl.glRotated(aX, 1, 0, 0); Gl.glRotated(aY, 0, 1, 0); Gl.glRotated(aZ, 0, 0, 1); Gl.glTranslated(1.5, 0, 0); Gl.glEnable(Gl.GL_TEXTURE_2D); //Glu.gluQuadricTexture(); //основание Gl.glTranslated(-1.5, 0, 0); Glut.glutSolidSphere(1.1, 50, 50); //тело Gl.glTranslated(1.6, 0, 0); Glut.glutSolidSphere(0.75, 50, 50); //голова Gl.glTranslated(1.1, 0, 0); Glut.glutSolidSphere(0.55, 50, 50); //правая рука Gl.glTranslated(-1, 0, 0); Gl.glRotated(20, 0, 1, 0); Glut.glutSolidCylinder(0.05, 2.5, 50, 50); //левая рука Gl.glRotated(-140, 0, -1, 0); Glut.glutSolidCylinder(0.05, 2.5, 50, 50); //шляпа Gl.glTranslated(-1.3, 0, 0.47); Gl.glRotated(290, 0, 1, 0); Glut.glutSolidCone(0.5, 0.75, 50, 50); //нос Gl.glTranslated(0, 0.3, -0.4); Gl.glRotated(275, 1, 0, 0); Glut.glutSolidCone(0.07, 0.75, 50, 50); //правый глаз Gl.glTranslated(-0.2, -0.25, 0.15); Glut.glutSolidSphere(0.05, 50, 50); //левый глаз Gl.glTranslated(0.4, 0, 0); Glut.glutSolidSphere(0.05, 50, 50); //рот Gl.glTranslated(-0.47, 0.4, 0.0175); Gl.glRotated(90, 0, 1, 0); Glut.glutSolidCylinder(0.05, 0.5, 50, 50); Glut.glutSwapBuffers(); }
static void display() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Cg.cgSetParameter1f(myCgVertexParam_twisting, myTwisting); CgGl.cgGLBindProgram(myCgVertexProgram); checkForCgError("binding vertex program"); CgGl.cgGLEnableProfile(myCgVertexProfile); checkForCgError("enabling vertex profile"); CgGl.cgGLBindProgram(myCgFragmentProgram); checkForCgError("binding fragment program"); CgGl.cgGLEnableProfile(myCgFragmentProfile); checkForCgError("enabling fragment profile"); drawSubDividedTriangle(5); CgGl.cgGLDisableProfile(myCgVertexProfile); checkForCgError("disabling vertex profile"); CgGl.cgGLDisableProfile(myCgFragmentProfile); checkForCgError("disabling fragment profile"); Glut.glutSwapBuffers(); }
// --- Callbacks --- #region Display() private static void Display() { float[] knots = { 0, 0, 0, 0, 1, 1, 1, 1 }; int i, j; Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glPushMatrix(); Gl.glRotatef(330, 1, 0, 0); Gl.glScalef(0.25f, 0.25f, 0.25f); Glu.gluBeginSurface(nurb); Glu.gluNurbsSurface(nurb, 8, knots, 8, knots, 4 * 3, 3, controlPoints, 4, 4, Gl.GL_MAP2_VERTEX_3); Glu.gluEndSurface(nurb); if (showPoints) { Gl.glPointSize(5.0f); Gl.glDisable(Gl.GL_LIGHTING); Gl.glColor3f(1, 1, 0); Gl.glBegin(Gl.GL_POINTS); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { Gl.glVertex3f(controlPoints[i, j, 0], controlPoints[i, j, 1], controlPoints[i, j, 2]); } } Gl.glEnd(); Gl.glEnable(Gl.GL_LIGHTING); } Gl.glPopMatrix(); Glut.glutSwapBuffers(); }
static void Desenha() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glColor3f(0.0f, 0.0f, 1.0f); Glut.glutSolidTeapot(50.0f); Glut.glutSwapBuffers(); }
//Рисование снеговика, вокруг которого вращается камера static void drawSnowMan() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // установить камеру Gl.glLoadIdentity(); vec3 cameraLook = cameraPos + cameraFront; Glu.gluLookAt(cameraPos.x, cameraPos.y, cameraPos.z, cameraLook.x, cameraLook.y, cameraLook.z, cameraUp.x, cameraUp.y, cameraUp.z); Glu.gluLookAt(camX, camY, camZ, 0.0, 0.0, 0.0, 0.0, camUpY, 0.0); Gl.glColor3f(1.0f, 1.0f, 1.0f); // тело снеговика Gl.glTranslatef(0.0f, 0.75f, 0.0f); Glut.glutSolidSphere(0.75f, 20, 20); // голова снеговика Gl.glTranslatef(0.0f, 1.0f, 0.0f); Glut.glutSolidSphere(0.25f, 20, 20); // глаза снеговика Gl.glPushMatrix(); Gl.glColor3f(0.0f, 0.0f, 0.0f); Gl.glTranslatef(0.05f, 0.10f, 0.18f); Glut.glutSolidSphere(0.05f, 10, 10); Gl.glTranslatef(-0.1f, 0.0f, 0.0f); Glut.glutSolidSphere(0.05f, 10, 10); Gl.glPopMatrix(); // нос снеговика Gl.glColor3f(1.0f, 0.5f, 0.5f); Gl.glRotatef(0.0f, 1.0f, 0.0f, 0.0f); Glut.glutSolidCone(0.08f, 0.5f, 10, 2); //Gl.glPopMatrix(); Gl.glFlush(); Glut.glutSwapBuffers(); }
static void Redraw() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glPushMatrix(); Axis3D.DrawAxis(); FigureMotion(); // Установка материала шара Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, light1); Gl.glLightfv(Gl.GL_LIGHT1, Gl.GL_POSITION, light2); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, ambient); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, diffuse); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, specular); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_EMISSION, emission); Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, shininess); // Отрисовка шара Glut.glutSolidSphere(3.0, 50, 50); // шар с радиусом 3 Gl.glPopMatrix(); Glut.glutSwapBuffers(); // Переключение буфферов отрисовки CalculateNewFigureSize(); }
private void OnRenderFrame() { Gl.Viewport(0, 0, width, height); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Gl.UseProgram(program); map.Draw(program); program["view_matrix"].SetValue( Matrix4.CreateTranslation(new Vector3(xCam, yCam, zCam)) * Matrix4.CreateRotationX(ryCam) * Matrix4.LookAt(new Vector3(0, 0, -1), Vector3.Zero, new Vector3(0, 1, 0))); player.position = new Vector3(xCam, yCam, zCam); if (map.mapY + player.position.Z < player.RenderDistance + 2) { Console.WriteLine("Created new line on Z"); map.ResizeMap(false); } else if (map.mapX + player.position.X < player.RenderDistance + 2) { Console.WriteLine("Created new line on X"); map.ResizeMap(true); } Glut.glutSwapBuffers(); }
private static void OnRenderFrame() { // calculate how much time has elapsed since the last frame watch.Stop(); float deltaTime = (float)watch.ElapsedTicks / System.Diagnostics.Stopwatch.Frequency; watch.Restart(); // use the deltaTime to adjust the angle of the cube angle += deltaTime; // set up the OpenGL viewport and clear both the color and depth bits Gl.Viewport(0, 0, width, height); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // use our shader program and bind the crate texture Gl.UseProgram(program); Gl.BindTexture(crateTexture); // set the transformation of the cube program["model_matrix"].SetValue(Matrix4.CreateRotationY(angle / 2) * Matrix4.CreateRotationX(angle)); // bind the vertex positions, UV coordinates and element array Gl.BindBufferToShaderAttribute(cube, program, "vertexPosition"); Gl.BindBufferToShaderAttribute(cubeUV, program, "vertexUV"); Gl.BindBuffer(cubeQuads); // draw the textured cube Gl.DrawElements(BeginMode.Quads, cubeQuads.Count, DrawElementsType.UnsignedInt, IntPtr.Zero); Glut.glutSwapBuffers(); }
static void on_display() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glLoadIdentity(); Glu.gluLookAt(0, 0, 5, 0, 0, 1, 0, 1, 0); Glut.glutSolidTeapot(1); Glut.glutSwapBuffers(); }
private static void OnRenderFrame() { // set up the OpenGL viewport and clear both the color and depth bits Gl.Viewport(0, 0, width, height); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Glut.glutSwapBuffers(); }
// --- Callbacks --- #region Display() private static void Display() { int x, y; int i, j; float minX, minY, maxX, maxY; float isize2, tmp0, tmp1, tmp2, tmp3; float sinTheta, cosTheta; Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); isize2 = (float)isize / 2; sinTheta = (float)Math.Sin(DegreeToRadian(theta)); cosTheta = (float)Math.Cos(DegreeToRadian(theta)); // Rotate the corners of the image to get the bounding box of the rotated image tmp0 = -isize2 * cosTheta - -isize2 * sinTheta; tmp1 = isize2 * cosTheta - -isize2 * sinTheta; tmp2 = isize2 * cosTheta - isize2 * sinTheta; tmp3 = -isize2 * cosTheta - isize2 * sinTheta; minX = (float)(Math.Min(tmp0, Math.Min(tmp1, Math.Min(tmp2, tmp3)))); maxX = (float)(Math.Max(tmp0, Math.Max(tmp1, Math.Max(tmp2, tmp3)))); tmp0 = -isize2 * sinTheta + -isize2 * cosTheta; tmp1 = isize2 * sinTheta + -isize2 * cosTheta; tmp2 = isize2 * sinTheta + isize2 * cosTheta; tmp3 = -isize2 * sinTheta + isize2 * cosTheta; minY = (float)(Math.Min(tmp0, Math.Min(tmp1, Math.Min(tmp2, tmp3)))); maxY = (float)(Math.Max(tmp0, Math.Max(tmp1, Math.Max(tmp2, tmp3)))); Gl.glBegin(Gl.GL_POINTS); for (j = (int)minY; j < maxY; j++) { for (i = (int)minX; i < maxX; i++) { // Calculate the sample point x = (int)((i * cosTheta - j * sinTheta) + isize2); y = (int)((i * sinTheta + j * cosTheta) + isize2); // Skip out if we're going to sample outside the bitmap if (x < 0 || x >= isize || y < 0 || y >= isize) { continue; } Gl.glColor3ub(image[(isize * y + x) * 3 + 0], image[(isize * y + x) * 3 + 1], image[(isize * y + x) * 3 + 2]); Gl.glVertex2i(width / 2 + i, width / 2 + j); } } Gl.glEnd(); theta += 6.0f; if (theta > 360.0f) { theta -= 360.0f; } Glut.glutSwapBuffers(); }
static void Display() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glPushMatrix(); Gl.glBegin(Gl.GL_LINES); Gl.glColor3f(0.0f, 1.0f, 0.0f); // ось x Gl.glVertex3f(0f, 0f, 0f); Gl.glVertex3f(14f, 0f, 0f); Gl.glColor3f(1.0f, 0.0f, 0.0f); // ось y Gl.glVertex3f(0f, 0f, 0f); Gl.glVertex3f(0f, 14f, 0f); Gl.glColor3f(0.0f, 0.0f, 1.0f); // ось z Gl.glVertex3f(0f, 0f, 0f); Gl.glVertex3f(0f, 0f, 14f); Gl.glEnd(); Gl.glPushMatrix(); Gl.glRotatef(_angleLight1, 0f, 0f, 1f); Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, lpt); Gl.glPopMatrix(); Gl.glPushMatrix(); Gl.glTranslatef(0f, 0f, 5f); Gl.glScalef(2f, 2f, 2f); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, no_mat); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, mat_diffuse); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, no_mat); Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, no_shininess); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_EMISSION, no_mat); Glut.glutSolidCone(1, 2, 50, 50); Gl.glPopMatrix(); Gl.glPushMatrix(); Gl.glRotatef(_angleLight1, 0f, 1f, 0f); Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, rpt); Gl.glPopMatrix(); Gl.glPushMatrix(); Gl.glTranslatef(6f, 0f, 0f); Gl.glScalef(2f, 2f, 2f); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_AMBIENT, mat_ambient); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_DIFFUSE, mat_diffuse); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_SPECULAR, mat_specular); Gl.glMaterialf(Gl.GL_FRONT, Gl.GL_SHININESS, no_shininess); Gl.glMaterialfv(Gl.GL_FRONT, Gl.GL_EMISSION, mat_emission); Glut.glutSolidSphere(1.0, 50, 50); Gl.glPopMatrix(); Glut.glutSwapBuffers(); // вращение _angleLight1 += 1f; _angleLight2 += 1.5f; }
public void RenderScene() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); camera.Look(); World.Render(); Glut.glutSwapBuffers(); }
private static void OnRenderFrame() { watch.Stop(); float DeltaTime = (float)watch.ElapsedTicks / (System.Diagnostics.Stopwatch.Frequency); watch.Restart(); Shader_Program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(PosX, 0, PosZ), new Vector3(PosX + Math.Sin(TurnAngle), 0, PosZ + Math.Cos(TurnAngle)), Vector3.Up)); Gl.Viewport(0, 0, CurrentWidth, CurrentHeight); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); Gl.UseProgram(Shader_Program); Gl.BindTexture(Texture1); /* * foreach (var Objects in Object_List) * { * * Shader_Program["model_matrix"].SetValue(Matrix4.CreateTranslation(new Vector3(0, 0, 0))); * Gl.BindBufferToShaderAttribute(Objects.Cube, Shader_Program, "vertexPosition"); * Gl.BindBufferToShaderAttribute(Objects.CubeUV, Shader_Program, "vertexUV"); * Gl.BindBuffer(Objects.CubeQuads); * * Gl.DrawElements(BeginMode.Quads, Objects.CubeQuads.Count, DrawElementsType.UnsignedInt, IntPtr.Zero); * }*/ Shader_Program["model_matrix"].SetValue(Matrix4.CreateTranslation(new Vector3(0, 0, 0))); Gl.BindBufferToShaderAttribute(Floor.Cube, Shader_Program, "vertexPosition"); Gl.BindBufferToShaderAttribute(Floor.CubeUV, Shader_Program, "vertexUV"); Gl.BindBuffer(Floor.CubeQuads); Gl.DrawElements(BeginMode.Quads, Floor.CubeQuads.Count, DrawElementsType.UnsignedInt, IntPtr.Zero); Gl.BindTexture(Texture2); Shader_Program["model_matrix"].SetValue(Matrix4.CreateTranslation(new Vector3(0, 0, 0))); Gl.BindBufferToShaderAttribute(Box.Cube, Shader_Program, "vertexPosition"); Gl.BindBufferToShaderAttribute(Box.CubeUV, Shader_Program, "vertexUV"); Gl.BindBuffer(Box.CubeQuads); Gl.DrawElements(BeginMode.Quads, Box.CubeQuads.Count, DrawElementsType.UnsignedInt, IntPtr.Zero); // draw my cube //Shader_Program["model_matrix"].SetValue(Matrix4.CreateRotationX(xangle) * Matrix4.CreateRotationY(yangle) * Matrix4.CreateRotationZ(zangle)); /*Shader_Program["model_matrix"].SetValue(Matrix4.CreateTranslation(new Vector3(0,0,0))); * Gl.BindBufferToShaderAttribute(Floor.Cube, Shader_Program, "vertexPosition"); * Gl.BindBufferToShaderAttribute(Floor.CubeUV, Shader_Program, "vertexUV"); * Gl.BindBuffer(Floor.CubeQuads); * * Gl.DrawElements(BeginMode.Quads, Floor.CubeQuads.Count, DrawElementsType.UnsignedInt, IntPtr.Zero); */ Glut.glutSwapBuffers(); }
private static void OnRenderFrame() { Gl.Viewport(0, 0, width, height); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); //Use shader Gl.UseProgram(program); //Drawing cube #region int num = 0; for (int j = 0; j < maxY; j++) { for (int i = 0; i < maxX; i++) { if (num == numShapes) { break; } //select texture if (texRandom[num] == 0) { Gl.BindTexture(crateTexture); } else if (texRandom[num] == 1) { Gl.BindTexture(rectTexture); } else { Gl.BindTexture(pyTexture); } //set translation offset program["model_matrix"].SetValue( Matrix4.CreateScaling(new Vector3(0.5f, 0.5f, 0.5f)) * Matrix4.CreateTranslation(new Vector3(-3 + i * 1.1f, 1.5f - j * 1.1f, 0))); Gl.BindBufferToShaderAttribute(cube, program, "vertexPosition"); Gl.BindBufferToShaderAttribute(cubeUV, program, "vertexUV"); Gl.BindBuffer(cubeElements); //Dibuja el cube Gl.DrawElements(BeginMode.Quads, cubeElements.Count, DrawElementsType.UnsignedInt, IntPtr.Zero); num++; } if (num == numShapes) { break; } } #endregion Glut.glutSwapBuffers(); }
private static void OnRenderFrame() { //Clock tick used for animation watch.Stop(); float deltaTime = (float)watch.ElapsedTicks / System.Diagnostics.Stopwatch.Frequency; watch.Restart(); //define rotations based on pressed keys if (autoRotate) { xangle += deltaTime / 2; yangle += deltaTime; } if (up) { xangle -= deltaTime; } if (down) { xangle += deltaTime; } if (left) { yangle -= deltaTime; } if (right) { yangle += deltaTime; } Gl.Viewport(0, 0, width, height); Gl.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); //Use shader Gl.UseProgram(program); //Drawing cube #region Gl.BindTexture(crateTexture); program["model_matrix"].SetValue( Matrix4.CreateRotationX(xangle) * Matrix4.CreateRotationY(yangle)); program["enable_lighting"].SetValue(lighting); Gl.BindBufferToShaderAttribute(cube, program, "vertexPosition"); Gl.BindBufferToShaderAttribute(cubeUV, program, "vertexUV"); Gl.BindBuffer(cubeElements); Gl.DrawElements(BeginMode.Quads, cubeElements.Count, DrawElementsType.UnsignedInt, IntPtr.Zero); #endregion Glut.glutSwapBuffers(); }
// --- Callbacks --- #region Display() private static void Display() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); Gl.glRasterPos2i(0, 0); Gl.glBitmap(0, 0, 0, 0, rasterX, rasterY, nullImage); Gl.glDrawPixels(256, 256, Gl.GL_RGB, Gl.GL_UNSIGNED_BYTE, image); Glut.glutSwapBuffers(); }
public void Redraw() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glLoadIdentity(); Glu.gluLookAt(0, 0, 1, 0, 0, 0, 0, 1, 0);//setting looker Render(); Glut.glutSwapBuffers(); }
public override void DrawFunc() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glLoadIdentity(); UpdateLookerPosition(); this.RedisplayMeth(); Glut.glutSwapBuffers(); }
static void Display() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); Gl.glPushMatrix(); Axis3D.DrawAxis(); Gl.glPopMatrix(); Glut.glutSwapBuffers(); }
// --- Callbacks --- #region Display() private static void Display() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); Gl.glPushMatrix(); Gl.glRotatef(spin, 0.0f, 0.0f, 1.0f); Gl.glColor3f(1.0f, 1.0f, 1.0f); Gl.glRectf(-25.0f, -25.0f, 25.0f, 25.0f); Gl.glPopMatrix(); Glut.glutSwapBuffers(); }