opentk

Problems using GLTexImage3D correctly

こ雲淡風輕ζ 提交于 2019-12-10 23:39:42
问题 This is how I give the Bitmaps to OpenGL. (C#) public static int Generate3DTexture( string[] names ) // file paths { //basically merging the images into one vertical column of images MagickImageCollection allimages = new MagickImageCollection(); foreach (string eachname in names) allimages.Add(new MagickImage(eachname)); MagickImage template = new MagickImage(MagickColor.FromRgba(0, 0, 0, 0), MasterSize.Width, MasterSize.Height * names.Length); Point drawpnt = new Point(0, 0); foreach

Previous calls to GL.Color3 are making my texture use the wrong colors

我的梦境 提交于 2019-12-10 22:10:01
问题 Making a 2D OpenGL game. When rendering a frame I need to first draw some computed quads geometry and then draw some textured sprites. When the body of my render method only draws the sprites, everything works fine. However, when I try to draw my geometric quads prior to the sprites the texture of the sprite changes to be the color of the last GL.Color3 used previously. How do I tell OpenGL (well, OpenTK) "Ok, we are done drawing geometry and its time to move on to sprites?" Here is what the

OpenTK.Core - GL.NamedBufferStorage raises System.AccessViolationException

爷,独闯天下 提交于 2019-12-08 21:42:37
Intro I am following this tutorial to learn how to use OpenGL in C#. Everything ran fine until this part: OpenGL 4 with OpenTK in C# Part 5: Buffers and Triangle . I am not using the exact same OpenTK as the one used in the tutorial. I am using this version that is compatible with .NET Core here: https://www.nuget.org/packages/OpenTK.NETCore/ Issue When I run the program, my console shows the following stacktrace: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at OpenTK.Graphics.OpenGL

OpenTK.Core - GL.NamedBufferStorage raises System.AccessViolationException

独自空忆成欢 提交于 2019-12-08 06:22:46
问题 Intro I am following this tutorial to learn how to use OpenGL in C#. Everything ran fine until this part: OpenGL 4 with OpenTK in C# Part 5: Buffers and Triangle. I am not using the exact same OpenTK as the one used in the tutorial. I am using this version that is compatible with .NET Core here: https://www.nuget.org/packages/OpenTK.NETCore/ Issue When I run the program, my console shows the following stacktrace: Unhandled Exception: System.AccessViolationException: Attempted to read or write

Projecting a 3D point to 2D screen coordinate OpenTK

南笙酒味 提交于 2019-12-08 01:46:28
问题 Using Monotouch and OpenTK I am trying to get the screen coordinate of one 3D point. I have my world view projection matrix set up, and OpenGL makes sense of it and projects my 3D model perfectly, but how to use the same matrix to project just one point from 2D to 3D? I thought I could simply use: Vector3.Transform(ref input3Dpos, ref matWorldViewProjection, out projected2Dpos); Then have the projected screen coordinate in projected2DPos. But the resulting Vector4 does not seem to represent

VBOs Using Interleaved Vertices in C#

ε祈祈猫儿з 提交于 2019-12-07 23:31:31
问题 I am trying to use VBOs to draw my model in in C# using OpenTK. In my online research I read in many places that it is good practice to make the size of the interleaved data structure an exact multiple of 32 bytes, so I coded up the following: [Serializable] [StructLayout(LayoutKind.Sequential)] public struct Byte4 { public byte R, G, B, A; public Byte4(byte[] input) { R = input[0]; G = input[1]; B = input[2]; A = input[3]; } public uint ToUInt32() { byte[] temp = new byte[] { this.R, this.G,

How to make objects transparent in OpenTK

ⅰ亾dé卋堺 提交于 2019-12-06 11:21:30
问题 I'm using OpenTK and C#, I have defined a plane in 3D space as follows: GL.Begin(BeginMode.Quads); GL.Color3(Color.Magenta); GL.Vertex3(-100.0f, -25.0f, -150.0f); GL.Vertex3(-100.0f, -25.0f, 150.0f); GL.Vertex3( 200.0f, -25.0f, 100.0f); GL.Vertex3( 200.0f, -25.0f, -100.0f); GL.End(); Can anyone please help me to make the plane transparent? 回答1: So you want something like this? There are a lot of things to take care of to get there. It all starts with a Color object that contains an alpha

Setup of matrix for instance shader

↘锁芯ラ 提交于 2019-12-05 10:49:58
I want to draw instanced cubes. I can call GL.DrawArraysInstanced(PrimitiveType.Triangles, 0, 36, 2); successfully. My problem is that all the cubes are drawn at the same position and same rotation. How can i change that individually for every cube? To create different positions and so on, i need a matrix for each cube, right? I created this: Matrix4[] Matrices = new Matrix4[]{ Matrix4.Identity, //do nothing Matrix4.Identity * Matrix4.CreateTranslation(1,0,0) //move a little bit }; GL.BindBuffer(BufferTarget.ArrayBuffer, matrixBuffer); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(sizeof

How to make objects transparent in OpenTK

时间秒杀一切 提交于 2019-12-04 18:09:48
I'm using OpenTK and C#, I have defined a plane in 3D space as follows: GL.Begin(BeginMode.Quads); GL.Color3(Color.Magenta); GL.Vertex3(-100.0f, -25.0f, -150.0f); GL.Vertex3(-100.0f, -25.0f, 150.0f); GL.Vertex3( 200.0f, -25.0f, 100.0f); GL.Vertex3( 200.0f, -25.0f, -100.0f); GL.End(); Can anyone please help me to make the plane transparent? So you want something like this? There are a lot of things to take care of to get there. It all starts with a Color object that contains an alpha value<255. For example Color.FromArgb(85, Color.Turquoise) for the sphere below. The main render class, sets up

Index Buffer Object and UV Coordinates don't play nice

核能气质少年 提交于 2019-12-04 05:43:47
问题 This generates the 25 main vertices. For x As Single = -1 To 1 Step 0.5F For y As Single = 1 To -1 Step -0.5F Dim pt1 As New Vector3(x, y, 0) tFloats.Add(pt1) Next Next This is the indices, which makes up 16 tiles made of 32 triangles, I actually generate them but this is the first row: Dim inasd() As Integer = { 0, 2, 10, 2, 10, 12, 10, 12, 20, 12, 20, 22, 20, 22, 30, 22, 30, 32 } Now I'm trying to apply a texture to every single triangle, 1 texture per tile. 16 different textures. Now my