本文整理汇总了C++中drawTriangle函数的典型用法代码示例。如果您正苦于以下问题:C++ drawTriangle函数的具体用法?C++ drawTriangle怎么用?C++ drawTriangle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drawTriangle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: init
void
init(char *filename)
{
stl_error_t err;
GLfloat *vertices = NULL;
GLuint triangle_cnt = 0;
int i = 0, base = 0;
stl = stl_alloc();
if (stl == NULL) {
fprintf(stderr, "Unable to allocate memoryfor the stl object");
exit(1);
}
err = stl_load(stl, filename);
if (err != STL_ERR_NONE) {
fprintf(stderr, "Problem loading the stl file, check lineno %d\n",
stl_error_lineno(stl));
exit(1);
}
err = stl_vertices(stl, &vertices);
if (err) {
fprintf(stderr, "Problem getting the vertex array");
exit(1);
}
triangle_cnt = stl_facet_cnt(stl);
model = glGenLists(1);
glNewList(model, GL_COMPILE);
glBegin(GL_TRIANGLES);
for (i = 0; i < triangle_cnt; i++) {
base = i*18;
drawTriangle(vertices[base], vertices[base + 1], vertices[base + 2],
vertices[base + 6], vertices[base + 7], vertices[base + 8],
vertices[base + 12], vertices[base + 13], vertices[base + 14]);
}
glEnd();
glEndList();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glClearColor(135.0 / 255, 206.0 / 255.0, 250.0 / 255.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(120.0 / 255.0 , 120.0 / 255.0, 120.0 / 255.0);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
glFlush();
}
开发者ID:DaikiMaekawa,项目名称:stlviewer,代码行数:55,代码来源:stl_viewer.c
示例2: main
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
//使用OpenGL 3.2
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
if(false==LoadImg("/Users/wistoneqqx/Documents/opengl/github/texture-maps-gl7/texture-maps/test01.jpg",0))
printf("加载图片1失败!\n");
if(false==LoadImg("/Users/wistoneqqx/Documents/opengl/github/texture-maps-gl7/texture-maps/test02.jpg",1))
printf("加载图片2失败!\n");
initShader();
initTriangle();
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClearColor(0.0f,0.0f,0.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
drawTriangle();
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
开发者ID:Nuos,项目名称:textureMapsGL7,代码行数:55,代码来源:main.cpp
示例3: sort
void Light::shine(sf::RenderWindow* win)
{
for(int i=0;i<lights.size();i++)
{
std::vector<PointID> pnt;
for(int j=0;j<tab.size();j++)
{
pnt.push_back(PointID(lights[i].first,tab[j].first,j));
pnt.push_back(PointID(lights[i].first,tab[j].second,j));
}
sort(pnt.begin(), pnt.begin() + pnt.size(), cmp);
for(int i=0;i<pnt.size()-1;i++)
if(pnt[i].p==pnt[i+1].p)
{
pnt.erase(pnt.begin()+i);
i--;
}
std::vector<Point> res;
for(int j=0;j<pnt.size();j++)
{
res.push_back(pnt[j].p-lights[i].first);
for(int k=0;k<tab.size();k++)
{
if(cross(lights[i].first,pnt[j].p,tab[k].first,tab[k].second))
{
res.pop_back();
break;
}
}
}
for(int j=0;j<res.size()-1;j++)
{
drawTriangle(win,lights[i].first,res[j],res[j+1],lights[i].second);
}
drawTriangle(win,lights[i].first,res[0],res[res.size()-1],lights[i].second);
sf::CircleShape circle(5);
circle.setFillColor(lights[i].second);
circle.move(lights[i].first-Point(5,5));
win->draw(circle);
}
}
开发者ID:BigDarkClown,项目名称:Light,代码行数:42,代码来源:Light.cpp
示例4: capturePoints
void capturePoints(int button,int state,int x,int y)
{
if(points_count==0 || points_count==1)
points_count++;
else if((points_count%2==1) && (points_count < (2*max_points)+1))
{
printf("count=%d\n",points_count);
points_count++;
}
else if((points_count%2==1) && (points_count==(2*max_points)+1))
{
printf("count=%d\n",points_count);
points_count=2;
}
else if(points_count==2*max_points)
{
printf("need to add the points\n");
printf("count=%d\n",points_count);
end_points[(points_count/2)-1][0]=x;
end_points[(points_count/2)-1][1]=500-y;
points_count++;
printf("%d %d\n",end_points[0][0],end_points[0][1]);
printf("%d %d\n",end_points[1][0],end_points[1][1]);
switch(global_primitive)
{
case 2 :
drawLine();
break;
case 3 :
{
int rad=distance(end_points[0][0],end_points[0][1],end_points[1][0],end_points[1][1]);
printf("%d\n",rad);
drawCircle(rad,end_points[0][0],end_points[0][1]);
break;
}
case 4 :
drawTriangle();
break;
}
}
else
{
printf("need to add the points\n");
printf("count=%d\n",points_count);
end_points[(points_count/2)-1][0]=x;
end_points[(points_count/2)-1][1]=500-y;
points_count++;
}
}
开发者ID:karthiksenthil,项目名称:thePaintApp,代码行数:54,代码来源:menu.c
示例5: testtriangles
void testtriangles()
{
fillScreen(BLACK);
uint16_t i;
for (i=0; i<width()/2; i+=5)
{
drawTriangle(width()/2, height()/2-i,
width()/2-i, height()/2+i,
width()/2+i, height()/2+i, Color565(0, 0, i));
}
}
开发者ID:blaezec,项目名称:stm32f4,代码行数:11,代码来源:main.c
示例6: display
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glTranslatef(0, 0 , 0);
drawTriangle(0.0,2.0,4);
//glFlush();
glutSwapBuffers();
}
开发者ID:asg09061,项目名称:Koch-Snowflake,代码行数:11,代码来源:kochSnowflake.cpp
示例7: triangleBinding
int triangleBinding(lua_State *L) {
int x1,y1,x2,y2,x3,y3;
x1 = lua_tonumber(L,-6);
y1 = lua_tonumber(L,-5);
x2 = lua_tonumber(L,-4);
y2 = lua_tonumber(L,-3);
x3 = lua_tonumber(L,-2);
y3 = lua_tonumber(L,-1);
drawTriangle(l81.fb,x1,y1,x2,y2,x3,y3,l81.r,l81.g,l81.b,l81.alpha);
return 0;
}
开发者ID:r043v,项目名称:load81,代码行数:12,代码来源:load81.c
示例8: main
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
return -1;
//使用OpenGL 3.2
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/*设置键盘事件监听*/
glfwSetKeyCallback(window,keyboardCallbackHandler);
initData();
initShader();
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClearColor(0.0f,0.0f,0.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
drawTriangle();
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
开发者ID:sbxfc,项目名称:opengl,代码行数:53,代码来源:main.cpp
示例9: drawArc
void drawArc(int depart, int arrivee)
{ //Dessine un arc colorié entre le sommet de départ et le sommet d'arrivée, chaque sommet étant repréré par un indice (voir sommets.txt)
if (G[depart][arrivee].poids != 1000) //si l'arc existe
{
switch(G[depart][arrivee].couleur)
{
case 0 : drawBigLine(points[depart],points[arrivee],vert);
drawTriangle(points[arrivee],5,vert);
break;
case 1 : drawBigLine(points[depart],points[arrivee],bleu);
drawTriangle(points[arrivee],5,bleu);
break;
case 2 : drawBigLine(points[depart],points[arrivee],rouge);
drawTriangle(points[arrivee],5,rouge);
break;
case 3 : drawBigLine(points[depart],points[arrivee],gris);
drawTriangle(points[arrivee],5,gris);
break;
case 4 : drawBigLine(points[depart],points[arrivee],noir);
drawTriangle(points[arrivee],5,noir);
break;
default : drawBigLine(points[depart],points[arrivee],blanc);
drawTriangle(points[arrivee],5,blanc);
break;
}
}
}
开发者ID:Mzem,项目名称:Ski,代码行数:27,代码来源:affichage.c
示例10: display
void display(void)
{
//カラーバッファのクリア
glClear(GL_COLOR_BUFFER_BIT);
//描画
// シェーダプログラムの適用
glUseProgram(shaderProg);
drawTriangle();
// シェーダプログラムの適用を解除
glUseProgram(0);
//終了
glFlush();
}
开发者ID:kzfm1024,项目名称:misc,代码行数:13,代码来源:slTriangle.cpp
示例11: glClear
void Widget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
// gluLookAt(radius*qCos(AngToRad*xRot), yRot, radius*qSin(AngToRad*xRot), 0, 0, 0, 0, 1, 0);
if(isObjOn){
drawObj();
}
else {
drawTriangle();
}
glFlush();
}
开发者ID:shibajiu,项目名称:qt_code,代码行数:13,代码来源:widget.cpp
示例12: drawPolygon
Mat BodyModel::generateMat()
{
_mask = Mat::zeros(_img_heigh, _img_width, CV_8UC3);
// draw waist
drawPolygon(_right_waist, _left_waist, _right_hip, _left_hip);
// draw chest
drawPolygon(_right_shoulder, _left_shoulder, _right_waist, _left_waist);
// draw neck
drawPolygon(Point(_center_x + _neck_width, _center_y - _neck_heigh),
Point(_center_x - _neck_width, _center_y - _neck_heigh),
Point(_center_x + _neck_width, _center_y),
Point(_center_x - _neck_width, _center_y));
// draw left arm
drawPolygon(_left_shoulder, _left_arm_lower, _left_elbow_upper, _left_elbow_lower);
// draw left hand
drawBodyShape(_left_elbow_upper, _left_elbow_lower, _left_hand_upper, _left_hand_lower, -5);
// draw right arm
drawPolygon(_right_shoulder, _right_arm_lower, _right_elbow_upper, _right_elbow_lower);
// draw right hand
drawBodyShape(_right_elbow_upper, _right_elbow_lower, _right_hand_upper, _right_hand_lower, 5);
// draw head
drawCircle(_head_center, _head_radius);
// draw left leg
drawPolygon(_left_hip, _mid_hip, _left_knee, _left_knee_inner);
// draw right leg
drawPolygon(_right_hip, _mid_hip, _right_knee, _right_knee_inner);
// draw left limb
drawBodyShape(_left_knee, _left_knee_inner, _left_footrope, _left_heel, -10);
// draw right limb
drawBodyShape(_right_knee, _right_knee_inner, _right_footrope, _right_heel, 10);
// draw left foot
drawTriangle(_left_heel, _left_toe, _left_heel_upper);
// draw right foot
drawTriangle(_right_heel, _right_toe, _right_heel_upper);
// draw shoulder
drawTriangle(_right_shoulder, _left_shoulder, Point(_center_x, _center_y - _shoulder_heigh));
return _mask;
}
开发者ID:chenww05,项目名称:M2M,代码行数:39,代码来源:BodyModel.cpp
示例13: drawRect
void gePropertyTransform::drawNode()
{
drawRect(&m_cVBClientArea);
geFontManager::g_pFontArial10_84Ptr->drawString(m_szName, 35, geFontManager::g_pFontArial10_84Ptr->getLineHeight(), m_cSize.x);
if(m_vControls.size() && m_bHaveAtleastOneTreeNodeChild)
{
if(m_bNodeOpen)
drawTriangle(&m_cVBLayoutToggleButtonLine[3*2], 0.3f, 0.3f, 0.3f, 1.0f, 3);
else
drawTriangle(&m_cVBLayoutToggleButtonLine[0], 0.3f, 0.3f, 0.3f, 1.0f, 3);
}
for(std::vector<geGUIBase*>::iterator it = m_vControls.begin(); it != m_vControls.end(); ++it)
{
geGUIBase* tvnode = *it;
tvnode->draw();
}
if(m_pSprite)
m_pSprite->draw();
}
开发者ID:arunmudhaliar,项目名称:GEAR_Alpha,代码行数:23,代码来源:gePropertyTransform.cpp
示例14: main
int main(int argc, char** argv) {
// start GL context and O/S window using the GLFW helper library
if (!glfwInit ()) {
fprintf (stderr, "ERROR: could not start GLFW3\n");
return 1;
}
GLFWwindow* window = glfwCreateWindow (640, 480, "Hello Triangle", NULL, NULL);
if (!window) {
fprintf (stderr, "ERROR: could not open window with GLFW3\n");
glfwTerminate();
return 1;
}
glfwMakeContextCurrent (window);
glewInit ();
printMachineSpecification();
// tell GL to only draw onto a pixel if the shape is closer to the viewer
glEnable (GL_DEPTH_TEST); // enable depth-testing
glDepthFunc (GL_LESS); // depth-testing interprets a smaller value as "closer"
glShadeModel(GL_SMOOTH);
float points[] = {
0.0f, 1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
-1.0f, -1.0f, 0.0f
};
GLuint vao;
createTriangle(&vao, points);
GLuint shader_programme;
createShader(&shader_programme, fragment_shader, vertex_shader);
while (!glfwWindowShouldClose (window)) {
// wipe the drawing surface clear
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
drawTriangle(vao, shader_programme);
// update other events like input handling
glfwPollEvents ();
// put the stuff we've been drawing onto the display
glfwSwapBuffers (window);
}
glfwTerminate();
return 0;
}
开发者ID:luqmanarifin,项目名称:open-gl-grafika,代码行数:49,代码来源:triangle_grad.cpp
示例15: draw_cube
void draw_cube()
{
sglClear(0.0, 0.0, 1.0);
sglModLoadIdentity();
sglViewLoadIdentity();
sglLookAt(20, 10, 20, 0, 0, 0,0,0,1);
sglModTranslate(0.0f, 0.0f, -10.0f);
sglModRotate(angle, 1.0 ,1.0,1.0);
drawTriangle();
sglShow();
angle += 0.075;
}
开发者ID:anku94,项目名称:simple-graphics-pipeline,代码行数:15,代码来源:main.cpp
示例16: testfilltriangles
void testfilltriangles()
{
fillScreen(BLACK);
uint16_t i;
for (i=width()/2; i>10; i-=5)
{
fillTriangle(width()/2, height()/2-i,
width()/2-i, height()/2+i,
width()/2+i, height()/2+i,
Color565(0, i, i));
drawTriangle(width()/2, height()/2-i,
width()/2-i, height()/2+i,
width()/2+i, height()/2+i, Color565(i, i, 0));
}
}
开发者ID:blaezec,项目名称:stm32f4,代码行数:15,代码来源:main.c
示例17: flashShape
void flashShape(int shape, WinDrawLine_fn WinDrawLine)
{
switch(shape){
case 0:
drawRectangle(14+5,24+5,50-10,50-10,WinDrawLine);
break;
case 1:
drawTriangle(90+5+5,34+5,70-10-10,WinDrawLine);
break;
case 2:
drawDiamond(14+5,90+5,60-10, WinDrawLine);
break;
case 3:
drawCircle(90+27,90+27,27+27-10,WinDrawLine);
break;
}
}
开发者ID:Gaoithe,项目名称:bgttoolbox,代码行数:17,代码来源:keepEupEGame.c
示例18: drawKeepEupEScreen
// will be called with next end as the last begin
// match == on begin only, otherwise get double markings
void drawKeepEupEScreen(void)
{
DEBUGBOX("drawKeepEupEScreen","");
clearScreen();
drawRectangleSafe(14,24,50,50);
DEBUGBOX("drawKeepEupEScreen","b4rect");
// messes up &WinDrawLineF ptr setup somewhere here
drawRectangle(14,24,50,50,&WinDrawLineF);
DEBUGBOX("drawKeepEupEScreen","");
drawTriangle(90,34,70,&WinDrawLineF);
DEBUGBOX("drawKeepEupEScreen","");
drawDiamond(14,90,60,&WinDrawLineF);
DEBUGBOX("drawKeepEupEScreen","");
drawCircle(90+27,90+27,27+27,&WinDrawLineF);
DEBUGBOX("drawKeepEupEScreen","");
}
开发者ID:Gaoithe,项目名称:bgttoolbox,代码行数:19,代码来源:keepEupEGame.c
示例19: testtriangles
//*****************************************************************************
void testtriangles() {
int color = 0xF800;
int t;
int w = width() / 2;
int x = height() - 1;
int y = 0;
int z = width() - 1;
fillScreen(BLACK);
for (t = 0; t <= 15; t += 1) {
drawTriangle(w, y, y, x, z, x, color);
x -= 4;
y += 4;
z -= 4;
color += 100;
delay(10);
}
}
开发者ID:billykwok,项目名称:TI-CC3200-IoT,代码行数:19,代码来源:test.c
示例20: display
void display(void){
//calcWheelVert();
calcTriangle();
glGenBuffers(NumBuffers, Buffers);
glBindBuffer(GL_ARRAY_BUFFER, Buffers[ArrayBuffer]);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glGenVertexArrays(NumVAOs, VAOs);
glBindVertexArray(VAOs[Triangles]);
glVertexAttribPointer(vPosition, 2, GL_FLOAT, GL_FALSE, 0, (void*)0);
glEnableVertexAttribArray(vPosition);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glClearColor(0.9, 0.9, 0.9, 1);
glClear(GL_COLOR_BUFFER_BIT);
drawTriangle();
glBindVertexArray(VAOs[Triangles]);
glutSwapBuffers();
}
开发者ID:Nos-,项目名称:htw,代码行数:19,代码来源:prakt3.cpp
注:本文中的drawTriangle函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论