opentk

OpenTK - After multiplying with ProjectionMatrix nothing is rendering anymore

可紊 提交于 2019-12-12 04:06:43
问题 From a tutorial that refused to explain it I got the following code. It was a lwjgl tutorial I copied where it worked perfectly fine. I'm not sure if the problem is created by having OpenGl differ from the java openGl, but since it's only math I would be surprised by that: private void createProjectionMatrix(int width, int height) { float aspectRatio = width / height; float yScale = (float)((1f / Math.Tan(Maths.degreeToRadian(FOV/2f))) * aspectRatio); float xScale = yScale / aspectRatio;

OpenGL - Use non normalized texcoords

烂漫一生 提交于 2019-12-12 03:36:48
问题 By default, OpenGL uses normalized TexCoords, which mean the value must be between 0 and 1 ([0..1]). the common implementation of Vertex must be look something like this: // Common Implementation of Vertex Vertex v = new Vertex( // Position new Vector2(0f, 500f), // 'Normalized' TexCoords [0..1] new Vector2(0f, 1f), // Color of Vertex Color.White ); // Or in immediate mode.. // It's the same, we still need to specify between 0 and 1 ([0..1]) GL.TexCoord2(1f, 0f); However, is it possible to

How to minimize floating point inaccuracy in rotating a point in 3D space about an arbitrary axis?

柔情痞子 提交于 2019-12-12 03:08:15
问题 I have a program which visualizes translation and rotation on a 3D space. I have no problem with the main code but after hours of testing i found out that the function which causes inaccuracies is the rotation on arbitrary axis. My object contains array of points, and three vectors which is its local axes. I use rotation function with these axes. The function works well when my position is at the origin, but once the point is translated to other than the origin it shows slightly wrong

How to change the viewport resolution in OpenTK

时间秒杀一切 提交于 2019-12-11 20:13:42
问题 I am using the OpenTk GameWindow. I have been adding graphics settings to my project. But I cannot figure out how to correctly change the resolution or go in or out of fullscreen mode in runtime. Can someone please explain the correct procedure to changing the resolution and/or fullscreen state in while the game is running. Using WindowState = WindowState.Fullscreen; and WindowState = WindowState.Fullscreen; work, but they modify the viewing area and setting GL.Viewport doesn't fix it. I am

Show half portion of image side by side on two separate glcontrols - openTK

霸气de小男生 提交于 2019-12-11 16:52:54
问题 I have a single texture and two glControls. I need to show the first half portion of texture on glControl2 and second half portion of texture on glControl1. And also I have put two numericupdown controls on left end of texture (range from 0 to 0.5) and another two numericupdown controls on right end of texture (range from 0.5 to 1.0). When I select 0. 4 and 0. 5 on left end of texture, I have to show the area between 0. 4 and 0. 5 on glControl2. And If I select 0. 8 and 1 on right end of

Increase the intensity of texture in shader code - OpenGL

亡梦爱人 提交于 2019-12-11 13:16:36
问题 How can I increase the intensity of an image using opengl shadercode? The purpose is that the resulted image should look more brighter than actual image. Found a related link here. But it is for android. private void CreateShaders() { /***********Vert Shader********************/ vertShader = GL.CreateShader(ShaderType.VertexShader); GL.ShaderSource(vertShader, @" attribute vec3 a_position; varying vec2 vTexCoord; void main() { vTexCoord = (a_position.xy + 1) / 2; gl_Position = vec4(a_position

OpenTK Camera in C#

倖福魔咒の 提交于 2019-12-11 11:06:03
问题 I'm trying to acquaint myself with writing programs with OpenTK in C#. I cannot figure out how to set and move camera. Currently, I have the following libraries imported: using System; using System.Collections.Generic; using System.Linq; using System.Text; using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; using OpenTK.Platform.Windows; using System.Runtime.InteropServices; using Imaging = System.Drawing.Imaging; using TK = OpenTK.Graphics.OpenGL; using System.IO; using System

Vertex Attribute Buffers getting bound to wrong attribute

时光怂恿深爱的人放手 提交于 2019-12-11 06:56:25
问题 When I bind my buffers to attributes for my shaders, they seem to be getting flipped. So, I've got a vertex shader: precision highp float; uniform mat4 projection_matrix; uniform mat4 modelview_matrix; in vec3 in_position; in vec3 in_color; out vec3 ex_Color; void main(void) { gl_Position = projection_matrix * modelview_matrix * vec4(in_position, 1); ex_Color = in_color; } and a fragment shader precision highp float; in vec3 ex_Color; out vec4 out_frag_color; void main(void) { out_frag_color

Projection is not working when cutting particular area from top and bottom of openGL control

左心房为你撑大大i 提交于 2019-12-11 06:48:02
问题 With the help of this link i can apply projection on my texture. Now I want to cut/remove equal area from top and bottom of my glcontrol and then need to apply same projection on remain area. I have tried like below. But as shown in the image top and bottom curve is missing on projection. How can I bring it back in remain area? precision highp float; uniform sampler2D sTexture; varying vec2 vTexCoord; void main() { float img_h_px = 432.0; // height of the image in pixel float area_h_px = 39.0

Show half portion of image side by side - OpenGL

假装没事ソ 提交于 2019-12-11 03:04:44
问题 I have created two textures for two images. Now I want to show this textures in opengl in an order that left part of image2, full image1, right part of image2. I have done like below. Image1 shows at the center of opengl screen. But left and right part of screen is not correct (which should show left part of image2 and right part of image2 respectively) Vertex shader: attribute vec3 a_position; varying vec2 vTexCoord; void main() { vTexCoord = (a_position.xy + 1) / 2; gl_Position = vec4(a