OpenGL绘制图像.PIC库
OpenGL Draw Image. PIC Library
我正试图在屏幕上画一幅图像。我正在使用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();
}
}
我的最佳猜测是你的问题在这里:
glDrawPixels(currentImage->nx, 1, GL_RGBA, GL_UNSIGNED_BYTE, currentImage->pix[y * currentImage->nx * currentImage->bpp]);
glDrawPixels的最后一个参数需要是常量GLVoid*
http://www.opengl.org/sdk/docs/man2/xhtml/glDrawPixels.xml
但您正在传递一个内部
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 平均图像时图像损坏
- 在C++中使用GDAL可以将图像的像素坐标转换为lat,long吗
- 如何将图像传输到c++(dll)中的缓冲区,然后在c#的缓冲区中读/写
- Vulkan验证层不断在VkQueuePresentKHR()上抛出图像布局错误
- 使用FFMPEG将RGB图像序列保存到.mp4时出现问题
- 将RGB图像保存为PPM格式
- 将图像添加到资源文件夹UWP C++
- 彩色图像的卤化物处理平均值
- C++射线示踪剂ppm表示没有足够的数据来显示图像
- 重新定位图像时如何前进到下一个内存块
- 如何使用按钮更新GTK3图像以使用C++从相机捕获图片
- 为什么 BMP 图像上的 imwrite 会卡住/不返回?
- Gstreamer:每 5 秒使用多文件墨水保存图像/jpeg
- 如何使用CImg打开图像?
- 如何使用 OpenCV 解码在两个 UWP 应用之间发送的图像字节?
- OpenGL绘制图像.PIC库