我想在屏幕上繪製圖像。我正在使用PIC庫進行圖像處理。OpenGL繪製圖像。 PIC庫
現在,我有像素強度的數組,每個值看起來像這樣
currentImage->pix[currentRow * x * bytesPerPixel] = number from 0 to 256.
我想用這樣的畫出來的圖像:
// initialize the most basic image
for (int y = currentImage->ny; y >= 0; y--) {
// draw out each row of pixels
// line 18 -- this following line throws the error on compile
glReadPixels(0, 479-y, 640, 1, GL_RGB, GL_UNSIGNED_BYTE, &image->pix[y*image->nx*image->bpp]);
}
但這不起作用。當我嘗試編譯時,我不斷收到此錯誤:
g++ -O3 -I/usr/local/src/pic -Iinclude -o current src/main.cpp src/modules/*.cpp -L/usr/local/src/pic -framework OpenGL -framework GLUT -lpicio -ljpeg
src/modules/application.cpp: In function ‘void application::idle()’:
src/modules/application.cpp:18: error: invalid conversion from ‘int’ to ‘const GLvoid*’
make: *** [all] Error 1
有沒有人有過類似的問題?我只是試圖在屏幕上畫出最基本的圖像,現在開始。
這是我的main.cpp函數,用於初始化gl顯示函數。
// set up the main display function
glutDisplayFunc(application::display);
// set the various callbacks for the interaction with opengl
glutIdleFunc(application::display);
Application.cpp完整的文件:
namespace application {
void init() {
idle();
}
// implement idle function -- responsible for working with the image on a consistent basis to continually ensure its integrity
void idle() {
// initialize the most basic image
for (int y = currentImage->ny; y >= 0; y--) {
// draw out each row of pixels
glDrawPixels(currentImage->nx, 1, GL_RGBA, GL_UNSIGNED_BYTE, currentImage->pix[y * currentImage->nx * currentImage->bpp]);
}
}
// display is for drawing out the elements using our scaled frame etc
void display() {
// rotate, scaling and translation should take place before this code in the future
// draw a quick cube around the origin of the screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(000.0, 0.0, 0.0, 1.0);
glutSwapBuffers();
}
}
'application.cpp'在第18行左右有什麼? – congusbongus 2013-02-18 23:49:29
這是一個孤立的功能。我初始化我的程序並在此函數之前繪製背景等。 – JonMorehouse 2013-02-18 23:51:43
它正在停止您的程序編譯。你可以向我們展示application.cpp,或者至少第18行的一部分。 – 2013-02-18 23:54:28