如何使用OpenGL ES 1.0动态绘制两个向量之间的线 [英] How to dynamically draw a line between two vectors using OpenGL ES 1.0
问题描述
我只是学习一些OpenGL ES的编程(1.0,因为这本书是什么我有使用),我不知道怎么画谁是重新presented由位置向量两种游戏对象之间的线
I'm just learning some OpenGL ES programming (1.0 since that is what the book I have uses), and I don't know how to draw a line between two game objects who are represented by position vectors.
说我有一个塔的塔和一个怪物蠕变(塔防游戏,如果你还没有猜到了),都与自己的立场重新由(对象).position.x和(目标).position.y psented $ P $ ,其中位置是一个矢量。我怎么会去使用GL10再接再presenting塔攻击蠕变给出各自的位置向量?
Say I have a Tower tower and a Creature creep (tower defense game if you haven't guessed), both with their positions represented by (object).position.x and (object).position.y, where position is a vector. How would I go about using GL10 to draw a line representing the tower attacking creep given their respective position vectors?
这是我第一次做这样的事情,所以请多多包涵。我也有一类Vector2处理pretty多所有的基本向量加法/减法/等。例如code将大大AP preciated !!
This is my first time doing something like this so please bear with me. I also have a class Vector2 that handles pretty much all basic vector addition/subtraction/etc. Example code would be greatly appreciated!!
推荐答案
加载了一个4个顶点6指数为1个像素的差别矩形,线条颜色设定为任何你想要的,使用的位置vector2 x和y矩形2triangles你的决策,像
load up a 4 vertices 6 indices rectangle with a difference of 1 pixel and set color of line to whatever you want, use the position vector2 x and y for the rectangle 2triangles your making, like
float[] {Vector2.x - 1, Vector2.y, 0,1,0,1, Vector2.x,Vector2.y,0,1,0,1,Vector2(1).x,Vector2(1).y, 0,1,0,1, Vector2(1).x - 1, Vector(2).y, 0,1,0,1);
IDK的,如果这会帮助你Vector2你在读开始时的Android游戏?这就是即时阅读什么
idk if this is going to help you Vector2 are you reading begining android games?thats what im reading
这篇关于如何使用OpenGL ES 1.0动态绘制两个向量之间的线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!