→OpenGl: nowy kod
opengl |
→OpenGl: nowy kod |
||
Linia 40:
#include <iostream>
using namespace std;
void display(
{
glClear(GL_COLOR_BUFFER_BIT
glMatrixMode(GL_PROJECTION);
Linia 68 ⟶ 65:
glPopMatrix();
unsigned char pixel[3];▼
glReadPixels(mouse_x, mouse_y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);▼
std::cout << "R: " << (int)pixel[0] << std::endl;▼
std::cout << "G: " << (int)pixel[1] << std::endl;▼
std::cout << "B: " << (int)pixel[2] << std::endl;▼
std::cout << std::endl;▼
glutSwapBuffers();
}
Linia 81 ⟶ 70:
void motion(int x, int y)
{
y = glutGet( GLUT_WINDOW_HEIGHT ) - y;
}
int main(int argc, char **argv)
{
glutInitWindowSize(640,480);▼
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA
▲ glutInitWindowSize(640,480);
glutCreateWindow("glReadPixels()");
glutDisplayFunc(display);
glutPassiveMotionFunc(motion);
glutMainLoop();
|