Jump to content
  • Advertisement
Sign in to follow this  
GhostRider03

CubeMap: How can I use samplerCube ?

This topic is 3657 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a problem to use the CubeMap Texture with samplerCube in the FragmentShader. As Example I use the VertexShader and the FragmentShader from here: http://www.gamedev.net/community/forums/topic.asp?topic_id=488668 Fragment Shader: --------------------------------------- uniform samplerCube CubeMap; varying vec3 vCubeMap; void main (void) { gl_FragColor = textureCube(CubeMap, vCubeMap); } --------------------------------------- But I don't know how to put the CubeMap Textures in samplerCube in Main. Can anyone help me?

Share this post


Link to post
Share on other sites
Advertisement
Are you binding the texture with glBindTexture(GL_TEXTURE_CUBE_MAP, ....)?

Here is more information
http://www.opengl.org/wiki/index.php/GLSL_:_common_mistakes

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
Are you binding the texture with glBindTexture(GL_TEXTURE_CUBE_MAP, ....)?


Yes, I binding the texture with glBindTexture, but it don't work. Maybe I have a trivial Bug in the Main-Routine.

glUseProgramObjectARB(shader_Rost); //Shader


//Aktivate the Textures
uniform = glGetUniformLocationARB(shader_Rost, "Rost");
glUniform1iARB(uniform, 0);

uniform = glGetUniformLocationARB(shader_Rost, "Rost_Bumpmap");
glUniform1iARB(uniform, 1);

uniform = glGetUniformLocationARB(shader_Rost, "depthTex");
glUniform1iARB(uniform, 2);

uniform = glGetUniformLocationARB(shader_Rost, "CubeMap");
glUniform1iARB(uniform, 3);

//Lightposition
uniform = glGetUniformLocationARB(shader_Rost, "lightPos");
glUniform4fARB(uniform, getLampX(), getLampY(), getLampZ(), 1.0f);

//Textures
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture[4]);

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, BumpMap[0]);

glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, depthTex);

glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_CUBE_MAP, texture[6]);

glPushMatrix();
Rostwuerfel();
glPopMatrix();


Share this post


Link to post
Share on other sites
From the stuff you posted, you seem to be talking about some other shader instead of that very basic shader you first posted. If the very basic shader doesn't work, then you have to give more information or post the entire code. Make sure your texcoords are correct. I could also recommend a library that generates geometry with the proper str coordinates for cube, sphere, etc. (glhlib)

Share this post


Link to post
Share on other sites

Yes, the stuff I posted was from the shader without the Cubemap. The shader was only a texture with Bump Mapping before. With the the both shader

Vertex shader:

varying vec3 vCubeMap;

void main()
{
vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);
vec3 vNormal = vec3(gl_NormalMatrix * gl_Normal);
vec3 vView = -normalize(vVertex);

vCubeMap = reflect(vView, vNormal);

gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}



Fragment shader:

uniform samplerCube CubeMap;
varying vec3 vCubeMap;

void main (void)
{
gl_FragColor = textureCube(CubeMap, vCubeMap);
}



the cube are black. I have changed the Fragment shader to

Fragment shader:

uniform samplerCube CubeMap;
varying vec3 vCubeMap;

void main (void)
{
vec3 vCubeMapTEST(1.0, 0.5, 1.0);
gl_FragColor = textureCube(CubeMap, vCubeMapTEST);
}



but the Cube ist permanent black. I think the CubeMap Textures are wrong with glBindTexture(GL_TEXTURE_CUBE_MAP, texture[6]).

But here is the complete Code, but the comments are German.



#include <stdlib.h>
#include "glut.h"
#include "Textures.h"
#include "Shader.h"
#include <iostream>
#include "glext.h"
#include <math.h>
using namespace std;

//Shader Variablen

GLhandleARB shader; //shader program
GLhandleARB vs; //vertex shader
GLhandleARB ps; //pixel shader

GLhandleARB shader_Silber; //shader program
GLhandleARB vs_Silber; //vertex shader
GLhandleARB ps_Silber; //pixel shader

GLhandleARB shader_Glas; //shader program
GLhandleARB vs_Glas; //vertex shader
GLhandleARB ps_Glas; //pixel shader

GLhandleARB shader_Rost; //shader program
GLhandleARB vs_Rost; //vertex shader
GLhandleARB ps_Rost; //pixel shader

GLhandleARB shader_Messing; //shader program
GLhandleARB vs_Messing; //vertex shader
GLhandleARB ps_Messing; //pixel shader

GLhandleARB shader_Holz; //shader program
GLhandleARB vs_Holz; //vertex shader
GLhandleARB ps_Holz; //pixel shader

GLhandleARB shader_Steinboden; //shader program
GLhandleARB vs_Steinboden; //vertex shader
GLhandleARB ps_Steinboden; //pixel shader

GLhandleARB shader_Glitzer; //shader program
GLhandleARB vs_Glitzer; //vertex shader
GLhandleARB ps_Glitzer; //pixel shader

//Handle für BumpMap Tangente
GLhandleARB prgmBMap;
GLuint BMapTangent;

// Model Methoden
extern void Tisch();
extern void Boden(GLfloat);
extern void Flaschenlampe(GLfloat X, GLfloat Y, GLfloat Z); //Taschenlampe ^^
extern void Silberwuerfel(GLuint BMapTangent);
extern void Rostwuerfel();
extern void Glaswuerfel();
extern void Messingwuerfel(GLuint BMapTangent);
extern void Steinboden();
extern void Skybox();

// Kamera Funktionen und Variablen
float fRotation; //Für Berechnung der Kamera Bewegung
float getCamX(); //Rückgabe des Kamera Wertes auf der X-Achse
float getCamZ(); //Rückgabe des Kamera Wertes auf der Z-Achse
float getCamY(); //Rückgabe des Kamera Wertes auf der Y-Achse
float fCamHigh; //Kamera Höhe
float fCamRadius;//Kamera Radius (Kleiner = Näher an Objekten / Größer = Weiter von den Objekten)

// Lampen Funktionen und Variablen
float getLampX(); //Rückgabe des Licht /Lampen Wertes auf der X-Achse
float getLampY(); //Rückgabe des Licht /Lampen Wertes auf der Y-Achse
float getLampZ(); //Rückgabe des Licht /Lampen Wertes auf der Z-Achse
float fRotationLamp; //Für Berechnung der Lampen Bewegung
float fLampHigh; //Lampen Höhe

// Kamerafahrt
bool CameraSelfMove;
bool CameraSelfMove_Up;
bool CameraSelfMove_Zoom;
void CameraMovement();

// Aktive Elemente
bool GlaswuerfelAktive;
bool MessingwuerfelAktive;
bool RostwuerfelAktive;
bool SilberwuerfelAktive;

// Aktiverung der Pfeiltasten
void pfeile(int a_keys, int x, int y);

// Methoden für Shadowmap
void shadowBegin(); //Beginn eines Shadowmap Model
void shadowEnd(); //Ende eines Shadowmap Model
void bauSchattenSzene(); //Baut die Szene für die Shadowmap
float proj[16];
float mv[16];
GLuint depthTex; //Datei um die Shadowmap als Textur zu speichern

GLuint BumpMap[9]; //Bumpmapping
GLuint texture[9];

//Extensions für Multitexturing
PFNGLACTIVETEXTUREPROC glActiveTexture; //Active Texture setzt aktive Textureinheit
PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f; //setzt 2d-texturkoordinaten einer textureinheit
PFNGLMULTITEXCOORD3FPROC glMultiTexCoord3f; //setzt 3d-texturkoordinaten einer textureinheit

extern PFNGLVERTEXATTRIB3FARBPROC glVertexAttrib3fARB;

//Extension functions
extern PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
extern PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
extern PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
extern PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
extern PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
extern PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
extern PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
extern PFNGLUNIFORM1IARBPROC glUniform1iARB;
extern PFNGLUNIFORM1FARBPROC glUniform1fARB;
extern PFNGLUNIFORM4FARBPROC glUniform4fARB;
extern PFNGLUNIFORM4FVARBPROC glUniform4fvARB;
extern PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
extern PFNGLVERTEXATTRIB4FARBPROC glVertexAttrib4fARB ;
extern PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB;
extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
extern PFNGLVALIDATEPROGRAMARBPROC glValidateProgramARB;

/*---------------------------------------------------------
// INIT
---------------------------------------------------------*/

void Init()
{
//////////// SHADER
glGenTextures(1, &depthTex);
glBindTexture(GL_TEXTURE_2D, depthTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,512,512, 0,GL_DEPTH_COMPONENT,GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);

//Variablen für Kamera und Licht setzen
fCamHigh = 1.0;
fRotation = 0;
fLampHigh = 0;
fCamRadius =7;

// Kamerafahrt
CameraSelfMove = false;
CameraSelfMove_Up = false;
CameraSelfMove_Zoom = false;

//Aktive Elemente
GlaswuerfelAktive = true;
MessingwuerfelAktive = true;
RostwuerfelAktive = true;
SilberwuerfelAktive = true;

//Adressen der Multitexturing-Funktionen setzen
glActiveTexture = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress("glActiveTexture");
glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2f");
glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC) wglGetProcAddress("glMultiTexCoord3f");

//Texturen laden
CreateTGATexture(&texture[0], "Textures//Holz.tga");
CreateTGATexture(&texture[1], "Textures//Silber.tga");
CreateTGATexture(&texture[2], "Textures//Glas.tga");
CreateTGATexture(&texture[3], "Textures//Messing.tga");
CreateTGATexture(&texture[4], "Textures//Rost.tga");
CreateTGATexture(&texture[5], "Textures//Steinboden.tga");
CreateTGATexture(&texture[6], "Textures//mauer.tga");

CreateTGATexture(&BumpMap[0], "Textures//Rost_normal.tga");
CreateTGATexture(&BumpMap[1], "Textures//Steinboden_normal.tga");
CreateTGATexture(&BumpMap[2], "Textures//Holz_normal.tga");
CreateTGATexture(&BumpMap[3], "Textures//Silber_normal.tga");
CreateTGATexture(&BumpMap[4], "Textures//Glas_normal.tga");
CreateTGATexture(&BumpMap[5], "Textures//Messing_normal.tga");
CreateTGATexture(&BumpMap[6], "Textures//mauer_normal.tga");

// OpenGL Settings
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);

glEnable(GL_DEPTH_TEST);
//glEnable(GL_TEXTURE_CUBE_MAP_EXT);
glDepthFunc(GL_LEQUAL);
glClearDepth(1.0f);

//Shader initialisieren
bool glslSupported = InitGLSL();
if(!glslSupported) cout<<"Error Initializing GLSL"<<endl;

//Shader laden
LoadShader(&shader, &vs, &ps, "Shader//Normal_VS.txt", "Shader//Normal_PS.txt");
LoadShader(&shader_Silber, &vs_Silber, &ps_Silber, "Shader//Silber_VS.txt", "Shader//Silber_PS.txt");
LoadShader(&shader_Glas, &vs_Glas, &ps_Glas, "Shader//Glas_VS.txt", "Shader//Glas_PS.txt");
LoadShader(&shader_Messing, &vs_Messing, &ps_Messing, "Shader//Messing_VS.txt", "Shader//Messing_PS.txt");
LoadShader(&shader_Rost, &vs_Rost, &ps_Rost, "Shader//Rost_VS.txt", "Shader//Rost_PS.txt");
LoadShader(&shader_Steinboden, &vs_Steinboden, &ps_Steinboden, "Shader//Steinboden_VS.txt", "Shader//Steinboden_PS.txt");
LoadShader(&shader_Holz, &vs_Holz, &ps_Holz, "Shader//Holz_VS.txt", "Shader//Holz_PS.txt");
//LoadShader(&shader_Glitzer, &vs_Glitzer, &ps_Glitzer, "Shader//Glitzer_VS.txt", "Shader//Glitzer_PS.txt");

//Lichtquellen Eigenschaften setzen
float lightambient[4] = {0.5,0.5,0.5,1.0};
glLightfv(GL_LIGHT0,GL_AMBIENT,lightambient);
float lightdiffuse[4] = {0.5,0.5,0.5,1.0};
glLightfv(GL_LIGHT0,GL_DIFFUSE,lightdiffuse);
float lightspecular[4] = {1.0,1.0,1.0,1.0};
glLightfv(GL_LIGHT0,GL_SPECULAR,lightspecular);
float lightposition[4] = {getLampX(), getLampY(), getLampZ(),1.0};
glLightfv(GL_LIGHT0,GL_POSITION,lightposition);
}

/*---------------------------------------------------------
// Render
---------------------------------------------------------*/

void Render(void)
{
//schaut ob automatische Kamera Bewegung an ist
if(CameraSelfMove)
CameraMovement(); // Setzt die neuen Kamera und Licht Positionen

//////////////////////////////////////////
// Shadowmap erzeugen
//////////////////////////////////////////
glViewport(0,0,512,512); //Setzt den Viewport auf 512x512 die größe der Shaowmap Textur
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Leert die Buffer
glLoadIdentity();
gluLookAt(getLampX(), getLampY(), getLampZ(), 0.0015f,0.001f,0.005f, 0,1,0); //setzt die Kamera auf Poistion der Lichtquelle

glGetFloatv(GL_MODELVIEW_MATRIX, mv);
glGetFloatv(GL_PROJECTION_MATRIX, proj);

bauSchattenSzene(); //baut die Szene nach

glBindTexture(GL_TEXTURE_2D, depthTex); //Bindet die Textur
glCopyTexImage2D(GL_TEXTURE_2D, 0,GL_DEPTH_COMPONENT, 0,0,512,512,0); //Speichert das Bild in die depthTex Textur

//////////////////////////////////////////
// Normale Szene erzeugen
//////////////////////////////////////////
glViewport(0, 0, 800, 600); //setzt den Viewport wieder zurück

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Leert die Buffer
glLoadIdentity();

gluLookAt(getCamX(), getCamY(), getCamZ(), 0.0, 0.25, 0.0, 0.0, 1.0, 0.0); //Position der Kamera
float lightposition[4] = {getLampX(), getLampY(), getLampZ(),1.0}; //Position der Lichtquelle
glLightfv(GL_LIGHT0,GL_POSITION,lightposition);

//shader aktivieren
glUseProgramObjectARB(shader);

//Tangente für Bump Mapping
BMapTangent=glGetAttribLocationARB(shader_Messing,"tangent");

int uniform;

///////////////////////////////
// Holztisch
///////////////////////////////
glUseProgramObjectARB(shader_Holz); //Shader für Holz

shadowBegin(); //Inititalisiert die Shadowmap



///////////////////////////////
// ROSTWÜRFEL
///////////////////////////////

glUseProgramObjectARB(shader_Rost); //Initialisiert den Shader für den Rostwürfel
float time = 1;

shadowBegin(); //Inititalisiert die Shadowmap

//Texturen dem Objekt bekannt machen
uniform = glGetUniformLocationARB(shader_Rost, "Rost");
glUniform1iARB(uniform, 0); //erstes bild kommt in erste textureinheit

uniform = glGetUniformLocationARB(shader_Rost, "Rost_Bumpmap");
glUniform1iARB(uniform, 1); //erstes bild kommt in erste textureinheit

uniform = glGetUniformLocationARB(shader_Rost, "depthTex");
glUniform1iARB(uniform, 2); //erstes bild kommt in erste textureinheit

uniform = glGetUniformLocationARB(shader_Rost, "CubeMap");
glUniform1iARB(uniform, 3); //erstes bild kommt in erste textureinheit

//Lichtposition bekannt machen
uniform = glGetUniformLocationARB(shader_Rost, "lightPos");
glUniform4fARB(uniform, getLampX(), getLampY(), getLampZ(), 1.0f);

//Aktivieren der Texturen
glActiveTexture(GL_TEXTURE0); //erste textureinheit aktivieren...
glBindTexture(GL_TEXTURE_2D, texture[4]); //...und die in die textur gerenderte szene binden

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, BumpMap[0]); //...und die in die textur gerenderte szene binden

glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, depthTex); //...und die in die textur gerenderte szene binden

glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_CUBE_MAP, texture[6]);

//Erstellt die Szene
glPushMatrix();
Rostwuerfel();
glPopMatrix();

shadowEnd(); //Beendet die Shadowmap

glActiveTexture(GL_TEXTURE0); //erste textureinheit aktivieren...

///////////////////////////////
// Steinboden
///////////////////////////////
glUseProgramObjectARB(shader_Steinboden); //Initialisiert den Shader für den Steinboden

shadowBegin(); //Inititalisiert die Shadowmap

//Texturen dem Objekt bekannt machen
uniform = glGetUniformLocationARB(shader_Steinboden, "Steinboden");
glUniform1iARB(uniform, 0); //erstes bild kommt in erste textureinheit

uniform = glGetUniformLocationARB(shader_Steinboden, "Steinboden_Bumpmap");
glUniform1iARB(uniform, 1); //erstes bild kommt in erste textureinheit

uniform = glGetUniformLocationARB(shader_Steinboden, "depthTex");
glUniform1iARB(uniform, 2); //erstes bild kommt in erste textureinheit

//Lichtposition bekannt machen
uniform = glGetUniformLocationARB(shader_Steinboden, "lightPos");
glUniform4fARB(uniform, getLampX(), getLampY(), getLampZ(), 1.0f);

//Aktivieren der Texturen
glActiveTexture(GL_TEXTURE0); //erste textureinheit aktivieren...
glBindTexture(GL_TEXTURE_2D, texture[5]); //...und die in die textur gerenderte szene binden

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, BumpMap[1]); //...und die in die textur gerenderte szene binden

glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, depthTex); //...und die in die textur gerenderte szene binden

//Erstellt die Szene
glPushMatrix();
Steinboden();
glPopMatrix();

shadowEnd(); //Beendet die Shadowmap

glActiveTexture(GL_TEXTURE0); //erste textureinheit aktivieren...

///////////////////////////////
// Skybox / Kellerwände
///////////////////////////////
glUseProgramObjectARB(shader); //Initialisiert den Shader für den Skybox

shadowBegin(); //Inititalisiert die Shadowmap

//Texturen dem Objekt bekannt machen
uniform = glGetUniformLocationARB(shader, "Skybox");
glUniform1iARB(uniform, 0); //erstes bild kommt in erste textureinheit

uniform = glGetUniformLocationARB(shader, "Skybox_Bumpmap");
glUniform1iARB(uniform, 1); //erstes bild kommt in erste textureinheit#

uniform = glGetUniformLocationARB(shader, "depthTex");
glUniform1iARB(uniform, 2); //erstes bild kommt in erste textureinheit

//Lichtposition bekannt machen
uniform = glGetUniformLocationARB(shader, "lightPos");
glUniform4fARB(uniform, getLampX(), getLampY(), getLampZ(), 1.0f);

//Aktivieren der Texturen
glActiveTexture(GL_TEXTURE0); //erste textureinheit aktivieren...
glBindTexture(GL_TEXTURE_2D, texture[6]); //...und die in die textur gerenderte szene binden

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, BumpMap[6]); //...und die in die textur gerenderte szene binden

glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, depthTex); //...und die in die textur gerenderte szene binden

//Erstellt die Szene
glPushMatrix();
Skybox();
glPopMatrix();

//Beendet die Shadowmap
shadowEnd();

glActiveTexture(GL_TEXTURE0); //erste textureinheit wieder aktivieren
///////////////////////////////
// Lampe
///////////////////////////////
glUseProgramObjectARB(shader); //Initialisiert den Shader für die Taschenlampe

//Texturen dem Objekt bekannt machen
glBindTexture(GL_TEXTURE_2D, texture[3]);

//Aktivieren der Texturen
glActiveTexture(GL_TEXTURE0); //erste textureinheit wieder aktivieren

//Erstellt die Szene
glPushMatrix();
Flaschenlampe(getLampX(),getLampY(),getLampZ());
glPopMatrix();

///////////////////////////////
// Stellt die Szene dar
///////////////////////////////
//shader deaktivieren
glUseProgramObjectARB(0);

glutSwapBuffers();

}

/*---------------------------------------------------------
// changeSize(int w, int h)
---------------------------------------------------------*/

void changeSize(int w, int h) {
if(h == 0)
h = 1;
float ratio = 1.0* w / h;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective (75.0f, float(w)/float(h), 0.1f, 400.0f);
glMatrixMode(GL_MODELVIEW);
}


/*---------------------------------------------------------
// Main
---------------------------------------------------------*/

int main(int argc, char **argv) {

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(800,600);
glutCreateWindow("Ich hab Hunger!");

Init();

glutDisplayFunc(Render);
glutReshapeFunc(changeSize);
glutIdleFunc(Render);
glutKeyboardFunc(processNormalKeys);
glutSpecialFunc(pfeile);

glutMainLoop();

return 0;
}


/*---------------------------------------------------------
// bauSchattenSzene() benötigt für die Shadowmap
---------------------------------------------------------*/

void bauSchattenSzene()
{
//Baut die Szene genauso auf wie in Render() aber ohne Texturen usw
//Da die Shadowmap dies nicht benötigt
glPushMatrix();
Tisch();
glPopMatrix();
if(GlaswuerfelAktive)
{
glPushMatrix();
Glaswuerfel();
glPopMatrix();
}
if(SilberwuerfelAktive)
{
glPushMatrix();
Silberwuerfel(BMapTangent);
glPopMatrix();
}
if(MessingwuerfelAktive)
{
glPushMatrix();
Messingwuerfel(BMapTangent);
glPopMatrix();
}
if(RostwuerfelAktive)
{
glPushMatrix();
Rostwuerfel();
glPopMatrix();
}
glPushMatrix();
Steinboden();
glPopMatrix();
glPushMatrix();
Skybox();
glPopMatrix();

}

/*---------------------------------------------------------
// shadowBegin() benötigt für die Shadowmap
---------------------------------------------------------*/

void shadowBegin()
{
glActiveTexture(GL_TEXTURE1);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, depthTex);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(0.5f,0.5f,0.5f);
glScalef(0.5f,0.5f,0.5f);
glMultMatrixf(proj);
glMultMatrixf(mv);
glMatrixMode(GL_MODELVIEW);
}

/*---------------------------------------------------------
// shadowEnd() benötigt für die Shadowmap
---------------------------------------------------------*/

void shadowEnd()
{
glActiveTexture(GL_TEXTURE2);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glActiveTexture(GL_TEXTURE0);
}

Share this post


Link to post
Share on other sites
It looks like texture[6] is not a cubemap
You are calling

CreateTGATexture(&texture[6], "Textures//mauer.tga");
glBindTexture(GL_TEXTURE_2D, texture[6]);

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
It looks like texture[6] is not a cubemap
You are calling

CreateTGATexture(&texture[6], "Textures//mauer.tga");
glBindTexture(GL_TEXTURE_2D, texture[6]);



And how do I make a cubemap? I know what a cubemap is, but I don't know do make a cubemap in GLSL.

[Edited by - GhostRider03 on June 15, 2008 2:29:16 PM]

Share this post


Link to post
Share on other sites
You should search for some tutorials or some example.
developer.nvidia.com has many examples.

It's not by making a 2D texture and binding it as a cubemap, that's for sure!

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
It's not by making a 2D texture and binding it as a cubemap, that's for sure!


I know that.

Quote:
Original post by V-man
You should search for some tutorials or some example.
developer.nvidia.com has many examples.


I had search in the Internet and found some tutorials like http://developer.nvidia.com/object/cube_map_ogl_tutorial.html (this is the best i found), but it don't help.
I had read two OpenGL and GLSL books and the only thing I know is the technical background about cubemaps. And now I search for a example to make a cubemap, but up to now without success.


V-man thanks for your help, even if it came to no result.

Share this post


Link to post
Share on other sites
You should work with the texture target GL_TEXTURE_CUBE_MAP_EXT instead of GL_TEXTURE_2D.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!