你如何编写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) 我正在尝试使用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出于某种原因,这个点总是显示为正方形,而不是圆形...有谁知道为什么?
我正在编译一个在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提前提供任何帮助.
我正在尝试使用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) 我正在用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)