Torna indietro   Hardware Upgrade Forum > Software > Programmazione

Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'' per spingere gli handheld gaming PC al massimo
Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'' per spingere gli handheld gaming PC al massimo
Lenovo Legion Go 2 è la nuova handheld PC gaming con processore AMD Ryzen Z2 Extreme (8 core Zen 5/5c, GPU RDNA 3.5 16 CU) e schermo OLED 8,8" 1920x1200 144Hz. È dotata anche di controller rimovibili TrueStrike con joystick Hall effect e una batteria da 74Wh. Rispetto al dispositivo che l'ha preceduta, migliora ergonomia e prestazioni a basse risoluzioni, ma pesa 920g e costa 1.299€ nella configurazione con 32GB RAM/1TB SSD e Z2 Extreme
AWS re:Invent 2025: inizia l'era dell'AI-as-a-Service con al centro gli agenti
AWS re:Invent 2025: inizia l'era dell'AI-as-a-Service con al centro gli agenti
A re:Invent 2025, AWS mostra un’evoluzione profonda della propria strategia: l’IA diventa una piattaforma di servizi sempre più pronta all’uso, con agenti e modelli preconfigurati che accelerano lo sviluppo, mentre il cloud resta la base imprescindibile per governare dati, complessità e lock-in in uno scenario sempre più orientato all’hybrid cloud
Cos'è la bolla dell'IA e perché se ne parla
Cos'è la bolla dell'IA e perché se ne parla
Si parla molto ultimamente di "bolla dell'intelligenza artificiale", ma non è sempre chiaro perché: l'IA è una tecnologia molto promettente e che ha già cambiato molte cose dentro e fuori le aziende, ma ci sono enormi aspettative che stanno gonfiando a dismisura i valori delle azioni e distorcendo il mercato. Il che, com'è facile intuire, può portare a una ripetizione della "bolla dotcom", e forse anche di quella dei mutui subprime. Vediamo perché
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 13-12-2013, 13:17   #1
-Ivan-
Senior Member
 
L'Avatar di -Ivan-
 
Iscritto dal: Mar 2003
Città: Rimini
Messaggi: 1846
[OpenGL] Esercizio per disegnare un cubo mostra solo la faccia frontale

Sto facendo un esercizio in cui cerco di disegnare un cubo con OpenGL.
Non riesco a capire perchè mi mostri solo la faccia frontale.
Per disegnarlo uso glDrawElements dopo aver creato un buffer di indici ed il buffer con i vertici del cubo.

Codice:
// include...


enum Attrib_IDs { vPosition = 0 };

GLuint VERTEX_SHADER_ID;

GLuint VBOs[1];		// Vertex Buffer Objects
GLuint IBOs[1];		// Index Buffer Objects

GLuint SCREEN_WIDTH = 512, SCREEN_HEIGHT = 512;

glm::mat4 mvp;		//model view projection matrix



#pragma region INITIALIZE DATA AND OPENGL

void ModelViewProjectionMatrix()
{
	// Matrix to translate the cube deep far in the scene
	glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(0.0, 0.0, -4.0));

	// The lookat function takes: eye (position of the camera), center (where the camera is pointed to), and up (top of the camera).
	glm::mat4 view = glm::lookAt(glm::vec3(0.0, 2.0, 0.0), glm::vec3(0.0, 0.0, -4.0), glm::vec3(0.0, 1.0, 0.0));

	// The perpective function takes: fovy (the lens angle), aspect (the aspect ratio), and zNear, zFar (clipping planes).
	glm::mat4 projection = glm::perspective(45.0f, 1.0f * SCREEN_WIDTH/SCREEN_HEIGHT, 0.1f, 10.0f);


	// We end up with a model view projection matrix giving us the result for our camera
	mvp = projection * view * model;
}

void CreateVerticesData()
{
	Vector3D cube_vertices[] = {
		// front
		Vector3D(-1.0, -1.0,  1.0),
		Vector3D( 1.0, -1.0,  1.0),
		Vector3D( 1.0,  1.0,  1.0),
		Vector3D(-1.0,  1.0,  1.0),
		// back
		Vector3D(-1.0, -1.0, -1.0),
		Vector3D( 1.0, -1.0, -1.0),
		Vector3D( 1.0,  1.0, -1.0),
		Vector3D(-1.0,  1.0, -1.0)
	};

	// Generate the Vertex Buffer Object storing the data for the 8 vertices of the cube.
	// In total there are 24 floats representing the x, y, z components of each vertex.
	glGenBuffers(1, VBOs);
	glBindBuffer(GL_ARRAY_BUFFER, VBOs[0]);
	glBufferData(GL_ARRAY_BUFFER, sizeof(cube_vertices), cube_vertices, GL_STATIC_DRAW);
}

void CreateIndexData()
{
	// Indices of the vertices of the cube.
	// This is used to avoid duplicates. As the faces of the cube share vertices we can duplicate this vertices ending with a
	// total of 36 (6 faces x 2 triangles per face x 3 vertices each triangle = 36) or we can store them just once and refer to them
	// using these indices and drawing the cube with glDrawElements instead than with glDrawArray that just iterates through an array
	// drawing every vertices it finds in it.
	GLushort cube_elements[] = {
		// front
		0, 1, 2,
		2, 3, 0,
		// top
		3, 2, 6,
		6, 7, 3,
		// back
		7, 6, 5,
		5, 4, 7,
		// bottom
		4, 5, 1,
		1, 0, 4,
		// left
		4, 0, 3,
		3, 7, 4,
		// right
		1, 5, 6,
		6, 2, 1,
	};

	// Generate the Index Buffer Object to index the vertices inside the Vertex Buffer Object.
	// The indexes are related to the 8 vertices making the cube.
	glGenBuffers(1, IBOs);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBOs[0]);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(cube_elements), cube_elements, GL_STATIC_DRAW);
}

void Init()
{
	glEnable(GL_DEPTH_TEST);
	ModelViewProjectionMatrix();

	CreateVerticesData();
	CreateIndexData();

	// Load and use the shaders
	VERTEX_SHADER_ID = LoadShader("shader.vert", "shader.frag");
	glUseProgram(VERTEX_SHADER_ID);

	// Set up the value of the uniform value inside the vertex shader
	GLuint mvp_Loc = glGetUniformLocation(VERTEX_SHADER_ID, "mvp");
	glUniformMatrix4fv(mvp_Loc, 1, GL_FALSE, glm::value_ptr(mvp));

	// Defines parameters to pass to the shaders
	glVertexAttribPointer(vPosition, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
	glEnableVertexAttribArray(vPosition);
}

#pragma endregion

void Display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	int size;
	glGetBufferParameteriv(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);

	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBOs[0]);
	glDrawElements(GL_TRIANGLES, size / sizeof(GLushort), GL_UNSIGNED_SHORT, 0);

	// marks the current window as needing to be redisplayed
    glutPostRedisplay();
	glFlush();
}

int _tmain(int argc, _TCHAR* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGBA);
	glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT);
	glutInitContextVersion(3, 3);
	glutInitContextProfile(GLUT_CORE_PROFILE);
	glutCreateWindow("Cube");

	if( glewInit() )
	{
		std::cerr << "Error...exiting";
		exit(EXIT_FAILURE);
	}

	Init();

	glutDisplayFunc(Display);
	glutMainLoop();

	return 0;
}
-Ivan- è offline   Rispondi citando il messaggio o parte di esso
Old 13-12-2013, 16:24   #2
-Ivan-
Senior Member
 
L'Avatar di -Ivan-
 
Iscritto dal: Mar 2003
Città: Rimini
Messaggi: 1846
Ho trovato.
L'errore era in:
Codice:
glVertexAttribPointer(vPosition, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
che invece deve essere:

Codice:
glVertexAttribPointer(vPosition, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
Stavo ignorando l'asse Z. Purtroppo avevo copiato quella riga da un altro esercizio in cui disegnavo un triangolo e quindi avevo coordinate su due dimensioni.
-Ivan- è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'' per spingere gli handheld gaming PC al massimo Lenovo Legion Go 2: Ryzen Z2 Extreme e OLED 8,8'...
AWS re:Invent 2025: inizia l'era dell'AI-as-a-Service con al centro gli agenti AWS re:Invent 2025: inizia l'era dell'AI-as-a-Se...
Cos'è la bolla dell'IA e perché se ne parla Cos'è la bolla dell'IA e perché se...
BOOX Palma 2 Pro in prova: l'e-reader diventa a colori, e davvero tascabile BOOX Palma 2 Pro in prova: l'e-reader diventa a ...
FRITZ!Repeater 1700 estende la rete super-veloce Wi-Fi 7 FRITZ!Repeater 1700 estende la rete super-veloce...
FSR 4 su Radeon RX 5000, 6000 e 7000? Li...
Quanti alberi ci sono in Skyrim? In The ...
Pocket Max, la nuova console Mangmi punt...
Pubblicato maxi backup di Spotify: 300 T...
GTA 6 potrebbe evolversi in un MMORPG, s...
Green Deal anche per i caldarrostai: a R...
BYD lancia la condivisione dei caricator...
L'Antitrust italiano colpisce Apple: san...
Lo Stato paga il conto: un miliardo di e...
Il furgone elettrico Kia PV5 alza l'asti...
Instagram introduce limite agli hashtag:...
Fortnite non arriverà sull'App Store gia...
IBM: dall’AI agentica ai dati in tempo r...
Vodafone ha la rete mobile migliore in I...
Lenovo Legion Go 2 con SteamOS: il debut...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 13:46.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Served by www3v