小编das*_*sen的帖子

你如何编写Prolog中的程序来使用递归打印1到10的数字?

你如何编写Prolog中的程序来使用递归打印1到10的数字?

我尝试过以下但它不起作用,你能告诉我为什么吗?

print_numbers(10) :- write(10).

print_numbers(X) :- write(X),nl,X is X + 1, print_numbers(X).
Run Code Online (Sandbox Code Playgroud)

recursion prolog

6
推荐指数
2
解决办法
9981
查看次数

为什么不"glEnable(GL_POINT_SMOOTH);" 努力使以下几点成为一个圆圈?

我正在尝试使用GL_POINT为每个棋子编码(在c中,使用opengl)一块棋盘游戏.我有以下代码:

        glEnable(GL_POINT_SMOOTH);
        glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
        glPointSize(20.0f);
        glBegin(GL_POINTS);

        glVertex2d(200, 200);

        glEnd();
Run Code Online (Sandbox Code Playgroud)

Bur出于某种原因,这个点总是显示为正方形,而不是圆形...有谁知道为什么?

c opengl

5
推荐指数
1
解决办法
5983
查看次数

当我在c中编译程序时,为什么会得到一个未定义的引用(例如`glColor3f')?

我正在编译一个在ubuntu(linux)中使用opengl的示例程序.代码的简短片段如下:

 #include <stdlib.h> 

 #include <GL/glut.h>


 void createBox( GLfloat centroX, GLfloat centroY,
                       GLfloat corR, GLfloat corG, GLfloat corB )
 {
    /* Cor  */

    glColor3f( corR, corG, corB );
Run Code Online (Sandbox Code Playgroud)

我安装了所有的包在opengl(在ubuntu中)开发,即:

freeglut3 freeglut3-dev libglew1.5 libglew1.5-dev libglu1-mesa
libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev
Run Code Online (Sandbox Code Playgroud)

我像这样编译示例:

gcc -lGL   CG_ex04.c -o main
Run Code Online (Sandbox Code Playgroud)

我得到以下内容

/tmp/ccDWmJDZ.o: In function `createBox':
CG_ex04.c:(.text+0x31): undefined reference to `glColor3f'
Run Code Online (Sandbox Code Playgroud)

和沿同一行的其他错误.

有谁知道我做错了什么?

Thanx提前提供任何帮助.

c gcc linker-errors

4
推荐指数
1
解决办法
3939
查看次数

如何使用此代码作为起点在opengl中绘制一个较小的圆?

我正在尝试使用opengl在c中绘制一个圆圈,它比显示的那个小.问题是我似乎无法找到如何减小它的大小...任何人都可以帮助我吗?

#define GLUT_DISABLE_ATEXIT_HACK
#include <GL/gl.h>
#include <GL/glut.h>
#include <stdio.h>

#include <math.h>
#define PI 3.1415926535898
GLint circle_points =100;
 // This is the draw function.
void draw()
{

glClear(GL_COLOR_BUFFER_BIT);
double angle = 2*  PI/circle_points ;
glPolygonMode( GL_FRONT, GL_FILL );
glColor3f(0.2, 0.5, 0.5 );
glBegin(GL_POLYGON);
    double angle1=0.0;
    glVertex2d( cos(0.0) , sin(0.0));
    int i;
    for ( i=0 ; i< circle_points ;i++)
    {
        printf( "angle = %f \n" , angle1);
        glVertex2d(cos(angle1),sin(angle1));
        angle1 += angle ;
    }
glEnd();
glFlush();
}

void init()
{
glClearColor(0.0,0.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); …
Run Code Online (Sandbox Code Playgroud)

c opengl

4
推荐指数
1
解决办法
7570
查看次数

为什么这个小函数(在opengl中画一个圆圈)不会在c中编译?

我正在用linux中的opengl进行一些实验.我有以下功能,可以根据这些参数绘制一个圆圈.我已经包括在内了

 #include <stdlib.h>
 #include <math.h>
 #include <GL/gl.h>
 #include <GL/glut.h>
Run Code Online (Sandbox Code Playgroud)

但是当我编译时:

gcc fiver.c -o fiver -lglut
Run Code Online (Sandbox Code Playgroud)

我明白了:

   /usr/bin/ld: /tmp/ccGdx4hW.o: undefined reference to symbol 'sin@@GLIBC_2.2.5'
   /usr/bin/ld: note: 'sin@@GLIBC_2.2.5' is defined in DSO /lib64/libm.so.6 so try  
   adding it to the linker command line
  /lib64/libm.so.6: could not read symbols: Invalid operation
   collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

功能如下:

void drawCircle (int xc, int yc, int rad) {
//
// draw a circle centered at (xc,yc) with radius rad
//
  glBegin(GL_LINE_LOOP);
//
  int angle;
  for(angle …
Run Code Online (Sandbox Code Playgroud)

c opengl math

2
推荐指数
1
解决办法
6842
查看次数

标签 统计

c ×4

opengl ×3

gcc ×1

linker-errors ×1

math ×1

prolog ×1

recursion ×1